From 49a3eb441a7530d82b23128c5e0b00c4267ad0f5 Mon Sep 17 00:00:00 2001 From: naurril Date: Fri, 4 Aug 2017 22:48:03 +0800 Subject: [PATCH 001/437] Add int64_t typemap for swig --- tensorflow/python/platform/base.i | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tensorflow/python/platform/base.i b/tensorflow/python/platform/base.i index aa33eb52c9..dbefca2be9 100644 --- a/tensorflow/python/platform/base.i +++ b/tensorflow/python/platform/base.i @@ -106,6 +106,10 @@ limitations under the License. $1 = &temp; } +%typemap(out) int64_t { + $result = PyLong_FromLongLong($1); +} + %typemap(out) string { $result = PyBytes_FromStringAndSize($1.data(), $1.size()); } -- GitLab From 3b6d5d9df888181e5fb5a49885c0d4eb0b58c5eb Mon Sep 17 00:00:00 2001 From: Dan Jarvis Date: Thu, 23 Nov 2017 12:43:24 -0500 Subject: [PATCH 002/437] Update .gitignore files for Android Studio Without these, Git shows lots of noisy build/IDE config files. These files are based on these two sources (plus the list of added files that Git shows when I build in Android Studio): https://github.com/github/gitignore/blob/master/Android.gitignore https://github.com/github/gitignore/pull/2103/files --- tensorflow/contrib/lite/java/demo/.gitignore | 28 ++++++++++++++++--- tensorflow/examples/android/.gitignore | 29 ++++++++++++++++++++ 2 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 tensorflow/examples/android/.gitignore diff --git a/tensorflow/contrib/lite/java/demo/.gitignore b/tensorflow/contrib/lite/java/demo/.gitignore index 39fb081a42..d245ab6109 100644 --- a/tensorflow/contrib/lite/java/demo/.gitignore +++ b/tensorflow/contrib/lite/java/demo/.gitignore @@ -1,9 +1,29 @@ +# This file is based on https://github.com/github/gitignore/blob/master/Android.gitignore *.iml +.idea/compiler.xml +.idea/copyright +.idea/dictionaries +.idea/gradle.xml +.idea/libraries +.idea/inspectionProfiles +.idea/misc.xml +.idea/modules.xml +.idea/runConfigurations.xml +.idea/tasks.xml +.idea/workspace.xml .gradle -/local.properties -/.idea/workspace.xml -/.idea/libraries +local.properties .DS_Store -/build +build/ +gradleBuild/ +*.apk +*.ap_ +*.dex +*.class +bin/ +gen/ +out/ +*.log +.navigation/ /captures .externalNativeBuild diff --git a/tensorflow/examples/android/.gitignore b/tensorflow/examples/android/.gitignore new file mode 100644 index 0000000000..d245ab6109 --- /dev/null +++ b/tensorflow/examples/android/.gitignore @@ -0,0 +1,29 @@ +# This file is based on https://github.com/github/gitignore/blob/master/Android.gitignore +*.iml +.idea/compiler.xml +.idea/copyright +.idea/dictionaries +.idea/gradle.xml +.idea/libraries +.idea/inspectionProfiles +.idea/misc.xml +.idea/modules.xml +.idea/runConfigurations.xml +.idea/tasks.xml +.idea/workspace.xml +.gradle +local.properties +.DS_Store +build/ +gradleBuild/ +*.apk +*.ap_ +*.dex +*.class +bin/ +gen/ +out/ +*.log +.navigation/ +/captures +.externalNativeBuild -- GitLab From 6f1a30c2589e2b9adf3d34a4d87fb280b2e6b149 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Tue, 3 Apr 2018 23:44:22 +0000 Subject: [PATCH 003/437] Add RecordInput documentation to tf.contrib.framework This fix tries to address the issue raised in 10622 where the RecordInput is not available in the documentation. As was suggested in 10622, this fix exposes RecordInput to tf.contrib (tf.contrib.framework) so that docs could shown up. This fix fixes 10622. Signed-off-by: Yong Tang --- tensorflow/contrib/framework/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tensorflow/contrib/framework/__init__.py b/tensorflow/contrib/framework/__init__.py index 11397e86bd..5435c98978 100644 --- a/tensorflow/contrib/framework/__init__.py +++ b/tensorflow/contrib/framework/__init__.py @@ -119,6 +119,7 @@ from tensorflow.python.framework.smart_cond import smart_constant_value from tensorflow.python.framework.tensor_spec import BoundedTensorSpec from tensorflow.python.framework.tensor_spec import TensorSpec from tensorflow.python.ops.array_ops import broadcast_to +from tensorflow.python.ops.data_flow_ops import RecordInput from tensorflow.python.ops.init_ops import convolutional_delta_orthogonal from tensorflow.python.ops.init_ops import convolutional_orthogonal_1d from tensorflow.python.ops.init_ops import convolutional_orthogonal_2d -- GitLab From 5dc8f313b1808ae893edb3b8b03ba06ce4968437 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Tue, 3 Apr 2018 23:47:02 +0000 Subject: [PATCH 004/437] Add `@@RecordInput` so that docs could be exposed After this change and run with: ``` bazel run tools/docs:generate -- --src_dir="$(pwd)/docs_src/" --output_dir=/tmp/tfdocs/ ``` The documentation correctly shown up in: `/tmp/tfdocs/api_docs/python/tf/contrib/framework/RecordInput.md` Signed-off-by: Yong Tang --- tensorflow/contrib/framework/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tensorflow/contrib/framework/__init__.py b/tensorflow/contrib/framework/__init__.py index 5435c98978..ffcfd6961e 100644 --- a/tensorflow/contrib/framework/__init__.py +++ b/tensorflow/contrib/framework/__init__.py @@ -100,6 +100,8 @@ See the @{$python/contrib.framework} guide. @@BoundedTensorSpec @@TensorSpec + +@@RecordInput """ from __future__ import absolute_import -- GitLab From 37f71fd3a983d0bacab4ecd96679f7d55202dd28 Mon Sep 17 00:00:00 2001 From: Nehal J Wani Date: Fri, 27 Apr 2018 15:12:59 -0500 Subject: [PATCH 005/437] Update is_windows() to allow mingw shells --- tensorflow/tools/pip_package/build_pip_package.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/tools/pip_package/build_pip_package.sh b/tensorflow/tools/pip_package/build_pip_package.sh index 8f0cf8c3d1..9108eb4f6f 100755 --- a/tensorflow/tools/pip_package/build_pip_package.sh +++ b/tensorflow/tools/pip_package/build_pip_package.sh @@ -34,7 +34,7 @@ function cp_external() { PLATFORM="$(uname -s | tr 'A-Z' 'a-z')" function is_windows() { # On windows, the shell script is actually running in msys - if [[ "${PLATFORM}" =~ msys_nt* ]]; then + if [[ "${PLATFORM}" =~ (mingw64|msys)_nt* ]]; then true else false -- GitLab From 6c62fa93ad22594c65e1b3f7aecce79da660f5e9 Mon Sep 17 00:00:00 2001 From: Andy Craze Date: Sat, 23 Dec 2017 18:39:49 -0800 Subject: [PATCH 006/437] update _DECORATED_OPS for each latest call This fixes a race condition where `add_arg_scope` doesn't reliably extract the arg list. fixes #11923 --- tensorflow/contrib/framework/python/ops/arg_scope.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tensorflow/contrib/framework/python/ops/arg_scope.py b/tensorflow/contrib/framework/python/ops/arg_scope.py index 5b15033995..ebe5bade23 100644 --- a/tensorflow/contrib/framework/python/ops/arg_scope.py +++ b/tensorflow/contrib/framework/python/ops/arg_scope.py @@ -103,9 +103,8 @@ def _kwarg_names(func): def _add_op(op): - key = arg_scope_func_key(op) - if key not in _DECORATED_OPS: - _DECORATED_OPS[key] = _kwarg_names(op) + key_op = _key_op(op) + _DECORATED_OPS[key_op] = _kwarg_names(op) @tf_contextlib.contextmanager -- GitLab From dea558b2f9dd27ae974a691a5d99fd96030dafb5 Mon Sep 17 00:00:00 2001 From: accraze Date: Sun, 15 Apr 2018 16:28:12 -0700 Subject: [PATCH 007/437] adding arg scope test --- .../framework/python/ops/arg_scope_test.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tensorflow/contrib/framework/python/ops/arg_scope_test.py b/tensorflow/contrib/framework/python/ops/arg_scope_test.py index 4c3879d4fc..c58ff603f8 100644 --- a/tensorflow/contrib/framework/python/ops/arg_scope_test.py +++ b/tensorflow/contrib/framework/python/ops/arg_scope_test.py @@ -38,6 +38,12 @@ def func3(args, a=None, b=1, c=2): """Some cool doc string.""" return (args, a, b, c) +@add_arg_scope +def func4(x='x', y='y'): + if x: + pass + if y: + pass def _key_op(op): return getattr(op, '_key_op', str(op)) @@ -231,6 +237,15 @@ class ArgScopeTest(test.TestCase): self.assertTupleEqual(args, func2_args) self.assertDictEqual(kwargs, func2_kwargs) + def testAddArgScopeRaceCondition(self): + func4_kwargs = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h') + for i in range(4): + # redefine the function with different args + @add_arg_scope + def func4(a=1, b=2, c=3, d=4, e=5, f=6, g=7, h=8): + pass + self.assertTupleEqual(arg_scoped_arguments(func4), func4_kwargs) + def testDocString(self): self.assertEqual(func3.__doc__, 'Some cool doc string.') -- GitLab From ad4cb2d268bd90c81525418d03ebb31aae3d80f3 Mon Sep 17 00:00:00 2001 From: tucan9389 Date: Wed, 9 May 2018 00:32:19 +0900 Subject: [PATCH 008/437] Just fix little issue that is model_file_type variable but not using it. --- .../lite/examples/ios/camera/CameraExampleViewController.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/contrib/lite/examples/ios/camera/CameraExampleViewController.mm b/tensorflow/contrib/lite/examples/ios/camera/CameraExampleViewController.mm index d74e275f04..30fee64a6f 100644 --- a/tensorflow/contrib/lite/examples/ios/camera/CameraExampleViewController.mm +++ b/tensorflow/contrib/lite/examples/ios/camera/CameraExampleViewController.mm @@ -315,7 +315,7 @@ static void GetTopN(const uint8_t* prediction, const int prediction_size, const labelLayers = [[NSMutableArray alloc] init]; oldPredictionValues = [[NSMutableDictionary alloc] init]; - NSString* graph_path = FilePathForResourceName(model_file_name, @"tflite"); + NSString* graph_path = FilePathForResourceName(model_file_name, model_file_type); model = tflite::FlatBufferModel::BuildFromFile([graph_path UTF8String]); if (!model) { LOG(FATAL) << "Failed to mmap model " << graph_path; -- GitLab From 1a181b9e079b67a8695850b15a4bf54c6472b83c Mon Sep 17 00:00:00 2001 From: accraze Date: Thu, 10 May 2018 09:23:07 -0700 Subject: [PATCH 009/437] use arg_scope_func_key instead of _key_op fn name --- tensorflow/contrib/framework/python/ops/arg_scope.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/contrib/framework/python/ops/arg_scope.py b/tensorflow/contrib/framework/python/ops/arg_scope.py index ebe5bade23..0a02e76a26 100644 --- a/tensorflow/contrib/framework/python/ops/arg_scope.py +++ b/tensorflow/contrib/framework/python/ops/arg_scope.py @@ -103,7 +103,7 @@ def _kwarg_names(func): def _add_op(op): - key_op = _key_op(op) + key_op = arg_scope_func_key(op) _DECORATED_OPS[key_op] = _kwarg_names(op) -- GitLab From 28727ba97c1b3d2987b96a51061f735157ebabf6 Mon Sep 17 00:00:00 2001 From: Guozhong Zhuang Date: Fri, 18 May 2018 11:40:08 -0700 Subject: [PATCH 010/437] enhancement with BatchNorm primitive reuse --- tensorflow/core/kernels/mkl_conv_ops.cc | 280 +++--- .../core/kernels/mkl_fused_batch_norm_op.cc | 904 +++++++++++++----- tensorflow/core/util/mkl_util.h | 59 +- 3 files changed, 858 insertions(+), 385 deletions(-) diff --git a/tensorflow/core/kernels/mkl_conv_ops.cc b/tensorflow/core/kernels/mkl_conv_ops.cc index f2b14f1278..c032add82e 100644 --- a/tensorflow/core/kernels/mkl_conv_ops.cc +++ b/tensorflow/core/kernels/mkl_conv_ops.cc @@ -59,7 +59,8 @@ namespace tensorflow { #ifndef INTEL_MKL_ML -struct ConvFwdDimensions { +// This structure aggregates multiple inputs to Conv2DFwd* methods. +struct MklConvFwdParams { memory::dims src_dims; memory::dims filter_dims; memory::dims bias_dims; @@ -69,7 +70,7 @@ struct ConvFwdDimensions { memory::dims padding_left; memory::dims padding_right; - ConvFwdDimensions(memory::dims src_dims, + MklConvFwdParams(memory::dims src_dims, memory::dims filter_dims, memory::dims bias_dims, memory::dims dst_dims, memory::dims strides, memory::dims dilations, memory::dims padding_left, @@ -82,35 +83,40 @@ struct ConvFwdDimensions { }; template -class Conv2DFwd : public DnnOp { +class MklConv2DFwdPrimitive: public MklPrimitive { public: - explicit Conv2DFwd(const ConvFwdDimensions& convFwdDims) { - fwd_stream_.reset(new stream(stream::kind::eager)); + explicit MklConv2DFwdPrimitive(const MklConvFwdParams& convFwdDims) { + context_.fwd_stream.reset(new stream(stream::kind::eager)); // create conv primitive - if (conv_fwd_ == nullptr) { + if (context_.conv_fwd == nullptr) { Setup(convFwdDims); } } - ~Conv2DFwd() {} + ~MklConv2DFwdPrimitive() {} // Convolution forward execute with bias // src_data: input data buffer of src // filter_data: input data buffer of filter (weights) // bias_data: input data buffer of bias // dst_data: output data buffer of dst - void Execute(T* src_data, T* filter_data, T* bias_data, T* dst_data) { - src_mem_->set_data_handle(static_cast(src_data)); - filter_mem_->set_data_handle(static_cast(filter_data)); - bias_mem_->set_data_handle(static_cast(bias_data)); - dst_mem_->set_data_handle(static_cast(dst_data)); - fwd_stream_->submit(fwd_primitives_); + void Execute(const T* src_data, const T* filter_data, + const T* bias_data, const T* dst_data) { + context_.src_mem->set_data_handle( + static_cast(const_cast(src_data))); + context_.filter_mem->set_data_handle( + static_cast(const_cast(filter_data))); + context_.bias_mem->set_data_handle( + static_cast(const_cast(bias_data))); + context_.dst_mem->set_data_handle( + static_cast(const_cast(dst_data))); + context_.fwd_stream->submit(context_.fwd_primitives); // after exec, set data handle back - src_mem_->set_data_handle(DummyData); - filter_mem_->set_data_handle(DummyData); - bias_mem_->set_data_handle(DummyData); - dst_mem_->set_data_handle(DummyData); + context_.src_mem->set_data_handle(DummyData); + context_.filter_mem->set_data_handle(DummyData); + context_.bias_mem->set_data_handle(DummyData); + context_.dst_mem->set_data_handle(DummyData); return; } @@ -119,139 +125,174 @@ class Conv2DFwd : public DnnOp { // src_data: input data buffer of src // filter_data: input data buffer of filter (weights) // dst_data: output data buffer of dst - void Execute(T* src_data, T* filter_data, T* dst_data) { - src_mem_->set_data_handle(static_cast(src_data)); - filter_mem_->set_data_handle(static_cast(filter_data)); - dst_mem_->set_data_handle(static_cast(dst_data)); - fwd_stream_->submit(fwd_primitives_); - - // after exec, set data handle back - src_mem_->set_data_handle(DummyData); - filter_mem_->set_data_handle(DummyData); - dst_mem_->set_data_handle(DummyData); + void Execute(const T* src_data, const T* filter_data, + const T* dst_data) { + context_.src_mem->set_data_handle( + static_cast(const_cast(src_data))); + context_.filter_mem->set_data_handle( + static_cast(const_cast(filter_data))); + context_.dst_mem->set_data_handle( + static_cast(const_cast(dst_data))); + context_.fwd_stream->submit(context_.fwd_primitives); + + // after execution, set data handle back + context_.src_mem->set_data_handle(DummyData); + context_.filter_mem->set_data_handle(DummyData); + context_.dst_mem->set_data_handle(DummyData); return; } - // expected memory format for this primitive instance - memory::format src_fmt_; - memory::format filter_fmt_; + memory::format GetSrcMemoryFormat() const { + return context_.src_fmt; + } + + memory::format GetFilterMemoryFormat() const { + return context_.filter_fmt; + } - // convolution primitive - std::shared_ptr fwd_pd_; - std::shared_ptr conv_fwd_; + std::shared_ptr + GetPrimitiveDesc() const { + return context_.fwd_pd; + } private: - void Setup(const ConvFwdDimensions& convFwdDims) { + // Primitive reuse context for Conv2D Fwd op + struct ConvFwdContext { + // expected memory format for this primitive instance + memory::format src_fmt; + memory::format filter_fmt; + + // MKLDNN memory + std::shared_ptr src_mem; + std::shared_ptr filter_mem; + std::shared_ptr bias_mem; + std::shared_ptr dst_mem; + + // desc & prmitive desc + std::shared_ptr fwd_desc; + + // memory desc + std::shared_ptr src_md; + std::shared_ptr filter_md; + std::shared_ptr bias_md; + std::shared_ptr dst_md; + + // convolution primitive + std::shared_ptr fwd_pd; + std::shared_ptr conv_fwd; + + std::shared_ptr fwd_stream; + std::vector fwd_primitives; + + ConvFwdContext() : + src_fmt(memory::format::any), filter_fmt(memory::format::any), + src_mem(nullptr), filter_mem(nullptr), bias_mem(nullptr), + dst_mem(nullptr), fwd_desc(nullptr), + src_md(nullptr), filter_md(nullptr), bias_md(nullptr), + fwd_pd(nullptr), conv_fwd(nullptr), fwd_stream(nullptr) { + } + } context_; + + engine cpu_engine_ = engine(engine::cpu, 0); + + void Setup(const MklConvFwdParams& convFwdDims) { // create memory descriptors for convolution data w/ no specified format - src_md_.reset(new memory::desc({convFwdDims.src_dims}, + context_.src_md.reset(new memory::desc({convFwdDims.src_dims}, MklDnnType(), memory::format::any)); - filter_md_.reset(new memory::desc({convFwdDims.filter_dims}, + context_.filter_md.reset(new memory::desc({convFwdDims.filter_dims}, MklDnnType(), memory::format::any)); - dst_md_.reset(new memory::desc({convFwdDims.dst_dims}, + context_.dst_md.reset(new memory::desc({convFwdDims.dst_dims}, MklDnnType(), memory::format::any)); if (!convFwdDims.bias_dims.empty()) - bias_md_.reset(new memory::desc({convFwdDims.bias_dims}, + context_.bias_md.reset(new memory::desc({convFwdDims.bias_dims}, MklDnnType(), memory::format::any)); // create a convolution if (!convFwdDims.bias_dims.empty()) { - fwd_desc_.reset(new convolution_forward::desc(prop_kind::forward, - convolution_direct, *src_md_, *filter_md_, *bias_md_, *dst_md_, + context_.fwd_desc.reset(new convolution_forward::desc(prop_kind::forward, + convolution_direct, *context_.src_md, *context_.filter_md, + *context_.bias_md, *context_.dst_md, convFwdDims.strides, convFwdDims.dilations, convFwdDims.padding_left, convFwdDims.padding_right, padding_kind::zero)); } else { - fwd_desc_.reset(new convolution_forward::desc(prop_kind::forward, - convolution_direct, *src_md_, *filter_md_, *dst_md_, - convFwdDims.strides, convFwdDims.dilations, convFwdDims.padding_left, - convFwdDims.padding_right, padding_kind::zero)); + context_.fwd_desc.reset(new convolution_forward::desc(prop_kind::forward, + convolution_direct, *context_.src_md, *context_.filter_md, + *context_.dst_md, convFwdDims.strides, convFwdDims.dilations, + convFwdDims.padding_left, convFwdDims.padding_right, + padding_kind::zero)); } - fwd_pd_.reset(new convolution_forward::primitive_desc( - *fwd_desc_, cpu_engine_)); + context_.fwd_pd.reset(new convolution_forward::primitive_desc( + *context_.fwd_desc, cpu_engine_)); // store the expected memory format - src_fmt_ = static_cast( - fwd_pd_.get()->src_primitive_desc().desc().data.format); + context_.src_fmt = static_cast( + context_.fwd_pd.get()->src_primitive_desc().desc().data.format); - filter_fmt_ = static_cast( - fwd_pd_.get()->weights_primitive_desc().desc().data.format); + context_.filter_fmt = static_cast( + context_.fwd_pd.get()->weights_primitive_desc().desc().data.format); // create memory primitive based on dummy data - src_mem_.reset(new memory(fwd_pd_.get()->src_primitive_desc(), DummyData)); - filter_mem_.reset(new memory(fwd_pd_.get()->weights_primitive_desc(), - DummyData)); - dst_mem_.reset(new memory(fwd_pd_.get()->dst_primitive_desc(), DummyData)); + context_.src_mem.reset(new memory( + context_.fwd_pd.get()->src_primitive_desc(), DummyData)); + context_.filter_mem.reset(new memory( + context_.fwd_pd.get()->weights_primitive_desc(), DummyData)); + context_.dst_mem.reset(new memory( + context_.fwd_pd.get()->dst_primitive_desc(), DummyData)); // create convolution primitive and add it to net if (!convFwdDims.bias_dims.empty()) { - bias_mem_.reset(new memory({{{convFwdDims.bias_dims}, MklDnnType(), - memory::format::x}, cpu_engine_}, DummyData)); - conv_fwd_.reset(new convolution_forward(*fwd_pd_, *src_mem_, - *filter_mem_, *bias_mem_, *dst_mem_)); + context_.bias_mem.reset(new memory({{{convFwdDims.bias_dims}, + MklDnnType(), memory::format::x}, cpu_engine_}, DummyData)); + context_.conv_fwd.reset(new convolution_forward( + *context_.fwd_pd, *context_.src_mem, *context_.filter_mem, + *context_.bias_mem, *context_.dst_mem)); } else { - conv_fwd_.reset(new convolution_forward(*fwd_pd_, *src_mem_, - *filter_mem_, *dst_mem_)); + context_.conv_fwd.reset(new convolution_forward( + *context_.fwd_pd, *context_.src_mem, + *context_.filter_mem, *context_.dst_mem)); } - fwd_primitives_.push_back(*conv_fwd_); + context_.fwd_primitives.push_back(*context_.conv_fwd); return; } - - // MKLDNN memory - std::shared_ptr src_mem_; - std::shared_ptr filter_mem_; - std::shared_ptr bias_mem_; - std::shared_ptr dst_mem_; - - std::shared_ptr fwd_stream_; - std::vector fwd_primitives_; - - // desc & prmitive desc - std::shared_ptr fwd_desc_; - - // memory desc - std::shared_ptr src_md_; - std::shared_ptr filter_md_; - std::shared_ptr bias_md_; - std::shared_ptr dst_md_; - - engine cpu_engine_ = engine(engine::cpu, 0); }; template -class Conv2DFwdFactory : public DnnOpFactory { +class MklConv2DFwdPrimitiveFactory : public MklPrimitiveFactory { public: - static Conv2DFwd* Get(const ConvFwdDimensions& convFwdDims) { - Conv2DFwd* conv2d_fwd = nullptr; + static MklConv2DFwdPrimitive* Get(const MklConvFwdParams& convFwdDims) { + MklConv2DFwdPrimitive* conv2d_fwd = nullptr; // try to find a suitable one in pool - conv2d_fwd = dynamic_cast*> ( - Conv2DFwdFactory::GetInstance().GetConv2DFwd(convFwdDims)); + conv2d_fwd = dynamic_cast*> ( + MklConv2DFwdPrimitiveFactory::GetInstance().GetConv2DFwd( + convFwdDims)); if (conv2d_fwd == nullptr) { - conv2d_fwd = new Conv2DFwd(convFwdDims); - Conv2DFwdFactory::GetInstance().SetConv2DFwd( + conv2d_fwd = new MklConv2DFwdPrimitive(convFwdDims); + MklConv2DFwdPrimitiveFactory::GetInstance().SetConv2DFwd( convFwdDims, conv2d_fwd); } return conv2d_fwd; } private: - Conv2DFwdFactory() {} - ~Conv2DFwdFactory() {} + MklConv2DFwdPrimitiveFactory() {} + ~MklConv2DFwdPrimitiveFactory() {} static const int kDilationH = 0, kDilationW = 1; - static Conv2DFwdFactory& GetInstance() { - static Conv2DFwdFactory instance_; + static MklConv2DFwdPrimitiveFactory& GetInstance() { + static MklConv2DFwdPrimitiveFactory instance_; return instance_; } - static std::string CreateKey(const ConvFwdDimensions& convFwdDims) { + static std::string CreateKey(const MklConvFwdParams& convFwdDims) { std::string prefix = "conv2d_fwd_"; FactoryKeyCreator key_creator; key_creator.AddAsKey(prefix); @@ -266,12 +307,12 @@ class Conv2DFwdFactory : public DnnOpFactory { return key_creator.GetKey(); } - DnnOp* GetConv2DFwd(const ConvFwdDimensions& convFwdDims) { + MklPrimitive* GetConv2DFwd(const MklConvFwdParams& convFwdDims) { std::string key = CreateKey(convFwdDims); return this->GetOp(key); } - void SetConv2DFwd(const ConvFwdDimensions& convFwdDims, DnnOp *op) { + void SetConv2DFwd(const MklConvFwdParams& convFwdDims, MklPrimitive *op) { std::string key = CreateKey(convFwdDims); this->SetOp(key, op); } @@ -762,7 +803,6 @@ class MklConv2DOp : public OpKernel { MklDnnData src(&cpu_engine); MklDnnData filter(&cpu_engine); - MklDnnData dst(&cpu_engine); // output memory::dims src_dims, filter_dims, padding_left, padding_right, dilations, strides; @@ -812,7 +852,6 @@ class MklConv2DOp : public OpKernel { auto src_md = src_mkl_shape.IsMklTensor() ? src_mkl_shape.GetMklLayout() : memory::desc(src_dims, MklDnnType(), tf_fmt); - src.SetUsrMem(src_md, &src_tensor); // Although filter shape (filter_dims) required is in MKL-DNN order, // the layout is Tensorflow's layout (HWIO). @@ -820,29 +859,28 @@ class MklConv2DOp : public OpKernel { ? filter_mkl_shape.GetMklLayout() : memory::desc(filter_dims, MklDnnType(), memory::format::hwio); - filter.SetUsrMem(filter_md, &filter_tensor); // MKLDNN dilation starts from 0. dilations[kDilationH] -= 1; dilations[kDilationW] -= 1; // get a conv2d fwd from primitive pool - Conv2DFwd *conv2d_fwd = nullptr; + MklConv2DFwdPrimitive *conv2d_fwd = nullptr; if (biasEnabled) { memory::dims bias_dims = {}; conv_utl.GetBiasSizeInMklOrder(kInputIndex_Bias, &bias_dims); - ConvFwdDimensions convFwdDims(src_dims, filter_dims, bias_dims, + MklConvFwdParams convFwdDims(src_dims, filter_dims, bias_dims, dst_dims_mkl_order, strides, dilations, padding_left, padding_right); - conv2d_fwd = Conv2DFwdFactory::Get(convFwdDims); + conv2d_fwd = MklConv2DFwdPrimitiveFactory::Get(convFwdDims); } else { - ConvFwdDimensions convFwdDims(src_dims, filter_dims, NONE_DIMS, + MklConvFwdParams convFwdDims(src_dims, filter_dims, NONE_DIMS, dst_dims_mkl_order, strides, dilations, padding_left, padding_right); - conv2d_fwd = Conv2DFwdFactory::Get(convFwdDims); + conv2d_fwd = MklConv2DFwdPrimitiveFactory::Get(convFwdDims); } // allocate output tensors output_tensor and filter_out_tensor std::shared_ptr - conv_fwd_pd = conv2d_fwd->fwd_pd_; + conv_fwd_pd = conv2d_fwd->GetPrimitiveDesc(); AllocateOutputTensor(context, *conv_fwd_pd, dst_dims_mkl_order, tf_fmt, &dst_tensor); Tensor* filter_out_tensor = nullptr; @@ -854,20 +892,30 @@ class MklConv2DOp : public OpKernel { // check whether src/filter need reorder std::vector net; - if (src_md.data.format != conv2d_fwd->src_fmt_) - src.CheckReorderToOpMem( - conv_fwd_pd.get()->src_primitive_desc(), &net); - - if (filter_md.data.format != conv2d_fwd->filter_fmt_) - filter.CheckReorderToOpMem( - conv_fwd_pd.get()->weights_primitive_desc(), - filter.GetTensorBuffer(filter_out_tensor), &net); + T *src_data = nullptr; + if (src_md.data.format != conv2d_fwd->GetSrcMemoryFormat()) { + src.SetUsrMem(src_md, &src_tensor); + src.CheckReorderToOpMem( + conv_fwd_pd.get()->src_primitive_desc(), &net); + src_data = static_cast(src.GetOpMem().get_data_handle()); + } else { + src_data = static_cast(const_cast( + src_tensor.flat().data())); + } + T *filter_data = nullptr; + if (filter_md.data.format != conv2d_fwd->GetFilterMemoryFormat()) { + filter.SetUsrMem(filter_md, &filter_tensor); + filter.CheckReorderToOpMem( + conv_fwd_pd.get()->weights_primitive_desc(), + filter.GetTensorBuffer(filter_out_tensor), &net); + filter_data = static_cast(filter.GetOpMem().get_data_handle()); + } else { + filter_data = static_cast(const_cast( + filter_tensor.flat().data())); + } + stream(stream::kind::eager).submit(net).wait(); - T* src_data = static_cast( - src.GetOpMem().get_data_handle()); - T* filter_data = static_cast( - filter.GetOpMem().get_data_handle()); // execute convolution if (biasEnabled) { diff --git a/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc b/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc index 62aafa7930..f4f6f8457d 100644 --- a/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc +++ b/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc @@ -262,6 +262,7 @@ class MklFusedBatchNormOp : public OpKernel { } void MklCreateInputLayout(OpKernelContext* context) { + const Tensor& input = MklGetInput(context, 0); bool input_in_mkl_format = mkl_shape_input_shape.IsMklTensor(); if (input_in_mkl_format) { mkl_lt_input = @@ -544,6 +545,7 @@ class MklFusedBatchNormGradOp : public OpKernel { } void MklCreateInputLayout(OpKernelContext* context) { + const Tensor& input = MklGetInput(context, 0); bool input_in_mkl_format = mkl_shape_input_shape.IsMklTensor(); if (input_in_mkl_format) { mkl_lt_input = @@ -684,6 +686,465 @@ class MklFusedBatchNormGradOp : public OpKernel { #ifndef INTEL_MKL_ML +struct MklBatchNormFwdParams { + memory::dims src_dims; + int depth; + float eps; + bool training; + + MklBatchNormFwdParams(const memory::dims &src_dims, + int depth, float eps, bool training) : src_dims(src_dims), + depth(depth), eps(eps), training(training) { + } +}; + +template +class MklFusedBatchNormFwdPrimitive : public MklPrimitive { + public: + explicit MklFusedBatchNormFwdPrimitive( + const MklBatchNormFwdParams& fwdParams) { + context_.fwd_stream.reset( + new mkldnn::stream(mkldnn::stream::kind::eager)); + if (context_.bn_fwd == nullptr) + Setup(fwdParams); + } + + ~MklFusedBatchNormFwdPrimitive() {} + + // BatchNormalization forward execute + // src_data: input data buffer of src + // weights_data: input data buffer of weights + // dst_data: output data buffer of dst + // mean_data: input data buffer of means + // variance_data: input data buffer of variances + void Execute(const T* src_data, const T* weights_data, const T* dst_data, + const T* mean_data, const T* variance_data) { + context_.src_mem->set_data_handle( + static_cast(const_cast(src_data))); + context_.dst_mem->set_data_handle( + static_cast(const_cast(dst_data))); + + if (context_.flags & use_scale_shift) + context_.weights_mem->set_data_handle( + static_cast(const_cast(weights_data))); + + if ((context_.pkind == prop_kind::forward_training) || + (context_.flags & use_global_stats)) { + context_.mean_mem->set_data_handle( + static_cast(const_cast(mean_data))); + context_.variance_mem->set_data_handle( + static_cast(const_cast(variance_data))); + } + + // execution + context_.fwd_stream->submit(context_.fwd_primitives); + + context_.src_mem->set_data_handle(DummyData); + context_.dst_mem->set_data_handle(DummyData); + + if (context_.flags & use_scale_shift) + context_.weights_mem->set_data_handle(DummyData); + + if ((context_.pkind == prop_kind::forward_training) || + (context_.flags & use_global_stats)) { + context_.mean_mem->set_data_handle(DummyData); + context_.variance_mem->set_data_handle(DummyData); + } + return; + } + + memory::primitive_desc GetDstPd() const { + return (*context_.dst_mem).get_primitive_desc(); + } + + mkldnn_memory_format_t GetSrcFmt() const { + return (*context_.src_mem).get_primitive_desc().desc().data.format; + } + + mkldnn_memory_format_t GetDstFmt() const { + return (*context_.dst_mem).get_primitive_desc().desc().data.format; + } + + private: + // Primitive reuse context for BatchNorm fwd op + struct BatchNormFwdContext { + // flags indict if it is training or inference mode + int64 flags; + + // algorithm + mkldnn::prop_kind pkind; + + // Mkldnn Memory + std::shared_ptr src_mem; + std::shared_ptr weights_mem; + std::shared_ptr dst_mem; + std::shared_ptr mean_mem; + std::shared_ptr variance_mem; + + // BatchNorm forward primitive + std::shared_ptr bn_fwd; + std::shared_ptr fwd_stream; + std::vector fwd_primitives; + + BatchNormFwdContext() : + flags(0), pkind(mkldnn::forward_training), src_mem(nullptr), + weights_mem(nullptr), dst_mem(nullptr), mean_mem(nullptr), + variance_mem(nullptr), bn_fwd(nullptr), fwd_stream(nullptr) { + } + } context_; + + void Setup(const MklBatchNormFwdParams& fwdParams) { + context_.flags = fwdParams.training ? use_scale_shift + : (use_scale_shift | use_global_stats); + context_.pkind = fwdParams.training ? prop_kind::forward_training + : prop_kind::forward_scoring; + + // memory desc + auto src_md = memory::desc({fwdParams.src_dims}, + MklDnnType(), get_desired_format(fwdParams.src_dims[1])); + + // fwd desc & primitive desc + auto fwd_desc = batch_normalization_forward::desc( + context_.pkind, src_md, fwdParams.eps, context_.flags); + auto fwd_pd = batch_normalization_forward::primitive_desc( + fwd_desc, cpu_engine_); + + // memory primitive + context_.src_mem.reset(new memory({src_md, cpu_engine_}, DummyData)); + context_.dst_mem.reset(new memory(fwd_pd.dst_primitive_desc(), DummyData)); + + if (context_.flags & use_scale_shift) { + auto weights_desc = memory::desc({2, fwdParams.depth}, + MklDnnType(), memory::format::nc); + context_.weights_mem.reset(new memory({weights_desc, cpu_engine_}, + DummyData)); + } + + if (fwdParams.training || (context_.flags & use_global_stats)) { + auto mean_desc = memory::desc({1, fwdParams.depth}, + MklDnnType(), memory::format::nc); + context_.mean_mem.reset(new memory({mean_desc, cpu_engine_}, DummyData)); + + auto variance_desc = memory::desc({1, fwdParams.depth}, + MklDnnType(), memory::nc); + context_.variance_mem.reset(new memory({variance_desc, cpu_engine_}, + DummyData)); + } + + // BatchNorm forward primitive + if (!fwdParams.training && !(context_.flags & use_global_stats)) { + if ((context_.flags & use_scale_shift) && mkldnn_use_scaleshift) { + context_.bn_fwd.reset(new batch_normalization_forward(fwd_pd, + *context_.src_mem, *context_.weights_mem, *context_.dst_mem)); + } else { + context_.bn_fwd.reset(new batch_normalization_forward( + fwd_pd, *context_.src_mem, *context_.dst_mem)); + } + } else if (context_.flags & use_global_stats) { + if ((context_.flags & use_scale_shift) && mkldnn_use_scaleshift) { + context_.bn_fwd.reset(new batch_normalization_forward( + fwd_pd, *context_.src_mem, (const primitive::at)*context_.mean_mem, + (const primitive::at)*context_.variance_mem, *context_.weights_mem, + *context_.dst_mem)); + } else { + context_.bn_fwd.reset(new batch_normalization_forward( + fwd_pd, *context_.src_mem, (const primitive::at)*context_.mean_mem, + (const primitive::at)*context_.variance_mem, *context_.dst_mem)); + } + } else { + if ((context_.flags & use_scale_shift) && mkldnn_use_scaleshift) { + context_.bn_fwd.reset(new batch_normalization_forward( + fwd_pd, *context_.src_mem, *context_.weights_mem, *context_.dst_mem, + *context_.mean_mem, *context_.variance_mem)); + } else { + context_.bn_fwd.reset(new batch_normalization_forward( + fwd_pd, *context_.src_mem, *context_.dst_mem, + *context_.mean_mem, *context_.variance_mem)); + } + } + + context_.fwd_primitives.push_back(*context_.bn_fwd); + return; + } + + mkldnn::memory::desc get_desc_data(const mkldnn::memory &m) const { + return m.get_primitive_desc().desc().data; + } + + engine cpu_engine_ = engine(engine::cpu, 0); +}; + +template +class MklFusedBatchNormFwdPrimitiveFactory : public MklPrimitiveFactory { + public: + static MklFusedBatchNormFwdPrimitive* Get( + const MklBatchNormFwdParams& fwdParams) { + auto bn_fwd = static_cast*>( + MklFusedBatchNormFwdPrimitiveFactory + ::GetInstance().GetBatchNormFwd(fwdParams)); + + if (bn_fwd == nullptr) { + bn_fwd = new MklFusedBatchNormFwdPrimitive(fwdParams); + MklFusedBatchNormFwdPrimitiveFactory::GetInstance().SetBatchNormFwd( + fwdParams, bn_fwd); + } + return bn_fwd; + } + + static MklFusedBatchNormFwdPrimitiveFactory & GetInstance() { + static MklFusedBatchNormFwdPrimitiveFactory instance_; + return instance_; + } + + private: + MklFusedBatchNormFwdPrimitiveFactory() {} + ~MklFusedBatchNormFwdPrimitiveFactory() {} + + static std::string CreateKey(const MklBatchNormFwdParams& fwdParams) { + std::string prefix = "bn_fwd"; + FactoryKeyCreator key_creator; + key_creator.AddAsKey(prefix); + key_creator.AddAsKey(fwdParams.src_dims); + key_creator.AddAsKey(fwdParams.depth); + key_creator.AddAsKey(fwdParams.eps); + key_creator.AddAsKey(fwdParams.training); + return key_creator.GetKey(); + } + + MklPrimitive* GetBatchNormFwd(const MklBatchNormFwdParams& fwdParams) { + std::string key = CreateKey(fwdParams); + return this->GetOp(key); + } + + void SetBatchNormFwd(const MklBatchNormFwdParams& fwdParams, + MklPrimitive *op) { + std::string key = CreateKey(fwdParams); + this->SetOp(key, op); + } +}; + +struct MklBatchNormBwdParams { + memory::dims src_dims; + memory::dims diff_dst_dims; + int depth; + float eps; + bool training; + + MklBatchNormBwdParams(memory::dims src_dims, memory::dims diff_dst_dims, + int depth, float eps, bool training) : src_dims(src_dims), + diff_dst_dims(diff_dst_dims), depth(depth), eps(eps), + training(training) { + } +}; + + +template +class MklFusedBatchNormBwdPrimitive : public MklPrimitive { + public: + explicit MklFusedBatchNormBwdPrimitive( + const MklBatchNormBwdParams& bwdParams) { + context_.bwd_stream.reset( + new mkldnn::stream(mkldnn::stream::kind::eager)); + if (context_.bn_bwd == nullptr) + Setup(bwdParams); + } + + ~MklFusedBatchNormBwdPrimitive() {} + + // BatchNormalization backward execute + // src_data: input data buffer of src + // mean_data: input data buffer of mean + // variance_data: input data buffer of variance + // diff_dst_data: input data buffer of diff_dst + // weights_data: input data buffer of weights + // diff_src_data: output data buffer of diff_src + // diff_weights_data: output data buffer of diff_weights + void Execute(const T* src_data, const T* mean_data, const T* variance_data, + const T* diff_dst_data, const T* weights_data, + const T* diff_src_data, const T* diff_weights_data) { + context_.src_mem->set_data_handle( + static_cast(const_cast(src_data))); + context_.mean_mem->set_data_handle( + static_cast(const_cast(mean_data))); + context_.variance_mem->set_data_handle( + static_cast(const_cast(variance_data))); + context_.diff_dst_mem->set_data_handle( + static_cast(const_cast(diff_dst_data))); + + if (context_.flags & use_scale_shift) { + context_.weights_mem->set_data_handle( + static_cast(const_cast(weights_data))); + context_.diff_weights_mem->set_data_handle( + static_cast(const_cast(diff_weights_data))); + } + + context_.diff_src_mem->set_data_handle( + static_cast(const_cast(diff_src_data))); + + // execution + context_.bwd_stream->submit(context_.bwd_primitives); + + context_.src_mem->set_data_handle(DummyData); + context_.mean_mem->set_data_handle(DummyData); + context_.variance_mem->set_data_handle(DummyData); + context_.diff_dst_mem->set_data_handle(DummyData); + if (context_.flags & use_scale_shift) { + context_.weights_mem->set_data_handle(DummyData); + context_.diff_weights_mem->set_data_handle(DummyData); + } + context_.diff_src_mem->set_data_handle(DummyData); + return; + } + + mkldnn_memory_format_t GetSrcFmt() { + return(*context_.src_mem).get_primitive_desc().desc().data.format; + } + + mkldnn_memory_format_t GetDiffDstFmt() { + return(*context_.diff_dst_mem).get_primitive_desc().desc().data.format; + } + + memory::primitive_desc GetDiffSrcPd() { + return(*context_.diff_src_mem).get_primitive_desc(); + } + + private: + struct BatchNormBwdContext { + // Flags to indicate whether it is training or inference + int64 flags; + + // MKLDNN memory + std::shared_ptr src_mem; + std::shared_ptr mean_mem; + std::shared_ptr variance_mem; + std::shared_ptr diff_dst_mem; + std::shared_ptr weights_mem; + std::shared_ptr diff_weights_mem; + std::shared_ptr diff_src_mem; + + // Batch Norm primitive + std::shared_ptr bn_bwd; + std::vector bwd_primitives; + std::shared_ptr bwd_stream; + + BatchNormBwdContext() : + src_mem(nullptr), mean_mem(nullptr), variance_mem(nullptr), + diff_dst_mem(nullptr), weights_mem(nullptr), diff_weights_mem(nullptr), + diff_src_mem(nullptr), bwd_stream(nullptr) { + } + } context_; + void Setup(const MklBatchNormBwdParams& bwdParams) { + context_.flags = bwdParams.training ? use_scale_shift + : (use_scale_shift | use_global_stats); + + // memory desc + auto src_md = memory::desc({bwdParams.src_dims}, + MklDnnType(), get_desired_format(bwdParams.src_dims[1])); + auto diff_dst_md = memory::desc({bwdParams.diff_dst_dims}, + MklDnnType(), get_desired_format(bwdParams.diff_dst_dims[1])); + auto variance_desc = memory::desc({1, bwdParams.depth}, MklDnnType(), + memory::nc); + auto mean_desc = memory::desc({1, bwdParams.depth}, + MklDnnType(), memory::format::nc); + auto weights_desc = memory::desc({2, bwdParams.depth}, + MklDnnType(), memory::format::nc); + auto diff_weights_desc = weights_desc; + + // fwd desc & primitive desc + auto fwd_desc = batch_normalization_forward::desc( + prop_kind::forward_training, src_md, bwdParams.eps, + bwdParams.training + ? use_scale_shift + : (use_scale_shift | use_global_stats)); + auto fwd_pd = batch_normalization_forward::primitive_desc( + fwd_desc, cpu_engine_); + + // BatchNorm backward primtive + // + // For inference, specify use_global_stats + // 1. on fwd propagation, use mean and variance provided as inputs. + // 2. on bwd propagation, mean and variance are considered as constants. + // Thus, reduce the amount of MKL computation. + auto bwd_desc = batch_normalization_backward::desc( + prop_kind::backward, diff_dst_md, src_md, bwdParams.eps, + bwdParams.training ? use_scale_shift + : (use_scale_shift | use_global_stats)); + auto bn_bwd_pd = batch_normalization_backward::primitive_desc( + bwd_desc, cpu_engine_, fwd_pd); + + // memory primitive + context_.src_mem.reset(new memory({src_md, cpu_engine_}, DummyData)); + context_.diff_dst_mem.reset(new memory({diff_dst_md, cpu_engine_}, + DummyData)); + context_.variance_mem.reset(new memory({variance_desc, cpu_engine_}, + DummyData)); + context_.mean_mem.reset(new memory({mean_desc, cpu_engine_}, DummyData)); + context_.weights_mem.reset(new memory({weights_desc, cpu_engine_}, + DummyData)); + context_.diff_weights_mem.reset(new memory({diff_weights_desc, cpu_engine_}, + DummyData)); + context_.diff_src_mem.reset(new memory({src_md, cpu_engine_}, DummyData)); + + context_.bn_bwd.reset(new batch_normalization_backward( + bn_bwd_pd, *context_.src_mem, *context_.mean_mem, + *context_.variance_mem, *context_.diff_dst_mem, *context_.weights_mem, + *context_.diff_src_mem, *context_.diff_weights_mem)); + context_.bwd_primitives.push_back(*context_.bn_bwd); + return; + } + + engine cpu_engine_ = engine(engine::cpu, 0); +}; + +template +class MklFusedBatchNormBwdPrimitiveFactory : public MklPrimitiveFactory { + public: + static MklFusedBatchNormBwdPrimitive* Get( + const MklBatchNormBwdParams& bwdParams) { + auto bn_bwd = static_cast*>( + MklFusedBatchNormBwdPrimitiveFactory + ::GetInstance().GetBatchNormBwd(bwdParams)); + if (bn_bwd == nullptr) { + bn_bwd = new MklFusedBatchNormBwdPrimitive(bwdParams); + MklFusedBatchNormBwdPrimitiveFactory::GetInstance().SetBatchNormBwd( + bwdParams, bn_bwd); + } + return bn_bwd; + } + + static MklFusedBatchNormBwdPrimitiveFactory& GetInstance() { + static MklFusedBatchNormBwdPrimitiveFactory instance_; + return instance_; + } + + private: + MklFusedBatchNormBwdPrimitiveFactory() {} + ~MklFusedBatchNormBwdPrimitiveFactory() {} + + static std::string CreateKey(const MklBatchNormBwdParams& bwdParams) { + std::string prefix = "bn_bwd"; + FactoryKeyCreator key_creator; + key_creator.AddAsKey(prefix); + key_creator.AddAsKey(bwdParams.src_dims); + key_creator.AddAsKey(bwdParams.diff_dst_dims); + key_creator.AddAsKey(bwdParams.depth); + key_creator.AddAsKey(bwdParams.eps); + key_creator.AddAsKey(bwdParams.training); + return key_creator.GetKey(); + } + + MklPrimitive* GetBatchNormBwd(const MklBatchNormBwdParams& bwdParams) { + std::string key = CreateKey(bwdParams); + return this->GetOp(key); + } + + void SetBatchNormBwd(const MklBatchNormBwdParams& bwdParams, + MklPrimitive* op) { + std::string key = CreateKey(bwdParams); + this->SetOp(key, op); + } +}; + template class MklFusedBatchNormOp : public OpKernel { public: @@ -701,7 +1162,6 @@ class MklFusedBatchNormOp : public OpKernel { void Compute(OpKernelContext* context) override { try { - auto cpu_engine = engine(engine::cpu, 0); const size_t kSrcIndex = 0; // index of src input tensor const size_t kScaleIndex = 1; // index of scale tensor const size_t kShiftIndex = 2; // index of shift tensor @@ -786,7 +1246,7 @@ class MklFusedBatchNormOp : public OpKernel { SetMeanVariance(est_mean_tensor, est_variance_tensor); MklDnnData src(&cpu_engine); - MklDnnData dst(&cpu_engine); + MklDnnData weights(&cpu_engine); memory::format format_m; if (dnn_shape_src.IsMklTensor()) { @@ -800,123 +1260,108 @@ class MklFusedBatchNormOp : public OpKernel { } // set src primitive - memory::dims src_dims; - if (dnn_shape_src.IsMklTensor()) { - src_dims = TFShapeToMklDnnDimsInNCHW(dnn_shape_src.GetTfShape(), - tensor_format_); - } else { - src_dims = - TFShapeToMklDnnDimsInNCHW(src_tensor.shape(), tensor_format_); - } + memory::dims src_dims = dnn_shape_src.IsMklTensor() + ? dnn_shape_src.GetSizesAsMklDnnDims() + : TFShapeToMklDnnDimsInNCHW(src_tensor.shape(), tensor_format_); auto src_md = dnn_shape_src.IsMklTensor() ? dnn_shape_src.GetMklLayout() : memory::desc(src_dims, MklDnnType(), format_m); - src.SetUsrMem(src_md, &src_tensor); - // set weights primitive // MKL-DNN packs scale & shift as "weights": // ...... - auto weights_desc = memory::desc({2, static_cast(depth_)}, - MklDnnType(), memory::format::nc); - auto weights_pd = memory::primitive_desc(weights_desc, cpu_engine); - auto weights_m = memory(weights_pd); - T* weights_data = reinterpret_cast(weights_m.get_data_handle()); + weights.AllocateBuffer(2 * depth_ * sizeof (T)); + T* weights_data = reinterpret_cast(weights.GetAllocatedBuffer()); T* scale_tf = reinterpret_cast(const_cast(scale_tensor.flat().data())); T* shift_tf = reinterpret_cast(const_cast(shift_tensor.flat().data())); - for (int k = 0; k < depth_; k++) { - weights_data[k] = scale_tf[k]; - weights_data[k + depth_] = shift_tf[k]; - } - - // set mean primitive - auto mean_desc = memory::desc({1, static_cast(depth_)}, - MklDnnType(), memory::format::nc); - auto mean_pd = memory::primitive_desc(mean_desc, cpu_engine); + std::memcpy(weights_data, scale_tf, depth_ * sizeof(T)); + std::memcpy(weights_data + depth_, shift_tf, depth_ * sizeof(T)); char* saved_mean_data_tf = reinterpret_cast(saved_mean_tensor->flat().data()); std::memcpy(saved_mean_data_tf, reinterpret_cast(mean_values_), depth_ * sizeof(T)); - auto mean_m = - memory(mean_pd, reinterpret_cast(saved_mean_data_tf)); - // set variance primitive - auto variance_desc = memory::desc({1, static_cast(depth_)}, - MklDnnType(), memory::format::nc); - auto variance_pd = memory::primitive_desc(variance_desc, cpu_engine); char* saved_variance_data_tf = reinterpret_cast(saved_variance_tensor->flat().data()); std::memcpy(saved_variance_data_tf, reinterpret_cast(variance_values_), depth_ * sizeof(T)); - auto variance_m = memory(variance_pd, saved_variance_data_tf); - - prop_kind pk = (is_training_) ? prop_kind::forward_training - : prop_kind::forward_scoring; - auto bnrm_fwd_desc = batch_normalization_forward::desc( - pk, src.GetUsrMemDesc(), epsilon_, - is_training_ ? use_scale_shift - : (use_scale_shift | use_global_stats)); - auto bnrm_fwd_pd = batch_normalization_forward::primitive_desc( - bnrm_fwd_desc, cpu_engine); - - // allocate dst tensor - MklDnnShape dnn_shape_dst; - TensorShape tf_shape_dst; - if (dnn_shape_src.IsMklTensor()) { - dnn_shape_dst.SetMklTensor(true); - auto dst_pd = bnrm_fwd_pd.dst_primitive_desc(); - dnn_shape_dst.SetMklLayout(&dst_pd); - dnn_shape_dst.SetElemType(MklDnnType()); - dnn_shape_dst.SetTfLayout(dnn_shape_src.GetDimension(), src_dims, - format_m); - tf_shape_dst.AddDim(dst_pd.get_size() / sizeof(T)); - } else { - dnn_shape_dst.SetMklTensor(false); - tf_shape_dst = src_tensor.shape(); - } - AllocateOutputSetMklShape(context, kDstIndex, &dst_tensor, tf_shape_dst, - dnn_shape_dst); - // Output of batchnorm has same shape as input. - dst.SetUsrMem(src_md, dst_tensor); + // get batchnorm op from the pool + MklBatchNormFwdParams fwdParams(src_dims, depth_, epsilon_, is_training_); + MklFusedBatchNormFwdPrimitive *bn_fwd = + MklFusedBatchNormFwdPrimitiveFactory::Get(fwdParams); - primitive bnrm_fwd_op; - if (is_training_) { - bnrm_fwd_op = - batch_normalization_forward(bnrm_fwd_pd, src.GetOpMem(), weights_m, - dst.GetOpMem(), mean_m, variance_m); + // check if reorder is needed for src, weights, mean, variance + std::vector net; + T* src_data = nullptr; + if (src_md.data.format != bn_fwd->GetSrcFmt()) { + src.SetUsrMem(src_md, &src_tensor); + auto src_target = memory::primitive_desc({{src_dims}, MklDnnType(), + static_cast(bn_fwd->GetSrcFmt())}, cpu_engine); + src.CheckReorderToOpMem(src_target, &net); + src_data = static_cast(src.GetOpMem().get_data_handle()); } else { - bnrm_fwd_op = batch_normalization_forward( - bnrm_fwd_pd, src.GetOpMem(), mean_m, variance_m, - (const primitive::at)weights_m, dst.GetOpMem()); + src_data = static_cast( + const_cast(src_tensor.flat().data())); } - std::vector net; - net.push_back(bnrm_fwd_op); stream(stream::kind::eager).submit(net).wait(); + // allocate output (dst) tensor; always set it as MKL-DNN layout + MklDnnShape dnn_shape_dst; + TensorShape tf_shape_dst; + dnn_shape_dst.SetMklTensor(true); + auto dst_pd = bn_fwd->GetDstPd(); + dnn_shape_dst.SetMklLayout(&dst_pd); + dnn_shape_dst.SetElemType(MklDnnType()); + auto ndims = dnn_shape_src.IsMklTensor() + ? dnn_shape_src.GetDimension() + : src_tensor.shape().dims(); + dnn_shape_dst.SetTfLayout(ndims, src_dims, format_m); + tf_shape_dst.AddDim(dst_pd.get_size() / sizeof(T)); + AllocateOutputSetMklShape(context, kDstIndex, &dst_tensor, + tf_shape_dst, dnn_shape_dst); + + T* weights_op_data = weights_data; + T* mean_op_data = reinterpret_cast( + saved_mean_tensor->flat().data()); + T* variance_op_data = reinterpret_cast( + saved_variance_tensor->flat().data()); + T* dst_data = static_cast(dst_tensor->flat().data()); + + // execution + bn_fwd->Execute(src_data, weights_op_data, dst_data, + mean_op_data, variance_op_data); + // copy batch_mean data T* batch_mean_data_tf = reinterpret_cast(batch_mean_tensor->flat().data()); std::memcpy(reinterpret_cast(batch_mean_data_tf), - reinterpret_cast(mean_m.get_data_handle()), + reinterpret_cast(saved_mean_data_tf), depth_ * sizeof(T)); + // TODO(yli135): OpMem is same as usr mem since + // since its format is hard-coded as nc when primitive is created. // copy batch_variance data with Bessel's correction - // if training mode is on float adjust_factor = 1.0; if (is_training_) { size_t orig_size = src_dims[0] * src_dims[2] * src_dims[3]; size_t adjust_size = orig_size - 1; adjust_factor = (static_cast(orig_size)) / adjust_size; } - for (int k = 0; k < depth_; k++) - batch_variance_tensor->flat().data()[k] = - (reinterpret_cast(variance_m.get_data_handle()))[k] * - adjust_factor; + + auto variance_data = reinterpret_cast(saved_variance_data_tf); + auto batch_variance_data = batch_variance_tensor->flat().data(); + if (is_training_) { + for (int k = 0; k < depth_; k++) { + batch_variance_data[k] = variance_data[k] * adjust_factor; + } + } else { + std::memcpy(batch_variance_data, variance_data, depth_ * sizeof(T)); + } } catch (mkldnn::error& e) { string error_msg = "Status: " + std::to_string(e.status) + ", message: " + string(e.message) + ", in file " + @@ -933,7 +1378,8 @@ class MklFusedBatchNormOp : public OpKernel { bool is_training_; T* mean_values_; T* variance_values_; - int depth_; // batch normalization is done for per channel. + size_t depth_; // batch normalization is done for per channel. + engine cpu_engine = engine(engine::cpu, 0); void ExtractParams(OpKernelContext* context) { const Tensor& input = MklGetInput(context, 0); @@ -990,8 +1436,10 @@ class MklFusedBatchNormOp : public OpKernel { tf_shape_scale, mkl_shape_batch_mean); CHECK_NOTNULL(*batch_mean_tensor); // set NAN mean value in case of empty input tensor - for (int k = 0; k < tf_shape_scale.num_elements(); k++) - (*batch_mean_tensor)->flat().data()[k] = NAN; + int num_elements = tf_shape_scale.num_elements(); + auto batch_mean_data = (*batch_mean_tensor)->flat().data(); + for (int k = 0; k < num_elements; k++) + batch_mean_data[k] = NAN; // allocate batch variance output tensor MklDnnShape mkl_shape_batch_variance; @@ -1001,8 +1449,9 @@ class MklFusedBatchNormOp : public OpKernel { mkl_shape_batch_variance); CHECK_NOTNULL(*batch_variance_tensor); // set NAN variance value in case of empty input tensor - for (int k = 0; k < tf_shape_scale.num_elements(); k++) - (*batch_variance_tensor)->flat().data()[k] = NAN; + auto batch_variance_data = (*batch_variance_tensor)->flat().data(); + for (int k = 0; k < num_elements; k++) + batch_variance_data[k] = NAN; // Mean and variance (without Bessel's correction) saved for backward // computation to serve as pre-computed mean and variance. @@ -1012,8 +1461,9 @@ class MklFusedBatchNormOp : public OpKernel { tf_shape_scale, mkl_shape_saved_mean); CHECK_NOTNULL(*saved_mean_tensor); // set NAN mean value in case of empty input tensor - for (int k = 0; k < tf_shape_scale.num_elements(); k++) - (*saved_mean_tensor)->flat().data()[k] = NAN; + auto saved_mean_data = (*saved_mean_tensor)->flat().data(); + for (int k = 0; k < num_elements; k++) + saved_mean_data[k] = NAN; MklDnnShape mkl_shape_saved_variance; mkl_shape_saved_variance.SetMklTensor(false); @@ -1022,8 +1472,9 @@ class MklFusedBatchNormOp : public OpKernel { mkl_shape_saved_variance); CHECK_NOTNULL(*saved_variance_tensor); // set NAN variance value in case of empty input tensor - for (int k = 0; k < tf_shape_scale.num_elements(); k++) - (*saved_variance_tensor)->flat().data()[k] = NAN; + auto saved_variance_data = (*saved_variance_tensor)->flat().data(); + for (int k = 0; k < num_elements; k++) + saved_variance_data[k] = NAN; } }; @@ -1044,24 +1495,24 @@ class MklFusedBatchNormGradOp : public OpKernel { void Compute(OpKernelContext* context) override { try { - auto cpu_engine = engine(engine::cpu, 0); const size_t kDiffDstIndex = 0; // index of diff_dst tensor const size_t kSrcIndex = 1; // index of src input tensor const size_t kScaleIndex = 2; // index of scale tensor const size_t kMeanIndex = 3; // index of saved_mean tensor const size_t kVarianceIndex = 4; // index of saved_variance tensor + const Tensor& diff_dst_tensor = MklGetInput(context, kDiffDstIndex); const Tensor& src_tensor = MklGetInput(context, kSrcIndex); const Tensor& scale_tensor = MklGetInput(context, kScaleIndex); const Tensor& saved_mean_tensor = MklGetInput(context, kMeanIndex); const Tensor& saved_variance_tensor = - MklGetInput(context, kVarianceIndex); + MklGetInput(context, kVarianceIndex); MklDnnShape dnn_shape_src, dnn_shape_diff_dst; GetMklShape(context, kSrcIndex, &dnn_shape_src); GetMklShape(context, kDiffDstIndex, &dnn_shape_diff_dst); - TensorShape tf_shape_src, tf_shape_diff_dst; + TensorShape tf_shape_src, tf_shape_diff_dst; if (dnn_shape_diff_dst.IsMklTensor()) { tf_shape_diff_dst = dnn_shape_diff_dst.GetTfShape(); OP_REQUIRES( @@ -1102,6 +1553,7 @@ class MklFusedBatchNormGradOp : public OpKernel { saved_variance_tensor.shape().DebugString())); Tensor* diff_src_tensor = nullptr; + // special case: input with 0 element and 0 batch size if (tf_shape_src.num_elements() == 0 || tf_shape_diff_dst.num_elements() == 0) { HandleEmptyInput(context, tf_shape_src, scale_tensor.shape(), @@ -1117,174 +1569,114 @@ class MklFusedBatchNormGradOp : public OpKernel { ExtractParams(context); } + memory::format format_m; + if (dnn_shape_src.IsMklTensor()) { + if (dnn_shape_src.IsTensorInNCHWFormat()) + format_m = memory::format::nchw; + else + format_m = memory::format::nhwc; + } else { + format_m = TFDataFormatToMklDnnDataFormat(tensor_format_); + } + MklDnnData src(&cpu_engine); - MklDnnData mean(&cpu_engine); - MklDnnData variance(&cpu_engine); MklDnnData diff_dst(&cpu_engine); - MklDnnData diff_src(&cpu_engine); + MklDnnData weights(&cpu_engine); + MklDnnData diff_weights(&cpu_engine); + + memory::dims src_dims = dnn_shape_src.IsMklTensor() + ? dnn_shape_src.GetSizesAsMklDnnDims() + : TFShapeToMklDnnDimsInNCHW(src_tensor.shape(), tensor_format_); + memory::dims diff_dst_dims = dnn_shape_diff_dst.IsMklTensor() + ? dnn_shape_diff_dst.GetSizesAsMklDnnDims() + : TFShapeToMklDnnDimsInNCHW(diff_dst_tensor.shape(), tensor_format_); + + // set src and diff_dst primitive descriptors + memory::desc src_md = dnn_shape_src.IsMklTensor() + ? dnn_shape_src.GetMklLayout() + : memory::desc(src_dims, MklDnnType(), format_m); + memory::desc diff_dst_md = dnn_shape_diff_dst.IsMklTensor() + ? dnn_shape_diff_dst.GetMklLayout() + : memory::desc(diff_dst_dims, MklDnnType(), format_m); + + // weights -- MKL DNN packs scales/ shifts as weights in order + // of scale, ..., scale, shift, ...., shift + weights.AllocateBuffer(2 * depth_ * sizeof(T)); + T* weights_data_tf = reinterpret_cast(weights.GetAllocatedBuffer()); + T* scale_tf = + reinterpret_cast(const_cast(scale_tensor.flat().data())); + for (int k = 0; k < depth_; k++) { + weights_data_tf[k] = scale_tf[k]; + weights_data_tf[k + depth_] = 0; + } - memory::dims src_dims, diff_dst_dims; - if (dnn_shape_src.IsMklTensor()) - src_dims = TFShapeToMklDnnDimsInNCHW(dnn_shape_src.GetTfShape(), - tensor_format_); - else - src_dims = - TFShapeToMklDnnDimsInNCHW(src_tensor.shape(), tensor_format_); + diff_weights.AllocateBuffer(2 * depth_ * sizeof(T)); - if (dnn_shape_diff_dst.IsMklTensor()) - diff_dst_dims = TFShapeToMklDnnDimsInNCHW( - dnn_shape_diff_dst.GetTfShape(), tensor_format_); - else - diff_dst_dims = - TFShapeToMklDnnDimsInNCHW(diff_dst_tensor.shape(), tensor_format_); + MklBatchNormBwdParams bwdParams(src_dims, diff_dst_dims, + depth_, epsilon_, is_training_); + MklFusedBatchNormBwdPrimitive *bn_bwd = + MklFusedBatchNormBwdPrimitiveFactory::Get(bwdParams); - // set src and diff_dst primitives according to input layout - memory::desc src_md({}, memory::data_undef, memory::format_undef); - memory::desc diff_dst_md({}, memory::data_undef, memory::format_undef); - if (dnn_shape_src.IsMklTensor()) { - src_md = dnn_shape_src.GetMklLayout(); + // check if src/diff_dst need to be reordered + std::vector net; + T* src_data = nullptr; + if (src_md.data.format != bn_bwd->GetSrcFmt()) { + src.SetUsrMem(src_md, &src_tensor); + auto src_target = memory::primitive_desc({{src_dims}, MklDnnType(), + static_cast(bn_bwd->GetSrcFmt())}, cpu_engine); + src.CheckReorderToOpMem(src_target, &net); + src_data = static_cast(src.GetOpMem().get_data_handle()); } else { - src_md = memory::desc(src_dims, MklDnnType(), - TFDataFormatToMklDnnDataFormat(tensor_format_)); + src_data = static_cast(const_cast( + src_tensor.flat().data())); } - if (dnn_shape_diff_dst.IsMklTensor()) { - diff_dst_md = dnn_shape_diff_dst.GetMklLayout(); + + T* diff_dst_data = nullptr; + if (diff_dst_md.data.format != bn_bwd->GetDiffDstFmt()) { + diff_dst.SetUsrMem(diff_dst_md, &diff_dst_tensor); + auto diff_dst_target = memory::primitive_desc({{diff_dst_dims}, + MklDnnType(), static_cast( + bn_bwd->GetDiffDstFmt())}, cpu_engine); + diff_dst.CheckReorderToOpMem(diff_dst_target, &net); + diff_dst_data = static_cast( + diff_dst.GetOpMem().get_data_handle()); } else { - diff_dst_md = memory::desc(diff_dst_dims, MklDnnType(), - TFDataFormatToMklDnnDataFormat(tensor_format_)); + diff_dst_data = static_cast(const_cast( + diff_dst_tensor.flat().data())); } - src.SetUsrMem(src_md, &src_tensor); - diff_dst.SetUsrMem(diff_dst_md, &diff_dst_tensor); - - // weights -- DNN packs scales/shifts as weights in order of - // scale, ..., scale, shift, ..., shift - auto weights_desc = - memory::desc({2, depth_}, MklDnnType(), memory::format::nc); - auto weights_pd = memory::primitive_desc(weights_desc, cpu_engine); - auto weights_m = memory(weights_pd); - T* weights_data = reinterpret_cast(weights_m.get_data_handle()); - T* scale_tf = - reinterpret_cast(const_cast(scale_tensor.flat().data())); - for (int k = 0; k < depth_; k++) { - weights_data[k] = scale_tf[k]; - weights_data[k + depth_] = 0; - } - - // set mean primitive - memory::dims mv_dims = GetMeanVarianceDims(); - mean.SetUsrMem(mv_dims, memory::format::nc, - const_cast(static_cast( - saved_mean_tensor.flat().data()))); - mean.SetOpMemDesc(mv_dims, memory::format::nc); - - // set variance primitive - variance.SetUsrMem(mv_dims, memory::format::nc, - const_cast(static_cast( - saved_variance_tensor.flat().data()))); - variance.SetOpMemDesc(mv_dims, memory::format::nc); - - // set diff_weight primitive - auto diff_weights_desc = - memory::desc({2, depth_}, MklDnnType(), memory::format::nc); - auto diff_weights_pd = - memory::primitive_desc(diff_weights_desc, cpu_engine); - auto diff_weights_m = memory(diff_weights_pd); - - auto bnrm_fwd_desc = batch_normalization_forward::desc( - prop_kind::forward_training, src.GetUsrMemDesc(), epsilon_, - is_training_ ? use_scale_shift - : (use_scale_shift | use_global_stats)); - auto bnrm_fwd_pd = batch_normalization_forward::primitive_desc( - bnrm_fwd_desc, cpu_engine); + stream(stream::kind::eager).submit(net).wait(); // Indices of output tensors const size_t kDiffSrcIndex = 0; // index of diff_src tensor - // allocate diff_src tensor + // allocate diff_src tensor, always set as MKL-DNN layout MklDnnShape dnn_shape_diff_src; TensorShape tf_shape_diff_src; - - // MKL-DNN's BN primitive not provide API to fetch internal format - // set common_md as OpMem - // src and diff_dst will reorder to common_md - // diff_src will set as common_md - memory::desc common_md({}, memory::data_undef, memory::format_undef); - if (dnn_shape_src.IsMklTensor() || dnn_shape_diff_dst.IsMklTensor()) { - if (dnn_shape_src.IsMklTensor()) { - common_md = dnn_shape_src.GetMklLayout(); - } else { - common_md = dnn_shape_diff_dst.GetMklLayout(); - } - } else { - common_md = memory::desc(src_dims, MklDnnType(), - TFDataFormatToMklDnnDataFormat(tensor_format_)); - } - // if any of src and diff_dst as mkl layout, - // then we set diff_src as mkl layout - if (dnn_shape_src.IsMklTensor() || - dnn_shape_diff_dst.IsMklTensor()) { - dnn_shape_diff_src.SetMklTensor(true); - // set diff_src's mkl layout as common_md - auto diff_src_pd = memory::primitive_desc(common_md, cpu_engine); - dnn_shape_diff_src.SetMklLayout(&diff_src_pd); - dnn_shape_diff_src.SetElemType(MklDnnType()); - if (dnn_shape_src.IsMklTensor()) { - dnn_shape_diff_src.SetTfLayout( - dnn_shape_src.GetDimension(), - src_dims, - dnn_shape_src.GetTfDataFormat()); - dnn_shape_diff_src.SetTfDimOrder( - dnn_shape_src.GetDimension(), - tensor_format_); - } else { - dnn_shape_diff_src.SetTfLayout( - dnn_shape_diff_dst.GetDimension(), - src_dims, - dnn_shape_diff_dst.GetTfDataFormat()); - dnn_shape_diff_src.SetTfDimOrder( - dnn_shape_diff_dst.GetDimension(), - tensor_format_); - } - tf_shape_diff_src.AddDim(diff_src_pd.get_size() / sizeof(T)); - } else { - dnn_shape_diff_src.SetMklTensor(false); - // both src and diff_dst are TensorFlow layout, - // so it is OK to get TensorFlow shape. - tf_shape_diff_src = src_tensor.shape(); - } + dnn_shape_diff_src.SetMklTensor(true); + auto diff_src_pd = bn_bwd->GetDiffSrcPd(); + dnn_shape_diff_src.SetMklLayout(&diff_src_pd); + dnn_shape_diff_src.SetElemType(MklDnnType()); + dnn_shape_diff_src.SetTfLayout(dnn_shape_src.GetDimension(), src_dims, + format_m); + dnn_shape_diff_src.SetTfDimOrder(dnn_shape_src.GetDimension(), + tensor_format_); + tf_shape_diff_src.AddDim(diff_src_pd.get_size() / sizeof(T)); AllocateOutputSetMklShape(context, kDiffSrcIndex, &diff_src_tensor, tf_shape_diff_src, dnn_shape_diff_src); - // set diff_src - diff_src.SetUsrMem(common_md, diff_src_tensor); - - prop_kind pk = prop_kind::backward; - auto bnrm_bwd_desc = batch_normalization_backward::desc( - pk, common_md, common_md, epsilon_, - /* for inference, specify use_global_stats - 1. on fwd prop, use mean and variance - provided as inputs - 2. on bwd prop, mean and variance are - considered as constants. Thus, - reduce the amout of MKL computations - */ - is_training_ ? use_scale_shift - : (use_scale_shift | use_global_stats)); - auto bnrm_bwd_pd = batch_normalization_backward::primitive_desc( - bnrm_bwd_desc, cpu_engine, bnrm_fwd_pd); - - std::vector net; - src.CheckReorderToOpMem(memory::primitive_desc(common_md, - cpu_engine), &net); - diff_dst.CheckReorderToOpMem(memory::primitive_desc(common_md, - cpu_engine), &net); - - auto bnrm_bwd_op = batch_normalization_backward( - bnrm_bwd_pd, src.GetOpMem(), mean.GetOpMem(), variance.GetOpMem(), - diff_dst.GetOpMem(), weights_m, diff_src.GetOpMem(), diff_weights_m); - net.push_back(bnrm_bwd_op); - stream(stream::kind::eager).submit(net).wait(); + T* mean_data = static_cast(const_cast( + saved_mean_tensor.flat().data())); + T* variance_data = static_cast(const_cast( + saved_variance_tensor.flat().data())); + T* weights_data = weights_data_tf; + T* diff_src_data = static_cast( + diff_src_tensor->flat().data()); + T* diff_weights_data = static_cast( + diff_weights.GetAllocatedBuffer()); + // Execute + bn_bwd->Execute(src_data, mean_data, variance_data, diff_dst_data, + weights_data, diff_src_data, diff_weights_data); // allocate 4 output TF tensors Tensor* diff_scale_tensor = nullptr; @@ -1293,13 +1685,14 @@ class MklFusedBatchNormGradOp : public OpKernel { &diff_shift_tensor); // copy data: diff_scale and diff_shift - T* diff_weights_data_dnn = - reinterpret_cast(diff_weights_m.get_data_handle()); - for (int i = 0; i < depth_; i++) { - diff_scale_tensor->flat().data()[i] = diff_weights_data_dnn[i]; - diff_shift_tensor->flat().data()[i] = - diff_weights_data_dnn[i + depth_]; - } + auto diff_scale_data = diff_scale_tensor->flat().data(); + auto diff_shift_data = diff_shift_tensor->flat().data(); + std::memcpy(reinterpret_cast(diff_scale_data), + reinterpret_cast(diff_weights_data), + depth_ * sizeof(T)); + std::memcpy(reinterpret_cast(diff_shift_data), + reinterpret_cast(diff_weights_data) + depth_, + depth_ * sizeof(T)); } catch (mkldnn::error& e) { string error_msg = "Status: " + std::to_string(e.status) + ", message: " + string(e.message) + ", in file " + @@ -1315,6 +1708,7 @@ class MklFusedBatchNormGradOp : public OpKernel { TensorFormat tensor_format_; int depth_; // batch normalization is done for per channel. bool is_training_; + engine cpu_engine = engine(engine::cpu, 0); void ExtractParams(OpKernelContext* context) { const Tensor& input = MklGetInput(context, 0); @@ -1330,8 +1724,10 @@ class MklFusedBatchNormGradOp : public OpKernel { dnn_shape_diff_src.SetMklTensor(false); AllocateOutputSetMklShape(context, kDiffSrcIndex, diff_src_tensor, tf_shape_src, dnn_shape_diff_src); - for (size_t i = 0; i < (*diff_src_tensor)->shape().num_elements(); i++) - (*diff_src_tensor)->flat().data()[i] = 0; + int num_elements = (*diff_src_tensor)->shape().num_elements(); + auto diff_src_data = (*diff_src_tensor)->flat().data(); + for (size_t i = 0; i < num_elements; i++) + diff_src_data[i] = 0; Tensor* diff_scale_tensor = nullptr; Tensor* diff_shift_tensor = nullptr; @@ -1357,16 +1753,20 @@ class MklFusedBatchNormGradOp : public OpKernel { AllocateOutputSetMklShape(context, kDiffScaleIndex, diff_scale_tensor, tf_shape_scale_shift, mkl_shape_diff_scale); CHECK_NOTNULL(*diff_scale_tensor); - for (size_t i = 0; i < (*diff_scale_tensor)->shape().num_elements(); i++) - (*diff_scale_tensor)->flat().data()[i] = 0; + int diff_scale_num_elements = (*diff_scale_tensor)->shape().num_elements(); + auto diff_scale_data = (*diff_scale_tensor)->flat().data(); + for (size_t i = 0; i < diff_scale_num_elements; i++) + diff_scale_data[i] = 0; MklDnnShape mkl_shape_diff_shift; mkl_shape_diff_shift.SetMklTensor(false); AllocateOutputSetMklShape(context, kDiffShiftIndex, diff_shift_tensor, tf_shape_scale_shift, mkl_shape_diff_shift); CHECK_NOTNULL(*diff_shift_tensor); - for (size_t i = 0; i < (*diff_shift_tensor)->shape().num_elements(); i++) - (*diff_shift_tensor)->flat().data()[i] = 0; + int diff_shift_num_elements = (*diff_shift_tensor)->shape().num_elements(); + auto diff_shift_data = (*diff_shift_tensor)->flat().data(); + for (size_t i = 0; i < diff_shift_num_elements; i++) + diff_shift_data[i] = 0; // Placeholders for estimated_mean and estimated_variance, which are // used for inference and thus not needed here for gradient computation. diff --git a/tensorflow/core/util/mkl_util.h b/tensorflow/core/util/mkl_util.h index 230b4278ca..5dd2ee4521 100644 --- a/tensorflow/core/util/mkl_util.h +++ b/tensorflow/core/util/mkl_util.h @@ -36,7 +36,7 @@ limitations under the License. #include "tensorflow/core/platform/macros.h" #include "tensorflow/core/util/padding.h" #include "tensorflow/core/util/tensor_format.h" - +#include "tensorflow/core/platform/cpu_info.h" #ifndef INTEL_MKL_ML #include "mkldnn.hpp" @@ -1482,7 +1482,8 @@ class MklDnnData { /// Operations memory descriptor memory::desc* op_md_; - + /// Operations temp buffer + void* allocated_buffer_; /// CPU engine on which operation will be executed const engine* cpu_engine_; @@ -1491,6 +1492,7 @@ class MklDnnData { : user_memory_(nullptr), reorder_memory_(nullptr), op_md_(nullptr), + allocated_buffer_(nullptr), cpu_engine_(e) {} ~MklDnnData() { @@ -1631,6 +1633,14 @@ class MklDnnData { user_memory_->set_data_handle(GetTensorBuffer(tensor)); } + /// allocate function for data buffer + inline void AllocateBuffer(size_t size) { + allocated_buffer_ = cpu_allocator()->AllocateRaw(64, size); + } + inline void* GetAllocatedBuffer() { + return allocated_buffer_; + } + /// Get the memory primitive for input and output of an op. If inputs /// to an op require reorders, then this function returns memory primitive /// for reorder. Otherwise, it will return memory primitive for user memory. @@ -1794,11 +1804,11 @@ class MklDnnData { } }; -/// Base class for operations with reuse of DNN primitives +/// Base class for operations with reuse of primitives /// -class DnnOp { +class MklPrimitive { public: - virtual ~DnnOp() {} + virtual ~MklPrimitive() {} // Dummy data. Its size, hard-coded as 256 here, does // not matter since MKL should never operate on this buffer. @@ -1808,31 +1818,31 @@ class DnnOp { const mkldnn::memory::dims NONE_DIMS = {}; // This constant is used to declare dummy buffer (size), for MKL primitives template -class DnnOpFactory { +class MklPrimitiveFactory { public: - DnnOpFactory() {} - ~DnnOpFactory() {} + MklPrimitiveFactory() {} + ~MklPrimitiveFactory() {} - DnnOp* GetOp(const std::string& key) { - auto stream_iter = DnnOpFactory::GetHashMap().find(key); - if (stream_iter == DnnOpFactory::GetHashMap().end()) { + MklPrimitive* GetOp(const std::string& key) { + auto stream_iter = MklPrimitiveFactory::GetHashMap().find(key); + if (stream_iter == MklPrimitiveFactory::GetHashMap().end()) { return nullptr; } else { return stream_iter->second; } } - void SetOp(const std::string& key, DnnOp* op) { - auto stream_iter = DnnOpFactory::GetHashMap().find(key); + void SetOp(const std::string& key, MklPrimitive* op) { + auto stream_iter = MklPrimitiveFactory::GetHashMap().find(key); - CHECK(stream_iter == DnnOpFactory::GetHashMap().end()); + CHECK(stream_iter == MklPrimitiveFactory::GetHashMap().end()); - DnnOpFactory::GetHashMap()[key] = op; + MklPrimitiveFactory::GetHashMap()[key] = op; } private: - static inline std::unordered_map &GetHashMap() { - static thread_local std::unordered_map map_; + static inline std::unordered_map &GetHashMap() { + static thread_local std::unordered_map map_; return map_; } }; @@ -1877,6 +1887,21 @@ class FactoryKeyCreator { } }; +static inline memory::format get_desired_format(int channel) { + memory::format fmt_desired = memory::format::any; + + if (port::TestCPUFeature(port::CPUFeature::AVX512F) + && (channel % 16) == 0) { + fmt_desired = memory::format::nChw16c; + } else if (port::TestCPUFeature(port::CPUFeature::AVX2) + && (channel % 8) == 0) { + fmt_desired = memory::format::nChw8c; + } else { + fmt_desired = memory::format::nchw; + } + return fmt_desired; +} + #endif // INTEL_MKL_DNN } // namespace tensorflow -- GitLab From d89e88ba872f901fb9134385bfb782fc408f51d2 Mon Sep 17 00:00:00 2001 From: Guozhong Zhuang Date: Mon, 21 May 2018 13:38:36 -0700 Subject: [PATCH 011/437] revert mkl_conv_ops.cc to avoid PR review confusion --- tensorflow/core/kernels/mkl_conv_ops.cc | 280 ++++++++++-------------- 1 file changed, 116 insertions(+), 164 deletions(-) diff --git a/tensorflow/core/kernels/mkl_conv_ops.cc b/tensorflow/core/kernels/mkl_conv_ops.cc index c032add82e..f2b14f1278 100644 --- a/tensorflow/core/kernels/mkl_conv_ops.cc +++ b/tensorflow/core/kernels/mkl_conv_ops.cc @@ -59,8 +59,7 @@ namespace tensorflow { #ifndef INTEL_MKL_ML -// This structure aggregates multiple inputs to Conv2DFwd* methods. -struct MklConvFwdParams { +struct ConvFwdDimensions { memory::dims src_dims; memory::dims filter_dims; memory::dims bias_dims; @@ -70,7 +69,7 @@ struct MklConvFwdParams { memory::dims padding_left; memory::dims padding_right; - MklConvFwdParams(memory::dims src_dims, + ConvFwdDimensions(memory::dims src_dims, memory::dims filter_dims, memory::dims bias_dims, memory::dims dst_dims, memory::dims strides, memory::dims dilations, memory::dims padding_left, @@ -83,40 +82,35 @@ struct MklConvFwdParams { }; template -class MklConv2DFwdPrimitive: public MklPrimitive { +class Conv2DFwd : public DnnOp { public: - explicit MklConv2DFwdPrimitive(const MklConvFwdParams& convFwdDims) { - context_.fwd_stream.reset(new stream(stream::kind::eager)); + explicit Conv2DFwd(const ConvFwdDimensions& convFwdDims) { + fwd_stream_.reset(new stream(stream::kind::eager)); // create conv primitive - if (context_.conv_fwd == nullptr) { + if (conv_fwd_ == nullptr) { Setup(convFwdDims); } } - ~MklConv2DFwdPrimitive() {} + ~Conv2DFwd() {} // Convolution forward execute with bias // src_data: input data buffer of src // filter_data: input data buffer of filter (weights) // bias_data: input data buffer of bias // dst_data: output data buffer of dst - void Execute(const T* src_data, const T* filter_data, - const T* bias_data, const T* dst_data) { - context_.src_mem->set_data_handle( - static_cast(const_cast(src_data))); - context_.filter_mem->set_data_handle( - static_cast(const_cast(filter_data))); - context_.bias_mem->set_data_handle( - static_cast(const_cast(bias_data))); - context_.dst_mem->set_data_handle( - static_cast(const_cast(dst_data))); - context_.fwd_stream->submit(context_.fwd_primitives); + void Execute(T* src_data, T* filter_data, T* bias_data, T* dst_data) { + src_mem_->set_data_handle(static_cast(src_data)); + filter_mem_->set_data_handle(static_cast(filter_data)); + bias_mem_->set_data_handle(static_cast(bias_data)); + dst_mem_->set_data_handle(static_cast(dst_data)); + fwd_stream_->submit(fwd_primitives_); // after exec, set data handle back - context_.src_mem->set_data_handle(DummyData); - context_.filter_mem->set_data_handle(DummyData); - context_.bias_mem->set_data_handle(DummyData); - context_.dst_mem->set_data_handle(DummyData); + src_mem_->set_data_handle(DummyData); + filter_mem_->set_data_handle(DummyData); + bias_mem_->set_data_handle(DummyData); + dst_mem_->set_data_handle(DummyData); return; } @@ -125,174 +119,139 @@ class MklConv2DFwdPrimitive: public MklPrimitive { // src_data: input data buffer of src // filter_data: input data buffer of filter (weights) // dst_data: output data buffer of dst - void Execute(const T* src_data, const T* filter_data, - const T* dst_data) { - context_.src_mem->set_data_handle( - static_cast(const_cast(src_data))); - context_.filter_mem->set_data_handle( - static_cast(const_cast(filter_data))); - context_.dst_mem->set_data_handle( - static_cast(const_cast(dst_data))); - context_.fwd_stream->submit(context_.fwd_primitives); - - // after execution, set data handle back - context_.src_mem->set_data_handle(DummyData); - context_.filter_mem->set_data_handle(DummyData); - context_.dst_mem->set_data_handle(DummyData); + void Execute(T* src_data, T* filter_data, T* dst_data) { + src_mem_->set_data_handle(static_cast(src_data)); + filter_mem_->set_data_handle(static_cast(filter_data)); + dst_mem_->set_data_handle(static_cast(dst_data)); + fwd_stream_->submit(fwd_primitives_); - return; - } + // after exec, set data handle back + src_mem_->set_data_handle(DummyData); + filter_mem_->set_data_handle(DummyData); + dst_mem_->set_data_handle(DummyData); - memory::format GetSrcMemoryFormat() const { - return context_.src_fmt; + return; } - memory::format GetFilterMemoryFormat() const { - return context_.filter_fmt; - } + // expected memory format for this primitive instance + memory::format src_fmt_; + memory::format filter_fmt_; - std::shared_ptr - GetPrimitiveDesc() const { - return context_.fwd_pd; - } + // convolution primitive + std::shared_ptr fwd_pd_; + std::shared_ptr conv_fwd_; private: - // Primitive reuse context for Conv2D Fwd op - struct ConvFwdContext { - // expected memory format for this primitive instance - memory::format src_fmt; - memory::format filter_fmt; - - // MKLDNN memory - std::shared_ptr src_mem; - std::shared_ptr filter_mem; - std::shared_ptr bias_mem; - std::shared_ptr dst_mem; - - // desc & prmitive desc - std::shared_ptr fwd_desc; - - // memory desc - std::shared_ptr src_md; - std::shared_ptr filter_md; - std::shared_ptr bias_md; - std::shared_ptr dst_md; - - // convolution primitive - std::shared_ptr fwd_pd; - std::shared_ptr conv_fwd; - - std::shared_ptr fwd_stream; - std::vector fwd_primitives; - - ConvFwdContext() : - src_fmt(memory::format::any), filter_fmt(memory::format::any), - src_mem(nullptr), filter_mem(nullptr), bias_mem(nullptr), - dst_mem(nullptr), fwd_desc(nullptr), - src_md(nullptr), filter_md(nullptr), bias_md(nullptr), - fwd_pd(nullptr), conv_fwd(nullptr), fwd_stream(nullptr) { - } - } context_; - - engine cpu_engine_ = engine(engine::cpu, 0); - - void Setup(const MklConvFwdParams& convFwdDims) { + void Setup(const ConvFwdDimensions& convFwdDims) { // create memory descriptors for convolution data w/ no specified format - context_.src_md.reset(new memory::desc({convFwdDims.src_dims}, + src_md_.reset(new memory::desc({convFwdDims.src_dims}, MklDnnType(), memory::format::any)); - context_.filter_md.reset(new memory::desc({convFwdDims.filter_dims}, + filter_md_.reset(new memory::desc({convFwdDims.filter_dims}, MklDnnType(), memory::format::any)); - context_.dst_md.reset(new memory::desc({convFwdDims.dst_dims}, + dst_md_.reset(new memory::desc({convFwdDims.dst_dims}, MklDnnType(), memory::format::any)); if (!convFwdDims.bias_dims.empty()) - context_.bias_md.reset(new memory::desc({convFwdDims.bias_dims}, + bias_md_.reset(new memory::desc({convFwdDims.bias_dims}, MklDnnType(), memory::format::any)); // create a convolution if (!convFwdDims.bias_dims.empty()) { - context_.fwd_desc.reset(new convolution_forward::desc(prop_kind::forward, - convolution_direct, *context_.src_md, *context_.filter_md, - *context_.bias_md, *context_.dst_md, + fwd_desc_.reset(new convolution_forward::desc(prop_kind::forward, + convolution_direct, *src_md_, *filter_md_, *bias_md_, *dst_md_, convFwdDims.strides, convFwdDims.dilations, convFwdDims.padding_left, convFwdDims.padding_right, padding_kind::zero)); } else { - context_.fwd_desc.reset(new convolution_forward::desc(prop_kind::forward, - convolution_direct, *context_.src_md, *context_.filter_md, - *context_.dst_md, convFwdDims.strides, convFwdDims.dilations, - convFwdDims.padding_left, convFwdDims.padding_right, - padding_kind::zero)); + fwd_desc_.reset(new convolution_forward::desc(prop_kind::forward, + convolution_direct, *src_md_, *filter_md_, *dst_md_, + convFwdDims.strides, convFwdDims.dilations, convFwdDims.padding_left, + convFwdDims.padding_right, padding_kind::zero)); } - context_.fwd_pd.reset(new convolution_forward::primitive_desc( - *context_.fwd_desc, cpu_engine_)); + fwd_pd_.reset(new convolution_forward::primitive_desc( + *fwd_desc_, cpu_engine_)); // store the expected memory format - context_.src_fmt = static_cast( - context_.fwd_pd.get()->src_primitive_desc().desc().data.format); + src_fmt_ = static_cast( + fwd_pd_.get()->src_primitive_desc().desc().data.format); - context_.filter_fmt = static_cast( - context_.fwd_pd.get()->weights_primitive_desc().desc().data.format); + filter_fmt_ = static_cast( + fwd_pd_.get()->weights_primitive_desc().desc().data.format); // create memory primitive based on dummy data - context_.src_mem.reset(new memory( - context_.fwd_pd.get()->src_primitive_desc(), DummyData)); - context_.filter_mem.reset(new memory( - context_.fwd_pd.get()->weights_primitive_desc(), DummyData)); - context_.dst_mem.reset(new memory( - context_.fwd_pd.get()->dst_primitive_desc(), DummyData)); + src_mem_.reset(new memory(fwd_pd_.get()->src_primitive_desc(), DummyData)); + filter_mem_.reset(new memory(fwd_pd_.get()->weights_primitive_desc(), + DummyData)); + dst_mem_.reset(new memory(fwd_pd_.get()->dst_primitive_desc(), DummyData)); // create convolution primitive and add it to net if (!convFwdDims.bias_dims.empty()) { - context_.bias_mem.reset(new memory({{{convFwdDims.bias_dims}, - MklDnnType(), memory::format::x}, cpu_engine_}, DummyData)); - context_.conv_fwd.reset(new convolution_forward( - *context_.fwd_pd, *context_.src_mem, *context_.filter_mem, - *context_.bias_mem, *context_.dst_mem)); + bias_mem_.reset(new memory({{{convFwdDims.bias_dims}, MklDnnType(), + memory::format::x}, cpu_engine_}, DummyData)); + conv_fwd_.reset(new convolution_forward(*fwd_pd_, *src_mem_, + *filter_mem_, *bias_mem_, *dst_mem_)); } else { - context_.conv_fwd.reset(new convolution_forward( - *context_.fwd_pd, *context_.src_mem, - *context_.filter_mem, *context_.dst_mem)); + conv_fwd_.reset(new convolution_forward(*fwd_pd_, *src_mem_, + *filter_mem_, *dst_mem_)); } - context_.fwd_primitives.push_back(*context_.conv_fwd); + fwd_primitives_.push_back(*conv_fwd_); return; } + + // MKLDNN memory + std::shared_ptr src_mem_; + std::shared_ptr filter_mem_; + std::shared_ptr bias_mem_; + std::shared_ptr dst_mem_; + + std::shared_ptr fwd_stream_; + std::vector fwd_primitives_; + + // desc & prmitive desc + std::shared_ptr fwd_desc_; + + // memory desc + std::shared_ptr src_md_; + std::shared_ptr filter_md_; + std::shared_ptr bias_md_; + std::shared_ptr dst_md_; + + engine cpu_engine_ = engine(engine::cpu, 0); }; template -class MklConv2DFwdPrimitiveFactory : public MklPrimitiveFactory { +class Conv2DFwdFactory : public DnnOpFactory { public: - static MklConv2DFwdPrimitive* Get(const MklConvFwdParams& convFwdDims) { - MklConv2DFwdPrimitive* conv2d_fwd = nullptr; + static Conv2DFwd* Get(const ConvFwdDimensions& convFwdDims) { + Conv2DFwd* conv2d_fwd = nullptr; // try to find a suitable one in pool - conv2d_fwd = dynamic_cast*> ( - MklConv2DFwdPrimitiveFactory::GetInstance().GetConv2DFwd( - convFwdDims)); + conv2d_fwd = dynamic_cast*> ( + Conv2DFwdFactory::GetInstance().GetConv2DFwd(convFwdDims)); if (conv2d_fwd == nullptr) { - conv2d_fwd = new MklConv2DFwdPrimitive(convFwdDims); - MklConv2DFwdPrimitiveFactory::GetInstance().SetConv2DFwd( + conv2d_fwd = new Conv2DFwd(convFwdDims); + Conv2DFwdFactory::GetInstance().SetConv2DFwd( convFwdDims, conv2d_fwd); } return conv2d_fwd; } private: - MklConv2DFwdPrimitiveFactory() {} - ~MklConv2DFwdPrimitiveFactory() {} + Conv2DFwdFactory() {} + ~Conv2DFwdFactory() {} static const int kDilationH = 0, kDilationW = 1; - static MklConv2DFwdPrimitiveFactory& GetInstance() { - static MklConv2DFwdPrimitiveFactory instance_; + static Conv2DFwdFactory& GetInstance() { + static Conv2DFwdFactory instance_; return instance_; } - static std::string CreateKey(const MklConvFwdParams& convFwdDims) { + static std::string CreateKey(const ConvFwdDimensions& convFwdDims) { std::string prefix = "conv2d_fwd_"; FactoryKeyCreator key_creator; key_creator.AddAsKey(prefix); @@ -307,12 +266,12 @@ class MklConv2DFwdPrimitiveFactory : public MklPrimitiveFactory { return key_creator.GetKey(); } - MklPrimitive* GetConv2DFwd(const MklConvFwdParams& convFwdDims) { + DnnOp* GetConv2DFwd(const ConvFwdDimensions& convFwdDims) { std::string key = CreateKey(convFwdDims); return this->GetOp(key); } - void SetConv2DFwd(const MklConvFwdParams& convFwdDims, MklPrimitive *op) { + void SetConv2DFwd(const ConvFwdDimensions& convFwdDims, DnnOp *op) { std::string key = CreateKey(convFwdDims); this->SetOp(key, op); } @@ -803,6 +762,7 @@ class MklConv2DOp : public OpKernel { MklDnnData src(&cpu_engine); MklDnnData filter(&cpu_engine); + MklDnnData dst(&cpu_engine); // output memory::dims src_dims, filter_dims, padding_left, padding_right, dilations, strides; @@ -852,6 +812,7 @@ class MklConv2DOp : public OpKernel { auto src_md = src_mkl_shape.IsMklTensor() ? src_mkl_shape.GetMklLayout() : memory::desc(src_dims, MklDnnType(), tf_fmt); + src.SetUsrMem(src_md, &src_tensor); // Although filter shape (filter_dims) required is in MKL-DNN order, // the layout is Tensorflow's layout (HWIO). @@ -859,28 +820,29 @@ class MklConv2DOp : public OpKernel { ? filter_mkl_shape.GetMklLayout() : memory::desc(filter_dims, MklDnnType(), memory::format::hwio); + filter.SetUsrMem(filter_md, &filter_tensor); // MKLDNN dilation starts from 0. dilations[kDilationH] -= 1; dilations[kDilationW] -= 1; // get a conv2d fwd from primitive pool - MklConv2DFwdPrimitive *conv2d_fwd = nullptr; + Conv2DFwd *conv2d_fwd = nullptr; if (biasEnabled) { memory::dims bias_dims = {}; conv_utl.GetBiasSizeInMklOrder(kInputIndex_Bias, &bias_dims); - MklConvFwdParams convFwdDims(src_dims, filter_dims, bias_dims, + ConvFwdDimensions convFwdDims(src_dims, filter_dims, bias_dims, dst_dims_mkl_order, strides, dilations, padding_left, padding_right); - conv2d_fwd = MklConv2DFwdPrimitiveFactory::Get(convFwdDims); + conv2d_fwd = Conv2DFwdFactory::Get(convFwdDims); } else { - MklConvFwdParams convFwdDims(src_dims, filter_dims, NONE_DIMS, + ConvFwdDimensions convFwdDims(src_dims, filter_dims, NONE_DIMS, dst_dims_mkl_order, strides, dilations, padding_left, padding_right); - conv2d_fwd = MklConv2DFwdPrimitiveFactory::Get(convFwdDims); + conv2d_fwd = Conv2DFwdFactory::Get(convFwdDims); } // allocate output tensors output_tensor and filter_out_tensor std::shared_ptr - conv_fwd_pd = conv2d_fwd->GetPrimitiveDesc(); + conv_fwd_pd = conv2d_fwd->fwd_pd_; AllocateOutputTensor(context, *conv_fwd_pd, dst_dims_mkl_order, tf_fmt, &dst_tensor); Tensor* filter_out_tensor = nullptr; @@ -892,30 +854,20 @@ class MklConv2DOp : public OpKernel { // check whether src/filter need reorder std::vector net; - T *src_data = nullptr; - if (src_md.data.format != conv2d_fwd->GetSrcMemoryFormat()) { - src.SetUsrMem(src_md, &src_tensor); - src.CheckReorderToOpMem( - conv_fwd_pd.get()->src_primitive_desc(), &net); - src_data = static_cast(src.GetOpMem().get_data_handle()); - } else { - src_data = static_cast(const_cast( - src_tensor.flat().data())); - } - T *filter_data = nullptr; - if (filter_md.data.format != conv2d_fwd->GetFilterMemoryFormat()) { - filter.SetUsrMem(filter_md, &filter_tensor); - filter.CheckReorderToOpMem( - conv_fwd_pd.get()->weights_primitive_desc(), - filter.GetTensorBuffer(filter_out_tensor), &net); - filter_data = static_cast(filter.GetOpMem().get_data_handle()); - } else { - filter_data = static_cast(const_cast( - filter_tensor.flat().data())); - } - + if (src_md.data.format != conv2d_fwd->src_fmt_) + src.CheckReorderToOpMem( + conv_fwd_pd.get()->src_primitive_desc(), &net); + + if (filter_md.data.format != conv2d_fwd->filter_fmt_) + filter.CheckReorderToOpMem( + conv_fwd_pd.get()->weights_primitive_desc(), + filter.GetTensorBuffer(filter_out_tensor), &net); stream(stream::kind::eager).submit(net).wait(); + T* src_data = static_cast( + src.GetOpMem().get_data_handle()); + T* filter_data = static_cast( + filter.GetOpMem().get_data_handle()); // execute convolution if (biasEnabled) { -- GitLab From 52485e7b66c2b44174f76394937ea90bff898ac4 Mon Sep 17 00:00:00 2001 From: Guozhong Zhuang Date: Tue, 22 May 2018 21:58:18 -0700 Subject: [PATCH 012/437] minor code style fix --- tensorflow/core/util/mkl_util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/core/util/mkl_util.h b/tensorflow/core/util/mkl_util.h index 5dd2ee4521..b382065e4b 100644 --- a/tensorflow/core/util/mkl_util.h +++ b/tensorflow/core/util/mkl_util.h @@ -1804,7 +1804,7 @@ class MklDnnData { } }; -/// Base class for operations with reuse of primitives +/// Base class for operations with reuse of primitives /// class MklPrimitive { public: -- GitLab From 2701ab910894da95c25bcf6f2e30f0a6c2c20552 Mon Sep 17 00:00:00 2001 From: Florian Courtial Date: Wed, 30 May 2018 23:36:52 +0200 Subject: [PATCH 013/437] Add C++ SegmentSum gradient operation. --- tensorflow/cc/gradients/math_grad.cc | 20 ++++++++++++++++++++ tensorflow/cc/gradients/math_grad_test.cc | 10 ++++++++++ 2 files changed, 30 insertions(+) diff --git a/tensorflow/cc/gradients/math_grad.cc b/tensorflow/cc/gradients/math_grad.cc index 52c177212a..62404fff09 100644 --- a/tensorflow/cc/gradients/math_grad.cc +++ b/tensorflow/cc/gradients/math_grad.cc @@ -1006,6 +1006,26 @@ Status ProdGrad(const Scope& scope, const Operation& op, } REGISTER_GRADIENT_OP("Prod", ProdGrad); +Status SegmentSumGrad(const Scope& scope, const Operation& op, + const std::vector& grad_inputs, + std::vector* grad_outputs) { + // The SegmentSum operation sums segments of the Tensor that have the same + // index in the segment_ids parameter. + // i.e z = [2, 3, 4, 5], segment_ids [0, 0, 0, 1] + // will produce [2 + 3 + 4, 5] = [9, 5] + // The gradient that will flow back to the gather operation will look like + // [x1, x2], it will have the same shape as the output of the SegmentSum + // operation. The differentiation step of the SegmentSum operation just + // broadcast the gradient in order to retrieve the z's shape. + // dy/dz = [x1, x1, x1, x2] + grad_outputs->push_back(Gather(scope, grad_inputs[0], op.input(1))); + + // stop propagation along segment_ids + grad_outputs->push_back(NoGradient()); + return scope.status(); +} +REGISTER_GRADIENT_OP("SegmentSum", SegmentSumGrad); + // MatMulGrad helper function used to compute two MatMul operations // based on input matrix transposition combinations. Status MatMulGradHelper(const Scope& scope, const bool is_batch, diff --git a/tensorflow/cc/gradients/math_grad_test.cc b/tensorflow/cc/gradients/math_grad_test.cc index fd7b6fe662..acc100d144 100644 --- a/tensorflow/cc/gradients/math_grad_test.cc +++ b/tensorflow/cc/gradients/math_grad_test.cc @@ -41,6 +41,7 @@ using ops::Mul; using ops::Placeholder; using ops::Pow; using ops::Prod; +using ops::SegmentSum; using ops::RealDiv; using ops::SquaredDifference; using ops::Sub; @@ -902,5 +903,14 @@ TEST_F(NaryGradTest, Prod) { RunTest({x}, {x_shape}, {y}, {y_shape}); } +TEST_F(NaryGradTest, SegmentSum) { + TensorShape x_shape({3, 4}); + auto x = Placeholder(scope_, DT_FLOAT, Placeholder::Shape(x_shape)); + auto y = SegmentSum(scope_, x, {0, 0, 1}); + // the sum is always on the first dimension + TensorShape y_shape({2, 4}); + RunTest({x}, {x_shape}, {y}, {y_shape}); +} + } // namespace } // namespace tensorflow -- GitLab From fa0e2e361aa9b2ca4496b93cef5917f8c359d27d Mon Sep 17 00:00:00 2001 From: Koan-Sin Tan Date: Mon, 4 Jun 2018 12:02:37 +0800 Subject: [PATCH 014/437] [tflite] label_image for tflite in Python With model (mobilenet_v1_1.0_224_quant.tflite), input image (grace_hooper.bmp), and labels file (labels.txt) in /tmp. Run ``` bazel run --config opt //tensorflow/contrib/lite/examples/python:label_image ``` We can get results like ``` 0.470588: military uniform 0.337255: Windsor tie 0.047059: bow tie 0.031373: mortarboard 0.019608: suit ``` --- tensorflow/contrib/lite/examples/python/BUILD | 13 +++ .../lite/examples/python/label_image.py | 97 +++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 tensorflow/contrib/lite/examples/python/BUILD create mode 100644 tensorflow/contrib/lite/examples/python/label_image.py diff --git a/tensorflow/contrib/lite/examples/python/BUILD b/tensorflow/contrib/lite/examples/python/BUILD new file mode 100644 index 0000000000..d337c3ddc4 --- /dev/null +++ b/tensorflow/contrib/lite/examples/python/BUILD @@ -0,0 +1,13 @@ +licenses(["notice"]) # Apache 2.0 + +package(default_visibility = ["//tensorflow:internal"]) + +py_binary( + name = "label_image", + srcs = ["label_image.py"], + main = "label_image.py", + srcs_version = "PY2AND3", + deps = [ + "//tensorflow/contrib/lite/python:lite", + ], +) diff --git a/tensorflow/contrib/lite/examples/python/label_image.py b/tensorflow/contrib/lite/examples/python/label_image.py new file mode 100644 index 0000000000..77e0d7cb4d --- /dev/null +++ b/tensorflow/contrib/lite/examples/python/label_image.py @@ -0,0 +1,97 @@ +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== +"""label_image for tflite""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import argparse +import numpy as np + +from PIL import Image + +from tensorflow.contrib.lite.python import interpreter as interpreter_wrapper + +def load_labels(filename): + my_labels = [] + input_file = open(filename, 'r') + for l in input_file: + my_labels.append(l.strip()) + return my_labels + +if __name__ == "__main__": + file_name = "/tmp/grace_hopper.bmp" + model_file = "/tmp/mobilenet_v1_1.0_224_quant.tflite" + label_file = "/tmp/labels.txt" + input_mean = 127.5 + input_std = 127.5 + floating_model = False + + parser = argparse.ArgumentParser() + parser.add_argument("--image", help="image to be classified") + parser.add_argument("--graph", help=".tflite model to be executed") + parser.add_argument("--labels", help="name of file containing labels") + parser.add_argument("--input_mean", help="input_mean") + parser.add_argument("--input_std", help="input standard deviation") + args = parser.parse_args() + + if args.graph: + model_file = args.graph + if args.image: + file_name = args.image + if args.labels: + label_file = args.labels + if args.input_mean: + input_mean = args.input_mean + if args.input_std: + input_std = args.input_std + + interpreter = interpreter_wrapper.Interpreter(model_path=model_file) + interpreter.allocate_tensors() + + input_details = interpreter.get_input_details() + output_details = interpreter.get_output_details() + + # check the type of the input tensor + if input_details[0]['dtype'] == type(np.float32(1.0)): + floating_model = True + + # NxHxWxC, H:1, W:2 + height = input_details[0]['shape'][1] + width = input_details[0]['shape'][2] + img = Image.open(file_name) + img = img.resize((width, height)) + + # add N dim + input_data = np.expand_dims(img, axis=0) + + if floating_model: + input_data = (np.float32(input_data) - input_mean) / input_std + + interpreter.set_tensor(input_details[0]['index'], input_data) + + interpreter.invoke() + + output_data = interpreter.get_tensor(output_details[0]['index']) + results = np.squeeze(output_data) + + top_k = results.argsort()[-5:][::-1] + labels = load_labels(label_file) + for i in top_k: + if floating_model: + print('{0:08.6f}'.format(float(results[i]))+":", labels[i]) + else: + print('{0:08.6f}'.format(float(results[i]/255.0))+":", labels[i]) -- GitLab From 558622cd1a95adcd96d0172774342fbea09931eb Mon Sep 17 00:00:00 2001 From: Koan-Sin Tan Date: Mon, 4 Jun 2018 13:14:15 +0800 Subject: [PATCH 015/437] add simple description --- .../lite/examples/python/label_image.md | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tensorflow/contrib/lite/examples/python/label_image.md diff --git a/tensorflow/contrib/lite/examples/python/label_image.md b/tensorflow/contrib/lite/examples/python/label_image.md new file mode 100644 index 0000000000..fe7c5226f4 --- /dev/null +++ b/tensorflow/contrib/lite/examples/python/label_image.md @@ -0,0 +1,35 @@ +With model (mobilenet_v1_1.0_224_quant.tflite), input image +(grace_hooper.bmp), and labels file (labels.txt) in /tmp. +Run + +``` +bazel run --config opt //tensorflow/contrib/lite/examples/python:label_image +``` + +We can get results like + +``` +0.470588: military uniform +0.337255: Windsor tie +0.047059: bow tie +0.031373: mortarboard +0.019608: suit +``` + +Run + +``` +bazel run --config opt //tensorflow/contrib/lite/examples/python:label_image \ +-- --graph /tmp/mobilenet_v1_1.0_224.tflite +``` + +We can get results like +``` +0.728693: military uniform +0.116163: Windsor tie +0.035517: bow tie +0.014874: mortarboard +0.011758: bolo tie +``` + +Check [models](../../g3doc/models.md) hosted by Google. -- GitLab From d46c73a8766be9342164f3c01d94879746a7b3c2 Mon Sep 17 00:00:00 2001 From: tucan <37643248+tucan9389@users.noreply.github.com> Date: Wed, 6 Jun 2018 13:26:35 +0900 Subject: [PATCH 016/437] Update CONTRIBUTING.md Just update clang-tidy to `clang-tidy`. --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3dad41a88c..aab506f419 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -79,7 +79,7 @@ Bazel BUILD files also need to include a license section, e.g., Changes to TensorFlow C++ code should conform to [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html). -Use `clang-tidy` to check your C/C++ changes. To install clang-tidy on ubuntu:16.04, do: +Use `clang-tidy` to check your C/C++ changes. To install `clang-tidy` on ubuntu:16.04, do: ```bash apt-get install -y clang-tidy -- GitLab From b7fe5202599bef13996278c5812bced85eba8a9a Mon Sep 17 00:00:00 2001 From: accraze Date: Thu, 7 Jun 2018 17:53:35 -0700 Subject: [PATCH 017/437] fix indent on tests --- .../framework/python/ops/arg_scope_test.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tensorflow/contrib/framework/python/ops/arg_scope_test.py b/tensorflow/contrib/framework/python/ops/arg_scope_test.py index c58ff603f8..bcafc1a328 100644 --- a/tensorflow/contrib/framework/python/ops/arg_scope_test.py +++ b/tensorflow/contrib/framework/python/ops/arg_scope_test.py @@ -40,10 +40,10 @@ def func3(args, a=None, b=1, c=2): @add_arg_scope def func4(x='x', y='y'): - if x: - pass - if y: - pass + if x: + pass + if y: + pass def _key_op(op): return getattr(op, '_key_op', str(op)) @@ -241,10 +241,10 @@ class ArgScopeTest(test.TestCase): func4_kwargs = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h') for i in range(4): # redefine the function with different args - @add_arg_scope - def func4(a=1, b=2, c=3, d=4, e=5, f=6, g=7, h=8): - pass - self.assertTupleEqual(arg_scoped_arguments(func4), func4_kwargs) + @add_arg_scope + def func4(a=1, b=2, c=3, d=4, e=5, f=6, g=7, h=8): + pass + self.assertTupleEqual(arg_scoped_arguments(func4), func4_kwargs) def testDocString(self): self.assertEqual(func3.__doc__, 'Some cool doc string.') -- GitLab From e7450fd344623b550eda4dc3d43e936d6a8af936 Mon Sep 17 00:00:00 2001 From: Madiyar Date: Sun, 10 Jun 2018 16:05:40 +0100 Subject: [PATCH 018/437] Fix code typo in eager programmers guide --- tensorflow/docs_src/programmers_guide/eager.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tensorflow/docs_src/programmers_guide/eager.md b/tensorflow/docs_src/programmers_guide/eager.md index b2bc3273b4..babdb1db09 100644 --- a/tensorflow/docs_src/programmers_guide/eager.md +++ b/tensorflow/docs_src/programmers_guide/eager.md @@ -193,8 +193,7 @@ class MNISTModel(tf.keras.Model): def call(self, input): """Run the model.""" result = self.dense1(input) - result = self.dense2(result) - result = self.dense2(result) # reuse variables from dense2 layer + result = self.dense2(result) # reuse variables from dense1 layer return result model = MNISTModel() -- GitLab From 9671a9d1981c9f1dba4899f98c397f7be9565e53 Mon Sep 17 00:00:00 2001 From: Grzegorz Pawelczak Date: Tue, 12 Jun 2018 11:06:44 +0100 Subject: [PATCH 019/437] [XLA] Reduce maxval in random ops test. Reduced maxval in testRandomUniformIsNotConstant since the current value causes an overflow when using a device which supports DT_HALF. --- tensorflow/compiler/tests/random_ops_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/compiler/tests/random_ops_test.py b/tensorflow/compiler/tests/random_ops_test.py index f13dff9620..df458ba8b9 100644 --- a/tensorflow/compiler/tests/random_ops_test.py +++ b/tensorflow/compiler/tests/random_ops_test.py @@ -54,7 +54,7 @@ class RandomOpsTest(XLATestCase): def testRandomUniformIsNotConstant(self): def rng(dtype): - return random_ops.random_uniform(shape=[2], dtype=dtype, maxval=1000000) + return random_ops.random_uniform(shape=[2], dtype=dtype, maxval=100) for dtype in self._random_types(): self._testRngIsNotConstant(rng, dtype) -- GitLab From fb704f74c4f697a1d85cb18e24a48f1a86d0825b Mon Sep 17 00:00:00 2001 From: Grzegorz Pawelczak Date: Tue, 12 Jun 2018 18:25:58 +0100 Subject: [PATCH 020/437] [XLA] Skip float16 adam_tests. Adam tests compare the output of the computation against a hand wirtten numpy solution which does not take into account the precision and hence fail for float16. --- tensorflow/compiler/tests/adam_test.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tensorflow/compiler/tests/adam_test.py b/tensorflow/compiler/tests/adam_test.py index 3215dc36e5..ee56a38f94 100644 --- a/tensorflow/compiler/tests/adam_test.py +++ b/tensorflow/compiler/tests/adam_test.py @@ -52,6 +52,8 @@ class AdamOptimizerTest(XLATestCase): def testBasic(self): for dtype in self.float_types: + if dtype == np.float16: + continue with self.test_session(), self.test_scope(): variable_scope.get_variable_scope().set_use_resource(True) @@ -91,6 +93,8 @@ class AdamOptimizerTest(XLATestCase): def testTensorLearningRate(self): for dtype in self.float_types: + if dtype == np.float16: + continue with self.test_session(), self.test_scope(): variable_scope.get_variable_scope().set_use_resource(True) @@ -130,6 +134,8 @@ class AdamOptimizerTest(XLATestCase): def testSharing(self): for dtype in self.float_types: + if dtype == np.float16: + continue with self.test_session(), self.test_scope(): variable_scope.get_variable_scope().set_use_resource(True) -- GitLab From 9aca063ab5417fbda5217352330b62a4115286df Mon Sep 17 00:00:00 2001 From: Guozhong Zhuang Date: Tue, 12 Jun 2018 16:05:44 -0700 Subject: [PATCH 021/437] code refactoring per Rasmus's suggestions on PR 19754 --- .../core/kernels/mkl_fused_batch_norm_op.cc | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc b/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc index f4f6f8457d..b70724968c 100644 --- a/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc +++ b/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc @@ -702,7 +702,8 @@ template class MklFusedBatchNormFwdPrimitive : public MklPrimitive { public: explicit MklFusedBatchNormFwdPrimitive( - const MklBatchNormFwdParams& fwdParams) { + const MklBatchNormFwdParams& fwdParams) : + cpu_engine_(engine::cpu, 0) { context_.fwd_stream.reset( new mkldnn::stream(mkldnn::stream::kind::eager)); if (context_.bn_fwd == nullptr) @@ -750,7 +751,6 @@ class MklFusedBatchNormFwdPrimitive : public MklPrimitive { context_.mean_mem->set_data_handle(DummyData); context_.variance_mem->set_data_handle(DummyData); } - return; } memory::primitive_desc GetDstPd() const { @@ -791,7 +791,7 @@ class MklFusedBatchNormFwdPrimitive : public MklPrimitive { weights_mem(nullptr), dst_mem(nullptr), mean_mem(nullptr), variance_mem(nullptr), bn_fwd(nullptr), fwd_stream(nullptr) { } - } context_; + }; void Setup(const MklBatchNormFwdParams& fwdParams) { context_.flags = fwdParams.training ? use_scale_shift @@ -864,14 +864,14 @@ class MklFusedBatchNormFwdPrimitive : public MklPrimitive { } context_.fwd_primitives.push_back(*context_.bn_fwd); - return; } mkldnn::memory::desc get_desc_data(const mkldnn::memory &m) const { return m.get_primitive_desc().desc().data; } - engine cpu_engine_ = engine(engine::cpu, 0); + struct BatchNormFwdContext context_; + engine cpu_engine_; }; template @@ -942,7 +942,8 @@ template class MklFusedBatchNormBwdPrimitive : public MklPrimitive { public: explicit MklFusedBatchNormBwdPrimitive( - const MklBatchNormBwdParams& bwdParams) { + const MklBatchNormBwdParams& bwdParams) : + cpu_engine_(engine::cpu, 0) { context_.bwd_stream.reset( new mkldnn::stream(mkldnn::stream::kind::eager)); if (context_.bn_bwd == nullptr) @@ -993,7 +994,6 @@ class MklFusedBatchNormBwdPrimitive : public MklPrimitive { context_.diff_weights_mem->set_data_handle(DummyData); } context_.diff_src_mem->set_data_handle(DummyData); - return; } mkldnn_memory_format_t GetSrcFmt() { @@ -1032,7 +1032,8 @@ class MklFusedBatchNormBwdPrimitive : public MklPrimitive { diff_dst_mem(nullptr), weights_mem(nullptr), diff_weights_mem(nullptr), diff_src_mem(nullptr), bwd_stream(nullptr) { } - } context_; + }; + void Setup(const MklBatchNormBwdParams& bwdParams) { context_.flags = bwdParams.training ? use_scale_shift : (use_scale_shift | use_global_stats); @@ -1090,10 +1091,10 @@ class MklFusedBatchNormBwdPrimitive : public MklPrimitive { *context_.variance_mem, *context_.diff_dst_mem, *context_.weights_mem, *context_.diff_src_mem, *context_.diff_weights_mem)); context_.bwd_primitives.push_back(*context_.bn_bwd); - return; } - engine cpu_engine_ = engine(engine::cpu, 0); + struct BatchNormBwdContext context_; + engine cpu_engine_; }; template -- GitLab From 310e822b4c88169b140a4e5c8e37da756c91758a Mon Sep 17 00:00:00 2001 From: Yoshihiro Yamazaki Date: Fri, 15 Jun 2018 01:21:11 +0900 Subject: [PATCH 022/437] fix decode_png function. Problem: In the case of palette png & channels=0, force into grayscale. --- tensorflow/core/lib/png/png_io.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tensorflow/core/lib/png/png_io.cc b/tensorflow/core/lib/png/png_io.cc index 62c803afb2..2f6f94e24c 100644 --- a/tensorflow/core/lib/png/png_io.cc +++ b/tensorflow/core/lib/png/png_io.cc @@ -232,11 +232,19 @@ bool CommonInitDecode(StringPiece png_string, int desired_channels, CommonFreeDecode(context); return false; } - if (context->channels == 0) { // Autodetect number of channels - context->channels = png_get_channels(context->png_ptr, context->info_ptr); - } const bool has_tRNS = (png_get_valid(context->png_ptr, context->info_ptr, PNG_INFO_tRNS)) != 0; + if (context->channels == 0) { // Autodetect number of channels + if (context->color_type == PNG_COLOR_TYPE_PALETTE) { + if (has_tRNS) { + context->channels = 4; // RGB + A(tRNS) + } else { + context->channels = 3; // RGB + } + } else { + context->channels = png_get_channels(context->png_ptr, context->info_ptr); + } + } const bool has_alpha = (context->color_type & PNG_COLOR_MASK_ALPHA) != 0; if ((context->channels & 1) == 0) { // We desire alpha if (has_alpha) { // There is alpha -- GitLab From 58edf068d972ab161efadfc0da49deb217a8d6c8 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Mon, 4 Jun 2018 13:15:13 +0000 Subject: [PATCH 023/437] Restrict contrast_factor as scalar for AdjustContrastv2 shape The contrast_factor should be scalar for AdjustContrastv2. This fix adds the scalar restriction in the shape function. Signed-off-by: Yong Tang --- tensorflow/core/ops/image_ops.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tensorflow/core/ops/image_ops.cc b/tensorflow/core/ops/image_ops.cc index 87f4991134..e2707558e1 100644 --- a/tensorflow/core/ops/image_ops.cc +++ b/tensorflow/core/ops/image_ops.cc @@ -357,6 +357,9 @@ REGISTER_OP("AdjustContrastv2") .Input("contrast_factor: float") .Output("output: float") .SetShapeFn([](InferenceContext* c) { + // The contrast_factor should be scalar only. + ShapeHandle unused; + TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 0, &unused)); return shape_inference::UnchangedShapeWithRankAtLeast(c, 3); }); -- GitLab From 7cf3394e5cf164998c68ec71ecd4493d3a619b1a Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Mon, 4 Jun 2018 13:16:47 +0000 Subject: [PATCH 024/437] Add shape restriction to AdjustContrast as well. Signed-off-by: Yong Tang --- tensorflow/core/ops/image_ops.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tensorflow/core/ops/image_ops.cc b/tensorflow/core/ops/image_ops.cc index e2707558e1..d14791fb8b 100644 --- a/tensorflow/core/ops/image_ops.cc +++ b/tensorflow/core/ops/image_ops.cc @@ -348,6 +348,11 @@ REGISTER_OP("AdjustContrast") .Attr("T: {uint8, int8, int16, int32, int64, float, double}") .Deprecated(2, "Use AdjustContrastv2 instead") .SetShapeFn([](InferenceContext* c) { + // The contrast_factor, min_value, max_value should be scalar only. + ShapeHandle unused; + TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 0, &unused)); + TF_RETURN_IF_ERROR(c->WithRank(c->input(2), 0, &unused)); + TF_RETURN_IF_ERROR(c->WithRank(c->input(3), 0, &unused)); return shape_inference::UnchangedShapeWithRankAtLeast(c, 3); }); -- GitLab From f9bd050efbd89c4327fdcc6bd1ca444dcf3b4219 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Thu, 14 Jun 2018 16:37:47 +0000 Subject: [PATCH 025/437] Add test case for shape of adjust_contrast Signed-off-by: Yong Tang --- tensorflow/python/ops/image_ops_test.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tensorflow/python/ops/image_ops_test.py b/tensorflow/python/ops/image_ops_test.py index 2a6ab26e96..58e0e17d34 100644 --- a/tensorflow/python/ops/image_ops_test.py +++ b/tensorflow/python/ops/image_ops_test.py @@ -1410,6 +1410,14 @@ class AdjustContrastTest(test_util.TensorFlowTestCase): y_tf = self._adjustContrastTf(x_np, contrast_factor) self.assertAllClose(y_tf, y_np, rtol=1e-5, atol=1e-5) + def testContrastFactorShape(self): + x_shape = [1, 2, 2, 3] + x_data = [0, 5, 13, 54, 135, 226, 37, 8, 234, 90, 255, 1] + x_np = np.array(x_data, dtype=np.uint8).reshape(x_shape) + with self.assertRaisesRegexp( + ValueError, 'Shape must be rank 0 but is rank 1'): + image_ops.adjust_contrast(x_np, [2.0]) + class AdjustBrightnessTest(test_util.TensorFlowTestCase): -- GitLab From bc3204f3b030ba84120d46bb8503c615624448e9 Mon Sep 17 00:00:00 2001 From: Jason Taylor Date: Thu, 14 Jun 2018 16:18:27 -0400 Subject: [PATCH 026/437] tf.contrib.graph_editor.transform.copy_op_handler: change default copy_shape to False so graph_replace can work for network pruning where new weight shape does not match old weight shape --- tensorflow/contrib/graph_editor/transform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/contrib/graph_editor/transform.py b/tensorflow/contrib/graph_editor/transform.py index 026a3d1200..e79ccd8da1 100644 --- a/tensorflow/contrib/graph_editor/transform.py +++ b/tensorflow/contrib/graph_editor/transform.py @@ -129,7 +129,7 @@ def transform_op_if_inside_handler(info, op, keep_if_possible=True): return None -def copy_op_handler(info, op, new_inputs, copy_shape=True, nodedef_fn=None): +def copy_op_handler(info, op, new_inputs, copy_shape=False, nodedef_fn=None): """Copy a `tf.Operation`. Args: -- GitLab From e9482666b30689dac06077dbf4ecfc13ff00d523 Mon Sep 17 00:00:00 2001 From: Niranjan Hasabnis Date: Fri, 15 Jun 2018 11:22:55 -0700 Subject: [PATCH 027/437] [Intel-MKL] Support for N-D Transpose using MKL-DNN This PR adds support for N dimensional transpose using MKL-DNN. Since MKL-DNN requires exception support enabled for compilation, we create a new build rule for mkl_transpose_op, and thus the related changes in other build files. Also, since we can eliminate MKL binary blob for Transpose, we add corresponding preprocessor macros around transpose code. --- tensorflow/compiler/tf2xla/kernels/BUILD | 14 ++- tensorflow/core/kernels/BUILD | 42 +++++--- tensorflow/core/kernels/mkl_transpose_op.cc | 102 +++++++++++++++++++- tensorflow/core/kernels/transpose_op.cc | 2 +- tensorflow/core/kernels/transpose_op.h | 4 +- 5 files changed, 143 insertions(+), 21 deletions(-) diff --git a/tensorflow/compiler/tf2xla/kernels/BUILD b/tensorflow/compiler/tf2xla/kernels/BUILD index edd2ab6301..ec9683393f 100644 --- a/tensorflow/compiler/tf2xla/kernels/BUILD +++ b/tensorflow/compiler/tf2xla/kernels/BUILD @@ -6,6 +6,10 @@ package( load("//tensorflow:tensorflow.bzl", "tf_copts") load("//tensorflow:tensorflow.bzl", "tf_kernel_library") +load( + "//third_party/mkl:build_defs.bzl", + "if_mkl", +) tf_kernel_library( name = "xla_ops", @@ -140,8 +144,14 @@ tf_kernel_library( "//tensorflow/core/kernels:sparse_to_dense_op", "//tensorflow/core/kernels:stack_ops", "//tensorflow/core/kernels:training_ops", - "//tensorflow/core/kernels:transpose_op", - ], + ] + if_mkl( + [ + "//tensorflow/core/kernels:mkl_transpose_op", + ], + [ + "//tensorflow/core/kernels:transpose_op", + ], + ), ) tf_kernel_library( diff --git a/tensorflow/core/kernels/BUILD b/tensorflow/core/kernels/BUILD index 6487cd3971..1b7d0fcae6 100644 --- a/tensorflow/core/kernels/BUILD +++ b/tensorflow/core/kernels/BUILD @@ -647,7 +647,14 @@ cc_library( ":split_v_op", ":strided_slice_op", ":tile_ops", - ":transpose_op", + ] + if_mkl( + [ + ":mkl_transpose_op", + ], + [ + ":transpose_op", + ], + ) + [ ":unique_op", ":unpack_op", ":unravel_index_op", @@ -885,18 +892,27 @@ tf_kernel_library( deps = ARRAY_DEPS, ) -tf_kernel_library( - name = "transpose_op", - srcs = [ - "transpose_op.cc", - ] + if_mkl([ - "mkl_transpose_op.cc", - ]), - hdrs = ["transpose_op.h"], - deps = ARRAY_DEPS + if_mkl([ - "//third_party/mkl:intel_binary_blob", - "@mkl_dnn", - ]), +if_mkl( + [tf_mkl_kernel_library( + name = "mkl_transpose_op", + srcs = [ + "transpose_op.cc", + "mkl_transpose_op.cc", + ], + hdrs = ["transpose_op.h"], + deps = ARRAY_DEPS + if_mkl([ + "//third_party/mkl:intel_binary_blob", + "@mkl_dnn", + ]), + )], + [tf_kernel_library( + name = "transpose_op", + srcs = [ + "transpose_op.cc", + ], + hdrs = ["transpose_op.h"], + deps = ARRAY_DEPS, + )], ) tf_kernel_library( diff --git a/tensorflow/core/kernels/mkl_transpose_op.cc b/tensorflow/core/kernels/mkl_transpose_op.cc index b180c2ff20..a0a34fc723 100644 --- a/tensorflow/core/kernels/mkl_transpose_op.cc +++ b/tensorflow/core/kernels/mkl_transpose_op.cc @@ -15,13 +15,23 @@ limitations under the License. // See docs in ../ops/array_ops.cc. -#if defined(INTEL_MKL) && !defined(DO_NOT_USE_ML) +#if defined(INTEL_MKL) #define EIGEN_USE_THREADS +#if !defined(DO_NOT_USE_ML) #include "mkl_trans.h" +#endif + #include "tensorflow/core/kernels/transpose_functor.h" #include "tensorflow/core/kernels/transpose_op.h" +#ifndef INTEL_MKL_ML +#include "mkldnn.hpp" +#include "tensorflow/core/util/mkl_util.h" + +using mkldnn::stream; +#endif + namespace tensorflow { // output = TransposeOp(T input, T perm) takes a tensor @@ -40,6 +50,7 @@ namespace tensorflow { // REQUIRES: perm is a permutation. namespace { +#if !defined(DO_NOT_USE_ML) template Status MKLTranspose2D(const char trans, const Tensor& in, Tensor* out); @@ -93,11 +104,67 @@ Status MKLTranspose2D(const char trans, const Tensor& in, static const char kMKLTranspose = 'T'; static const char kMKLConjugateTranspose = 'C'; +#endif // if !defined(DO_NOT_USE_ML) + +#ifndef INTEL_MKL_ML +// MKL-DNN based Transpose implementation +template +Status MKLTransposeND(OpKernelContext* ctx, const Tensor& in, Tensor* out, + const gtl::ArraySlice& perm); + + +static inline memory::dims ReorderStrides(const memory::dims& strides, + const gtl::ArraySlice& perm) { + memory::dims reordered_strides; + reordered_strides.resize(strides.size()); + for (size_t i = 0; i < strides.size(); ++i) { + reordered_strides[perm[i]] = strides[i]; + } + return reordered_strides; +} + +// Transpose of N-dimensional tensor using MKL-DNN +template +Status MKLTransposeND(OpKernelContext* context, + const Tensor& in_tensor, Tensor* out_tensor, + const gtl::ArraySlice& perm) { + try { + engine cpu_engine = engine(engine::cpu, 0); + MklDnnData in(&cpu_engine); + MklDnnData out(&cpu_engine); + + memory::dims in_dims = TFShapeToMklDnnDims(in_tensor.shape()); + memory::dims out_dims = TFShapeToMklDnnDims(out_tensor->shape()); + memory::dims in_strides = CalculateTFStrides(in_dims); + // Reorder output strides based on permutation requested. + memory::dims out_strides = ReorderStrides(CalculateTFStrides(out_dims), + perm); + + in.SetUsrMem(in_dims, in_strides, &in_tensor); + // Output dimensions are same as input dimensions. We adjust the layout + // using strides. + out.SetUsrMem(in_dims, out_strides, out_tensor); + + std::vector net; + net.push_back(in.CreateReorder(in.GetUsrMem(), out.GetUsrMem())); + stream(stream::kind::eager).submit(net).wait(); + return Status::OK(); + } catch (mkldnn::error &e) { + string error_msg = "Status: " + std::to_string(e.status) + + ", message: " + std::string(e.message) + + ", in file " + std::string(__FILE__) + ":" + + std::to_string(__LINE__); + return errors::Aborted("Operation received an exception:", error_msg); + } +} +#endif // #ifndef INTEL_MKL_ML + } // namespace Status MklTransposeCpuOp::DoTranspose(OpKernelContext* ctx, const Tensor& in, gtl::ArraySlice perm, Tensor* out) { +#if !defined(DO_NOT_USE_ML) if (in.dims() == 2) { if (perm[0] == 0 && perm[1] == 1) { return Status::OK(); @@ -115,7 +182,21 @@ Status MklTransposeCpuOp::DoTranspose(OpKernelContext* ctx, const Tensor& in, break; } } - // Fallback to eigen if transpose parameters not supported by MKL +#endif + +#ifndef INTEL_MKL_ML + // MKL-DNN has limit on the maximum number of dimensions in a tensor. + // Fallback to Eigen for not supported cases. + if (in.dims() <= TENSOR_MAX_DIMS) { + switch (in.dtype()) { + case DT_FLOAT: return MKLTransposeND(ctx, in, out, perm); break; + // TODO(nhasabni): support other types such as INT8. + default: break; + } + } +#endif + + // Fallback to eigen if transpose parameters not supported by MKL or MKL-DNN typedef Eigen::ThreadPoolDevice CPUDevice; return ::tensorflow::DoTranspose(ctx->eigen_device(), in, perm, out); @@ -125,6 +206,7 @@ Status MklConjugateTransposeCpuOp::DoTranspose(OpKernelContext* ctx, const Tensor& in, gtl::ArraySlice perm, Tensor* out) { +#if !defined(DO_NOT_USE_ML) if (in.dims() == 2 && perm[0] == 1 && perm[1] == 0) { // TODO(rmlarsen): By setting lda and ldb, we could use the MKL kernels // for any transpose that can be reduced to swapping the last two @@ -143,7 +225,21 @@ Status MklConjugateTransposeCpuOp::DoTranspose(OpKernelContext* ctx, break; } } - // Fallback to eigen if transpose parameters not supported by MKL +#endif + +#ifndef INTEL_MKL_ML + // MKL-DNN has limit on the maximum number of dimensions in a tensor. + // Fallback to Eigen for not supported cases. + if (in.dims() <= TENSOR_MAX_DIMS) { + switch (in.dtype()) { + case DT_FLOAT: return MKLTransposeND(ctx, in, out, perm); break; + // TODO(nhasabni): support other types such as INT8. + default: break; + } + } +#endif + + // Fallback to eigen if transpose parameters not supported by MKL or MKL-DNN typedef Eigen::ThreadPoolDevice CPUDevice; return ::tensorflow::DoConjugateTranspose(ctx->eigen_device(), in, perm, out); diff --git a/tensorflow/core/kernels/transpose_op.cc b/tensorflow/core/kernels/transpose_op.cc index 886b3e7492..0f0f65c5a3 100644 --- a/tensorflow/core/kernels/transpose_op.cc +++ b/tensorflow/core/kernels/transpose_op.cc @@ -218,7 +218,7 @@ Status ConjugateTransposeCpuOp::DoTranspose(OpKernelContext* ctx, perm, out); } -#if defined(INTEL_MKL) && !defined(DO_NOT_USE_ML) +#if defined(INTEL_MKL) #define REGISTER(T) \ REGISTER_KERNEL_BUILDER(Name("Transpose") \ .Device(DEVICE_CPU) \ diff --git a/tensorflow/core/kernels/transpose_op.h b/tensorflow/core/kernels/transpose_op.h index 709b0a92e9..9e8c573761 100644 --- a/tensorflow/core/kernels/transpose_op.h +++ b/tensorflow/core/kernels/transpose_op.h @@ -42,7 +42,7 @@ class TransposeCpuOp : public TransposeOp { gtl::ArraySlice perm, Tensor* out) override; }; -#if defined(INTEL_MKL) && !defined(DO_NOT_USE_ML) +#if defined(INTEL_MKL) class MklTransposeCpuOp : public TransposeOp { public: explicit MklTransposeCpuOp(OpKernelConstruction* ctx) : TransposeOp(ctx) {} @@ -85,7 +85,7 @@ class ConjugateTransposeCpuOp : public TransposeOp { bool IsConjugate() const override { return true; } }; -#if defined(INTEL_MKL) && !defined(DO_NOT_USE_ML) +#if defined(INTEL_MKL) class MklConjugateTransposeCpuOp : public TransposeOp { public: explicit MklConjugateTransposeCpuOp(OpKernelConstruction* ctx) -- GitLab From cb91b26c38c36d6a6c410bf8807868d5677a61fb Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Sat, 16 Jun 2018 14:43:12 +0000 Subject: [PATCH 028/437] Some enhancement on S3 file system error processing This fix is an enhancement on S3 file system error processing. As TF's errors API allows takes variadic arguments, this fix removed the unneeded string concatenation for error message generation Signed-off-by: Yong Tang --- tensorflow/core/platform/s3/s3_file_system.cc | 35 ++++--------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/tensorflow/core/platform/s3/s3_file_system.cc b/tensorflow/core/platform/s3/s3_file_system.cc index 6da679dc75..9647bbaa7f 100644 --- a/tensorflow/core/platform/s3/s3_file_system.cc +++ b/tensorflow/core/platform/s3/s3_file_system.cc @@ -256,10 +256,7 @@ class S3WritableFile : public WritableFile { outfile_->clear(); outfile_->seekp(offset); if (!putObjectOutcome.IsSuccess()) { - string error = strings::StrCat( - putObjectOutcome.GetError().GetExceptionName().c_str(), ": ", - putObjectOutcome.GetError().GetMessage().c_str()); - return errors::Internal(error); + return errors::Unknown(putObjectOutcome.GetError().GetExceptionName(), ": ", putObjectOutcome.GetError().GetMessage()); } return Status::OK(); } @@ -412,10 +409,7 @@ Status S3FileSystem::GetChildren(const string& dir, auto listObjectsOutcome = this->GetS3Client()->ListObjects(listObjectsRequest); if (!listObjectsOutcome.IsSuccess()) { - string error = strings::StrCat( - listObjectsOutcome.GetError().GetExceptionName().c_str(), ": ", - listObjectsOutcome.GetError().GetMessage().c_str()); - return errors::Internal(error); + return errors::Unknown(listObjectsOutcome.GetError().GetExceptionName(), ": ", listObjectsOutcome.GetError().GetMessage()); } listObjectsResult = listObjectsOutcome.GetResult(); @@ -449,10 +443,7 @@ Status S3FileSystem::Stat(const string& fname, FileStatistics* stats) { headBucketRequest.WithBucket(bucket.c_str()); auto headBucketOutcome = this->GetS3Client()->HeadBucket(headBucketRequest); if (!headBucketOutcome.IsSuccess()) { - string error = strings::StrCat( - headBucketOutcome.GetError().GetExceptionName().c_str(), ": ", - headBucketOutcome.GetError().GetMessage().c_str()); - return errors::Internal(error); + return errors::Unknown(headBucketOutcome.GetError().GetExceptionName(), ": ", headBucketOutcome.GetError().GetMessage()); } stats->length = 0; stats->is_directory = 1; @@ -513,10 +504,7 @@ Status S3FileSystem::DeleteFile(const string& fname) { auto deleteObjectOutcome = this->GetS3Client()->DeleteObject(deleteObjectRequest); if (!deleteObjectOutcome.IsSuccess()) { - string error = strings::StrCat( - deleteObjectOutcome.GetError().GetExceptionName().c_str(), ": ", - deleteObjectOutcome.GetError().GetMessage().c_str()); - return errors::Internal(error); + return errors::Unknown(deleteObjectOutcome.GetError().GetExceptionName(), ": ", deleteObjectOutcome.GetError().GetMessage()); } return Status::OK(); } @@ -614,10 +602,7 @@ Status S3FileSystem::RenameFile(const string& src, const string& target) { auto listObjectsOutcome = this->GetS3Client()->ListObjects(listObjectsRequest); if (!listObjectsOutcome.IsSuccess()) { - string error = strings::StrCat( - listObjectsOutcome.GetError().GetExceptionName().c_str(), ": ", - listObjectsOutcome.GetError().GetMessage().c_str()); - return errors::Internal(error); + return errors::Unknown(listObjectsOutcome.GetError().GetExceptionName(), ": ", listObjectsOutcome.GetError().GetMessage()); } listObjectsResult = listObjectsOutcome.GetResult(); @@ -635,10 +620,7 @@ Status S3FileSystem::RenameFile(const string& src, const string& target) { auto copyObjectOutcome = this->GetS3Client()->CopyObject(copyObjectRequest); if (!copyObjectOutcome.IsSuccess()) { - string error = strings::StrCat( - copyObjectOutcome.GetError().GetExceptionName().c_str(), ": ", - copyObjectOutcome.GetError().GetMessage().c_str()); - return errors::Internal(error); + return errors::Unknown(copyObjectOutcome.GetError().GetExceptionName(), ": ", copyObjectOutcome.GetError().GetMessage()); } deleteObjectRequest.SetBucket(src_bucket.c_str()); @@ -647,10 +629,7 @@ Status S3FileSystem::RenameFile(const string& src, const string& target) { auto deleteObjectOutcome = this->GetS3Client()->DeleteObject(deleteObjectRequest); if (!deleteObjectOutcome.IsSuccess()) { - string error = strings::StrCat( - deleteObjectOutcome.GetError().GetExceptionName().c_str(), ": ", - deleteObjectOutcome.GetError().GetMessage().c_str()); - return errors::Internal(error); + return errors::Unknown(deleteObjectOutcome.GetError().GetExceptionName(), ": ", deleteObjectOutcome.GetError().GetMessage()); } } listObjectsRequest.SetMarker(listObjectsResult.GetNextMarker()); -- GitLab From f8844f932d63a020f8ca44c012df2b26600df002 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Sat, 16 Jun 2018 15:34:32 +0000 Subject: [PATCH 029/437] Format with clang-format -i --style=google Signed-off-by: Yong Tang --- tensorflow/core/platform/s3/s3_file_system.cc | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tensorflow/core/platform/s3/s3_file_system.cc b/tensorflow/core/platform/s3/s3_file_system.cc index 9647bbaa7f..6655c560e3 100644 --- a/tensorflow/core/platform/s3/s3_file_system.cc +++ b/tensorflow/core/platform/s3/s3_file_system.cc @@ -24,9 +24,9 @@ limitations under the License. #include #include #include +#include #include #include -#include #include #include #include @@ -256,7 +256,8 @@ class S3WritableFile : public WritableFile { outfile_->clear(); outfile_->seekp(offset); if (!putObjectOutcome.IsSuccess()) { - return errors::Unknown(putObjectOutcome.GetError().GetExceptionName(), ": ", putObjectOutcome.GetError().GetMessage()); + return errors::Unknown(putObjectOutcome.GetError().GetExceptionName(), + ": ", putObjectOutcome.GetError().GetMessage()); } return Status::OK(); } @@ -409,7 +410,8 @@ Status S3FileSystem::GetChildren(const string& dir, auto listObjectsOutcome = this->GetS3Client()->ListObjects(listObjectsRequest); if (!listObjectsOutcome.IsSuccess()) { - return errors::Unknown(listObjectsOutcome.GetError().GetExceptionName(), ": ", listObjectsOutcome.GetError().GetMessage()); + return errors::Unknown(listObjectsOutcome.GetError().GetExceptionName(), + ": ", listObjectsOutcome.GetError().GetMessage()); } listObjectsResult = listObjectsOutcome.GetResult(); @@ -443,7 +445,8 @@ Status S3FileSystem::Stat(const string& fname, FileStatistics* stats) { headBucketRequest.WithBucket(bucket.c_str()); auto headBucketOutcome = this->GetS3Client()->HeadBucket(headBucketRequest); if (!headBucketOutcome.IsSuccess()) { - return errors::Unknown(headBucketOutcome.GetError().GetExceptionName(), ": ", headBucketOutcome.GetError().GetMessage()); + return errors::Unknown(headBucketOutcome.GetError().GetExceptionName(), + ": ", headBucketOutcome.GetError().GetMessage()); } stats->length = 0; stats->is_directory = 1; @@ -504,7 +507,8 @@ Status S3FileSystem::DeleteFile(const string& fname) { auto deleteObjectOutcome = this->GetS3Client()->DeleteObject(deleteObjectRequest); if (!deleteObjectOutcome.IsSuccess()) { - return errors::Unknown(deleteObjectOutcome.GetError().GetExceptionName(), ": ", deleteObjectOutcome.GetError().GetMessage()); + return errors::Unknown(deleteObjectOutcome.GetError().GetExceptionName(), + ": ", deleteObjectOutcome.GetError().GetMessage()); } return Status::OK(); } @@ -602,7 +606,8 @@ Status S3FileSystem::RenameFile(const string& src, const string& target) { auto listObjectsOutcome = this->GetS3Client()->ListObjects(listObjectsRequest); if (!listObjectsOutcome.IsSuccess()) { - return errors::Unknown(listObjectsOutcome.GetError().GetExceptionName(), ": ", listObjectsOutcome.GetError().GetMessage()); + return errors::Unknown(listObjectsOutcome.GetError().GetExceptionName(), + ": ", listObjectsOutcome.GetError().GetMessage()); } listObjectsResult = listObjectsOutcome.GetResult(); @@ -620,7 +625,8 @@ Status S3FileSystem::RenameFile(const string& src, const string& target) { auto copyObjectOutcome = this->GetS3Client()->CopyObject(copyObjectRequest); if (!copyObjectOutcome.IsSuccess()) { - return errors::Unknown(copyObjectOutcome.GetError().GetExceptionName(), ": ", copyObjectOutcome.GetError().GetMessage()); + return errors::Unknown(copyObjectOutcome.GetError().GetExceptionName(), + ": ", copyObjectOutcome.GetError().GetMessage()); } deleteObjectRequest.SetBucket(src_bucket.c_str()); @@ -629,7 +635,9 @@ Status S3FileSystem::RenameFile(const string& src, const string& target) { auto deleteObjectOutcome = this->GetS3Client()->DeleteObject(deleteObjectRequest); if (!deleteObjectOutcome.IsSuccess()) { - return errors::Unknown(deleteObjectOutcome.GetError().GetExceptionName(), ": ", deleteObjectOutcome.GetError().GetMessage()); + return errors::Unknown( + deleteObjectOutcome.GetError().GetExceptionName(), ": ", + deleteObjectOutcome.GetError().GetMessage()); } } listObjectsRequest.SetMarker(listObjectsResult.GetNextMarker()); -- GitLab From df1134694f47b9a924df1bf48f673392ee1d3e15 Mon Sep 17 00:00:00 2001 From: Grzegorz Pawelczak Date: Tue, 19 Jun 2018 09:08:00 +0100 Subject: [PATCH 030/437] Add comments explaining why the test is skipped for f16 --- tensorflow/compiler/tests/adam_test.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tensorflow/compiler/tests/adam_test.py b/tensorflow/compiler/tests/adam_test.py index ee56a38f94..b904e6676b 100644 --- a/tensorflow/compiler/tests/adam_test.py +++ b/tensorflow/compiler/tests/adam_test.py @@ -52,6 +52,7 @@ class AdamOptimizerTest(XLATestCase): def testBasic(self): for dtype in self.float_types: + # TODO: test fails for float16 due to excessive precision requirements. if dtype == np.float16: continue with self.test_session(), self.test_scope(): @@ -93,6 +94,7 @@ class AdamOptimizerTest(XLATestCase): def testTensorLearningRate(self): for dtype in self.float_types: + # TODO: test fails for float16 due to excessive precision requirements. if dtype == np.float16: continue with self.test_session(), self.test_scope(): @@ -134,6 +136,7 @@ class AdamOptimizerTest(XLATestCase): def testSharing(self): for dtype in self.float_types: + # TODO: test fails for float16 due to excessive precision requirements. if dtype == np.float16: continue with self.test_session(), self.test_scope(): -- GitLab From 39b756322b96d4296c5f077991768534077d381e Mon Sep 17 00:00:00 2001 From: Grzegorz Pawelczak Date: Tue, 19 Jun 2018 09:14:43 +0100 Subject: [PATCH 031/437] Use the max value of the type as upper bound to minimise chances of repeated numbers --- tensorflow/compiler/tests/random_ops_test.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tensorflow/compiler/tests/random_ops_test.py b/tensorflow/compiler/tests/random_ops_test.py index df458ba8b9..9c7b5a361b 100644 --- a/tensorflow/compiler/tests/random_ops_test.py +++ b/tensorflow/compiler/tests/random_ops_test.py @@ -54,7 +54,11 @@ class RandomOpsTest(XLATestCase): def testRandomUniformIsNotConstant(self): def rng(dtype): - return random_ops.random_uniform(shape=[2], dtype=dtype, maxval=100) + if np.issubdtype(dtype, np.float): + maxval=np.finfo(dtype).max + else: + maxval=np.iinfo(dtype).max + return random_ops.random_uniform(shape=[2], dtype=dtype, maxval=maxval) for dtype in self._random_types(): self._testRngIsNotConstant(rng, dtype) -- GitLab From dbe650786f9071ac3494731e09de14c6240018df Mon Sep 17 00:00:00 2001 From: Koan-Sin Tan Date: Tue, 26 Jun 2018 09:54:37 +0800 Subject: [PATCH 032/437] fix tests in lite/kernels/internal make ``` bazel test -config opt //tensorflow/contrib/lite/kernels/internal:all ``` work. So that ``` bazel test -config opt //tensorflow/contrib/lite/kernels/... ``` works --- .../kernels/internal/log_quantized_test.cc | 12 +++---- .../internal/logsoftmax_quantized_test.cc | 2 +- .../internal/quantization_util_test.cc | 32 +++++++++---------- .../internal/softmax_quantized_test.cc | 2 +- .../kernels/internal/tensor_utils_test.cc | 16 ++++++---- 5 files changed, 33 insertions(+), 31 deletions(-) diff --git a/tensorflow/contrib/lite/kernels/internal/log_quantized_test.cc b/tensorflow/contrib/lite/kernels/internal/log_quantized_test.cc index 7e9ff5242a..5dd03db8e3 100644 --- a/tensorflow/contrib/lite/kernels/internal/log_quantized_test.cc +++ b/tensorflow/contrib/lite/kernels/internal/log_quantized_test.cc @@ -69,7 +69,7 @@ inline int32 LogPositiveValuesViaFloat(int32 input_val, int input_integer_bits, void CheckOutputData(const std::vector& test_output, const std::vector& reference_output, const std::vector& test_input, - const string& check_label, int input_integer_bits, + const std::string& check_label, int input_integer_bits, int output_integer_bits, int tolerance) { // In the special case of small input, specifically raw value of 5, a rounding // up leads to difference in the output. We do not aim to be accurate for @@ -117,7 +117,7 @@ void RightShiftVector(const std::vector& shifts, template void RunSingleTest(const std::vector& test_input, - const string& check_label, int tolerance) { + const std::string& check_label, int tolerance) { const int n = test_input.size(); std::vector float_gen_output(n, 0); std::vector reference_output(n, 0); @@ -175,7 +175,7 @@ void RunSingleTest(const std::vector& test_input, template void RunSingleTest(const std::vector& test_input, int input_integer_bits, - const string& check_label, int tolerance) { + const std::string& check_label, int tolerance) { #define INPUT_CASE(K) \ case K: \ return RunSingleTest(test_input, check_label, \ @@ -219,7 +219,7 @@ void RunSingleTest(const std::vector& test_input, int input_integer_bits, } void RunSingleTest(const std::vector& test_input, int input_integer_bits, - int output_integer_bits, const string& check_label, + int output_integer_bits, const std::string& check_label, int tolerance) { #define OUTPUT_CASE(K) \ case K: \ @@ -264,7 +264,7 @@ void RunSingleTest(const std::vector& test_input, int input_integer_bits, } void RunUniformTest(int test_size, int input_integer_bits, - int output_integer_bits, const string& check_label, + int output_integer_bits, const std::string& check_label, int tolerance, NumberGenerator* generator) { std::vector test_data = generator->RandomIntVector( test_size, 2, std::numeric_limits::max() - 1); @@ -281,7 +281,7 @@ void RunUniformTest(int test_size, int input_integer_bits, void RunUniformShiftUniformTest(int test_size, int input_integer_bits, int output_integer_bits, - const string& check_label, int tolerance, + const std::string& check_label, int tolerance, NumberGenerator* generator) { std::vector test_data = generator->RandomIntVector( test_size, 2, std::numeric_limits::max() - 1); diff --git a/tensorflow/contrib/lite/kernels/internal/logsoftmax_quantized_test.cc b/tensorflow/contrib/lite/kernels/internal/logsoftmax_quantized_test.cc index d2f1103e14..e82af96519 100644 --- a/tensorflow/contrib/lite/kernels/internal/logsoftmax_quantized_test.cc +++ b/tensorflow/contrib/lite/kernels/internal/logsoftmax_quantized_test.cc @@ -58,7 +58,7 @@ void RunLogSoftmaxFloatReference(const uint8* input_data, void CheckOutputData(const uint8* test_output, const uint8* reference_output, const RuntimeShape& shape_common, - const string& check_label, bool be_exacting) { + const std::string& check_label, bool be_exacting) { const int buffer_size = shape_common.FlatSize(); // While calculating some metrics in floating point, we work with quantized // scaling. diff --git a/tensorflow/contrib/lite/kernels/internal/quantization_util_test.cc b/tensorflow/contrib/lite/kernels/internal/quantization_util_test.cc index 94773b47d3..00fc3e91dc 100644 --- a/tensorflow/contrib/lite/kernels/internal/quantization_util_test.cc +++ b/tensorflow/contrib/lite/kernels/internal/quantization_util_test.cc @@ -130,22 +130,22 @@ void RunSafeCastTests() { } TEST(QuantizationUtilTest, SafeCast) { - RunSafeCastTests(); - RunSafeCastTests(); - RunSafeCastTests(); - RunSafeCastTests(); - RunSafeCastTests(); - RunSafeCastTests(); - RunSafeCastTests(); - RunSafeCastTests(); - RunSafeCastTests(); - RunSafeCastTests(); - RunSafeCastTests(); - RunSafeCastTests(); - RunSafeCastTests(); - RunSafeCastTests(); - RunSafeCastTests(); - RunSafeCastTests(); + RunSafeCastTests(); + RunSafeCastTests(); + RunSafeCastTests(); + RunSafeCastTests(); + RunSafeCastTests(); + RunSafeCastTests(); + RunSafeCastTests(); + RunSafeCastTests(); + RunSafeCastTests(); + RunSafeCastTests(); + RunSafeCastTests(); + RunSafeCastTests(); + RunSafeCastTests(); + RunSafeCastTests(); + RunSafeCastTests(); + RunSafeCastTests(); } // Example taken from http://www.tensorflow.org/performance/quantization diff --git a/tensorflow/contrib/lite/kernels/internal/softmax_quantized_test.cc b/tensorflow/contrib/lite/kernels/internal/softmax_quantized_test.cc index a7dad3c14e..bbfc5b6474 100644 --- a/tensorflow/contrib/lite/kernels/internal/softmax_quantized_test.cc +++ b/tensorflow/contrib/lite/kernels/internal/softmax_quantized_test.cc @@ -58,7 +58,7 @@ void RunSoftmaxFloatReference(const uint8* input_data, void CheckOutputData(const uint8* test_output, const uint8* reference_output, const RuntimeShape& shape_common, - const string& check_label, bool be_exacting) { + const std::string& check_label, bool be_exacting) { const int buffer_size = shape_common.FlatSize(); // While calculating some metrics in floating point, we work with quantized // scaling. diff --git a/tensorflow/contrib/lite/kernels/internal/tensor_utils_test.cc b/tensorflow/contrib/lite/kernels/internal/tensor_utils_test.cc index 14ee528394..82118cfbd3 100644 --- a/tensorflow/contrib/lite/kernels/internal/tensor_utils_test.cc +++ b/tensorflow/contrib/lite/kernels/internal/tensor_utils_test.cc @@ -56,7 +56,7 @@ TEST(uKernels, SymmetricQuantizeFloatsTest) { static float input[kVectorSize] = {-640, -635.0, -630, 10.0, 2.0, -5.0, -10.0, 0.0, 1000.0}; - int8 output[kVectorSize]; + int8_t output[kVectorSize]; float min, max, scaling_factor; SymmetricQuantizeFloats(input, kVectorSize, output, &min, &max, &scaling_factor); @@ -72,7 +72,7 @@ TEST(uKernels, SymmetricQuantizeFloatsAllZerosTest) { constexpr int kVectorSize = 9; static float input[kVectorSize] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; - int8 output[kVectorSize]; + int8_t output[kVectorSize]; float min, max, scaling_factor; SymmetricQuantizeFloats(input, kVectorSize, output, &min, &max, &scaling_factor); @@ -88,7 +88,7 @@ TEST(uKernels, SymmetricQuantizeFloatsAllAlmostZeroTest) { static float input[kVectorSize] = {-1e-5, 3e-5, -7e-6, -9e-5, 1e-6, 4e-5, 9e-6, 2e-4, 0}; - int8 output[kVectorSize]; + int8_t output[kVectorSize]; float min, max, scaling_factor; SymmetricQuantizeFloats(input, kVectorSize, output, &min, &max, &scaling_factor); @@ -126,6 +126,7 @@ TEST(uKernels, MatrixBatchVectorMultiplyAccumulateTest) { -1., 3., 7., 3., 23., 3.}))); } +#ifdef __ANDROID__ TEST(uKernels, MatrixBatchVectorMultiplyAccumulateSymmetricQuantizedTest) { // Note we use 29 columns as this exercises all the neon kernel: the // 16-block SIMD code, the 8-block postamble, and the leftover postamble. @@ -149,13 +150,13 @@ TEST(uKernels, MatrixBatchVectorMultiplyAccumulateSymmetricQuantizedTest) { -13.13, 14.14, -15.15, 16.16, -17.17, 18.18, -19.19, 20.2, -21.21, 22.22, -23.23, 24.24, -25.25, 26.26, -27.27, 28.28, 0}; - int8* a_int8_data = reinterpret_cast( + int8_t* a_int8_data = reinterpret_cast( aligned_malloc(a_rows * a_cols, kWeightsPerUint32)); float a_min, a_max; float scaling_factor_a; SymmetricQuantizeFloats(a_float_data, a_rows * a_cols, a_int8_data, &a_min, &a_max, &scaling_factor_a); - const int8 expected_a_int8_data[] = { + const int8_t expected_a_int8_data[] = { /* 1st row */ 5, 10, @@ -346,7 +347,7 @@ TEST(uKernels, MatrixBatchVectorMultiplyAccumulateSymmetricQuantizedTest) { }; // Quantized values of B: - int8 b_int8_data[b_rows * b_cols * batches]; + int8_t b_int8_data[b_rows * b_cols * batches]; float b_min, b_max; float scaling_factor_b[batches]; SymmetricQuantizeFloats(b_float_data, b_rows * b_cols, b_int8_data, &b_min, @@ -355,7 +356,7 @@ TEST(uKernels, MatrixBatchVectorMultiplyAccumulateSymmetricQuantizedTest) { &b_int8_data[b_rows * b_cols], &b_min, &b_max, &scaling_factor_b[1]); - const int8 expected_b_int8_data[] = { + const int8_t expected_b_int8_data[] = { /* batch 1 */ 127, -127, @@ -448,6 +449,7 @@ TEST(uKernels, MatrixBatchVectorMultiplyAccumulateSymmetricQuantizedTest) { aligned_free(a_int8_data); } +#endif // __ANDROID__ TEST(uKernels, VectorVectorCwiseProductTest) { constexpr int kVectorSize = 10; -- GitLab From 57dacd87afc9d6e30bb11480deccf5481f8d3bc3 Mon Sep 17 00:00:00 2001 From: Koan-Sin Tan Date: Wed, 27 Jun 2018 13:02:00 +0800 Subject: [PATCH 033/437] updated --- .../lite/examples/python/label_image.md | 23 +++++++++-- .../lite/examples/python/label_image.py | 41 +++++++------------ 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/tensorflow/contrib/lite/examples/python/label_image.md b/tensorflow/contrib/lite/examples/python/label_image.md index fe7c5226f4..e81192a96c 100644 --- a/tensorflow/contrib/lite/examples/python/label_image.md +++ b/tensorflow/contrib/lite/examples/python/label_image.md @@ -1,8 +1,22 @@ -With model (mobilenet_v1_1.0_224_quant.tflite), input image -(grace_hooper.bmp), and labels file (labels.txt) in /tmp. + +With model, input image (grace_hopper.bmp), and labels file (labels.txt) +in /tmp. + +The example input image and labels file are from TensorFlow repo and +MobileNet V1 model files. + +``` +curl https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/contrib/lite/examples/label_image/testdata/grace_hopper.bmp > /tmp/grace_hopper.bmp + +curl https://storage.googleapis.com/download.tensorflow.org/models/mobilenet_v1_1.0_224_frozen.tgz | tar xzv -C /tmp mobilenet_v1_1.0_224/labels.txt +mv /tmp/mobilenet_v1_1.0_224/labels.txt /tmp/ + +``` + Run ``` +curl http://download.tensorflow.org/models/mobilenet_v1_2018_02_22/mobilenet_v1_1.0_224_quant.tgz | tar xzv -C /tmp bazel run --config opt //tensorflow/contrib/lite/examples/python:label_image ``` @@ -19,8 +33,9 @@ We can get results like Run ``` +curl http://download.tensorflow.org/models/mobilenet_v1_2018_02_22/mobilenet_v1_1.0_224.tgz | tar xzv -C /tmp bazel run --config opt //tensorflow/contrib/lite/examples/python:label_image \ --- --graph /tmp/mobilenet_v1_1.0_224.tflite +-- --model_file /tmp/mobilenet_v1_1.0_224.tflite ``` We can get results like @@ -32,4 +47,4 @@ We can get results like 0.011758: bolo tie ``` -Check [models](../../g3doc/models.md) hosted by Google. +Check [models](../../g3doc/models.md) for models hosted by Google. diff --git a/tensorflow/contrib/lite/examples/python/label_image.py b/tensorflow/contrib/lite/examples/python/label_image.py index 77e0d7cb4d..282118a1d2 100644 --- a/tensorflow/contrib/lite/examples/python/label_image.py +++ b/tensorflow/contrib/lite/examples/python/label_image.py @@ -33,53 +33,42 @@ def load_labels(filename): return my_labels if __name__ == "__main__": - file_name = "/tmp/grace_hopper.bmp" - model_file = "/tmp/mobilenet_v1_1.0_224_quant.tflite" - label_file = "/tmp/labels.txt" - input_mean = 127.5 - input_std = 127.5 floating_model = False parser = argparse.ArgumentParser() - parser.add_argument("--image", help="image to be classified") - parser.add_argument("--graph", help=".tflite model to be executed") - parser.add_argument("--labels", help="name of file containing labels") - parser.add_argument("--input_mean", help="input_mean") - parser.add_argument("--input_std", help="input standard deviation") + parser.add_argument("-i", "--image", default="/tmp/grace_hopper.bmp", \ + help="image to be classified") + parser.add_argument("-m", "--model_file", \ + default="/tmp/mobilenet_v1_1.0_224_quant.tflite", \ + help=".tflite model to be executed") + parser.add_argument("-l", "--label_file", default="/tmp/labels.txt", \ + help="name of file containing labels") + parser.add_argument("--input_mean", default=127.5, help="input_mean") + parser.add_argument("--input_std", default=127.5, \ + help="input standard deviation") args = parser.parse_args() - if args.graph: - model_file = args.graph - if args.image: - file_name = args.image - if args.labels: - label_file = args.labels - if args.input_mean: - input_mean = args.input_mean - if args.input_std: - input_std = args.input_std - - interpreter = interpreter_wrapper.Interpreter(model_path=model_file) + interpreter = interpreter_wrapper.Interpreter(model_path=args.model_file) interpreter.allocate_tensors() input_details = interpreter.get_input_details() output_details = interpreter.get_output_details() # check the type of the input tensor - if input_details[0]['dtype'] == type(np.float32(1.0)): + if input_details[0]['dtype'] == np.float32: floating_model = True # NxHxWxC, H:1, W:2 height = input_details[0]['shape'][1] width = input_details[0]['shape'][2] - img = Image.open(file_name) + img = Image.open(args.image) img = img.resize((width, height)) # add N dim input_data = np.expand_dims(img, axis=0) if floating_model: - input_data = (np.float32(input_data) - input_mean) / input_std + input_data = (np.float32(input_data) - args.input_mean) / args.input_std interpreter.set_tensor(input_details[0]['index'], input_data) @@ -89,7 +78,7 @@ if __name__ == "__main__": results = np.squeeze(output_data) top_k = results.argsort()[-5:][::-1] - labels = load_labels(label_file) + labels = load_labels(args.label_file) for i in top_k: if floating_model: print('{0:08.6f}'.format(float(results[i]))+":", labels[i]) -- GitLab From 671bc5b8474bd2200089f7f28a65644fdbe490dc Mon Sep 17 00:00:00 2001 From: Dan Dascalescu Date: Wed, 27 Jun 2018 18:19:06 -0700 Subject: [PATCH 034/437] Add JS to langs not covered by the compat guarantee --- tensorflow/docs_src/guide/version_compat.md | 1 + 1 file changed, 1 insertion(+) diff --git a/tensorflow/docs_src/guide/version_compat.md b/tensorflow/docs_src/guide/version_compat.md index 72e427c5f8..5f31c6c5f8 100644 --- a/tensorflow/docs_src/guide/version_compat.md +++ b/tensorflow/docs_src/guide/version_compat.md @@ -79,6 +79,7 @@ backward incompatible ways between minor releases. These include: [`tensorflow/cc`](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/cc)). - [Java](../api_docs/java/reference/org/tensorflow/package-summary), - [Go](https://godoc.org/github.com/tensorflow/tensorflow/tensorflow/go) + - [JavaScript](https://js.tensorflow.org) * **Details of composite ops:** Many public functions in Python expand to several primitive ops in the graph, and these details will be part of any -- GitLab From 3939b750f1f5da2b85b7010983e9c77e5a27f861 Mon Sep 17 00:00:00 2001 From: Koan-Sin Tan Date: Fri, 29 Jun 2018 14:17:37 +0800 Subject: [PATCH 035/437] use tensorflow/contrib/lite/string.h as suggested, use //tensorflow/contrib/lite:string instead of using std::string explicitly --- tensorflow/contrib/lite/kernels/internal/BUILD | 2 ++ .../lite/kernels/internal/log_quantized_test.cc | 15 ++++++++------- .../kernels/internal/logsoftmax_quantized_test.cc | 3 ++- .../kernels/internal/softmax_quantized_test.cc | 3 ++- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tensorflow/contrib/lite/kernels/internal/BUILD b/tensorflow/contrib/lite/kernels/internal/BUILD index 7962fcbc9d..4b19e2f1c1 100644 --- a/tensorflow/contrib/lite/kernels/internal/BUILD +++ b/tensorflow/contrib/lite/kernels/internal/BUILD @@ -491,6 +491,7 @@ cc_library( hdrs = ["test_util.h"], deps = [ ":types", + "//tensorflow/contrib/lite:string", ], ) @@ -588,6 +589,7 @@ cc_test( deps = [ ":optimized_base", ":reference_base", + "//tensorflow/contrib/lite:string", "@com_google_googletest//:gtest_main", ], ) diff --git a/tensorflow/contrib/lite/kernels/internal/log_quantized_test.cc b/tensorflow/contrib/lite/kernels/internal/log_quantized_test.cc index 5dd03db8e3..c6900dbf07 100644 --- a/tensorflow/contrib/lite/kernels/internal/log_quantized_test.cc +++ b/tensorflow/contrib/lite/kernels/internal/log_quantized_test.cc @@ -29,8 +29,9 @@ limitations under the License. #include #include "tensorflow/contrib/lite/kernels/internal/optimized/optimized_ops.h" #include "tensorflow/contrib/lite/kernels/internal/reference/reference_ops.h" +#include "tensorflow/contrib/lite/string.h" -namespace { +namespace tflite { class NumberGenerator { public: @@ -69,7 +70,7 @@ inline int32 LogPositiveValuesViaFloat(int32 input_val, int input_integer_bits, void CheckOutputData(const std::vector& test_output, const std::vector& reference_output, const std::vector& test_input, - const std::string& check_label, int input_integer_bits, + const string& check_label, int input_integer_bits, int output_integer_bits, int tolerance) { // In the special case of small input, specifically raw value of 5, a rounding // up leads to difference in the output. We do not aim to be accurate for @@ -117,7 +118,7 @@ void RightShiftVector(const std::vector& shifts, template void RunSingleTest(const std::vector& test_input, - const std::string& check_label, int tolerance) { + const string& check_label, int tolerance) { const int n = test_input.size(); std::vector float_gen_output(n, 0); std::vector reference_output(n, 0); @@ -175,7 +176,7 @@ void RunSingleTest(const std::vector& test_input, template void RunSingleTest(const std::vector& test_input, int input_integer_bits, - const std::string& check_label, int tolerance) { + const string& check_label, int tolerance) { #define INPUT_CASE(K) \ case K: \ return RunSingleTest(test_input, check_label, \ @@ -219,7 +220,7 @@ void RunSingleTest(const std::vector& test_input, int input_integer_bits, } void RunSingleTest(const std::vector& test_input, int input_integer_bits, - int output_integer_bits, const std::string& check_label, + int output_integer_bits, const string& check_label, int tolerance) { #define OUTPUT_CASE(K) \ case K: \ @@ -264,7 +265,7 @@ void RunSingleTest(const std::vector& test_input, int input_integer_bits, } void RunUniformTest(int test_size, int input_integer_bits, - int output_integer_bits, const std::string& check_label, + int output_integer_bits, const string& check_label, int tolerance, NumberGenerator* generator) { std::vector test_data = generator->RandomIntVector( test_size, 2, std::numeric_limits::max() - 1); @@ -281,7 +282,7 @@ void RunUniformTest(int test_size, int input_integer_bits, void RunUniformShiftUniformTest(int test_size, int input_integer_bits, int output_integer_bits, - const std::string& check_label, int tolerance, + const string& check_label, int tolerance, NumberGenerator* generator) { std::vector test_data = generator->RandomIntVector( test_size, 2, std::numeric_limits::max() - 1); diff --git a/tensorflow/contrib/lite/kernels/internal/logsoftmax_quantized_test.cc b/tensorflow/contrib/lite/kernels/internal/logsoftmax_quantized_test.cc index e82af96519..3624c20ae3 100644 --- a/tensorflow/contrib/lite/kernels/internal/logsoftmax_quantized_test.cc +++ b/tensorflow/contrib/lite/kernels/internal/logsoftmax_quantized_test.cc @@ -27,6 +27,7 @@ limitations under the License. #include "tensorflow/contrib/lite/kernels/internal/quantization_util.h" #include "tensorflow/contrib/lite/kernels/internal/reference/reference_ops.h" #include "tensorflow/contrib/lite/kernels/internal/test_util.h" +#include "tensorflow/contrib/lite/string.h" namespace tflite { namespace { @@ -58,7 +59,7 @@ void RunLogSoftmaxFloatReference(const uint8* input_data, void CheckOutputData(const uint8* test_output, const uint8* reference_output, const RuntimeShape& shape_common, - const std::string& check_label, bool be_exacting) { + const string& check_label, bool be_exacting) { const int buffer_size = shape_common.FlatSize(); // While calculating some metrics in floating point, we work with quantized // scaling. diff --git a/tensorflow/contrib/lite/kernels/internal/softmax_quantized_test.cc b/tensorflow/contrib/lite/kernels/internal/softmax_quantized_test.cc index bbfc5b6474..ca94e7740e 100644 --- a/tensorflow/contrib/lite/kernels/internal/softmax_quantized_test.cc +++ b/tensorflow/contrib/lite/kernels/internal/softmax_quantized_test.cc @@ -27,6 +27,7 @@ limitations under the License. #include "tensorflow/contrib/lite/kernels/internal/quantization_util.h" #include "tensorflow/contrib/lite/kernels/internal/reference/reference_ops.h" #include "tensorflow/contrib/lite/kernels/internal/test_util.h" +#include "tensorflow/contrib/lite/string.h" namespace tflite { namespace { @@ -58,7 +59,7 @@ void RunSoftmaxFloatReference(const uint8* input_data, void CheckOutputData(const uint8* test_output, const uint8* reference_output, const RuntimeShape& shape_common, - const std::string& check_label, bool be_exacting) { + const string& check_label, bool be_exacting) { const int buffer_size = shape_common.FlatSize(); // While calculating some metrics in floating point, we work with quantized // scaling. -- GitLab From a69b18a2d24247071b6826be4933226f5eff9af9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Horst=20H=C3=BCnnemeyer?= Date: Fri, 29 Jun 2018 14:37:33 +0200 Subject: [PATCH 036/437] Utilizing dict comprehension --- tensorflow/contrib/distribute/python/mirrored_strategy.py | 2 +- tensorflow/contrib/lite/schema/upgrade_schema.py | 6 +++--- .../python/training/sequence_queueing_state_saver.py | 6 +++--- tensorflow/python/framework/errors_impl.py | 4 ++-- tensorflow/python/keras/preprocessing/text.py | 2 +- tensorflow/python/ops/distributions/distribution.py | 4 ++-- tensorflow/python/util/deprecation.py | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tensorflow/contrib/distribute/python/mirrored_strategy.py b/tensorflow/contrib/distribute/python/mirrored_strategy.py index d269bed1e5..cdb505d95d 100644 --- a/tensorflow/contrib/distribute/python/mirrored_strategy.py +++ b/tensorflow/contrib/distribute/python/mirrored_strategy.py @@ -87,7 +87,7 @@ class MirroredStrategy(distribute_lib.DistributionStrategy): self._devices = [device_util.resolve(d) for d in devices] self._canonical_device_set = set(self._devices) self._device_index = values.PerDevice( - dict((d, i) for i, d in enumerate(devices))) + {d: i for i, d in enumerate(devices)}) self._cross_tower_ops = cross_tower_ops self._prefetch_on_device = prefetch_on_device # TODO(yuefengz): consider setting the default device. diff --git a/tensorflow/contrib/lite/schema/upgrade_schema.py b/tensorflow/contrib/lite/schema/upgrade_schema.py index e0b36d3d3e..a2ddf62950 100644 --- a/tensorflow/contrib/lite/schema/upgrade_schema.py +++ b/tensorflow/contrib/lite/schema/upgrade_schema.py @@ -99,9 +99,9 @@ class Converter(object): # dispatch function table. self._schemas.sort() self._new_version, self._new_schema = self._schemas[-1][:2] - self._upgrade_dispatch = dict( - (version, dispatch) - for version, unused1, unused2, dispatch in self._schemas) + self._upgrade_dispatch = { + version: dispatch + for version, unused1, unused2, dispatch in self._schemas} def _Read(self, input_file, schema, raw_binary=False): """Read a tflite model assuming the given flatbuffer schema. diff --git a/tensorflow/contrib/training/python/training/sequence_queueing_state_saver.py b/tensorflow/contrib/training/python/training/sequence_queueing_state_saver.py index 39d75a0806..53e4f23a7c 100644 --- a/tensorflow/contrib/training/python/training/sequence_queueing_state_saver.py +++ b/tensorflow/contrib/training/python/training/sequence_queueing_state_saver.py @@ -988,14 +988,14 @@ class SequenceQueueingStateSaver(object): assert isinstance(sequences, dict) assert isinstance(context, dict) assert isinstance(states, dict) - self._name_to_index = dict( - (name, ix) + self._name_to_index = { + name: ix for (ix, name) in enumerate([ "__length", "__total_length", "__next_key", "__sequence", "__sequence_count" ] + ["__sequence__%s" % k for k in sequences.keys()] + [ "__context__%s" % k for k in context.keys() - ] + ["__state__%s" % k for k in states.keys()])) + ] + ["__state__%s" % k for k in states.keys()])} self._index_to_name = [ name for (name, _) in sorted( diff --git a/tensorflow/python/framework/errors_impl.py b/tensorflow/python/framework/errors_impl.py index 84106c32c6..c2521fdc00 100644 --- a/tensorflow/python/framework/errors_impl.py +++ b/tensorflow/python/framework/errors_impl.py @@ -475,8 +475,8 @@ _CODE_TO_EXCEPTION_CLASS = { c_api.PyExceptionRegistry_Init(_CODE_TO_EXCEPTION_CLASS) -_EXCEPTION_CLASS_TO_CODE = dict(( - (class_, code) for (code, class_) in _CODE_TO_EXCEPTION_CLASS.items())) +_EXCEPTION_CLASS_TO_CODE = { + class_: code for code, class_ in _CODE_TO_EXCEPTION_CLASS.items()} @tf_export("errors.exception_type_from_error_code") diff --git a/tensorflow/python/keras/preprocessing/text.py b/tensorflow/python/keras/preprocessing/text.py index f3b57de257..8f4eae81f2 100644 --- a/tensorflow/python/keras/preprocessing/text.py +++ b/tensorflow/python/keras/preprocessing/text.py @@ -69,7 +69,7 @@ def text_to_word_sequence(text, for c in filters: text = text.replace(c, split) else: - translate_dict = dict((c, split) for c in filters) + translate_dict = {c: split for c in filters} translate_map = maketrans(translate_dict) text = text.translate(translate_map) diff --git a/tensorflow/python/ops/distributions/distribution.py b/tensorflow/python/ops/distributions/distribution.py index 41dcd40188..ddf3b04b8d 100644 --- a/tensorflow/python/ops/distributions/distribution.py +++ b/tensorflow/python/ops/distributions/distribution.py @@ -526,8 +526,8 @@ class Distribution(_BaseDistribution): # Remove "self", "__class__", or other special variables. These can appear # if the subclass used: # `parameters = dict(locals())`. - return dict((k, v) for k, v in self._parameters.items() - if not k.startswith("__") and k != "self") + return {k: v for k, v in self._parameters.items() + if not k.startswith("__") and k != "self"} @property def reparameterization_type(self): diff --git a/tensorflow/python/util/deprecation.py b/tensorflow/python/util/deprecation.py index 376be39978..ac8144bacc 100644 --- a/tensorflow/python/util/deprecation.py +++ b/tensorflow/python/util/deprecation.py @@ -337,8 +337,8 @@ def deprecated_args(date, instructions, *deprecated_arg_names_or_tuples, Returns: Dictionary from arg_name to DeprecatedArgSpec. """ - arg_name_to_pos = dict( - (name, pos) for (pos, name) in enumerate(arg_spec.args)) + arg_name_to_pos = { + name: pos for pos, name in enumerate(arg_spec.args)} deprecated_positional_args = {} for arg_name, spec in iter(names_to_ok_vals.items()): if arg_name in arg_name_to_pos: -- GitLab From 31cb975c3c1ff8e844cbf159b7e99f5f9989f399 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Wed, 23 May 2018 18:54:14 +0000 Subject: [PATCH 037/437] Add Hadoop SequenceFile support for tensorflow Dataset This fix adds Hadoop SequenceFile for tensorflow Dataset, so that it is possible to process files stored in Hadoop system directly. This fix is a very preliminary and early implementation. It supports `org.apache.hadoop.io.Text` only, and there is no compression support. Will work on expanding the support of other seralization types, and compresion support in the follow up PR. Signed-off-by: Yong Tang --- .../hadoop/kernels/hadoop_dataset_ops.cc | 336 ++++++++++++++++++ 1 file changed, 336 insertions(+) create mode 100644 tensorflow/contrib/hadoop/kernels/hadoop_dataset_ops.cc diff --git a/tensorflow/contrib/hadoop/kernels/hadoop_dataset_ops.cc b/tensorflow/contrib/hadoop/kernels/hadoop_dataset_ops.cc new file mode 100644 index 0000000000..36057bbd9b --- /dev/null +++ b/tensorflow/contrib/hadoop/kernels/hadoop_dataset_ops.cc @@ -0,0 +1,336 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#include "tensorflow/core/framework/dataset.h" +#include "tensorflow/core/lib/io/buffered_inputstream.h" +#include "tensorflow/core/platform/file_system.h" + +namespace tensorflow { +namespace { + +static const size_t kSyncMarkerSize = 16; +static const size_t kSequenceFileBufferSize = 1024 * 1024; + +class SequenceFileReader { + public: + explicit SequenceFileReader(RandomAccessFile* file) + : input_stream_( + new io::BufferedInputStream(file, kSequenceFileBufferSize)) {} + + Status ReadHeader() { + std::string version; + TF_RETURN_IF_ERROR(input_stream_->ReadNBytes(4, &version)); + if (version.substr(0, 3) != "SEQ" || version[3] != 6) { + return errors::InvalidArgument( + "sequence file header must starts with `SEQ6`, received \"", + version.substr(0, 3), int(version[3]), "\""); + } + TF_RETURN_IF_ERROR(ReadString(&key_class_name_)); + TF_RETURN_IF_ERROR(ReadString(&value_class_name_)); + + // At the moment we only support `org.apache.hadoop.io.Text` for key/value. + // TODO (yongtang): Add more class name support. + if (key_class_name_ != "org.apache.hadoop.io.Text" || + value_class_name_ != "org.apache.hadoop.io.Text") { + return errors::Unimplemented("key/value of '", key_class_name_, "/", + value_class_name_, + "' is currently not supported"); + } + + std::string buffer; + TF_RETURN_IF_ERROR(input_stream_->ReadNBytes(2, &buffer)); + compression_ = buffer[0]; + block_compression_ = buffer[1]; + if (compression_ || block_compression_) { + TF_RETURN_IF_ERROR(ReadString(&compression_codec_class_name_)); + } + + // At the moment no compression is supported. + // TODO (yongtang): Add compression support. + if (compression_ || block_compression_) { + return errors::Unimplemented("compression is currently not supported"); + } + + // Not interested in metadata for now. + uint32 num_metadata_pairs = 0; + TF_RETURN_IF_ERROR(ReadUInt32(&num_metadata_pairs)); + if (num_metadata_pairs > 1024) { + return errors::InvalidArgument( + "sequence file metadata should have key value pairs < 1024, " + "received ", + num_metadata_pairs); + } + for (int i = 0; i < num_metadata_pairs; i++) { + TF_RETURN_IF_ERROR(ReadString(nullptr)); + TF_RETURN_IF_ERROR(ReadString(nullptr)); + } + + TF_RETURN_IF_ERROR( + input_stream_->ReadNBytes(kSyncMarkerSize, &sync_marker_)); + + return Status::OK(); + } + + Status ReadRecord(std::string* key, std::string* value) { + uint32 length = 0; + TF_RETURN_IF_ERROR(ReadUInt32(&length)); + if (length == static_cast(-1)) { + // Sync marker. + std::string sync_marker; + TF_RETURN_IF_ERROR( + input_stream_->ReadNBytes(kSyncMarkerSize, &sync_marker)); + if (sync_marker != sync_marker_) { + return errors::InvalidArgument( + "sequence file should have sync marker \"", sync_marker_, + "\" at pos ", input_stream_->Tell() - kSyncMarkerSize, + ", received \"", sync_marker, "\""); + } + return ReadRecord(key, value); + } + uint32 key_length = 0; + TF_RETURN_IF_ERROR(ReadUInt32(&key_length)); + if (key_length > length) { + return errors::InvalidArgument("key length (", key_length, + ") should be < record length (", length, + ")"); + } + uint32 value_length = length - key_length; + // At the moment we only support `org.apache.hadoop.io.Text` for key/value. + // TODO (yongtang): Expand supported format. + TF_RETURN_IF_ERROR(ReadString(key)); + TF_RETURN_IF_ERROR(ReadString(value)); + return Status::OK(); + } + + Status ReadString(std::string* value) { + int64 length = 0; + TF_RETURN_IF_ERROR(ReadVInt(&length)); + if (value == nullptr) { + return input_stream_->SkipNBytes(length); + } + return input_stream_->ReadNBytes(length, value); + } + + Status ReadUInt32(uint32* value) { + std::string buffer; + TF_RETURN_IF_ERROR(input_stream_->ReadNBytes(4, &buffer)); + *value = (uint32(buffer[0]) << 24) | (uint32(buffer[1]) << 16) | + (uint32(buffer[2]) << 8) | uint32(buffer[3]); + return Status::OK(); + } + + Status ReadVInt(int64* value) { + std::string buffer; + TF_RETURN_IF_ERROR(input_stream_->ReadNBytes(1, &buffer)); + if (buffer[0] >= -112) { + *value = static_cast(buffer[0]); + return Status::OK(); + } + + int64 remaining = 0; + bool negative = false; + if (buffer[0] >= -120) { + remaining = static_cast(-112) - static_cast(buffer[0]); + } else { + remaining = static_cast(-120) - static_cast(buffer[0]); + negative = true; + } + buffer.clear(); + TF_RETURN_IF_ERROR(input_stream_->ReadNBytes(remaining, &buffer)); + + uint64 v = 0; + for (int i = 0; i < buffer.size(); i++) { + v = (v << 8) | (uint64)(buffer[i]); + } + if (negative) { + v = ~v; + } + *value = static_cast(v); + return Status::OK(); + } + + virtual ~SequenceFileReader() = default; + + private: + std::unique_ptr input_stream_; + std::string key_class_name_; + std::string value_class_name_; + std::string sync_marker_; + bool compression_; + bool block_compression_; + std::string compression_codec_class_name_; + TF_DISALLOW_COPY_AND_ASSIGN(SequenceFileReader); +}; +} +class SequenceFileDatasetOp : public DatasetOpKernel { + public: + using DatasetOpKernel::DatasetOpKernel; + explicit SequenceFileDatasetOp(OpKernelConstruction* ctx) + : DatasetOpKernel(ctx) { + OP_REQUIRES_OK(ctx, ctx->GetAttr("output_types", &output_types_)); + for (const DataType& dt : output_types_) { + OP_REQUIRES(ctx, dt == DT_STRING, + errors::InvalidArgument( + "Each element of `output_types_` must be one of: " + "DT_STRING")); + } + } + void MakeDataset(OpKernelContext* ctx, DatasetBase** output) override { + const Tensor* filenames_tensor; + OP_REQUIRES_OK(ctx, ctx->input("filenames", &filenames_tensor)); + OP_REQUIRES( + ctx, filenames_tensor->dims() <= 1, + errors::InvalidArgument("`filenames` must be a scalar or a vector.")); + + std::vector filenames; + filenames.reserve(filenames_tensor->NumElements()); + for (int i = 0; i < filenames_tensor->NumElements(); ++i) { + filenames.push_back(filenames_tensor->flat()(i)); + } + + *output = new Dataset(ctx, filenames, output_types_); + } + + private: + class Dataset : public GraphDatasetBase { + public: + Dataset(OpKernelContext* ctx, const std::vector& filenames, + const DataTypeVector& output_types) + : GraphDatasetBase(ctx), + filenames_(filenames), + output_types_(output_types) {} + + std::unique_ptr MakeIterator( + const string& prefix) const override { + return std::unique_ptr( + new Iterator({this, strings::StrCat(prefix, "::SequenceFile")})); + } + + const DataTypeVector& output_dtypes() const override { + return output_types_; + } + + const std::vector& output_shapes() const override { + static std::vector* shapes = + new std::vector({{}, {}}); + return *shapes; + } + + string DebugString() override { return "SequenceFileDatasetOp::Dataset"; } + + protected: + Status AsGraphDefInternal(DatasetGraphDefBuilder* b, + Node** output) const override { + Node* filenames = nullptr; + TF_RETURN_IF_ERROR(b->AddVector(filenames_, &filenames)); + TF_RETURN_IF_ERROR(b->AddDataset(this, {filenames}, output)); + return Status::OK(); + } + + private: + class Iterator : public DatasetIterator { + public: + explicit Iterator(const Params& params) + : DatasetIterator(params) {} + + Status GetNextInternal(IteratorContext* ctx, + std::vector* out_tensors, + bool* end_of_sequence) override { + mutex_lock l(mu_); + do { + // We are currently processing a file, so try to read the next record. + if (reader_) { + std::string key, value; + Status status = reader_->ReadRecord(&key, &value); + if (!errors::IsOutOfRange(status)) { + TF_RETURN_IF_ERROR(status); + + Tensor key_tensor(ctx->allocator({}), DT_STRING, {}); + key_tensor.scalar()() = key; + out_tensors->emplace_back(std::move(key_tensor)); + + Tensor value_tensor(ctx->allocator({}), DT_STRING, {}); + value_tensor.scalar()() = value; + out_tensors->emplace_back(std::move(value_tensor)); + + *end_of_sequence = false; + return Status::OK(); + } + // We have reached the end of the current file, so maybe + // move on to next file. + ResetStreamsLocked(); + ++current_file_index_; + } + + // Iteration ends when there are no more files to process. + if (current_file_index_ == dataset()->filenames_.size()) { + *end_of_sequence = true; + return Status::OK(); + } + + TF_RETURN_IF_ERROR(SetupStreamsLocked(ctx->env())); + } while (true); + } + + protected: + Status SaveInternal(IteratorStateWriter* writer) override { + return errors::Unimplemented("SaveInternal is currently not supported"); + } + + Status RestoreInternal(IteratorContext* ctx, + IteratorStateReader* reader) override { + return errors::Unimplemented( + "RestoreInternal is currently not supported"); + } + + private: + // Sets up SequenceFile streams to read from the topic at + // `current_file_index_`. + Status SetupStreamsLocked(Env* env) EXCLUSIVE_LOCKS_REQUIRED(mu_) { + if (current_file_index_ >= dataset()->filenames_.size()) { + return errors::InvalidArgument( + "current_file_index_:", current_file_index_, + " >= filenames_.size():", dataset()->filenames_.size()); + } + + // Actually move on to next file. + const string& filename = dataset()->filenames_[current_file_index_]; + TF_RETURN_IF_ERROR(env->NewRandomAccessFile(filename, &file_)); + reader_.reset(new SequenceFileReader(file_.get())); + return reader_->ReadHeader(); + } + + // Resets all Parquet streams. + void ResetStreamsLocked() EXCLUSIVE_LOCKS_REQUIRED(mu_) { + reader_.reset(); + file_.reset(); + } + + mutex mu_; + size_t current_file_index_ GUARDED_BY(mu_) = 0; + std::unique_ptr file_ GUARDED_BY(mu_); + std::unique_ptr reader_ GUARDED_BY(mu_); + }; + + const std::vector filenames_; + const DataTypeVector output_types_; + }; + DataTypeVector output_types_; +}; + +REGISTER_KERNEL_BUILDER(Name("SequenceFileDataset").Device(DEVICE_CPU), + SequenceFileDatasetOp); + +} // namespace tensorflow -- GitLab From 26d73d21b396adf3c23d11bdafee3c8bc63ef6ba Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Wed, 23 May 2018 19:00:57 +0000 Subject: [PATCH 038/437] Register SequenceFileDataset ops Signed-off-by: Yong Tang --- tensorflow/contrib/hadoop/ops/dataset_ops.cc | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tensorflow/contrib/hadoop/ops/dataset_ops.cc diff --git a/tensorflow/contrib/hadoop/ops/dataset_ops.cc b/tensorflow/contrib/hadoop/ops/dataset_ops.cc new file mode 100644 index 0000000000..66ad549b47 --- /dev/null +++ b/tensorflow/contrib/hadoop/ops/dataset_ops.cc @@ -0,0 +1,29 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#include "tensorflow/core/framework/common_shape_fns.h" +#include "tensorflow/core/framework/op.h" +#include "tensorflow/core/framework/shape_inference.h" + +namespace tensorflow { + +REGISTER_OP("SequenceFileDataset") + .Input("filenames: string") + .Output("handle: variant") + .Attr("output_types: list(type) >= 1") + .SetIsStateful() + .SetShapeFn(shape_inference::ScalarShape); + +} // namespace tensorflow -- GitLab From fa9f9a0f76c86bfabd2e63db2add2829a749f639 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Wed, 23 May 2018 19:02:02 +0000 Subject: [PATCH 039/437] Add python wrapper for tf.contrib.hadoop.SequenceFileDataset Signed-off-by: Yong Tang --- .../hadoop/python/ops/hadoop_dataset_ops.py | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 tensorflow/contrib/hadoop/python/ops/hadoop_dataset_ops.py diff --git a/tensorflow/contrib/hadoop/python/ops/hadoop_dataset_ops.py b/tensorflow/contrib/hadoop/python/ops/hadoop_dataset_ops.py new file mode 100644 index 0000000000..661e298756 --- /dev/null +++ b/tensorflow/contrib/hadoop/python/ops/hadoop_dataset_ops.py @@ -0,0 +1,80 @@ +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== +"""SequenceFile Dataset.""" +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +from tensorflow.contrib.hadoop.python.ops import hadoop_op_loader # pylint: disable=unused-import +from tensorflow.contrib.hadoop.python.ops import gen_dataset_ops +from tensorflow.python.data.ops.dataset_ops import Dataset +from tensorflow.python.data.util import nest +from tensorflow.python.framework import dtypes +from tensorflow.python.framework import ops +from tensorflow.python.framework import tensor_shape + + +class SequenceFileDataset(Dataset): + """A Sequence File Dataset that reads the sequence file.""" + + def __init__(self, filenames, output_types=(dtypes.string, dtypes.string)): + """Create a `SequenceFileDataset`. + + `SequenceFileDataset` allows a user to read data from a hadoop sequence + file. A sequence file consists of (key value) pairs sequentially. At + the moment, `org.apache.hadoop.io.Text` is the only serialization type + being supported, and there is no compression support. + + For example: + + ```python + dataset = tf.contrib.hadoop.SequenceFileDataset( + "/foo/bar.seq", (tf.string, tf.string)) + iterator = dataset.make_one_shot_iterator() + next_element = iterator.get_next() + # Prints the (key, value) pairs inside a hadoop sequence file. + while True: + try: + print(sess.run(next_element)) + except tf.errors.OutOfRangeError: + break + ``` + + Args: + filenames: A `tf.string` tensor containing one or more filenames. + output_types: A tuple of `tf.DType` objects representing the types of the + key-value pairs returned. Only `(tf.string, tf.string)` is supported + at the moment. + """ + super(SequenceFileDataset, self).__init__() + self._filenames = ops.convert_to_tensor( + filenames, dtype=dtypes.string, name="filenames") + self._output_types = output_types + + def _as_variant_tensor(self): + return gen_dataset_ops.sequence_file_dataset( + self._filenames, nest.flatten(self.output_types)) + + @property + def output_classes(self): + return nest.map_structure(lambda _: ops.Tensor, self._output_types) + + @property + def output_shapes(self): + return (tensor_shape.TensorShape([]), tensor_shape.TensorShape([])) + + @property + def output_types(self): + return self._output_types -- GitLab From 01e125d0ccce72948aa9a0f80d1fc6e343e81a10 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Wed, 23 May 2018 19:03:45 +0000 Subject: [PATCH 040/437] Add test case for hadoop SequenceFileDataset Signed-off-by: Yong Tang --- .../hadoop/python/kernel_tests/hadoop_test.py | 66 ++++++++++++++++++ .../python/kernel_tests/testdata/string.seq | Bin 0 -> 603 bytes 2 files changed, 66 insertions(+) create mode 100644 tensorflow/contrib/hadoop/python/kernel_tests/hadoop_test.py create mode 100755 tensorflow/contrib/hadoop/python/kernel_tests/testdata/string.seq diff --git a/tensorflow/contrib/hadoop/python/kernel_tests/hadoop_test.py b/tensorflow/contrib/hadoop/python/kernel_tests/hadoop_test.py new file mode 100644 index 0000000000..8bbb1da85d --- /dev/null +++ b/tensorflow/contrib/hadoop/python/kernel_tests/hadoop_test.py @@ -0,0 +1,66 @@ +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# ============================================================================== +"""Tests for SequenceFileDataset.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import os + +from tensorflow.contrib.hadoop.python.ops import hadoop_dataset_ops +from tensorflow.python.framework import constant_op +from tensorflow.python.framework import dtypes +from tensorflow.python.framework import errors +from tensorflow.python.ops import array_ops +from tensorflow.python.platform import resource_loader +from tensorflow.python.platform import test + +class SequenceFileDatasetTest(test.TestCase): + + def test_sequence_file_dataset(self): + """Test case for SequenceFileDataset. + + The file is generated with `org.apache.hadoop.io.Text` for key/value. + There are 25 records in the file with the format of: + key = XXX + value = VALUEXXX + where XXX is replaced as the line number (starts with 001). + """ + filename = os.path.join( + resource_loader.get_data_files_path(), 'testdata/string.seq') + + filenames = array_ops.placeholder_with_default( + constant_op.constant([filename], dtypes.string), shape=[None]) + num_repeats = 2 + + dataset = hadoop_dataset_ops.SequenceFileDataset( + filenames).repeat(num_repeats) + iterator = dataset.make_initializable_iterator() + init_op = iterator.initializer + get_next = iterator.get_next() + + with self.test_session() as sess: + sess.run(init_op) + for _ in range(num_repeats): # Dataset is repeated. + for i in range(25): # 25 records. + v0 = "{0:03d}".format(i + 1) + v1 = "VALUE{0:03d}".format(i + 1) + self.assertEqual((v0, v1), sess.run(get_next)) + with self.assertRaises(errors.OutOfRangeError): + sess.run(get_next) + +if __name__ == "__main__": + test.main() diff --git a/tensorflow/contrib/hadoop/python/kernel_tests/testdata/string.seq b/tensorflow/contrib/hadoop/python/kernel_tests/testdata/string.seq new file mode 100755 index 0000000000000000000000000000000000000000..b7175338af3417a8858d66082ab5a616f87cb234 GIT binary patch literal 603 zcmWG`4P=wdFG|--EJ#ewNY%?oOv%qL(96u%3rVdg!7al829_SbZ|qXOS}}LW>a8By z(wYnm47>~s3@pqB28JAAjy|ET1_p*mf<`bwBP2m%n4mF|pb1RS1WC{oCTNNzXa*BB zLlQKH37R7bTEGM?kOVDZf|dwDLj$Owp#hR0%twYuJ~D*)$Pmd#hA Date: Wed, 23 May 2018 19:04:47 +0000 Subject: [PATCH 041/437] Expose op to tf.contrib.hadoop namespace Signed-off-by: Yong Tang --- tensorflow/contrib/hadoop/__init__.py | 32 +++++++++++++++++++ .../hadoop/python/ops/hadoop_op_loader.py | 24 ++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 tensorflow/contrib/hadoop/__init__.py create mode 100644 tensorflow/contrib/hadoop/python/ops/hadoop_op_loader.py diff --git a/tensorflow/contrib/hadoop/__init__.py b/tensorflow/contrib/hadoop/__init__.py new file mode 100644 index 0000000000..abf8cd4845 --- /dev/null +++ b/tensorflow/contrib/hadoop/__init__.py @@ -0,0 +1,32 @@ +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== +"""Sequence File Dataset. + +@@SequenceFileDataset +""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +from tensorflow.contrib.hadoop.python.ops.hadoop_dataset_ops import SequenceFileDataset + +from tensorflow.python.util.all_util import remove_undocumented + +_allowed_symbols = [ + "SequenceFileDataset", +] + +remove_undocumented(__name__) diff --git a/tensorflow/contrib/hadoop/python/ops/hadoop_op_loader.py b/tensorflow/contrib/hadoop/python/ops/hadoop_op_loader.py new file mode 100644 index 0000000000..6dbf1253f3 --- /dev/null +++ b/tensorflow/contrib/hadoop/python/ops/hadoop_op_loader.py @@ -0,0 +1,24 @@ +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== +"""Python helper for loading hadoop ops and kernels.""" +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +from tensorflow.contrib.util import loader +from tensorflow.python.platform import resource_loader + +_dataset_ops = loader.load_op_library( + resource_loader.get_path_to_datafile("../../_dataset_ops.so")) -- GitLab From 6d000b8b02ac42aeb0ceb6f7706e1cb0e604e1db Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Wed, 23 May 2018 19:06:31 +0000 Subject: [PATCH 042/437] Add bazel BUILD file to hadoop Signed-off-by: Yong Tang --- tensorflow/contrib/hadoop/BUILD | 117 ++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 tensorflow/contrib/hadoop/BUILD diff --git a/tensorflow/contrib/hadoop/BUILD b/tensorflow/contrib/hadoop/BUILD new file mode 100644 index 0000000000..ccad31efa1 --- /dev/null +++ b/tensorflow/contrib/hadoop/BUILD @@ -0,0 +1,117 @@ +package(default_visibility = ["//tensorflow:internal"]) + +licenses(["notice"]) # Apache 2.0 + +exports_files(["LICENSE"]) + +load( + "//tensorflow:tensorflow.bzl", + "tf_custom_op_library", + "tf_custom_op_py_library", + "tf_gen_op_libs", + "tf_gen_op_wrapper_py", + "tf_kernel_library", + "tf_py_test", +) + +filegroup( + name = "test_data", + srcs = glob(["python/kernel_tests/testdata/*"]), +) + +py_library( + name = "hadoop", + srcs = ["__init__.py"], + srcs_version = "PY2AND3", + deps = [ + ":dataset_ops", + ], +) + +tf_custom_op_library( + name = "_dataset_ops.so", + srcs = ["ops/dataset_ops.cc"], + deps = [ + ":dataset_kernels", + ], +) + +tf_gen_op_libs( + op_lib_names = ["dataset_ops"], +) + +cc_library( + name = "dataset_kernels", + srcs = ["kernels/hadoop_dataset_ops.cc"], + deps = [ + "//tensorflow/core:framework_headers_lib", + "//third_party/eigen3", + "@protobuf_archive//:protobuf_headers", + ], + alwayslink = 1, +) + +py_library( + name = "dataset_ops", + srcs = [ + "python/ops/hadoop_dataset_ops.py", + ], + srcs_version = "PY2AND3", + deps = [ + ":hadoop_op_loader", + "//tensorflow/python:dataset_ops_gen", + "//tensorflow/python:util", + "//tensorflow/python/data/ops:dataset_ops", + "//tensorflow/python/data/util:nest", + ], +) + +tf_gen_op_wrapper_py( + name = "gen_dataset_ops", + out = "python/ops/gen_dataset_ops.py", + deps = ["//tensorflow/contrib/hadoop:dataset_ops_op_lib"], +) + +tf_kernel_library( + name = "dataset_ops_kernels", + deps = [ + ":dataset_kernels", + "//tensorflow/core:framework", + ], + alwayslink = 1, +) + +tf_custom_op_py_library( + name = "hadoop_op_loader", + srcs = ["python/ops/hadoop_op_loader.py"], + dso = ["//tensorflow/contrib/hadoop:_dataset_ops.so"], + kernels = [ + ":dataset_ops_kernels", + "//tensorflow/contrib/hadoop:dataset_ops_op_lib", + ], + srcs_version = "PY2AND3", + deps = [ + ":gen_dataset_ops", + "//tensorflow/contrib/util:util_py", + "//tensorflow/python:platform", + ], +) + +tf_py_test( + name = "hadoop_test", + srcs = ["python/kernel_tests/hadoop_test.py"], + additional_deps = [ + ":hadoop", + "//third_party/py/numpy", + "//tensorflow/python:client_testlib", + "//tensorflow/python:framework", + "//tensorflow/python:framework_test_lib", + "//tensorflow/python:platform_test", + ], + data = [ + ":test_data", + ], + tags = [ + "notap", + ], +) -- GitLab From cf1429707d68edb22cd861ce900d0ec4600668e5 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Wed, 23 May 2018 19:06:56 +0000 Subject: [PATCH 043/437] Expose tf.contrib.hadoop.SequenceFileDataset to tf.contrib Signed-off-by: Yong Tang --- tensorflow/contrib/BUILD | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tensorflow/contrib/BUILD b/tensorflow/contrib/BUILD index 2d7916c8b1..f57a111c45 100644 --- a/tensorflow/contrib/BUILD +++ b/tensorflow/contrib/BUILD @@ -49,6 +49,7 @@ py_library( "//tensorflow/contrib/gan", "//tensorflow/contrib/graph_editor:graph_editor_py", "//tensorflow/contrib/grid_rnn:grid_rnn_py", + "//tensorflow/contrib/hadoop", "//tensorflow/contrib/hooks", "//tensorflow/contrib/image:distort_image_py", "//tensorflow/contrib/image:image_py", @@ -139,6 +140,7 @@ cc_library( "//tensorflow/contrib/coder:all_kernels", "//tensorflow/contrib/data/kernels:dataset_kernels", "//tensorflow/contrib/factorization/kernels:all_kernels", + "//tensorflow/contrib/hadoop:dataset_kernels", "//tensorflow/contrib/input_pipeline:input_pipeline_ops_kernels", "//tensorflow/contrib/layers:sparse_feature_cross_op_kernel", "//tensorflow/contrib/nearest_neighbor:nearest_neighbor_ops_kernels", @@ -168,6 +170,7 @@ cc_library( "//tensorflow/contrib/data:dataset_ops_op_lib", "//tensorflow/contrib/factorization:all_ops", "//tensorflow/contrib/framework:all_ops", + "//tensorflow/contrib/hadoop:dataset_ops_op_lib", "//tensorflow/contrib/input_pipeline:input_pipeline_ops_op_lib", "//tensorflow/contrib/layers:sparse_feature_cross_op_op_lib", "//tensorflow/contrib/nccl:nccl_ops_op_lib", -- GitLab From a10f5141868b98d41137572a80594adc158a3227 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Thu, 24 May 2018 14:50:43 +0000 Subject: [PATCH 044/437] Sanity build fix. Signed-off-by: Yong Tang --- tensorflow/contrib/cmake/python_modules.txt | 2 ++ tensorflow/tools/pip_package/pip_smoke_test.py | 1 + 2 files changed, 3 insertions(+) diff --git a/tensorflow/contrib/cmake/python_modules.txt b/tensorflow/contrib/cmake/python_modules.txt index d530572e91..be8688126d 100644 --- a/tensorflow/contrib/cmake/python_modules.txt +++ b/tensorflow/contrib/cmake/python_modules.txt @@ -183,6 +183,8 @@ tensorflow/contrib/graph_editor/examples tensorflow/contrib/grid_rnn tensorflow/contrib/grid_rnn/python tensorflow/contrib/grid_rnn/python/ops +tensorflow/contrib/hadoop/python +tensorflow/contrib/hadoop/python/ops tensorflow/contrib/hooks tensorflow/contrib/hooks/python tensorflow/contrib/image diff --git a/tensorflow/tools/pip_package/pip_smoke_test.py b/tensorflow/tools/pip_package/pip_smoke_test.py index 401f833dbd..bfc007bc39 100644 --- a/tensorflow/tools/pip_package/pip_smoke_test.py +++ b/tensorflow/tools/pip_package/pip_smoke_test.py @@ -90,6 +90,7 @@ BLACKLIST = [ "//tensorflow/contrib/lite/python:interpreter.py", "//tensorflow/contrib/lite/python:interpreter_test.py", "//tensorflow/contrib/ffmpeg:test_data", + "//tensorflow/contrib/hadoop:test_data", "//tensorflow/contrib/factorization/examples:mnist", "//tensorflow/contrib/factorization/examples:mnist.py", "//tensorflow/contrib/factorization:factorization_py_CYCLIC_DEPENDENCIES_THAT_NEED_TO_GO", # pylint:disable=line-too-long -- GitLab From 21bf4812c5079764c817cb2e193f136d4e590d17 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Thu, 24 May 2018 16:42:48 +0000 Subject: [PATCH 045/437] Fix python 3 issue with `b` prefix strings Signed-off-by: Yong Tang --- tensorflow/contrib/hadoop/python/kernel_tests/hadoop_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow/contrib/hadoop/python/kernel_tests/hadoop_test.py b/tensorflow/contrib/hadoop/python/kernel_tests/hadoop_test.py index 8bbb1da85d..108aaecdb7 100644 --- a/tensorflow/contrib/hadoop/python/kernel_tests/hadoop_test.py +++ b/tensorflow/contrib/hadoop/python/kernel_tests/hadoop_test.py @@ -56,8 +56,8 @@ class SequenceFileDatasetTest(test.TestCase): sess.run(init_op) for _ in range(num_repeats): # Dataset is repeated. for i in range(25): # 25 records. - v0 = "{0:03d}".format(i + 1) - v1 = "VALUE{0:03d}".format(i + 1) + v0 = b"%03d" % (i + 1) + v1 = b"VALUE%03d" % (i + 1) self.assertEqual((v0, v1), sess.run(get_next)) with self.assertRaises(errors.OutOfRangeError): sess.run(get_next) -- GitLab From 7e47b7733549b99dfa14aa0592eadbf384f0f036 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Mon, 25 Jun 2018 15:39:43 +0000 Subject: [PATCH 046/437] Address review comments Signed-off-by: Yong Tang --- .../hadoop/kernels/hadoop_dataset_ops.cc | 33 ++++++++++--------- .../hadoop/python/kernel_tests/hadoop_test.py | 3 +- .../hadoop/python/ops/hadoop_dataset_ops.py | 13 +++----- 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/tensorflow/contrib/hadoop/kernels/hadoop_dataset_ops.cc b/tensorflow/contrib/hadoop/kernels/hadoop_dataset_ops.cc index 36057bbd9b..c2ddbb858d 100644 --- a/tensorflow/contrib/hadoop/kernels/hadoop_dataset_ops.cc +++ b/tensorflow/contrib/hadoop/kernels/hadoop_dataset_ops.cc @@ -30,7 +30,7 @@ class SequenceFileReader { new io::BufferedInputStream(file, kSequenceFileBufferSize)) {} Status ReadHeader() { - std::string version; + string version; TF_RETURN_IF_ERROR(input_stream_->ReadNBytes(4, &version)); if (version.substr(0, 3) != "SEQ" || version[3] != 6) { return errors::InvalidArgument( @@ -49,7 +49,7 @@ class SequenceFileReader { "' is currently not supported"); } - std::string buffer; + string buffer; TF_RETURN_IF_ERROR(input_stream_->ReadNBytes(2, &buffer)); compression_ = buffer[0]; block_compression_ = buffer[1]; @@ -83,12 +83,12 @@ class SequenceFileReader { return Status::OK(); } - Status ReadRecord(std::string* key, std::string* value) { + Status ReadRecord(string* key, string* value) { uint32 length = 0; TF_RETURN_IF_ERROR(ReadUInt32(&length)); if (length == static_cast(-1)) { // Sync marker. - std::string sync_marker; + string sync_marker; TF_RETURN_IF_ERROR( input_stream_->ReadNBytes(kSyncMarkerSize, &sync_marker)); if (sync_marker != sync_marker_) { @@ -114,7 +114,7 @@ class SequenceFileReader { return Status::OK(); } - Status ReadString(std::string* value) { + Status ReadString(string* value) { int64 length = 0; TF_RETURN_IF_ERROR(ReadVInt(&length)); if (value == nullptr) { @@ -124,7 +124,7 @@ class SequenceFileReader { } Status ReadUInt32(uint32* value) { - std::string buffer; + string buffer; TF_RETURN_IF_ERROR(input_stream_->ReadNBytes(4, &buffer)); *value = (uint32(buffer[0]) << 24) | (uint32(buffer[1]) << 16) | (uint32(buffer[2]) << 8) | uint32(buffer[3]); @@ -132,7 +132,7 @@ class SequenceFileReader { } Status ReadVInt(int64* value) { - std::string buffer; + string buffer; TF_RETURN_IF_ERROR(input_stream_->ReadNBytes(1, &buffer)); if (buffer[0] >= -112) { *value = static_cast(buffer[0]); @@ -165,15 +165,14 @@ class SequenceFileReader { private: std::unique_ptr input_stream_; - std::string key_class_name_; - std::string value_class_name_; - std::string sync_marker_; + string key_class_name_; + string value_class_name_; + string sync_marker_; bool compression_; bool block_compression_; - std::string compression_codec_class_name_; + string compression_codec_class_name_; TF_DISALLOW_COPY_AND_ASSIGN(SequenceFileReader); }; -} class SequenceFileDatasetOp : public DatasetOpKernel { public: using DatasetOpKernel::DatasetOpKernel; @@ -252,17 +251,17 @@ class SequenceFileDatasetOp : public DatasetOpKernel { do { // We are currently processing a file, so try to read the next record. if (reader_) { - std::string key, value; + string key, value; Status status = reader_->ReadRecord(&key, &value); if (!errors::IsOutOfRange(status)) { TF_RETURN_IF_ERROR(status); Tensor key_tensor(ctx->allocator({}), DT_STRING, {}); - key_tensor.scalar()() = key; + key_tensor.scalar()() = key; out_tensors->emplace_back(std::move(key_tensor)); Tensor value_tensor(ctx->allocator({}), DT_STRING, {}); - value_tensor.scalar()() = value; + value_tensor.scalar()() = value; out_tensors->emplace_back(std::move(value_tensor)); *end_of_sequence = false; @@ -312,7 +311,7 @@ class SequenceFileDatasetOp : public DatasetOpKernel { return reader_->ReadHeader(); } - // Resets all Parquet streams. + // Resets all Hadoop SequenceFile streams. void ResetStreamsLocked() EXCLUSIVE_LOCKS_REQUIRED(mu_) { reader_.reset(); file_.reset(); @@ -330,6 +329,8 @@ class SequenceFileDatasetOp : public DatasetOpKernel { DataTypeVector output_types_; }; +} + REGISTER_KERNEL_BUILDER(Name("SequenceFileDataset").Device(DEVICE_CPU), SequenceFileDatasetOp); diff --git a/tensorflow/contrib/hadoop/python/kernel_tests/hadoop_test.py b/tensorflow/contrib/hadoop/python/kernel_tests/hadoop_test.py index 108aaecdb7..8f6f4a20e3 100644 --- a/tensorflow/contrib/hadoop/python/kernel_tests/hadoop_test.py +++ b/tensorflow/contrib/hadoop/python/kernel_tests/hadoop_test.py @@ -42,8 +42,7 @@ class SequenceFileDatasetTest(test.TestCase): filename = os.path.join( resource_loader.get_data_files_path(), 'testdata/string.seq') - filenames = array_ops.placeholder_with_default( - constant_op.constant([filename], dtypes.string), shape=[None]) + filenames = constant_op.constant([filename], dtypes.string) num_repeats = 2 dataset = hadoop_dataset_ops.SequenceFileDataset( diff --git a/tensorflow/contrib/hadoop/python/ops/hadoop_dataset_ops.py b/tensorflow/contrib/hadoop/python/ops/hadoop_dataset_ops.py index 661e298756..7e9e8094a8 100644 --- a/tensorflow/contrib/hadoop/python/ops/hadoop_dataset_ops.py +++ b/tensorflow/contrib/hadoop/python/ops/hadoop_dataset_ops.py @@ -29,7 +29,7 @@ from tensorflow.python.framework import tensor_shape class SequenceFileDataset(Dataset): """A Sequence File Dataset that reads the sequence file.""" - def __init__(self, filenames, output_types=(dtypes.string, dtypes.string)): + def __init__(self, filenames): """Create a `SequenceFileDataset`. `SequenceFileDataset` allows a user to read data from a hadoop sequence @@ -40,8 +40,7 @@ class SequenceFileDataset(Dataset): For example: ```python - dataset = tf.contrib.hadoop.SequenceFileDataset( - "/foo/bar.seq", (tf.string, tf.string)) + dataset = tf.contrib.hadoop.SequenceFileDataset("/foo/bar.seq") iterator = dataset.make_one_shot_iterator() next_element = iterator.get_next() # Prints the (key, value) pairs inside a hadoop sequence file. @@ -54,14 +53,10 @@ class SequenceFileDataset(Dataset): Args: filenames: A `tf.string` tensor containing one or more filenames. - output_types: A tuple of `tf.DType` objects representing the types of the - key-value pairs returned. Only `(tf.string, tf.string)` is supported - at the moment. """ super(SequenceFileDataset, self).__init__() self._filenames = ops.convert_to_tensor( filenames, dtype=dtypes.string, name="filenames") - self._output_types = output_types def _as_variant_tensor(self): return gen_dataset_ops.sequence_file_dataset( @@ -69,7 +64,7 @@ class SequenceFileDataset(Dataset): @property def output_classes(self): - return nest.map_structure(lambda _: ops.Tensor, self._output_types) + return ops.Tensor, ops.Tensor @property def output_shapes(self): @@ -77,4 +72,4 @@ class SequenceFileDataset(Dataset): @property def output_types(self): - return self._output_types + return dtypes.string, dtypes.string -- GitLab From 3d5364b9d75d36121289fc36c02cd02c0bd0d1a9 Mon Sep 17 00:00:00 2001 From: Dan J Date: Fri, 29 Jun 2018 16:14:58 -0700 Subject: [PATCH 047/437] Fix broken download links --- tensorflow/examples/android/README.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tensorflow/examples/android/README.md b/tensorflow/examples/android/README.md index 30a26d13c5..dac9b7ab82 100644 --- a/tensorflow/examples/android/README.md +++ b/tensorflow/examples/android/README.md @@ -45,11 +45,7 @@ on API >= 14 devices. ## Prebuilt Components: -If you just want the fastest path to trying the demo, you may download the -nightly build -[here](https://ci.tensorflow.org/view/Nightly/job/nightly-android/). Expand the -"View" and then the "out" folders under "Last Successful Artifacts" to find -tensorflow_demo.apk. +The fastest path to trying the demo is to download the [prebuilt demo APK](http://download.tensorflow.org/deps/tflite/TfLiteCameraDemo.apk). Also available are precompiled native libraries, and a jcenter package that you may simply drop into your own applications. See @@ -113,8 +109,7 @@ protobuf compilation. NOTE: Bazel does not currently support building for Android on Windows. Full support for gradle/cmake builds is coming soon, but in the meantime we suggest -that Windows users download the [prebuilt -binaries](https://ci.tensorflow.org/view/Nightly/job/nightly-android/) instead. +that Windows users download the [prebuilt demo APK](http://download.tensorflow.org/deps/tflite/TfLiteCameraDemo.apk) instead. ##### Install Bazel and Android Prerequisites -- GitLab From 7462a25a2aed29f63ed3a047aec4ff363d8b6aad Mon Sep 17 00:00:00 2001 From: "William D. Irons" Date: Mon, 2 Jul 2018 09:44:57 -0500 Subject: [PATCH 048/437] Fix matrix_inverse_tril_test handling the inverse of 0 The inverse of 0 is undefined, so when computing the inverse of a lower triangular numpy array, we need to ensure the zeros in the upper parts of the triangle remain as zero. After doing the inverse of an array, iterator over the array and set the values above the main diagonal to zero. See: https://github.com/numpy/numpy/issues/11445 Fixes: #20013 --- .../bijectors/matrix_inverse_tril_test.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tensorflow/contrib/distributions/python/kernel_tests/bijectors/matrix_inverse_tril_test.py b/tensorflow/contrib/distributions/python/kernel_tests/bijectors/matrix_inverse_tril_test.py index 85d604e34a..49a9afe3f6 100644 --- a/tensorflow/contrib/distributions/python/kernel_tests/bijectors/matrix_inverse_tril_test.py +++ b/tensorflow/contrib/distributions/python/kernel_tests/bijectors/matrix_inverse_tril_test.py @@ -29,6 +29,17 @@ from tensorflow.python.platform import test class MatrixInverseTriLBijectorTest(test.TestCase): """Tests the correctness of the Y = inv(tril) transformation.""" + #The inverse of 0 is undefined, as the numbers above the main + #diagonal must be zero, we zero out these numbers after running inverse. + #See: https://github.com/numpy/numpy/issues/11445 + def _inv(self, x): + y = np.linalg.inv(x) + #triu_indices only works on 2d arrays + #need to iterate over all the 2d arrays in a x-dimensional array. + for idx in np.ndindex(y.shape[0:-2]): + y[idx][np.triu_indices(y[idx].shape[-1], 1)] = 0 + return y + @test_util.run_in_graph_and_eager_modes def testComputesCorrectValues(self): inv = bijectors.MatrixInverseTriL(validate_args=True) @@ -98,7 +109,7 @@ class MatrixInverseTriLBijectorTest(test.TestCase): [2., 3.]]], [[[4., 0.], [5., -6.]]]], dtype=np.float32) - x_inv_ = np.linalg.inv(x_) + x_inv_ = self._inv(x_) expected_fldj_ = -4. * np.sum( np.log(np.abs(np.diagonal(x_, axis1=-2, axis2=-1))), axis=-1) -- GitLab From 54fee8b09ed3a3b6f87dcd76dc6fb7c388e6482f Mon Sep 17 00:00:00 2001 From: naurril Date: Tue, 3 Jul 2018 00:36:19 +0800 Subject: [PATCH 049/437] cleanup CondContext at exception --- tensorflow/python/ops/control_flow_ops.py | 28 +++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/tensorflow/python/ops/control_flow_ops.py b/tensorflow/python/ops/control_flow_ops.py index fc37805c79..f441e4be9b 100644 --- a/tensorflow/python/ops/control_flow_ops.py +++ b/tensorflow/python/ops/control_flow_ops.py @@ -2044,21 +2044,25 @@ def cond(pred, # Build the graph for the true branch in a new context. context_t = CondContext(pred, pivot_1, branch=1) - context_t.Enter() - orig_res_t, res_t = context_t.BuildCondBranch(true_fn) - if orig_res_t is None: - raise ValueError("true_fn must have a return value.") - context_t.ExitResult(res_t) - context_t.Exit() + try: + context_t.Enter() + orig_res_t, res_t = context_t.BuildCondBranch(true_fn) + if orig_res_t is None: + raise ValueError("true_fn must have a return value.") + context_t.ExitResult(res_t) + finally: + context_t.Exit() # Build the graph for the false branch in a new context. context_f = CondContext(pred, pivot_2, branch=0) - context_f.Enter() - orig_res_f, res_f = context_f.BuildCondBranch(false_fn) - if orig_res_f is None: - raise ValueError("false_fn must have a return value.") - context_f.ExitResult(res_f) - context_f.Exit() + try: + context_f.Enter() + orig_res_f, res_f = context_f.BuildCondBranch(false_fn) + if orig_res_f is None: + raise ValueError("false_fn must have a return value.") + context_f.ExitResult(res_f) + finally: + context_f.Exit() if not strict: orig_res_t = _UnpackIfSingleton(orig_res_t) -- GitLab From 36db4d00e46c6ebecaf9e5a73ca1994df98086de Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Mon, 2 Jul 2018 18:35:22 +0000 Subject: [PATCH 050/437] Update signature change and fix pylint issue Signed-off-by: Yong Tang --- tensorflow/contrib/hadoop/kernels/hadoop_dataset_ops.cc | 7 ++++--- .../contrib/hadoop/python/kernel_tests/hadoop_test.py | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tensorflow/contrib/hadoop/kernels/hadoop_dataset_ops.cc b/tensorflow/contrib/hadoop/kernels/hadoop_dataset_ops.cc index c2ddbb858d..1afb4334f5 100644 --- a/tensorflow/contrib/hadoop/kernels/hadoop_dataset_ops.cc +++ b/tensorflow/contrib/hadoop/kernels/hadoop_dataset_ops.cc @@ -211,7 +211,7 @@ class SequenceFileDatasetOp : public DatasetOpKernel { filenames_(filenames), output_types_(output_types) {} - std::unique_ptr MakeIterator( + std::unique_ptr MakeIteratorInternal( const string& prefix) const override { return std::unique_ptr( new Iterator({this, strings::StrCat(prefix, "::SequenceFile")})); @@ -227,7 +227,9 @@ class SequenceFileDatasetOp : public DatasetOpKernel { return *shapes; } - string DebugString() override { return "SequenceFileDatasetOp::Dataset"; } + string DebugString() const override { + return "SequenceFileDatasetOp::Dataset"; + } protected: Status AsGraphDefInternal(DatasetGraphDefBuilder* b, @@ -328,7 +330,6 @@ class SequenceFileDatasetOp : public DatasetOpKernel { }; DataTypeVector output_types_; }; - } REGISTER_KERNEL_BUILDER(Name("SequenceFileDataset").Device(DEVICE_CPU), diff --git a/tensorflow/contrib/hadoop/python/kernel_tests/hadoop_test.py b/tensorflow/contrib/hadoop/python/kernel_tests/hadoop_test.py index 8f6f4a20e3..91ba6b0a11 100644 --- a/tensorflow/contrib/hadoop/python/kernel_tests/hadoop_test.py +++ b/tensorflow/contrib/hadoop/python/kernel_tests/hadoop_test.py @@ -24,7 +24,6 @@ from tensorflow.contrib.hadoop.python.ops import hadoop_dataset_ops from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors -from tensorflow.python.ops import array_ops from tensorflow.python.platform import resource_loader from tensorflow.python.platform import test -- GitLab From 76b3aae602d298c43db08f3822567f4c32338871 Mon Sep 17 00:00:00 2001 From: Loo Rong Jie Date: Tue, 3 Jul 2018 12:33:24 +0800 Subject: [PATCH 051/437] Fix int64 to int truncation in std::accumulate --- tensorflow/compiler/xla/array.h | 2 +- tensorflow/compiler/xla/service/indexed_array_analysis.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tensorflow/compiler/xla/array.h b/tensorflow/compiler/xla/array.h index ea75ad32d5..2d5d078aa7 100644 --- a/tensorflow/compiler/xla/array.h +++ b/tensorflow/compiler/xla/array.h @@ -409,7 +409,7 @@ class Array { // Returns the total number of elements in the array. int64 num_elements() const { - return std::accumulate(sizes_.begin(), sizes_.end(), 1, + return std::accumulate(sizes_.begin(), sizes_.end(), 1LL, std::multiplies()); } diff --git a/tensorflow/compiler/xla/service/indexed_array_analysis.cc b/tensorflow/compiler/xla/service/indexed_array_analysis.cc index 1985d20578..e809a183d7 100644 --- a/tensorflow/compiler/xla/service/indexed_array_analysis.cc +++ b/tensorflow/compiler/xla/service/indexed_array_analysis.cc @@ -441,7 +441,7 @@ int64 FindSourcePositionForPassthroughResultDim(ArraySlice operand_shape, int64 indexed_source_subarray_size = std::accumulate(operand_shape.begin() + source_passthrough_dim + 1, - operand_shape.end(), 1, std::multiplies()); + operand_shape.end(), 1LL, std::multiplies()); return FindSuffixWithProduct(result_shape, indexed_source_subarray_size); } @@ -758,7 +758,7 @@ IndexedArrayAnalysis::FoldReshapeOfGatherNoDegenerateDims( &new_scalar_indexed_source_shape, source_dim_for_new_scalar_indexed_node, scalar_indexed_source_shape.dimensions(scalar_indexed->source_dim())); - CHECK_EQ(c_accumulate(new_scalar_indexed_source_shape, 1l, + CHECK_EQ(c_accumulate(new_scalar_indexed_source_shape, 1LL, std::multiplies()), ShapeUtil::ElementsIn(scalar_indexed_source_shape)); -- GitLab From 38e56744327f5090585179554d0df21fb52515a6 Mon Sep 17 00:00:00 2001 From: naurril Date: Thu, 5 Jul 2018 00:49:37 +0800 Subject: [PATCH 052/437] check parameters before init GrpcServer --- .../rpc/grpc_server_lib.cc | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc b/tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc index 2c833d11a9..7987fdbcc0 100644 --- a/tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc +++ b/tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc @@ -120,27 +120,6 @@ Status GrpcServer::Init( master_env_.env = env_; worker_env_.env = env_; - SessionOptions sess_opts; - ConfigProto config = server_def_.default_session_config(); - sess_opts.config = config; - - // Configure shared devices between master and worker. - string name_prefix = - strings::StrCat("/job:", server_def_.job_name(), "/replica:0", - "/task:", server_def_.task_index()); - TF_RETURN_IF_ERROR(DeviceFactory::AddDevices(sess_opts, name_prefix, - &master_env_.local_devices)); - worker_env_.local_devices = master_env_.local_devices; - worker_env_.device_mgr = new DeviceMgr(worker_env_.local_devices); - worker_env_.rendezvous_mgr = rendezvous_mgr_func == nullptr - ? new RpcRendezvousMgr(&worker_env_) - : rendezvous_mgr_func(&worker_env_); - string unused; - string default_worker_name; - if (!DeviceNameUtils::SplitDeviceName(master_env_.local_devices[0]->name(), - &default_worker_name, &unused)) { - return errors::Internal("Could not parse worker name."); - } // Look up the port that has been requested for this task in `server_def_`. int requested_port = -1; @@ -169,6 +148,31 @@ Status GrpcServer::Init( "\" was not defined in cluster"); } + + SessionOptions sess_opts; + ConfigProto config = server_def_.default_session_config(); + sess_opts.config = config; + + // Configure shared devices between master and worker. + string name_prefix = + strings::StrCat("/job:", server_def_.job_name(), "/replica:0", + "/task:", server_def_.task_index()); + TF_RETURN_IF_ERROR(DeviceFactory::AddDevices(sess_opts, name_prefix, + &master_env_.local_devices)); + worker_env_.local_devices = master_env_.local_devices; + worker_env_.device_mgr = new DeviceMgr(worker_env_.local_devices); + worker_env_.rendezvous_mgr = rendezvous_mgr_func == nullptr + ? new RpcRendezvousMgr(&worker_env_) + : rendezvous_mgr_func(&worker_env_); + string unused; + string default_worker_name; + if (!DeviceNameUtils::SplitDeviceName(master_env_.local_devices[0]->name(), + &default_worker_name, &unused)) { + return errors::Internal("Could not parse worker name."); + } + + + // N.B. The order of initialization here is intricate, because we // wish to allow `requested_port == 0` (for choosing any port, // mostly for testing). Therefore, the construction of the channel -- GitLab From 7d2872f91d454a45a84162cc0e1e881857158730 Mon Sep 17 00:00:00 2001 From: naurril Date: Thu, 5 Jul 2018 00:52:14 +0800 Subject: [PATCH 053/437] add comments --- tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc b/tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc index 7987fdbcc0..d54a9d4fd1 100644 --- a/tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc +++ b/tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc @@ -121,6 +121,9 @@ Status GrpcServer::Init( worker_env_.env = env_; + // Check parameters before DeviceFactory::AddDevices, + // otherwise if 'task_index=-1' the program will abort. + // Look up the port that has been requested for this task in `server_def_`. int requested_port = -1; for (const auto& job : server_def_.cluster().job()) { -- GitLab From cccfb75736120ec55a1b23c148242f615cf4aa77 Mon Sep 17 00:00:00 2001 From: Clayne Robison Date: Thu, 5 Jul 2018 16:45:15 -0700 Subject: [PATCH 054/437] Adding support for python3 to MKL Dockerfile --- tensorflow/tools/docker/Dockerfile.mkl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tensorflow/tools/docker/Dockerfile.mkl b/tensorflow/tools/docker/Dockerfile.mkl index 139395d491..ad5109f26d 100755 --- a/tensorflow/tools/docker/Dockerfile.mkl +++ b/tensorflow/tools/docker/Dockerfile.mkl @@ -20,7 +20,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libpng12-dev \ libzmq3-dev \ pkg-config \ - python \ + ${PYTHON} \ ${PYTHON_DEV} \ rsync \ software-properties-common \ @@ -30,7 +30,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ rm -rf /var/lib/apt/lists/* RUN curl -O https://bootstrap.pypa.io/get-pip.py && \ - python get-pip.py && \ + ${PYTHON} get-pip.py && \ rm get-pip.py RUN ${PIP} --no-cache-dir install \ @@ -44,7 +44,7 @@ RUN ${PIP} --no-cache-dir install \ scipy \ sklearn \ && \ - python -m ipykernel.kernelspec + ${PYTHON} -m ipykernel.kernelspec COPY ${TF_WHL_URL} / RUN ${PIP} install --no-cache-dir --force-reinstall /${TF_WHL_URL} && \ -- GitLab From 1dc5772b08adc34cc5e830e243f8884cdc5bac72 Mon Sep 17 00:00:00 2001 From: Loo Rong Jie Date: Wed, 4 Jul 2018 08:07:59 +0800 Subject: [PATCH 055/437] [Bazel/MSVC] Cleanup -ldl/-lm flags for MSVC --- tensorflow/core/BUILD | 8 +++----- third_party/double_conversion.BUILD | 16 ++++++++++------ third_party/fft2d/fft2d.BUILD | 10 +++++++++- third_party/flatbuffers/flatbuffers.BUILD | 12 ++++++++---- third_party/snappy.BUILD | 13 +++---------- 5 files changed, 33 insertions(+), 26 deletions(-) diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD index dbe87a6dbb..1cd2830efb 100644 --- a/tensorflow/core/BUILD +++ b/tensorflow/core/BUILD @@ -2477,13 +2477,11 @@ tf_cuda_library( hdrs = FRAMEWORK_INTERNAL_PUBLIC_HEADERS, copts = tf_copts(), linkopts = select({ - "//tensorflow:freebsd": [], + "//tensorflow:freebsd": ["-lm"], "//tensorflow:windows": [], "//tensorflow:windows_msvc": [], - "//conditions:default": ["-ldl"], - }) + [ - "-lm", - ], + "//conditions:default": ["-ldl", "-lm"], + }), deps = [ ":lib", ":lib_internal", diff --git a/third_party/double_conversion.BUILD b/third_party/double_conversion.BUILD index 9f905216c0..d875a1a2b5 100644 --- a/third_party/double_conversion.BUILD +++ b/third_party/double_conversion.BUILD @@ -4,6 +4,11 @@ licenses(["notice"]) exports_files(["LICENSE"]) +config_setting( + name = "windows", + values = {"cpu": "x64_windows"}, +) + cc_library( name = "double-conversion", srcs = [ @@ -28,11 +33,10 @@ cc_library( "double-conversion/ieee.h", "double-conversion/strtod.h", ], - includes = [ - ".", - ], - linkopts = [ - "-lm", - ], + includes = ["."], + linkopts = select({ + ":windows": [], + "//conditions:default": ["-lm"], + }), visibility = ["//visibility:public"], ) diff --git a/third_party/fft2d/fft2d.BUILD b/third_party/fft2d/fft2d.BUILD index 3dbd36aec0..74dd3112fc 100644 --- a/third_party/fft2d/fft2d.BUILD +++ b/third_party/fft2d/fft2d.BUILD @@ -14,6 +14,11 @@ FFT2D_SRCS = [ "fft/fftsg.c", ] +config_setting( + name = "windows", + values = {"cpu": "x64_windows"}, +) + # This is the main 2D FFT library. The 2D FFTs in this library call # 1D FFTs. In addition, fast DCTs are provided for the special case # of 8x8 and 16x16. This code in this library is referred to as @@ -21,7 +26,10 @@ FFT2D_SRCS = [ cc_library( name = "fft2d", srcs = FFT2D_SRCS, - linkopts = ["-lm"], + linkopts = select({ + ":windows": [], + "//conditions:default": ["-lm"], + }), ) objc_library( diff --git a/third_party/flatbuffers/flatbuffers.BUILD b/third_party/flatbuffers/flatbuffers.BUILD index 639dff2cd0..3a19d28667 100644 --- a/third_party/flatbuffers/flatbuffers.BUILD +++ b/third_party/flatbuffers/flatbuffers.BUILD @@ -12,12 +12,15 @@ config_setting( visibility = ["//visibility:public"], ) -FLATBUFFERS_COPTS = [ - "-fexceptions", -] + select({ +config_setting( + name = "windows", + values = {"cpu": "x64_windows"}, +) + +FLATBUFFERS_COPTS = select({ "@bazel_tools//src:windows": [], "@bazel_tools//src:windows_msvc": [], - "//conditions:default": ["-Wno-implicit-fallthrough"], + "//conditions:default": ["-Wno-implicit-fallthrough", "-fexceptions"], }) # Public flatc library to compile flatbuffer files at runtime. @@ -121,6 +124,7 @@ cc_binary( ":freebsd": [ "-lm", ], + ":windows": [], "//conditions:default": [ "-lm", "-ldl", diff --git a/third_party/snappy.BUILD b/third_party/snappy.BUILD index cc11f52d0e..58120ccdf2 100644 --- a/third_party/snappy.BUILD +++ b/third_party/snappy.BUILD @@ -18,17 +18,10 @@ cc_library( "snappy-stubs-public.h", ], hdrs = ["snappy.h"], - copts = select({ - "@org_tensorflow//tensorflow:windows": [ - "/DHAVE_CONFIG_H", - "/EHsc", - ], - "@org_tensorflow//tensorflow:windows_msvc": [ - "/DHAVE_CONFIG_H", - "/EHsc", - ], + copts = ["-DHAVE_CONFIG_H"] + select({ + "@org_tensorflow//tensorflow:windows": [], + "@org_tensorflow//tensorflow:windows_msvc": [], "//conditions:default": [ - "-DHAVE_CONFIG_H", "-fno-exceptions", "-Wno-sign-compare", "-Wno-shift-negative-value", -- GitLab From 36032a2dfd38eb7f4fb96baf60e01b8e72bec2b1 Mon Sep 17 00:00:00 2001 From: Loo Rong Jie Date: Wed, 4 Jul 2018 09:01:18 +0800 Subject: [PATCH 056/437] More cleanup --- tensorflow/core/BUILD | 10 ++++++++-- tensorflow/core/kernels/BUILD | 1 + tensorflow/java/BUILD | 5 ++++- tensorflow/stream_executor/BUILD | 2 ++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD index 1cd2830efb..6fa557d53f 100644 --- a/tensorflow/core/BUILD +++ b/tensorflow/core/BUILD @@ -734,7 +734,10 @@ cc_library( "util/reporter.h", ], copts = tf_copts(), - linkopts = ["-lm"], + linkopts = select({ + "//tensorflow:windows": [], + "//conditions:default": ["-lm"], + }), visibility = ["//visibility:public"], deps = [ ":lib", @@ -3116,7 +3119,10 @@ cc_library( testonly = 1, srcs = ["platform/test_main.cc"], copts = tf_copts(), - linkopts = ["-lm"], + linkopts = select({ + "//tensorflow:windows": [], + "//conditions:default": ["-lm"], + }), visibility = ["//tensorflow:internal"], deps = [ ":lib", diff --git a/tensorflow/core/kernels/BUILD b/tensorflow/core/kernels/BUILD index 7599cf7db2..6f0223f50d 100644 --- a/tensorflow/core/kernels/BUILD +++ b/tensorflow/core/kernels/BUILD @@ -2501,6 +2501,7 @@ tf_kernel_library( # allow multiple definitions when linking this. linkopts = select({ "//tensorflow:darwin": [], + "//tensorflow:windows": [], "//conditions:default": ["-Wl,-z,muldefs"], }), visibility = [":friends"], diff --git a/tensorflow/java/BUILD b/tensorflow/java/BUILD index 73e210fae0..d1108f251c 100644 --- a/tensorflow/java/BUILD +++ b/tensorflow/java/BUILD @@ -86,7 +86,10 @@ tf_cc_binary( "src/gen/cc/op_gen_main.cc", ], copts = tf_copts(), - linkopts = ["-lm"], + linkopts = select({ + "//tensorflow:windows": [], + "//conditions:default": ["-lm"], + }), linkstatic = 1, deps = [ ":java_op_gen_lib", diff --git a/tensorflow/stream_executor/BUILD b/tensorflow/stream_executor/BUILD index e742f8e8d5..d4d97087ba 100644 --- a/tensorflow/stream_executor/BUILD +++ b/tensorflow/stream_executor/BUILD @@ -30,6 +30,7 @@ cc_library( hdrs = STREAM_EXECUTOR_HEADERS, linkopts = select({ "//tensorflow:freebsd": [], + "//tensorflow:windows": [], "//conditions:default": ["-ldl"], }), visibility = ["//visibility:public"], @@ -79,6 +80,7 @@ cc_library( }), linkopts = select({ "//tensorflow:freebsd": [], + "//tensorflow:windows": [], "//conditions:default": ["-ldl"], }), visibility = ["//visibility:public"], -- GitLab From bdd8bf316e4ab7d699127d192d30eb614a158462 Mon Sep 17 00:00:00 2001 From: Loo Rong Jie Date: Wed, 11 Jul 2018 20:24:10 +0800 Subject: [PATCH 057/437] Remove all references of windows_msvc config_setting --- tensorflow/BUILD | 9 --------- tensorflow/cc/BUILD | 1 - tensorflow/core/BUILD | 6 ------ tensorflow/core/platform/default/build_config.bzl | 3 --- tensorflow/java/BUILD | 1 - tensorflow/tensorflow.bzl | 9 --------- tensorflow/tools/pip_package/BUILD | 1 - tensorflow/tools/proto_text/BUILD | 1 - third_party/curl.BUILD | 14 -------------- third_party/farmhash.BUILD | 8 -------- third_party/flatbuffers/flatbuffers.BUILD | 3 +-- third_party/gif.BUILD | 9 --------- third_party/jpeg/jpeg.BUILD | 8 -------- third_party/lmdb.BUILD | 6 ------ third_party/nasm.BUILD | 9 --------- third_party/snappy.BUILD | 1 - third_party/sqlite.BUILD | 8 +++----- third_party/swig.BUILD | 6 ------ third_party/zlib.BUILD | 1 - 19 files changed, 4 insertions(+), 100 deletions(-) diff --git a/tensorflow/BUILD b/tensorflow/BUILD index 51eea94847..314db599ca 100644 --- a/tensorflow/BUILD +++ b/tensorflow/BUILD @@ -115,12 +115,6 @@ config_setting( visibility = ["//visibility:public"], ) -config_setting( - name = "windows_msvc", - values = {"cpu": "x64_windows_msvc"}, - visibility = ["//visibility:public"], -) - config_setting( name = "no_tensorflow_py_deps", define_values = {"no_tensorflow_py_deps": "true"}, @@ -484,7 +478,6 @@ tf_cc_shared_object( linkopts = select({ "//tensorflow:darwin": [], "//tensorflow:windows": [], - "//tensorflow:windows_msvc": [], "//conditions:default": [ "-Wl,--version-script", # This line must be directly followed by the version_script.lds file "$(location //tensorflow:tf_framework_version_script.lds)", @@ -526,7 +519,6 @@ tf_cc_shared_object( "-Wl,-install_name,@rpath/libtensorflow.so", ], "//tensorflow:windows": [], - "//tensorflow:windows_msvc": [], "//conditions:default": [ "-z defs", "-Wl,--version-script", # This line must be directly followed by the version_script.lds file @@ -551,7 +543,6 @@ tf_cc_shared_object( "$(location //tensorflow:tf_exported_symbols.lds)", ], "//tensorflow:windows": [], - "//tensorflow:windows_msvc": [], "//conditions:default": [ "-z defs", "-Wl,--version-script", # This line must be directly followed by the version_script.lds file diff --git a/tensorflow/cc/BUILD b/tensorflow/cc/BUILD index a98f0b00b2..9533e96f13 100644 --- a/tensorflow/cc/BUILD +++ b/tensorflow/cc/BUILD @@ -595,7 +595,6 @@ tf_cc_binary( copts = tf_copts(), linkopts = select({ "//tensorflow:windows": [], - "//tensorflow:windows_msvc": [], "//tensorflow:darwin": [ "-lm", "-lpthread", diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD index 6fa557d53f..d979b55580 100644 --- a/tensorflow/core/BUILD +++ b/tensorflow/core/BUILD @@ -861,7 +861,6 @@ tf_cuda_library( "util/work_sharder.h", ] + select({ "//tensorflow:windows": [], - "//tensorflow:windows_msvc": [], "//conditions:default": [ "util/memmapped_file_system.h", "util/memmapped_file_system_writer.h", @@ -2025,7 +2024,6 @@ cc_library( linkopts = select({ "//tensorflow:freebsd": [], "//tensorflow:windows": [], - "//tensorflow:windows_msvc": [], "//conditions:default": [ "-ldl", "-lpthread", @@ -2114,7 +2112,6 @@ cc_library( linkopts = select({ "//tensorflow:freebsd": [], "//tensorflow:windows": [], - "//tensorflow:windows_msvc": [], "//conditions:default": ["-ldl"], }), deps = [ @@ -2139,7 +2136,6 @@ cc_library( linkopts = select({ "//tensorflow:freebsd": [], "//tensorflow:windows": [], - "//tensorflow:windows_msvc": [], "//conditions:default": ["-ldl"], }), deps = [ @@ -2471,7 +2467,6 @@ tf_cuda_library( ], ) + select({ "//tensorflow:windows": [], - "//tensorflow:windows_msvc": [], "//conditions:default": [ "util/memmapped_file_system.cc", "util/memmapped_file_system_writer.cc", @@ -2482,7 +2477,6 @@ tf_cuda_library( linkopts = select({ "//tensorflow:freebsd": ["-lm"], "//tensorflow:windows": [], - "//tensorflow:windows_msvc": [], "//conditions:default": ["-ldl", "-lm"], }), deps = [ diff --git a/tensorflow/core/platform/default/build_config.bzl b/tensorflow/core/platform/default/build_config.bzl index 28891320c4..fb4ee1c33c 100644 --- a/tensorflow/core/platform/default/build_config.bzl +++ b/tensorflow/core/platform/default/build_config.bzl @@ -467,7 +467,6 @@ def tf_platform_srcs(files): return select({ "//tensorflow:windows" : native.glob(windows_set), - "//tensorflow:windows_msvc" : native.glob(windows_set), "//conditions:default" : native.glob(posix_set), }) @@ -479,7 +478,6 @@ def tf_additional_lib_hdrs(exclude = []): ], exclude = exclude) return select({ "//tensorflow:windows" : windows_hdrs, - "//tensorflow:windows_msvc" : windows_hdrs, "//conditions:default" : native.glob([ "platform/default/*.h", "platform/posix/*.h", @@ -494,7 +492,6 @@ def tf_additional_lib_srcs(exclude = []): ], exclude = exclude) return select({ "//tensorflow:windows" : windows_srcs, - "//tensorflow:windows_msvc" : windows_srcs, "//conditions:default" : native.glob([ "platform/default/*.cc", "platform/posix/*.cc", diff --git a/tensorflow/java/BUILD b/tensorflow/java/BUILD index d1108f251c..b2b7ee3fa5 100644 --- a/tensorflow/java/BUILD +++ b/tensorflow/java/BUILD @@ -345,7 +345,6 @@ tf_cc_binary( "$(location {})".format(LINKER_EXPORTED_SYMBOLS), ], "//tensorflow:windows": [], - "//tensorflow:windows_msvc": [], "//conditions:default": [ "-z defs", "-s", diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl index e4241667ad..8e3323ded5 100644 --- a/tensorflow/tensorflow.bzl +++ b/tensorflow/tensorflow.bzl @@ -137,14 +137,12 @@ def if_not_mobile(a): def if_not_windows(a): return select({ clean_dep("//tensorflow:windows"): [], - clean_dep("//tensorflow:windows_msvc"): [], "//conditions:default": a, }) def if_windows(a): return select({ clean_dep("//tensorflow:windows"): a, - clean_dep("//tensorflow:windows_msvc"): a, "//conditions:default": [], }) @@ -226,7 +224,6 @@ def tf_copts(android_optimization_level_override="-O2", is_external=False): clean_dep("//tensorflow:android"): android_copts, clean_dep("//tensorflow:darwin"): [], clean_dep("//tensorflow:windows"): get_win_copts(is_external), - clean_dep("//tensorflow:windows_msvc"): get_win_copts(is_external), clean_dep("//tensorflow:ios"): ["-std=c++11"], "//conditions:default": ["-pthread"] })) @@ -286,7 +283,6 @@ def _rpath_linkopts(name): "-Wl,%s" % (_make_search_paths("@loader_path", levels_to_root),), ], clean_dep("//tensorflow:windows"): [], - clean_dep("//tensorflow:windows_msvc"): [], "//conditions:default": [ "-Wl,%s" % (_make_search_paths("$$ORIGIN", levels_to_root),), ], @@ -656,7 +652,6 @@ def tf_cc_test(name, "-pie", ], clean_dep("//tensorflow:windows"): [], - clean_dep("//tensorflow:windows_msvc"): [], clean_dep("//tensorflow:darwin"): [ "-lm", ], @@ -838,7 +833,6 @@ def tf_cc_test_mkl(srcs, "-pie", ], clean_dep("//tensorflow:windows"): [], - clean_dep("//tensorflow:windows_msvc"): [], "//conditions:default": [ "-lpthread", "-lm" @@ -1351,7 +1345,6 @@ def tf_custom_op_library(name, srcs=[], gpu_srcs=[], deps=[], linkopts=[]): "-lm", ], clean_dep("//tensorflow:windows"): [], - clean_dep("//tensorflow:windows_msvc"): [], clean_dep("//tensorflow:darwin"): [], }),) @@ -1461,7 +1454,6 @@ def tf_py_wrap_cc(name, "$(location %s.lds)"%vscriptname, ], clean_dep("//tensorflow:windows"): [], - clean_dep("//tensorflow:windows_msvc"): [], "//conditions:default": [ "-Wl,--version-script", "$(location %s.lds)"%vscriptname, @@ -1472,7 +1464,6 @@ def tf_py_wrap_cc(name, "%s.lds"%vscriptname, ], clean_dep("//tensorflow:windows"): [], - clean_dep("//tensorflow:windows_msvc"): [], "//conditions:default": [ "%s.lds"%vscriptname, ] diff --git a/tensorflow/tools/pip_package/BUILD b/tensorflow/tools/pip_package/BUILD index c9d53f46c3..91d574b295 100644 --- a/tensorflow/tools/pip_package/BUILD +++ b/tensorflow/tools/pip_package/BUILD @@ -176,7 +176,6 @@ sh_binary( srcs = ["build_pip_package.sh"], data = select({ "//tensorflow:windows": [":simple_console_for_windows"], - "//tensorflow:windows_msvc": [":simple_console_for_windows"], "//conditions:default": COMMON_PIP_DEPS + [ ":simple_console", "//tensorflow/contrib/lite/python:interpreter_test_data", diff --git a/tensorflow/tools/proto_text/BUILD b/tensorflow/tools/proto_text/BUILD index 31e8fb9120..fc2c041b6c 100644 --- a/tensorflow/tools/proto_text/BUILD +++ b/tensorflow/tools/proto_text/BUILD @@ -49,7 +49,6 @@ cc_library( copts = if_ios(["-DGOOGLE_LOGGING"]), linkopts = select({ "//tensorflow:windows": [], - "//tensorflow:windows_msvc": [], "//tensorflow:darwin": [ "-lm", "-lpthread", diff --git a/third_party/curl.BUILD b/third_party/curl.BUILD index 1638b72161..c93fac6549 100644 --- a/third_party/curl.BUILD +++ b/third_party/curl.BUILD @@ -243,7 +243,6 @@ cc_library( "lib/vtls/darwinssl.c", ], "@org_tensorflow//tensorflow:windows": CURL_WIN_SRCS, - "@org_tensorflow//tensorflow:windows_msvc": CURL_WIN_SRCS, "//conditions:default": [ "lib/vtls/openssl.c", ], @@ -260,7 +259,6 @@ cc_library( ], copts = select({ "@org_tensorflow//tensorflow:windows": CURL_WIN_COPTS, - "@org_tensorflow//tensorflow:windows_msvc": CURL_WIN_COPTS, "//conditions:default": [ "-Iexternal/curl/lib", "-D_GNU_SOURCE", @@ -280,10 +278,6 @@ cc_library( # See curl.h for discussion of write size and Windows "/DCURL_MAX_WRITE_SIZE=16384", ], - "@org_tensorflow//tensorflow:windows_msvc": [ - # See curl.h for discussion of write size and Windows - "/DCURL_MAX_WRITE_SIZE=16384", - ], "//conditions:default": [ "-DCURL_MAX_WRITE_SIZE=65536", ], @@ -307,12 +301,6 @@ cc_library( "-DEFAULTLIB:crypt32.lib", "-DEFAULTLIB:Normaliz.lib", ], - "@org_tensorflow//tensorflow:windows_msvc": [ - "-DEFAULTLIB:ws2_32.lib", - "-DEFAULTLIB:advapi32.lib", - "-DEFAULTLIB:crypt32.lib", - "-DEFAULTLIB:Normaliz.lib", - ], "//conditions:default": [ "-lrt", ], @@ -323,7 +311,6 @@ cc_library( ] + select({ "@org_tensorflow//tensorflow:ios": [], "@org_tensorflow//tensorflow:windows": [], - "@org_tensorflow//tensorflow:windows_msvc": [], "//conditions:default": [ "@boringssl//:ssl", ], @@ -426,7 +413,6 @@ cc_binary( ], copts = select({ "@org_tensorflow//tensorflow:windows": CURL_BIN_WIN_COPTS, - "@org_tensorflow//tensorflow:windows_msvc": CURL_BIN_WIN_COPTS, "//conditions:default": [ "-Iexternal/curl/lib", "-D_GNU_SOURCE", diff --git a/third_party/farmhash.BUILD b/third_party/farmhash.BUILD index a51e1511c1..4b8464684a 100644 --- a/third_party/farmhash.BUILD +++ b/third_party/farmhash.BUILD @@ -2,13 +2,6 @@ licenses(["notice"]) # MIT exports_files(["COPYING"]) -config_setting( - name = "windows_msvc", - values = { - "cpu": "x64_windows_msvc", - }, -) - config_setting( name = "windows", values = { @@ -23,7 +16,6 @@ cc_library( # Disable __builtin_expect support on Windows copts = select({ ":windows": ["/DFARMHASH_OPTIONAL_BUILTIN_EXPECT"], - ":windows_msvc": ["/DFARMHASH_OPTIONAL_BUILTIN_EXPECT"], "//conditions:default": [], }), includes = ["src/."], diff --git a/third_party/flatbuffers/flatbuffers.BUILD b/third_party/flatbuffers/flatbuffers.BUILD index 3a19d28667..4a3701e893 100644 --- a/third_party/flatbuffers/flatbuffers.BUILD +++ b/third_party/flatbuffers/flatbuffers.BUILD @@ -18,8 +18,7 @@ config_setting( ) FLATBUFFERS_COPTS = select({ - "@bazel_tools//src:windows": [], - "@bazel_tools//src:windows_msvc": [], + ":windows": [], "//conditions:default": ["-Wno-implicit-fallthrough", "-fexceptions"], }) diff --git a/third_party/gif.BUILD b/third_party/gif.BUILD index 78fbd6c0e0..cbe730fe10 100644 --- a/third_party/gif.BUILD +++ b/third_party/gif.BUILD @@ -21,7 +21,6 @@ cc_library( ], hdrs = ["lib/gif_lib.h"], defines = select({ - #"@org_tensorflow//tensorflow:android": [ ":android": [ "S_IREAD=S_IRUSR", "S_IWRITE=S_IWUSR", @@ -33,7 +32,6 @@ cc_library( visibility = ["//visibility:public"], deps = select({ ":windows": [":windows_polyfill"], - ":windows_msvc": [":windows_polyfill"], "//conditions:default": [], }), ) @@ -50,13 +48,6 @@ genrule( cmd = "touch $@", ) -config_setting( - name = "windows_msvc", - values = { - "cpu": "x64_windows_msvc", - }, -) - config_setting( name = "windows", values = { diff --git a/third_party/jpeg/jpeg.BUILD b/third_party/jpeg/jpeg.BUILD index 663a218733..99431de62e 100644 --- a/third_party/jpeg/jpeg.BUILD +++ b/third_party/jpeg/jpeg.BUILD @@ -22,7 +22,6 @@ libjpegturbo_copts = select({ "-w", ], ":windows": WIN_COPTS, - ":windows_msvc": WIN_COPTS, "//conditions:default": [ "-O3", "-w", @@ -423,7 +422,6 @@ genrule( outs = ["jconfig.h"], cmd = select({ ":windows": "cp $(location jconfig_win.h) $@", - ":windows_msvc": "cp $(location jconfig_win.h) $@", ":k8": "cp $(location jconfig_nowin_simd.h) $@", ":armeabi-v7a": "cp $(location jconfig_nowin_simd.h) $@", ":arm64-v8a": "cp $(location jconfig_nowin_simd.h) $@", @@ -441,7 +439,6 @@ genrule( outs = ["jconfigint.h"], cmd = select({ ":windows": "cp $(location jconfigint_win.h) $@", - ":windows_msvc": "cp $(location jconfigint_win.h) $@", "//conditions:default": "cp $(location jconfigint_nowin.h) $@", }), ) @@ -541,11 +538,6 @@ config_setting( values = {"cpu": "x64_windows"}, ) -config_setting( - name = "windows_msvc", - values = {"cpu": "x64_windows_msvc"}, -) - config_setting( name = "linux_ppc64le", values = {"cpu": "ppc"}, diff --git a/third_party/lmdb.BUILD b/third_party/lmdb.BUILD index 9b3e1d97c8..f36a698ee3 100644 --- a/third_party/lmdb.BUILD +++ b/third_party/lmdb.BUILD @@ -20,7 +20,6 @@ cc_library( ], linkopts = select({ ":windows": ["-DEFAULTLIB:advapi32.lib"], # InitializeSecurityDescriptor, SetSecurityDescriptorDacl - ":windows_msvc": ["-DEFAULTLIB:advapi32.lib"], "//conditions:default": ["-lpthread"], }), visibility = ["//visibility:public"], @@ -30,8 +29,3 @@ config_setting( name = "windows", values = {"cpu": "x64_windows"}, ) - -config_setting( - name = "windows_msvc", - values = {"cpu": "x64_windows_msvc"}, -) diff --git a/third_party/nasm.BUILD b/third_party/nasm.BUILD index 89330eac54..2b877883b9 100644 --- a/third_party/nasm.BUILD +++ b/third_party/nasm.BUILD @@ -142,7 +142,6 @@ cc_binary( ], copts = select({ ":windows": [], - ":windows_msvc": [], "//conditions:default": [ "-w", "-std=c99", @@ -150,7 +149,6 @@ cc_binary( }), defines = select({ ":windows": [], - ":windows_msvc": [], "//conditions:default": [ "HAVE_SNPRINTF", "HAVE_SYS_TYPES_H", @@ -159,13 +157,6 @@ cc_binary( visibility = ["@jpeg//:__pkg__"], ) -config_setting( - name = "windows_msvc", - values = { - "cpu": "x64_windows_msvc", - }, -) - config_setting( name = "windows", values = { diff --git a/third_party/snappy.BUILD b/third_party/snappy.BUILD index 58120ccdf2..d93f030769 100644 --- a/third_party/snappy.BUILD +++ b/third_party/snappy.BUILD @@ -20,7 +20,6 @@ cc_library( hdrs = ["snappy.h"], copts = ["-DHAVE_CONFIG_H"] + select({ "@org_tensorflow//tensorflow:windows": [], - "@org_tensorflow//tensorflow:windows_msvc": [], "//conditions:default": [ "-fno-exceptions", "-Wno-sign-compare", diff --git a/third_party/sqlite.BUILD b/third_party/sqlite.BUILD index 2876f305f1..8b876fb56f 100644 --- a/third_party/sqlite.BUILD +++ b/third_party/sqlite.BUILD @@ -4,7 +4,6 @@ licenses(["unencumbered"]) # Public Domain SQLITE_COPTS = [ - "-Os", "-DSQLITE_ENABLE_JSON1", "-DHAVE_DECL_STRERROR_R=1", "-DHAVE_STDINT_H=1", @@ -15,15 +14,14 @@ SQLITE_COPTS = [ "@org_tensorflow//tensorflow:windows": [ "-DSQLITE_MAX_TRIGGER_DEPTH=100", ], - "@org_tensorflow//tensorflow:windows_msvc": [ - "-DSQLITE_MAX_TRIGGER_DEPTH=100", - ], "@org_tensorflow//tensorflow:darwin": [ + "-Os", "-DHAVE_GMTIME_R=1", "-DHAVE_LOCALTIME_R=1", "-DHAVE_USLEEP=1", ], "//conditions:default": [ + "-Os", "-DHAVE_FDATASYNC=1", "-DHAVE_GMTIME_R=1", "-DHAVE_LOCALTIME_R=1", @@ -48,7 +46,7 @@ cc_library( "SQLITE_OMIT_DEPRECATED", ], linkopts = select({ - "@org_tensorflow//tensorflow:windows_msvc": [], + "@org_tensorflow//tensorflow:windows": [], "//conditions:default": [ "-ldl", "-lpthread", diff --git a/third_party/swig.BUILD b/third_party/swig.BUILD index f2f647401b..59a3d9e671 100644 --- a/third_party/swig.BUILD +++ b/third_party/swig.BUILD @@ -71,7 +71,6 @@ cc_binary( ], copts = ["$(STACK_FRAME_UNLIMITED)"] + select({ ":windows": [], - ":windows_msvc": [], "//conditions:default": [ "-Wno-parentheses", "-Wno-unused-variable", @@ -331,11 +330,6 @@ genrule( " $< >$@", ) -config_setting( - name = "windows_msvc", - values = {"cpu": "x64_windows_msvc"}, -) - config_setting( name = "windows", values = {"cpu": "x64_windows"}, diff --git a/third_party/zlib.BUILD b/third_party/zlib.BUILD index e8048dd98a..33694eaaae 100644 --- a/third_party/zlib.BUILD +++ b/third_party/zlib.BUILD @@ -34,7 +34,6 @@ cc_library( hdrs = ["zlib.h"], copts = select({ "@org_tensorflow//tensorflow:windows": [], - "@org_tensorflow//tensorflow:windows_msvc": [], "//conditions:default": [ "-Wno-shift-negative-value", "-DZ_HAVE_UNISTD_H", -- GitLab From 87b15fc8fc67d7b9dc9771f46a897c3f3befeeda Mon Sep 17 00:00:00 2001 From: Loo Rong Jie Date: Thu, 12 Jul 2018 10:52:06 +0800 Subject: [PATCH 058/437] Remove windows_msvc from png_internal --- tensorflow/core/BUILD | 1 - 1 file changed, 1 deletion(-) diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD index d979b55580..05b393ac9f 100644 --- a/tensorflow/core/BUILD +++ b/tensorflow/core/BUILD @@ -2167,7 +2167,6 @@ cc_library( linkopts = select({ "//tensorflow:freebsd": [], "//tensorflow:windows": [], - "//tensorflow:windows_msvc": [], "//conditions:default": ["-ldl"], }), deps = [ -- GitLab From c7e29163d49db7c4957fb225d17bda86d086a14b Mon Sep 17 00:00:00 2001 From: Loo Rong Jie Date: Thu, 12 Jul 2018 12:36:58 +0800 Subject: [PATCH 059/437] Fix buildifier check --- tensorflow/core/BUILD | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD index 05b393ac9f..69723b1d77 100644 --- a/tensorflow/core/BUILD +++ b/tensorflow/core/BUILD @@ -2476,7 +2476,10 @@ tf_cuda_library( linkopts = select({ "//tensorflow:freebsd": ["-lm"], "//tensorflow:windows": [], - "//conditions:default": ["-ldl", "-lm"], + "//conditions:default": [ + "-ldl", + "-lm", + ], }), deps = [ ":lib", -- GitLab From 2bd9b11055c2ca5120a1ab94c3d6d94ee63c6215 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Fri, 13 Jul 2018 06:00:25 +0000 Subject: [PATCH 060/437] Fix tf.Print summarized format bug This fix fixes the issue raised in 20751 where tf.Print may miss `...` at the end with `summarize`. This fix fixes 20751 Signed-off-by: Yong Tang --- tensorflow/core/framework/tensor.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tensorflow/core/framework/tensor.cc b/tensorflow/core/framework/tensor.cc index 384a42fc11..c69658a0b0 100644 --- a/tensorflow/core/framework/tensor.cc +++ b/tensorflow/core/framework/tensor.cc @@ -915,7 +915,11 @@ void PrintOneDim(int dim_index, const gtl::InlinedVector& shape, // We have reached the right-most dimension of the tensor. if (dim_index == shape_size - 1) { for (int64 i = 0; i < element_count; i++) { - if (*data_index >= limit) return; + if (*data_index >= limit) { + // If not enough elements has been printed, append "...". + if (i < element_count) { strings::StrAppend(result, "..."); } + return; + } if (i > 0) strings::StrAppend(result, " "); strings::StrAppend(result, PrintOneElement(data[(*data_index)++])); } @@ -933,6 +937,10 @@ void PrintOneDim(int dim_index, const gtl::InlinedVector& shape, result); if (*data_index < limit || flag) { strings::StrAppend(result, "]"); + if (*data_index >= limit) { + // If not enough elements has been printed in this dim, append "...". + strings::StrAppend(result, "..."); + } flag = false; } } -- GitLab From 5fdb6643ae2b068798922bf96bbf2894e5576aed Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Fri, 13 Jul 2018 06:04:03 +0000 Subject: [PATCH 061/437] Format tensor.cc with clang-foramt Signed-off-by: Yong Tang --- tensorflow/core/framework/tensor.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tensorflow/core/framework/tensor.cc b/tensorflow/core/framework/tensor.cc index c69658a0b0..c7554482aa 100644 --- a/tensorflow/core/framework/tensor.cc +++ b/tensorflow/core/framework/tensor.cc @@ -917,7 +917,9 @@ void PrintOneDim(int dim_index, const gtl::InlinedVector& shape, for (int64 i = 0; i < element_count; i++) { if (*data_index >= limit) { // If not enough elements has been printed, append "...". - if (i < element_count) { strings::StrAppend(result, "..."); } + if (i < element_count) { + strings::StrAppend(result, "..."); + } return; } if (i > 0) strings::StrAppend(result, " "); -- GitLab From 771a8060e8eea386d75ace3d08794f3b967db564 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Fri, 13 Jul 2018 06:04:32 +0000 Subject: [PATCH 062/437] Remove extra `...` from the tf.Print Signed-off-by: Yong Tang --- tensorflow/core/framework/tensor.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/tensorflow/core/framework/tensor.cc b/tensorflow/core/framework/tensor.cc index c7554482aa..c7cf17d6f8 100644 --- a/tensorflow/core/framework/tensor.cc +++ b/tensorflow/core/framework/tensor.cc @@ -967,7 +967,6 @@ string SummarizeArray(int64 limit, int64 num_elts, const int shape_size = tensor_shape.dims(); PrintOneDim(0, shape, limit, shape_size, array, &data_index, &ret); - if (num_elts > limit) strings::StrAppend(&ret, "..."); return ret; } } // namespace -- GitLab From 8a5c6c4c305905a206065b0f5fa9a86c03876428 Mon Sep 17 00:00:00 2001 From: "William D. Irons" Date: Fri, 13 Jul 2018 15:13:03 -0500 Subject: [PATCH 063/437] Patch boringssl for ppc64le This commit adds a patch file for the bazel BUILD file contained in the boringssl.tar.gz file. It set the necessary compile options to build boringssl on pp64le. (Basically adds linux_ppc64le everywhere linux_x86_64 is) Fixes #20677 --- tensorflow/workspace.bzl | 1 + .../boringssl_build_file_ppc64le.patch | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 third_party/boringssl/boringssl_build_file_ppc64le.patch diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl index ed654c3285..d37139b621 100644 --- a/tensorflow/workspace.bzl +++ b/tensorflow/workspace.bzl @@ -510,6 +510,7 @@ def tf_workspace(path_prefix="", tf_repo_name=""): ], sha256 = "524ba98a56300149696481b4cb9ddebd0c7b7ac9b9f6edee81da2d2d7e5d2bb3", strip_prefix = "boringssl-a0fb951d2a26a8ee746b52f3ba81ab011a0af778", + patch_file = clean_dep("//third_party/boringssl:boringssl_build_file_ppc64le.patch"), ) tf_http_archive( diff --git a/third_party/boringssl/boringssl_build_file_ppc64le.patch b/third_party/boringssl/boringssl_build_file_ppc64le.patch new file mode 100644 index 0000000000..2e6cb40fed --- /dev/null +++ b/third_party/boringssl/boringssl_build_file_ppc64le.patch @@ -0,0 +1,53 @@ +--- a/BUILD 2017-10-17 21:30:48.000000000 +0000 ++++ b/BUILD 2018-01-09 12:40:36.264153992 +0000 +@@ -23,6 +23,7 @@ + "crypto_sources", + "crypto_sources_linux_x86_64", + "crypto_sources_mac_x86_64", ++ "crypto_sources_linux_ppc64le", + "fips_fragments", + "ssl_headers", + "ssl_internal_headers", +@@ -46,6 +47,11 @@ + values = {"cpu": "x64_windows"}, + ) + ++config_setting( ++ name = "linux_ppc64le", ++ values = {"cpu": "ppc"}, ++) ++ + posix_copts = [ + # Assembler option --noexecstack adds .note.GNU-stack to each object to + # ensure that binaries can be built with non-executable stack. +@@ -77,12 +83,14 @@ + "-DWIN32_LEAN_AND_MEAN", + "-DOPENSSL_NO_ASM", + ], ++ ":linux_ppc64le": posix_copts, + "//conditions:default": ["-DOPENSSL_NO_ASM"], + }) + + crypto_sources_asm = select({ + ":linux_x86_64": crypto_sources_linux_x86_64, + ":mac_x86_64": crypto_sources_mac_x86_64, ++ ":linux_ppc64le": crypto_sources_linux_ppc64le, + "//conditions:default": [], + }) + +@@ -97,6 +105,7 @@ + boringssl_copts_c11 = boringssl_copts + select({ + ":linux_x86_64": posix_copts_c11, + ":mac_x86_64": posix_copts_c11, ++ ":linux_ppc64le": posix_copts_c11, + "//conditions:default": [], + }) + +@@ -110,6 +119,7 @@ + ":linux_x86_64": posix_copts_cxx, + ":mac_x86_64": posix_copts_cxx, + "//conditions:default": [], ++ ":linux_ppc64le": posix_copts_cxx, + }) + + cc_library( -- GitLab From 0e5721ed066f5a1bfda82bc94ff980e821110e6a Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Fri, 13 Jul 2018 23:03:13 +0000 Subject: [PATCH 064/437] Fix build breaks Signed-off-by: Yong Tang --- tensorflow/core/framework/tensor.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tensorflow/core/framework/tensor.cc b/tensorflow/core/framework/tensor.cc index c7cf17d6f8..5ae737306a 100644 --- a/tensorflow/core/framework/tensor.cc +++ b/tensorflow/core/framework/tensor.cc @@ -917,7 +917,7 @@ void PrintOneDim(int dim_index, const gtl::InlinedVector& shape, for (int64 i = 0; i < element_count; i++) { if (*data_index >= limit) { // If not enough elements has been printed, append "...". - if (i < element_count) { + if (dim_index != 0 && i < element_count) { strings::StrAppend(result, "..."); } return; @@ -939,10 +939,6 @@ void PrintOneDim(int dim_index, const gtl::InlinedVector& shape, result); if (*data_index < limit || flag) { strings::StrAppend(result, "]"); - if (*data_index >= limit) { - // If not enough elements has been printed in this dim, append "...". - strings::StrAppend(result, "..."); - } flag = false; } } @@ -967,6 +963,7 @@ string SummarizeArray(int64 limit, int64 num_elts, const int shape_size = tensor_shape.dims(); PrintOneDim(0, shape, limit, shape_size, array, &data_index, &ret); + if (num_elts > limit) strings::StrAppend(&ret, "..."); return ret; } } // namespace -- GitLab From 20625cf7ab03c2fd749bb3738520251458c37fd6 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Fri, 13 Jul 2018 23:04:13 +0000 Subject: [PATCH 065/437] Add test case Signed-off-by: Yong Tang --- tensorflow/core/framework/tensor_test.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tensorflow/core/framework/tensor_test.cc b/tensorflow/core/framework/tensor_test.cc index 80e168df97..659685482d 100644 --- a/tensorflow/core/framework/tensor_test.cc +++ b/tensorflow/core/framework/tensor_test.cc @@ -1260,6 +1260,12 @@ TEST(SummarizeValue, INT32) { EXPECT_EQ("", x.SummarizeValue(16)); } +TEST(SummarizeValue, INT32Dims) { + Tensor x = MkTensor(DT_INT32, TensorShape({3, 4}), {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}); + EXPECT_EQ("[1 2 3...]...", x.SummarizeValue(3)); + EXPECT_EQ("[1 2 3 4][5 6 7 8][9 10...]...", x.SummarizeValue(10)); +} + TEST(SummarizeValue, FLOAT) { Tensor x = MkTensor(DT_FLOAT, TensorShape({5}), {1, 2, 3, 4, 0}); EXPECT_EQ("1 2 3 4 0", x.SummarizeValue(16)); -- GitLab From a6987f03ef621a28f8260df5849f0f8e3ea18f29 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Fri, 13 Jul 2018 23:04:37 +0000 Subject: [PATCH 066/437] Format with clang-format -i --style=Google Signed-off-by: Yong Tang --- tensorflow/core/framework/tensor_test.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tensorflow/core/framework/tensor_test.cc b/tensorflow/core/framework/tensor_test.cc index 659685482d..84a373c196 100644 --- a/tensorflow/core/framework/tensor_test.cc +++ b/tensorflow/core/framework/tensor_test.cc @@ -1261,7 +1261,8 @@ TEST(SummarizeValue, INT32) { } TEST(SummarizeValue, INT32Dims) { - Tensor x = MkTensor(DT_INT32, TensorShape({3, 4}), {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}); + Tensor x = MkTensor(DT_INT32, TensorShape({3, 4}), + {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}); EXPECT_EQ("[1 2 3...]...", x.SummarizeValue(3)); EXPECT_EQ("[1 2 3 4][5 6 7 8][9 10...]...", x.SummarizeValue(10)); } -- GitLab From 85aa9313c80cae2c1e9c9e7be7cab37ba3b20de3 Mon Sep 17 00:00:00 2001 From: "Li, Yiqiang" Date: Sun, 15 Jul 2018 22:29:55 +0800 Subject: [PATCH 067/437] Replace to call fast reorder path in MklBN op. --- .../core/kernels/mkl_fused_batch_norm_op.cc | 19 +++++++------------ tensorflow/core/util/mkl_util.h | 12 +++++++----- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc b/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc index 4ccb10a7cf..44268fc305 100644 --- a/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc +++ b/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc @@ -1297,19 +1297,17 @@ class MklFusedBatchNormOp : public OpKernel { MklFusedBatchNormFwdPrimitiveFactory::Get(fwdParams); // check if reorder is needed for src, weights, mean, variance - std::vector net; T* src_data = nullptr; if (src_md.data.format != bn_fwd->GetSrcFmt()) { src.SetUsrMem(src_md, &src_tensor); auto src_target = memory::primitive_desc({{src_dims}, MklDnnType(), static_cast(bn_fwd->GetSrcFmt())}, cpu_engine); - src.CheckReorderToOpMem(src_target, &net); + src.CheckReorderToOpMem(src_target); src_data = static_cast(src.GetOpMem().get_data_handle()); } else { src_data = static_cast( const_cast(src_tensor.flat().data())); } - stream(stream::kind::eager).submit(net).wait(); // allocate output (dst) tensor; always set it as MKL-DNN layout MklDnnShape dnn_shape_dst; @@ -1507,7 +1505,7 @@ class MklFusedBatchNormGradOp : public OpKernel { const Tensor& scale_tensor = MklGetInput(context, kScaleIndex); const Tensor& saved_mean_tensor = MklGetInput(context, kMeanIndex); const Tensor& saved_variance_tensor = - MklGetInput(context, kVarianceIndex); + MklGetInput(context, kVarianceIndex); MklDnnShape dnn_shape_src, dnn_shape_diff_dst; GetMklShape(context, kSrcIndex, &dnn_shape_src); @@ -1619,13 +1617,12 @@ class MklFusedBatchNormGradOp : public OpKernel { MklFusedBatchNormBwdPrimitiveFactory::Get(bwdParams); // check if src/diff_dst need to be reordered - std::vector net; T* src_data = nullptr; if (src_md.data.format != bn_bwd->GetSrcFmt()) { src.SetUsrMem(src_md, &src_tensor); auto src_target = memory::primitive_desc({{src_dims}, MklDnnType(), static_cast(bn_bwd->GetSrcFmt())}, cpu_engine); - src.CheckReorderToOpMem(src_target, &net); + src.CheckReorderToOpMem(src_target); src_data = static_cast(src.GetOpMem().get_data_handle()); } else { src_data = static_cast(const_cast( @@ -1638,14 +1635,13 @@ class MklFusedBatchNormGradOp : public OpKernel { auto diff_dst_target = memory::primitive_desc({{diff_dst_dims}, MklDnnType(), static_cast( bn_bwd->GetDiffDstFmt())}, cpu_engine); - diff_dst.CheckReorderToOpMem(diff_dst_target, &net); + diff_dst.CheckReorderToOpMem(diff_dst_target); diff_dst_data = static_cast( diff_dst.GetOpMem().get_data_handle()); } else { diff_dst_data = static_cast(const_cast( diff_dst_tensor.flat().data())); } - stream(stream::kind::eager).submit(net).wait(); // Indices of output tensors const size_t kDiffSrcIndex = 0; // index of diff_src tensor @@ -1657,10 +1653,9 @@ class MklFusedBatchNormGradOp : public OpKernel { auto diff_src_pd = bn_bwd->GetDiffSrcPd(); dnn_shape_diff_src.SetMklLayout(&diff_src_pd); dnn_shape_diff_src.SetElemType(MklDnnType()); - dnn_shape_diff_src.SetTfLayout(dnn_shape_src.GetDimension(), src_dims, + dnn_shape_diff_src.SetTfLayout(src_dims.size(), src_dims, format_m); - dnn_shape_diff_src.SetTfDimOrder(dnn_shape_src.GetDimension(), - tensor_format_); + dnn_shape_diff_src.SetTfDimOrder(src_dims.size(), tensor_format_); tf_shape_diff_src.AddDim(diff_src_pd.get_size() / sizeof(T)); AllocateOutputSetMklShape(context, kDiffSrcIndex, &diff_src_tensor, tf_shape_diff_src, dnn_shape_diff_src); @@ -1692,7 +1687,7 @@ class MklFusedBatchNormGradOp : public OpKernel { reinterpret_cast(diff_weights_data), depth_ * sizeof(T)); std::memcpy(reinterpret_cast(diff_shift_data), - reinterpret_cast(diff_weights_data) + depth_, + reinterpret_cast(diff_weights_data + depth_), depth_ * sizeof(T)); } catch (mkldnn::error& e) { string error_msg = "Status: " + std::to_string(e.status) + diff --git a/tensorflow/core/util/mkl_util.h b/tensorflow/core/util/mkl_util.h index efba2d8941..9967fead20 100644 --- a/tensorflow/core/util/mkl_util.h +++ b/tensorflow/core/util/mkl_util.h @@ -1907,8 +1907,9 @@ class MklPrimitiveFactory { ~MklPrimitiveFactory() {} MklPrimitive* GetOp(const std::string& key) { - auto stream_iter = MklPrimitiveFactory::GetHashMap().find(key); - if (stream_iter == MklPrimitiveFactory::GetHashMap().end()) { + auto &map = MklPrimitiveFactory::GetHashMap(); + auto stream_iter = map.find(key); + if (stream_iter == map.end()) { return nullptr; } else { return stream_iter->second; @@ -1916,11 +1917,12 @@ class MklPrimitiveFactory { } void SetOp(const std::string& key, MklPrimitive* op) { - auto stream_iter = MklPrimitiveFactory::GetHashMap().find(key); + auto &map = MklPrimitiveFactory::GetHashMap(); + auto stream_iter = map.find(key); - CHECK(stream_iter == MklPrimitiveFactory::GetHashMap().end()); + CHECK(stream_iter == map.end()); - MklPrimitiveFactory::GetHashMap()[key] = op; + map[key] = op; } private: -- GitLab From 578da8225cc558c495cb45be383421e7b4201b42 Mon Sep 17 00:00:00 2001 From: "William D. Irons" Date: Mon, 16 Jul 2018 17:04:21 -0500 Subject: [PATCH 068/437] Update boringssl dependency for ppc64le/gcc 4.8.5 build failure In booringssl PR: https://boringssl-review.googlesource.com/c/boringssl/+/29784 The bazel build file was updated to build ppc64le with the same compile options as linux_x86_64. This commit updates boringssl to reference that commit. --- tensorflow/workspace.bzl | 9 ++-- .../boringssl_build_file_ppc64le.patch | 53 ------------------- 2 files changed, 4 insertions(+), 58 deletions(-) delete mode 100644 third_party/boringssl/boringssl_build_file_ppc64le.patch diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl index d37139b621..cc0251fd46 100644 --- a/tensorflow/workspace.bzl +++ b/tensorflow/workspace.bzl @@ -505,12 +505,11 @@ def tf_workspace(path_prefix="", tf_repo_name=""): tf_http_archive( name = "boringssl", urls = [ - "https://mirror.bazel.build/github.com/google/boringssl/archive/a0fb951d2a26a8ee746b52f3ba81ab011a0af778.tar.gz", - "https://github.com/google/boringssl/archive/a0fb951d2a26a8ee746b52f3ba81ab011a0af778.tar.gz", + "https://mirror.bazel.build/github.com/google/boringssl/archive/45c4a87ae97eb95a8fc2906c035d6a8d0e02e1b8.tar.gz", + "https://github.com/google/boringssl/archive/45c4a87ae97eb95a8fc2906c035d6a8d0e02e1b8.tar.gz", ], - sha256 = "524ba98a56300149696481b4cb9ddebd0c7b7ac9b9f6edee81da2d2d7e5d2bb3", - strip_prefix = "boringssl-a0fb951d2a26a8ee746b52f3ba81ab011a0af778", - patch_file = clean_dep("//third_party/boringssl:boringssl_build_file_ppc64le.patch"), + sha256 = "972e8d8a9d1daf9892fff7155312b1af46b4754446575a7b285e62f917424c78", + strip_prefix = "boringssl-45c4a87ae97eb95a8fc2906c035d6a8d0e02e1b8", ) tf_http_archive( diff --git a/third_party/boringssl/boringssl_build_file_ppc64le.patch b/third_party/boringssl/boringssl_build_file_ppc64le.patch deleted file mode 100644 index 2e6cb40fed..0000000000 --- a/third_party/boringssl/boringssl_build_file_ppc64le.patch +++ /dev/null @@ -1,53 +0,0 @@ ---- a/BUILD 2017-10-17 21:30:48.000000000 +0000 -+++ b/BUILD 2018-01-09 12:40:36.264153992 +0000 -@@ -23,6 +23,7 @@ - "crypto_sources", - "crypto_sources_linux_x86_64", - "crypto_sources_mac_x86_64", -+ "crypto_sources_linux_ppc64le", - "fips_fragments", - "ssl_headers", - "ssl_internal_headers", -@@ -46,6 +47,11 @@ - values = {"cpu": "x64_windows"}, - ) - -+config_setting( -+ name = "linux_ppc64le", -+ values = {"cpu": "ppc"}, -+) -+ - posix_copts = [ - # Assembler option --noexecstack adds .note.GNU-stack to each object to - # ensure that binaries can be built with non-executable stack. -@@ -77,12 +83,14 @@ - "-DWIN32_LEAN_AND_MEAN", - "-DOPENSSL_NO_ASM", - ], -+ ":linux_ppc64le": posix_copts, - "//conditions:default": ["-DOPENSSL_NO_ASM"], - }) - - crypto_sources_asm = select({ - ":linux_x86_64": crypto_sources_linux_x86_64, - ":mac_x86_64": crypto_sources_mac_x86_64, -+ ":linux_ppc64le": crypto_sources_linux_ppc64le, - "//conditions:default": [], - }) - -@@ -97,6 +105,7 @@ - boringssl_copts_c11 = boringssl_copts + select({ - ":linux_x86_64": posix_copts_c11, - ":mac_x86_64": posix_copts_c11, -+ ":linux_ppc64le": posix_copts_c11, - "//conditions:default": [], - }) - -@@ -110,6 +119,7 @@ - ":linux_x86_64": posix_copts_cxx, - ":mac_x86_64": posix_copts_cxx, - "//conditions:default": [], -+ ":linux_ppc64le": posix_copts_cxx, - }) - - cc_library( -- GitLab From e5379bb6c053c1d1af913cd1c8c14663191e58b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Horst=20H=C3=BCnnemeyer?= Date: Tue, 17 Jul 2018 09:53:19 +0200 Subject: [PATCH 069/437] pylint: whitespace changes --- tensorflow/contrib/distribute/python/mirrored_strategy.py | 2 +- tensorflow/python/framework/errors_impl.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow/contrib/distribute/python/mirrored_strategy.py b/tensorflow/contrib/distribute/python/mirrored_strategy.py index cdb505d95d..8092d8efe0 100644 --- a/tensorflow/contrib/distribute/python/mirrored_strategy.py +++ b/tensorflow/contrib/distribute/python/mirrored_strategy.py @@ -87,7 +87,7 @@ class MirroredStrategy(distribute_lib.DistributionStrategy): self._devices = [device_util.resolve(d) for d in devices] self._canonical_device_set = set(self._devices) self._device_index = values.PerDevice( - {d: i for i, d in enumerate(devices)}) + {d: i for i, d in enumerate(devices)}) self._cross_tower_ops = cross_tower_ops self._prefetch_on_device = prefetch_on_device # TODO(yuefengz): consider setting the default device. diff --git a/tensorflow/python/framework/errors_impl.py b/tensorflow/python/framework/errors_impl.py index c2521fdc00..a74a295870 100644 --- a/tensorflow/python/framework/errors_impl.py +++ b/tensorflow/python/framework/errors_impl.py @@ -476,7 +476,7 @@ _CODE_TO_EXCEPTION_CLASS = { c_api.PyExceptionRegistry_Init(_CODE_TO_EXCEPTION_CLASS) _EXCEPTION_CLASS_TO_CODE = { - class_: code for code, class_ in _CODE_TO_EXCEPTION_CLASS.items()} + class_: code for code, class_ in _CODE_TO_EXCEPTION_CLASS.items()} @tf_export("errors.exception_type_from_error_code") -- GitLab From 99a1fa450eda5d292cb1673b104144216c9c3694 Mon Sep 17 00:00:00 2001 From: Eliel Hojman Date: Tue, 17 Jul 2018 13:32:17 +0300 Subject: [PATCH 070/437] Small typo fix --- tensorflow/python/data/ops/iterator_ops.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/python/data/ops/iterator_ops.py b/tensorflow/python/data/ops/iterator_ops.py index 35de2f2841..659b92a140 100644 --- a/tensorflow/python/data/ops/iterator_ops.py +++ b/tensorflow/python/data/ops/iterator_ops.py @@ -211,7 +211,7 @@ class Iterator(object): This method allows you to define a "feedable" iterator where you can choose between concrete iterators by feeding a value in a @{tf.Session.run} call. - In that case, `string_handle` would a @{tf.placeholder}, and you would feed + In that case, `string_handle` would be a @{tf.placeholder}, and you would feed it with the value of @{tf.data.Iterator.string_handle} in each step. For example, if you had two iterators that marked the current position in -- GitLab From b28b82052525517beff238d2c53bde0171a4a59f Mon Sep 17 00:00:00 2001 From: Yoshihiro Yamazaki Date: Wed, 18 Jul 2018 00:00:29 +0900 Subject: [PATCH 071/437] - adding PNG-8(palette) files. convert lena_std.png -scale '51x26!' png8:lena_palette.png convert lena_rgba.png png8:lena_palette_trns.png - update python test script - update core/BUILD file --- tensorflow/core/BUILD | 2 ++ .../core/lib/png/testdata/lena_palette.png | Bin 0 -> 1368 bytes .../core/lib/png/testdata/lena_palette_trns.png | Bin 0 -> 1368 bytes tensorflow/python/ops/image_ops_test.py | 2 +- 4 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 tensorflow/core/lib/png/testdata/lena_palette.png create mode 100644 tensorflow/core/lib/png/testdata/lena_palette_trns.png diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD index b6b48a077c..f79e2526a9 100644 --- a/tensorflow/core/BUILD +++ b/tensorflow/core/BUILD @@ -4456,6 +4456,8 @@ filegroup( # PNG data "lib/png/testdata/lena_gray.png", "lib/png/testdata/lena_rgba.png", + "lib/png/testdata/lena_palette.png", + "lib/png/testdata/lena_palette_trns.png", # JPEG data "lib/jpeg/testdata/jpeg_merge_test1.jpg", "lib/jpeg/testdata/jpeg_merge_test1_cmyk.jpg", diff --git a/tensorflow/core/lib/png/testdata/lena_palette.png b/tensorflow/core/lib/png/testdata/lena_palette.png new file mode 100644 index 0000000000000000000000000000000000000000..c298fee9fffdbd0b1848001b407cc2cbb1c7af83 GIT binary patch literal 1368 zcmeAS@N?(olHy`uVBq!ia0y~yU@&H2V36WqW?*2@y))$*0|Ns~x}&cn1H;CC?mvmF z3=9kk$sR$z3=CCj3=9n|3=F>*7#JE}Fff!FFfhDIU|_JC!N4G1FlSew4FdyXRe(>3 z>;M1%&xD4aNeexbmUbqs{7iZInU0R#p`p87LU)Iz?M_QOGqdCFs+o6puew{Fb~i2U zOh@_MnKSRMT6Oo#?ssQ)-`%}?cSpx6m(W$lF7L|IW*WPk2~E2@vtw0STAHBoOykhI z9p&$4c9bi*gbEs`3A*fdaaomCerDCGcX!Y1o;h=si_5#2<#)@=?{;*|Oeq}|;;b7pATyNDRg&v`Kr*+ znJ#JXIy%Z-%0od8bJ?9%Uan+3)1~}wdBmx4V3mOIn(7d76^( z-O$i?<>l{Y&V0AKBc! zh{fr>Q(i|;PLMd}`otjRfJn2U8;5?Bu*%)rmu5`dkQp3&=h`gY^kr#Q);ACK{jYw1 z?O^4JKNqh4oq50X{`tRl{I<6LJtCs_-gvtIc;TLY1NwjanuT5LPak`% zbMk^oZ?VkzVsSwc*P|2qCrEVg^L06gt4R76O*&L;Q@&2IH_^m(X@G^3tC@52B8_90 zBaAdN!@nlpF*qoBWRYdpGJ_)=TBkQLcR0m4s~k5}Ui@h5Yc&hrRGn_A!x>Vg4mbK{ zd8i0n3zNBc!e7SR_kqyej!7p^T*5al`n6{*}Xs8lk#36#Y9`6hu`-Bcc0%sw|8kGlC6h}H*X9%!@I|zB{9+F z_PkXd=gta$=kdMl)w0U!oPJ8q!net~K~?!)TuuUQ-WT@HPYo^IsUfy>Y9=p(aR-aa zrr8s9O#ZEkj^kuxN$d>yt-NggrkI#8)d$i72ew?eXqbF*+8(bXO`_|6FI&1F{d#VSOUa$v zO{%_YMW@Y5S!O;L3=NAJ(+)@JPbar0v4 z8RVG7@10kW=-d1?EN$X*=|9rd!q*-o-hF>YUiQsC+pUY=uX=AUbGDv^A>&q9?7@QD zD{rWBJWM>TssX$#~zlLet)`p2cx87*T0%OXVdIV9J(iM^ke^Ja7%9E^Yunsce$ol{JZVCzw!UV z_uB+33UcFZZZI$~sFt`!l%yncTId>>>l&Je7#dp{7+INGY8zNu z85opH&j95cgofPwl+3hBs0K4#Lz56ALn~7YD?>Agh7W4TL>L$t7(8A5T-G@yGywpn C4p@)? literal 0 HcmV?d00001 diff --git a/tensorflow/core/lib/png/testdata/lena_palette_trns.png b/tensorflow/core/lib/png/testdata/lena_palette_trns.png new file mode 100644 index 0000000000000000000000000000000000000000..c298fee9fffdbd0b1848001b407cc2cbb1c7af83 GIT binary patch literal 1368 zcmeAS@N?(olHy`uVBq!ia0y~yU@&H2V36WqW?*2@y))$*0|Ns~x}&cn1H;CC?mvmF z3=9kk$sR$z3=CCj3=9n|3=F>*7#JE}Fff!FFfhDIU|_JC!N4G1FlSew4FdyXRe(>3 z>;M1%&xD4aNeexbmUbqs{7iZInU0R#p`p87LU)Iz?M_QOGqdCFs+o6puew{Fb~i2U zOh@_MnKSRMT6Oo#?ssQ)-`%}?cSpx6m(W$lF7L|IW*WPk2~E2@vtw0STAHBoOykhI z9p&$4c9bi*gbEs`3A*fdaaomCerDCGcX!Y1o;h=si_5#2<#)@=?{;*|Oeq}|;;b7pATyNDRg&v`Kr*+ znJ#JXIy%Z-%0od8bJ?9%Uan+3)1~}wdBmx4V3mOIn(7d76^( z-O$i?<>l{Y&V0AKBc! zh{fr>Q(i|;PLMd}`otjRfJn2U8;5?Bu*%)rmu5`dkQp3&=h`gY^kr#Q);ACK{jYw1 z?O^4JKNqh4oq50X{`tRl{I<6LJtCs_-gvtIc;TLY1NwjanuT5LPak`% zbMk^oZ?VkzVsSwc*P|2qCrEVg^L06gt4R76O*&L;Q@&2IH_^m(X@G^3tC@52B8_90 zBaAdN!@nlpF*qoBWRYdpGJ_)=TBkQLcR0m4s~k5}Ui@h5Yc&hrRGn_A!x>Vg4mbK{ zd8i0n3zNBc!e7SR_kqyej!7p^T*5al`n6{*}Xs8lk#36#Y9`6hu`-Bcc0%sw|8kGlC6h}H*X9%!@I|zB{9+F z_PkXd=gta$=kdMl)w0U!oPJ8q!net~K~?!)TuuUQ-WT@HPYo^IsUfy>Y9=p(aR-aa zrr8s9O#ZEkj^kuxN$d>yt-NggrkI#8)d$i72ew?eXqbF*+8(bXO`_|6FI&1F{d#VSOUa$v zO{%_YMW@Y5S!O;L3=NAJ(+)@JPbar0v4 z8RVG7@10kW=-d1?EN$X*=|9rd!q*-o-hF>YUiQsC+pUY=uX=AUbGDv^A>&q9?7@QD zD{rWBJWM>TssX$#~zlLet)`p2cx87*T0%OXVdIV9J(iM^ke^Ja7%9E^Yunsce$ol{JZVCzw!UV z_uB+33UcFZZZI$~sFt`!l%yncTId>>>l&Je7#dp{7+INGY8zNu z85opH&j95cgofPwl+3hBs0K4#Lz56ALn~7YD?>Agh7W4TL>L$t7(8A5T-G@yGywpn C4p@)? literal 0 HcmV?d00001 diff --git a/tensorflow/python/ops/image_ops_test.py b/tensorflow/python/ops/image_ops_test.py index 2a6ab26e96..70f52f1c66 100644 --- a/tensorflow/python/ops/image_ops_test.py +++ b/tensorflow/python/ops/image_ops_test.py @@ -3105,7 +3105,7 @@ class PngTest(test_util.TensorFlowTestCase): def testExisting(self): # Read some real PNGs, converting to different channel numbers prefix = "tensorflow/core/lib/png/testdata/" - inputs = (1, "lena_gray.png"), (4, "lena_rgba.png") + inputs = (1, "lena_gray.png"), (4, "lena_rgba.png"), (3, "lena_palette.png"), (4, "lena_palette_trns.png") for channels_in, filename in inputs: for channels in 0, 1, 3, 4: with self.test_session(use_gpu=True) as sess: -- GitLab From 1f31116a081afbf6794c5247a0b3b8ac120896b0 Mon Sep 17 00:00:00 2001 From: Yoshihiro Yamazaki Date: Wed, 18 Jul 2018 00:56:08 +0900 Subject: [PATCH 072/437] fixing to coding style, too long line. --- tensorflow/python/ops/image_ops_test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tensorflow/python/ops/image_ops_test.py b/tensorflow/python/ops/image_ops_test.py index 70f52f1c66..301b4a6045 100644 --- a/tensorflow/python/ops/image_ops_test.py +++ b/tensorflow/python/ops/image_ops_test.py @@ -3105,7 +3105,8 @@ class PngTest(test_util.TensorFlowTestCase): def testExisting(self): # Read some real PNGs, converting to different channel numbers prefix = "tensorflow/core/lib/png/testdata/" - inputs = (1, "lena_gray.png"), (4, "lena_rgba.png"), (3, "lena_palette.png"), (4, "lena_palette_trns.png") + inputs = ((1, "lena_gray.png"), (4, "lena_rgba.png"), + (3, "lena_palette.png"), (4, "lena_palette_trns.png")) for channels_in, filename in inputs: for channels in 0, 1, 3, 4: with self.test_session(use_gpu=True) as sess: -- GitLab From b462815ccc279c79a5592a0a2d4492718da02c5d Mon Sep 17 00:00:00 2001 From: KB Sriram Date: Wed, 18 Jul 2018 08:31:46 -0700 Subject: [PATCH 073/437] Add gradient for tensorflow::ops::Fill See https://github.com/tensorflow/tensorflow/issues/20926 --- tensorflow/cc/gradients/array_grad.cc | 18 ++++++++++++++++++ tensorflow/cc/gradients/array_grad_test.cc | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/tensorflow/cc/gradients/array_grad.cc b/tensorflow/cc/gradients/array_grad.cc index b353accddc..e9173227aa 100644 --- a/tensorflow/cc/gradients/array_grad.cc +++ b/tensorflow/cc/gradients/array_grad.cc @@ -120,6 +120,24 @@ Status SplitGrad(const Scope& scope, const Operation& op, } REGISTER_GRADIENT_OP("Split", SplitGrad); +Status FillGrad(const Scope& scope, const Operation& op, + const std::vector& grad_inputs, + std::vector* grad_outputs) { + // y = fill(fill_shape, x) + // No gradient returned for the fill_shape argument. + grad_outputs->push_back(NoGradient()); + // The gradient for x (which must be a scalar) is just the sum of + // all the gradients from the shape it fills. + // We use ReduceSum to implement this, which needs an argument providing + // the indices of all the dimensions of the incoming gradient. + // grad(x) = reduce_sum(grad(y), [0..rank(grad(y))]) + auto all_dims = Range(scope, Const(scope, 0), Rank(scope, grad_inputs[0]), + Const(scope, 1)); + grad_outputs->push_back(ReduceSum(scope, grad_inputs[0], all_dims)); + return scope.status(); +} +REGISTER_GRADIENT_OP("Fill", FillGrad); + Status DiagGrad(const Scope& scope, const Operation& op, const std::vector& grad_inputs, std::vector* grad_outputs) { diff --git a/tensorflow/cc/gradients/array_grad_test.cc b/tensorflow/cc/gradients/array_grad_test.cc index d09275b648..f41de3dc20 100644 --- a/tensorflow/cc/gradients/array_grad_test.cc +++ b/tensorflow/cc/gradients/array_grad_test.cc @@ -108,6 +108,14 @@ TEST_F(ArrayGradTest, SplitGrad) { RunTest({x}, {x_shape}, y.output, {y_shape, y_shape}); } +TEST_F(ArrayGradTest, FillGrad) { + TensorShape x_shape({}); + auto x = Placeholder(scope_, DT_FLOAT, Placeholder::Shape(x_shape)); + TensorShape y_shape({2, 5, 3}); + auto y = Fill(scope_, {2, 5, 3}, x); + RunTest(x, x_shape, y, y_shape); +} + TEST_F(ArrayGradTest, DiagGrad) { TensorShape x_shape({5, 2}); auto x = Placeholder(scope_, DT_FLOAT, Placeholder::Shape(x_shape)); -- GitLab From 8ac782c2e1088bc236b477ac0a07f1b318dcce7c Mon Sep 17 00:00:00 2001 From: DavidNorman Date: Wed, 23 May 2018 11:11:15 +0100 Subject: [PATCH 074/437] Disable tests which do a windowed reduction on a scalar sized window --- .../compiler/xla/tests/reduce_window_test.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tensorflow/compiler/xla/tests/reduce_window_test.cc b/tensorflow/compiler/xla/tests/reduce_window_test.cc index c2681f70f7..5408ba0a53 100644 --- a/tensorflow/compiler/xla/tests/reduce_window_test.cc +++ b/tensorflow/compiler/xla/tests/reduce_window_test.cc @@ -1341,7 +1341,7 @@ INSTANTIATE_TEST_CASE_P( // results on the interpreter backend. class ReduceWindowTextTest : public HloTestBase {}; -TEST_F(ReduceWindowTextTest, R2General256x384) { +XLA_TEST_F(ReduceWindowTextTest, R2General256x384) { const string hlo_string = R"( HloModule R2Window mul { @@ -1358,7 +1358,7 @@ ENTRY R2Window { EXPECT_TRUE(RunAndCompare(hlo_string, ErrorSpec{0.001})); } -TEST_F(ReduceWindowTextTest, R2General256x384Layout01) { +XLA_TEST_F(ReduceWindowTextTest, R2General256x384Layout01) { const string hlo_string = R"( HloModule R2Window mul { @@ -1375,7 +1375,7 @@ ROOT reduce-window = f32[256,384]{0,1} reduce-window(operand, constant), window= EXPECT_TRUE(RunAndCompare(hlo_string, ErrorSpec{0.001})); } -TEST_F(ReduceWindowTextTest, R2General2x5) { +XLA_TEST_F(ReduceWindowTextTest, R2General2x5) { const string hlo_string = R"( HloModule R2Window mul { @@ -1392,7 +1392,7 @@ ENTRY R2Window { EXPECT_TRUE(RunAndCompare(hlo_string, ErrorSpec{0.001})); } -TEST_F(ReduceWindowTextTest, R2EffectiveScalar) { +XLA_TEST_F(ReduceWindowTextTest, R2EffectiveScalar) { const string hlo_string = R"( HloModule R2Window mul { @@ -1410,7 +1410,7 @@ ENTRY R2Window { EXPECT_TRUE(RunAndCompare(hlo_string, ErrorSpec{0.001})); } -TEST_F(ReduceWindowTextTest, R3EffectiveScalar) { +XLA_TEST_F(ReduceWindowTextTest, R3EffectiveScalar) { const string hlo_string = R"( HloModule R3Window mul { @@ -1428,7 +1428,7 @@ ENTRY R3Window { EXPECT_TRUE(RunAndCompare(hlo_string, ErrorSpec{0.001})); } -TEST_F(HloTestBase, ReduceWindowIdentity) { +XLA_TEST_F(HloTestBase, ReduceWindowIdentity) { const string hlo_string = R"( HloModule ReduceWindowIdentity identity.pad_to_reduce_window { @@ -1445,7 +1445,7 @@ ENTRY reduce-window-identity { EXPECT_TRUE(RunAndCompare(hlo_string, tensorflow::gtl::nullopt)); } -TEST_F(HloTestBase, ReduceWindowS32) { +XLA_TEST_F(HloTestBase, ReduceWindowS32) { const string hlo_string = R"( HloModule reduce-window -- GitLab From 9f1c2bf91ab32477e26cf31ad36a9ad87ca2ac09 Mon Sep 17 00:00:00 2001 From: Loo Rong Jie Date: Wed, 4 Jul 2018 09:05:38 +0800 Subject: [PATCH 075/437] [Bazel/MSVC] Enable png SIMD for MSVC --- third_party/png.BUILD | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/third_party/png.BUILD b/third_party/png.BUILD index 17c5449cc0..f129779653 100644 --- a/third_party/png.BUILD +++ b/third_party/png.BUILD @@ -29,6 +29,10 @@ cc_library( "pngwtran.c", "pngwutil.c", ] + select({ + ":windows": [ + "intel/intel_init.c", + "intel/filter_sse2_intrinsics.c", + ], "@org_tensorflow//tensorflow:linux_ppc64le": [ "powerpc/powerpc_init.c", "powerpc/filter_vsx_intrinsics.c", @@ -41,7 +45,14 @@ cc_library( "pngconf.h", ], includes = ["."], - linkopts = ["-lm"], + copts = select({ + ":windows": ["-DPNG_INTEL_SSE_OPT=1"], + "//conditions:default": [], + }), + linkopts = select({ + ":windows": [], + "//conditions:default": ["-lm"], + }), visibility = ["//visibility:public"], deps = ["@zlib_archive//:zlib"], ) @@ -52,3 +63,8 @@ genrule( outs = ["pnglibconf.h"], cmd = "sed -e 's/PNG_ZLIB_VERNUM 0/PNG_ZLIB_VERNUM 0x12b0/' $< >$@", ) + +config_setting( + name = "windows", + values = {"cpu": "x64_windows"}, +) \ No newline at end of file -- GitLab From 2737e9fdcf61e49b11646b75c7b714158d042855 Mon Sep 17 00:00:00 2001 From: Loo Rong Jie Date: Wed, 11 Jul 2018 20:02:41 +0800 Subject: [PATCH 076/437] Add new line --- third_party/png.BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/png.BUILD b/third_party/png.BUILD index f129779653..c26a289717 100644 --- a/third_party/png.BUILD +++ b/third_party/png.BUILD @@ -67,4 +67,4 @@ genrule( config_setting( name = "windows", values = {"cpu": "x64_windows"}, -) \ No newline at end of file +) -- GitLab From d4fc213ebbfef8a30113f7b0905138685bcb7592 Mon Sep 17 00:00:00 2001 From: Loo Rong Jie Date: Wed, 4 Jul 2018 11:33:45 +0800 Subject: [PATCH 077/437] [Bazel/MSVC] Make Kafka builds on Windows --- .../kafka/kernels/kafka_dataset_ops.cc | 2 +- third_party/kafka/BUILD | 36 +++++++++++++------ 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/tensorflow/contrib/kafka/kernels/kafka_dataset_ops.cc b/tensorflow/contrib/kafka/kernels/kafka_dataset_ops.cc index 2638b25ec4..588e456bd6 100644 --- a/tensorflow/contrib/kafka/kernels/kafka_dataset_ops.cc +++ b/tensorflow/contrib/kafka/kernels/kafka_dataset_ops.cc @@ -15,7 +15,7 @@ limitations under the License. #include "tensorflow/core/framework/dataset.h" -#include "src-cpp/rdkafkacpp.h" +#include "rdkafkacpp.h" namespace tensorflow { diff --git a/third_party/kafka/BUILD b/third_party/kafka/BUILD index 75792b0d87..7a60edb483 100644 --- a/third_party/kafka/BUILD +++ b/third_party/kafka/BUILD @@ -15,6 +15,7 @@ cc_library( "src-cpp/KafkaConsumerImpl.cpp", "src-cpp/MessageImpl.cpp", "src-cpp/MetadataImpl.cpp", + "src-cpp/ProducerImpl.cpp", "src-cpp/QueueImpl.cpp", "src-cpp/RdKafka.cpp", "src-cpp/TopicImpl.cpp", @@ -130,7 +131,15 @@ cc_library( "src/tinycthread.h", "src/xxhash.c", "src/xxhash.h", - ], + ] + select({ + "@org_tensorflow//tensorflow:windows": [ + "src/rdkafka_sasl_win32.c", + "src/rdwin32.h", + "src/regexp.c", + "src/regexp.h", + ], + "//conditions:default": [], + }), hdrs = [ "config.h", "src-cpp/rdkafkacpp.h", @@ -138,15 +147,22 @@ cc_library( "src/lz4.c", "src/snappy_compat.h", ], - copts = [ - "-Iexternal/kafka/src", - "-Iexternal/kafka/src-cpp", - ], - defines = [ - ], - linkopts = [ - "-lpthread", - ], + includes = ["src", "src-cpp"], + defines = ["LIBRDKAFKA_STATICLIB"], + copts = select({ + "@org_tensorflow//tensorflow:windows": [ + "-DWIN32_LEAN_AND_MEAN", + "-DWITHOUT_WIN32_CONFIG", + "-DWITH_ZLIB=1", + "-DWITH_SSL=1", + "-DWITH_SNAPPY=1", + ], + "//conditions:default": [], + }), + linkopts = select({ + "@org_tensorflow//tensorflow:windows": ["-defaultlib:crypt32.lib"], + "//conditions:default": ["-lpthread"], + }), visibility = ["//visibility:public"], deps = [ "@boringssl//:ssl", -- GitLab From a7fc3811dfbb75f14a9ece2d8904b72b8a45a670 Mon Sep 17 00:00:00 2001 From: Koan-Sin Tan Date: Fri, 20 Jul 2018 14:21:42 +0800 Subject: [PATCH 078/437] get output size from output tensor 1. get output size from the output tensor 2. add command line option to specify number of results --- .../lite/examples/label_image/label_image.cc | 19 +++++++++++++------ .../lite/examples/label_image/label_image.h | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tensorflow/contrib/lite/examples/label_image/label_image.cc b/tensorflow/contrib/lite/examples/label_image/label_image.cc index 86d7d1cc4a..7c6f523041 100644 --- a/tensorflow/contrib/lite/examples/label_image/label_image.cc +++ b/tensorflow/contrib/lite/examples/label_image/label_image.cc @@ -213,22 +213,23 @@ void RunInference(Settings* s) { } } - const int output_size = 1000; - const size_t num_results = 5; const float threshold = 0.001f; std::vector> top_results; int output = interpreter->outputs()[0]; + TfLiteIntArray* output_dims = interpreter->tensor(output)->dims; + // assume output dims to be something like (1, 1, ... ,size) + auto output_size = output_dims->data[output_dims->size - 1]; switch (interpreter->tensor(output)->type) { case kTfLiteFloat32: get_top_n(interpreter->typed_output_tensor(0), output_size, - num_results, threshold, &top_results, true); + s->number_of_results, threshold, &top_results, true); break; case kTfLiteUInt8: get_top_n(interpreter->typed_output_tensor(0), - output_size, num_results, threshold, &top_results, - false); + output_size, s->number_of_results, threshold, + &top_results, false); break; default: LOG(FATAL) << "cannot handle output type " @@ -259,6 +260,7 @@ void display_usage() { << "--labels, -l: labels for the model\n" << "--tflite_model, -m: model_name.tflite\n" << "--profiling, -p: [0|1], profiling or not\n" + << "--num_results, -r: number of results to show\n" << "--threads, -t: number of threads\n" << "--verbose, -v: [0|1] print more information\n" << "\n"; @@ -280,12 +282,13 @@ int Main(int argc, char** argv) { {"threads", required_argument, nullptr, 't'}, {"input_mean", required_argument, nullptr, 'b'}, {"input_std", required_argument, nullptr, 's'}, + {"num_results", required_argument, nullptr, 'r'}, {nullptr, 0, nullptr, 0}}; /* getopt_long stores the option index here. */ int option_index = 0; - c = getopt_long(argc, argv, "a:b:c:f:i:l:m:p:s:t:v:", long_options, + c = getopt_long(argc, argv, "a:b:c:f:i:l:m:p:r:s:t:v:", long_options, &option_index); /* Detect the end of the options. */ @@ -315,6 +318,10 @@ int Main(int argc, char** argv) { s.profiling = strtol(optarg, nullptr, 10); // NOLINT(runtime/deprecated_fn) break; + case 'r': + s.number_of_results = + strtol(optarg, nullptr, 10); // NOLINT(runtime/deprecated_fn) + break; case 's': s.input_std = strtod(optarg, nullptr); break; diff --git a/tensorflow/contrib/lite/examples/label_image/label_image.h b/tensorflow/contrib/lite/examples/label_image/label_image.h index 4b48014e1c..34c223f713 100644 --- a/tensorflow/contrib/lite/examples/label_image/label_image.h +++ b/tensorflow/contrib/lite/examples/label_image/label_image.h @@ -34,6 +34,7 @@ struct Settings { string labels_file_name = "./labels.txt"; string input_layer_type = "uint8_t"; int number_of_threads = 4; + int number_of_results = 5; }; } // namespace label_image -- GitLab From 828257c82a6dfc1537547d226b25b7e394ff3cd4 Mon Sep 17 00:00:00 2001 From: XFeiF Date: Sat, 21 Jul 2018 22:59:03 +0800 Subject: [PATCH 079/437] [tf.contrib.slim] Update documentation in evaluation.py --- .../contrib/slim/python/slim/evaluation.py | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/tensorflow/contrib/slim/python/slim/evaluation.py b/tensorflow/contrib/slim/python/slim/evaluation.py index 5cfd5ee82e..0feb3925eb 100644 --- a/tensorflow/contrib/slim/python/slim/evaluation.py +++ b/tensorflow/contrib/slim/python/slim/evaluation.py @@ -22,7 +22,8 @@ modules using a variety of metrics and summarizing the results. ********************** In the simplest use case, we use a model to create the predictions, then specify -the metrics and finally call the `evaluation` method: +the metrics and choose one model checkpoint, finally call the`evaluation_once` +method: # Create model and obtain the predictions: images, labels = LoadData(...) @@ -34,20 +35,24 @@ the metrics and finally call the `evaluation` method: "mse": slim.metrics.mean_squared_error(predictions, labels), }) + checkpoint_path = '/tmp/my_model_dir/my_checkpoint' + log_dir = '/tmp/my_model_eval/' + initial_op = tf.group( tf.global_variables_initializer(), tf.local_variables_initializer()) - with tf.Session() as sess: - metric_values = slim.evaluation( - sess, - num_evals=1, - initial_op=initial_op, - eval_op=names_to_updates.values(), - final_op=name_to_values.values()) + metric_values = slim.evaluate_once( + master='', + checkpoint_path=checkpoint_path, + log_dir=log_dir, + num_evals=1, + initial_op=initial_op, + eval_op=names_to_updates.values(), + final_op=name_to_values.values()) - for metric, value in zip(names_to_values.keys(), metric_values): - logging.info('Metric %s has value: %f', metric, value) + for metric, value in zip(names_to_values.keys(), metric_values): + logging.info('Metric %s has value: %f', metric, value) ************************************************ * Evaluating a Checkpointed Model with Metrics * -- GitLab From 7a43aad35a4f806cec9715fa394c48dae3abd42a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E5=B1=85?= Date: Sun, 22 Jul 2018 00:05:09 +0800 Subject: [PATCH 080/437] Fold BN after depthwise conv --- .../graph_transforms/fold_batch_norms.cc | 16 ++++++------ .../graph_transforms/fold_old_batch_norms.cc | 25 +++++++++---------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/tensorflow/tools/graph_transforms/fold_batch_norms.cc b/tensorflow/tools/graph_transforms/fold_batch_norms.cc index 975b17380f..42eebd98c9 100644 --- a/tensorflow/tools/graph_transforms/fold_batch_norms.cc +++ b/tensorflow/tools/graph_transforms/fold_batch_norms.cc @@ -38,7 +38,7 @@ Status FoldBatchNorms(const GraphDef& input_graph_def, input_graph_def, // clang-format off {"Mul", // mul_node { - {"Conv2D|MatMul", // conv_node + {"Conv2D|MatMul|DepthwiseConv2dNative", // conv_node { {"*"}, // input_node {"Const"}, // weights_node @@ -73,7 +73,7 @@ Status FoldBatchNorms(const GraphDef& input_graph_def, // Make sure all the inputs really are vectors, with as many entries as // there are columns in the weights. - const int weights_cols_index = conv_node.op() == "Conv2D" ? 3 : 1; + const int weights_cols_index = conv_node.op() == "Conv2D" ? 3 : (conv_node.op() == "DepthwiseConv2dNative" ? 2 : 1); const int64 weights_cols = weights.shape().dim_size(weights_cols_index); if ((mul_values.shape().dims() != 1) || (mul_values.shape().dim_size(0) != weights_cols)) { @@ -83,14 +83,12 @@ Status FoldBatchNorms(const GraphDef& input_graph_def, } // Multiply the original weights by the scale vector. - auto weights_matrix = weights.flat_inner_dims(); + auto weights_vector = weights.flat(); Tensor scaled_weights(DT_FLOAT, weights.shape()); - auto scaled_weights_matrix = scaled_weights.flat_inner_dims(); - for (int64 row = 0; row < weights_matrix.dimension(0); ++row) { - for (int64 col = 0; col < weights_cols; ++col) { - scaled_weights_matrix(row, col) = - weights_matrix(row, col) * mul_values.flat()(col); - } + auto scaled_weights_vector = scaled_weights.flat(); + for (int64 row = 0; row < weights_vector.dimension(0); ++row) { + scaled_weights_vector(row) = + weights_vector(row) * mul_values.flat()(row % weights_cols); } // Construct the new nodes. diff --git a/tensorflow/tools/graph_transforms/fold_old_batch_norms.cc b/tensorflow/tools/graph_transforms/fold_old_batch_norms.cc index f1d361e07d..1a4b141d0e 100644 --- a/tensorflow/tools/graph_transforms/fold_old_batch_norms.cc +++ b/tensorflow/tools/graph_transforms/fold_old_batch_norms.cc @@ -110,24 +110,23 @@ Status FuseScaleOffsetToConvWeights(const std::vector& scale_values, const string& conv_output_name, std::vector* new_nodes) { const NodeDef& conv_node = conv_node_match.node; - CHECK_EQ("Conv2D", conv_node.op()); + // CHECK_EQ("Conv2D", conv_node.op()); const NodeDef& input_node = conv_node_match.inputs[0].node; const NodeDef& weights_node = conv_node_match.inputs[1].node; CHECK_EQ("Const", weights_node.op()); Tensor weights = GetNodeTensorAttr(weights_node, "value"); - const int64 weights_cols = weights.shape().dim_size(3); + const int weights_cols_idx = conv_node.op() == "Conv2D" ? 3 : 2; + const int64 weights_cols = weights.shape().dim_size(weights_cols_idx); CHECK_EQ(weights_cols, scale_values.size()); // Multiply the original weights by the scale vector. - auto weights_matrix = weights.flat_inner_dims(); + auto weights_vector = weights.flat(); Tensor scaled_weights(DT_FLOAT, weights.shape()); - auto scaled_weights_matrix = scaled_weights.flat_inner_dims(); - for (int64 row = 0; row < weights_matrix.dimension(0); ++row) { - for (int64 col = 0; col < weights_cols; ++col) { - scaled_weights_matrix(row, col) = - weights_matrix(row, col) * scale_values[col]; - } + auto scaled_weights_vector = scaled_weights.flat(); + for (int64 row = 0; row < weights_vector.dimension(0); ++row) { + scaled_weights_vector(row) = + weights_vector(row) * scale_values[row % weights_cols]; } // Figure out the remaining bias to add on. Tensor bias_offset(DT_FLOAT, {weights_cols}); @@ -293,7 +292,7 @@ Status FoldOldBatchNorms(const GraphDef& input_graph_def, current_graph_def, // clang-format off {"BatchNormWithGlobalNormalization|FusedBatchNorm", // batch_norm_node { - {"Conv2D", // conv_node + {"Conv2D|DepthwiseConv2dNative", // conv_node { {"*"}, // input_node {"Const"}, // weights_node @@ -326,7 +325,7 @@ Status FoldOldBatchNorms(const GraphDef& input_graph_def, { {"BatchToSpaceND", // batch_to_space_node { - {"Conv2D", // conv_node + {"Conv2D|DepthwiseConv2dNative", // conv_node { {"*"}, // input_node {"Const"}, // weights_node @@ -364,13 +363,13 @@ Status FoldOldBatchNorms(const GraphDef& input_graph_def, { {"ConcatV2|Concat", // concat two conv2d. { - {"Conv2D", // conv_node + {"Conv2D|DepthwiseConv2dNative", // conv_node { {"*"}, // input_node {"Const"}, // weights_node } }, - {"Conv2D", // conv_node + {"Conv2D|DepthwiseConv2dNative", // conv_node { {"*"}, // input_node {"Const"}, // weights_node -- GitLab From 163aae337c875efce2518c3cd0fecb61968fe408 Mon Sep 17 00:00:00 2001 From: Eliel Hojman Date: Sun, 22 Jul 2018 10:20:49 +0300 Subject: [PATCH 081/437] Fixed pylint error Line was too long --- tensorflow/python/data/ops/iterator_ops.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow/python/data/ops/iterator_ops.py b/tensorflow/python/data/ops/iterator_ops.py index 659b92a140..f4d6d53997 100644 --- a/tensorflow/python/data/ops/iterator_ops.py +++ b/tensorflow/python/data/ops/iterator_ops.py @@ -211,8 +211,8 @@ class Iterator(object): This method allows you to define a "feedable" iterator where you can choose between concrete iterators by feeding a value in a @{tf.Session.run} call. - In that case, `string_handle` would be a @{tf.placeholder}, and you would feed - it with the value of @{tf.data.Iterator.string_handle} in each step. + In that case, `string_handle` would be a @{tf.placeholder}, and you would + feed it with the value of @{tf.data.Iterator.string_handle} in each step. For example, if you had two iterators that marked the current position in a training dataset and a test dataset, you could choose which to use in -- GitLab From 29831cdce5beb9082940c140aaab735888626dfd Mon Sep 17 00:00:00 2001 From: Shaba Abhiram Date: Sat, 21 Jul 2018 17:49:05 -0700 Subject: [PATCH 082/437] [BugFix] Fixes #20983 - Store py_func dtypes for correct conversion 1. Implement wrapper class `PythonFunc` to store Tout list for appropriate dtype conversion from tensorflow types to numpy types using the `dtype.as_numpy_dtype` member. 2. Adjust BUILD file to include py_test of the script_ops_test. 3. Add script_ops_test to illustrate broken behavior (see `test_convert_empty_list`). Run the specific test suite with: bazel test //tensorflow/python:script_ops_test 4. `_convert` was being called from dataset_ops, update this to refer to the `PythonFunc` instead of the `FuncRegistry`. 5. [Review Feedback] Move script_ops tests to py_func_test.py. Also removed the BUILD rules for the deleted test file. --- tensorflow/python/data/ops/dataset_ops.py | 2 +- .../python/kernel_tests/py_func_test.py | 13 ++- tensorflow/python/ops/script_ops.py | 93 ++++++++++++------- 3 files changed, 71 insertions(+), 37 deletions(-) diff --git a/tensorflow/python/data/ops/dataset_ops.py b/tensorflow/python/data/ops/dataset_ops.py index 88de4b588c..ed727fc77f 100644 --- a/tensorflow/python/data/ops/dataset_ops.py +++ b/tensorflow/python/data/ops/dataset_ops.py @@ -428,7 +428,7 @@ class Dataset(object): ret_arrays = [] for ret, dtype in zip(flattened_values, flattened_types): try: - ret_arrays.append(script_ops.FuncRegistry._convert( # pylint: disable=protected-access + ret_arrays.append(script_ops.PythonFunc._convert( # pylint: disable=protected-access ret, dtype=dtype.as_numpy_dtype)) except (TypeError, ValueError): raise TypeError( diff --git a/tensorflow/python/kernel_tests/py_func_test.py b/tensorflow/python/kernel_tests/py_func_test.py index 50154a45a8..f1fd3d571f 100644 --- a/tensorflow/python/kernel_tests/py_func_test.py +++ b/tensorflow/python/kernel_tests/py_func_test.py @@ -148,6 +148,17 @@ class PyFuncTest(test.TestCase): script_ops.py_func(list_func, [x], [dtypes.float64] * 2)) self.assertAllClose(y, [0.0, 1.0]) + def testConvertEmptyList(self): + with self.test_session(): + + def empty_list_func(args): + return [], + + x = constant_op.constant(0, dtypes.int64) + y = self.evaluate( + script_ops.py_func(empty_list_func, [x], dtypes.int64)) + self.assertAllClose(y, []) + def testTuple(self): # returns a tuple with self.test_session(): @@ -452,7 +463,7 @@ class PyFuncTest(test.TestCase): # (see #18292) _ = script_ops.py_func(lambda x: x + c.shape[0], [c], [dtypes.float32]) _ = script_ops.eager_py_func(lambda x: x + c.shape[0], [c], [dtypes.float32]) - + # Call garbage collector to enforce deletion. make_graphs() ops.reset_default_graph() diff --git a/tensorflow/python/ops/script_ops.py b/tensorflow/python/ops/script_ops.py index af103d3cc7..5d695216ca 100644 --- a/tensorflow/python/ops/script_ops.py +++ b/tensorflow/python/ops/script_ops.py @@ -120,30 +120,19 @@ class EagerFunc(object): return outputs -class FuncRegistry(object): - """A helper class to keep track of registered py functions. - - FuncRegistry keeps a map from unique tokens (string) to python - functions, which takes numpy arrays and outputs numpy arrays. - """ +class PythonFunc(object): + """A wrapper for a function owned by PyFunc.""" - def __init__(self): - self._lock = threading.Lock() - self._unique_id = 0 # GUARDED_BY(self._lock) - # Only store weakrefs to the functions. The strong reference is stored in - # the graph. - self._funcs = weakref.WeakValueDictionary() - - def insert(self, func): - """Registers `func` and returns a unique token for this entry.""" - token = self._next_unique_token() - # Store a weakref to the function - self._funcs[token] = func - return token + def __init__(self, func, Tout): + """Constructs a PythonFunc. - def remove(self, token): - """Removes the registered function corresponding to `token`.""" - self._funcs.pop(token, None) + Args: + func: The function to wrap. + Tout: A list of datatypes for the output; an empty list if the output is + None. + """ + self._func = func + self._out_dtypes = Tout @staticmethod def _convert(value, dtype=None): @@ -171,8 +160,48 @@ class FuncRegistry(object): return np.asarray(value, order="C", dtype=object) elif result.dtype.char == "U": return result.astype(np.bytes_) - else: - return result + return result + + def __call__(self, args): + ret = self._func(*args) + # Strings seem to lead to a memory leak here if they're not wrapped in a + # list. + if isinstance(ret, six.binary_type): + ret = [ret] + # Ensures that we return either a single numpy array or a list of numpy + # arrays. + if isinstance(ret, (tuple, list)): + return [ + self._convert(x, dtype=dtype.as_numpy_dtype) + for (x, dtype) in zip(ret, self._out_dtypes) + ] + return self._convert(ret) # TODO: pass self._out_dtypes? + + +class FuncRegistry(object): + """A helper class to keep track of registered py functions. + + FuncRegistry keeps a map from unique tokens (string) to python + functions, which takes numpy arrays and outputs numpy arrays. + """ + + def __init__(self): + self._lock = threading.Lock() + self._unique_id = 0 # GUARDED_BY(self._lock) + # Only store weakrefs to the functions. The strong reference is stored in + # the graph. + self._funcs = weakref.WeakValueDictionary() + + def insert(self, func): + """Registers `func` and returns a unique token for this entry.""" + token = self._next_unique_token() + # Store a weakref to the function + self._funcs[token] = func + return token + + def remove(self, token): + """Removes the registered function corresponding to `token`.""" + self._funcs.pop(token, None) def __call__(self, token, device, args): """Calls the registered function for `token` with args. @@ -202,18 +231,10 @@ class FuncRegistry(object): # # TODO(akshayka): Key the tape cache in a thread-safe way. return func(device, token, args) + elif isinstance(func, PythonFunc): + return func(args) else: - ret = func(*args) - # Strings seem to lead to a memory leak here if they're not wrapped in a - # list. - if isinstance(ret, six.binary_type): - ret = [ret] - # Ensures that we return either a single numpy array or a list of numpy - # arrays. - if isinstance(ret, (tuple, list)): - return [self._convert(x) for x in ret] - else: - return self._convert(ret) + raise ValueError("callback %s type is invalid" % token) def size(self): """Returns how many functions are currently registered.""" @@ -249,6 +270,8 @@ def _internal_py_func(func, if eager: func = EagerFunc(func, Tout, is_grad_func) + else: + func = PythonFunc(func, Tout) token = _py_funcs.insert(func) # We tie the registered function's lifetime with the current default graph, -- GitLab From 4d876cd4b1187a839c3f6b12283eaa599218c0b6 Mon Sep 17 00:00:00 2001 From: Shaba Abhiram Date: Mon, 23 Jul 2018 18:17:24 -0700 Subject: [PATCH 083/437] [Review Feedback] apply dtype to _convert on non list inputs to py_func Disabled the `testBadNumpyReturnType` which should allow for a conversion of an arbitrary np.array into a list of a specified dtype. Modified the exception expectation for the `testBadReturnType` test. --- .../python/kernel_tests/py_func_test.py | 42 ++++++++++++------- tensorflow/python/ops/script_ops.py | 6 ++- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/tensorflow/python/kernel_tests/py_func_test.py b/tensorflow/python/kernel_tests/py_func_test.py index f1fd3d571f..7aae9b8a60 100644 --- a/tensorflow/python/kernel_tests/py_func_test.py +++ b/tensorflow/python/kernel_tests/py_func_test.py @@ -159,6 +159,17 @@ class PyFuncTest(test.TestCase): script_ops.py_func(empty_list_func, [x], dtypes.int64)) self.assertAllClose(y, []) + def testConvertScalarType(self): + with self.test_session(): + + def one_func(args): + return 1 + + x = constant_op.constant(0, dtypes.int64) + y = self.evaluate( + script_ops.py_func(one_func, [x], dtypes.int64)) + self.assertAllClose(y, 1) + def testTuple(self): # returns a tuple with self.test_session(): @@ -272,18 +283,20 @@ class PyFuncTest(test.TestCase): z, = script_ops.py_func(unicode_string, [], [dtypes.string]) self.assertEqual(z.eval(), correct.encode("utf8")) - def testBadNumpyReturnType(self): - with self.test_session(): - - def bad(): - # Structured numpy arrays aren't supported. - return np.array([], dtype=[("foo", np.float32)]) - - y, = script_ops.py_func(bad, [], [dtypes.float32]) - - with self.assertRaisesRegexp(errors.UnimplementedError, - "Unsupported numpy type"): - y.eval() + # TODO: This will no longer raise an exception since the byte-array + # will be converted into a float32 type. Is this not as desired? + # def testBadNumpyReturnType(self): + # with self.test_session(): + # + # def bad(): + # # Structured numpy arrays aren't supported. + # return np.array([], dtype=[("foo", np.float32)]) + # + # y, = script_ops.py_func(bad, [], [dtypes.float32]) + # + # with self.assertRaisesRegexp(errors.UnimplementedError, + # "Unsupported numpy type"): + # y.eval() def testBadReturnType(self): with self.test_session(): @@ -294,8 +307,9 @@ class PyFuncTest(test.TestCase): z, = script_ops.py_func(bad, [], [dtypes.int64]) - with self.assertRaisesRegexp(errors.UnimplementedError, - "Unsupported object type"): + with self.assertRaisesRegexp( + errors.InvalidArgumentError, + "argument must be a string or a number, not 'dict'"): z.eval() def testReturnInput(self): diff --git a/tensorflow/python/ops/script_ops.py b/tensorflow/python/ops/script_ops.py index 5d695216ca..a053ede942 100644 --- a/tensorflow/python/ops/script_ops.py +++ b/tensorflow/python/ops/script_ops.py @@ -175,7 +175,11 @@ class PythonFunc(object): self._convert(x, dtype=dtype.as_numpy_dtype) for (x, dtype) in zip(ret, self._out_dtypes) ] - return self._convert(ret) # TODO: pass self._out_dtypes? + + dtype = None + if isinstance(self._out_dtypes, (tuple, list)) and self._out_dtypes: + dtype = self._out_dtypes[0].as_numpy_dtype + return self._convert(ret, dtype) class FuncRegistry(object): -- GitLab From 0f1b0d6a031c883ca531b4469110eb034637b120 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: Tue, 24 Jul 2018 10:30:04 +0800 Subject: [PATCH 084/437] BUG: check original dtype with restore dtype --- tensorflow/core/kernels/save_restore_tensor.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tensorflow/core/kernels/save_restore_tensor.cc b/tensorflow/core/kernels/save_restore_tensor.cc index 990bd2bff9..158182a45b 100644 --- a/tensorflow/core/kernels/save_restore_tensor.cc +++ b/tensorflow/core/kernels/save_restore_tensor.cc @@ -250,13 +250,15 @@ Status RestoreTensorsV2(OpKernelContext* context, const Tensor& prefix, // TODO(zongheng): consider measuring speed and issuing concurrent lookups // within a fixed memory budget. TensorShape restored_full_shape; + DataType restored_dtype; Tensor* restored_tensor = nullptr; for (auto i : sorted_name_idx) { const string& tensor_name = tensor_names_flat(i); const string& shape_and_slice = shape_and_slices_flat(i); TF_RETURN_IF_ERROR( - reader.LookupTensorShape(tensor_name, &restored_full_shape)); + reader.LookupDtypeAndShape(tensor_name, + &restored_dtype, &restored_full_shape)); if (shape_and_slice.empty()) { // Lookup the full tensor. @@ -285,10 +287,10 @@ Status RestoreTensorsV2(OpKernelContext* context, const Tensor& prefix, TF_RETURN_IF_ERROR( reader.LookupSlice(tensor_name, parsed_slice, restored_tensor)); } - if (dtypes[i] != restored_tensor->dtype()) { + if (restored_dtype != restored_tensor->dtype()) { return errors::InvalidArgument( "tensor_name = ", tensor_name, "; expected dtype ", - DataTypeString(dtypes[i]), " does not equal restored dtype ", + DataTypeString(restored_dtype), " does not equal restored dtype ", DataTypeString(restored_tensor->dtype())); } } -- GitLab From 885206514f1ea0681418692603f3853917de07b5 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: Tue, 24 Jul 2018 11:09:44 +0800 Subject: [PATCH 085/437] TST: add test case --- tensorflow/python/training/saver_test.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tensorflow/python/training/saver_test.py b/tensorflow/python/training/saver_test.py index ae9c244aaf..b6a9157371 100644 --- a/tensorflow/python/training/saver_test.py +++ b/tensorflow/python/training/saver_test.py @@ -768,6 +768,30 @@ class SaverTest(test.TestCase): self.assertEqual(20.0, v1.eval()) save.save(sess, save_path) + def testSaveRestoreAndValidateVariableDtype(self): + for variable_op in [variables.Variable, + resource_variable_ops.ResourceVariable]: + save_path = os.path.join(self.get_temp_dir(), "basic_save_restore") + + # Build the first session. + with self.test_session(graph=ops_lib.Graph()) as sess: + v0 = variable_op(10.0, name="v0", dtype=dtypes.float32) + + if not context.executing_eagerly(): + self.evaluate([variables.global_variables_initializer()]) + + save = saver_module.Saver({"v0": v0}) + save.save(sess, save_path) + + # Start a second session. + with self.test_session(graph=ops_lib.Graph()) as sess: + v0_wrong_dtype = variable_op(1, name="v0", dtype=dtypes.int32) + # Restore the saved value with different dtype + # in the parameter nodes. + save = saver_module.Saver({"v0": v0_wrong_dtype}) + with self.assertRaises(errors.InvalidArgumentError): + save.restore(sess, save_path) + class SaveRestoreShardedTest(test.TestCase): -- GitLab From 88504ad869598dc5603acb91b717b6ad50fc87ba 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: Tue, 24 Jul 2018 11:19:41 +0800 Subject: [PATCH 086/437] DOC: add comment --- tensorflow/core/kernels/save_restore_tensor.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tensorflow/core/kernels/save_restore_tensor.cc b/tensorflow/core/kernels/save_restore_tensor.cc index 158182a45b..d4f5424cbf 100644 --- a/tensorflow/core/kernels/save_restore_tensor.cc +++ b/tensorflow/core/kernels/save_restore_tensor.cc @@ -287,6 +287,8 @@ Status RestoreTensorsV2(OpKernelContext* context, const Tensor& prefix, TF_RETURN_IF_ERROR( reader.LookupSlice(tensor_name, parsed_slice, restored_tensor)); } + // `restored_tensor` is allocated with output_type, which is the same with `dtypes`. + // Hence we validate the dtype of `restored_tensor` with `restored_dtype` here. if (restored_dtype != restored_tensor->dtype()) { return errors::InvalidArgument( "tensor_name = ", tensor_name, "; expected dtype ", -- GitLab From ffc01d4eb4e82e8e152b49edcf6877ab83f7c549 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: Tue, 24 Jul 2018 11:32:09 +0800 Subject: [PATCH 087/437] CLN: validate dtype before allocate --- tensorflow/core/kernels/save_restore_tensor.cc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tensorflow/core/kernels/save_restore_tensor.cc b/tensorflow/core/kernels/save_restore_tensor.cc index d4f5424cbf..3e69f06bb4 100644 --- a/tensorflow/core/kernels/save_restore_tensor.cc +++ b/tensorflow/core/kernels/save_restore_tensor.cc @@ -250,7 +250,7 @@ Status RestoreTensorsV2(OpKernelContext* context, const Tensor& prefix, // TODO(zongheng): consider measuring speed and issuing concurrent lookups // within a fixed memory budget. TensorShape restored_full_shape; - DataType restored_dtype; + DataType original_dtype; Tensor* restored_tensor = nullptr; for (auto i : sorted_name_idx) { const string& tensor_name = tensor_names_flat(i); @@ -258,7 +258,15 @@ Status RestoreTensorsV2(OpKernelContext* context, const Tensor& prefix, TF_RETURN_IF_ERROR( reader.LookupDtypeAndShape(tensor_name, - &restored_dtype, &restored_full_shape)); + &original_dtype, &restored_full_shape)); + + // Precheck dtype. + if (dtypes[i] != original_dtype) { + return errors::InvalidArgument( + "tensor_name = ", tensor_name, "; expected dtype ", + DataTypeString(dtypes[i]), " does not equal original dtype ", + DataTypeString(original_dtype)); + } if (shape_and_slice.empty()) { // Lookup the full tensor. @@ -287,12 +295,10 @@ Status RestoreTensorsV2(OpKernelContext* context, const Tensor& prefix, TF_RETURN_IF_ERROR( reader.LookupSlice(tensor_name, parsed_slice, restored_tensor)); } - // `restored_tensor` is allocated with output_type, which is the same with `dtypes`. - // Hence we validate the dtype of `restored_tensor` with `restored_dtype` here. - if (restored_dtype != restored_tensor->dtype()) { + if (dtypes[i] != restored_tensor->dtype()) { return errors::InvalidArgument( "tensor_name = ", tensor_name, "; expected dtype ", - DataTypeString(restored_dtype), " does not equal restored dtype ", + DataTypeString(dtypes[i]), " does not equal restored dtype ", DataTypeString(restored_tensor->dtype())); } } -- GitLab From 6d0bb6f647a73e394666d1d8821f0427053a8803 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: Tue, 24 Jul 2018 11:35:15 +0800 Subject: [PATCH 088/437] TST: check message of exception --- tensorflow/python/training/saver_test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tensorflow/python/training/saver_test.py b/tensorflow/python/training/saver_test.py index b6a9157371..8943173cda 100644 --- a/tensorflow/python/training/saver_test.py +++ b/tensorflow/python/training/saver_test.py @@ -789,7 +789,8 @@ class SaverTest(test.TestCase): # Restore the saved value with different dtype # in the parameter nodes. save = saver_module.Saver({"v0": v0_wrong_dtype}) - with self.assertRaises(errors.InvalidArgumentError): + with self.assertRaisesRegexp(errors.InvalidArgumentError, + "original dtype"): save.restore(sess, save_path) -- GitLab From e153fa9207a5396b1403c4ca6635e62bff39d621 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: Tue, 24 Jul 2018 12:49:24 +0800 Subject: [PATCH 089/437] CLN: remove comment --- tensorflow/core/kernels/save_restore_tensor.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/tensorflow/core/kernels/save_restore_tensor.cc b/tensorflow/core/kernels/save_restore_tensor.cc index 3e69f06bb4..1c22b280b3 100644 --- a/tensorflow/core/kernels/save_restore_tensor.cc +++ b/tensorflow/core/kernels/save_restore_tensor.cc @@ -260,7 +260,6 @@ Status RestoreTensorsV2(OpKernelContext* context, const Tensor& prefix, reader.LookupDtypeAndShape(tensor_name, &original_dtype, &restored_full_shape)); - // Precheck dtype. if (dtypes[i] != original_dtype) { return errors::InvalidArgument( "tensor_name = ", tensor_name, "; expected dtype ", -- GitLab From 3d7c2729da4d6373e5dfe32c791b8b002e02f376 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: Tue, 24 Jul 2018 13:36:37 +0800 Subject: [PATCH 090/437] ENH: collect all mismatched dtypes --- .../core/kernels/save_restore_tensor.cc | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/tensorflow/core/kernels/save_restore_tensor.cc b/tensorflow/core/kernels/save_restore_tensor.cc index 1c22b280b3..a7d0523f87 100644 --- a/tensorflow/core/kernels/save_restore_tensor.cc +++ b/tensorflow/core/kernels/save_restore_tensor.cc @@ -251,21 +251,34 @@ Status RestoreTensorsV2(OpKernelContext* context, const Tensor& prefix, // within a fixed memory budget. TensorShape restored_full_shape; DataType original_dtype; - Tensor* restored_tensor = nullptr; + std::vector mismatched_errors; for (auto i : sorted_name_idx) { const string& tensor_name = tensor_names_flat(i); - const string& shape_and_slice = shape_and_slices_flat(i); - TF_RETURN_IF_ERROR( reader.LookupDtypeAndShape(tensor_name, &original_dtype, &restored_full_shape)); - if (dtypes[i] != original_dtype) { - return errors::InvalidArgument( - "tensor_name = ", tensor_name, "; expected dtype ", - DataTypeString(dtypes[i]), " does not equal original dtype ", - DataTypeString(original_dtype)); + string error_msg = string("tensor_name = ") + tensor_name + + "; expected dtype " + DataTypeString(dtypes[i]) + + " does not equal original dtype " + + DataTypeString(original_dtype) + '\n'; + mismatched_errors.emplace_back(error_msg); } + } + if (!mismatched_errors.empty()) { + string error_msg = std::accumulate(mismatched_errors.begin(), + mismatched_errors.end(), + string()); + return errors::InvalidArgument(error_msg); + } + + Tensor* restored_tensor = nullptr; + for (auto i : sorted_name_idx) { + const string& tensor_name = tensor_names_flat(i); + const string& shape_and_slice = shape_and_slices_flat(i); + + TF_RETURN_IF_ERROR( + reader.LookupTensorShape(tensor_name, &restored_full_shape)); if (shape_and_slice.empty()) { // Lookup the full tensor. -- GitLab From 6f776c78f8824b962a00898eee8277104f978e94 Mon Sep 17 00:00:00 2001 From: Taehoon Lee Date: Tue, 24 Jul 2018 20:18:51 +0900 Subject: [PATCH 091/437] Fix typos --- tensorflow/contrib/autograph/operators/control_flow.py | 2 +- .../autograph/pyct/static_analysis/reaching_definitions.py | 2 +- tensorflow/contrib/bigtable/python/ops/bigtable_api.py | 4 ++-- .../constrained_optimization/python/swap_regret_optimizer.py | 2 +- tensorflow/contrib/distributions/python/ops/sample_stats.py | 4 ++-- tensorflow/contrib/lite/toco/model.h | 2 +- tensorflow/contrib/model_pruning/python/layers/layers.py | 2 +- tensorflow/contrib/quantize/python/quant_ops_test.py | 4 ++-- tensorflow/core/framework/function.h | 2 +- tensorflow/python/ops/image_ops_test.py | 4 ++-- tensorflow/python/ops/parallel_for/pfor.py | 2 +- tensorflow/python/training/checkpoint_utils.py | 2 +- tensorflow/python/training/ftrl.py | 2 +- 13 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tensorflow/contrib/autograph/operators/control_flow.py b/tensorflow/contrib/autograph/operators/control_flow.py index 988df70157..5126592e1e 100644 --- a/tensorflow/contrib/autograph/operators/control_flow.py +++ b/tensorflow/contrib/autograph/operators/control_flow.py @@ -141,7 +141,7 @@ def _dataset_for_stmt(ds, extra_test, body, init_state): while_body, init_state=(epoch_number, iterate) + init_state, extra_deps=()) - # Dropping the epoch number and iterate because they are not not syntactically + # Dropping the epoch number and iterate because they are not syntactically # visible. results = results[2:] diff --git a/tensorflow/contrib/autograph/pyct/static_analysis/reaching_definitions.py b/tensorflow/contrib/autograph/pyct/static_analysis/reaching_definitions.py index 9a84f1231c..7f2b379d3d 100644 --- a/tensorflow/contrib/autograph/pyct/static_analysis/reaching_definitions.py +++ b/tensorflow/contrib/autograph/pyct/static_analysis/reaching_definitions.py @@ -39,7 +39,7 @@ from tensorflow.contrib.autograph.pyct.static_analysis import annos class Definition(object): """Definition objects describe a unique definition of a variable. - Subclasses of this may be used by passing an appropriate factory fuction to + Subclasses of this may be used by passing an appropriate factory function to resolve. Attributes: diff --git a/tensorflow/contrib/bigtable/python/ops/bigtable_api.py b/tensorflow/contrib/bigtable/python/ops/bigtable_api.py index fd30aa8bbb..53d58a8efe 100644 --- a/tensorflow/contrib/bigtable/python/ops/bigtable_api.py +++ b/tensorflow/contrib/bigtable/python/ops/bigtable_api.py @@ -331,7 +331,7 @@ class BigtableTable(object): """Retrieves row (including values) from the Bigtable service at high speed. Rows with row-key prefixed by `prefix` will be retrieved. This method is - similar to `scan_prefix`, but by constrast performs multiple sub-scans in + similar to `scan_prefix`, but by contrast performs multiple sub-scans in parallel in order to achieve higher performance. Note: The dataset produced by this method is not deterministic! @@ -390,7 +390,7 @@ class BigtableTable(object): """Retrieves rows (including values) from the Bigtable service. Rows with row-keys between `start` and `end` will be retrieved. This method - is similar to `scan_range`, but by constrast performs multiple sub-scans in + is similar to `scan_range`, but by contrast performs multiple sub-scans in parallel in order to achieve higher performance. Note: The dataset produced by this method is not deterministic! diff --git a/tensorflow/contrib/constrained_optimization/python/swap_regret_optimizer.py b/tensorflow/contrib/constrained_optimization/python/swap_regret_optimizer.py index 3791dae8d7..ff846b191a 100644 --- a/tensorflow/contrib/constrained_optimization/python/swap_regret_optimizer.py +++ b/tensorflow/contrib/constrained_optimization/python/swap_regret_optimizer.py @@ -150,7 +150,7 @@ def _project_stochastic_matrix_wrt_euclidean_norm(matrix): "matrix must be two dimensional (instead is %d-dimensional)" % matrix_shape.ndims) if matrix_shape[0] != matrix_shape[1]: - raise ValueError("matrix must be be square (instead has shape (%d,%d))" % + raise ValueError("matrix must be square (instead has shape (%d,%d))" % (matrix_shape[0], matrix_shape[1])) dimension = matrix_shape[0].value if dimension is None: diff --git a/tensorflow/contrib/distributions/python/ops/sample_stats.py b/tensorflow/contrib/distributions/python/ops/sample_stats.py index f5aaa5cf34..aa680a92be 100644 --- a/tensorflow/contrib/distributions/python/ops/sample_stats.py +++ b/tensorflow/contrib/distributions/python/ops/sample_stats.py @@ -134,7 +134,7 @@ def auto_correlation( x_len = util.prefer_static_shape(x_rotated)[-1] # TODO(langmore) Investigate whether this zero padding helps or hurts. At - # the moment is is necessary so that all FFT implementations work. + # the moment is necessary so that all FFT implementations work. # Zero pad to the next power of 2 greater than 2 * x_len, which equals # 2**(ceil(Log_2(2 * x_len))). Note: Log_2(X) = Log_e(X) / Log_e(2). x_len_float64 = math_ops.cast(x_len, np.float64) @@ -198,7 +198,7 @@ def auto_correlation( # Recall R[m] is a sum of N / 2 - m nonzero terms x[n] Conj(x[n - m]). The # other terms were zeros arising only due to zero padding. # `denominator = (N / 2 - m)` (defined below) is the proper term to - # divide by by to make this an unbiased estimate of the expectation + # divide by to make this an unbiased estimate of the expectation # E[X[n] Conj(X[n - m])]. x_len = math_ops.cast(x_len, dtype.real_dtype) max_lags = math_ops.cast(max_lags, dtype.real_dtype) diff --git a/tensorflow/contrib/lite/toco/model.h b/tensorflow/contrib/lite/toco/model.h index d629787939..58927f550b 100644 --- a/tensorflow/contrib/lite/toco/model.h +++ b/tensorflow/contrib/lite/toco/model.h @@ -2009,7 +2009,7 @@ class Model { std::size_t transient_data_size = 0; // For code-generation only: required alignment of the transient_data buffer std::size_t transient_data_alignment = 0; - // Arithmatic operations performed in the model. + // Arithmetic operations performed in the model. int64 ops_count = 0; private: diff --git a/tensorflow/contrib/model_pruning/python/layers/layers.py b/tensorflow/contrib/model_pruning/python/layers/layers.py index 466daf204a..d453e350f0 100644 --- a/tensorflow/contrib/model_pruning/python/layers/layers.py +++ b/tensorflow/contrib/model_pruning/python/layers/layers.py @@ -139,7 +139,7 @@ def masked_convolution(inputs, with "NC". num_outputs: Integer, the number of output filters. kernel_size: A sequence of N positive integers specifying the spatial - dimensions of of the filters. Can be a single integer to specify the same + dimensions of the filters. Can be a single integer to specify the same value for all spatial dimensions. stride: A sequence of N positive integers specifying the stride at which to compute output. Can be a single integer to specify the same value for all diff --git a/tensorflow/contrib/quantize/python/quant_ops_test.py b/tensorflow/contrib/quantize/python/quant_ops_test.py index c2a8def480..a45840009b 100644 --- a/tensorflow/contrib/quantize/python/quant_ops_test.py +++ b/tensorflow/contrib/quantize/python/quant_ops_test.py @@ -75,7 +75,7 @@ class QuantOpsTest(googletest.TestCase): self.assertGreater(max_value, 0.0) self.assertLess(max_value, 1.0) - def testVariablesNotParitioned_LastValue(self): + def testVariablesNotPartitioned_LastValue(self): # Variables added should not use a default partiioner since they are # scalar. There would be a tensorflow error thrown if the partitioner was # respected by the rewrite. @@ -90,7 +90,7 @@ class QuantOpsTest(googletest.TestCase): is_training=True, vars_collection=_MIN_MAX_VARS) - def testVariablesNotParitioned_MovingAvg(self): + def testVariablesNotPartitioned_MovingAvg(self): # Variables added should not use a default partiioner since they are # scalar. There would be a tensorflow error thrown if the partitioner was # respected by the rewrite. diff --git a/tensorflow/core/framework/function.h b/tensorflow/core/framework/function.h index 5da9af7db3..31a816ac5f 100644 --- a/tensorflow/core/framework/function.h +++ b/tensorflow/core/framework/function.h @@ -456,7 +456,7 @@ class FunctionLibraryRuntime { // This interface is EXPERIMENTAL and subject to change. // - // Instatiates the function using an executor of the given type. If empty, + // Instantiates the function using an executor of the given type. If empty, // the default TensorFlow executor will be used. string executor_type; }; diff --git a/tensorflow/python/ops/image_ops_test.py b/tensorflow/python/ops/image_ops_test.py index cf9761803b..187f3e6e2d 100644 --- a/tensorflow/python/ops/image_ops_test.py +++ b/tensorflow/python/ops/image_ops_test.py @@ -1956,7 +1956,7 @@ class PadToBoundingBoxTest(test_util.TensorFlowTestCase): "all dims of 'image.shape' must be > 0", use_tensor_inputs_options=[False]) - # The orignal error message does not contain back slashes. However, they + # The original error message does not contain back slashes. However, they # are added by either the assert op or the runtime. If this behavior # changes in the future, the match string will also needs to be changed. self._assertRaises( @@ -2985,7 +2985,7 @@ class ResizeImageWithCropOrPadTest(test_util.TensorFlowTestCase): "all dims of 'image.shape' must be > 0", use_tensor_inputs_options=[False]) - # The orignal error message does not contain back slashes. However, they + # The original error message does not contain back slashes. However, they # are added by either the assert op or the runtime. If this behavior # changes in the future, the match string will also needs to be changed. self._assertRaises( diff --git a/tensorflow/python/ops/parallel_for/pfor.py b/tensorflow/python/ops/parallel_for/pfor.py index 77ec3bc0d4..2e4b2fd64e 100644 --- a/tensorflow/python/ops/parallel_for/pfor.py +++ b/tensorflow/python/ops/parallel_for/pfor.py @@ -2117,7 +2117,7 @@ def _convert_print(pfor_input): # 2a Elements written to the array are "stacked" # To simulate multiple TensorArrays, we may increase the dimension of each # element of the array. i.e. the i_th row of the j_th entry of the converted -# TensorArray corresponds to to the j_th entry of the TensorArray in the i_th +# TensorArray corresponds to the j_th entry of the TensorArray in the i_th # pfor iteration. # # 2b Elements written to the array are "unstacked" diff --git a/tensorflow/python/training/checkpoint_utils.py b/tensorflow/python/training/checkpoint_utils.py index 883f4fd910..4752b9dce6 100644 --- a/tensorflow/python/training/checkpoint_utils.py +++ b/tensorflow/python/training/checkpoint_utils.py @@ -316,7 +316,7 @@ def _set_checkpoint_initializer(variable, # pylint:disable=protected-access # We need special handling for `DistributedVariable`s as they contain - # mutliple actual variables. `assign` on a `DistributedVariable` returns a + # multiple actual variables. `assign` on a `DistributedVariable` returns a # combined `init_op` which contains initializers for all the contained # variables. We then set each underlying variable's `_initializer_op` using # the corresponding `init_op`. diff --git a/tensorflow/python/training/ftrl.py b/tensorflow/python/training/ftrl.py index 4fa081fab7..832c10d454 100644 --- a/tensorflow/python/training/ftrl.py +++ b/tensorflow/python/training/ftrl.py @@ -86,7 +86,7 @@ class FtrlOptimizer(optimizer.Optimizer): if initial_accumulator_value < 0.0: raise ValueError( - "initial_accumulator_value %f needs to be be positive or zero" % + "initial_accumulator_value %f needs to be positive or zero" % initial_accumulator_value) if learning_rate_power > 0.0: raise ValueError("learning_rate_power %f needs to be negative or zero" % -- GitLab From abfc8525faee0c0587f454ccd928674c1538bb6f Mon Sep 17 00:00:00 2001 From: Guozhong Zhuang Date: Tue, 24 Jul 2018 08:39:08 -0700 Subject: [PATCH 092/437] code refactoring based on suggestions from PR403 code review --- .../core/kernels/mkl_fused_batch_norm_op.cc | 76 ++++++++----------- tensorflow/core/util/mkl_util.h | 31 ++++---- 2 files changed, 47 insertions(+), 60 deletions(-) diff --git a/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc b/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc index 44268fc305..fdb04cac64 100644 --- a/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc +++ b/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc @@ -715,15 +715,15 @@ class MklFusedBatchNormFwdPrimitive : public MklPrimitive { // BatchNormalization forward execute // src_data: input data buffer of src // weights_data: input data buffer of weights - // dst_data: output data buffer of dst - // mean_data: input data buffer of means - // variance_data: input data buffer of variances - void Execute(const T* src_data, const T* weights_data, const T* dst_data, - const T* mean_data, const T* variance_data) { + // dst_data: output data buffer of dst + // mean_data: output data buffer of means + // variance_data: output data buffer of variances + void Execute(const T* src_data, const T* weights_data, T* dst_data, + T* mean_data, T* variance_data) { context_.src_mem->set_data_handle( static_cast(const_cast(src_data))); context_.dst_mem->set_data_handle( - static_cast(const_cast(dst_data))); + static_cast(dst_data)); if (context_.flags & use_scale_shift) context_.weights_mem->set_data_handle( @@ -732,9 +732,9 @@ class MklFusedBatchNormFwdPrimitive : public MklPrimitive { if ((context_.pkind == prop_kind::forward_training) || (context_.flags & use_global_stats)) { context_.mean_mem->set_data_handle( - static_cast(const_cast(mean_data))); + static_cast(mean_data)); context_.variance_mem->set_data_handle( - static_cast(const_cast(variance_data))); + static_cast(variance_data)); } // execution @@ -962,7 +962,7 @@ class MklFusedBatchNormBwdPrimitive : public MklPrimitive { // diff_weights_data: output data buffer of diff_weights void Execute(const T* src_data, const T* mean_data, const T* variance_data, const T* diff_dst_data, const T* weights_data, - const T* diff_src_data, const T* diff_weights_data) { + T* diff_src_data, T* diff_weights_data) { context_.src_mem->set_data_handle( static_cast(const_cast(src_data))); context_.mean_mem->set_data_handle( @@ -976,11 +976,11 @@ class MklFusedBatchNormBwdPrimitive : public MklPrimitive { context_.weights_mem->set_data_handle( static_cast(const_cast(weights_data))); context_.diff_weights_mem->set_data_handle( - static_cast(const_cast(diff_weights_data))); + static_cast(diff_weights_data)); } context_.diff_src_mem->set_data_handle( - static_cast(const_cast(diff_src_data))); + static_cast(diff_src_data)); // execution context_.bwd_stream->submit(context_.bwd_primitives); @@ -1273,10 +1273,8 @@ class MklFusedBatchNormOp : public OpKernel { // ...... weights.AllocateBuffer(2 * depth_ * sizeof (T)); T* weights_data = reinterpret_cast(weights.GetAllocatedBuffer()); - T* scale_tf = - reinterpret_cast(const_cast(scale_tensor.flat().data())); - T* shift_tf = - reinterpret_cast(const_cast(shift_tensor.flat().data())); + const T* scale_tf = scale_tensor.flat().data(); + const T* shift_tf = shift_tensor.flat().data(); std::memcpy(weights_data, scale_tf, depth_ * sizeof(T)); std::memcpy(weights_data + depth_, shift_tf, depth_ * sizeof(T)); @@ -1297,16 +1295,14 @@ class MklFusedBatchNormOp : public OpKernel { MklFusedBatchNormFwdPrimitiveFactory::Get(fwdParams); // check if reorder is needed for src, weights, mean, variance - T* src_data = nullptr; + const T* src_data = src_tensor.flat().data(); if (src_md.data.format != bn_fwd->GetSrcFmt()) { src.SetUsrMem(src_md, &src_tensor); auto src_target = memory::primitive_desc({{src_dims}, MklDnnType(), static_cast(bn_fwd->GetSrcFmt())}, cpu_engine); src.CheckReorderToOpMem(src_target); - src_data = static_cast(src.GetOpMem().get_data_handle()); - } else { - src_data = static_cast( - const_cast(src_tensor.flat().data())); + src_data = const_cast( + reinterpret_cast(src.GetOpMem().get_data_handle())); } // allocate output (dst) tensor; always set it as MKL-DNN layout @@ -1325,19 +1321,16 @@ class MklFusedBatchNormOp : public OpKernel { tf_shape_dst, dnn_shape_dst); T* weights_op_data = weights_data; - T* mean_op_data = reinterpret_cast( - saved_mean_tensor->flat().data()); - T* variance_op_data = reinterpret_cast( - saved_variance_tensor->flat().data()); - T* dst_data = static_cast(dst_tensor->flat().data()); + T* mean_op_data = saved_mean_tensor->flat().data(); + T* variance_op_data = saved_variance_tensor->flat().data(); + T* dst_data = dst_tensor->flat().data(); // execution bn_fwd->Execute(src_data, weights_op_data, dst_data, mean_op_data, variance_op_data); // copy batch_mean data - T* batch_mean_data_tf = - reinterpret_cast(batch_mean_tensor->flat().data()); + T* batch_mean_data_tf = batch_mean_tensor->flat().data(); std::memcpy(reinterpret_cast(batch_mean_data_tf), reinterpret_cast(saved_mean_data_tf), depth_ * sizeof(T)); @@ -1602,8 +1595,7 @@ class MklFusedBatchNormGradOp : public OpKernel { // of scale, ..., scale, shift, ...., shift weights.AllocateBuffer(2 * depth_ * sizeof(T)); T* weights_data_tf = reinterpret_cast(weights.GetAllocatedBuffer()); - T* scale_tf = - reinterpret_cast(const_cast(scale_tensor.flat().data())); + const T* scale_tf = scale_tensor.flat().data(); for (int k = 0; k < depth_; k++) { weights_data_tf[k] = scale_tf[k]; weights_data_tf[k + depth_] = 0; @@ -1617,36 +1609,31 @@ class MklFusedBatchNormGradOp : public OpKernel { MklFusedBatchNormBwdPrimitiveFactory::Get(bwdParams); // check if src/diff_dst need to be reordered - T* src_data = nullptr; + const T* src_data = src_tensor.flat().data(); if (src_md.data.format != bn_bwd->GetSrcFmt()) { src.SetUsrMem(src_md, &src_tensor); auto src_target = memory::primitive_desc({{src_dims}, MklDnnType(), static_cast(bn_bwd->GetSrcFmt())}, cpu_engine); src.CheckReorderToOpMem(src_target); - src_data = static_cast(src.GetOpMem().get_data_handle()); - } else { - src_data = static_cast(const_cast( - src_tensor.flat().data())); + src_data = const_cast( + reinterpret_cast(src.GetOpMem().get_data_handle())); } - T* diff_dst_data = nullptr; + const T* diff_dst_data = diff_dst_tensor.flat().data(); if (diff_dst_md.data.format != bn_bwd->GetDiffDstFmt()) { diff_dst.SetUsrMem(diff_dst_md, &diff_dst_tensor); auto diff_dst_target = memory::primitive_desc({{diff_dst_dims}, MklDnnType(), static_cast( bn_bwd->GetDiffDstFmt())}, cpu_engine); diff_dst.CheckReorderToOpMem(diff_dst_target); - diff_dst_data = static_cast( - diff_dst.GetOpMem().get_data_handle()); - } else { - diff_dst_data = static_cast(const_cast( - diff_dst_tensor.flat().data())); + diff_dst_data = const_cast( + reinterpret_cast(diff_dst.GetOpMem().get_data_handle())); } // Indices of output tensors const size_t kDiffSrcIndex = 0; // index of diff_src tensor - // allocate diff_src tensor, always set as MKL-DNN layout + // allocate output tensor: diff_src, always set as MKL-DNN layout MklDnnShape dnn_shape_diff_src; TensorShape tf_shape_diff_src; dnn_shape_diff_src.SetMklTensor(true); @@ -1660,21 +1647,20 @@ class MklFusedBatchNormGradOp : public OpKernel { AllocateOutputSetMklShape(context, kDiffSrcIndex, &diff_src_tensor, tf_shape_diff_src, dnn_shape_diff_src); - T* mean_data = static_cast(const_cast( saved_mean_tensor.flat().data())); T* variance_data = static_cast(const_cast( saved_variance_tensor.flat().data())); T* weights_data = weights_data_tf; T* diff_src_data = static_cast( - diff_src_tensor->flat().data()); + diff_src_tensor->flat().data()); T* diff_weights_data = static_cast( - diff_weights.GetAllocatedBuffer()); + diff_weights.GetAllocatedBuffer()); // Execute bn_bwd->Execute(src_data, mean_data, variance_data, diff_dst_data, weights_data, diff_src_data, diff_weights_data); - // allocate 4 output TF tensors + // allocate output TF tensors: diff_scale and diff_shift Tensor* diff_scale_tensor = nullptr; Tensor* diff_shift_tensor = nullptr; AllocateTFOutputs(context, scale_tensor.shape(), &diff_scale_tensor, diff --git a/tensorflow/core/util/mkl_util.h b/tensorflow/core/util/mkl_util.h index 9967fead20..7ffe39643f 100644 --- a/tensorflow/core/util/mkl_util.h +++ b/tensorflow/core/util/mkl_util.h @@ -19,6 +19,7 @@ limitations under the License. #include #include +#include #include #include @@ -1657,8 +1658,10 @@ class MklDnnData { /// allocate function for data buffer inline void AllocateBuffer(size_t size) { - allocated_buffer_ = cpu_allocator()->AllocateRaw(64, size); + const int64 kMemoryAlginment = 64; // For AVX512 memory alignment. + allocated_buffer_ = cpu_allocator()->AllocateRaw(kMemoryAlginment, size); } + inline void* GetAllocatedBuffer() { return allocated_buffer_; } @@ -1884,7 +1887,6 @@ class MklDnnData { net.push_back(FindOrCreateReorder(reorder_memory_, user_memory_)); stream(stream::kind::eager).submit(net).wait(); } - }; /// Base class for operations with reuse of primitives @@ -1919,9 +1921,7 @@ class MklPrimitiveFactory { void SetOp(const std::string& key, MklPrimitive* op) { auto &map = MklPrimitiveFactory::GetHashMap(); auto stream_iter = map.find(key); - CHECK(stream_iter == map.end()); - map[key] = op; } @@ -1985,7 +1985,7 @@ static inline memory::format get_desired_format(int channel) { } class MklReorderPrimitive : public MklPrimitive { - public: + public: explicit MklReorderPrimitive(const memory* from, const memory* to) { Setup(from, to); } @@ -2000,7 +2000,7 @@ class MklReorderPrimitive : public MklPrimitive { context_.dst_mem->set_data_handle(to->get_data_handle()); } - private: + private: struct ReorderContext { std::shared_ptr src_mem; std::shared_ptr dst_mem; @@ -2024,7 +2024,7 @@ class MklReorderPrimitive : public MklPrimitive { template class MklReorderPrimitiveFactory : public MklPrimitiveFactory { - public: + public: static MklReorderPrimitive* Get(const memory* from, const memory* to) { auto reorderPrim = static_cast( @@ -2043,9 +2043,9 @@ class MklReorderPrimitiveFactory : public MklPrimitiveFactory { return instance_; } - private: - MklReorderPrimitiveFactory() {}; - ~MklReorderPrimitiveFactory() {}; + private: + MklReorderPrimitiveFactory() {} + ~MklReorderPrimitiveFactory() {} static std::string CreateKey(const memory* from, const memory* to) { std::string prefix = "reorder"; @@ -2075,18 +2075,19 @@ class MklReorderPrimitiveFactory : public MklPrimitiveFactory { } }; - /// Fuction to find(or create) a reorder from memory pointed by from to memory pointed - /// by to, it will created primitive or get primitive from pool if it is cached. + /// Fuction to find(or create) a reorder from memory pointed by + /// from to memory pointed by to, it will created primitive or + /// get primitive from pool if it is cached. /// Returns the primitive. template inline primitive FindOrCreateReorder(const memory* from, const memory* to) { CHECK_NOTNULL(from); CHECK_NOTNULL(to); - MklReorderPrimitive *reorder_prim = - MklReorderPrimitiveFactory::Get(from, to); + MklReorderPrimitive *reorder_prim = + MklReorderPrimitiveFactory::Get(from, to); return *reorder_prim->GetPrimitive(); } - + #endif // INTEL_MKL_DNN } // namespace tensorflow -- GitLab From 3c343c19f2414f10aaea6ba3802d883d2303d6fd Mon Sep 17 00:00:00 2001 From: Shaba Abhiram Date: Tue, 24 Jul 2018 10:48:57 -0700 Subject: [PATCH 093/437] [Review Feedback] remove commented test --- tensorflow/python/kernel_tests/py_func_test.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/tensorflow/python/kernel_tests/py_func_test.py b/tensorflow/python/kernel_tests/py_func_test.py index 7aae9b8a60..869c85eb0b 100644 --- a/tensorflow/python/kernel_tests/py_func_test.py +++ b/tensorflow/python/kernel_tests/py_func_test.py @@ -283,21 +283,6 @@ class PyFuncTest(test.TestCase): z, = script_ops.py_func(unicode_string, [], [dtypes.string]) self.assertEqual(z.eval(), correct.encode("utf8")) - # TODO: This will no longer raise an exception since the byte-array - # will be converted into a float32 type. Is this not as desired? - # def testBadNumpyReturnType(self): - # with self.test_session(): - # - # def bad(): - # # Structured numpy arrays aren't supported. - # return np.array([], dtype=[("foo", np.float32)]) - # - # y, = script_ops.py_func(bad, [], [dtypes.float32]) - # - # with self.assertRaisesRegexp(errors.UnimplementedError, - # "Unsupported numpy type"): - # y.eval() - def testBadReturnType(self): with self.test_session(): -- GitLab From a8429ea5a842438228629e12e81d78f0104171be Mon Sep 17 00:00:00 2001 From: AG Ramesh Date: Tue, 24 Jul 2018 11:12:44 -0700 Subject: [PATCH 094/437] Call mkldnn's SGEMM if DO_NOT_USE_ML is defined. --- tensorflow/core/kernels/matmul_op.cc | 13 ++++++++++ tensorflow/core/kernels/mkl_matmul_op.cc | 30 +++++++++++++++++++++--- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/tensorflow/core/kernels/matmul_op.cc b/tensorflow/core/kernels/matmul_op.cc index 80376c61aa..c0bb9e5c50 100644 --- a/tensorflow/core/kernels/matmul_op.cc +++ b/tensorflow/core/kernels/matmul_op.cc @@ -591,6 +591,19 @@ TF_CALL_bfloat16(REGISTER_CPU); TF_CALL_int32(REGISTER_CPU); TF_CALL_complex64(REGISTER_CPU_EIGEN); TF_CALL_complex128(REGISTER_CPU_EIGEN); + +#elif defined(INTEL_MKL) && defined(DO_NOT_USE_ML) + +// MKL opensource supports only float for matrix-multiplication +TF_CALL_float(REGISTER_CPU_EIGEN); +TF_CALL_double(REGISTER_CPU); +TF_CALL_half(REGISTER_CPU); +TF_CALL_bfloat16(REGISTER_CPU); + +TF_CALL_int32(REGISTER_CPU); +TF_CALL_complex64(REGISTER_CPU); +TF_CALL_complex128(REGISTER_CPU); + #else TF_CALL_float(REGISTER_CPU); TF_CALL_double(REGISTER_CPU); diff --git a/tensorflow/core/kernels/mkl_matmul_op.cc b/tensorflow/core/kernels/mkl_matmul_op.cc index 62c0404891..26224ce0a9 100644 --- a/tensorflow/core/kernels/mkl_matmul_op.cc +++ b/tensorflow/core/kernels/mkl_matmul_op.cc @@ -23,14 +23,21 @@ limitations under the License. // and when it is undefined at build time, this file becomes an empty // compilation unit -#if defined(INTEL_MKL) && !defined(DO_NOT_USE_ML) -#include "mkl_cblas.h" +#if defined(INTEL_MKL) + #include "tensorflow/core/framework/op.h" #include "tensorflow/core/framework/op_kernel.h" #include "tensorflow/core/framework/register_types.h" #include "tensorflow/core/kernels/fill_functor.h" +//This header file is part of MKL ML, need equivalent file in MKL DNN +#ifndef DO_NOT_USE_ML +#include "mkl_cblas.h" +#else +#include "mkldnn.h" +#endif + namespace tensorflow { typedef Eigen::ThreadPoolDevice CPUDevice; @@ -100,7 +107,6 @@ class MklMatMulOp : public OpKernel { private: bool transpose_a_; bool transpose_b_; - // -------------------------------------------------------------------------- // // @brief Matrix-Matrix Multiplication with FP32 tensors, a, b, c using CBLAS @@ -150,11 +156,25 @@ class MklMatMulOp : public OpKernel { // 1.0 and 0.0 respectively. const float alpha = 1.0f; const float beta = 0.0f; +#if defined(DO_NOT_USE_ML) + const char* const ftrans[] = { "N", "T", "C"}; + int index_transa = transa? 1 : 0 ; + int index_transb = transb? 1 : 0 ; + VLOG(2) << "MKL DNN SGEMM called"; + //Using the fortran api of mkldnn + //Since TF is in row major layout,reversing the order of A and B + mkldnn_sgemm(ftrans[index_transb], ftrans[index_transa], + &n, &m, &k, &alpha, b, &ldb, a, &lda, &beta, c, &ldc); +#else cblas_sgemm(CblasRowMajor, transa ? CblasTrans : CblasNoTrans, transb ? CblasTrans : CblasNoTrans, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc); +#endif } + // MKLDNN only supports SGEMM +#ifndef DO_NOT_USE_ML + // Matrix-Matrix Multiplication with FP64 tensors. For detailed info about // parameters, look at FP32 function description. void MklBlasGemm(bool transa, bool transb, const int m, const int n, @@ -197,6 +217,7 @@ class MklMatMulOp : public OpKernel { reinterpret_cast(b), ldb, &beta, reinterpret_cast(c), ldc); } +#endif }; #define REGISTER_CPU(T) \ @@ -207,9 +228,12 @@ class MklMatMulOp : public OpKernel { // TODO(inteltf) Consider template specialization when adding/removing // additional types TF_CALL_float(REGISTER_CPU); + +#ifndef DO_NOT_USE_ML TF_CALL_double(REGISTER_CPU); TF_CALL_complex64(REGISTER_CPU); TF_CALL_complex128(REGISTER_CPU); +#endif } // namespace tensorflow #endif // INTEL_MKL -- GitLab From 1e33f539fcd430db7d61609c3c9aee13716380d3 Mon Sep 17 00:00:00 2001 From: AG Ramesh Date: Tue, 24 Jul 2018 11:19:17 -0700 Subject: [PATCH 095/437] Removed unnecessary comment --- tensorflow/core/kernels/mkl_matmul_op.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/tensorflow/core/kernels/mkl_matmul_op.cc b/tensorflow/core/kernels/mkl_matmul_op.cc index 26224ce0a9..e8166a1f7c 100644 --- a/tensorflow/core/kernels/mkl_matmul_op.cc +++ b/tensorflow/core/kernels/mkl_matmul_op.cc @@ -31,7 +31,6 @@ limitations under the License. #include "tensorflow/core/framework/register_types.h" #include "tensorflow/core/kernels/fill_functor.h" -//This header file is part of MKL ML, need equivalent file in MKL DNN #ifndef DO_NOT_USE_ML #include "mkl_cblas.h" #else -- GitLab From 80a27921a5fc782ab24eccac15aa0a47b8b670f7 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, 25 Jul 2018 13:28:16 +0800 Subject: [PATCH 096/437] CLN: use StrCat --- tensorflow/core/kernels/save_restore_tensor.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tensorflow/core/kernels/save_restore_tensor.cc b/tensorflow/core/kernels/save_restore_tensor.cc index a7d0523f87..11f3028ea0 100644 --- a/tensorflow/core/kernels/save_restore_tensor.cc +++ b/tensorflow/core/kernels/save_restore_tensor.cc @@ -258,10 +258,10 @@ Status RestoreTensorsV2(OpKernelContext* context, const Tensor& prefix, reader.LookupDtypeAndShape(tensor_name, &original_dtype, &restored_full_shape)); if (dtypes[i] != original_dtype) { - string error_msg = string("tensor_name = ") + tensor_name + - "; expected dtype " + DataTypeString(dtypes[i]) + - " does not equal original dtype " + - DataTypeString(original_dtype) + '\n'; + string error_msg = strings::StrCat( + "tensor_name = ", tensor_name, + "; expected dtype ", DataTypeString(dtypes[i]), + " does not equal original dtype ", DataTypeString(original_dtype)); mismatched_errors.emplace_back(error_msg); } } -- GitLab From 0b893a748e0e5f9c1d6b36490ed3eeb506ff2fbe 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, 25 Jul 2018 13:28:53 +0800 Subject: [PATCH 097/437] CLN: put original_dtype inside the loop --- tensorflow/core/kernels/save_restore_tensor.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/core/kernels/save_restore_tensor.cc b/tensorflow/core/kernels/save_restore_tensor.cc index 11f3028ea0..120bede469 100644 --- a/tensorflow/core/kernels/save_restore_tensor.cc +++ b/tensorflow/core/kernels/save_restore_tensor.cc @@ -250,9 +250,9 @@ Status RestoreTensorsV2(OpKernelContext* context, const Tensor& prefix, // TODO(zongheng): consider measuring speed and issuing concurrent lookups // within a fixed memory budget. TensorShape restored_full_shape; - DataType original_dtype; std::vector mismatched_errors; for (auto i : sorted_name_idx) { + DataType original_dtype; const string& tensor_name = tensor_names_flat(i); TF_RETURN_IF_ERROR( reader.LookupDtypeAndShape(tensor_name, -- GitLab From a6f5a803ee7bf9c8474049fd02e1f3d9698a2156 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, 25 Jul 2018 13:33:05 +0800 Subject: [PATCH 098/437] CLN: use str_util::Join --- tensorflow/core/kernels/save_restore_tensor.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tensorflow/core/kernels/save_restore_tensor.cc b/tensorflow/core/kernels/save_restore_tensor.cc index 120bede469..d4f70db9ba 100644 --- a/tensorflow/core/kernels/save_restore_tensor.cc +++ b/tensorflow/core/kernels/save_restore_tensor.cc @@ -24,6 +24,7 @@ limitations under the License. #include "tensorflow/core/framework/types.h" #include "tensorflow/core/kernels/bounds_check.h" #include "tensorflow/core/lib/gtl/array_slice.h" +#include "tensorflow/core/lib/strings/str_util.h" #include "tensorflow/core/lib/strings/strcat.h" #include "tensorflow/core/lib/strings/stringprintf.h" #include "tensorflow/core/platform/logging.h" @@ -266,9 +267,7 @@ Status RestoreTensorsV2(OpKernelContext* context, const Tensor& prefix, } } if (!mismatched_errors.empty()) { - string error_msg = std::accumulate(mismatched_errors.begin(), - mismatched_errors.end(), - string()); + const string error_msg = str_util::Join(mismatched_errors, "\n"); return errors::InvalidArgument(error_msg); } -- GitLab From 6d0022737a100d947722a1d21a62a492365ffb74 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, 25 Jul 2018 13:34:00 +0800 Subject: [PATCH 099/437] CLN: use size_t --- tensorflow/core/kernels/save_restore_tensor.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/core/kernels/save_restore_tensor.cc b/tensorflow/core/kernels/save_restore_tensor.cc index d4f70db9ba..b74a7cbc14 100644 --- a/tensorflow/core/kernels/save_restore_tensor.cc +++ b/tensorflow/core/kernels/save_restore_tensor.cc @@ -252,7 +252,7 @@ Status RestoreTensorsV2(OpKernelContext* context, const Tensor& prefix, // within a fixed memory budget. TensorShape restored_full_shape; std::vector mismatched_errors; - for (auto i : sorted_name_idx) { + for (size_t i : sorted_name_idx) { DataType original_dtype; const string& tensor_name = tensor_names_flat(i); TF_RETURN_IF_ERROR( -- GitLab From 41acd2461018e695154cd4beafc77499ea473646 Mon Sep 17 00:00:00 2001 From: drpngx Date: Wed, 25 Jul 2018 09:24:23 -0700 Subject: [PATCH 100/437] Const correct. --- tensorflow/core/kernels/save_restore_tensor.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/core/kernels/save_restore_tensor.cc b/tensorflow/core/kernels/save_restore_tensor.cc index b74a7cbc14..5036d9704b 100644 --- a/tensorflow/core/kernels/save_restore_tensor.cc +++ b/tensorflow/core/kernels/save_restore_tensor.cc @@ -96,7 +96,7 @@ void SaveTensors( return tensor_names_flat(a) < tensor_names_flat(b); }); - for (size_t i : sorted_name_idx) { + for (const size_t i : sorted_name_idx) { const string& name = tensor_names_flat(i); const Tensor& input = context->input(i + kFixedInputs); TensorShape shape(input.shape()); -- GitLab From bbff4eee4d8b37ec08678fdf0c749f658d4fad35 Mon Sep 17 00:00:00 2001 From: "Yuan, Man" Date: Thu, 26 Jul 2018 11:54:55 +0800 Subject: [PATCH 101/437] Fix typo: accidently -> accidentally. --- tensorflow/compiler/xla/service/layout_assignment.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/compiler/xla/service/layout_assignment.cc b/tensorflow/compiler/xla/service/layout_assignment.cc index 9705687b00..109a477a41 100644 --- a/tensorflow/compiler/xla/service/layout_assignment.cc +++ b/tensorflow/compiler/xla/service/layout_assignment.cc @@ -1563,7 +1563,7 @@ Status LayoutAssignment::ClearComputationLayouts(HloComputation* computation) { // and the computation result. The latter two are specified in // computation_layout, so we only need to keep the existing layouts for // infeeds. Clearing the layouts here avoids hiding potential bugs in the - // layout assignment pass that may accidently use the existing layout. + // layout assignment pass that may accidentally use the existing layout. for (HloInstruction* instruction : computation->instructions()) { if (instruction->opcode() == HloOpcode::kBitcast) { // bitcasts are inherently layout sensitive and so a bitcast instruction -- GitLab From 23f826271a5956982df17980bca3ac7513ec4ee4 Mon Sep 17 00:00:00 2001 From: Cao Zongyan Date: Thu, 26 Jul 2018 11:27:40 +0800 Subject: [PATCH 102/437] A faster BatchSelectFunctor for tf.where on CPU. Op 'tf.where(c, t, e)' supports that 't' and 'e' are N-D tensors while 'c' is a 1D tensor, which would call BatchSelectFunctor to get the result. But its basic implementation broadcasts 'c' to the same dimension with 't' and 'e', which would get bad efficiency on CPU for large tensors. Here a loop-based implementation would be adopted to make this operation faster on CPU. --- tensorflow/core/kernels/cwise_op_select.cc | 42 ++++++++++++++++++- .../python/kernel_tests/where_op_test.py | 37 ++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/tensorflow/core/kernels/cwise_op_select.cc b/tensorflow/core/kernels/cwise_op_select.cc index e259daaba4..0d6d83fc3a 100644 --- a/tensorflow/core/kernels/cwise_op_select.cc +++ b/tensorflow/core/kernels/cwise_op_select.cc @@ -22,6 +22,7 @@ limitations under the License. #include "tensorflow/core/framework/register_types.h" #include "tensorflow/core/kernels/bounds_check.h" #include "tensorflow/core/kernels/cwise_ops_common.h" +#include "tensorflow/core/platform/prefetch.h" namespace tensorflow { @@ -254,9 +255,48 @@ struct BatchSelectFunctorBase { } }; +// A fast implementation on CPU, using loop to get rid of broadcasting. template -struct BatchSelectFunctor : BatchSelectFunctorBase { +struct BatchSelectFunctor { + void operator()(const CPUDevice& d, + typename TTypes::Matrix output_flat_outer_dims, + TTypes::ConstVec cond_vec, + typename TTypes::ConstMatrix then_flat_outer_dims, + typename TTypes::ConstMatrix else_flat_outer_dims) { + const size_t batch = cond_vec.size(); + const size_t batch_size = then_flat_outer_dims.size() / batch; + T* output = output_flat_outer_dims.data(); + const bool* c = cond_vec.data(); + const T* t = then_flat_outer_dims.data(); + const T* e = else_flat_outer_dims.data(); + + auto work = [batch_size, output, c, t, e](int64 start, int64 end) { + for (size_t i = start; i < end; ++i) { + size_t offset = i * batch_size; + port::prefetch( + reinterpret_cast(&t[offset + batch_size])); + port::prefetch( + reinterpret_cast(&e[offset + batch_size])); + port::prefetch( + reinterpret_cast(&c[i + 1])); + if (c[i]) { + for (size_t j = 0; j < batch_size; ++j) { + output[offset + j] = t[offset + j]; + } + } else { + for (size_t j = 0; j < batch_size; ++j) { + output[offset + j] = e[offset + j]; + } + } + } + }; + auto cost = Eigen::TensorOpCost(sizeof(T) * batch_size * 2, // ld bytes + sizeof(T) * batch_size, // st bytes + batch_size); // compute cycles + d.parallelFor(batch, cost, work); + } }; + #ifdef TENSORFLOW_USE_SYCL template struct BatchSelectFunctor diff --git a/tensorflow/python/kernel_tests/where_op_test.py b/tensorflow/python/kernel_tests/where_op_test.py index 17575da6f1..53324d5b20 100644 --- a/tensorflow/python/kernel_tests/where_op_test.py +++ b/tensorflow/python/kernel_tests/where_op_test.py @@ -135,6 +135,15 @@ class WhereOpTest(test.TestCase): tf_val = array_ops.where(constant_op.constant(x) > 0, x * x, -x).eval() self.assertAllEqual(tf_val, np_val) + def testBatchSelect(self): + x = np.array([[-2, 3, -1] * 64, [1, -3, -3] * 64] * 8192) # [16384, 192] + c_mat = np.array([[False] * 192, [True] * 192] * 8192) # [16384, 192] + c_vec = np.array([False, True] * 8192) # [16384] + np_val = np.where(c_mat, x * x, -x) + for use_gpu in [True, False]: + with self.test_session(use_gpu=use_gpu): + tf_val = array_ops.where(c_vec, x * x, -x).eval() + self.assertAllEqual(tf_val, np_val) class WhereBenchmark(test.Benchmark): @@ -163,5 +172,33 @@ class WhereBenchmark(test.Benchmark): "Throughput: %0.03g GB/s" % (name, r["wall_time"], throughput)) sys.stdout.flush() + def benchmarkBatchSelect(self): + for (m, n, use_gpu) in itertools.product( + [1000, 10000, 100000], + [10, 100, 1000], + [False, True]): + name = "m_%d_n_%d_use_gpu_%s" % (m, n, use_gpu) + device = "/%s:0" % ("gpu" if use_gpu else "cpu") + with ops.Graph().as_default(): + with ops.device(device): + x_gen = random_ops.random_uniform([m, n], dtype=dtypes.float32) + y_gen = random_ops.random_uniform([m, n], dtype=dtypes.float32) + c_gen = random_ops.random_uniform([m], dtype=dtypes.float32) <= 0.5 + x = resource_variable_ops.ResourceVariable(x_gen) + y = resource_variable_ops.ResourceVariable(y_gen) + c = resource_variable_ops.ResourceVariable(c_gen) + op = array_ops.where(c, x, y) + with session.Session() as sess: + x.initializer.run() + y.initializer.run() + c.initializer.run() + r = self.run_op_benchmark(sess, op, min_iters=100, name=name) + # approximate size of output: m*n*2 floats for each axis. + gb_processed = m * n * 8 / 1.0e9 + throughput = gb_processed / r["wall_time"] + print("Benchmark: %s \t wall_time: %0.03g s \t " + "Throughput: %0.03g GB/s" % (name, r["wall_time"], throughput)) + sys.stdout.flush() + if __name__ == "__main__": test.main() -- GitLab From 141fe1e7dccd97c99a60bbabfd1e8c52a7d3348a Mon Sep 17 00:00:00 2001 From: Yoshihiro Yamazaki Date: Thu, 26 Jul 2018 15:48:39 +0900 Subject: [PATCH 103/437] $ mogrify +matte tensorflow/core/lib/png/testdata/lena_palette.png (remove tRNS chunk) --- .../core/lib/png/testdata/lena_palette.png | Bin 1368 -> 1355 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/tensorflow/core/lib/png/testdata/lena_palette.png b/tensorflow/core/lib/png/testdata/lena_palette.png index c298fee9fffdbd0b1848001b407cc2cbb1c7af83..d19ec04895d67f674a01b64e8af62c6bf3f4e83a 100644 GIT binary patch delta 88 zcmcb?b((9#bH>SE7&SQArT8`V|B27@-K@&=kV(|YEX2^%%EZvh)Kc5P(#pV~@R6(Y hWNB6@WpiD)oQXL^ZjM%)4FdxMgQu&X%Q~loCIE}F7&ia_ delta 98 zcmX@jb%Sfeb4JdRAirP+hi5m^CO>A>;bh}yvl6Iz;a;#=g6ScXsG)g?p|O>Lk(H^X zwt=OUfkC Date: Thu, 26 Jul 2018 01:42:58 +0200 Subject: [PATCH 104/437] [CMake] tf_tests.cmake | Add CheckExists --- tensorflow/contrib/cmake/tf_tests.cmake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tensorflow/contrib/cmake/tf_tests.cmake b/tensorflow/contrib/cmake/tf_tests.cmake index b2330c4e34..4ad9a20e3f 100644 --- a/tensorflow/contrib/cmake/tf_tests.cmake +++ b/tensorflow/contrib/cmake/tf_tests.cmake @@ -122,6 +122,17 @@ function(AddPythonTests) endforeach() endfunction(AddPythonTests) +# +# ensure that every element is an existing file +# +function(CheckExists TYPE SOURCES) + foreach(source ${SOURCES}) + if(NOT EXISTS ${source}) + message(SEND_ERROR "${TYPE} not found: ${source}") + endif() + endforeach(source) +endfunction(CheckExists) + if (tensorflow_BUILD_PYTHON_TESTS) # # python tests. This assumes that the tensorflow wheel is @@ -329,6 +340,7 @@ if (tensorflow_BUILD_PYTHON_TESTS) "${tensorflow_source_dir}/tensorflow/python/keras/_impl/keras/utils/io_utils_test.py" # b/72894325 ) endif() + CheckExists(${tf_test_src_py_exclude}) list(REMOVE_ITEM tf_test_src_py ${tf_test_src_py_exclude}) AddPythonTests( @@ -480,6 +492,7 @@ if (tensorflow_BUILD_CC_TESTS) "${tensorflow_source_dir}/tensorflow/cc/saved_model/*_test.cc" ) + CheckExists(${tf_test_src_simple_exclude}) list(REMOVE_ITEM tf_test_src_simple ${tf_test_src_simple_exclude} ${tf_cc_saved_model_test_srcs} @@ -494,6 +507,7 @@ if (tensorflow_BUILD_CC_TESTS) ${tf_core_profiler_test_srcs} ) + CheckExists(${tf_src_testlib}) set(tf_test_lib tf_test_lib) add_library(${tf_test_lib} STATIC ${tf_src_testlib}) -- GitLab From 6085e672f927184d8af0b7e82d47f929f525c886 Mon Sep 17 00:00:00 2001 From: Robin Richtsfeld Date: Thu, 26 Jul 2018 01:51:50 +0200 Subject: [PATCH 105/437] [CMake] tf_tests.cmake | Fix invalid entries --- tensorflow/contrib/cmake/tf_tests.cmake | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tensorflow/contrib/cmake/tf_tests.cmake b/tensorflow/contrib/cmake/tf_tests.cmake index 4ad9a20e3f..2c878c1716 100644 --- a/tensorflow/contrib/cmake/tf_tests.cmake +++ b/tensorflow/contrib/cmake/tf_tests.cmake @@ -156,7 +156,6 @@ if (tensorflow_BUILD_PYTHON_TESTS) "${tensorflow_source_dir}/tensorflow/python/debug/wrappers/*_test.py" "${tensorflow_source_dir}/tensorflow/contrib/estimator/python/estimator/*_test.py" "${tensorflow_source_dir}/tensorflow/python/kernel_tests/*.py" - "${tensorflow_source_dir}/tensorflow/python/meta_graph_transform/*_test.py" "${tensorflow_source_dir}/tensorflow/python/ops/quantized_conv_ops_test.py" "${tensorflow_source_dir}/tensorflow/python/ops/quantized_ops_test.py" "${tensorflow_source_dir}/tensorflow/python/platform/build_info_test.py" @@ -209,7 +208,6 @@ if (tensorflow_BUILD_PYTHON_TESTS) "${tensorflow_source_dir}/tensorflow/python/saved_model/saved_model_test.py" "${tensorflow_source_dir}/tensorflow/contrib/image/python/kernel_tests/sparse_image_warp_test.py" # requires scipy - "${tensorflow_source_dir}/tensorflow/contrib/keras/python/keras/preprocessing/*_test.py" "${tensorflow_source_dir}/tensorflow/contrib/tfprof/python/tools/tfprof/pprof_profiler_test.py" "${tensorflow_source_dir}/tensorflow/contrib/image/python/kernel_tests/interpolate_spline_test.py" # Takes very long to run without sharding (defined in bazel build file). @@ -267,10 +265,9 @@ if (tensorflow_BUILD_PYTHON_TESTS) # Flaky because of local cluster creation. "${tensorflow_source_dir}/tensorflow/python/training/sync_replicas_optimizer_test.py" "${tensorflow_source_dir}/tensorflow/python/debug/lib/session_debug_grpc_test.py" - "${tensorflow_source_dir}tensorflow/python/training/localhost_cluster_performance_test.py" + "${tensorflow_source_dir}/tensorflow/python/training/localhost_cluster_performance_test.py" "${tensorflow_source_dir}/tensorflow/python/data/kernel_tests/iterator_ops_cluster_test.py" "${tensorflow_source_dir}/tensorflow/python/kernel_tests/functional_ops_test.py" - "${tensorflow_source_dir}/tensorflow/contrib/data/python/kernel_tests/iterator_ops_cluster_test.py" # Type error in testRemoteIteratorUsingRemoteCallOpDirectSessionGPUCPU. "${tensorflow_source_dir}/tensorflow/python/data/kernel_tests/iterator_ops_test.py" "${tensorflow_source_dir}/tensorflow/python/kernel_tests/self_adjoint_eig_op_test.py" -- GitLab From 64994e5eb05c262ae1aef9480c54e0f992833b02 Mon Sep 17 00:00:00 2001 From: Clayne Robison Date: Thu, 26 Jul 2018 15:43:21 -0700 Subject: [PATCH 106/437] [Intel MKL] Adding support for MPI and Horovod to MKL containers --- .../tools/docker/Dockerfile.devel-mkl-horovod | 166 ++++++++++++++++++ .../tools/docker/Dockerfile.mkl-horovod | 109 ++++++++++++ .../docker/parameterized_docker_build.sh | 34 +++- 3 files changed, 301 insertions(+), 8 deletions(-) create mode 100755 tensorflow/tools/docker/Dockerfile.devel-mkl-horovod create mode 100755 tensorflow/tools/docker/Dockerfile.mkl-horovod diff --git a/tensorflow/tools/docker/Dockerfile.devel-mkl-horovod b/tensorflow/tools/docker/Dockerfile.devel-mkl-horovod new file mode 100755 index 0000000000..cf69fb9033 --- /dev/null +++ b/tensorflow/tools/docker/Dockerfile.devel-mkl-horovod @@ -0,0 +1,166 @@ +FROM ubuntu:16.04 + +LABEL maintainer="Cong Xu " + +# These parameters can be overridden by parameterized_docker_build.sh +ARG TF_BUILD_VERSION=r1.9 +ARG PYTHON="python" +ARG PYTHON3_DEV="" +ARG WHL_DIR="/tmp/pip" +ARG PIP="pip" + +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + curl \ + git \ + libcurl3-dev \ + libfreetype6-dev \ + libhdf5-serial-dev \ + libpng12-dev \ + libzmq3-dev \ + pkg-config \ + python-dev \ + ${PYTHON3_DEV} \ + rsync \ + software-properties-common \ + unzip \ + zip \ + zlib1g-dev \ + openjdk-8-jdk \ + openjdk-8-jre-headless \ + wget \ + numactl \ + openssh-client \ + openssh-server \ + && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +RUN curl -fSsL -O https://bootstrap.pypa.io/get-pip.py && \ + ${PYTHON} get-pip.py && \ + rm get-pip.py + +RUN ${PIP} --no-cache-dir install \ + Pillow \ + h5py \ + ipykernel \ + jupyter \ + matplotlib \ + mock \ + numpy \ + scipy \ + sklearn \ + pandas \ + && \ + ${PYTHON} -m ipykernel.kernelspec + +RUN if [ "${PYTHON}" = "python3" ]; then \ + ln -s -f /usr/bin/python3 /usr/bin/python; \ + fi + +# Set up our notebook config. +COPY jupyter_notebook_config.py /root/.jupyter/ + +# Jupyter has issues with being run directly: +# https://github.com/ipython/ipython/issues/7062 +# We just add a little wrapper script. +COPY run_jupyter.sh / + +# Set up Bazel. + +# Running bazel inside a `docker build` command causes trouble, cf: +# https://github.com/bazelbuild/bazel/issues/134 +# The easiest solution is to set up a bazelrc file forcing --batch. +RUN echo "startup --batch" >>/etc/bazel.bazelrc +# Similarly, we need to workaround sandboxing issues: +# https://github.com/bazelbuild/bazel/issues/418 +RUN echo "build --spawn_strategy=standalone --genrule_strategy=standalone" \ + >>/etc/bazel.bazelrc +# Install the most recent bazel release. +ENV BAZEL_VERSION 0.15.0 +WORKDIR / +RUN mkdir /bazel && \ + cd /bazel && \ + curl -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" -fSsL -O https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \ + curl -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" -fSsL -o /bazel/LICENSE.txt https://raw.githubusercontent.com/bazelbuild/bazel/master/LICENSE && \ + chmod +x bazel-*.sh && \ + ./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \ + cd / && \ + rm -f /bazel/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh + +# Download and build TensorFlow. +WORKDIR /tensorflow + +# Download and build TensorFlow. +# Enable checking out both tags and branches +RUN export TAG_PREFIX="v" && \ + echo ${TF_BUILD_VERSION} | grep -q ^${TAG_PREFIX}; \ + if [ $? -eq 0 ]; then \ + git clone --depth=1 https://github.com/tensorflow/tensorflow.git . && \ + git fetch --tags && \ + git checkout ${TF_BUILD_VERSION}; \ + else \ + git clone --depth=1 --branch=${TF_BUILD_VERSION} https://github.com/tensorflow/tensorflow.git . ; \ + fi + +RUN yes "" | ${PYTHON} configure.py + +ENV CI_BUILD_PYTHON ${PYTHON} + +# Set bazel build parameters in .bazelrc in parameterized_docker_build.sh +# Use --copt=-march values to get optimized builds appropriate for the hardware +# platform of your choice. +# For ivy-bridge or sandy-bridge +# --copt=-march="avx" \ +# For haswell, broadwell, or skylake +# --copt=-march="avx2" \ +COPY .bazelrc /root/.bazelrc + +RUN tensorflow/tools/ci_build/builds/configured CPU \ + bazel --bazelrc=/root/.bazelrc build -c opt \ + tensorflow/tools/pip_package:build_pip_package && \ + bazel-bin/tensorflow/tools/pip_package/build_pip_package "${WHL_DIR}" && \ + ${PIP} --no-cache-dir install --upgrade "${WHL_DIR}"/tensorflow-*.whl && \ + rm -rf /root/.cache +# Clean up Bazel cache when done. + +WORKDIR /root + +# Install Open MPI +RUN mkdir /tmp/openmpi && \ + cd /tmp/openmpi && \ + wget https://www.open-mpi.org/software/ompi/v3.0/downloads/openmpi-3.0.0.tar.gz && \ + tar zxf openmpi-3.0.0.tar.gz && \ + cd openmpi-3.0.0 && \ + ./configure --enable-orterun-prefix-by-default && \ + make -j $(nproc) all && \ + make install && \ + ldconfig && \ + rm -rf /tmp/openmpi + +# Create a wrapper for OpenMPI to allow running as root by default +RUN mv /usr/local/bin/mpirun /usr/local/bin/mpirun.real && \ + echo '#!/bin/bash' > /usr/local/bin/mpirun && \ + echo 'mpirun.real --allow-run-as-root "$@"' >> /usr/local/bin/mpirun && \ + chmod a+x /usr/local/bin/mpirun + +# Configure OpenMPI to run good defaults: +RUN echo "btl_tcp_if_exclude = lo,docker0" >> /usr/local/etc/openmpi-mca-params.conf + +# Install Horovod +RUN ${PIP} install --no-cache-dir horovod + +# Install OpenSSH for MPI to communicate between containers +RUN mkdir -p /var/run/sshd + +# Allow OpenSSH to talk to containers without asking for confirmation +RUN cat /etc/ssh/ssh_config | grep -v StrictHostKeyChecking > /etc/ssh/ssh_config.new && \ + echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config.new && \ + mv /etc/ssh/ssh_config.new /etc/ssh/ssh_config + +# TensorBoard +EXPOSE 6006 +# IPython +EXPOSE 8888 + +WORKDIR /root diff --git a/tensorflow/tools/docker/Dockerfile.mkl-horovod b/tensorflow/tools/docker/Dockerfile.mkl-horovod new file mode 100755 index 0000000000..9485a5bff6 --- /dev/null +++ b/tensorflow/tools/docker/Dockerfile.mkl-horovod @@ -0,0 +1,109 @@ +FROM ubuntu:16.04 + +LABEL maintainer="Cong Xu " + +# This parameter MUST be set by parameterized_docker_build.sh +ARG TF_WHL_URL + +# Optional parameters +ARG TF_BUILD_VERSION=r1.9 +ARG PYTHON="python" +ARG PYTHON_DEV="python-dev" +ARG PIP="pip" + +# Pick up some TF dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + curl \ + libfreetype6-dev \ + libhdf5-serial-dev \ + libpng12-dev \ + libzmq3-dev \ + pkg-config \ + python \ + ${PYTHON_DEV} \ + rsync \ + software-properties-common \ + unzip \ + && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +RUN curl -O https://bootstrap.pypa.io/get-pip.py && \ + python get-pip.py && \ + rm get-pip.py + +RUN ${PIP} --no-cache-dir install \ + Pillow \ + h5py \ + ipykernel \ + jupyter \ + matplotlib \ + numpy \ + pandas \ + scipy \ + sklearn \ + && \ + python -m ipykernel.kernelspec + +COPY ${TF_WHL_URL} / +RUN ${PIP} install --no-cache-dir --force-reinstall /${TF_WHL_URL} && \ + rm -rf /${TF_WHL_URL} + +RUN if [ "${PYTHON}" = "python3" ]; then \ + ln -s -f /usr/bin/python3 /usr/bin/python; \ + fi + +# Set up our notebook config. +COPY jupyter_notebook_config.py /root/.jupyter/ + +# Copy sample notebooks. +COPY notebooks /notebooks + +# Jupyter has issues with being run directly: +# https://github.com/ipython/ipython/issues/7062 +# We just add a little wrapper script. +COPY run_jupyter.sh / + +WORKDIR /root + +# Install Open MPI +RUN mkdir /tmp/openmpi && \ + cd /tmp/openmpi && \ + wget https://www.open-mpi.org/software/ompi/v3.0/downloads/openmpi-3.0.0.tar.gz && \ + tar zxf openmpi-3.0.0.tar.gz && \ + cd openmpi-3.0.0 && \ + ./configure --enable-orterun-prefix-by-default && \ + make -j $(nproc) all && \ + make install && \ + ldconfig && \ + rm -rf /tmp/openmpi + +# Create a wrapper for OpenMPI to allow running as root by default +RUN mv /usr/local/bin/mpirun /usr/local/bin/mpirun.real && \ + echo '#!/bin/bash' > /usr/local/bin/mpirun && \ + echo 'mpirun.real --allow-run-as-root "$@"' >> /usr/local/bin/mpirun && \ + chmod a+x /usr/local/bin/mpirun + +# Configure OpenMPI to run good defaults: +RUN echo "btl_tcp_if_exclude = lo,docker0" >> /usr/local/etc/openmpi-mca-params.conf + +# Install Horovod +RUN ${PIP} install --no-cache-dir horovod + +# Install OpenSSH for MPI to communicate between containers +RUN mkdir -p /var/run/sshd + +# Allow OpenSSH to talk to containers without asking for confirmation +RUN cat /etc/ssh/ssh_config | grep -v StrictHostKeyChecking > /etc/ssh/ssh_config.new && \ + echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config.new && \ + mv /etc/ssh/ssh_config.new /etc/ssh/ssh_config + +# TensorBoard +EXPOSE 6006 +# IPython +EXPOSE 8888 + +WORKDIR "/notebooks" + +CMD ["/run_jupyter.sh", "--allow-root"] diff --git a/tensorflow/tools/docker/parameterized_docker_build.sh b/tensorflow/tools/docker/parameterized_docker_build.sh index 4681c5fd61..04fc1659af 100755 --- a/tensorflow/tools/docker/parameterized_docker_build.sh +++ b/tensorflow/tools/docker/parameterized_docker_build.sh @@ -19,8 +19,8 @@ # parameterized_docker_build.sh # # The script obeys the following environment variables: -# TF_DOCKER_BUILD_TYPE: (CPU | GPU | MKL) -# CPU, GPU, or MKL image +# TF_DOCKER_BUILD_TYPE: (CPU | GPU | MKL | MKL-HOROVOD) +# CPU, GPU, MKL or MKL-HOROVOD image # # TF_DOCKER_BUILD_IS_DEVEL: (NO | YES) # Is this developer image @@ -169,6 +169,15 @@ elif [[ ${TF_DOCKER_BUILD_TYPE} == "mkl" ]]; then else ORIG_DOCKERFILE="${ORIG_DOCKERFILE}.mkl" fi +elif [[ ${TF_DOCKER_BUILD_TYPE} == "mkl-horovod" ]]; then + DOCKER_BINARY="docker" + FINAL_TAG="${FINAL_TAG}-mkl-horovod" + if [[ ${ORIG_DOCKERFILE} == *"."* ]]; then + # There is already a dot in the tag, use "-" + ORIG_DOCKERFILE="${ORIG_DOCKERFILE}-mkl-horovod" + else + ORIG_DOCKERFILE="${ORIG_DOCKERFILE}.mkl-horovod" + fi elif [[ ${TF_DOCKER_BUILD_TYPE} == "gpu" ]]; then DOCKER_BINARY="nvidia-docker" @@ -227,6 +236,10 @@ if [[ "${TF_DOCKER_BUILD_IS_DEVEL}" == "no" ]]; then die "FAIL: Non-development MKL builds require a pre-built pip whl." fi + if [[ "${TF_DOCKER_BUILD_TYPE}" == "mkl-horovod" ]]; then + die "FAIL: Non-development MKL-HOROVOD builds require a pre-built pip whl." + fi + if [[ "${TF_DOCKER_BUILD_TYPE}" == "gpu" ]]; then export TF_BUILD_APPEND_CI_DOCKER_EXTRA_PARAMS=\ "${TF_BUILD_APPEND_CI_DOCKER_EXTRA_PARAMS} -e TF_CUDA_COMPUTE_CAPABILITIES=3.0,3.5,5.2" @@ -279,7 +292,8 @@ if [[ "${TF_DOCKER_BUILD_IS_DEVEL}" == "no" ]]; then # Use string replacement to put the correct file name into the Dockerfile PIP_WHL=$(basename "${PIP_WHL}") - if [[ ${TF_DOCKER_BUILD_TYPE} == "mkl" ]]; then + if [[ ${TF_DOCKER_BUILD_TYPE} == "mkl" ]] || \ + [[ ${TF_DOCKER_BUILD_TYPE} == "mkl-horovod" ]]; then TF_DOCKER_BUILD_ARGS+=("--build-arg TF_WHL_URL=${PIP_WHL}" ) cp "${ORIG_DOCKERFILE}" "${DOCKERFILE}" else @@ -295,7 +309,8 @@ if [[ "${TF_DOCKER_BUILD_IS_DEVEL}" == "no" ]]; then echo else echo "Downloading pip wheel from: ${TF_DOCKER_BUILD_CENTRAL_PIP}" - if [[ ${TF_DOCKER_BUILD_TYPE} == "mkl" ]]; then + if [[ ${TF_DOCKER_BUILD_TYPE} == "mkl" ]] || \ + [[ ${TF_DOCKER_BUILD_TYPE} == "mkl-horovod" ]]; then pushd "${TMP_DIR}/" curl -O ${TF_DOCKER_BUILD_CENTRAL_PIP} popd @@ -319,7 +334,8 @@ if [[ "${TF_DOCKER_BUILD_IS_DEVEL}" == "no" ]]; then # Modify python/pip version if necessary. if [[ "${TF_DOCKER_BUILD_PYTHON_VERSION}" == "python3" ]]; then - if [[ ${TF_DOCKER_BUILD_TYPE} == "mkl" ]]; then + if [[ ${TF_DOCKER_BUILD_TYPE} == "mkl" ]] || \ + [[ ${TF_DOCKER_BUILD_TYPE} == "mkl-horovod" ]]; then TF_DOCKER_BUILD_ARGS+=("--build-arg PYTHON=${TF_DOCKER_BUILD_PYTHON_VERSION}") TF_DOCKER_BUILD_ARGS+=("--build-arg PYTHON_DEV=python3-dev") TF_DOCKER_BUILD_ARGS+=("--build-arg PIP=pip3") @@ -340,8 +356,9 @@ if [[ "${TF_DOCKER_BUILD_IS_DEVEL}" == "no" ]]; then else # TF_DOCKER_BUILD_IS_DEVEL == 'yes' DOCKERFILE="${TMP_DIR}/Dockerfile" - # Set up Dockerfile ARGS for mkl build - if [[ ${TF_DOCKER_BUILD_TYPE} == "mkl" ]]; then + # Set up Dockerfile ARGS for mkl and mkl-horovod build + if [[ ${TF_DOCKER_BUILD_TYPE} == "mkl" ]] || \ + [[ ${TF_DOCKER_BUILD_TYPE} == "mkl-horovod" ]]; then if [[ -z "${TF_BAZEL_BUILD_OPTIONS// }" ]]; then TF_BAZEL_BUILD_OPTIONS=("--config=mkl --copt=-mavx --cxxopt=-D_GLIBCXX_USE_CXX11_ABI=0") else @@ -361,7 +378,8 @@ else # TF_DOCKER_BUILD_IS_DEVEL == 'yes' # Modify python/pip version if necessary. if [[ "${TF_DOCKER_BUILD_PYTHON_VERSION}" == "python3" ]]; then - if [[ ${TF_DOCKER_BUILD_TYPE} == "mkl" ]]; then + if [[ ${TF_DOCKER_BUILD_TYPE} == "mkl" ]] || \ + [[ ${TF_DOCKER_BUILD_TYPE} == "mkl-horovod" ]]; then TF_DOCKER_BUILD_ARGS+=("--build-arg PYTHON=${TF_DOCKER_BUILD_PYTHON_VERSION}") TF_DOCKER_BUILD_ARGS+=("--build-arg PYTHON3_DEV=python3-dev") TF_DOCKER_BUILD_ARGS+=("--build-arg WHL_DIR=/tmp/pip3") -- GitLab From 042336cfa7b1d4c600d3a09f65d517dd5ff73904 Mon Sep 17 00:00:00 2001 From: Taehoon Lee Date: Fri, 27 Jul 2018 20:54:09 +0900 Subject: [PATCH 107/437] Resolve a merge conflict --- tensorflow/python/training/checkpoint_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/python/training/checkpoint_utils.py b/tensorflow/python/training/checkpoint_utils.py index 4752b9dce6..883f4fd910 100644 --- a/tensorflow/python/training/checkpoint_utils.py +++ b/tensorflow/python/training/checkpoint_utils.py @@ -316,7 +316,7 @@ def _set_checkpoint_initializer(variable, # pylint:disable=protected-access # We need special handling for `DistributedVariable`s as they contain - # multiple actual variables. `assign` on a `DistributedVariable` returns a + # mutliple actual variables. `assign` on a `DistributedVariable` returns a # combined `init_op` which contains initializers for all the contained # variables. We then set each underlying variable's `_initializer_op` using # the corresponding `init_op`. -- GitLab From 3d1f89ce1fbbe656fa7fd711d964080f88688966 Mon Sep 17 00:00:00 2001 From: Matt Dodge Date: Fri, 27 Jul 2018 12:50:09 -0700 Subject: [PATCH 108/437] Use correct hash_bucket_size parameter `s/hash_buckets_size/hash_bucket_size/` since that is the correct argument spelling for the Python method. --- tensorflow/docs_src/guide/feature_columns.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow/docs_src/guide/feature_columns.md b/tensorflow/docs_src/guide/feature_columns.md index 41080e050b..38760df82b 100644 --- a/tensorflow/docs_src/guide/feature_columns.md +++ b/tensorflow/docs_src/guide/feature_columns.md @@ -289,7 +289,7 @@ pseudocode: ```python # pseudocode -feature_id = hash(raw_feature) % hash_buckets_size +feature_id = hash(raw_feature) % hash_bucket_size ``` The code to create the `feature_column` might look something like this: @@ -298,7 +298,7 @@ The code to create the `feature_column` might look something like this: hashed_feature_column = tf.feature_column.categorical_column_with_hash_bucket( key = "some_feature", - hash_buckets_size = 100) # The number of categories + hash_bucket_size = 100) # The number of categories ``` At this point, you might rightfully think: "This is crazy!" After all, we are forcing the different input values to a smaller set of categories. This means -- GitLab From 22d32216ef7de874c338ce1e531a3879abb2a25b Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 28 Jul 2018 02:50:26 -0400 Subject: [PATCH 109/437] Add MKL to PATH in CMake --- tensorflow/contrib/cmake/tf_python.cmake | 93 ++++++++++-------------- 1 file changed, 38 insertions(+), 55 deletions(-) diff --git a/tensorflow/contrib/cmake/tf_python.cmake b/tensorflow/contrib/cmake/tf_python.cmake index 32b185f07b..01d2c442b4 100755 --- a/tensorflow/contrib/cmake/tf_python.cmake +++ b/tensorflow/contrib/cmake/tf_python.cmake @@ -198,7 +198,7 @@ function(add_python_module MODULE_NAME) # so we currently add explicit commands to include those files # later on in this script. if (NOT "${script}" MATCHES "_test\.py$") - add_custom_command(TARGET tf_python_copy_scripts_to_destination PRE_BUILD + add_custom_command(TARGET tf_python_copy_scripts_to_destination PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${tensorflow_source_dir}/${script} ${CMAKE_CURRENT_BINARY_DIR}/tf_python/${script}) endif() endforeach() @@ -297,7 +297,7 @@ function(GENERATE_PYTHON_OP_LIB tf_python_op_lib_name) ) target_link_libraries(${tf_python_op_lib_name}_gen_python PRIVATE tf_protos_cc - tf_python_protos_cc + tf_python_protos_cc ${tensorflow_EXTERNAL_LIBRARIES} ) @@ -549,15 +549,15 @@ if(WIN32) ${NUMPY_INCLUDE_DIR} ) #target_link_libraries(pywrap_tensorflow_internal_static - # tf_protos_cc - # tf_python_protos_cc + # tf_protos_cc + # tf_python_protos_cc #) add_dependencies(pywrap_tensorflow_internal_static tf_protos_cc tf_python_protos_cc) set(pywrap_tensorflow_internal_static_dependencies $ $ $ - ${nsync_STATIC_LIBRARIES} + ${nsync_STATIC_LIBRARIES} ) if(${CMAKE_GENERATOR} MATCHES "Visual Studio.*") @@ -763,57 +763,40 @@ file(WRITE "${api_init_list_file}" "${api_init_files}") # recongnize paths. As CUDA isn't built with MKL, the MKL built directory is the only path to this command to work around that issue. # To not override the CUDA and system path in other circumstances, `if-else` branch used here to handle this problem, # and should be removed if the path issue can be resolved. +# UPDATE: Below block appears to handle multiple items in PATH correctly, but risks command line limits if PATH is large. +# If you have issues, try `set(PY_RUNTIME_ENV "PATH=${mkl_BIN_DIRS}")` instead. ### -if (tensorflow_ENABLE_MKL_SUPPORT) +set(PY_RUNTIME_ENV "") +if(tensorflow_ENABLE_MKL_SUPPORT) # add mkl dist dlls to system path for python - # TODO: In current cmake version, PY_RUNTIME_ENV behaves strange with multiple paths, - # so we have to specify only one path in it to work around the issue. We need this if/else - # to protect overwriting CUDA environments - set(PY_RUNTIME_ENV ${mkl_BIN_DIRS}) - add_custom_command( - OUTPUT ${api_init_files} - DEPENDS tf_python_ops tf_python_copy_scripts_to_destination pywrap_tensorflow_internal tf_python_touchup_modules tf_extension_ops - - # tensorflow/__init__.py depends on files generated in this step. So, remove it while - # this step is running since the files aren't there yet. - COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_CURRENT_BINARY_DIR}/tf_python/tensorflow/__init__.py - - # Run create_python_api.py to generate API init files. - COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/tf_python PATH=${PY_RUNTIME_ENV} ${PYTHON_EXECUTABLE} - "${CMAKE_CURRENT_BINARY_DIR}/tf_python/tensorflow/python/tools/api/generator/create_python_api.py" - "--root_init_template=${CMAKE_CURRENT_BINARY_DIR}/tf_python/tensorflow/api_template.__init__.py" - "--apidir=${CMAKE_CURRENT_BINARY_DIR}/tf_python/tensorflow" - "--package=tensorflow.python" - "--apiname=tensorflow" - "${api_init_list_file}" - - COMMENT "Generating __init__.py files for Python API." - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tf_python" - VERBATIM - ) -else (tensorflow_ENABLE_MKL_SUPPORT) - add_custom_command( - OUTPUT ${api_init_files} - DEPENDS tf_python_ops tf_python_copy_scripts_to_destination pywrap_tensorflow_internal tf_python_touchup_modules tf_extension_ops - - # tensorflow/__init__.py depends on files generated in this step. So, remove it while - # this step is running since the files aren't there yet. - COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_CURRENT_BINARY_DIR}/tf_python/tensorflow/__init__.py - - # Run create_python_api.py to generate API init files. - COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/tf_python ${PYTHON_EXECUTABLE} - "${CMAKE_CURRENT_BINARY_DIR}/tf_python/tensorflow/python/tools/api/generator/create_python_api.py" - "--root_init_template=${CMAKE_CURRENT_BINARY_DIR}/tf_python/tensorflow/api_template.__init__.py" - "--apidir=${CMAKE_CURRENT_BINARY_DIR}/tf_python/tensorflow" - "--package=tensorflow.python" - "--apiname=tensorflow" - "${api_init_list_file}" - - COMMENT "Generating __init__.py files for Python API." - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tf_python" - ) -endif (tensorflow_ENABLE_MKL_SUPPORT) + file(TO_CMAKE_PATH "$ENV{PATH}" PY_RUNTIME_ENV) + set(PY_RUNTIME_ENV ${mkl_BIN_DIRS} ${PY_RUNTIME_ENV}) + file(TO_NATIVE_PATH "${PY_RUNTIME_ENV}" PY_RUNTIME_ENV) + set(PY_RUNTIME_ENV "PATH=${PY_RUNTIME_ENV}") +endif(tensorflow_ENABLE_MKL_SUPPORT) + +add_custom_command( + OUTPUT ${api_init_files} + DEPENDS tf_python_ops tf_python_copy_scripts_to_destination pywrap_tensorflow_internal tf_python_touchup_modules tf_extension_ops + + # tensorflow/__init__.py depends on files generated in this step. So, remove it while + # this step is running since the files aren't there yet. + COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_CURRENT_BINARY_DIR}/tf_python/tensorflow/__init__.py + + # Run create_python_api.py to generate API init files. + COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/tf_python "${PY_RUNTIME_ENV}" ${PYTHON_EXECUTABLE} + "${CMAKE_CURRENT_BINARY_DIR}/tf_python/tensorflow/python/tools/api/generator/create_python_api.py" + "--root_init_template=${CMAKE_CURRENT_BINARY_DIR}/tf_python/tensorflow/api_template.__init__.py" + "--apidir=${CMAKE_CURRENT_BINARY_DIR}/tf_python/tensorflow" + "--package=tensorflow.python" + "--apiname=tensorflow" + "${api_init_list_file}" + + COMMENT "Generating __init__.py files for Python API." + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tf_python" + VERBATIM +) add_custom_target(tf_python_api SOURCES ${api_init_files}) add_dependencies(tf_python_api tf_python_ops) @@ -848,12 +831,12 @@ add_custom_command( DEPENDS tf_python_ops tf_python_copy_scripts_to_destination pywrap_tensorflow_internal tf_python_touchup_modules tf_extension_ops # Run create_python_api.py to generate API init files. - COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/tf_python ${PYTHON_EXECUTABLE} + COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/tf_python "${PY_RUNTIME_ENV}" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/tf_python/tensorflow/python/tools/api/generator/create_python_api.py" "--apidir=${CMAKE_CURRENT_BINARY_DIR}/tf_python/tensorflow/python/estimator/api" "--package=tensorflow.python.estimator" "--apiname=estimator" - "--output_package=tensorflow.python.estimator.api" + "--output_package=tensorflow.python.estimator.api" "${estimator_api_init_list_file}" COMMENT "Generating __init__.py files for Python API." -- GitLab From 6cc0ef8afe751164c17ab4981ba64957685594ef Mon Sep 17 00:00:00 2001 From: CUI Wei Date: Sun, 29 Jul 2018 20:54:54 -0400 Subject: [PATCH 110/437] Fix typo: host_src -> gpu_src for inter-gpu copy Signed-off-by: CUI Wei --- tensorflow/stream_executor/stream_executor_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/stream_executor/stream_executor_internal.h b/tensorflow/stream_executor/stream_executor_internal.h index f34b1fc083..52b3dc04c4 100644 --- a/tensorflow/stream_executor/stream_executor_internal.h +++ b/tensorflow/stream_executor/stream_executor_internal.h @@ -236,7 +236,7 @@ class StreamExecutorInterface { virtual bool Memcpy(Stream *stream, DeviceMemoryBase *gpu_dst, const void *host_src, uint64 size) = 0; virtual bool MemcpyDeviceToDevice(Stream *stream, DeviceMemoryBase *gpu_dst, - const DeviceMemoryBase &host_src, + const DeviceMemoryBase &gpu_src, uint64 size) = 0; virtual bool HostCallback(Stream *stream, std::function callback) = 0; virtual port::Status AllocateEvent(Event *event) = 0; -- GitLab From 5161c7bacd8bc1b7a94434e33e24f62a8f9264b2 Mon Sep 17 00:00:00 2001 From: Grzegorz Pawelczak Date: Mon, 30 Jul 2018 10:13:30 +0100 Subject: [PATCH 111/437] Use dtypes --- tensorflow/compiler/tests/random_ops_test.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tensorflow/compiler/tests/random_ops_test.py b/tensorflow/compiler/tests/random_ops_test.py index 9c7b5a361b..18806b820c 100644 --- a/tensorflow/compiler/tests/random_ops_test.py +++ b/tensorflow/compiler/tests/random_ops_test.py @@ -54,11 +54,8 @@ class RandomOpsTest(XLATestCase): def testRandomUniformIsNotConstant(self): def rng(dtype): - if np.issubdtype(dtype, np.float): - maxval=np.finfo(dtype).max - else: - maxval=np.iinfo(dtype).max - return random_ops.random_uniform(shape=[2], dtype=dtype, maxval=maxval) + dtype = dtypes.as_dtype(dtype) + return random_ops.random_uniform(shape=[2], dtype=dtype, maxval=dtype.max) for dtype in self._random_types(): self._testRngIsNotConstant(rng, dtype) -- GitLab From 52bb2b0abe8b70ca9687c9f2ef02fc6f3c4590ba Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Tue, 31 Jul 2018 14:54:01 +0000 Subject: [PATCH 112/437] Add complex128 support for tf.as_string The tf.as_string supports most of the data types (including complex64) but not complex128. This fix add complex128 support for tf.as_string. Signed-off-by: Yong Tang --- tensorflow/core/kernels/as_string_op.cc | 11 ++++++++++- tensorflow/core/ops/string_ops.cc | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tensorflow/core/kernels/as_string_op.cc b/tensorflow/core/kernels/as_string_op.cc index a7757d1361..e6d6c40f76 100644 --- a/tensorflow/core/kernels/as_string_op.cc +++ b/tensorflow/core/kernels/as_string_op.cc @@ -47,6 +47,7 @@ class AsStringOp : public OpKernel { case DT_FLOAT: case DT_DOUBLE: case DT_COMPLEX64: + case DT_COMPLEX128: break; default: OP_REQUIRES(ctx, !(scientific || shortest), @@ -83,6 +84,7 @@ class AsStringOp : public OpKernel { case DT_FLOAT: case DT_DOUBLE: case DT_COMPLEX64: + case DT_COMPLEX128: if (shortest) { strings::Appendf(&format_, "g"); } else if (scientific) { @@ -100,7 +102,7 @@ class AsStringOp : public OpKernel { DataTypeString(dtype))); } - if (dtype == DT_COMPLEX64) { + if (dtype == DT_COMPLEX64 || dtype == DT_COMPLEX128) { format_ = strings::Printf("(%s,%s)", format_.c_str(), format_.c_str()); } } @@ -144,6 +146,13 @@ class AsStringOp : public OpKernel { format_.c_str(), input_flat(i).real(), input_flat(i).imag()); } } break; + case (DT_COMPLEX128): { + const auto& input_flat = input_tensor->flat(); + for (int i = 0; i < input_flat.size(); ++i) { + output_flat(i) = strings::Printf( + format_.c_str(), input_flat(i).real(), input_flat(i).imag()); + } + } break; default: bool can_encode_type = false; OP_REQUIRES(context, can_encode_type, diff --git a/tensorflow/core/ops/string_ops.cc b/tensorflow/core/ops/string_ops.cc index 4423062362..8c39d69157 100644 --- a/tensorflow/core/ops/string_ops.cc +++ b/tensorflow/core/ops/string_ops.cc @@ -78,7 +78,9 @@ REGISTER_OP("ReduceJoin") REGISTER_OP("AsString") .Input("input: T") .Output("output: string") - .Attr("T: {int8, int16, int32, int64, complex64, float, double, bool}") + .Attr( + "T: {int8, int16, int32, int64, complex64, complex128, float, double, " + "bool}") .Attr("precision: int = -1") .Attr("scientific: bool = false") .Attr("shortest: bool = false") -- GitLab From 9e568bfdfc6f729a65af77c39d66c5d615aaac22 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Tue, 31 Jul 2018 15:08:44 +0000 Subject: [PATCH 113/437] Enable test cases for complex128 with tf.as_string Signed-off-by: Yong Tang --- tensorflow/python/kernel_tests/as_string_op_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/python/kernel_tests/as_string_op_test.py b/tensorflow/python/kernel_tests/as_string_op_test.py index 94ed8ebd31..51aa17babe 100644 --- a/tensorflow/python/kernel_tests/as_string_op_test.py +++ b/tensorflow/python/kernel_tests/as_string_op_test.py @@ -160,7 +160,7 @@ class AsStringOpTest(test.TestCase): complex_inputs_ = [(x + (x + 1) * 1j) for x in float_inputs_] with self.test_session(): - for dtype in (dtypes.complex64,): + for dtype in (dtypes.complex64, dtypes.complex128): input_ = array_ops.placeholder(dtype) def clean_nans(s_l): -- GitLab From a4c4dca8d027bf36a0830d3c6afffc50bec71bc8 Mon Sep 17 00:00:00 2001 From: olicht <29300900+olicht@users.noreply.github.com> Date: Tue, 31 Jul 2018 22:10:27 +0300 Subject: [PATCH 114/437] Improve estimator.py doc-strings * Fixed typos * Warped python terms with ` ...` * A lot of tf terms are now links to their docs --- tensorflow/python/estimator/estimator.py | 315 +++++++++++------------ 1 file changed, 157 insertions(+), 158 deletions(-) diff --git a/tensorflow/python/estimator/estimator.py b/tensorflow/python/estimator/estimator.py index 52b19466eb..4999778029 100644 --- a/tensorflow/python/estimator/estimator.py +++ b/tensorflow/python/estimator/estimator.py @@ -84,7 +84,7 @@ class Estimator(object): subdirectory thereof. If `model_dir` is not set, a temporary directory is used. - The `config` argument can be passed `RunConfig` object containing information + The `config` argument can be passed `tf.estimator.RunConfig` object containing information about the execution environment. It is passed on to the `model_fn`, if the `model_fn` has a parameter named "config" (and input functions in the same manner). If the `config` parameter is not passed, it is instantiated by the @@ -136,15 +136,15 @@ class Estimator(object): * `features`: This is the first item returned from the `input_fn` passed to `train`, `evaluate`, and `predict`. This should be a - single `Tensor` or `dict` of same. + single `tf.Tensor` or `dict` of same. * `labels`: This is the second item returned from the `input_fn` passed to `train`, `evaluate`, and `predict`. This should be a - single `Tensor` or `dict` of same (for multi-head models). If - mode is `ModeKeys.PREDICT`, `labels=None` will be passed. If + single `tf.Tensor` or `dict` of same (for multi-head models). If + mode is @{tf.estimator.ModeKeys.PREDICT}, `labels=None` will be passed. If the `model_fn`'s signature does not accept `mode`, the `model_fn` must still be able to handle `labels=None`. * `mode`: Optional. Specifies if this training, evaluation or - prediction. See `ModeKeys`. + prediction. See `tf.estimator.ModeKeys`. * `params`: Optional `dict` of hyperparameters. Will receive what is passed to Estimator in `params` parameter. This allows to configure Estimators from hyper parameter tuning. @@ -154,10 +154,10 @@ class Estimator(object): configuration such as `num_ps_replicas`, or `model_dir`. * Returns: - `EstimatorSpec` + `tf.estimator.EstimatorSpec` model_dir: Directory to save model parameters, graph and etc. This can - also be used to load checkpoints from the directory into a estimator to + also be used to load checkpoints from the directory into an estimator to continue training a previously saved model. If `PathLike` object, the path will be resolved. If `None`, the model_dir in `config` will be used if set. If both are set, they must be same. If both are `None`, a @@ -168,9 +168,9 @@ class Estimator(object): warm_start_from: Optional string filepath to a checkpoint or SavedModel to warm-start from, or a `tf.estimator.WarmStartSettings` object to fully configure warm-starting. If the string - filepath is provided instead of a `WarmStartSettings`, + filepath is provided instead of a `tf.estimator.WarmStartSettings`, then all variables are warm-started, and it is assumed - that vocabularies and Tensor names are unchanged. + that vocabularies and `tf.Tensor` names are unchanged. Raises: ValueError: parameters of `model_fn` don't match `params`. @@ -217,10 +217,10 @@ class Estimator(object): @property def model_fn(self): - """Returns the model_fn which is bound to self.params. + """Returns the `model_fn` which is bound to `self.params`. Returns: - The model_fn with following signature: + The `model_fn` with following signature: `def model_fn(features, labels, mode, config)` """ @@ -240,7 +240,7 @@ class Estimator(object): Numpy array - value of the tensor. Raises: - ValueError: If the Estimator has not produced a checkpoint yet. + ValueError: If the `Estimator` has not produced a checkpoint yet. """ _check_checkpoint_available(self.model_dir) with context.graph_mode(): @@ -253,14 +253,14 @@ class Estimator(object): List of names. Raises: - ValueError: If the Estimator has not produced a checkpoint yet. + ValueError: If the `Estimator` has not produced a checkpoint yet. """ _check_checkpoint_available(self.model_dir) with context.graph_mode(): return [name for name, _ in training.list_variables(self.model_dir)] def latest_checkpoint(self): - """Finds the filename of latest saved checkpoint file in `model_dir`. + """Finds the filename of the latest saved checkpoint file in `model_dir`. Returns: The full path to the latest checkpoint or `None` if no checkpoint was @@ -275,7 +275,7 @@ class Estimator(object): steps=None, max_steps=None, saving_listeners=None): - """Trains a model given training data input_fn. + """Trains a model given training data `input_fn`. Args: input_fn: A function that provides input data for training as minibatches. @@ -283,25 +283,25 @@ class Estimator(object): information. The function should construct and return one of the following: - * A 'tf.data.Dataset' object: Outputs of `Dataset` object must be a - tuple (features, labels) with same constraints as below. - * A tuple (features, labels): Where `features` is a `Tensor` or a + * A `tf.data.Dataset` object: Outputs of `Dataset` object must be a + tuple `(features, labels)` with same constraints as below. + * A tuple `(features, labels)`: Where `features` is a `tf.Tensor` or a dictionary of string feature name to `Tensor` and `labels` is a `Tensor` or a dictionary of string label name to `Tensor`. Both `features` and `labels` are consumed by `model_fn`. They should satisfy the expectation of `model_fn` from inputs. - hooks: List of `SessionRunHook` subclass instances. Used for callbacks + hooks: List of `tf.train.SessionRunHook` subclass instances. Used for callbacks inside the training loop. - steps: Number of steps for which to train model. If `None`, train forever - or train until input_fn generates the `OutOfRange` error or - `StopIteration` exception. 'steps' works incrementally. If you call two - times train(steps=10) then training occurs in total 20 steps. If + steps: Number of steps for which to train the model. If `None`, train forever + or train until `input_fn` generates the `tf.errors.OutOfRange` error or + `StopIteration` exception. `steps` works incrementally. If you call two + times `train(steps=10)` then training occurs in total 20 steps. If `OutOfRange` or `StopIteration` occurs in the middle, training stops before 20 steps. If you don't want to have incremental behavior please set `max_steps` instead. If set, `max_steps` must be `None`. max_steps: Number of total steps for which to train model. If `None`, - train forever or train until input_fn generates the `OutOfRange` error + train forever or train until `input_fn` generates the `tf.errors.OutOfRange` error or `StopIteration` exception. If set, `steps` must be `None`. If `OutOfRange` or `StopIteration` occurs in the middle, training stops before `max_steps` steps. @@ -317,7 +317,7 @@ class Estimator(object): Raises: ValueError: If both `steps` and `max_steps` are not `None`. - ValueError: If either `steps` or `max_steps` is <= 0. + ValueError: If either `steps` or `max_steps <= 0`. """ with context.graph_mode(): if (steps is not None) and (max_steps is not None): @@ -349,7 +349,7 @@ class Estimator(object): return [] def eval_dir(self, name=None): - """Shows directory name where evaluation metrics are dumped. + """Shows the directory name where evaluation metrics are dumped. Args: name: Name of the evaluation if user needs to run multiple evaluations on @@ -365,12 +365,12 @@ class Estimator(object): def evaluate(self, input_fn, steps=None, hooks=None, checkpoint_path=None, name=None): - """Evaluates the model given evaluation data input_fn. + """Evaluates the model given evaluation data `input_fn`. For each step, calls `input_fn`, which returns one batch of data. Evaluates until: - `steps` batches are processed, or - - `input_fn` raises an end-of-input exception (`OutOfRangeError` or + - `input_fn` raises an end-of-input exception (`tf.errors.OutOfRangeError` or `StopIteration`). Args: @@ -379,9 +379,9 @@ class Estimator(object): information. The function should construct and return one of the following: - * A 'tf.data.Dataset' object: Outputs of `Dataset` object must be a - tuple (features, labels) with same constraints as below. - * A tuple (features, labels): Where `features` is a `Tensor` or a + * A `tf.data.Dataset` object: Outputs of `Dataset` object must be a + tuple `(features, labels)` with same constraints as below. + * A tuple `(features, labels)`: Where `features` is a `tf.Tensor` or a dictionary of string feature name to `Tensor` and `labels` is a `Tensor` or a dictionary of string label name to `Tensor`. Both `features` and `labels` are consumed by `model_fn`. They should @@ -389,12 +389,12 @@ class Estimator(object): steps: Number of steps for which to evaluate model. If `None`, evaluates until `input_fn` raises an end-of-input exception. - hooks: List of `SessionRunHook` subclass instances. Used for callbacks + hooks: List of `tf.train.SessionRunHook` subclass instances. Used for callbacks inside the evaluation call. checkpoint_path: Path of a specific checkpoint to evaluate. If `None`, the latest checkpoint in `model_dir` is used. If there are no checkpoints in `model_dir`, evaluation is run with newly initialized `Variables` - instead of restored from checkpoint. + instead of ones restored from checkpoint. name: Name of the evaluation if user needs to run multiple evaluations on different data sets, such as on training data vs test data. Metrics for different evaluations are saved in separate folders, and appear @@ -452,30 +452,30 @@ class Estimator(object): Args: input_fn: A function that constructs the features. Prediction continues - until `input_fn` raises an end-of-input exception (`OutOfRangeError` or + until `input_fn` raises an end-of-input exception (`tf.errors.OutOfRangeError` or `StopIteration`). See @{$premade_estimators#create_input_functions} for more information. The function should construct and return one of the following: - * A 'tf.data.Dataset' object: Outputs of `Dataset` object must have + * A `tf.data.Dataset` object: Outputs of `Dataset` object must have same constraints as below. - * features: A `Tensor` or a dictionary of string feature name to + * features: A `tf.Tensor` or a dictionary of string feature name to `Tensor`. features are consumed by `model_fn`. They should satisfy the expectation of `model_fn` from inputs. * A tuple, in which case the first item is extracted as features. predict_keys: list of `str`, name of the keys to predict. It is used if - the `EstimatorSpec.predictions` is a `dict`. If `predict_keys` is used + the `tf.estimator.EstimatorSpec.predictions` is a `dict`. If `predict_keys` is used then rest of the predictions will be filtered from the dictionary. If `None`, returns all. - hooks: List of `SessionRunHook` subclass instances. Used for callbacks + hooks: List of `tf.train.SessionRunHook` subclass instances. Used for callbacks inside the prediction call. checkpoint_path: Path of a specific checkpoint to predict. If `None`, the latest checkpoint in `model_dir` is used. If there are no checkpoints in `model_dir`, prediction is run with newly initialized `Variables` - instead of restored from checkpoint. - yield_single_examples: If False, yield the whole batch as returned by the + instead of ones restored from checkpoint. + yield_single_examples: If `False`, yields the whole batch as returned by the `model_fn` instead of decomposing the batch into individual elements. This is useful if `model_fn` returns some tensors whose first dimension is not equal to the batch size. @@ -486,10 +486,10 @@ class Estimator(object): Raises: ValueError: Could not find a trained model in `model_dir`. ValueError: If batch length of predictions is not the same and - `yield_single_examples` is True. + `yield_single_examples` is `True`. ValueError: If there is a conflict between `predict_keys` and `predictions`. For example if `predict_keys` is not `None` but - `EstimatorSpec.predictions` is not a `dict`. + `tf.estimator.EstimatorSpec.predictions` is not a `dict`. """ with context.graph_mode(): hooks = _check_hooks_type(hooks) @@ -571,30 +571,30 @@ class Estimator(object): checkpoint_path=None, strip_default_attrs=False): # pylint: disable=line-too-long - """Exports inference graph as a SavedModel into given dir. + """Exports inference graph as a `SavedModel` into the given dir. For a detailed guide, see @{$saved_model#using_savedmodel_with_estimators$Using SavedModel with Estimators}. This method builds a new graph by first calling the - serving_input_receiver_fn to obtain feature `Tensor`s, and then calling - this `Estimator`'s model_fn to generate the model graph based on those + `serving_input_receiver_fn` to obtain feature `Tensor`s, and then calling + this `Estimator`'s `model_fn` to generate the model graph based on those features. It restores the given checkpoint (or, lacking that, the most recent checkpoint) into this graph in a fresh session. Finally it creates - a timestamped export directory below the given export_dir_base, and writes - a `SavedModel` into it containing a single `MetaGraphDef` saved from this + a timestamped export directory below the given `export_dir_base`, and writes + a `SavedModel` into it containing a single `tf.MetaGraphDef` saved from this session. The exported `MetaGraphDef` will provide one `SignatureDef` for each - element of the export_outputs dict returned from the model_fn, named using + element of the `export_outputs` dict returned from the `model_fn`, named using the same keys. One of these keys is always - signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY, indicating which + `tf.saved_model.signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY`, indicating which signature will be served when a serving request does not specify one. For each signature, the outputs are provided by the corresponding - `ExportOutput`s, and the inputs are always the input receivers provided by - the serving_input_receiver_fn. + `tf.estimator.export.ExportOutput`s, and the inputs are always the input receivers provided by + the `serving_input_receiver_fn`. - Extra assets may be written into the SavedModel via the assets_extra + Extra assets may be written into the `SavedModel` via the `assets_extra` argument. This should be a dict, where each key gives a destination path (including the filename) relative to the assets.extra directory. The corresponding value gives the full path of the source file to be copied. @@ -603,23 +603,23 @@ class Estimator(object): Args: export_dir_base: A string containing a directory in which to create - timestamped subdirectories containing exported SavedModels. + timestamped subdirectories containing exported `SavedModel`s. serving_input_receiver_fn: A function that takes no argument and - returns a `ServingInputReceiver` or `TensorServingInputReceiver`. + returns a `tf.estimator.export.ServingInputReceiver` or `tf.estimator.export.TensorServingInputReceiver`. assets_extra: A dict specifying how to populate the assets.extra directory - within the exported SavedModel, or `None` if no extra assets are needed. - as_text: whether to write the SavedModel proto in text format. + within the exported `SavedModel`, or `None` if no extra assets are needed. + as_text: whether to write the `SavedModel` proto in text format. checkpoint_path: The checkpoint path to export. If `None` (the default), the most recent checkpoint found within the model directory is chosen. strip_default_attrs: Boolean. If `True`, default-valued attributes will be - removed from the NodeDefs. For a detailed guide, see + removed from the `NodeDef`s. For a detailed guide, see [Stripping Default-Valued Attributes](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md#stripping-default-valued-attributes). Returns: The string path to the exported directory. Raises: - ValueError: if no serving_input_receiver_fn is provided, no export_outputs + ValueError: if no `serving_input_receiver_fn` is provided, no `export_outputs` are provided, or no checkpoint can be found. """ # pylint: enable=line-too-long @@ -640,35 +640,35 @@ class Estimator(object): strip_default_attrs=False, mode=model_fn_lib.ModeKeys.PREDICT): # pylint: disable=line-too-long - """Exports a single train/eval/predict graph as a SavedModel. + """Exports a single train/eval/predict graph as a `SavedModel`. - This method is a wrapper for _export_all_saved_models, and wraps a raw - input_receiver_fn in a dictionary to pass in to that function. - See _export_all_saved_models for full docs. + This method is a wrapper for `_export_all_saved_models`, and wraps a raw + `input_receiver_fn` in a dictionary to pass in to that function. + See `_export_all_saved_models` for full docs. - See tf.contrib.estimator.export_saved_model_for_mode for the currently + See `tf.contrib.estimator.export_saved_model_for_mode` for the currently exposed version of this function. Args: export_dir_base: A string containing a directory in which to create - timestamped subdirectories containing exported SavedModels. + timestamped subdirectories containing exported `SavedModel`s. input_receiver_fn: a function that takes no argument and returns the appropriate subclass of `InputReceiver`. assets_extra: A dict specifying how to populate the assets.extra directory - within the exported SavedModel, or `None` if no extra assets are needed. - as_text: whether to write the SavedModel proto in text format. + within the exported `SavedModel`, or `None` if no extra assets are needed. + as_text: whether to write the `SavedModel` proto in text format. checkpoint_path: The checkpoint path to export. If `None` (the default), the most recent checkpoint found within the model directory is chosen. strip_default_attrs: Boolean. If `True`, default-valued attributes will be - removed from the NodeDefs. For a detailed guide, see + removed from the `NodeDef`s. For a detailed guide, see [Stripping Default-Valued Attributes](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md#stripping-default-valued-attributes). - mode: tf.estimator.ModeKeys value indicating with mode will be exported. + mode: `tf.estimator.ModeKeys` value indicating with mode will be exported. Returns: The string path to the exported directory. Raises: - ValueError: if input_receiver_fn is None, no export_outputs + ValueError: if `input_receiver_fn` is `None`, no `export_outputs` are provided, or no checkpoint can be found. """ # pylint: enable=line-too-long @@ -692,40 +692,40 @@ class Estimator(object): checkpoint_path=None, strip_default_attrs=False): # pylint: disable=line-too-long - """Exports a SavedModel containing MetaGraphDefs for each requested mode. + """Exports a `SavedModel` containing `tf.MetaGraphDefs` for each requested mode. - See tf.contrib.estimator.export_all_saved_models for the currently + See `tf.contrib.estimator.export_all_saved_models` for the currently exposed version of this function. - For each mode passed in via the input_receiver_fn_map, - this method builds a new graph by calling the input_receiver_fn to obtain + For each mode passed in via the `input_receiver_fn_map`, + this method builds a new graph by calling the `input_receiver_fn` to obtain feature and label `Tensor`s. Next, this method calls the `Estimator`'s - model_fn in the passed mode to generate the model graph based on + `model_fn` in the passed mode to generate the model graph based on those features and labels, and restores the given checkpoint (or, lacking that, the most recent checkpoint) into the graph. - Only one of the modes is used for saving variables to the SavedModel - (order of preference: TRAIN, EVAL, then PREDICT), such that up to three - MetaGraphDefs are saved with a single set of variables in a single - SavedModel directory. + Only one of the modes is used for saving variables to the `SavedModel` + (order of preference: @{tf.estimator.ModeKeys#TRAIN$TRAIN}, @{tf.estimator.ModeKeys#EVAL$EVAL}, then @{tf.estimator.ModeKeys#PREDICT$PREDICT}), such that up to three + `tf.MetaGraphDefs` are saved with a single set of variables in a single + `SavedModel` directory. - For the variables and MetaGraphDefs, a timestamped export directory below - export_dir_base, and writes a `SavedModel` into it containing - the `MetaGraphDef` for the given mode and its associated signatures. + For the variables and `tf.MetaGraphDefs`, a timestamped export directory below + `export_dir_base`, and writes a `SavedModel` into it containing + the `tf.MetaGraphDef` for the given mode and its associated signatures. For prediction, the exported `MetaGraphDef` will provide one `SignatureDef` - for each element of the export_outputs dict returned from the model_fn, + for each element of the `export_outputs` dict returned from the `model_fn`, named using the same keys. One of these keys is always - signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY, indicating which + `tf.saved_model.signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY`, indicating which signature will be served when a serving request does not specify one. For each signature, the outputs are provided by the corresponding - `ExportOutput`s, and the inputs are always the input receivers provided by - the serving_input_receiver_fn. + `tf.estimator.export.ExportOutput`s, and the inputs are always the input receivers provided by + the `serving_input_receiver_fn`. - For training and evaluation, the train_op is stored in an extra collection, - and loss, metrics, and predictions are included in a SignatureDef for the + For training and evaluation, the `train_op` is stored in an extra collection, + and loss, metrics, and predictions are included in a `SignatureDef` for the mode in question. - Extra assets may be written into the SavedModel via the assets_extra + Extra assets may be written into the `SavedModel` via the `assets_extra` argument. This should be a dict, where each key gives a destination path (including the filename) relative to the assets.extra directory. The corresponding value gives the full path of the source file to be copied. @@ -734,25 +734,25 @@ class Estimator(object): Args: export_dir_base: A string containing a directory in which to create - timestamped subdirectories containing exported SavedModels. - input_receiver_fn_map: dict of tf.estimator.ModeKeys to input_receiver_fn - mappings, where the input_receiver_fn is a function that takes no - argument and returns the appropriate subclass of `InputReceiver`. + timestamped subdirectories containing exported `SavedModel`s. + input_receiver_fn_map: dict of `tf.estimator.ModeKeys` to `input_receiver_fn` + mappings, where the `input_receiver_fn` is a function that takes no + arguments and returns the appropriate subclass of `InputReceiver`. assets_extra: A dict specifying how to populate the assets.extra directory - within the exported SavedModel, or `None` if no extra assets are needed. - as_text: whether to write the SavedModel proto in text format. + within the exported `SavedModel`, or `None` if no extra assets are needed. + as_text: whether to write the `SavedModel` proto in text format. checkpoint_path: The checkpoint path to export. If `None` (the default), the most recent checkpoint found within the model directory is chosen. strip_default_attrs: Boolean. If `True`, default-valued attributes will be - removed from the NodeDefs. For a detailed guide, see + removed from the `NodeDef`s. For a detailed guide, see [Stripping Default-Valued Attributes](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md#stripping-default-valued-attributes). Returns: - A dict of tf.estimator.ModeKeys value to string path for each exported + A dict of `tf.estimator.ModeKeys` value to string path for each exported directory. Raises: - ValueError: if any input_receiver_fn is None, no export_outputs + ValueError: if any `input_receiver_fn` is `None`, no `export_outputs` are provided, or no checkpoint can be found. """ # pylint: enable=line-too-long @@ -824,24 +824,24 @@ class Estimator(object): export_tags=None, check_variables=True): # pylint: disable=line-too-long - """Loads variables and adds them along with a MetaGraphDef for saving. + """Loads variables and adds them along with a `tf.MetaGraphDef` for saving. Args: - builder: instance of SavedModelBuilder that will be used for saving. - input_receiver_fn_map: dict of tf.estimator.ModeKeys to input_receiver_fn - mappings, where the input_receiver_fn is a function that takes no + builder: instance of `tf.saved_modle.builder.SavedModelBuilder` that will be used for saving. + input_receiver_fn_map: dict of `tf.estimator.ModeKeys` to `input_receiver_fn` + mappings, where the `input_receiver_fn` is a function that takes no argument and returns the appropriate subclass of `InputReceiver`. checkpoint_path: The checkpoint path to export. If `None` (the default), the most recent checkpoint found within the model directory is chosen. strip_default_attrs: Boolean. If `True`, default-valued attributes will be - removed from the NodeDefs. For a detailed guide, see + removed from the `NodeDef`s. For a detailed guide, see [Stripping Default-Valued Attributes](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md#stripping-default-valued-attributes). - save_variables: bool, whether variables should be saved. If False, just - the MetaGraphDef will be saved. Note that save_variables should only be - True for the first call to this function, and the SavedModelBuilder will + save_variables: bool, whether variables should be saved. If `False`, just + the `tf.MetaGraphDef` will be saved. Note that `save_variables` should only be + `True` for the first call to this function, and the `SavedModelBuilder` will raise an error if that is not the case. - mode: tf.estimator.ModeKeys value indicating which mode will be exported. - export_tags: The set of tags with which to save `MetaGraphDef`. If None, + mode: `tf.estimator.ModeKeys` value indicating which mode will be exported. + export_tags: The set of tags with which to save `tf.MetaGraphDef`. If `None`, a default set will be selected to matched the passed mode. check_variables: bool, whether to check the checkpoint has all variables. @@ -924,21 +924,21 @@ class Estimator(object): builder.add_meta_graph(**meta_graph_kwargs) def _get_export_outputs_for_spec(self, estimator_spec): - """Given an EstimatorSpec, determine what our export outputs should be. + """Given an `tf.estimator.EstimatorSpec`, determine what our export outputs should be. - EstimatorSpecs contain export_outputs that are used for serving, but for + `EstimatorSpecs` contains `export_outputs` that are used for serving, but for training and eval graphs, we must wrap the tensors of interest in - appropriate ExportOutput objects. + appropriate `tf.estimator.export.ExportOutput` objects. Args: - estimator_spec: EstimatorSpec object that will be exported. + estimator_spec: `tf.estimator.EstimatorSpec` object that will be exported. Returns: - a dict mapping export_output_name to ExportOutput object. + a dict mapping `export_output_name` to `tf.estimator.export.ExportOutput` object. Raises: - ValueError: if an appropriate ExportOutput cannot be found for the - passed EstimatorSpec.mode + ValueError: if an appropriate `ExportOutput` cannot be found for the + passed `EstimatorSpec.mode` """ mode = estimator_spec.mode if mode == model_fn_lib.ModeKeys.PREDICT: @@ -1014,13 +1014,13 @@ class Estimator(object): """Creates the global step tensor in graph. The global step tensor must be an integer type with name 'global_step' and - be added to the collection @{tf.GraphKeys.GLOBAL_STEP}. + be added to the collection @{tf.GraphKeys#GLOBAL_STEP$GLOBAL_STEP}. Args: graph: The graph in which to create the global step tensor. Returns: - The global step `Tensor`. + The global step `tf.Tensor`. """ return training.create_global_step(graph) @@ -1031,7 +1031,7 @@ class Estimator(object): graph: The graph in which to create the global step tensor. Returns: - The global step `Tensor`. + The global step `tf.Tensor`. """ step = self._create_global_step(graph) assert step == training.get_global_step() @@ -1043,21 +1043,21 @@ class Estimator(object): Args: input_fn: The input function. - mode: ModeKeys + mode: `tf.estimator.ModeKeys` Returns: - The return value of the passed input_fn, which should be one of: + The return value of the passed `input_fn`, which should be one of: * A 'tf.data.Dataset' object: Outputs of `Dataset` object must be a - tuple (features, labels) with same constraints as below. - * A tuple (features, labels): Where `features` is a `Tensor` or a + tuple `(features, labels)` with same constraints as below. + * A tuple `(features, labels)`: Where `features` is a `Tensor` or a dictionary of string feature name to `Tensor` and `labels` is a `Tensor` or a dictionary of string label name to `Tensor`. Both `features` and `labels` are consumed by `model_fn`. They should satisfy the expectation of `model_fn` from inputs. Raises: - ValueError: if input_fn takes invalid arguments. + ValueError: if `input_fn` takes invalid arguments. """ input_fn_args = function_utils.fn_args(input_fn) kwargs = {} @@ -1076,14 +1076,14 @@ class Estimator(object): Args: features: features dict. labels: labels dict. - mode: ModeKeys - config: RunConfig + mode: `tf.estimator.ModeKeys` + config: `tf.estimator.RunConfig` Returns: - An `EstimatorSpec` object. + An `tf.estimator.EstimatorSpec` object. Raises: - ValueError: if model_fn returns invalid objects. + ValueError: if `model_fn` returns invalid objects. """ model_fn_args = function_utils.fn_args(self._model_fn) kwargs = {} @@ -1116,13 +1116,13 @@ class Estimator(object): return self._train_model_default(input_fn, hooks, saving_listeners) def _train_model_default(self, input_fn, hooks, saving_listeners): - """Initiate training with input_fn, without DistributionStrategies. + """Initiate training with `input_fn`, without `tf.contrib.distribute.DistributionStrategies`. Args: input_fn: A function that provides input data for training as minibatches. - hooks: List of `SessionRunHook` subclass instances. Used for callbacks + hooks: List of `tf.train.SessionRunHook` subclass instances. Used for callbacks inside the training loop. - saving_listeners: list of `CheckpointSaverListener` objects. Used for + saving_listeners: list of `tf.train.CheckpointSaverListener` objects. Used for callbacks that run immediately before or after checkpoint savings. Returns: @@ -1150,13 +1150,13 @@ class Estimator(object): saving_listeners) def _train_model_distributed(self, input_fn, hooks, saving_listeners): - """Initiate training with input_fn, using DistributionStrategies. + """Initiate training with `input_fn`, using `tf.contrib.distribute.DistributionStrategies`. Args: input_fn: A function that provides input data for training as minibatches. - hooks: List of `SessionRunHook` subclass instances. Used for callbacks + hooks: List of `tf.train.SessionRunHook` subclass instances. Used for callbacks inside the training loop. - saving_listeners: list of `CheckpointSaverListener` objects. Used for + saving_listeners: list of `tf.train.CheckpointSaverListener` objects. Used for callbacks that run immediately before or after checkpoint savings. Returns: @@ -1546,9 +1546,8 @@ def maybe_overwrite_model_dir_and_session_config(config, model_dir): "`model_dir` are set both in constructor and `RunConfig`, but with " "different values. In constructor: '{}', in `RunConfig`: " "'{}' ".format(model_dir, config.model_dir)) - if model_dir: - config = run_config.RunConfig.replace(config, model_dir=model_dir) - if getattr(config, 'model_dir', None) is None: + config = run_config.RunConfig.replace(config, model_dir=model_dir) + elif getattr(config, 'model_dir', None) is None: model_dir = tempfile.mkdtemp() logging.warning('Using temporary folder as model directory: %s', model_dir) config = run_config.RunConfig.replace(config, model_dir=model_dir) @@ -1557,7 +1556,7 @@ def maybe_overwrite_model_dir_and_session_config(config, model_dir): def create_per_tower_ready_op(scaffold): - """Create a Scaffold.ready_op inside a tower.""" + """Create a `tf.train.Scaffold.ready_op` inside a tower.""" if scaffold.ready_op: return scaffold.ready_op @@ -1572,7 +1571,7 @@ def create_per_tower_ready_op(scaffold): def create_per_tower_ready_for_local_init_op(scaffold): - """Create a Scaffold.ready_for_local_init_op inside a tower.""" + """Create a `tf.train.Scaffold.ready_for_local_init_op` inside a tower.""" if scaffold.ready_for_local_init_op: return scaffold.ready_for_local_init_op @@ -1593,7 +1592,7 @@ def _check_checkpoint_available(model_dir): def _check_hooks_type(hooks): - """Returns hooks if all are SessionRunHook, raises TypeError otherwise.""" + """Returns hooks if all are `tf.train.SessionRunHook`, raises TypeError otherwise.""" hooks = list(hooks or []) for h in hooks: if not isinstance(h, training.SessionRunHook): @@ -1613,17 +1612,17 @@ def _check_listeners_type(saving_listeners): def _get_replica_device_setter(config): - """Creates a replica device setter if required as a default device_fn. + """Creates a replica device setter if required as a default `device_fn`. - `Estimator` uses ReplicaDeviceSetter as a default device placer. It sets the - distributed related arguments such as number of ps_replicas based on given - config. + `Estimator` uses `tf.train.ReplicaDeviceSetter` as a default device placer. It sets the + distributed related arguments such as number of `ps_replicas` based on given + `config`. Args: - config: A `RunConfig` instance. + config: A `tf.estimator.RunConfig` instance. Returns: - A replica device setter, or None. + A replica device setter, or `None`. """ if config.task_type: worker_device = '/job:%s/task:%d' % (config.task_type, config.task_id) @@ -1642,7 +1641,7 @@ def _get_replica_device_setter(config): def _verify_model_fn_args(model_fn, params): - """Verifies model fn arguments.""" + """Verifies `model_fn` arguments.""" args = set(function_utils.fn_args(model_fn)) if 'features' not in args: raise ValueError('model_fn (%s) must include features argument.' % model_fn) @@ -1769,7 +1768,7 @@ def _write_checkpoint_path_to_summary(output_dir, checkpoint_path, def _has_dataset_or_queue_runner(maybe_tensor): - """Returns True if TF dataset or QueueRunner has been used.""" + """Returns `True` if TF `tf.data.Dataset` or `tf.train.QueueRunner` has been used.""" # Check TF dataset first. Here, we use a simple algorithm to check the top # level Tensors only, which should be sufficient for most users. tensors = [x for x in nest.flatten(maybe_tensor) if isinstance(x, ops.Tensor)] @@ -1792,9 +1791,9 @@ class WarmStartSettings( 'var_name_to_vocab_info', 'var_name_to_prev_var_name', ])): - """Settings for warm-starting in Estimators. + """Settings for warm-starting in `tf.estimator.Estimators`. - Example Use with canned `DNNEstimator`: + Example Use with canned `tf.estimator.DNNEstimator`: ``` emb_vocab_file = tf.feature_column.embedding_column( @@ -1914,18 +1913,18 @@ class WarmStartSettings( vars_to_warm_start: [Optional] One of the following: - A regular expression (string) that captures which variables to - warm-start (see tf.get_collection). This expression will only consider - variables in the TRAINABLE_VARIABLES collection. + warm-start (see `tf.get_collection`). This expression will only consider + variables in the `TRAINABLE_VARIABLES` collection. - A list of Variables to warm-start. - A list of strings, each representing a full variable name to warm-start. - `None`, in which case only variables specified in `var_name_to_vocab_info` will be warm-started. Defaults to `'.*'`, which warm-starts all variables in the - TRAINABLE_VARIABLES collection. Note that this excludes variables such as + `TRAINABLE_VARIABLES` collection. Note that this excludes variables such as accumulators and moving statistics from batch norm. var_name_to_vocab_info: [Optional] Dict of variable names (strings) to - VocabInfo. The variable names should be "full" variables, not the names + `tf.estimator.VocabInfo`. The variable names should be "full" variables, not the names of the partitions. If not explicitly provided, the variable is assumed to have no vocabulary. var_name_to_prev_var_name: [Optional] Dict of variable names (strings) to @@ -1952,7 +1951,7 @@ class WarmStartSettings( def _get_saved_model_ckpt(saved_model_dir): - """Return path to variables checkpoint in a SavedModel directory.""" + """Return path to variables checkpoint in a `SavedModel` directory.""" if not gfile.Exists( os.path.join(compat.as_bytes(saved_model_dir), compat.as_bytes('variables/variables.index'))): @@ -1965,18 +1964,18 @@ def _get_saved_model_ckpt(saved_model_dir): def _get_default_warm_start_settings(warm_start_from): - """Returns default WarmStartSettings. + """Returns default `tf.estimator.WarmStartSettings`. Args: warm_start_from: Either a string representing the filepath of a checkpoint - or SavedModel to initialize from, or an instance of WarmStartSettings. + or `SavedModel` to initialize from, or an instance of `tf.estimator.WarmStartSettings`. Returns: - Either None or an instance of WarmStartSettings. + Either None or an instance of `WarmStartSettings`. Raises: - ValueError: If warm_start_from is not None but is neither a string nor an - instance of WarmStartSettings. + ValueError: If `warm_start_from` is not `None` but is neither a string nor an + instance of `WarmStartSettings`. """ if warm_start_from is None: return None -- GitLab From e3ef4b19627853e694a51ea0b1465a060caa8952 Mon Sep 17 00:00:00 2001 From: Peng Yu Date: Tue, 31 Jul 2018 16:02:15 -0400 Subject: [PATCH 115/437] Add extra log for failing to load variable purpose --- tensorflow/cc/saved_model/loader.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/tensorflow/cc/saved_model/loader.cc b/tensorflow/cc/saved_model/loader.cc index 98be66a6ad..ca8cb8a9be 100644 --- a/tensorflow/cc/saved_model/loader.cc +++ b/tensorflow/cc/saved_model/loader.cc @@ -169,6 +169,7 @@ Status RunRestore(const RunOptions& run_options, const string& export_dir, const string variables_index_path = io::JoinPath( variables_directory, MetaFilename(kSavedModelVariablesFilename)); if (!Env::Default()->FileExists(variables_index_path).ok()) { + LOG(INFO) << "Falied to restore variables from " << variables_index_path; LOG(INFO) << "The specified SavedModel has no variables; no checkpoints " "were restored."; return Status::OK(); -- GitLab From 8e2f587b95cda1f67deaa4ae315c7540444919f5 Mon Sep 17 00:00:00 2001 From: Guozhong Zhuang Date: Tue, 31 Jul 2018 13:57:40 -0700 Subject: [PATCH 116/437] use std::fill_n to replace array assignment with for loop based on Rasmus's suggestion --- .../core/kernels/mkl_fused_batch_norm_op.cc | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc b/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc index fdb04cac64..e048e70395 100644 --- a/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc +++ b/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc @@ -1430,8 +1430,7 @@ class MklFusedBatchNormOp : public OpKernel { // set NAN mean value in case of empty input tensor int num_elements = tf_shape_scale.num_elements(); auto batch_mean_data = (*batch_mean_tensor)->flat().data(); - for (int k = 0; k < num_elements; k++) - batch_mean_data[k] = NAN; + std::fill_n(batch_mean_data, num_elements, NAN); // allocate batch variance output tensor MklDnnShape mkl_shape_batch_variance; @@ -1442,8 +1441,7 @@ class MklFusedBatchNormOp : public OpKernel { CHECK_NOTNULL(*batch_variance_tensor); // set NAN variance value in case of empty input tensor auto batch_variance_data = (*batch_variance_tensor)->flat().data(); - for (int k = 0; k < num_elements; k++) - batch_variance_data[k] = NAN; + std::fill_n(batch_variance_data, num_elements, NAN); // Mean and variance (without Bessel's correction) saved for backward // computation to serve as pre-computed mean and variance. @@ -1454,8 +1452,7 @@ class MklFusedBatchNormOp : public OpKernel { CHECK_NOTNULL(*saved_mean_tensor); // set NAN mean value in case of empty input tensor auto saved_mean_data = (*saved_mean_tensor)->flat().data(); - for (int k = 0; k < num_elements; k++) - saved_mean_data[k] = NAN; + std::fill_n(saved_mean_data, num_elements, NAN); MklDnnShape mkl_shape_saved_variance; mkl_shape_saved_variance.SetMklTensor(false); @@ -1465,8 +1462,7 @@ class MklFusedBatchNormOp : public OpKernel { CHECK_NOTNULL(*saved_variance_tensor); // set NAN variance value in case of empty input tensor auto saved_variance_data = (*saved_variance_tensor)->flat().data(); - for (int k = 0; k < num_elements; k++) - saved_variance_data[k] = NAN; + std::fill_n(saved_variance_data, num_elements, NAN); } }; @@ -1706,10 +1702,8 @@ class MklFusedBatchNormGradOp : public OpKernel { dnn_shape_diff_src.SetMklTensor(false); AllocateOutputSetMklShape(context, kDiffSrcIndex, diff_src_tensor, tf_shape_src, dnn_shape_diff_src); - int num_elements = (*diff_src_tensor)->shape().num_elements(); auto diff_src_data = (*diff_src_tensor)->flat().data(); - for (size_t i = 0; i < num_elements; i++) - diff_src_data[i] = 0; + std::fill_n(diff_src_data, (*diff_src_tensor)->shape().num_elements(), 0); Tensor* diff_scale_tensor = nullptr; Tensor* diff_shift_tensor = nullptr; @@ -1735,20 +1729,16 @@ class MklFusedBatchNormGradOp : public OpKernel { AllocateOutputSetMklShape(context, kDiffScaleIndex, diff_scale_tensor, tf_shape_scale_shift, mkl_shape_diff_scale); CHECK_NOTNULL(*diff_scale_tensor); - int diff_scale_num_elements = (*diff_scale_tensor)->shape().num_elements(); auto diff_scale_data = (*diff_scale_tensor)->flat().data(); - for (size_t i = 0; i < diff_scale_num_elements; i++) - diff_scale_data[i] = 0; + std::fill_n(diff_scale_data, (*diff_scale_tensor)->shape().num_elements(), 0); MklDnnShape mkl_shape_diff_shift; mkl_shape_diff_shift.SetMklTensor(false); AllocateOutputSetMklShape(context, kDiffShiftIndex, diff_shift_tensor, tf_shape_scale_shift, mkl_shape_diff_shift); CHECK_NOTNULL(*diff_shift_tensor); - int diff_shift_num_elements = (*diff_shift_tensor)->shape().num_elements(); auto diff_shift_data = (*diff_shift_tensor)->flat().data(); - for (size_t i = 0; i < diff_shift_num_elements; i++) - diff_shift_data[i] = 0; + std::fill_n(diff_shift_data, (*diff_shift_tensor)->shape().num_elements(), 0); // Placeholders for estimated_mean and estimated_variance, which are // used for inference and thus not needed here for gradient computation. -- GitLab From 19f86cbeadb7014b9940be1f6921776ef9d2f986 Mon Sep 17 00:00:00 2001 From: Peng Yu Date: Tue, 31 Jul 2018 17:30:06 -0400 Subject: [PATCH 117/437] address comments --- tensorflow/cc/saved_model/loader.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tensorflow/cc/saved_model/loader.cc b/tensorflow/cc/saved_model/loader.cc index ca8cb8a9be..22ad5e0162 100644 --- a/tensorflow/cc/saved_model/loader.cc +++ b/tensorflow/cc/saved_model/loader.cc @@ -169,9 +169,8 @@ Status RunRestore(const RunOptions& run_options, const string& export_dir, const string variables_index_path = io::JoinPath( variables_directory, MetaFilename(kSavedModelVariablesFilename)); if (!Env::Default()->FileExists(variables_index_path).ok()) { - LOG(INFO) << "Falied to restore variables from " << variables_index_path; LOG(INFO) << "The specified SavedModel has no variables; no checkpoints " - "were restored."; + "were restored. Failed to restore from " << variables_index_path; return Status::OK(); } const string variables_path = -- GitLab From 234c9a3fd3a430f25c604c42b457b72842375f30 Mon Sep 17 00:00:00 2001 From: Jonathan Hseu Date: Tue, 31 Jul 2018 14:50:55 -0700 Subject: [PATCH 118/437] Slightly modify error message --- tensorflow/cc/saved_model/loader.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/cc/saved_model/loader.cc b/tensorflow/cc/saved_model/loader.cc index 22ad5e0162..a5eae97f6e 100644 --- a/tensorflow/cc/saved_model/loader.cc +++ b/tensorflow/cc/saved_model/loader.cc @@ -170,7 +170,7 @@ Status RunRestore(const RunOptions& run_options, const string& export_dir, variables_directory, MetaFilename(kSavedModelVariablesFilename)); if (!Env::Default()->FileExists(variables_index_path).ok()) { LOG(INFO) << "The specified SavedModel has no variables; no checkpoints " - "were restored. Failed to restore from " << variables_index_path; + "were restored. File does not exist: " << variables_index_path; return Status::OK(); } const string variables_path = -- GitLab From 8cd2d6fe9389e93a4182ae9287f2f8325913fe6c Mon Sep 17 00:00:00 2001 From: Derek Murray Date: Wed, 1 Aug 2018 14:31:15 -0700 Subject: [PATCH 119/437] [tf.py_func()] Check Python interpreter state before call Attempting to acquire the GIL in a destructor when the process is terminating can fail, leading to a hang. Fixes #21277. --- tensorflow/python/lib/core/py_func.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tensorflow/python/lib/core/py_func.cc b/tensorflow/python/lib/core/py_func.cc index 57139986af..8c1fa31f05 100644 --- a/tensorflow/python/lib/core/py_func.cc +++ b/tensorflow/python/lib/core/py_func.cc @@ -500,6 +500,11 @@ class PyFuncOp : public OpKernel { call.ins.push_back(ctx->input(i)); } + OP_REQUIRES( + ctx, Py_IsInitialized(), + errors::FailedPrecondition("Python interpreter state is not initialized. " + "The process may be terminated.")); + PyGILState_STATE py_threadstate; py_threadstate = PyGILState_Ensure(); bool log_on_error; -- GitLab From 6cc83f55cd6fbc5af0fd6f1e8220bf9dd392306c Mon Sep 17 00:00:00 2001 From: "Wen-Heng (Jack) Chung" Date: Wed, 1 Aug 2018 15:35:07 +0000 Subject: [PATCH 120/437] Add scratch memory size in AlgorithmDesc Add one field, scratch_size_, into AlgorithmDesc. The field would be set by DNN libraries during algorithm finding / profiling stage. For algorithms not using scratch memory the field would be zero. Change CUDA StreamExecutor implementation to set this field properly. --- tensorflow/stream_executor/cuda/cuda_dnn.cc | 63 ++++++++++++++------- tensorflow/stream_executor/dnn.h | 15 ++++- 2 files changed, 54 insertions(+), 24 deletions(-) diff --git a/tensorflow/stream_executor/cuda/cuda_dnn.cc b/tensorflow/stream_executor/cuda/cuda_dnn.cc index 1c3940e92c..f3955c3455 100644 --- a/tensorflow/stream_executor/cuda/cuda_dnn.cc +++ b/tensorflow/stream_executor/cuda/cuda_dnn.cc @@ -1986,15 +1986,15 @@ GetCudnnConvolutionBackwardFilterAlgo(const CudnnHandle& cudnn, port::StatusOr> AllocateCudnnConvolutionForwardWorkspace( Stream* stream, const CudnnHandle& cudnn, - const dnn::AlgorithmDesc& algorithm_desc, const CudnnTensorDescriptor& input_nd, const CudnnFilterDescriptor& filter, const CudnnConvolutionDescriptor& conv, const CudnnTensorDescriptor& output_nd, + dnn::AlgorithmDesc* algorithm_desc, ScratchAllocator* scratch_allocator) { // TODO(csigg): This has side effects on the convolution descriptor. It is // functionally correct because the convolution is run with the algorithm of // the last call to this function, but should be fixed anyway. - conv.set_use_tensor_op_math(algorithm_desc.tensor_ops_enabled()); + conv.set_use_tensor_op_math(algorithm_desc->tensor_ops_enabled()); // Query the size of the workspace and allocate it. size_t size_in_bytes; @@ -2002,8 +2002,14 @@ port::StatusOr> AllocateCudnnConvolutionForwardWorkspace( cudnn.handle(), /*xDesc=*/input_nd.handle(), /*wDesc=*/filter.handle(), /*convDesc=*/conv.handle(), - /*yDesc=*/output_nd.handle(), /*algo=*/ToConvForwardAlgo(algorithm_desc), + /*yDesc=*/output_nd.handle(), /*algo=*/ToConvForwardAlgo(*algorithm_desc), /*sizeInBytes=*/&size_in_bytes)); + + if (TF_PREDICT_FALSE(!algorithm_desc)) { + return port::Status(port::error::INVALID_ARGUMENT, + "No AlgorithmDesc provided"); + } + algorithm_desc->set_scratch_size(size_in_bytes); int64 size_in_bytes_int64 = size_in_bytes; if (TF_PREDICT_FALSE(size_in_bytes_int64 < 0)) { @@ -2028,15 +2034,15 @@ port::StatusOr> AllocateCudnnConvolutionForwardWorkspace( port::StatusOr> AllocateCudnnConvolutionBackwardDataWorkspace( Stream* stream, const CudnnHandle& cudnn, - const dnn::AlgorithmDesc& algorithm_desc, const CudnnTensorDescriptor& input_nd, const CudnnFilterDescriptor& filter, const CudnnConvolutionDescriptor& conv, const CudnnTensorDescriptor& output_nd, + dnn::AlgorithmDesc* algorithm_desc, ScratchAllocator* scratch_allocator) { // TODO(csigg): This has side effects on the convolution descriptor. It is // functionally correct because the convolution is run with the algorithm of // the last call to this function, but should be fixed anyway. - conv.set_use_tensor_op_math(algorithm_desc.tensor_ops_enabled()); + conv.set_use_tensor_op_math(algorithm_desc->tensor_ops_enabled()); // Query the size of the workspace and allocate it. size_t size_in_bytes; @@ -2046,8 +2052,14 @@ AllocateCudnnConvolutionBackwardDataWorkspace( /*dyDesc=*/output_nd.handle(), /*convDesc=*/conv.handle(), /*dxDesc=*/input_nd.handle(), - /*algo=*/ToConvBackwardDataAlgo(algorithm_desc), + /*algo=*/ToConvBackwardDataAlgo(*algorithm_desc), /*sizeInBytes=*/&size_in_bytes)); + + if (TF_PREDICT_FALSE(!algorithm_desc)) { + return port::Status(port::error::INVALID_ARGUMENT, + "No AlgorithmDesc provided"); + } + algorithm_desc->set_scratch_size(size_in_bytes); int64 size_in_bytes_int64 = size_in_bytes; if (TF_PREDICT_FALSE(size_in_bytes_int64 < 0)) { @@ -2072,15 +2084,15 @@ AllocateCudnnConvolutionBackwardDataWorkspace( port::StatusOr> AllocateCudnnConvolutionBackwardFilterWorkspace( Stream* stream, const CudnnHandle& cudnn, - const dnn::AlgorithmDesc& algorithm_desc, const CudnnTensorDescriptor& input_nd, const CudnnFilterDescriptor& filter, const CudnnConvolutionDescriptor& conv, const CudnnTensorDescriptor& output_nd, + dnn::AlgorithmDesc* algorithm_desc, ScratchAllocator* scratch_allocator) { // TODO(csigg): This has side effects on the convolution descriptor. It is // functionally correct because the convolution is run with the algorithm of // the last call to this function, but should be fixed anyway. - conv.set_use_tensor_op_math(algorithm_desc.tensor_ops_enabled()); + conv.set_use_tensor_op_math(algorithm_desc->tensor_ops_enabled()); // Query the size of the workspace and allocate it. size_t size_in_bytes; @@ -2090,8 +2102,14 @@ AllocateCudnnConvolutionBackwardFilterWorkspace( /*dyDesc=*/output_nd.handle(), /*convDesc=*/conv.handle(), /*gradDesc=*/filter.handle(), - /*algo=*/ToConvBackwardFilterAlgo(algorithm_desc), + /*algo=*/ToConvBackwardFilterAlgo(*algorithm_desc), /*sizeInBytes=*/&size_in_bytes)); + + if (TF_PREDICT_FALSE(!algorithm_desc)) { + return port::Status(port::error::INVALID_ARGUMENT, + "No AlgorithmDesc provided"); + } + algorithm_desc->set_scratch_size(size_in_bytes); int64 size_in_bytes_int64 = size_in_bytes; if (TF_PREDICT_FALSE(size_in_bytes_int64 < 0)) { @@ -2138,7 +2156,7 @@ port::StatusOr GetCudnnConvolutionForwardAlgorithm( } auto scratch_or = AllocateCudnnConvolutionForwardWorkspace( - stream, cudnn, algo_desc, input_nd, filter, conv, output_nd, + stream, cudnn, input_nd, filter, conv, output_nd, &algo_desc, scratch_allocator); if (scratch_or.ok()) { @@ -2155,11 +2173,12 @@ port::StatusOr GetCudnnConvolutionForwardAlgorithm( "while a secondary algorithm is not provided."); } + algo_desc = algorithm_config.algorithm_no_scratch(); SE_ASSIGN_OR_RETURN( *scratch, AllocateCudnnConvolutionForwardWorkspace( - stream, cudnn, algorithm_config.algorithm_no_scratch(), - input_nd, filter, conv, output_nd, scratch_allocator)); - return algorithm_config.algorithm_no_scratch(); + stream, cudnn, + input_nd, filter, conv, output_nd, &algo_desc, scratch_allocator)); + return algo_desc; } port::StatusOr GetCudnnConvolutionBackwardDataAlgorithm( @@ -2187,7 +2206,7 @@ port::StatusOr GetCudnnConvolutionBackwardDataAlgorithm( } auto scratch_or = AllocateCudnnConvolutionBackwardDataWorkspace( - stream, cudnn, algo_desc, input_nd, filter, conv, output_nd, + stream, cudnn, input_nd, filter, conv, output_nd, &algo_desc, scratch_allocator); if (scratch_or.ok()) { @@ -2204,11 +2223,12 @@ port::StatusOr GetCudnnConvolutionBackwardDataAlgorithm( "while a secondary algorithm is not provided."); } + algo_desc = algorithm_config.algorithm_no_scratch(); SE_ASSIGN_OR_RETURN( *scratch, AllocateCudnnConvolutionBackwardDataWorkspace( - stream, cudnn, algorithm_config.algorithm_no_scratch(), - input_nd, filter, conv, output_nd, scratch_allocator)); - return algorithm_config.algorithm_no_scratch(); + stream, cudnn, + input_nd, filter, conv, output_nd, &algo_desc, scratch_allocator)); + return algo_desc; } port::StatusOr GetCudnnConvolutionBackwardFilterAlgorithm( @@ -2236,7 +2256,7 @@ port::StatusOr GetCudnnConvolutionBackwardFilterAlgorithm( } auto scratch_or = AllocateCudnnConvolutionBackwardFilterWorkspace( - stream, cudnn, algo_desc, input_nd, filter, conv, output_nd, + stream, cudnn, input_nd, filter, conv, output_nd, &algo_desc, scratch_allocator); if (scratch_or.ok()) { @@ -2253,11 +2273,12 @@ port::StatusOr GetCudnnConvolutionBackwardFilterAlgorithm( "while a secondary algorithm is not provided."); } + algo_desc = algorithm_config.algorithm_no_scratch(); SE_ASSIGN_OR_RETURN(*scratch, AllocateCudnnConvolutionBackwardFilterWorkspace( - stream, cudnn, algorithm_config.algorithm(), input_nd, - filter, conv, output_nd, scratch_allocator)); - return algorithm_config.algorithm_no_scratch(); + stream, cudnn, input_nd, + filter, conv, output_nd, &algo_desc, scratch_allocator)); + return algo_desc; } // A helper class to set env-vars and choose options for cudnn-related diff --git a/tensorflow/stream_executor/dnn.h b/tensorflow/stream_executor/dnn.h index a7449c2df4..9abfa1db6a 100644 --- a/tensorflow/stream_executor/dnn.h +++ b/tensorflow/stream_executor/dnn.h @@ -713,15 +713,23 @@ class PoolingDescriptor { class AlgorithmDesc { public: typedef int64 Index; - AlgorithmDesc() : algo_(kDefaultAlgorithm), tensor_ops_enabled_(true) {} + AlgorithmDesc() + : algo_(kDefaultAlgorithm), tensor_ops_enabled_(true), scratch_size_(0) {} AlgorithmDesc(Index a, bool use_tensor_ops) - : algo_(a), tensor_ops_enabled_(use_tensor_ops) {} + : algo_(a), tensor_ops_enabled_(use_tensor_ops), scratch_size_(0) {} + AlgorithmDesc(Index a, bool use_tensor_ops, size_t scratch_size) + : algo_(a), + tensor_ops_enabled_(use_tensor_ops), + scratch_size_(scratch_size) {} bool is_default() const { return algo_ == kDefaultAlgorithm; } bool tensor_ops_enabled() const { return tensor_ops_enabled_; } Index algo_id() const { return algo_; } + size_t scratch_size() const { return scratch_size_; } + void set_scratch_size(size_t val) { scratch_size_ = val; } bool operator==(const AlgorithmDesc& other) const { return this->algo_ == other.algo_ && - this->tensor_ops_enabled_ == other.tensor_ops_enabled_; + this->tensor_ops_enabled_ == other.tensor_ops_enabled_ && + this->scratch_size_ == other.scratch_size_; } uint64 hash() const; @@ -729,6 +737,7 @@ class AlgorithmDesc { enum { kDefaultAlgorithm = -1 }; Index algo_; bool tensor_ops_enabled_; + size_t scratch_size_; }; // Describes the result from a perf experiment. -- GitLab From 33dd56457fc89598687609f7d0fb06b2c538da3a Mon Sep 17 00:00:00 2001 From: melvinljy96 <38601254+melvinljy96@users.noreply.github.com> Date: Thu, 2 Aug 2018 15:59:56 +0800 Subject: [PATCH 121/437] Update README.md Add new links and descriptions about Tensorflow. The reasons is to make it more user-friendly and provide more informations to all the users so that they can get the informations quickly and learn more faster. --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 82de010dd4..05a181e414 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ organization for the purposes of conducting machine learning and deep neural networks research. The system is general enough to be applicable in a wide variety of other domains, as well. +TensorFlow provides stable Python API and C APIs as well as without API backwards compatibility guarantee like C++, Go, Java, JavaScript and Swift. + Keep up to date with release announcements and security updates by subscribing to [announce@tensorflow.org](https://groups.google.com/a/tensorflow.org/forum/#!forum/announce). @@ -105,9 +107,12 @@ The TensorFlow project strives to abide by generally accepted best practices in * [TensorFlow Website](https://www.tensorflow.org) * [TensorFlow White Papers](https://www.tensorflow.org/about/bib) * [TensorFlow YouTube Channel](https://www.youtube.com/channel/UC0rqucBdTuFTjJiefW5t-IQ) +* [Tensorflow Twitter](https://twitter.com/tensorflow) +* [Tensorflow Blog](https://medium.com/tensorflow) * [TensorFlow Model Zoo](https://github.com/tensorflow/models) * [TensorFlow MOOC on Udacity](https://www.udacity.com/course/deep-learning--ud730) * [TensorFlow Course at Stanford](https://web.stanford.edu/class/cs20si) +* [TensorFlow Roadmap](https://www.tensorflow.org/community/roadmap) Learn more about the TensorFlow community at the [community page of tensorflow.org](https://www.tensorflow.org/community) for a few ways to participate. -- GitLab From fbd62e568b65a6f5dedeea173d23dd2b28828e43 Mon Sep 17 00:00:00 2001 From: Derek Murray Date: Thu, 2 Aug 2018 11:07:52 -0700 Subject: [PATCH 122/437] Add a defensive comment about the TOCTOU race --- tensorflow/python/lib/core/py_func.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tensorflow/python/lib/core/py_func.cc b/tensorflow/python/lib/core/py_func.cc index 8c1fa31f05..a3c541da87 100644 --- a/tensorflow/python/lib/core/py_func.cc +++ b/tensorflow/python/lib/core/py_func.cc @@ -500,6 +500,12 @@ class PyFuncOp : public OpKernel { call.ins.push_back(ctx->input(i)); } + // NOTE(mrry): There is a potential time-of-check-to-time-of-use race here. + // because it is possible that `Py_Finalize()` could be called in another + // thread between this check and the call to `PyGILState_Ensure()`, which + // will abort the process if `Py_Finalize()` has been called. A more robust + // solution would be welcome, but it is not obvious how to make this work + // using the current Python C API. OP_REQUIRES( ctx, Py_IsInitialized(), errors::FailedPrecondition("Python interpreter state is not initialized. " -- GitLab From e11baf825247ed249d16750dcba0bd43e2a0f653 Mon Sep 17 00:00:00 2001 From: Clayne Robison Date: Thu, 2 Aug 2018 14:49:56 -0700 Subject: [PATCH 123/437] [Intel MKL] Updating artifact references in Readme.md. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 82de010dd4..63379d6c6c 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,8 @@ The TensorFlow project strives to abide by generally accepted best practices in | **IBM s390x** | [![Build Status](http://ibmz-ci.osuosl.org/job/TensorFlow_IBMZ_CI/badge/icon)](http://ibmz-ci.osuosl.org/job/TensorFlow_IBMZ_CI/) | TBA | | **IBM ppc64le CPU** | [![Build Status](http://powerci.osuosl.org/job/TensorFlow_Ubuntu_16.04_CPU/badge/icon)](http://powerci.osuosl.org/job/TensorFlow_Ubuntu_16.04_CPU/) | TBA | | **IBM ppc64le GPU** | [![Build Status](http://powerci.osuosl.org/job/TensorFlow_Ubuntu_16.04_PPC64LE_GPU/badge/icon)](http://powerci.osuosl.org/job/TensorFlow_Ubuntu_16.04_PPC64LE_GPU/) | TBA | -| **Linux CPU with Intel® MKL-DNN®** | [![Build Status](https://tensorflow-ci.intel.com/job/tensorflow-mkl-linux-cpu/badge/icon)](https://tensorflow-ci.intel.com/job/tensorflow-mkl-linux-cpu/) | TBA | +| **Linux CPU with Intel® MKL-DNN®** | [![Build Status](https://tensorflow-ci.intel.com/job/tensorflow-mkl-linux-cpu/badge/icon)](https://tensorflow-ci.intel.com/job/tensorflow-mkl-linux-cpu/) | [Nightly](https://tensorflow-ci.intel.com/job/tensorflow-mkl-build-whl-nightly/) | +| **Linux CPU with Intel® MKL-DNN®** Python 2.7
**Linux CPU with Intel® MKL-DNN®** Python 3.5
**Linux CPU with Intel® MKL-DNN®** Python 3.6| ![Build Status](https://tensorflow-ci.intel.com/job/tensorflow-mkl-build-release-whl/badge/icon)|[1.9.0 py2.7](https://storage.googleapis.com/intel-optimized-tensorflow/tensorflow-1.9.0-cp27-cp27mu-linux_x86_64.whl)
[1.9.0 py3.5](https://storage.googleapis.com/intel-optimized-tensorflow/tensorflow-1.9.0-cp35-cp35m-linux_x86_64.whl)
[1.9.0 py3.6](https://storage.cloud.google.com/intel-optimized-tensorflow/tensorflow-1.9.0-cp36-cp36m-linux_x86_64.whl) | ## For more information -- GitLab From 049c529e567a557461d9ffe8614e6c06a7b3a39f Mon Sep 17 00:00:00 2001 From: zhaoyongke Date: Fri, 3 Aug 2018 10:58:06 +0800 Subject: [PATCH 124/437] Fold bn with depthwise conv, minor typo --- tensorflow/tools/graph_transforms/fold_batch_norms.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tensorflow/tools/graph_transforms/fold_batch_norms.cc b/tensorflow/tools/graph_transforms/fold_batch_norms.cc index 42eebd98c9..cb4230dd82 100644 --- a/tensorflow/tools/graph_transforms/fold_batch_norms.cc +++ b/tensorflow/tools/graph_transforms/fold_batch_norms.cc @@ -73,7 +73,8 @@ Status FoldBatchNorms(const GraphDef& input_graph_def, // Make sure all the inputs really are vectors, with as many entries as // there are columns in the weights. - const int weights_cols_index = conv_node.op() == "Conv2D" ? 3 : (conv_node.op() == "DepthwiseConv2dNative" ? 2 : 1); + const int weights_cols_index = conv_node.op() == "Conv2D" ? 3 : \ + (conv_node.op() == "DepthwiseConv2dNative" ? 2 : 1); const int64 weights_cols = weights.shape().dim_size(weights_cols_index); if ((mul_values.shape().dims() != 1) || (mul_values.shape().dim_size(0) != weights_cols)) { -- GitLab From a2dc1d52ab068b531e85cabaf5043d920b56c0f4 Mon Sep 17 00:00:00 2001 From: cbockman Date: Fri, 3 Aug 2018 16:58:21 -0700 Subject: [PATCH 125/437] fix var type issue which breaks crf_decode CRF decode can fail when default type of "0" (as viewed by math_ops.maximum) does not match the type of sequence_length. This change is parallel in motivation and solution to the fix in https://github.com/tensorflow/tensorflow/commit/c0f1080188c5c6955cfa3b3c086ac262b1e5ec02, for crf_log_norm()=>_multi_seq_fn(). --- tensorflow/contrib/crf/python/ops/crf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tensorflow/contrib/crf/python/ops/crf.py b/tensorflow/contrib/crf/python/ops/crf.py index 8a7ff61bc8..2a91dcb63a 100644 --- a/tensorflow/contrib/crf/python/ops/crf.py +++ b/tensorflow/contrib/crf/python/ops/crf.py @@ -548,7 +548,9 @@ def crf_decode(potentials, transition_params, sequence_length): initial_state = array_ops.squeeze(initial_state, axis=[1]) # [B, O] inputs = array_ops.slice(potentials, [0, 1, 0], [-1, -1, -1]) # [B, T-1, O] # Sequence length is not allowed to be less than zero. - sequence_length_less_one = math_ops.maximum(0, sequence_length - 1) + sequence_length_less_one = math_ops.maximum( + constant_op.constant(0, dtype=sequence_length.dtype), + sequence_length - 1) backpointers, last_score = rnn.dynamic_rnn( # [B, T - 1, O], [B, O] crf_fwd_cell, inputs=inputs, -- GitLab From eec7744f5a29411507ad7c7e5fd9ef19cf07c699 Mon Sep 17 00:00:00 2001 From: cbockman Date: Fri, 3 Aug 2018 17:05:39 -0700 Subject: [PATCH 126/437] Change test cases to ensure survivable to different var types --- tensorflow/contrib/crf/python/kernel_tests/crf_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow/contrib/crf/python/kernel_tests/crf_test.py b/tensorflow/contrib/crf/python/kernel_tests/crf_test.py index f56a973f6f..8cfe142059 100644 --- a/tensorflow/contrib/crf/python/kernel_tests/crf_test.py +++ b/tensorflow/contrib/crf/python/kernel_tests/crf_test.py @@ -158,7 +158,7 @@ class CrfTest(test.TestCase): # Test both the length-1 and regular cases. sequence_lengths_list = [ np.array(3, dtype=np.int32), - np.array(1, dtype=np.int32) + np.array(1, dtype=np.int64) ] inputs_list = [ np.array([[4, 5, -3], [3, -1, 3], [-1, 2, 1], [0, 0, 0]], @@ -291,7 +291,7 @@ class CrfTest(test.TestCase): # Test both the length-1 and regular cases. sequence_lengths_list = [ np.array(3, dtype=np.int32), - np.array(1, dtype=np.int32) + np.array(1, dtype=np.int64) ] inputs_list = [ np.array([[4, 5, -3], [3, -1, 3], [-1, 2, 1], [0, 0, 0]], -- GitLab From b3b04f153dc675f8a7cc0fcd4621c89b91b7490b Mon Sep 17 00:00:00 2001 From: Clayne Robison Date: Fri, 3 Aug 2018 17:13:23 -0700 Subject: [PATCH 127/437] Added 'Nightly' to the row title and made the trademark lawyers happy by removing incorrect (R) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 63379d6c6c..1aaecae6de 100644 --- a/README.md +++ b/README.md @@ -97,8 +97,8 @@ The TensorFlow project strives to abide by generally accepted best practices in | **IBM s390x** | [![Build Status](http://ibmz-ci.osuosl.org/job/TensorFlow_IBMZ_CI/badge/icon)](http://ibmz-ci.osuosl.org/job/TensorFlow_IBMZ_CI/) | TBA | | **IBM ppc64le CPU** | [![Build Status](http://powerci.osuosl.org/job/TensorFlow_Ubuntu_16.04_CPU/badge/icon)](http://powerci.osuosl.org/job/TensorFlow_Ubuntu_16.04_CPU/) | TBA | | **IBM ppc64le GPU** | [![Build Status](http://powerci.osuosl.org/job/TensorFlow_Ubuntu_16.04_PPC64LE_GPU/badge/icon)](http://powerci.osuosl.org/job/TensorFlow_Ubuntu_16.04_PPC64LE_GPU/) | TBA | -| **Linux CPU with Intel® MKL-DNN®** | [![Build Status](https://tensorflow-ci.intel.com/job/tensorflow-mkl-linux-cpu/badge/icon)](https://tensorflow-ci.intel.com/job/tensorflow-mkl-linux-cpu/) | [Nightly](https://tensorflow-ci.intel.com/job/tensorflow-mkl-build-whl-nightly/) | -| **Linux CPU with Intel® MKL-DNN®** Python 2.7
**Linux CPU with Intel® MKL-DNN®** Python 3.5
**Linux CPU with Intel® MKL-DNN®** Python 3.6| ![Build Status](https://tensorflow-ci.intel.com/job/tensorflow-mkl-build-release-whl/badge/icon)|[1.9.0 py2.7](https://storage.googleapis.com/intel-optimized-tensorflow/tensorflow-1.9.0-cp27-cp27mu-linux_x86_64.whl)
[1.9.0 py3.5](https://storage.googleapis.com/intel-optimized-tensorflow/tensorflow-1.9.0-cp35-cp35m-linux_x86_64.whl)
[1.9.0 py3.6](https://storage.cloud.google.com/intel-optimized-tensorflow/tensorflow-1.9.0-cp36-cp36m-linux_x86_64.whl) | +| **Linux CPU with Intel® MKL-DNN** Nightly | [![Build Status](https://tensorflow-ci.intel.com/job/tensorflow-mkl-linux-cpu/badge/icon)](https://tensorflow-ci.intel.com/job/tensorflow-mkl-linux-cpu/) | [Nightly](https://tensorflow-ci.intel.com/job/tensorflow-mkl-build-whl-nightly/) | +| **Linux CPU with Intel® MKL-DNN** Python 2.7
**Linux CPU with Intel® MKL-DNN** Python 3.5
**Linux CPU with Intel® MKL-DNN** Python 3.6| ![Build Status](https://tensorflow-ci.intel.com/job/tensorflow-mkl-build-release-whl/badge/icon)|[1.9.0 py2.7](https://storage.googleapis.com/intel-optimized-tensorflow/tensorflow-1.9.0-cp27-cp27mu-linux_x86_64.whl)
[1.9.0 py3.5](https://storage.googleapis.com/intel-optimized-tensorflow/tensorflow-1.9.0-cp35-cp35m-linux_x86_64.whl)
[1.9.0 py3.6](https://storage.cloud.google.com/intel-optimized-tensorflow/tensorflow-1.9.0-cp36-cp36m-linux_x86_64.whl) | ## For more information -- GitLab From fd7c6bd68d9c333b457b3692eef102088fbb5874 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Sat, 4 Aug 2018 20:31:10 +0000 Subject: [PATCH 128/437] Fix issue with tf.nn.relu6 grad in eager This fix tries to address the issue raised in 21380 where the gradient of tf.nn.relu6 throws out an error. The issue seems to be that relu6 was not placed in OpDoesntRequireInput like tf.nn.relu. This fix fixes 21380. Signed-off-by: Yong Tang --- tensorflow/python/eager/pywrap_tfe_src.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/python/eager/pywrap_tfe_src.cc b/tensorflow/python/eager/pywrap_tfe_src.cc index 0eabea321c..2d54555cd3 100644 --- a/tensorflow/python/eager/pywrap_tfe_src.cc +++ b/tensorflow/python/eager/pywrap_tfe_src.cc @@ -1726,7 +1726,6 @@ bool OpDoesntRequireOutput(const string& op_name) { "BiasAdd", "BiasAddV1", "BiasAddGrad", - "Relu6", "Softplus", "SoftplusGrad", "Softsign", @@ -1799,6 +1798,7 @@ bool OpDoesntRequireInput(const string& op_name) { "LogSoftmax", "BiasAdd", "Relu", + "Relu6", "Elu", "Selu", "SparseSoftmaxCrossEntropyWithLogits", -- GitLab From 88c5c8b3ed1440435a8aeac8186d7ecfc83b97ab Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Sun, 5 Aug 2018 16:26:40 +0000 Subject: [PATCH 129/437] Fix warning in image_ops_test While running test: ``` bazel test -s --verbose_failures --config=opt --cache_test_results=no //tensorflow/python:image_ops_test ``` The following warning showed up: ``` WARNING:tensorflow:From /home/ubuntu/.cache/bazel/_bazel_ubuntu/ad1e09741bb4109fbc70ef8216b59ee2/execroot/org_tensorflow/bazel-out/k8-opt/bin/tensorflow/python/image_ops_test.runfiles/org_tensorflow/tensorflow/python/ops/image_ops_impl.py:1170: calling squeeze (from tensorflow.python.ops.array_ops) with squeeze_dims is deprecated and will be removed in a future version. Instructions for updating: Use the `axis` argument instead ``` This fix fixes the above warning. Signed-off-by: Yong Tang --- tensorflow/python/ops/image_ops_impl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/python/ops/image_ops_impl.py b/tensorflow/python/ops/image_ops_impl.py index 855a4d0c33..945864600b 100644 --- a/tensorflow/python/ops/image_ops_impl.py +++ b/tensorflow/python/ops/image_ops_impl.py @@ -1167,7 +1167,7 @@ def resize_image_with_pad(image, _ImageDimensions(padded, rank=4) if not is_batch: - padded = array_ops.squeeze(padded, squeeze_dims=[0]) + padded = array_ops.squeeze(padded, axis=[0]) return padded -- GitLab From a637166088a6f73f49a4a505a07759eb0d8b14e2 Mon Sep 17 00:00:00 2001 From: Pei Zhang Date: Mon, 6 Aug 2018 16:08:02 +0800 Subject: [PATCH 130/437] cross compile tool chain name error The space between the CC_PREFIX and gcc makes system failed to find the correct gcc binary. Signed-off-by: Pei Zhang --- tensorflow/contrib/lite/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tensorflow/contrib/lite/Makefile b/tensorflow/contrib/lite/Makefile index 92635ff430..979e88611f 100644 --- a/tensorflow/contrib/lite/Makefile +++ b/tensorflow/contrib/lite/Makefile @@ -81,12 +81,12 @@ ifeq ($(TARGET_ARCH),armm1) endif # Settings for the host compiler. -CXX := $(CC_PREFIX) ${TARGET_TOOLCHAIN_PREFIX}g++ +CXX := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}g++ CXXFLAGS += -O3 -DNDEBUG CCFLAGS := ${CXXFLAGS} CXXFLAGS += --std=c++11 -CC := $(CC_PREFIX) ${TARGET_TOOLCHAIN_PREFIX}gcc -AR := $(CC_PREFIX) ${TARGET_TOOLCHAIN_PREFIX}ar +CC := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}gcc +AR := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}ar CFLAGS := LDOPTS := LDOPTS += -L/usr/local/lib -- GitLab From 26076b456f17a4b24f209d26dc0ea7f608913450 Mon Sep 17 00:00:00 2001 From: "William D. Irons" Date: Mon, 6 Aug 2018 15:11:56 -0500 Subject: [PATCH 131/437] run test shell scripts for ppc64le to be invoked using ci_build.sh from the root of the tensorflow project. For example: ./tensorflow/tools/ci_build/ci_build.sh gpu --dockerfile \ tensorflow/tools/ci_build/Dockerfile.gpu.ppc64le \ ./tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh --- .../ci_build/linux/ppc64le/cpu/run_cc_core.sh | 38 ++++++++++++++++ .../linux/ppc64le/cpu/run_py2_core.sh | 37 +++++++++++++++ .../linux/ppc64le/cpu/run_py3_contrib.sh | 37 +++++++++++++++ .../linux/ppc64le/cpu/run_py3_core.sh | 37 +++++++++++++++ .../ci_build/linux/ppc64le/gpu/run_cc_core.sh | 45 +++++++++++++++++++ .../linux/ppc64le/gpu/run_py2_core.sh | 45 +++++++++++++++++++ .../linux/ppc64le/gpu/run_py3_core.sh | 45 +++++++++++++++++++ 7 files changed, 284 insertions(+) create mode 100755 tensorflow/tools/ci_build/linux/ppc64le/cpu/run_cc_core.sh create mode 100755 tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py2_core.sh create mode 100755 tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_contrib.sh create mode 100755 tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_core.sh create mode 100755 tensorflow/tools/ci_build/linux/ppc64le/gpu/run_cc_core.sh create mode 100755 tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2_core.sh create mode 100755 tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh diff --git a/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_cc_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_cc_core.sh new file mode 100755 index 0000000000..d026d00d47 --- /dev/null +++ b/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_cc_core.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# Copyright 2016 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============================================================================== + +set -e +set -x + +N_JOBS=$(grep -c ^processor /proc/cpuinfo) + +echo "" +echo "Bazel will use ${N_JOBS} concurrent job(s)." +echo "" + +# Run configure. +export TF_NEED_CUDA=0 +export CC_OPT_FLAGS='-mcpu=power8 -mtune=power8' +# Only running cc tests, python version does not matter. +export PYTHON_BIN_PATH=`which python` +yes "" | $PYTHON_BIN_PATH configure.py + +# Run bazel test command. Double test timeouts to avoid flakes. +bazel test --test_tag_filters=-no_oss,-gpu,-benchmark-test --test_lang_filters=cc,java -k \ + --jobs=${N_JOBS} --test_timeout 300,450,1200,3600 --config=opt \ + --test_output=errors --test_size_filters=small,medium -- \ + //tensorflow/... -//tensorflow/compiler/... -//tensorflow/contrib/... diff --git a/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py2_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py2_core.sh new file mode 100755 index 0000000000..22a8ddf388 --- /dev/null +++ b/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py2_core.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# Copyright 2016 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============================================================================== + +set -e +set -x + +N_JOBS=$(grep -c ^processor /proc/cpuinfo) + +echo "" +echo "Bazel will use ${N_JOBS} concurrent job(s)." +echo "" + +# Run configure. +export TF_NEED_CUDA=0 +export CC_OPT_FLAGS='-mcpu=power8 -mtune=power8' +export PYTHON_BIN_PATH=`which python2` +yes "" | $PYTHON_BIN_PATH configure.py + +# Run bazel test command. Double test timeouts to avoid flakes. +bazel test --test_tag_filters=-no_oss,-oss_serial,-gpu,-benchmark-test --test_lang_filters=py -k \ + --jobs=${N_JOBS} --test_timeout 300,450,1200,3600 --build_tests_only --config=opt \ + --test_output=errors --test_size_filters=small,medium -- \ + //tensorflow/... -//tensorflow/compiler/... -//tensorflow/contrib/... diff --git a/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_contrib.sh b/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_contrib.sh new file mode 100755 index 0000000000..658410a1a5 --- /dev/null +++ b/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_contrib.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# Copyright 2017 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============================================================================== + +set -e +set -x + +N_JOBS=$(grep -c ^processor /proc/cpuinfo) + +echo "" +echo "Bazel will use ${N_JOBS} concurrent job(s)." +echo "" + +# Run configure. +export TF_NEED_CUDA=0 +export CC_OPT_FLAGS='-mcpu=power8 -mtune=power8' +export PYTHON_BIN_PATH=`which python3` +yes "" | $PYTHON_BIN_PATH configure.py + +# Run bazel test command. Double test timeouts to avoid flakes. +bazel test --test_tag_filters=-no_oss,-oss_serial,-gpu,-benchmark-test -k \ + --jobs=${N_JOBS} --test_timeout 300,450,1200,3600 --config=opt \ + --test_size_filters=small,medium --test_output=errors -- \ + //tensorflow/contrib/... diff --git a/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_core.sh new file mode 100755 index 0000000000..8557b70037 --- /dev/null +++ b/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_core.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# Copyright 2017 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============================================================================== + +set -e +set -x + +N_JOBS=$(grep -c ^processor /proc/cpuinfo) + +echo "" +echo "Bazel will use ${N_JOBS} concurrent job(s)." +echo "" + +# Run configure. +export TF_NEED_CUDA=0 +export CC_OPT_FLAGS='-mcpu=power8 -mtune=power8' +export PYTHON_BIN_PATH=`which python3` +yes "" | $PYTHON_BIN_PATH configure.py + +# Run bazel test command. Double test timeouts to avoid flakes. +bazel test --test_tag_filters=-no_oss,-oss_serial,-gpu,-benchmark-test --test_lang_filters=py -k \ + --jobs=${N_JOBS} --test_timeout 300,450,1200,3600 --build_tests_only --config=opt \ + --test_output=errors --test_size_filters=small,medium -- \ + //tensorflow/... -//tensorflow/compiler/... -//tensorflow/contrib/... diff --git a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_cc_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_cc_core.sh new file mode 100755 index 0000000000..b220676b77 --- /dev/null +++ b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_cc_core.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# Copyright 2017 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============================================================================== + +set -e +set -x + +N_JOBS=$(grep -c ^processor /proc/cpuinfo) + +echo "" +echo "Bazel will use ${N_JOBS} concurrent job(s)." +echo "" + +# Run configure. +export PYTHON_BIN_PATH=`which python3` +export CC_OPT_FLAGS='-mcpu=power8 -mtune=power8' + +#TODO get NCCL 2 in the docker image +export TF_NCCL_VERSION=1 + +export TF_NEED_CUDA=1 +export TF_CUDA_COMPUTE_CAPABILITIES=3.7 + +yes "" | $PYTHON_BIN_PATH configure.py + +# Run bazel test command. Double test timeouts to avoid flakes. +bazel test --config=cuda --test_tag_filters=-no_oss,-oss_serial,-no_gpu,-benchmark-test -k \ + --test_lang_filters=cc --jobs=${N_JOBS} --test_timeout 300,450,1200,3600 \ + --build_tests_only --test_output=errors --local_test_jobs=8 --config=opt \ + --test_size_filters=small,medium \ + --run_under=//tensorflow/tools/ci_build/gpu_build:parallel_gpu_execute -- \ + //tensorflow/... -//tensorflow/compiler/... -//tensorflow/contrib/... diff --git a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2_core.sh new file mode 100755 index 0000000000..019b52d8a0 --- /dev/null +++ b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2_core.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# Copyright 2017 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============================================================================== + +set -e +set -x + +N_JOBS=$(grep -c ^processor /proc/cpuinfo) + +echo "" +echo "Bazel will use ${N_JOBS} concurrent job(s)." +echo "" + +# Run configure. +export PYTHON_BIN_PATH=`which python` +export CC_OPT_FLAGS='-mcpu=power8 -mtune=power8' + +#TODO get NCCL 2 in the docker image +export TF_NCCL_VERSION=1 + +export TF_NEED_CUDA=1 +export TF_CUDA_COMPUTE_CAPABILITIES=3.7 + +yes "" | $PYTHON_BIN_PATH configure.py + +# Run bazel test command. Double test timeouts to avoid flakes. +bazel test --config=cuda --test_tag_filters=-no_oss,-oss_serial,-no_gpu,-benchmark-test -k \ + --test_lang_filters=py --jobs=${N_JOBS} --test_timeout 300,450,1200,3600 \ + --build_tests_only --test_output=errors --local_test_jobs=8 --config=opt \ + --test_size_filters=small,medium \ + --run_under=//tensorflow/tools/ci_build/gpu_build:parallel_gpu_execute -- \ + //tensorflow/... -//tensorflow/compiler/... -//tensorflow/contrib/... diff --git a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh new file mode 100755 index 0000000000..7a28ee87c0 --- /dev/null +++ b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# Copyright 2017 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ============================================================================== + +set -e +set -x + +N_JOBS=$(grep -c ^processor /proc/cpuinfo) + +echo "" +echo "Bazel will use ${N_JOBS} concurrent job(s)." +echo "" + +# Run configure. +export PYTHON_BIN_PATH=`which python3` +export CC_OPT_FLAGS='-mcpu=power8 -mtune=power8' + +#TODO get NCCL 2 in the docker image +export TF_NCCL_VERSION=1 + +export TF_NEED_CUDA=1 +export TF_CUDA_COMPUTE_CAPABILITIES=3.7 + +yes "" | $PYTHON_BIN_PATH configure.py + +# Run bazel test command. Double test timeouts to avoid flakes. +bazel test --config=cuda --test_tag_filters=-no_oss,-oss_serial,-no_gpu,-benchmark-test -k \ + --test_lang_filters=py --jobs=${N_JOBS} --test_timeout 300,450,1200,3600 \ + --build_tests_only --test_output=errors --local_test_jobs=8 --config=opt \ + --test_size_filters=small,medium \ + --run_under=//tensorflow/tools/ci_build/gpu_build:parallel_gpu_execute -- \ + //tensorflow/... -//tensorflow/compiler/... -//tensorflow/contrib/... -- GitLab From 70e9b1fe3dc774150daa910bd044338a44acd3a4 Mon Sep 17 00:00:00 2001 From: AG Ramesh Date: Mon, 6 Aug 2018 14:24:47 -0700 Subject: [PATCH 132/437] Updated based on github comments --- tensorflow/core/kernels/matmul_op.cc | 35 ++++++++++++------------ tensorflow/core/kernels/mkl_matmul_op.cc | 6 ++-- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/tensorflow/core/kernels/matmul_op.cc b/tensorflow/core/kernels/matmul_op.cc index c0bb9e5c50..0c6bb79964 100644 --- a/tensorflow/core/kernels/matmul_op.cc +++ b/tensorflow/core/kernels/matmul_op.cc @@ -578,38 +578,39 @@ struct MatMulFunctor { .Label("cublas"), \ MatMulOp) -#if defined(INTEL_MKL) && !defined(DO_NOT_USE_ML) +#if defined(INTEL_MKL) -// MKL does not support half and int32 types for matrix-multiplication, so +// MKL does not support half, bfloat16 and int32 types for matrix-multiplication, so // register the kernel to use default Eigen based implementations for these -// types. Registration for NO-LABEL version is in mkl_matmul_op.cc -TF_CALL_float(REGISTER_CPU_EIGEN); -TF_CALL_double(REGISTER_CPU_EIGEN); +// types. REGISTER_CPU defines two versions - Eigen label and NO-LABEL TF_CALL_half(REGISTER_CPU); TF_CALL_bfloat16(REGISTER_CPU); - TF_CALL_int32(REGISTER_CPU); -TF_CALL_complex64(REGISTER_CPU_EIGEN); -TF_CALL_complex128(REGISTER_CPU_EIGEN); -#elif defined(INTEL_MKL) && defined(DO_NOT_USE_ML) - -// MKL opensource supports only float for matrix-multiplication +// Float is supported in both MKL DNN as well as in MKL ML +// Registration for NO-LABEL version is in mkl_matmul_op.cc for types supported by +// MKL. However we define Eigen label version here just to pass a few unit tests TF_CALL_float(REGISTER_CPU_EIGEN); -TF_CALL_double(REGISTER_CPU); -TF_CALL_half(REGISTER_CPU); -TF_CALL_bfloat16(REGISTER_CPU); -TF_CALL_int32(REGISTER_CPU); +// MKL DNN does not support complex64/complex128/double, if user specifies +// to use only opensource MKL DNN then use default implementation for these types +// otherwise use GEMM from MKL ML binary + +#if defined(DO_NOT_USE_ML) TF_CALL_complex64(REGISTER_CPU); TF_CALL_complex128(REGISTER_CPU); +TF_CALL_double(REGISTER_CPU); +#else // DO_NOT_USE_ML +TF_CALL_complex64(REGISTER_CPU_EIGEN); +TF_CALL_complex128(REGISTER_CPU_EIGEN); +TF_CALL_double(REGISTER_CPU_EIGEN); +#endif -#else +#else // INTEL MKL TF_CALL_float(REGISTER_CPU); TF_CALL_double(REGISTER_CPU); TF_CALL_half(REGISTER_CPU); TF_CALL_bfloat16(REGISTER_CPU); - TF_CALL_int32(REGISTER_CPU); TF_CALL_complex64(REGISTER_CPU); TF_CALL_complex128(REGISTER_CPU); diff --git a/tensorflow/core/kernels/mkl_matmul_op.cc b/tensorflow/core/kernels/mkl_matmul_op.cc index e8166a1f7c..d031d8d7f8 100644 --- a/tensorflow/core/kernels/mkl_matmul_op.cc +++ b/tensorflow/core/kernels/mkl_matmul_op.cc @@ -31,6 +31,7 @@ limitations under the License. #include "tensorflow/core/framework/register_types.h" #include "tensorflow/core/kernels/fill_functor.h" +//This header file is part of MKL ML, need equivalent file in MKL DNN #ifndef DO_NOT_USE_ML #include "mkl_cblas.h" #else @@ -160,11 +161,12 @@ class MklMatMulOp : public OpKernel { int index_transa = transa? 1 : 0 ; int index_transb = transb? 1 : 0 ; VLOG(2) << "MKL DNN SGEMM called"; - //Using the fortran api of mkldnn - //Since TF is in row major layout,reversing the order of A and B + // MKL DNN only supports the Fortran api and requires column major while Tensorflow + // uses row major so we reverse the order A and B mkldnn_sgemm(ftrans[index_transb], ftrans[index_transa], &n, &m, &k, &alpha, b, &ldb, a, &lda, &beta, c, &ldc); #else + // MKL ML binary uses CBLAS API cblas_sgemm(CblasRowMajor, transa ? CblasTrans : CblasNoTrans, transb ? CblasTrans : CblasNoTrans, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc); -- GitLab From 1a2ea9bd3be2c041e2cd5d605502365e74ac722c Mon Sep 17 00:00:00 2001 From: Andrew Gibiansky Date: Mon, 6 Aug 2018 22:44:36 +0000 Subject: [PATCH 133/437] Don't include -lpthread for android --- tensorflow/core/BUILD | 1 + 1 file changed, 1 insertion(+) diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD index 1423c7fbcb..3ed393f486 100644 --- a/tensorflow/core/BUILD +++ b/tensorflow/core/BUILD @@ -2037,6 +2037,7 @@ cc_library( "//tensorflow:freebsd": [], "//tensorflow:windows": [], "//tensorflow:windows_msvc": [], + "//tensorflow:android": [], "//conditions:default": [ "-ldl", "-lpthread", -- GitLab From fac5feee5fb8cbcee4b787b3d21245bd739e0c9e Mon Sep 17 00:00:00 2001 From: Andrew Gibiansky Date: Mon, 6 Aug 2018 22:50:11 +0000 Subject: [PATCH 134/437] Fix bazel issue with jpeg lib on arm v7 --- third_party/jpeg/jpeg.BUILD | 2 ++ 1 file changed, 2 insertions(+) diff --git a/third_party/jpeg/jpeg.BUILD b/third_party/jpeg/jpeg.BUILD index 663a218733..b36295ad06 100644 --- a/third_party/jpeg/jpeg.BUILD +++ b/third_party/jpeg/jpeg.BUILD @@ -272,8 +272,10 @@ cc_library( "jchuff.h", "jconfig.h", "jdct.h", + "jerror.h", "jinclude.h", "jmorecfg.h", + "jpegint.h", "jpeglib.h", "jsimd.h", "jsimddct.h", -- GitLab From d9deec2f5bb24a69afd90492ec93e478631a4cf3 Mon Sep 17 00:00:00 2001 From: Justin Shenk Date: Tue, 7 Aug 2018 01:16:51 +0200 Subject: [PATCH 135/437] Fix markdown formatting by removing indent Previous display:
 $ pip3 install tensorflow     # Python 3.n
  $ pip install tensorflow      # Python 2.7
--- tensorflow/docs_src/install/install_raspbian.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow/docs_src/install/install_raspbian.md b/tensorflow/docs_src/install/install_raspbian.md index 58a5285c78..1c8eecf244 100644 --- a/tensorflow/docs_src/install/install_raspbian.md +++ b/tensorflow/docs_src/install/install_raspbian.md @@ -78,8 +78,8 @@ your system, run the following command: Assuming the prerequisite software is installed on your Pi, install TensorFlow by invoking **one** of the following commands: -
 $ pip3 install tensorflow     # Python 3.n
-     $ pip install tensorflow      # Python 2.7
+
 $ pip3 install tensorflow     # Python 3.n
+$ pip install tensorflow      # Python 2.7
This can take some time on certain platforms like the Pi Zero, where some Python packages like scipy that TensorFlow depends on need to be compiled before the -- GitLab From b5cb9f07655040bdc6dc2e9ece0892163fe7d2ba Mon Sep 17 00:00:00 2001 From: Justin Shenk Date: Tue, 7 Aug 2018 01:17:31 +0200 Subject: [PATCH 136/437] Fix spacing Remove extra space --- tensorflow/docs_src/install/install_raspbian.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/docs_src/install/install_raspbian.md b/tensorflow/docs_src/install/install_raspbian.md index 1c8eecf244..b10e081d5e 100644 --- a/tensorflow/docs_src/install/install_raspbian.md +++ b/tensorflow/docs_src/install/install_raspbian.md @@ -78,7 +78,7 @@ your system, run the following command: Assuming the prerequisite software is installed on your Pi, install TensorFlow by invoking **one** of the following commands: -
 $ pip3 install tensorflow     # Python 3.n
+
$ pip3 install tensorflow     # Python 3.n
 $ pip install tensorflow      # Python 2.7
This can take some time on certain platforms like the Pi Zero, where some Python -- GitLab From 9d5e8b25072db34d8bf550e09acd351f126f5075 Mon Sep 17 00:00:00 2001 From: Justin Shenk Date: Tue, 7 Aug 2018 01:20:14 +0200 Subject: [PATCH 137/437] Add shell prompt ("$") to command --- tensorflow/docs_src/install/install_raspbian.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/docs_src/install/install_raspbian.md b/tensorflow/docs_src/install/install_raspbian.md index b10e081d5e..cf6b6b4f79 100644 --- a/tensorflow/docs_src/install/install_raspbian.md +++ b/tensorflow/docs_src/install/install_raspbian.md @@ -60,7 +60,7 @@ If it gives the error "Command not found", then the package has not been installed yet. To install if for the first time, run:
$ sudo apt-get install python3-pip # for Python 3.n
-sudo apt-get install python-pip # for Python 2.7
+$ sudo apt-get install python-pip # for Python 2.7
You can find more help on installing and upgrading pip in [the Raspberry Pi documentation](https://www.raspberrypi.org/documentation/linux/software/python.md). -- GitLab From bd3f56b6adcc5303e5fff36bb64c9ef5e0195baf Mon Sep 17 00:00:00 2001 From: Bixia Zheng Date: Mon, 6 Aug 2018 22:31:21 -0700 Subject: [PATCH 138/437] [XLA:CPU/GPU] Fix a problem in the random number generator for F16. ConvertValueForDistribution incorrectly uses the element type to perform the division that reduces the raw value to the range of [0, 1). When the element type is F16, the result of a division result is always zero due to overflow and the generator always generates a value equal to the lower bound of the requested range. To fix this problem, we perform the division using the float type with the same number of bits as the raw value type. PiperOrigin-RevId: 207662942 --- .../xla/service/elemental_ir_emitter.cc | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tensorflow/compiler/xla/service/elemental_ir_emitter.cc b/tensorflow/compiler/xla/service/elemental_ir_emitter.cc index f05c2d63d2..6aab317ca5 100644 --- a/tensorflow/compiler/xla/service/elemental_ir_emitter.cc +++ b/tensorflow/compiler/xla/service/elemental_ir_emitter.cc @@ -1239,13 +1239,23 @@ StatusOr ElementalIrEmitter::ConvertValueForDistribution( // Convert raw integer to float in range [0, 1) if the element is a float. llvm::Value* elem_value = raw_value; if (elem_ir_ty->isFloatingPointTy()) { - elem_value = b_->CreateUIToFP(elem_value, elem_ir_ty); unsigned raw_value_size_in_bits = raw_value_ty->getPrimitiveSizeInBits(); CHECK(raw_value_size_in_bits == 32 || raw_value_size_in_bits == 64); - elem_value = b_->CreateFDiv( - elem_value, - llvm::ConstantFP::get(elem_ir_ty, - raw_value_size_in_bits == 64 ? 0x1p64 : 0x1p32)); + // Perform the division using the float type with the same number of bits + // as the raw value to avoid overflow. + if (raw_value_size_in_bits == 32) { + elem_value = b_->CreateUIToFP(elem_value, b_->getFloatTy()); + elem_value = b_->CreateFDiv( + elem_value, llvm::ConstantFP::get(b_->getFloatTy(), std::exp2(32))); + } else { + elem_value = b_->CreateUIToFP(elem_value, b_->getDoubleTy()); + elem_value = b_->CreateFDiv( + elem_value, llvm::ConstantFP::get(b_->getDoubleTy(), std::exp2(64))); + } + + if (elem_ir_ty != elem_value->getType()) { + elem_value = b_->CreateFPTrunc(elem_value, elem_ir_ty); + } } // Convert the value for the requested distribution. -- GitLab From cb685b69f5b6e19ab6ffdccc9e3a693add1536b2 Mon Sep 17 00:00:00 2001 From: Jason Zaman Date: Wed, 1 Aug 2018 23:48:24 +0800 Subject: [PATCH 139/437] lib / pip_package: only include licenses if option is enabled The license files were included unconditionally so the whole dependency needs to be downloaded even if disabled and not used. This puts them behind in a select() so they are only included when the feature is enabled for the build and significantly reduces the dependencies when configured without all the cloud options. Signed-off-by: Jason Zaman --- tensorflow/tools/lib_package/BUILD | 78 ++++++++++++++++++++++++------ tensorflow/tools/pip_package/BUILD | 42 ++++++++++++---- 2 files changed, 95 insertions(+), 25 deletions(-) diff --git a/tensorflow/tools/lib_package/BUILD b/tensorflow/tools/lib_package/BUILD index 44d8a37a8f..b450bc42c5 100644 --- a/tensorflow/tools/lib_package/BUILD +++ b/tensorflow/tools/lib_package/BUILD @@ -4,7 +4,9 @@ package(default_visibility = ["//visibility:private"]) load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar") +load("@local_config_syslibs//:build_defs.bzl", "if_not_system_lib") load("//tensorflow:tensorflow.bzl", "tf_binary_additional_srcs") +load("//tensorflow:tensorflow.bzl", "if_cuda") load("//third_party/mkl:build_defs.bzl", "if_mkl") genrule( @@ -113,11 +115,8 @@ genrule( "//third_party/hadoop:LICENSE.txt", "//third_party/eigen3:LICENSE", "//third_party/fft2d:LICENSE", - "@aws//:LICENSE", "@boringssl//:LICENSE", - "@com_github_googlecloudplatform_google_cloud_cpp//:LICENSE", "@com_googlesource_code_re2//:LICENSE", - "@cub_archive//:LICENSE.TXT", "@curl//:COPYING", "@double_conversion//:LICENSE", "@eigen_archive//:COPYING.MPL2", @@ -125,13 +124,8 @@ genrule( "@fft2d//:fft/readme.txt", "@gemmlowp//:LICENSE", "@gif_archive//:COPYING", - "@grpc//:LICENSE", - "@grpc//third_party/address_sorting:LICENSE", - "@grpc//third_party/nanopb:LICENSE.txt", "@highwayhash//:LICENSE", - "@jemalloc//:COPYING", "@jpeg//:LICENSE.md", - "@libxsmm_archive//:LICENSE.md", "@llvm//:LICENSE.TXT", "@lmdb//:LICENSE", "@local_config_sycl//sycl:LICENSE.text", @@ -141,10 +135,42 @@ genrule( "@protobuf_archive//:LICENSE", "@snappy//:COPYING", "@zlib_archive//:zlib.h", - ] + if_mkl([ + ] + select({ + "//tensorflow:with_aws_support": [ + "@aws//:LICENSE", + ], + "//conditions:default": [], + }) + select({ + "//tensorflow:with_gcp_support": [ + "@com_github_googlecloudplatform_google_cloud_cpp//:LICENSE", + ], + "//conditions:default": [], + }) + select({ + "//tensorflow:with_jemalloc_linux_x86_64": [ + "@jemalloc//:COPYING", + ], + "//tensorflow:with_jemalloc_linux_ppc64le": [ + "@jemalloc//:COPYING", + ], + "//conditions:default": [], + }) + select({ + "//tensorflow/core/kernels:xsmm": [ + "@libxsmm_archive//:LICENSE.md", + ], + "//conditions:default": [], + }) + if_cuda([ + "@cub_archive//:LICENSE.TXT", + ]) + if_mkl([ "//third_party/mkl:LICENSE", "//third_party/mkl_dnn:LICENSE", - ]), + ]) + if_not_system_lib( + "grpc", + [ + "@grpc//:LICENSE", + "@grpc//third_party/nanopb:LICENSE.txt", + "@grpc//third_party/address_sorting:LICENSE", + ], + ), outs = ["include/tensorflow/c/LICENSE"], cmd = "$(location :concat_licenses.sh) $(SRCS) >$@", tools = [":concat_licenses.sh"], @@ -156,11 +182,8 @@ genrule( "//third_party/hadoop:LICENSE.txt", "//third_party/eigen3:LICENSE", "//third_party/fft2d:LICENSE", - "@aws//:LICENSE", "@boringssl//:LICENSE", - "@com_github_googlecloudplatform_google_cloud_cpp//:LICENSE", "@com_googlesource_code_re2//:LICENSE", - "@cub_archive//:LICENSE.TXT", "@curl//:COPYING", "@double_conversion//:LICENSE", "@eigen_archive//:COPYING.MPL2", @@ -169,9 +192,7 @@ genrule( "@gemmlowp//:LICENSE", "@gif_archive//:COPYING", "@highwayhash//:LICENSE", - "@jemalloc//:COPYING", "@jpeg//:LICENSE.md", - "@libxsmm_archive//:LICENSE.md", "@llvm//:LICENSE.TXT", "@lmdb//:LICENSE", "@local_config_sycl//sycl:LICENSE.text", @@ -181,7 +202,32 @@ genrule( "@protobuf_archive//:LICENSE", "@snappy//:COPYING", "@zlib_archive//:zlib.h", - ] + if_mkl([ + ] + select({ + "//tensorflow:with_aws_support": [ + "@aws//:LICENSE", + ], + "//conditions:default": [], + }) + select({ + "//tensorflow:with_gcp_support": [ + "@com_github_googlecloudplatform_google_cloud_cpp//:LICENSE", + ], + "//conditions:default": [], + }) + select({ + "//tensorflow:with_jemalloc_linux_x86_64": [ + "@jemalloc//:COPYING", + ], + "//tensorflow:with_jemalloc_linux_ppc64le": [ + "@jemalloc//:COPYING", + ], + "//conditions:default": [], + }) + select({ + "//tensorflow/core/kernels:xsmm": [ + "@libxsmm_archive//:LICENSE.md", + ], + "//conditions:default": [], + }) + if_cuda([ + "@cub_archive//:LICENSE.TXT", + ]) + if_mkl([ "//third_party/mkl:LICENSE", "//third_party/mkl_dnn:LICENSE", ]), diff --git a/tensorflow/tools/pip_package/BUILD b/tensorflow/tools/pip_package/BUILD index 06ee2307e5..ef7ae1aa25 100644 --- a/tensorflow/tools/pip_package/BUILD +++ b/tensorflow/tools/pip_package/BUILD @@ -131,13 +131,9 @@ filegroup( "@absl_py//absl/flags:LICENSE", "@arm_neon_2_x86_sse//:LICENSE", "@astor_archive//:LICENSE", - "@aws//:LICENSE", "@boringssl//:LICENSE", - "@com_github_googleapis_googleapis//:LICENSE", - "@com_github_googlecloudplatform_google_cloud_cpp//:LICENSE", "@com_google_absl//:LICENSE", "@com_googlesource_code_re2//:LICENSE", - "@cub_archive//:LICENSE.TXT", "@curl//:COPYING", "@double_conversion//:LICENSE", "@eigen_archive//:COPYING.MPL2", @@ -148,12 +144,8 @@ filegroup( "@gemmlowp//:LICENSE", "@gif_archive//:COPYING", "@highwayhash//:LICENSE", - "@jemalloc//:COPYING", "@jpeg//:LICENSE.md", - "@kafka//:LICENSE", - "@libxsmm_archive//:LICENSE.md", "@lmdb//:LICENSE", - "@local_config_nccl//:LICENSE", "@local_config_sycl//sycl:LICENSE.text", "@nasm//:LICENSE", "@nsync//:LICENSE", @@ -166,7 +158,39 @@ filegroup( "@termcolor_archive//:COPYING.txt", "@zlib_archive//:zlib.h", "@org_python_pypi_backports_weakref//:LICENSE", - ] + if_mkl([ + ] + select({ + "//tensorflow:with_aws_support": [ + "@aws//:LICENSE", + ], + "//conditions:default": [], + }) + select({ + "//tensorflow:with_gcp_support": [ + "@com_github_googleapis_googleapis//:LICENSE", + "@com_github_googlecloudplatform_google_cloud_cpp//:LICENSE", + ], + "//conditions:default": [], + }) + select({ + "//tensorflow:with_jemalloc_linux_x86_64": [ + "@jemalloc//:COPYING", + ], + "//tensorflow:with_jemalloc_linux_ppc64le": [ + "@jemalloc//:COPYING", + ], + "//conditions:default": [], + }) + select({ + "//tensorflow:with_kafka_support": [ + "@kafka//:LICENSE", + ], + "//conditions:default": [], + }) + select({ + "//tensorflow/core/kernels:xsmm": [ + "@libxsmm_archive//:LICENSE.md", + ], + "//conditions:default": [], + }) + if_cuda([ + "@cub_archive//:LICENSE.TXT", + "@local_config_nccl//:LICENSE", + ]) + if_mkl([ "//third_party/mkl:LICENSE", "//third_party/mkl_dnn:LICENSE", ]) + if_not_system_lib( -- GitLab From e1b825ded7585f5ab83634ebaa7c0b15ad787fc5 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: Tue, 7 Aug 2018 13:10:56 +0800 Subject: [PATCH 140/437] BUG: should return NaN when use_norm = inf --- .../python/kernel_tests/clip_ops_test.py | 19 +++++++++++++++++++ tensorflow/python/ops/clip_ops.py | 8 +++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/tensorflow/python/kernel_tests/clip_ops_test.py b/tensorflow/python/kernel_tests/clip_ops_test.py index fb52d10475..dacb7bd8df 100644 --- a/tensorflow/python/kernel_tests/clip_ops_test.py +++ b/tensorflow/python/kernel_tests/clip_ops_test.py @@ -369,6 +369,25 @@ class ClipTest(test.TestCase): self.assertAllClose(np_ans_0, tf_ans_1) self.assertAllClose(np_ans_1, tf_ans_2) + def testClipByGlobalNormInf(self): + # Norm = inf, return NaN + with self.test_session(use_gpu=True): + x0 = constant_op.constant([-2.0, 0.0, np.inf, 4.0, 0.0, 0.0], + shape=[2, 3]) + x1 = constant_op.constant([1.0, -2.0]) + np_ans_0 = [[np.nan, np.nan, np.nan], [np.nan, np.nan, np.nan]] + np_ans_1 = [np.nan, np.nan] + clip_norm = 6.0 + + ans, norm = clip_ops.clip_by_global_norm([x0, x1], clip_norm) + tf_ans_1 = ans[0].eval() + tf_ans_2 = ans[1].eval() + tf_norm = norm.eval() + + self.assertAllClose(tf_norm, np.inf) + self.assertAllClose(np_ans_0, tf_ans_1) + self.assertAllClose(np_ans_1, tf_ans_2) + def testClipByAverageNormClipped(self): # Norm clipping when average clip_norm < 0.83333333 with self.test_session(use_gpu=True): diff --git a/tensorflow/python/ops/clip_ops.py b/tensorflow/python/ops/clip_ops.py index 75c459a9cf..a116b24370 100644 --- a/tensorflow/python/ops/clip_ops.py +++ b/tensorflow/python/ops/clip_ops.py @@ -20,6 +20,7 @@ from __future__ import print_function import collections +import numpy as np import six from tensorflow.python.framework import constant_op @@ -220,6 +221,7 @@ def clip_by_global_norm(t_list, clip_norm, use_norm=None, name=None): If `clip_norm > global_norm` then the entries in `t_list` remain as they are, otherwise they're all shrunk by the global ratio. + If `global_norm` is not finite, the entries in `t_list` become NaN. Any of the entries of `t_list` that are of type `None` are ignored. @@ -254,9 +256,13 @@ def clip_by_global_norm(t_list, clip_norm, use_norm=None, name=None): with ops.name_scope(name, "clip_by_global_norm", t_list + [clip_norm]) as name: # Calculate L2-norm, clip elements by ratio of clip_norm to L2-norm - scale = clip_norm * math_ops.minimum( + scale_for_finite = clip_norm * math_ops.minimum( 1.0 / use_norm, constant_op.constant(1.0, dtype=use_norm.dtype) / clip_norm) + scale = array_ops.where(math_ops.is_finite(use_norm), + scale_for_finite, + # Return NaN if user_norm is not finite. + constant_op.constant(np.nan, dtype=use_norm.dtype)) values = [ ops.convert_to_tensor( -- GitLab From f055fb23b726baef93b887d378f4539ad524146f Mon Sep 17 00:00:00 2001 From: Chris Leary Date: Mon, 6 Aug 2018 23:45:42 -0700 Subject: [PATCH 141/437] [XLA] Unbreak TPU testing by relaxing tolerances. PiperOrigin-RevId: 207668115 --- tensorflow/compiler/tests/random_ops_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow/compiler/tests/random_ops_test.py b/tensorflow/compiler/tests/random_ops_test.py index 5bd7d68111..8124955afd 100644 --- a/tensorflow/compiler/tests/random_ops_test.py +++ b/tensorflow/compiler/tests/random_ops_test.py @@ -130,13 +130,13 @@ class RandomOpsTest(xla_test.XLATestCase): expected_median = mu + probit( (normal_cdf(alpha) + normal_cdf(beta)) / 2.) * sigma actual_median = np.median(y) - self.assertAllClose(actual_median, expected_median, atol=8e-4) + self.assertAllClose(actual_median, expected_median, atol=1e-3) expected_variance = sigma**2 * (1 + ( (alpha * normal_pdf(alpha) - beta * normal_pdf(beta)) / z) - ( (normal_pdf(alpha) - normal_pdf(beta)) / z)**2) actual_variance = np.var(y) - self.assertAllClose(actual_variance, expected_variance, rtol=3e-4) + self.assertAllClose(actual_variance, expected_variance, atol=1e-3) def testShuffle1d(self): with self.test_session() as sess: -- GitLab From e8adf96abcf03a02440d565b67fdf48e0d98860b Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 7 Aug 2018 00:43:27 -0700 Subject: [PATCH 142/437] Fixed typo in Estimator documentation. PiperOrigin-RevId: 207672785 --- tensorflow/python/estimator/estimator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/python/estimator/estimator.py b/tensorflow/python/estimator/estimator.py index 43deb8bc6c..2fe44bc6ce 100644 --- a/tensorflow/python/estimator/estimator.py +++ b/tensorflow/python/estimator/estimator.py @@ -104,7 +104,7 @@ class Estimator(object): constructor enforces this). Subclasses should use `model_fn` to configure the base class, and may add methods implementing specialized functionality. - @compatbility(eager) + @compatibility(eager) Calling methods of `Estimator` will work while eager execution is enabled. However, the `model_fn` and `input_fn` is not executed eagerly, `Estimator` will switch to graph model before calling all user-provided functions (incl. -- GitLab From 7fef41bc5c86a1d0bb8a1621a746335ffba41c71 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 7 Aug 2018 02:02:20 -0700 Subject: [PATCH 143/437] compat: Update forward compatibility horizon to 2018-08-07 PiperOrigin-RevId: 207680195 --- tensorflow/python/compat/compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/python/compat/compat.py b/tensorflow/python/compat/compat.py index af47ff69c9..b8ead6b778 100644 --- a/tensorflow/python/compat/compat.py +++ b/tensorflow/python/compat/compat.py @@ -26,7 +26,7 @@ import datetime from tensorflow.python.util import tf_contextlib from tensorflow.python.util.tf_export import tf_export -_FORWARD_COMPATIBILITY_HORIZON = datetime.date(2018, 8, 6) +_FORWARD_COMPATIBILITY_HORIZON = datetime.date(2018, 8, 7) @tf_export("compat.forward_compatible") -- GitLab From f126d1d812ae54e3912f50743dd0ed6cfa7f6dfb Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Tue, 7 Aug 2018 02:54:17 -0700 Subject: [PATCH 144/437] [XLA:GPU] Schedule freeing the tuple address buffer after it's use In theory cuMemcpyHtoDAsync can access the memory asynchronously after it went out of scope. Synchronize releasing the memory with the memcpy completion. PiperOrigin-RevId: 207686517 --- .../compiler/xla/service/gpu/tuple_thunk.cc | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tensorflow/compiler/xla/service/gpu/tuple_thunk.cc b/tensorflow/compiler/xla/service/gpu/tuple_thunk.cc index a10e40451c..8579b1545f 100644 --- a/tensorflow/compiler/xla/service/gpu/tuple_thunk.cc +++ b/tensorflow/compiler/xla/service/gpu/tuple_thunk.cc @@ -24,24 +24,32 @@ namespace gpu { Status TupleThunk::ExecuteOnStream(const BufferAllocations& buffer_allocations, se::Stream* stream, HloExecutionProfiler* profiler) { - std::vector tuple_element_buffer_addresses; - for (BufferAllocation::Slice tuple_element_buffer : tuple_element_buffers_) { - tuple_element_buffer_addresses.push_back( - buffer_allocations.GetDeviceAddress(tuple_element_buffer).opaque()); + auto size = tuple_element_buffers_.size(); + auto tuple_element_buffer_addresses = MakeUnique(size); + for (int i = 0; i != size; ++i) { + tuple_element_buffer_addresses[i] = + buffer_allocations.GetDeviceAddress(tuple_element_buffers_[i]).opaque(); } se::DeviceMemory dest_buffer_address( buffer_allocations.GetDeviceAddress(dest_buffer_)); - auto host_size = tuple_element_buffer_addresses.size() * sizeof(void*); + auto host_size = size * sizeof(void*); auto op_profiler = profiler->MakeScopedInstructionProfiler(hlo_instruction()); if (!stream ->ThenMemcpy(&dest_buffer_address, - tuple_element_buffer_addresses.data(), host_size) + tuple_element_buffer_addresses.get(), host_size) .ok()) { return InternalError( "Unable to launch MemcpyH2D from %p to %p with size %lu", - tuple_element_buffer_addresses.data(), dest_buffer_address.opaque(), - sizeof(void*) * tuple_element_buffer_addresses.size()); + tuple_element_buffer_addresses.get(), dest_buffer_address.opaque(), + host_size); + } + // Free the tuple address buffer when memcpy is done. + auto* buffers_raw = tuple_element_buffer_addresses.release(); + if (!stream->ThenDoHostCallback([buffers_raw] { delete[] buffers_raw; }) + .ok()) { + delete[] buffers_raw; + return InternalError("Unable to enqueue host callback!"); } return Status::OK(); } -- GitLab From aed8f42bafabf11c5d92ce4109a5e0408b31f9c5 Mon Sep 17 00:00:00 2001 From: Peter Hawkins Date: Tue, 7 Aug 2018 03:53:15 -0700 Subject: [PATCH 145/437] [TF:XLA] Add test that verifies that transfers on and off XLA devices do not crash, even for unsupported types. PiperOrigin-RevId: 207691957 --- tensorflow/compiler/tests/xla_device_test.py | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tensorflow/compiler/tests/xla_device_test.py b/tensorflow/compiler/tests/xla_device_test.py index 06d977b93c..85084bb124 100644 --- a/tensorflow/compiler/tests/xla_device_test.py +++ b/tensorflow/compiler/tests/xla_device_test.py @@ -21,6 +21,8 @@ from __future__ import print_function import numpy as np from tensorflow.compiler.tests import xla_test +from tensorflow.python.framework import dtypes +from tensorflow.python.framework import errors from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops from tensorflow.python.ops import gen_control_flow_ops @@ -47,6 +49,34 @@ class XlaDeviceTest(xla_test.XLATestCase): result = sess.run(z, {x: inputs}) self.assertAllCloseAccordingToType(result, inputs + inputs) + def testCopiesOfUnsupportedTypesFailGracefully(self): + """Tests that copies of unsupported types don't crash.""" + test_types = set([ + np.uint8, np.uint16, np.uint32, np.uint64, np.int8, np.int16, np.int32, + np.int64, np.float16, np.float32, np.float16, + dtypes.bfloat16.as_numpy_dtype + ]) + shape = (10, 10) + for unsupported_dtype in test_types - self.all_types: + with self.test_session() as sess: + with ops.device("CPU"): + x = array_ops.placeholder(unsupported_dtype, shape) + with self.test_scope(): + y, = array_ops.identity_n([x]) + with ops.device("CPU"): + z = array_ops.identity(y) + + inputs = np.random.randint(-100, 100, shape) + inputs = inputs.astype(unsupported_dtype) + # Execution should either succeed or raise an InvalidArgumentError, + # but not crash. Even "unsupported types" may succeed here since some + # backends (e.g., the CPU backend) are happy to handle buffers of + # unsupported types, even if they cannot compute with them. + try: + sess.run(z, {x: inputs}) + except errors.InvalidArgumentError: + pass + def testControlTrigger(self): with self.test_session() as sess: with self.test_scope(): -- GitLab From 799db6e589380179c7ef07ba35ddda0e0a636fb3 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Tue, 7 Aug 2018 12:32:19 +0000 Subject: [PATCH 146/437] Fix incorrect to version compatibility This fix tries to address the issue raised in 21434 where the link to version compatibility is not correct. The link should be `version_compat.md`, not `version_semantics.md`. This fix fixes 21434. Signed-off-by: Yong Tang --- tensorflow/docs_src/install/install_go.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/docs_src/install/install_go.md b/tensorflow/docs_src/install/install_go.md index a59c2741e1..83d16bc4b7 100644 --- a/tensorflow/docs_src/install/install_go.md +++ b/tensorflow/docs_src/install/install_go.md @@ -6,7 +6,7 @@ a Go application. This guide explains how to install and set up the [TensorFlow Go package](https://godoc.org/github.com/tensorflow/tensorflow/tensorflow/go). Warning: The TensorFlow Go API is *not* covered by the TensorFlow -[API stability guarantees](../guide/version_semantics.md). +[API stability guarantees](../guide/version_compat.md). ## Supported Platforms -- GitLab From 55656e37f1d5f111faf59b3b94229178c49eab56 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Tue, 7 Aug 2018 12:47:42 +0000 Subject: [PATCH 147/437] Fix incorrect doc in sparse_softmax_cross_entropy_with_logits This fix fixes the incorrect doc in sparse_softmax_cross_entropy_with_logits. In sparse_softmax_cross_entropy_with_logits, `labels` must be `int32` or `int64`, as is seen in: https://github.com/tensorflow/tensorflow/blob/46cf73f0214bc6208295e36650f1a8ffde4abdd7/tensorflow/core/ops/nn_ops.cc#L1092-L1099 This fix fixes 21435. Signed-off-by: Yong Tang --- tensorflow/python/ops/nn_ops.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow/python/ops/nn_ops.py b/tensorflow/python/ops/nn_ops.py index 5cdb7726a7..763dd026c3 100644 --- a/tensorflow/python/ops/nn_ops.py +++ b/tensorflow/python/ops/nn_ops.py @@ -2003,8 +2003,8 @@ def sparse_softmax_cross_entropy_with_logits( A common use case is to have logits and labels of shape `[batch_size, num_classes]`, but higher dimensions are supported, in which case the `dim`-th dimension is assumed to be of size `num_classes`. - `logits` and `labels` must have the same dtype (either `float16`, `float32`, - or `float64`). + `logits` must have the dtype of `float16`, `float32`, or `float64`, and + `labels` must have the dtype of `int32` or `int64`. **Note that to avoid confusion, it is required to pass only named arguments to this function.** -- GitLab From a1a370cb8b8ef43996a275b64ada81f9cb32e743 Mon Sep 17 00:00:00 2001 From: Shanqing Cai Date: Tue, 7 Aug 2018 07:35:20 -0700 Subject: [PATCH 148/437] Improve doc string and error checking in Permute Layer Check the validity of the permutation dims in the constructor of tf.keras.layers.Permute. This improves the error messages on invalid dims. PiperOrigin-RevId: 207712499 --- tensorflow/python/keras/layers/core.py | 7 ++++++- tensorflow/python/keras/layers/core_test.py | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tensorflow/python/keras/layers/core.py b/tensorflow/python/keras/layers/core.py index f28cade474..2a42816854 100644 --- a/tensorflow/python/keras/layers/core.py +++ b/tensorflow/python/keras/layers/core.py @@ -466,7 +466,7 @@ class Permute(Layer): Arguments: dims: Tuple of integers. Permutation pattern, does not include the samples dimension. Indexing starts at 1. - For instance, `(2, 1)` permutes the first and second dimension + For instance, `(2, 1)` permutes the first and second dimensions of the input. Input shape: @@ -482,6 +482,11 @@ class Permute(Layer): def __init__(self, dims, **kwargs): super(Permute, self).__init__(**kwargs) self.dims = tuple(dims) + if sorted(dims) != list(range(1, len(dims) + 1)): + raise ValueError( + 'Invalid permutation `dims` for Permute Layer: %s. ' + 'The set of indices in `dims` must be consecutive and start from 1.' % + (dims,)) self.input_spec = InputSpec(ndim=len(self.dims) + 1) def compute_output_shape(self, input_shape): diff --git a/tensorflow/python/keras/layers/core_test.py b/tensorflow/python/keras/layers/core_test.py index 226403c592..0ff392ebb3 100644 --- a/tensorflow/python/keras/layers/core_test.py +++ b/tensorflow/python/keras/layers/core_test.py @@ -119,6 +119,20 @@ class CoreLayersTest(test.TestCase): testing_utils.layer_test( keras.layers.Permute, kwargs={'dims': (2, 1)}, input_shape=(3, 2, 4)) + @tf_test_util.run_in_graph_and_eager_modes + def test_permute_errors_on_invalid_starting_dims_index(self): + with self.assertRaisesRegexp(ValueError, r'Invalid permutation .*dims.*'): + testing_utils.layer_test( + keras.layers.Permute, + kwargs={'dims': (0, 1, 2)}, input_shape=(3, 2, 4)) + + @tf_test_util.run_in_graph_and_eager_modes + def test_permute_errors_on_invalid_set_of_dims_indices(self): + with self.assertRaisesRegexp(ValueError, r'Invalid permutation .*dims.*'): + testing_utils.layer_test( + keras.layers.Permute, + kwargs={'dims': (1, 4, 2)}, input_shape=(3, 2, 4)) + @tf_test_util.run_in_graph_and_eager_modes def test_flatten(self): testing_utils.layer_test( -- GitLab From 335336aa2cdf853d380c3e22ab6694ff78cb487a Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 7 Aug 2018 07:50:21 -0700 Subject: [PATCH 149/437] Implement DoHostCallbackWithStatus to allow callbacks to return a status PiperOrigin-RevId: 207714420 --- tensorflow/stream_executor/stream.cc | 13 +++++++++++++ tensorflow/stream_executor/stream.h | 5 +++++ .../stream_executor/stream_executor_internal.cc | 12 ++++++++++++ .../stream_executor/stream_executor_internal.h | 2 ++ tensorflow/stream_executor/stream_executor_pimpl.cc | 5 +++++ tensorflow/stream_executor/stream_executor_pimpl.h | 5 +++++ 6 files changed, 42 insertions(+) diff --git a/tensorflow/stream_executor/stream.cc b/tensorflow/stream_executor/stream.cc index a42a469df5..9efd34de24 100644 --- a/tensorflow/stream_executor/stream.cc +++ b/tensorflow/stream_executor/stream.cc @@ -5294,6 +5294,19 @@ Stream &Stream::ThenDoHostCallback(std::function callback) { return *this; } +Stream &Stream::ThenDoHostCallbackWithStatus( + std::function callback) { + VLOG_CALL(PARAM(callback)); + + if (ok()) { + CheckError(parent_->HostCallback(this, std::move(callback))); + } else { + LOG(WARNING) << "stream " << DebugStreamPointers() + << " was in error state before adding host callback"; + } + return *this; +} + Stream &Stream::ThenFft(fft::Plan *plan, const DeviceMemory> &input, DeviceMemory> *output) { diff --git a/tensorflow/stream_executor/stream.h b/tensorflow/stream_executor/stream.h index 4d41409fef..e1629b5b30 100644 --- a/tensorflow/stream_executor/stream.h +++ b/tensorflow/stream_executor/stream.h @@ -2045,6 +2045,11 @@ class Stream { // negative effects on performance. Stream &ThenDoHostCallback(std::function callback); + // Entrains onto the stream a callback to the host (from the device). + // Behaves as ThenDoHostCallback above, but returns a Status instead of void. + // This overload should be preferred if the callback could fail. + Stream &ThenDoHostCallbackWithStatus(std::function callback); + // Returns the StreamExecutor (parent object) associated with this stream. StreamExecutor *parent() const { CHECK(parent_ != nullptr); diff --git a/tensorflow/stream_executor/stream_executor_internal.cc b/tensorflow/stream_executor/stream_executor_internal.cc index 8297228e6f..7df6a361c6 100644 --- a/tensorflow/stream_executor/stream_executor_internal.cc +++ b/tensorflow/stream_executor/stream_executor_internal.cc @@ -36,5 +36,17 @@ StreamExecutorFactory* MakeOpenCLExecutorImplementation() { StreamExecutorFactory MakeHostExecutorImplementation; +// TODO(b/112125301): Consolodate this down to one implementation of +// HostCallback, taking a callback that returns a Status. +bool StreamExecutorInterface::HostCallback( + Stream* stream, std::function callback) { + return HostCallback(stream, [callback]() { + port::Status s = callback(); + if (!s.ok()) { + LOG(WARNING) << "HostCallback failed: " << s; + } + }); +} + } // namespace internal } // namespace stream_executor diff --git a/tensorflow/stream_executor/stream_executor_internal.h b/tensorflow/stream_executor/stream_executor_internal.h index f34b1fc083..92e5376835 100644 --- a/tensorflow/stream_executor/stream_executor_internal.h +++ b/tensorflow/stream_executor/stream_executor_internal.h @@ -239,6 +239,8 @@ class StreamExecutorInterface { const DeviceMemoryBase &host_src, uint64 size) = 0; virtual bool HostCallback(Stream *stream, std::function callback) = 0; + virtual bool HostCallback(Stream *stream, + std::function callback); virtual port::Status AllocateEvent(Event *event) = 0; virtual port::Status DeallocateEvent(Event *event) = 0; virtual port::Status RecordEvent(Stream *stream, Event *event) = 0; diff --git a/tensorflow/stream_executor/stream_executor_pimpl.cc b/tensorflow/stream_executor/stream_executor_pimpl.cc index 2e0137a485..9515d8e62a 100644 --- a/tensorflow/stream_executor/stream_executor_pimpl.cc +++ b/tensorflow/stream_executor/stream_executor_pimpl.cc @@ -699,6 +699,11 @@ bool StreamExecutor::HostCallback(Stream *stream, return implementation_->HostCallback(stream, std::move(callback)); } +bool StreamExecutor::HostCallback(Stream *stream, + std::function callback) { + return implementation_->HostCallback(stream, std::move(callback)); +} + port::Status StreamExecutor::AllocateEvent(Event *event) { return implementation_->AllocateEvent(event); } diff --git a/tensorflow/stream_executor/stream_executor_pimpl.h b/tensorflow/stream_executor/stream_executor_pimpl.h index 47b3a2b030..437f298616 100644 --- a/tensorflow/stream_executor/stream_executor_pimpl.h +++ b/tensorflow/stream_executor/stream_executor_pimpl.h @@ -549,6 +549,11 @@ class StreamExecutor { // See Stream::ThenDoHostCallback for full details. bool HostCallback(Stream *stream, std::function callback); + // Entrains on a stream a user-specified function to be run on the host. + // See Stream::ThenDoHostCallback for full details. + // This is the preferred form for a callback that may return an error. + bool HostCallback(Stream *stream, std::function callback); + // Performs platform-specific allocation and initialization of an event. port::Status AllocateEvent(Event *event); -- GitLab From c5d384469a659df4ed52d0f7cfadfbab5255c36e Mon Sep 17 00:00:00 2001 From: Vicente Reyes Date: Tue, 7 Aug 2018 17:41:50 +0200 Subject: [PATCH 150/437] Delete confusing comment related to missing output Variable The method KMeans().training_graph() does not return anymore the output Variable cluster_centers_var. Thus the related comment is outdated and should be deleted. --- tensorflow/contrib/factorization/python/ops/kmeans.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tensorflow/contrib/factorization/python/ops/kmeans.py b/tensorflow/contrib/factorization/python/ops/kmeans.py index 9ffdd3ba5e..21ea329190 100644 --- a/tensorflow/contrib/factorization/python/ops/kmeans.py +++ b/tensorflow/contrib/factorization/python/ops/kmeans.py @@ -188,7 +188,6 @@ class _ModelFn(object): # center. # is_initialized: scalar indicating whether the initial cluster centers # have been chosen; see init_op. - # cluster_centers_var: a Variable containing the cluster centers. # init_op: an op to choose the initial cluster centers. A single worker # repeatedly executes init_op until is_initialized becomes True. # training_op: an op that runs an iteration of training, either an entire -- GitLab From 7f666bb652063874134ed60b77edb4ddc85ec488 Mon Sep 17 00:00:00 2001 From: Scott Zhu Date: Tue, 7 Aug 2018 08:50:25 -0700 Subject: [PATCH 151/437] Deprecate BasicLSTMCell and push user to use LSTMCell instead. PiperOrigin-RevId: 207722104 --- tensorflow/python/kernel_tests/rnn_test.py | 23 ++++++++++++++++++++++ tensorflow/python/ops/rnn_cell_impl.py | 10 +++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/tensorflow/python/kernel_tests/rnn_test.py b/tensorflow/python/kernel_tests/rnn_test.py index acee180a6c..2405f65270 100644 --- a/tensorflow/python/kernel_tests/rnn_test.py +++ b/tensorflow/python/kernel_tests/rnn_test.py @@ -18,6 +18,7 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +import os import time import timeit @@ -46,6 +47,7 @@ import tensorflow.python.ops.nn_grad # pylint: disable=unused-import import tensorflow.python.ops.sparse_grad # pylint: disable=unused-import import tensorflow.python.ops.tensor_array_grad # pylint: disable=unused-import from tensorflow.python.platform import test +from tensorflow.python.training import saver class Plus1RNNCell(rnn_cell_impl.RNNCell): @@ -275,6 +277,27 @@ class RNNTest(test.TestCase): self._assert_cell_builds(contrib_rnn.IndyLSTMCell, f32, 5, 7, 3) self._assert_cell_builds(contrib_rnn.IndyLSTMCell, f64, 5, 7, 3) + def testBasicLSTMCellInterchangeWithLSTMCell(self): + with self.test_session(graph=ops_lib.Graph()) as sess: + basic_cell = rnn_cell_impl.BasicLSTMCell(1) + basic_cell(array_ops.ones([1, 1]), + state=basic_cell.zero_state(batch_size=1, + dtype=dtypes.float32)) + self.evaluate([v.initializer for v in basic_cell.variables]) + self.evaluate(basic_cell._bias.assign([10.] * 4)) + save = saver.Saver() + prefix = os.path.join(self.get_temp_dir(), "ckpt") + save_path = save.save(sess, prefix) + + with self.test_session(graph=ops_lib.Graph()) as sess: + lstm_cell = rnn_cell_impl.LSTMCell(1, name="basic_lstm_cell") + lstm_cell(array_ops.ones([1, 1]), + state=lstm_cell.zero_state(batch_size=1, + dtype=dtypes.float32)) + self.evaluate([v.initializer for v in lstm_cell.variables]) + save = saver.Saver() + save.restore(sess, save_path) + self.assertAllEqual([10.] * 4, self.evaluate(lstm_cell._bias)) ######### Benchmarking RNN code diff --git a/tensorflow/python/ops/rnn_cell_impl.py b/tensorflow/python/ops/rnn_cell_impl.py index 42806ba6ec..8356fbbb9d 100644 --- a/tensorflow/python/ops/rnn_cell_impl.py +++ b/tensorflow/python/ops/rnn_cell_impl.py @@ -48,6 +48,7 @@ from tensorflow.python.ops import variables as tf_variables from tensorflow.python.platform import tf_logging as logging from tensorflow.python.training.checkpointable import base as checkpointable from tensorflow.python.util import nest +from tensorflow.python.util.deprecation import deprecated from tensorflow.python.util.tf_export import tf_export @@ -515,9 +516,12 @@ class LSTMStateTuple(_LSTMStateTuple): return c.dtype +# TODO(scottzhu): Stop exporting this class in TF 2.0. @tf_export("nn.rnn_cell.BasicLSTMCell") class BasicLSTMCell(LayerRNNCell): - """Basic LSTM recurrent network cell. + """DEPRECATED: Please use @{tf.nn.rnn_cell.LSTMCell} instead. + + Basic LSTM recurrent network cell. The implementation is based on: http://arxiv.org/abs/1409.2329. @@ -531,6 +535,10 @@ class BasicLSTMCell(LayerRNNCell): that follows. """ + @deprecated(None, "This class is deprecated, please use " + "tf.nn.rnn_cell.LSTMCell, which supports all the feature " + "this cell currently has. Please replace the existing code " + "with tf.nn.rnn_cell.LSTMCell(name='basic_lstm_cell').") def __init__(self, num_units, forget_bias=1.0, -- GitLab From 60fc3dba6722753b546f20295fd73a841410fafb Mon Sep 17 00:00:00 2001 From: Rohan Jain Date: Tue, 7 Aug 2018 09:31:09 -0700 Subject: [PATCH 152/437] Small fix to MultiDeviceIterator to allow for no prefetching if needed. PiperOrigin-RevId: 207728361 --- .../contrib/data/python/ops/prefetching_ops.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tensorflow/contrib/data/python/ops/prefetching_ops.py b/tensorflow/contrib/data/python/ops/prefetching_ops.py index 0edd7c9fe9..0243c72c70 100644 --- a/tensorflow/contrib/data/python/ops/prefetching_ops.py +++ b/tensorflow/contrib/data/python/ops/prefetching_ops.py @@ -633,6 +633,15 @@ class MultiDeviceIterator(object): devices, prefetch_buffer_size=1, source_device="/cpu:0"): + """Constructs a MultiDeviceIterator. + + Args: + dataset: The input dataset to be iterated over. + devices: The list of devices to fetch data to. + prefetch_buffer_size: if > 1, then we setup a buffer on each device + to prefetch into. + source_device: The host device to place the `dataset` on. + """ self._dataset = dataset self._devices = devices self._source_device = source_device @@ -673,7 +682,8 @@ class MultiDeviceIterator(object): i, self._multi_device_iterator_resource, self._incarnation_id, self._source_device_tensor, device, self._dataset.output_shapes, self._dataset.output_types, self._dataset.output_classes) - ds = ds.prefetch(prefetch_buffer_size) + if prefetch_buffer_size > 0: + ds = ds.prefetch(prefetch_buffer_size) with ops.device(device): self._device_iterators.append(ds.make_initializable_iterator()) i += 1 -- GitLab From 7446059bc9066b47ee1d1dc0abaa826f39a13aac Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 7 Aug 2018 09:48:57 -0700 Subject: [PATCH 153/437] There are .tflite files that are missing some metadata (at least description). With this change visualize.py can process those files. PiperOrigin-RevId: 207731192 --- tensorflow/contrib/lite/tools/visualize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/contrib/lite/tools/visualize.py b/tensorflow/contrib/lite/tools/visualize.py index e07f899e4d..597dede63b 100644 --- a/tensorflow/contrib/lite/tools/visualize.py +++ b/tensorflow/contrib/lite/tools/visualize.py @@ -334,7 +334,7 @@ def CreateHtmlFile(tflite_input, html_output): for key, mapping in toplevel_stuff: if not mapping: mapping = lambda x: x - html += "%s%s\n" % (key, mapping(data[key])) + html += "%s%s\n" % (key, mapping(data.get(key))) html += "\n" # Spec on what keys to display -- GitLab From 1a22e9a608b43cbdf7d990d09c7d317ee3c57d8c Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 7 Aug 2018 10:18:12 -0700 Subject: [PATCH 154/437] Add NNAPI delegation support for MEAN, RNN, SVDF, LSTM and lookup functions. PiperOrigin-RevId: 207736388 --- .../lite/delegates/nnapi/nnapi_delegate.cc | 349 ++- .../delegates/nnapi/nnapi_delegate_test.cc | 1892 +++++++++++++++++ tensorflow/contrib/lite/nnapi_delegate.cc | 10 +- 3 files changed, 2215 insertions(+), 36 deletions(-) diff --git a/tensorflow/contrib/lite/delegates/nnapi/nnapi_delegate.cc b/tensorflow/contrib/lite/delegates/nnapi/nnapi_delegate.cc index 60855eb8ed..b1b8e9890c 100644 --- a/tensorflow/contrib/lite/delegates/nnapi/nnapi_delegate.cc +++ b/tensorflow/contrib/lite/delegates/nnapi/nnapi_delegate.cc @@ -142,6 +142,12 @@ class NNAPIOpBuilder { ANEURALNETWORKS_TENSOR_INT32); } + TfLiteStatus AddVectorFloat32Operand(const float* values, + uint32_t num_values) { + return AddVectorOperand(values, num_values, + ANEURALNETWORKS_TENSOR_FLOAT32); + } + TfLiteStatus AddPoolingParams(void* data) { auto builtin = reinterpret_cast(data); AddScalarInt32Operand(builtin->padding); @@ -167,6 +173,37 @@ class NNAPIOpBuilder { return kTfLiteOk; } + TfLiteStatus AddAdditionalFloat32OutputTensor(uint32_t dimension_count) { + std::vector dims(dimension_count, 0); + ANeuralNetworksOperandType operand_type{ + .type = ANEURALNETWORKS_TENSOR_FLOAT32, + .dimensionCount = dimension_count, + .dimensions = dims.data()}; + CHECK_NN(context_, + ANeuralNetworksModel_addOperand(nn_model_, &operand_type)); + int ann_operand = operand_mapping_->add_new_non_tensor_operand(); + augmented_outputs_.push_back(ann_operand); + return kTfLiteOk; + } + + TfLiteStatus AddStateFloat32Tensor(int tensor_index, + int* ann_tensor_index_out) { + TfLiteTensor* tensor = &context_->tensors[tensor_index]; + int ann_index = operand_mapping_->add_new_non_tensor_operand(); + + ANeuralNetworksOperandType operand_type{ + ANEURALNETWORKS_TENSOR_FLOAT32, + static_cast(tensor->dims->size), + reinterpret_cast(tensor->dims->data), tensor->params.scale, + tensor->params.zero_point}; + CHECK_NN(context_, + ANeuralNetworksModel_addOperand(nn_model_, &operand_type)); + augmented_inputs_.push_back(ann_index); + + *ann_tensor_index_out = ann_index; + return kTfLiteOk; + } + // Adds a new NN API tensor that shadows the TF Lite tensor `tensor_index`. // This returns the NN API tensor index corresponding to the created tensor. // If another caller previously created a NN API tensor for `tensor_index` @@ -198,6 +235,10 @@ class NNAPIOpBuilder { nn_type = ANEURALNETWORKS_TENSOR_QUANT8_ASYMM; scale = tensor->params.scale; zeroPoint = tensor->params.zero_point; + if (scale == 0) { + // TENSOR_QUANT8_ASYMM with zero scale is not valid in NNAPI. + scale = 1; + } break; case kTfLiteInt32: nn_type = ANEURALNETWORKS_TENSOR_INT32; @@ -290,9 +331,10 @@ class NNAPIDelegateKernel { public: NNAPIDelegateKernel() = default; - typedef ANeuralNetworksOperationType (*MappingFn)(TfLiteContext*, - NNAPIOpBuilder* builder, - TfLiteNode* node); + typedef ANeuralNetworksOperationType (*MappingFn)( + TfLiteContext*, NNAPIOpBuilder* builder, TfLiteNode* node, + std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs); // Return a function that knows how to translate a node into its operands // when called. You can use this function to see if a node is supported @@ -303,7 +345,9 @@ class NNAPIDelegateKernel { case kTfLiteBuiltinAdd: if (version == 1) { return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { auto builtin = reinterpret_cast(node->builtin_data); builder->AddScalarInt32Operand(builtin->activation); @@ -316,7 +360,9 @@ class NNAPIDelegateKernel { case kTfLiteBuiltinMul: if (version == 1) { return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { auto builtin = reinterpret_cast(node->builtin_data); builder->AddScalarInt32Operand(builtin->activation); @@ -329,7 +375,9 @@ class NNAPIDelegateKernel { case kTfLiteBuiltinAveragePool2d: if (version == 1) { return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { builder->AddPoolingParams(node->builtin_data); return ANEURALNETWORKS_AVERAGE_POOL_2D; }; @@ -340,7 +388,9 @@ class NNAPIDelegateKernel { case kTfLiteBuiltinMaxPool2d: if (version == 1) { return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { builder->AddPoolingParams(node->builtin_data); return ANEURALNETWORKS_MAX_POOL_2D; }; @@ -351,7 +401,9 @@ class NNAPIDelegateKernel { case kTfLiteBuiltinL2Pool2d: if (version == 1) { return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { builder->AddPoolingParams(node->builtin_data); return ANEURALNETWORKS_L2_POOL_2D; }; @@ -369,7 +421,9 @@ class NNAPIDelegateKernel { return nullptr; } return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { auto builtin = reinterpret_cast(node->builtin_data); builder->AddScalarInt32Operand(builtin->padding); @@ -385,7 +439,9 @@ class NNAPIDelegateKernel { case kTfLiteBuiltinDepthwiseConv2d: if (version == 1) { return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { auto builtin = reinterpret_cast( node->builtin_data); builder->AddScalarInt32Operand(builtin->padding); @@ -402,7 +458,9 @@ class NNAPIDelegateKernel { case kTfLiteBuiltinFullyConnected: if (version == 1) { return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { auto builtin = reinterpret_cast( node->builtin_data); builder->AddScalarInt32Operand(builtin->activation); @@ -415,7 +473,9 @@ class NNAPIDelegateKernel { case kTfLiteBuiltinSoftmax: if (version == 1) { return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { auto builtin = reinterpret_cast(node->builtin_data); builder->AddScalarFloat32Operand(builtin->beta); @@ -428,7 +488,9 @@ class NNAPIDelegateKernel { case kTfLiteBuiltinReshape: if (version == 1) { return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { return ANEURALNETWORKS_RESHAPE; }; } else { @@ -438,7 +500,9 @@ class NNAPIDelegateKernel { case kTfLiteBuiltinSqueeze: if (version == 1 && kAndroidSdkVersion >= kMinSdkVersionForNNAPI11) { return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { auto builtin = reinterpret_cast(node->builtin_data); // Note that we add the squeeze dimensions even if the dimensions @@ -459,14 +523,18 @@ class NNAPIDelegateKernel { return nullptr; } return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { return ANEURALNETWORKS_L2_NORMALIZATION; }; } case kTfLiteBuiltinLocalResponseNormalization: if (version == 1) { return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { auto builtin = reinterpret_cast( node->builtin_data); builder->AddScalarInt32Operand(builtin->radius); @@ -489,7 +557,9 @@ class NNAPIDelegateKernel { return nullptr; } return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { auto builtin = reinterpret_cast( node->builtin_data); builder->AddScalarInt32Operand(builtin->type); @@ -516,7 +586,9 @@ class NNAPIDelegateKernel { } } return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { auto builtin = reinterpret_cast( node->builtin_data); builder->AddScalarInt32Operand(builtin->axis); @@ -529,7 +601,9 @@ class NNAPIDelegateKernel { case kTfLiteBuiltinDequantize: if (version == 1) { return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { return ANEURALNETWORKS_DEQUANTIZE; }; } else { @@ -539,7 +613,9 @@ class NNAPIDelegateKernel { case kTfLiteBuiltinFloor: if (version == 1) { return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { return ANEURALNETWORKS_FLOOR; }; } else { @@ -549,7 +625,9 @@ class NNAPIDelegateKernel { case kTfLiteBuiltinRelu: if (version == 1) { return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { return ANEURALNETWORKS_RELU; }; } else { @@ -559,7 +637,9 @@ class NNAPIDelegateKernel { case kTfLiteBuiltinReluN1To1: if (version == 1) { return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { return ANEURALNETWORKS_RELU1; }; } else { @@ -569,7 +649,9 @@ class NNAPIDelegateKernel { case kTfLiteBuiltinRelu6: if (version == 1) { return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { return ANEURALNETWORKS_RELU6; }; } else { @@ -579,7 +661,9 @@ class NNAPIDelegateKernel { case kTfLiteBuiltinLogistic: if (version == 1) { return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { return ANEURALNETWORKS_LOGISTIC; }; } else { @@ -592,7 +676,9 @@ class NNAPIDelegateKernel { context->tensors[node->inputs->data[0]].type == kTfLiteFloat32) { // NNAPI only support float tanh. return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { return ANEURALNETWORKS_TANH; }; } else { @@ -604,7 +690,9 @@ class NNAPIDelegateKernel { context->tensors[node->inputs->data[0]].type == kTfLiteFloat32) { // NNAPI only support float sub. return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { auto builtin = reinterpret_cast(node->builtin_data); builder->AddScalarInt32Operand(builtin->activation); @@ -619,7 +707,9 @@ class NNAPIDelegateKernel { context->tensors[node->inputs->data[0]].type == kTfLiteFloat32) { // NNAPI only support float div. return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { auto builtin = reinterpret_cast(node->builtin_data); builder->AddScalarInt32Operand(builtin->activation); @@ -637,7 +727,9 @@ class NNAPIDelegateKernel { // NNAPI pads physical zero for quantized tensors, so only delegate // float pad to NNAPI. return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { return ANEURALNETWORKS_PAD; }; } else { @@ -647,7 +739,9 @@ class NNAPIDelegateKernel { case kTfLiteBuiltinSpaceToBatchNd: if (version == 1 && kAndroidSdkVersion >= kMinSdkVersionForNNAPI11) { return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { return ANEURALNETWORKS_SPACE_TO_BATCH_ND; }; } else { @@ -657,7 +751,9 @@ class NNAPIDelegateKernel { case kTfLiteBuiltinStridedSlice: if (version == 1 && kAndroidSdkVersion >= kMinSdkVersionForNNAPI11) { return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { auto builtin = reinterpret_cast(node->builtin_data); builder->AddScalarInt32Operand(builtin->begin_mask); @@ -679,13 +775,155 @@ class NNAPIDelegateKernel { (context->tensors[node->inputs->data[1]].allocation_type == kTfLiteMmapRo)) { return [](TfLiteContext* context, NNAPIOpBuilder* builder, - TfLiteNode* node) -> ANeuralNetworksOperationType { + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { return ANEURALNETWORKS_TRANSPOSE; }; } else { return nullptr; } break; + case kTfLiteBuiltinRnn: + // NNAPI only support float32 weights. + // TODO(miaowang): check the number of inputs before accessing it. + if (version == 1 && + context->tensors[node->inputs->data[/*kWeightsTensor*/ 1]].type == + kTfLiteFloat32) { + return [](TfLiteContext* context, NNAPIOpBuilder* builder, + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { + // NNAPI need both state_in and state_out. + int ann_index; + builder->AddStateFloat32Tensor( + node->outputs->data[/*kHiddenStateTensor*/ 0], &ann_index); + model_state_inputs->push_back(ann_index); + model_state_tfl_outputs->push_back( + node->outputs->data[/*kHiddenStateTensor*/ 0]); + auto builtin = + reinterpret_cast(node->builtin_data); + builder->AddScalarInt32Operand(builtin->activation); + return ANEURALNETWORKS_RNN; + }; + } else { + return nullptr; + } + break; + case kTfLiteBuiltinSvdf: + // NNAPI only support float32 weights. + if (version == 1 && + context->tensors[node->inputs->data[/*kWeightsFeatureTensor*/ 1]] + .type == kTfLiteFloat32) { + return [](TfLiteContext* context, NNAPIOpBuilder* builder, + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { + // NNAPI need both state_in and state_out. + int ann_index; + builder->AddStateFloat32Tensor( + node->outputs->data[/*kStateTensor*/ 0], &ann_index); + model_state_inputs->push_back(ann_index); + model_state_tfl_outputs->push_back( + node->outputs->data[/*kStateTensor*/ 0]); + + auto builtin = + reinterpret_cast(node->builtin_data); + builder->AddScalarInt32Operand(builtin->rank); + builder->AddScalarInt32Operand(builtin->activation); + return ANEURALNETWORKS_SVDF; + }; + } else { + return nullptr; + } + break; + case kTfLiteBuiltinLstm: + // NNAPI only support float32 weights. + // TODO(miaowang): add loggings to indicate why the op is rejected. + if (version == 1 && node->inputs->size == 18 && + context->tensors[node->inputs + ->data[/*kInputToOutputWeightsTensor*/ 4]] + .type == kTfLiteFloat32) { + return [](TfLiteContext* context, NNAPIOpBuilder* builder, + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { + // NNAPI need both state_in and state_out for cell_state and + // output_state. + int ann_index; + builder->AddStateFloat32Tensor( + node->outputs->data[/*kOutputStateTensor*/ 0], &ann_index); + model_state_inputs->push_back(ann_index); + model_state_tfl_outputs->push_back( + node->outputs->data[/*kOutputStateTensor*/ 0]); + builder->AddStateFloat32Tensor( + node->outputs->data[/*kCellStateTensor*/ 1], &ann_index); + model_state_inputs->push_back(ann_index); + model_state_tfl_outputs->push_back( + node->outputs->data[/*kCellStateTensor*/ 1]); + + auto builtin = + reinterpret_cast(node->builtin_data); + builder->AddScalarInt32Operand(builtin->activation); + builder->AddScalarFloat32Operand(builtin->cell_clip); + builder->AddScalarFloat32Operand(builtin->proj_clip); + + // Current NNAPI implementation requires the sratch_buffer as + // output. + builder->AddAdditionalFloat32OutputTensor(2); + return ANEURALNETWORKS_LSTM; + }; + } else { + return nullptr; + } + break; + case kTfLiteBuiltinMean: + // NNAPI does not support generating a scalar as output for MEAN. + if (version == 1 && kAndroidSdkVersion >= kMinSdkVersionForNNAPI11 && + context->tensors[node->inputs->data[0]].type == kTfLiteFloat32 && + context->tensors[node->outputs->data[0]].dims->size > 0) { + return [](TfLiteContext* context, NNAPIOpBuilder* builder, + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { + auto builtin = + reinterpret_cast(node->builtin_data); + int32_t keep_dims = 0; + if (builtin->keep_dims) keep_dims = 1; + builder->AddScalarInt32Operand(keep_dims); + return ANEURALNETWORKS_MEAN; + }; + } else { + return nullptr; + } + case kTfLiteBuiltinEmbeddingLookup: + // NNAPI only support float32 values. + if (version == 1 && + context->tensors[node->inputs->data[1]].type == kTfLiteFloat32) { + return [](TfLiteContext* context, NNAPIOpBuilder* builder, + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { + return ANEURALNETWORKS_EMBEDDING_LOOKUP; + }; + } else { + return nullptr; + } + break; + case kTfLiteBuiltinHashtableLookup: + // NNAPI only support float32 output. + if (version == 1 && + context->tensors[node->outputs->data[0]].type == kTfLiteFloat32) { + return [](TfLiteContext* context, NNAPIOpBuilder* builder, + TfLiteNode* node, std::vector* model_state_inputs, + std::vector* model_state_tfl_outputs) + -> ANeuralNetworksOperationType { + return ANEURALNETWORKS_HASHTABLE_LOOKUP; + }; + } else { + return nullptr; + } + break; default: return nullptr; } @@ -725,7 +963,12 @@ class NNAPIDelegateKernel { // Set the input tensor buffers. Note: we access tflite tensors using // absolute indices but NN api indices inputs by relative indices. int relative_input_index = 0; + int num_optional_tensors = 0; for (auto absolute_input_index : TfLiteIntArrayView(node->inputs)) { + if (absolute_input_index == kOptionalTensor) { + num_optional_tensors++; + continue; + } TfLiteTensor* tensor = &context->tensors[absolute_input_index]; // TODO(miaowang): make sure the delegation works with dequantized weights // as intermediate tensors. @@ -746,6 +989,20 @@ class NNAPIDelegateKernel { tensor->data.raw, tensor->bytes)); relative_output_index++; } + + // The state_out of previous invocation need to be mapped to state_in of + // current invocation. + for (size_t i = 0; i < model_state_tfl_outputs_.size(); i++) { + int state_tensor_idx = model_state_tfl_outputs_[i]; + TfLiteTensor* tensor = &context->tensors[state_tensor_idx]; + // Here we are using a deep copy for state_in tensors so that we are not + // reading and writing into the same buffer during a invocation. + // TODO(110369471): using double shared buffer to minimize the copies. + CHECK_NN(context, + ANeuralNetworksExecution_setInput( + execution, i + node->inputs->size - num_optional_tensors, + nullptr, tensor->data.raw, tensor->bytes)); + } // Invoke ANN in blocking fashion. ANeuralNetworksEvent* event = nullptr; CHECK_NN(context, ANeuralNetworksExecution_startCompute(execution, &event)); @@ -767,6 +1024,9 @@ class NNAPIDelegateKernel { // Track indices we use OperandMapping operand_mapping_; + std::vector model_state_inputs_; + std::vector model_state_tfl_outputs_; + TfLiteStatus AddOpsAndTensors(TfLiteContext* context) { // The operand builder allows creating a single op. We create it at this // reduced power position rather than in the for loop to avoid reallocating @@ -781,11 +1041,22 @@ class NNAPIDelegateKernel { context->GetNodeAndRegistration(context, node_index, &node, ®); // Map inputs to NN API tensor indices. for (auto input_index : TfLiteIntArrayView(node->inputs)) { - TF_LITE_ENSURE_STATUS(builder.AddTensorInput(input_index)); + if (input_index == kOptionalTensor && + (reg->builtin_code == kTfLiteBuiltinLstm || + reg->builtin_code == kTfLiteBuiltinSvdf)) { + // properly handle the optional tensor for LSTM and SVDF. + // currently only support float32. + // TODO(miaowang): make sure this is also able to handle quantized + // tensor when supported by NNAPI. + TF_LITE_ENSURE_STATUS(builder.AddVectorFloat32Operand(nullptr, 0)); + } else { + TF_LITE_ENSURE_STATUS(builder.AddTensorInput(input_index)); + } } // Get op type and operands int nn_op_type = Map(context, reg->builtin_code, reg->version, node)( - context, &builder, node); + context, &builder, node, &model_state_inputs_, + &model_state_tfl_outputs_); // Map outputs to NN API tensor indices. for (auto output_index : TfLiteIntArrayView(node->outputs)) { TF_LITE_ENSURE_STATUS(builder.AddTensorOutput(output_index)); @@ -809,12 +1080,20 @@ class NNAPIDelegateKernel { // Make the TensorFlow lite inputs and outputs to ann_indices. for (int i : TfLiteIntArrayView(input_tensors)) { // Constant tensors are not NNAPI inputs. - if (context->tensors[i].allocation_type != kTfLiteMmapRo) { + if (i != kOptionalTensor && + context->tensors[i].allocation_type != kTfLiteMmapRo) { inputs.push_back(operand_mapping_.lite_index_to_ann(i)); } } - for (int i : TfLiteIntArrayView(output_tensors)) + // Add state input tensors as model inputs + for (int i : model_state_inputs_) { + inputs.push_back(i); + } + + for (int i : TfLiteIntArrayView(output_tensors)) { outputs.push_back(operand_mapping_.lite_index_to_ann(i)); + } + // Tell ANN to declare inputs/outputs CHECK_NN(context, ANeuralNetworksModel_identifyInputsAndOutputs( nn_model_.get(), inputs.size(), inputs.data(), diff --git a/tensorflow/contrib/lite/delegates/nnapi/nnapi_delegate_test.cc b/tensorflow/contrib/lite/delegates/nnapi/nnapi_delegate_test.cc index b7b159c59f..3224b23a0c 100644 --- a/tensorflow/contrib/lite/delegates/nnapi/nnapi_delegate_test.cc +++ b/tensorflow/contrib/lite/delegates/nnapi/nnapi_delegate_test.cc @@ -1623,6 +1623,1898 @@ TEST(NNAPIDelegate, StridedSliceIn2D_ShrinkAxisMask) { EXPECT_THAT(m.GetOutput(), ElementsAreArray({1})); } +static float rnn_input[] = { + 0.23689353, 0.285385, 0.037029743, -0.19858193, -0.27569133, + 0.43773448, 0.60379338, 0.35562468, -0.69424844, -0.93421471, + -0.87287879, 0.37144363, -0.62476718, 0.23791671, 0.40060222, + 0.1356622, -0.99774903, -0.98858172, -0.38952237, -0.47685933, + 0.31073618, 0.71511042, -0.63767755, -0.31729108, 0.33468103, + 0.75801885, 0.30660987, -0.37354088, 0.77002847, -0.62747043, + -0.68572164, 0.0069220066, 0.65791464, 0.35130811, 0.80834007, + -0.61777675, -0.21095741, 0.41213346, 0.73784804, 0.094794154, + 0.47791874, 0.86496925, -0.53376222, 0.85315156, 0.10288584, + 0.86684, -0.011186242, 0.10513687, 0.87825835, 0.59929144, + 0.62827742, 0.18899453, 0.31440187, 0.99059987, 0.87170351, + -0.35091716, 0.74861872, 0.17831337, 0.2755419, 0.51864719, + 0.55084288, 0.58982027, -0.47443086, 0.20875752, -0.058871567, + -0.66609079, 0.59098077, 0.73017097, 0.74604273, 0.32882881, + -0.17503482, 0.22396147, 0.19379807, 0.29120302, 0.077113032, + -0.70331609, 0.15804303, -0.93407321, 0.40182066, 0.036301374, + 0.66521823, 0.0300982, -0.7747041, -0.02038002, 0.020698071, + -0.90300065, 0.62870288, -0.23068321, 0.27531278, -0.095755219, + -0.712036, -0.17384434, -0.50593495, -0.18646687, -0.96508682, + 0.43519354, 0.14744234, 0.62589407, 0.1653645, -0.10651493, + -0.045277178, 0.99032974, -0.88255352, -0.85147917, 0.28153265, + 0.19455957, -0.55479527, -0.56042433, 0.26048636, 0.84702539, + 0.47587705, -0.074295521, -0.12287641, 0.70117295, 0.90532446, + 0.89782166, 0.79817224, 0.53402734, -0.33286154, 0.073485017, + -0.56172788, -0.044897556, 0.89964068, -0.067662835, 0.76863563, + 0.93455386, -0.6324693, -0.083922029}; + +static float rnn_golden_output[] = { + 0.496726, 0, 0.965996, 0, 0.0584254, 0, + 0, 0.12315, 0, 0, 0.612266, 0.456601, + 0, 0.52286, 1.16099, 0.0291232, + + 0, 0, 0.524901, 0, 0, 0, + 0, 1.02116, 0, 1.35762, 0, 0.356909, + 0.436415, 0.0355727, 0, 0, + + 0, 0, 0, 0.262335, 0, 0, + 0, 1.33992, 0, 2.9739, 0, 0, + 1.31914, 2.66147, 0, 0, + + 0.942568, 0, 0, 0, 0.025507, 0, + 0, 0, 0.321429, 0.569141, 1.25274, 1.57719, + 0.8158, 1.21805, 0.586239, 0.25427, + + 1.04436, 0, 0.630725, 0, 0.133801, 0.210693, + 0.363026, 0, 0.533426, 0, 1.25926, 0.722707, + 0, 1.22031, 1.30117, 0.495867, + + 0.222187, 0, 0.72725, 0, 0.767003, 0, + 0, 0.147835, 0, 0, 0, 0.608758, + 0.469394, 0.00720298, 0.927537, 0, + + 0.856974, 0.424257, 0, 0, 0.937329, 0, + 0, 0, 0.476425, 0, 0.566017, 0.418462, + 0.141911, 0.996214, 1.13063, 0, + + 0.967899, 0, 0, 0, 0.0831304, 0, + 0, 1.00378, 0, 0, 0, 1.44818, + 1.01768, 0.943891, 0.502745, 0, + + 0.940135, 0, 0, 0, 0, 0, + 0, 2.13243, 0, 0.71208, 0.123918, 1.53907, + 1.30225, 1.59644, 0.70222, 0, + + 0.804329, 0, 0.430576, 0, 0.505872, 0.509603, + 0.343448, 0, 0.107756, 0.614544, 1.44549, 1.52311, + 0.0454298, 0.300267, 0.562784, 0.395095, + + 0.228154, 0, 0.675323, 0, 1.70536, 0.766217, + 0, 0, 0, 0.735363, 0.0759267, 1.91017, + 0.941888, 0, 0, 0, + + 0, 0, 1.5909, 0, 0, 0, + 0, 0.5755, 0, 0.184687, 0, 1.56296, + 0.625285, 0, 0, 0, + + 0, 0, 0.0857888, 0, 0, 0, + 0, 0.488383, 0.252786, 0, 0, 0, + 1.02817, 1.85665, 0, 0, + + 0.00981836, 0, 1.06371, 0, 0, 0, + 0, 0, 0, 0.290445, 0.316406, 0, + 0.304161, 1.25079, 0.0707152, 0, + + 0.986264, 0.309201, 0, 0, 0, 0, + 0, 1.64896, 0.346248, 0, 0.918175, 0.78884, + 0.524981, 1.92076, 2.07013, 0.333244, + + 0.415153, 0.210318, 0, 0, 0, 0, + 0, 2.02616, 0, 0.728256, 0.84183, 0.0907453, + 0.628881, 3.58099, 1.49974, 0}; + +static std::initializer_list rnn_weights = { + 0.461459, 0.153381, 0.529743, -0.00371218, 0.676267, -0.211346, + 0.317493, 0.969689, -0.343251, 0.186423, 0.398151, 0.152399, + 0.448504, 0.317662, 0.523556, -0.323514, 0.480877, 0.333113, + -0.757714, -0.674487, -0.643585, 0.217766, -0.0251462, 0.79512, + -0.595574, -0.422444, 0.371572, -0.452178, -0.556069, -0.482188, + -0.685456, -0.727851, 0.841829, 0.551535, -0.232336, 0.729158, + -0.00294906, -0.69754, 0.766073, -0.178424, 0.369513, -0.423241, + 0.548547, -0.0152023, -0.757482, -0.85491, 0.251331, -0.989183, + 0.306261, -0.340716, 0.886103, -0.0726757, -0.723523, -0.784303, + 0.0354295, 0.566564, -0.485469, -0.620498, 0.832546, 0.697884, + -0.279115, 0.294415, -0.584313, 0.548772, 0.0648819, 0.968726, + 0.723834, -0.0080452, -0.350386, -0.272803, 0.115121, -0.412644, + -0.824713, -0.992843, -0.592904, -0.417893, 0.863791, -0.423461, + -0.147601, -0.770664, -0.479006, 0.654782, 0.587314, -0.639158, + 0.816969, -0.337228, 0.659878, 0.73107, 0.754768, -0.337042, + 0.0960841, 0.368357, 0.244191, -0.817703, -0.211223, 0.442012, + 0.37225, -0.623598, -0.405423, 0.455101, 0.673656, -0.145345, + -0.511346, -0.901675, -0.81252, -0.127006, 0.809865, -0.721884, + 0.636255, 0.868989, -0.347973, -0.10179, -0.777449, 0.917274, + 0.819286, 0.206218, -0.00785118, 0.167141, 0.45872, 0.972934, + -0.276798, 0.837861, 0.747958, -0.0151566, -0.330057, -0.469077, + 0.277308, 0.415818}; + +static std::initializer_list rnn_recurrent_weights = { + 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0.1}; + +static std::initializer_list rnn_bias = { + 0.065691948, -0.69055247, 0.1107955, -0.97084129, -0.23957068, -0.23566568, + -0.389184, 0.47481549, -0.4791103, 0.29931796, 0.10463274, 0.83918178, + 0.37197268, 0.61957061, 0.3956964, -0.37609905}; + +class RNNOpModel : public SingleOpModelWithNNAPI { + public: + RNNOpModel(int batches, int units, int size, + const TensorType& weights = TensorType_FLOAT32, + const TensorType& recurrent_weights = TensorType_FLOAT32) + : batches_(batches), units_(units), input_size_(size) { + input_ = AddInput(TensorType_FLOAT32); + weights_ = AddInput(weights); + recurrent_weights_ = AddInput(recurrent_weights); + bias_ = AddInput(TensorType_FLOAT32); + hidden_state_ = AddOutput(TensorType_FLOAT32); + output_ = AddOutput(TensorType_FLOAT32); + SetBuiltinOp( + BuiltinOperator_RNN, BuiltinOptions_RNNOptions, + CreateRNNOptions(builder_, ActivationFunctionType_RELU).Union()); + BuildInterpreter({{batches_, input_size_}, + {units_, input_size_}, + {units_, units_}, + {units_}}); + } + + void SetBias(std::initializer_list f) { PopulateTensor(bias_, f); } + + void SetWeights(std::initializer_list f) { + PopulateTensor(weights_, f); + } + + void SetRecurrentWeights(std::initializer_list f) { + PopulateTensor(recurrent_weights_, f); + } + + void SetInput(std::initializer_list data) { + PopulateTensor(input_, data); + } + + void SetInput(int offset, float* begin, float* end) { + PopulateTensor(input_, offset, begin, end); + } + + void ResetHiddenState() { + const int zero_buffer_size = units_ * batches_; + std::unique_ptr zero_buffer(new float[zero_buffer_size]); + memset(zero_buffer.get(), 0, zero_buffer_size * sizeof(float)); + PopulateTensor(hidden_state_, 0, zero_buffer.get(), + zero_buffer.get() + zero_buffer_size); + } + + std::vector GetOutput() { return ExtractVector(output_); } + + int input_size() { return input_size_; } + int num_units() { return units_; } + int num_batches() { return batches_; } + + protected: + int input_; + int weights_; + int recurrent_weights_; + int bias_; + int hidden_state_; + int output_; + + int batches_; + int units_; + int input_size_; +}; + +TEST(NNAPIDelegate, RnnBlackBoxTest) { + RNNOpModel rnn(2, 16, 8); + rnn.SetWeights(rnn_weights); + rnn.SetBias(rnn_bias); + rnn.SetRecurrentWeights(rnn_recurrent_weights); + + rnn.ResetHiddenState(); + const int input_sequence_size = sizeof(rnn_input) / sizeof(float) / + (rnn.input_size() * rnn.num_batches()); + + for (int i = 0; i < input_sequence_size; i++) { + float* batch_start = rnn_input + i * rnn.input_size(); + float* batch_end = batch_start + rnn.input_size(); + rnn.SetInput(0, batch_start, batch_end); + rnn.SetInput(rnn.input_size(), batch_start, batch_end); + + rnn.Invoke(); + + float* golden_start = rnn_golden_output + i * rnn.num_units(); + float* golden_end = golden_start + rnn.num_units(); + std::vector expected; + expected.insert(expected.end(), golden_start, golden_end); + expected.insert(expected.end(), golden_start, golden_end); + + EXPECT_THAT(rnn.GetOutput(), ElementsAreArray(ArrayFloatNear(expected))); + } +} + +static float svdf_input[] = { + 0.12609188, -0.46347019, -0.89598465, + 0.35867718, 0.36897406, 0.73463392, + + 0.14278367, -1.64410412, -0.75222826, + -0.57290924, 0.12729003, 0.7567004, + + 0.49837467, 0.19278903, 0.26584083, + 0.17660543, 0.52949083, -0.77931279, + + -0.11186574, 0.13164264, -0.05349274, + -0.72674477, -0.5683046, 0.55900657, + + -0.68892461, 0.37783599, 0.18263303, + -0.63690937, 0.44483393, -0.71817774, + + -0.81299269, -0.86831826, 1.43940818, + -0.95760226, 1.82078898, 0.71135032, + + -1.45006323, -0.82251364, -1.69082689, + -1.65087092, -1.89238167, 1.54172635, + + 0.03966608, -0.24936394, -0.77526885, + 2.06740379, -1.51439476, 1.43768692, + + 0.11771342, -0.23761693, -0.65898693, + 0.31088525, -1.55601168, -0.87661445, + + -0.89477462, 1.67204106, -0.53235275, + -0.6230064, 0.29819036, 1.06939757, +}; + +static float svdf_golden_output_rank_1[] = { + 0.014899, -0.0517661, -0.143725, -0.00271883, + -0.03004015, 0.09565311, 0.1587342, 0.00784263, + + 0.068281, -0.162217, -0.152268, 0.00323521, + 0.01582633, 0.03858774, -0.03001583, -0.02671271, + + -0.0317821, -0.0333089, 0.0609602, 0.0333759, + -0.01432795, 0.05524484, 0.1101355, -0.02382665, + + -0.00623099, -0.077701, -0.391193, -0.0136691, + -0.02333033, 0.02293761, 0.12338032, 0.04326871, + + 0.201551, -0.164607, -0.179462, -0.0592739, + 0.01064911, -0.17503069, 0.07821996, -0.00224009, + + 0.0886511, -0.0875401, -0.269283, 0.0281379, + -0.02282338, 0.09741908, 0.32973239, 0.12281385, + + -0.201174, -0.586145, -0.628624, -0.0330412, + 0.24780814, -0.39304617, -0.22473189, 0.02589256, + + -0.0839096, -0.299329, 0.108746, 0.109808, + 0.10084175, -0.06416984, 0.28936723, 0.0026358, + + 0.419114, -0.237824, -0.422627, 0.175115, + -0.2314795, -0.18584411, -0.4228974, -0.12928449, + + 0.36726, -0.522303, -0.456502, -0.175475, + 0.17012937, -0.34447709, 0.38505614, -0.28158101, +}; + +static float svdf_golden_output_rank_2[] = { + -0.09623547, -0.10193135, 0.11083051, -0.0347917, + 0.1141196, 0.12965347, -0.12652366, 0.01007236, + + -0.16396809, -0.21247184, 0.11259045, -0.04156673, + 0.10132131, -0.06143532, -0.00924693, 0.10084561, + + 0.01257364, 0.0506071, -0.19287863, -0.07162561, + -0.02033747, 0.22673416, 0.15487903, 0.02525555, + + -0.1411963, -0.37054959, 0.01774767, 0.05867489, + 0.09607603, -0.0141301, -0.08995658, 0.12867066, + + -0.27142537, -0.16955489, 0.18521598, -0.12528358, + 0.00331409, 0.11167502, 0.02218599, -0.07309391, + + 0.09593632, -0.28361851, -0.0773851, 0.17199151, + -0.00075242, 0.33691186, -0.1536046, 0.16572715, + + -0.27916506, -0.27626723, 0.42615682, 0.3225764, + -0.37472126, -0.55655634, -0.05013514, 0.289112, + + -0.24418658, 0.07540751, -0.1940318, -0.08911639, + 0.00732617, 0.46737891, 0.26449674, 0.24888524, + + -0.17225097, -0.54660404, -0.38795233, 0.08389944, + 0.07736043, -0.28260678, 0.15666828, 1.14949894, + + -0.57454878, -0.64704704, 0.73235172, -0.34616736, + 0.21120001, -0.22927976, 0.02455296, -0.35906726, +}; + +class BaseSVDFOpModel : public SingleOpModelWithNNAPI { + public: + BaseSVDFOpModel(int batches, int units, int input_size, int memory_size, + int rank, + TensorType weights_feature_type = TensorType_FLOAT32, + TensorType weights_time_type = TensorType_FLOAT32) + : batches_(batches), + units_(units), + input_size_(input_size), + memory_size_(memory_size), + rank_(rank) { + input_ = AddInput(TensorType_FLOAT32); + weights_feature_ = AddInput(weights_feature_type); + weights_time_ = AddInput(weights_time_type); + bias_ = AddNullInput(); + state_ = AddOutput(TensorType_FLOAT32); + output_ = AddOutput(TensorType_FLOAT32); + SetBuiltinOp( + BuiltinOperator_SVDF, BuiltinOptions_SVDFOptions, + CreateSVDFOptions(builder_, rank, ActivationFunctionType_NONE).Union()); + BuildInterpreter({ + {batches_, input_size_}, // Input tensor + {units_ * rank, input_size_}, // weights_feature tensor + {units_ * rank, memory_size_}, // weights_time tensor + {units_} // bias tensor + }); + } + + // Populates the weights_feature tensor. + void SetWeightsFeature(std::initializer_list f) { + PopulateTensor(weights_feature_, f); + } + + // Populates the weights_time tensor. + void SetWeightsTime(std::initializer_list f) { + PopulateTensor(weights_time_, f); + } + + // Populates the input tensor. + void SetInput(int offset, float* begin, float* end) { + PopulateTensor(input_, offset, begin, end); + } + + // Resets the state of SVDF op by filling it with 0's. + void ResetState() { + const int zero_buffer_size = rank_ * units_ * batches_ * memory_size_; + std::unique_ptr zero_buffer(new float[zero_buffer_size]); + memset(zero_buffer.get(), 0, zero_buffer_size * sizeof(float)); + PopulateTensor(state_, 0, zero_buffer.get(), + zero_buffer.get() + zero_buffer_size); + } + + // Extracts the output tensor from the SVDF op. + std::vector GetOutput() { return ExtractVector(output_); } + + int input_size() { return input_size_; } + int num_units() { return units_; } + int num_batches() { return batches_; } + + protected: + int input_; + int weights_feature_; + int weights_time_; + int bias_; + int state_; + int output_; + + int batches_; + int units_; + int input_size_; + int memory_size_; + int rank_; +}; + +class SVDFOpModel : public BaseSVDFOpModel { + public: + using BaseSVDFOpModel::BaseSVDFOpModel; + + void VerifyGoldens(float golden_input[], float golden_output[], + int golden_size, float tolerance = 1e-5) { + const int svdf_num_batches = num_batches(); + const int svdf_input_size = input_size(); + const int svdf_num_units = num_units(); + const int input_sequence_size = + golden_size / sizeof(float) / (svdf_input_size * svdf_num_batches); + // Going over each input batch, setting the input tensor, invoking the SVDF + // op and checking the output with the expected golden values. + for (int i = 0; i < input_sequence_size; i++) { + float* batch_start = + golden_input + i * svdf_input_size * svdf_num_batches; + float* batch_end = batch_start + svdf_input_size * svdf_num_batches; + SetInput(0, batch_start, batch_end); + + Invoke(); + + const float* golden_start = + golden_output + i * svdf_num_units * svdf_num_batches; + const float* golden_end = + golden_start + svdf_num_units * svdf_num_batches; + std::vector expected; + expected.insert(expected.end(), golden_start, golden_end); + + EXPECT_THAT(GetOutput(), + ElementsAreArray(ArrayFloatNear(expected, tolerance))); + } + } +}; + +TEST(NNAPIDelegate, SVDFBlackBoxTestRank1) { + SVDFOpModel svdf(/*batches=*/2, /*units=*/4, /*input_size=*/3, + /*memory_size=*/10, /*rank=*/1); + svdf.SetWeightsFeature({-0.31930989, -0.36118156, 0.0079667, 0.37613347, + 0.22197971, 0.12416199, 0.27901134, 0.27557442, + 0.3905206, -0.36137494, -0.06634006, -0.10640851}); + + svdf.SetWeightsTime( + {-0.31930989, 0.37613347, 0.27901134, -0.36137494, -0.36118156, + 0.22197971, 0.27557442, -0.06634006, 0.0079667, 0.12416199, + + 0.3905206, -0.10640851, -0.0976817, 0.15294972, 0.39635518, + -0.02702999, 0.39296314, 0.15785322, 0.21931258, 0.31053296, + + -0.36916667, 0.38031587, -0.21580373, 0.27072677, 0.23622236, + 0.34936687, 0.18174365, 0.35907319, -0.17493086, 0.324846, + + -0.10781813, 0.27201805, 0.14324132, -0.23681851, -0.27115166, + -0.01580888, -0.14943552, 0.15465137, 0.09784451, -0.0337657}); + + svdf.ResetState(); + svdf.VerifyGoldens(svdf_input, svdf_golden_output_rank_1, sizeof(svdf_input)); +} + +TEST(NNAPIDelegate, SVDFBlackBoxTestRank2) { + SVDFOpModel svdf(/*batches=*/2, /*units=*/4, /*input_size=*/3, + /*memory_size=*/10, /*rank=*/2); + svdf.SetWeightsFeature({-0.31930989, 0.0079667, 0.39296314, 0.37613347, + 0.12416199, 0.15785322, 0.27901134, 0.3905206, + 0.21931258, -0.36137494, -0.10640851, 0.31053296, + -0.36118156, -0.0976817, -0.36916667, 0.22197971, + 0.15294972, 0.38031587, 0.27557442, 0.39635518, + -0.21580373, -0.06634006, -0.02702999, 0.27072677}); + + svdf.SetWeightsTime( + {-0.31930989, 0.37613347, 0.27901134, -0.36137494, -0.36118156, + 0.22197971, 0.27557442, -0.06634006, 0.0079667, 0.12416199, + + 0.3905206, -0.10640851, -0.0976817, 0.15294972, 0.39635518, + -0.02702999, 0.39296314, 0.15785322, 0.21931258, 0.31053296, + + -0.36916667, 0.38031587, -0.21580373, 0.27072677, 0.23622236, + 0.34936687, 0.18174365, 0.35907319, -0.17493086, 0.324846, + + -0.10781813, 0.27201805, 0.14324132, -0.23681851, -0.27115166, + -0.01580888, -0.14943552, 0.15465137, 0.09784451, -0.0337657, + + -0.14884081, 0.19931212, -0.36002168, 0.34663299, -0.11405486, + 0.12672701, 0.39463779, -0.07886535, -0.06384811, 0.08249187, + + -0.26816407, -0.19905911, 0.29211238, 0.31264046, -0.28664589, + 0.05698794, 0.11613581, 0.14078894, 0.02187902, -0.21781836, + + -0.15567942, 0.08693647, -0.38256618, 0.36580828, -0.22922277, + -0.0226903, 0.12878349, -0.28122205, -0.10850525, -0.11955214, + + 0.27179423, -0.04710215, 0.31069002, 0.22672787, 0.09580326, + 0.08682203, 0.1258215, 0.1851041, 0.29228821, 0.12366763}); + + svdf.ResetState(); + svdf.VerifyGoldens(svdf_input, svdf_golden_output_rank_2, sizeof(svdf_input)); +} + +class LSTMOpModel : public SingleOpModelWithNNAPI { + public: + LSTMOpModel(int n_batch, int n_input, int n_cell, int n_output, bool use_cifg, + bool use_peephole, bool use_projection_weights, + bool use_projection_bias, float cell_clip, float proj_clip, + const std::vector>& input_shapes, + const TensorType& weight_type = TensorType_FLOAT32) + : n_batch_(n_batch), + n_input_(n_input), + n_cell_(n_cell), + n_output_(n_output) { + input_ = AddInput(TensorType_FLOAT32); + + if (use_cifg) { + input_to_input_weights_ = AddNullInput(); + } else { + input_to_input_weights_ = AddInput(weight_type); + } + + input_to_forget_weights_ = AddInput(weight_type); + input_to_cell_weights_ = AddInput(weight_type); + input_to_output_weights_ = AddInput(weight_type); + + if (use_cifg) { + recurrent_to_input_weights_ = AddNullInput(); + } else { + recurrent_to_input_weights_ = AddInput(weight_type); + } + + recurrent_to_forget_weights_ = AddInput(weight_type); + recurrent_to_cell_weights_ = AddInput(weight_type); + recurrent_to_output_weights_ = AddInput(weight_type); + + if (use_peephole) { + if (use_cifg) { + cell_to_input_weights_ = AddNullInput(); + } else { + cell_to_input_weights_ = AddInput(weight_type); + } + cell_to_forget_weights_ = AddInput(weight_type); + cell_to_output_weights_ = AddInput(weight_type); + } else { + cell_to_input_weights_ = AddNullInput(); + cell_to_forget_weights_ = AddNullInput(); + cell_to_output_weights_ = AddNullInput(); + } + + if (use_cifg) { + input_gate_bias_ = AddNullInput(); + } else { + input_gate_bias_ = AddInput(TensorType_FLOAT32); + } + forget_gate_bias_ = AddInput(TensorType_FLOAT32); + cell_bias_ = AddInput(TensorType_FLOAT32); + output_gate_bias_ = AddInput(TensorType_FLOAT32); + + if (use_projection_weights) { + projection_weights_ = AddInput(weight_type); + if (use_projection_bias) { + projection_bias_ = AddInput(TensorType_FLOAT32); + } else { + projection_bias_ = AddNullInput(); + } + } else { + projection_weights_ = AddNullInput(); + projection_bias_ = AddNullInput(); + } + + output_state_ = AddOutput(TensorType_FLOAT32); + cell_state_ = AddOutput(TensorType_FLOAT32); + output_ = AddOutput(TensorType_FLOAT32); + + SetBuiltinOp(BuiltinOperator_LSTM, BuiltinOptions_LSTMOptions, + CreateLSTMOptions(builder_, ActivationFunctionType_TANH, + cell_clip, proj_clip) + .Union()); + BuildInterpreter(input_shapes); + } + + void SetInputToInputWeights(std::initializer_list f) { + PopulateTensor(input_to_input_weights_, f); + } + + void SetInputToForgetWeights(std::initializer_list f) { + PopulateTensor(input_to_forget_weights_, f); + } + + void SetInputToCellWeights(std::initializer_list f) { + PopulateTensor(input_to_cell_weights_, f); + } + + void SetInputToOutputWeights(std::initializer_list f) { + PopulateTensor(input_to_output_weights_, f); + } + + void SetRecurrentToInputWeights(std::initializer_list f) { + PopulateTensor(recurrent_to_input_weights_, f); + } + + void SetRecurrentToForgetWeights(std::initializer_list f) { + PopulateTensor(recurrent_to_forget_weights_, f); + } + + void SetRecurrentToCellWeights(std::initializer_list f) { + PopulateTensor(recurrent_to_cell_weights_, f); + } + + void SetRecurrentToOutputWeights(std::initializer_list f) { + PopulateTensor(recurrent_to_output_weights_, f); + } + + void SetCellToInputWeights(std::initializer_list f) { + PopulateTensor(cell_to_input_weights_, f); + } + + void SetCellToForgetWeights(std::initializer_list f) { + PopulateTensor(cell_to_forget_weights_, f); + } + + void SetCellToOutputWeights(std::initializer_list f) { + PopulateTensor(cell_to_output_weights_, f); + } + + void SetInputGateBias(std::initializer_list f) { + PopulateTensor(input_gate_bias_, f); + } + + void SetForgetGateBias(std::initializer_list f) { + PopulateTensor(forget_gate_bias_, f); + } + + void SetCellBias(std::initializer_list f) { + PopulateTensor(cell_bias_, f); + } + + void SetOutputGateBias(std::initializer_list f) { + PopulateTensor(output_gate_bias_, f); + } + + void SetProjectionWeights(std::initializer_list f) { + PopulateTensor(projection_weights_, f); + } + + void SetProjectionBias(std::initializer_list f) { + PopulateTensor(projection_bias_, f); + } + + void ResetOutputState() { + const int zero_buffer_size = n_cell_ * n_batch_; + std::unique_ptr zero_buffer(new float[zero_buffer_size]); + memset(zero_buffer.get(), 0, zero_buffer_size * sizeof(float)); + PopulateTensor(output_state_, 0, zero_buffer.get(), + zero_buffer.get() + zero_buffer_size); + } + + void ResetCellState() { + const int zero_buffer_size = n_cell_ * n_batch_; + std::unique_ptr zero_buffer(new float[zero_buffer_size]); + memset(zero_buffer.get(), 0, zero_buffer_size * sizeof(float)); + PopulateTensor(cell_state_, 0, zero_buffer.get(), + zero_buffer.get() + zero_buffer_size); + } + + void SetInput(int offset, const float* begin, const float* end) { + PopulateTensor(input_, offset, const_cast(begin), + const_cast(end)); + } + + std::vector GetOutput() { return ExtractVector(output_); } + + int num_inputs() { return n_input_; } + int num_outputs() { return n_output_; } + int num_cells() { return n_cell_; } + int num_batches() { return n_batch_; } + + protected: + int input_; + int input_to_input_weights_; + int input_to_forget_weights_; + int input_to_cell_weights_; + int input_to_output_weights_; + + int recurrent_to_input_weights_; + int recurrent_to_forget_weights_; + int recurrent_to_cell_weights_; + int recurrent_to_output_weights_; + + int cell_to_input_weights_; + int cell_to_forget_weights_; + int cell_to_output_weights_; + + int input_gate_bias_; + int forget_gate_bias_; + int cell_bias_; + int output_gate_bias_; + + int projection_weights_; + int projection_bias_; + int input_activation_state_; + int input_cell_state_; + + int output_; + int output_state_; + int cell_state_; + + int n_batch_; + int n_input_; + int n_cell_; + int n_output_; +}; + +class BaseLstmTest : public ::testing::Test { + protected: + // Weights of the LSTM model. Some are optional. + std::initializer_list input_to_input_weights_; + std::initializer_list input_to_cell_weights_; + std::initializer_list input_to_forget_weights_; + std::initializer_list input_to_output_weights_; + std::initializer_list input_gate_bias_; + std::initializer_list cell_gate_bias_; + std::initializer_list forget_gate_bias_; + std::initializer_list output_gate_bias_; + std::initializer_list recurrent_to_input_weights_; + std::initializer_list recurrent_to_cell_weights_; + std::initializer_list recurrent_to_forget_weights_; + std::initializer_list recurrent_to_output_weights_; + std::initializer_list cell_to_input_weights_; + std::initializer_list cell_to_forget_weights_; + std::initializer_list cell_to_output_weights_; + std::initializer_list projection_weights_; + + // LSTM input is stored as num_batch x num_inputs vector. + std::vector> lstm_input_; + // LSTM output is stored as num_batch x num_outputs vector. + std::vector> lstm_golden_output_; + + // Compares output up to tolerance to the result of the lstm given the input. + void VerifyGoldens(const std::vector>& input, + const std::vector>& output, + LSTMOpModel* lstm, float tolerance = 1e-5) { + const int num_batches = input.size(); + EXPECT_GT(num_batches, 0); + const int num_inputs = lstm->num_inputs(); + EXPECT_GT(num_inputs, 0); + const int input_sequence_size = input[0].size() / num_inputs; + EXPECT_GT(input_sequence_size, 0); + for (int i = 0; i < input_sequence_size; ++i) { + for (int b = 0; b < num_batches; ++b) { + const float* batch_start = input[b].data() + i * num_inputs; + const float* batch_end = batch_start + num_inputs; + + lstm->SetInput(b * lstm->num_inputs(), batch_start, batch_end); + } + + lstm->Invoke(); + + const int num_outputs = lstm->num_outputs(); + std::vector expected; + for (int b = 0; b < num_batches; ++b) { + const float* golden_start_batch = output[b].data() + i * num_outputs; + const float* golden_end_batch = golden_start_batch + num_outputs; + expected.insert(expected.end(), golden_start_batch, golden_end_batch); + } + EXPECT_THAT(lstm->GetOutput(), + ElementsAreArray(ArrayFloatNear(expected, tolerance))); + } + } +}; + +class NoCifgNoPeepholeNoProjectionNoClippingLstmTest : public BaseLstmTest { + void SetUp() override { + input_to_input_weights_ = {-0.45018822, -0.02338299, -0.0870589, + -0.34550029, 0.04266912, -0.15680569, + -0.34856534, 0.43890524}; + input_to_cell_weights_ = {-0.50013041, 0.1370284, 0.11810488, 0.2013163, + -0.20583314, 0.44344562, 0.22077113, -0.29909778}; + input_to_forget_weights_ = {0.09701663, 0.20334584, -0.50592935, + -0.31343272, -0.40032279, 0.44781327, + 0.01387155, -0.35593212}; + input_to_output_weights_ = {-0.25065863, -0.28290087, 0.04613829, + 0.40525138, 0.44272184, 0.03897077, + -0.1556896, 0.19487578}; + input_gate_bias_ = {0., 0., 0., 0.}; + cell_gate_bias_ = {0., 0., 0., 0.}; + forget_gate_bias_ = {1., 1., 1., 1.}; + output_gate_bias_ = {0., 0., 0., 0.}; + + recurrent_to_input_weights_ = { + -0.0063535, -0.2042388, 0.31454784, -0.35746509, + 0.28902304, 0.08183324, -0.16555229, 0.02286911, + -0.13566875, 0.03034258, 0.48091322, -0.12528998, + 0.24077177, -0.51332325, -0.33502164, 0.10629296}; + + recurrent_to_cell_weights_ = { + -0.3407414, 0.24443203, -0.2078532, 0.26320225, + 0.05695659, -0.00123841, -0.4744786, -0.35869038, + -0.06418842, -0.13502428, -0.501764, 0.22830659, + -0.46367589, 0.26016325, -0.03894562, -0.16368064}; + + recurrent_to_forget_weights_ = { + -0.48684245, -0.06655136, 0.42224967, 0.2112639, + 0.27654213, 0.20864892, -0.07646349, 0.45877004, + 0.00141793, -0.14609534, 0.36447752, 0.09196436, + 0.28053468, 0.01560611, -0.20127171, -0.01140004}; + + recurrent_to_output_weights_ = { + 0.43385774, -0.17194885, 0.2718237, 0.09215671, + 0.24107647, -0.39835793, 0.18212086, 0.01301402, + 0.48572797, -0.50656658, 0.20047462, -0.20607421, + -0.51818722, -0.15390486, 0.0468148, 0.39922136}; + + lstm_input_ = {{2., 3., 3., 4., 1., 1.}}; + lstm_golden_output_ = {{-0.02973187, 0.1229473, 0.20885126, -0.15358765, + -0.03716109, 0.12507336, 0.41193449, -0.20860538, + -0.15053082, 0.09120187, 0.24278517, -0.12222792}}; + } +}; + +TEST_F(NoCifgNoPeepholeNoProjectionNoClippingLstmTest, LstmBlackBoxTest) { + const int n_batch = 1; + const int n_input = 2; + // n_cell and n_output have the same size when there is no projection. + const int n_cell = 4; + const int n_output = 4; + + LSTMOpModel lstm(n_batch, n_input, n_cell, n_output, + /*use_cifg=*/false, /*use_peephole=*/false, + /*use_projection_weights=*/false, + /*use_projection_bias=*/false, + /*cell_clip=*/0.0, /*proj_clip=*/0.0, + { + {n_batch, n_input}, // input tensor + + {n_cell, n_input}, // input_to_input_weight tensor + {n_cell, n_input}, // input_to_forget_weight tensor + {n_cell, n_input}, // input_to_cell_weight tensor + {n_cell, n_input}, // input_to_output_weight tensor + + {n_cell, n_output}, // recurrent_to_input_weight_tensor + {n_cell, n_output}, // recurrent_to_forget_weight_tensor + {n_cell, n_output}, // recurrent_to_cell_weight_tensor + {n_cell, n_output}, // recurrent_to_output_weight_tensor + + {0}, // cell_to_input_weight tensor + {0}, // cell_to_forget_weight tensor + {0}, // cell_to_output_weight tensor + + {n_cell}, // input_gate_bias tensor + {n_cell}, // forget_gate_bias tensor + {n_cell}, // cell_bias tensor + {n_cell}, // output_gate_bias tensor + + {0, 0}, // projection_weight tensor + {0}, // projection_bias tensor + }); + + lstm.SetInputToInputWeights(input_to_input_weights_); + lstm.SetInputToCellWeights(input_to_cell_weights_); + lstm.SetInputToForgetWeights(input_to_forget_weights_); + lstm.SetInputToOutputWeights(input_to_output_weights_); + + lstm.SetInputGateBias(input_gate_bias_); + lstm.SetCellBias(cell_gate_bias_); + lstm.SetForgetGateBias(forget_gate_bias_); + lstm.SetOutputGateBias(output_gate_bias_); + + lstm.SetRecurrentToInputWeights(recurrent_to_input_weights_); + lstm.SetRecurrentToCellWeights(recurrent_to_cell_weights_); + lstm.SetRecurrentToForgetWeights(recurrent_to_forget_weights_); + lstm.SetRecurrentToOutputWeights(recurrent_to_output_weights_); + + // Resetting cell_state and output_state + lstm.ResetCellState(); + lstm.ResetOutputState(); + + VerifyGoldens(lstm_input_, lstm_golden_output_, &lstm); +} + +class CifgNoPeepholeNoProjectionNoClippingLstmTest : public BaseLstmTest { + void SetUp() override { + input_to_cell_weights_ = {-0.49770179, -0.27711356, -0.09624726, + 0.05100781, 0.04717243, 0.48944736, + -0.38535351, -0.17212132}; + + input_to_forget_weights_ = {-0.55291498, -0.42866567, 0.13056988, + -0.3633365, -0.22755712, 0.28253698, + 0.24407166, 0.33826375}; + + input_to_output_weights_ = {0.10725588, -0.02335852, -0.55932593, + -0.09426838, -0.44257352, 0.54939759, + 0.01533556, 0.42751634}; + cell_gate_bias_ = {0., 0., 0., 0.}; + forget_gate_bias_ = {1., 1., 1., 1.}; + output_gate_bias_ = {0., 0., 0., 0.}; + + recurrent_to_cell_weights_ = { + 0.54066205, -0.32668582, -0.43562764, -0.56094903, + 0.42957711, 0.01841056, -0.32764608, -0.33027974, + -0.10826075, 0.20675004, 0.19069612, -0.03026325, + -0.54532051, 0.33003211, 0.44901288, 0.21193194}; + + recurrent_to_forget_weights_ = { + -0.13832897, -0.0515101, -0.2359007, -0.16661474, + -0.14340827, 0.36986142, 0.23414481, 0.55899, + 0.10798943, -0.41174671, 0.17751795, -0.34484994, + -0.35874045, -0.11352962, 0.27268326, 0.54058349}; + + recurrent_to_output_weights_ = { + 0.41613156, 0.42610586, -0.16495961, -0.5663873, + 0.30579174, -0.05115908, -0.33941799, 0.23364776, + 0.11178309, 0.09481031, -0.26424935, 0.46261835, + 0.50248802, 0.26114327, -0.43736315, 0.33149987}; + + cell_to_forget_weights_ = {0.47485286, -0.51955009, -0.24458408, + 0.31544167}; + cell_to_output_weights_ = {-0.17135078, 0.82760304, 0.85573703, + -0.77109635}; + + lstm_input_ = {{2., 3., 3., 4., 1., 1.}}; + lstm_golden_output_ = {{-0.36444446, -0.00352185, 0.12886585, -0.05163646, + -0.42312205, -0.01218222, 0.24201041, -0.08124574, + -0.358325, -0.04621704, 0.21641694, -0.06471302}}; + } +}; + +TEST_F(CifgNoPeepholeNoProjectionNoClippingLstmTest, LstmBlackBoxTest) { + const int n_batch = 1; + const int n_input = 2; + // n_cell and n_output have the same size when there is no projection. + const int n_cell = 4; + const int n_output = 4; + + LSTMOpModel lstm(n_batch, n_input, n_cell, n_output, + /*use_cifg=*/true, /*use_peephole=*/true, + /*use_projection_weights=*/false, + /*use_projection_bias=*/false, + /*cell_clip=*/0.0, /*proj_clip=*/0.0, + { + {n_batch, n_input}, // input tensor + + {0, 0}, // input_to_input_weight tensor + {n_cell, n_input}, // input_to_forget_weight tensor + {n_cell, n_input}, // input_to_cell_weight tensor + {n_cell, n_input}, // input_to_output_weight tensor + + {0, 0}, // recurrent_to_input_weight tensor + {n_cell, n_output}, // recurrent_to_forget_weight tensor + {n_cell, n_output}, // recurrent_to_cell_weight tensor + {n_cell, n_output}, // recurrent_to_output_weight tensor + + {0}, // cell_to_input_weight tensor + {n_cell}, // cell_to_forget_weight tensor + {n_cell}, // cell_to_output_weight tensor + + {0}, // input_gate_bias tensor + {n_cell}, // forget_gate_bias tensor + {n_cell}, // cell_bias tensor + {n_cell}, // output_gate_bias tensor + + {0, 0}, // projection_weight tensor + {0}, // projection_bias tensor + }); + + lstm.SetInputToCellWeights(input_to_cell_weights_); + lstm.SetInputToForgetWeights(input_to_forget_weights_); + lstm.SetInputToOutputWeights(input_to_output_weights_); + + lstm.SetCellBias(cell_gate_bias_); + lstm.SetForgetGateBias(forget_gate_bias_); + lstm.SetOutputGateBias(output_gate_bias_); + + lstm.SetRecurrentToCellWeights(recurrent_to_cell_weights_); + lstm.SetRecurrentToForgetWeights(recurrent_to_forget_weights_); + lstm.SetRecurrentToOutputWeights(recurrent_to_output_weights_); + + lstm.SetCellToForgetWeights(cell_to_forget_weights_); + lstm.SetCellToOutputWeights(cell_to_output_weights_); + + // Resetting cell_state and output_state + lstm.ResetCellState(); + lstm.ResetOutputState(); + + VerifyGoldens(lstm_input_, lstm_golden_output_, &lstm); +} + +class NoCifgPeepholeProjectionClippingLstmTest : public BaseLstmTest { + void SetUp() override { + input_to_input_weights_ = { + 0.021393683, 0.06124551, 0.046905167, -0.014657677, -0.03149463, + 0.09171803, 0.14647801, 0.10797193, -0.0057968358, 0.0019193048, + -0.2726754, 0.10154029, -0.018539885, 0.080349885, -0.10262385, + -0.022599787, -0.09121155, -0.008675967, -0.045206103, -0.0821282, + -0.008045952, 0.015478081, 0.055217247, 0.038719587, 0.044153627, + -0.06453243, 0.05031825, -0.046935108, -0.008164439, 0.014574226, + -0.1671009, -0.15519552, -0.16819797, -0.13971269, -0.11953059, + 0.25005487, -0.22790983, 0.009855087, -0.028140958, -0.11200698, + 0.11295408, -0.0035217577, 0.054485075, 0.05184695, 0.064711206, + 0.10989193, 0.11674786, 0.03490607, 0.07727357, 0.11390585, + -0.1863375, -0.1034451, -0.13945189, -0.049401227, -0.18767063, + 0.042483903, 0.14233552, 0.13832581, 0.18350165, 0.14545603, + -0.028545704, 0.024939531, 0.050929718, 0.0076203286, -0.0029723682, + -0.042484224, -0.11827596, -0.09171104, -0.10808628, -0.16327988, + -0.2273378, -0.0993647, -0.017155107, 0.0023917493, 0.049272764, + 0.0038534778, 0.054764505, 0.089753784, 0.06947234, 0.08014476, + -0.04544234, -0.0497073, -0.07135631, -0.048929106, -0.004042012, + -0.009284026, 0.018042054, 0.0036860977, -0.07427302, -0.11434604, + -0.018995456, 0.031487543, 0.012834908, 0.019977754, 0.044256654, + -0.39292613, -0.18519334, -0.11651281, -0.06809892, 0.011373677}; + + input_to_forget_weights_ = { + -0.0018401089, -0.004852237, 0.03698424, 0.014181704, + 0.028273236, -0.016726194, -0.05249759, -0.10204261, + 0.00861066, -0.040979505, -0.009899187, 0.01923892, + -0.028177269, -0.08535103, -0.14585495, 0.10662567, + -0.01909731, -0.017883534, -0.0047269356, -0.045103323, + 0.0030784295, 0.076784775, 0.07463696, 0.094531395, + 0.0814421, -0.12257899, -0.033945758, -0.031303465, + 0.045630626, 0.06843887, -0.13492945, -0.012480007, + -0.0811829, -0.07224499, -0.09628791, 0.045100946, + 0.0012300825, 0.013964662, 0.099372394, 0.02543059, + 0.06958324, 0.034257296, 0.0482646, 0.06267997, + 0.052625068, 0.12784666, 0.07077897, 0.025725935, + 0.04165009, 0.07241905, 0.018668644, -0.037377294, + -0.06277783, -0.08833636, -0.040120605, -0.011405586, + -0.007808335, -0.010301386, -0.005102167, 0.027717464, + 0.05483423, 0.11449111, 0.11289652, 0.10939839, + 0.13396506, -0.08402166, -0.01901462, -0.044678304, + -0.07720565, 0.014350063, -0.11757958, -0.0652038, + -0.08185733, -0.076754324, -0.092614375, 0.10405491, + 0.052960336, 0.035755895, 0.035839386, -0.012540553, + 0.036881298, 0.02913376, 0.03420159, 0.05448447, + -0.054523353, 0.02582715, 0.02327355, -0.011857179, + -0.0011980024, -0.034641717, -0.026125094, -0.17582615, + -0.15923657, -0.27486774, -0.0006143371, 0.0001771948, + -8.470171e-05, 0.02651807, 0.045790765, 0.06956496}; + + input_to_cell_weights_ = { + -0.04580283, -0.09549462, -0.032418985, -0.06454633, + -0.043528453, 0.043018587, -0.049152344, -0.12418144, + -0.078985475, -0.07596889, 0.019484362, -0.11434962, + -0.0074034138, -0.06314844, -0.092981495, 0.0062155537, + -0.025034338, -0.0028890965, 0.048929527, 0.06235075, + 0.10665918, -0.032036792, -0.08505916, -0.10843358, + -0.13002433, -0.036816437, -0.02130134, -0.016518239, + 0.0047691227, -0.0025825808, 0.066017866, 0.029991534, + -0.10652836, -0.1037554, -0.13056071, -0.03266643, + -0.033702414, -0.006473424, -0.04611692, 0.014419339, + -0.025174323, 0.0396852, 0.081777506, 0.06157468, + 0.10210095, -0.009658194, 0.046511717, 0.03603906, + 0.0069369148, 0.015960095, -0.06507666, 0.09551598, + 0.053568836, 0.06408714, 0.12835667, -0.008714329, + -0.20211966, -0.12093674, 0.029450472, 0.2849013, + -0.029227901, 0.1164364, -0.08560263, 0.09941786, + -0.036999565, -0.028842626, -0.0033637602, -0.017012902, + -0.09720865, -0.11193351, -0.029155117, -0.017936034, + -0.009768936, -0.04223324, -0.036159635, 0.06505112, + -0.021742892, -0.023377212, -0.07221364, -0.06430552, + 0.05453865, 0.091149814, 0.06387331, 0.007518393, + 0.055960953, 0.069779344, 0.046411168, 0.10509911, + 0.07463894, 0.0075130584, 0.012850982, 0.04555431, + 0.056955688, 0.06555285, 0.050801456, -0.009862683, + 0.00826772, -0.026555609, -0.0073611983, -0.0014897042}; + + input_to_output_weights_ = { + -0.0998932, -0.07201956, -0.052803773, -0.15629593, -0.15001918, + -0.07650751, 0.02359855, -0.075155355, -0.08037709, -0.15093534, + 0.029517552, -0.04751393, 0.010350531, -0.02664851, -0.016839722, + -0.023121163, 0.0077019283, 0.012851257, -0.05040649, -0.0129761, + -0.021737747, -0.038305793, -0.06870586, -0.01481247, -0.001285394, + 0.10124236, 0.083122835, 0.053313006, -0.062235646, -0.075637154, + -0.027833903, 0.029774971, 0.1130802, 0.09218906, 0.09506135, + -0.086665764, -0.037162706, -0.038880914, -0.035832845, -0.014481564, + -0.09825003, -0.12048569, -0.097665586, -0.05287633, -0.0964047, + -0.11366429, 0.035777505, 0.13568819, 0.052451383, 0.050649304, + 0.05798951, -0.021852335, -0.099848844, 0.014740475, -0.078897946, + 0.04974699, 0.014160473, 0.06973932, 0.04964942, 0.033364646, + 0.08190124, 0.025535367, 0.050893165, 0.048514254, 0.06945813, + -0.078907564, -0.06707616, -0.11844508, -0.09986688, -0.07509403, + 0.06263226, 0.14925587, 0.20188436, 0.12098451, 0.14639415, + 0.0015017595, -0.014267382, -0.03417257, 0.012711468, 0.0028300495, + -0.024758482, -0.05098548, -0.0821182, 0.014225672, 0.021544158, + 0.08949725, 0.07505268, -0.0020780868, 0.04908258, 0.06476295, + -0.022907063, 0.027562456, 0.040185735, 0.019567577, -0.015598739, + -0.049097303, -0.017121866, -0.083368234, -0.02332002, -0.0840956}; + + input_gate_bias_ = {0.02234832, 0.14757581, 0.18176508, 0.10380666, + 0.053110216, -0.06928846, -0.13942584, -0.11816189, + 0.19483899, 0.03652339, -0.10250295, 0.036714908, + -0.18426876, 0.036065217, 0.21810818, 0.02383196, + -0.043370757, 0.08690144, -0.04444982, 0.00030581196}; + + forget_gate_bias_ = {0.035185695, -0.042891346, -0.03032477, 0.23027696, + 0.11098921, 0.15378423, 0.09263801, 0.09790885, + 0.09508917, 0.061199076, 0.07665568, -0.015443159, + -0.03499149, 0.046190713, 0.08895977, 0.10899629, + 0.40694186, 0.06030037, 0.012413437, -0.06108739}; + + cell_gate_bias_ = {-0.024379363, 0.0055531194, 0.23377132, 0.033463873, + -0.1483596, -0.10639995, -0.091433935, 0.058573797, + -0.06809782, -0.07889636, -0.043246906, -0.09829136, + -0.4279842, 0.034901652, 0.18797937, 0.0075234566, + 0.016178843, 0.1749513, 0.13975595, 0.92058027}; + + output_gate_bias_ = {0.046159424, -0.0012809046, 0.03563469, 0.12648113, + 0.027195795, 0.35373217, -0.018957434, 0.008907322, + -0.0762701, 0.12018895, 0.04216877, 0.0022856654, + 0.040952638, 0.3147856, 0.08225149, -0.057416286, + -0.14995944, -0.008040261, 0.13208859, 0.029760877}; + + recurrent_to_input_weights_ = { + -0.001374326, -0.078856036, 0.10672688, 0.029162422, + -0.11585556, 0.02557986, -0.13446963, -0.035785314, + -0.01244275, 0.025961924, -0.02337298, -0.044228926, + -0.055839065, -0.046598054, -0.010546039, -0.06900766, + 0.027239809, 0.022582639, -0.013296484, -0.05459212, + 0.08981, -0.045407712, 0.08682226, -0.06867011, + -0.14390695, -0.02916037, 0.000996957, 0.091420636, + 0.14283475, -0.07390571, -0.06402044, 0.062524505, + -0.093129106, 0.04860203, -0.08364217, -0.08119002, + 0.009352075, 0.22920375, 0.0016303885, 0.11583097, + -0.13732095, 0.012405723, -0.07551853, 0.06343048, + 0.12162708, -0.031923793, -0.014335606, 0.01790974, + -0.10650317, -0.0724401, 0.08554849, -0.05727212, + 0.06556731, -0.042729504, -0.043227166, 0.011683251, + -0.013082158, -0.029302018, -0.010899579, -0.062036745, + -0.022509435, -0.00964907, -0.01567329, 0.04260106, + -0.07787477, -0.11576462, 0.017356863, 0.048673786, + -0.017577527, -0.05527947, -0.082487635, -0.040137455, + -0.10820036, -0.04666372, 0.022746278, -0.07851417, + 0.01068115, 0.032956902, 0.022433773, 0.0026891115, + 0.08944216, -0.0685835, 0.010513544, 0.07228705, + 0.02032331, -0.059686817, -0.0005566496, -0.086984694, + 0.040414046, -0.1380399, 0.094208956, -0.05722982, + 0.012092817, -0.04989123, -0.086576, -0.003399834, + -0.04696032, -0.045747425, 0.10091314, 0.048676282, + -0.029037097, 0.031399418, -0.0040285117, 0.047237843, + 0.09504992, 0.041799378, -0.049185462, -0.031518843, + -0.10516937, 0.026374253, 0.10058866, -0.0033195973, + -0.041975245, 0.0073591834, 0.0033782164, -0.004325073, + -0.10167381, 0.042500053, -0.01447153, 0.06464186, + -0.017142897, 0.03312627, 0.009205989, 0.024138335, + -0.011337001, 0.035530265, -0.010912711, 0.0706555, + -0.005894094, 0.051841937, -0.1401738, -0.02351249, + 0.0365468, 0.07590991, 0.08838724, 0.021681072, + -0.10086113, 0.019608743, -0.06195883, 0.077335775, + 0.023646897, -0.095322326, 0.02233014, 0.09756986, + -0.048691444, -0.009579111, 0.07595467, 0.11480546, + -0.09801813, 0.019894179, 0.08502348, 0.004032281, + 0.037211012, 0.068537936, -0.048005626, -0.091520436, + -0.028379958, -0.01556313, 0.06554592, -0.045599163, + -0.01672207, -0.020169014, -0.011877351, -0.20212261, + 0.010889619, 0.0047078193, 0.038385306, 0.08540671, + -0.017140968, -0.0035865551, 0.016678626, 0.005633034, + 0.015963363, 0.00871737, 0.060130805, 0.028611384, + 0.10109069, -0.015060172, -0.07894427, 0.06401885, + 0.011584063, -0.024466386, 0.0047652307, -0.09041358, + 0.030737216, -0.0046374933, 0.14215417, -0.11823516, + 0.019899689, 0.006106124, -0.027092824, 0.0786356, + 0.05052217, -0.058925, -0.011402121, -0.024987547, + -0.0013661642, -0.06832946, -0.015667673, -0.1083353, + -0.00096863037, -0.06988685, -0.053350925, -0.027275559, + -0.033664223, -0.07978348, -0.025200296, -0.017207067, + -0.058403496, -0.055697463, 0.005798788, 0.12965427, + -0.062582195, 0.0013350133, -0.10482091, 0.0379771, + 0.072521195, -0.0029455067, -0.13797039, -0.03628521, + 0.013806405, -0.017858358, -0.01008298, -0.07700066, + -0.017081132, 0.019358726, 0.0027079724, 0.004635139, + 0.062634714, -0.02338735, -0.039547626, -0.02050681, + 0.03385117, -0.083611414, 0.002862572, -0.09421313, + 0.058618143, -0.08598433, 0.00972939, 0.023867095, + -0.053934585, -0.023203006, 0.07452513, -0.048767887, + -0.07314807, -0.056307215, -0.10433547, -0.06440842, + 0.04328182, 0.04389765, -0.020006588, -0.09076438, + -0.11652589, -0.021705797, 0.03345259, -0.010329105, + -0.025767034, 0.013057034, -0.07316461, -0.10145612, + 0.06358255, 0.18531723, 0.07759293, 0.12006465, + 0.1305557, 0.058638252, -0.03393652, 0.09622831, + -0.16253184, -2.4580743e-06, 0.079869635, -0.070196845, + -0.005644518, 0.06857898, -0.12598175, -0.035084512, + 0.03156317, -0.12794146, -0.031963028, 0.04692781, + 0.030070418, 0.0071660685, -0.095516115, -0.004643372, + 0.040170413, -0.062104587, -0.0037324072, 0.0554317, + 0.08184801, -0.019164372, 0.06791302, 0.034257166, + -0.10307039, 0.021943003, 0.046745934, 0.0790918, + -0.0265588, -0.007824208, 0.042546265, -0.00977924, + -0.0002440307, -0.017384544, -0.017990116, 0.12252321, + -0.014512694, -0.08251313, 0.08861942, 0.13589665, + 0.026351685, 0.012641483, 0.07466548, 0.044301085, + -0.045414884, -0.051112458, 0.03444247, -0.08502782, + -0.04106223, -0.028126027, 0.028473156, 0.10467447}; + + recurrent_to_cell_weights_ = { + -0.037322544, 0.018592842, 0.0056175636, -0.06253426, + 0.055647098, -0.05713207, -0.05626563, 0.005559383, + 0.03375411, -0.025757805, -0.088049285, 0.06017052, + -0.06570978, 0.007384076, 0.035123326, -0.07920549, + 0.053676967, 0.044480428, -0.07663568, 0.0071805613, + 0.08089997, 0.05143358, 0.038261272, 0.03339287, + -0.027673481, 0.044746667, 0.028349208, 0.020090483, + -0.019443132, -0.030755889, -0.0040000007, 0.04465846, + -0.021585021, 0.0031670958, 0.0053199246, -0.056117613, + -0.10893326, 0.076739706, -0.08509834, -0.027997585, + 0.037871376, 0.01449768, -0.09002357, -0.06111149, + -0.046195522, 0.0422062, -0.005683705, -0.1253618, + -0.012925729, -0.04890792, 0.06985068, 0.037654128, + 0.03398274, -0.004781977, 0.007032333, -0.031787455, + 0.010868644, -0.031489216, 0.09525667, 0.013939797, + 0.0058680447, 0.0167067, 0.02668468, -0.04797466, + -0.048885044, -0.12722108, 0.035304096, 0.06554885, + 0.00972396, -0.039238118, -0.05159735, -0.11329045, + 0.1613692, -0.03750952, 0.06529313, -0.071974665, + -0.11769596, 0.015524369, -0.0013754242, -0.12446318, + 0.02786344, -0.014179351, 0.005264273, 0.14376344, + 0.015983658, 0.03406988, -0.06939408, 0.040699873, + 0.02111075, 0.09669095, 0.041345075, -0.08316494, + -0.07684199, -0.045768797, 0.032298047, -0.041805092, + 0.0119405, 0.0061010392, 0.12652606, 0.0064572375, + -0.024950314, 0.11574242, 0.04508852, -0.04335324, + 0.06760663, -0.027437469, 0.07216407, 0.06977076, + -0.05438599, 0.034033038, -0.028602652, 0.05346137, + 0.043184172, -0.037189785, 0.10420091, 0.00882477, + -0.054019816, -0.074273005, -0.030617684, -0.0028467078, + 0.024302477, -0.0038869337, 0.005332455, 0.0013399826, + 0.04361412, -0.007001822, 0.09631092, -0.06702025, + -0.042049985, -0.035070654, -0.04103342, -0.10273396, + 0.0544271, 0.037184782, -0.13150354, -0.0058036847, + -0.008264958, 0.042035464, 0.05891794, 0.029673764, + 0.0063542654, 0.044788733, 0.054816857, 0.062257513, + -0.00093483756, 0.048938446, -0.004952862, -0.007730018, + -0.04043371, -0.017094059, 0.07229206, -0.023670016, + -0.052195564, -0.025616996, -0.01520939, 0.045104615, + -0.007376126, 0.003533447, 0.006570588, 0.056037236, + 0.12436656, 0.051817212, 0.028532185, -0.08686856, + 0.11868599, 0.07663395, -0.07323171, 0.03463402, + -0.050708205, -0.04458982, -0.11590894, 0.021273347, + 0.1251325, -0.15313013, -0.12224372, 0.17228661, + 0.023029093, 0.086124025, 0.006445803, -0.03496501, + 0.028332196, 0.04449512, -0.042436164, -0.026587414, + -0.006041347, -0.09292539, -0.05678812, 0.03897832, + 0.09465633, 0.008115513, -0.02171956, 0.08304309, + 0.071401566, 0.019622514, 0.032163795, -0.004167056, + 0.02295182, 0.030739572, 0.056506045, 0.004612461, + 0.06524936, 0.059999723, 0.046395954, -0.0045512207, + -0.1335546, -0.030136576, 0.11584653, -0.014678886, + 0.0020118146, -0.09688814, -0.0790206, 0.039770417, + -0.0329582, 0.07922767, 0.029322514, 0.026405897, + 0.04207835, -0.07073373, 0.063781224, 0.0859677, + -0.10925287, -0.07011058, 0.048005477, 0.03438226, + -0.09606514, -0.006669445, -0.043381985, 0.04240257, + -0.06955775, -0.06769346, 0.043903265, -0.026784198, + -0.017840602, 0.024307009, -0.040079936, -0.019946516, + 0.045318738, -0.12233574, 0.026170589, 0.0074471775, + 0.15978073, 0.10185836, 0.10298046, -0.015476589, + -0.039390966, -0.072174534, 0.0739445, -0.1211869, + -0.0347889, -0.07943156, 0.014809798, -0.12412325, + -0.0030663363, 0.039695457, 0.0647603, -0.08291318, + -0.018529687, -0.004423833, 0.0037507233, 0.084633216, + -0.01514876, -0.056505352, -0.012800942, -0.06994386, + 0.012962922, -0.031234352, 0.07029052, 0.016418684, + 0.03618972, 0.055686004, -0.08663945, -0.017404709, + -0.054761406, 0.029065743, 0.052404847, 0.020238016, + 0.0048197987, -0.0214882, 0.07078733, 0.013016777, + 0.06262858, 0.009184685, 0.020785125, -0.043904778, + -0.0270329, -0.03299152, -0.060088247, -0.015162964, + -0.001828936, 0.12642565, -0.056757294, 0.013586685, + 0.09232601, -0.035886683, 0.06000002, 0.05229691, + -0.052580316, -0.082029596, -0.010794592, 0.012947712, + -0.036429964, -0.085508935, -0.13127148, -0.017744139, + 0.031502828, 0.036232427, -0.031581745, 0.023051167, + -0.05325106, -0.03421577, 0.028793324, -0.034633752, + -0.009881397, -0.043551125, -0.018609839, 0.0019097115, + -0.008799762, 0.056595087, 0.0022273948, 0.055752404}; + + recurrent_to_forget_weights_ = { + -0.057784554, -0.026057621, -0.068447545, -0.022581743, + 0.14811787, 0.10826372, 0.09471067, 0.03987225, + -0.0039523416, 0.00030638507, 0.053185795, 0.10572994, + 0.08414449, -0.022036452, -0.00066928595, -0.09203576, + 0.032950465, -0.10985798, -0.023809856, 0.0021431844, + -0.02196096, -0.00326074, 0.00058621005, -0.074678116, + -0.06193199, 0.055729095, 0.03736828, 0.020123724, + 0.061878487, -0.04729229, 0.034919553, -0.07585433, + -0.04421272, -0.044019096, 0.085488975, 0.04058006, + -0.06890133, -0.030951202, -0.024628663, -0.07672815, + 0.034293607, 0.08556707, -0.05293577, -0.033561368, + -0.04899627, 0.0241671, 0.015736353, -0.095442444, + -0.029564252, 0.016493602, -0.035026584, 0.022337519, + -0.026871363, 0.004780428, 0.0077918363, -0.03601621, + 0.016435321, -0.03263031, -0.09543275, -0.047392778, + 0.013454138, 0.028934088, 0.01685226, -0.086110644, + -0.046250615, -0.01847454, 0.047608484, 0.07339695, + 0.034546845, -0.04881143, 0.009128804, -0.08802852, + 0.03761666, 0.008096139, -0.014454086, 0.014361001, + -0.023502491, -0.0011840804, -0.07607001, 0.001856849, + -0.06509276, -0.006021153, -0.08570962, -0.1451793, + 0.060212336, 0.055259194, 0.06974018, 0.049454916, + -0.027794661, -0.08077226, -0.016179763, 0.1169753, + 0.17213494, -0.0056326236, -0.053934924, -0.0124349, + -0.11520337, 0.05409887, 0.088759385, 0.0019655675, + 0.0042065294, 0.03881498, 0.019844765, 0.041858196, + -0.05695512, 0.047233116, 0.038937137, -0.06542224, + 0.014429736, -0.09719407, 0.13908425, -0.05379757, + 0.012321099, 0.082840554, -0.029899208, 0.044217527, + 0.059855383, 0.07711018, -0.045319796, 0.0948846, + -0.011724666, -0.0033288454, -0.033542685, -0.04764985, + -0.13873616, 0.040668588, 0.034832682, -0.015319203, + -0.018715994, 0.046002675, 0.0599172, -0.043107376, + 0.0294216, -0.002314414, -0.022424703, 0.0030315618, + 0.0014641669, 0.0029166266, -0.11878115, 0.013738511, + 0.12375372, -0.0006038222, 0.029104086, 0.087442465, + 0.052958444, 0.07558703, 0.04817258, 0.044462286, + -0.015213451, -0.08783778, -0.0561384, -0.003008196, + 0.047060397, -0.002058388, 0.03429439, -0.018839769, + 0.024734668, 0.024614193, -0.042046934, 0.09597743, + -0.0043254104, 0.04320769, 0.0064070094, -0.0019131786, + -0.02558259, -0.022822596, -0.023273505, -0.02464396, + -0.10991725, -0.006240552, 0.0074488563, 0.024044557, + 0.04383914, -0.046476185, 0.028658995, 0.060410924, + 0.050786525, 0.009452605, -0.0073054377, -0.024810238, + 0.0052906186, 0.0066939713, -0.0020913032, 0.014515517, + 0.015898481, 0.021362653, -0.030262267, 0.016587038, + -0.011442813, 0.041154444, -0.007631438, -0.03423484, + -0.010977775, 0.036152758, 0.0066366293, 0.11915515, + 0.02318443, -0.041350313, 0.021485701, -0.10906167, + -0.028218046, -0.00954771, 0.020531068, -0.11995105, + -0.03672871, 0.024019798, 0.014255957, -0.05221243, + -0.00661567, -0.04630967, 0.033188973, 0.10107534, + -0.014027541, 0.030796422, -0.10270911, -0.035999842, + 0.15443139, 0.07684145, 0.036571592, -0.035900835, + -0.0034699554, 0.06209149, 0.015920248, -0.031122351, + -0.03858649, 0.01849943, 0.13872518, 0.01503974, + 0.069941424, -0.06948533, -0.0088794185, 0.061282158, + -0.047401894, 0.03100163, -0.041533746, -0.10430945, + 0.044574402, -0.01425562, -0.024290353, 0.034563623, + 0.05866852, 0.023947537, -0.09445152, 0.035450947, + 0.02247216, -0.0042998926, 0.061146557, -0.10250651, + 0.020881841, -0.06747029, 0.10062043, -0.0023941975, + 0.03532124, -0.016341697, 0.09685456, -0.016764693, + 0.051808182, 0.05875331, -0.04536488, 0.001626336, + -0.028892258, -0.01048663, -0.009793449, -0.017093895, + 0.010987891, 0.02357273, -0.00010856845, 0.0099760275, + -0.001845119, -0.03551521, 0.0018358806, 0.05763657, + -0.01769146, 0.040995963, 0.02235177, -0.060430344, + 0.11475477, -0.023854522, 0.10071741, 0.0686208, + -0.014250481, 0.034261297, 0.047418304, 0.08562733, + -0.030519066, 0.0060542435, 0.014653856, -0.038836084, + 0.04096551, 0.032249358, -0.08355519, -0.026823482, + 0.056386515, -0.010401743, -0.028396193, 0.08507674, + 0.014410365, 0.020995233, 0.17040324, 0.11511526, + 0.02459721, 0.0066619175, 0.025853224, -0.023133837, + -0.081302024, 0.017264642, -0.009585969, 0.09491168, + -0.051313367, 0.054532815, -0.014298593, 0.10657464, + 0.007076659, 0.10964551, 0.0409152, 0.008275321, + -0.07283536, 0.07937492, 0.04192024, -0.1075027}; + + recurrent_to_output_weights_ = { + 0.025825322, -0.05813119, 0.09495884, -0.045984812, + -0.01255415, -0.0026479573, -0.08196161, -0.054914974, + -0.0046604523, -0.029587349, -0.044576716, -0.07480124, + -0.082868785, 0.023254942, 0.027502948, -0.0039728214, + -0.08683098, -0.08116779, -0.014675607, -0.037924774, + -0.023314456, -0.007401714, -0.09255757, 0.029460307, + -0.08829125, -0.005139627, -0.08989442, -0.0555066, + 0.13596267, -0.025062224, -0.048351806, -0.03850004, + 0.07266485, -0.022414139, 0.05940088, 0.075114764, + 0.09597592, -0.010211725, -0.0049794707, -0.011523867, + -0.025980417, 0.072999895, 0.11091378, -0.081685916, + 0.014416728, 0.043229222, 0.034178585, -0.07530371, + 0.035837382, -0.085607, -0.007721233, -0.03287832, + -0.043848954, -0.06404588, -0.06632928, -0.073643476, + 0.008214239, -0.045984086, 0.039764922, 0.03474462, + 0.060612556, -0.080590084, 0.049127717, 0.04151091, + -0.030063879, 0.008801774, -0.023021035, -0.019558564, + 0.05158114, -0.010947698, -0.011825728, 0.0075720972, + 0.0699727, -0.0039981045, 0.069350146, 0.08799282, + 0.016156472, 0.035502106, 0.11695009, 0.006217345, + 0.13392477, -0.037875112, 0.025745004, 0.08940699, + -0.00924166, 0.0046702605, -0.036598757, -0.08811812, + 0.10522024, -0.032441203, 0.008176899, -0.04454919, + 0.07058152, 0.0067963637, 0.039206743, 0.03259838, + 0.03725492, -0.09515802, 0.013326398, -0.052055415, + -0.025676316, 0.03198509, -0.015951829, -0.058556724, + 0.036879618, 0.043357447, 0.028362012, -0.05908629, + 0.0059240665, -0.04995891, -0.019187413, 0.0276265, + -0.01628143, 0.0025863599, 0.08800015, 0.035250366, + -0.022165963, -0.07328642, -0.009415526, -0.07455109, + 0.11690406, 0.0363299, 0.07411125, 0.042103454, + -0.009660886, 0.019076364, 0.018299393, -0.046004917, + 0.08891175, 0.0431396, -0.026327137, -0.051502608, + 0.08979574, -0.051670972, 0.04940282, -0.07491107, + -0.021240504, 0.022596184, -0.034280192, 0.060163025, + -0.058211457, -0.051837247, -0.01349775, -0.04639988, + -0.035936575, -0.011681591, 0.064818054, 0.0073146066, + -0.021745546, -0.043124277, -0.06471268, -0.07053354, + -0.029321948, -0.05330136, 0.016933719, -0.053782392, + 0.13747959, -0.1361751, -0.11569455, 0.0033329215, + 0.05693899, -0.053219706, 0.063698, 0.07977434, + -0.07924483, 0.06936997, 0.0034815092, -0.007305279, + -0.037325785, -0.07251102, -0.033633437, -0.08677009, + 0.091591336, -0.14165086, 0.021752775, 0.019683983, + 0.0011612234, -0.058154266, 0.049996935, 0.0288841, + -0.0024567875, -0.14345716, 0.010955264, -0.10234828, + 0.1183656, -0.0010731248, -0.023590032, -0.072285876, + -0.0724771, -0.026382286, -0.0014920527, 0.042667855, + 0.0018776858, 0.02986552, 0.009814309, 0.0733756, + 0.12289186, 0.018043943, -0.0458958, 0.049412545, + 0.033632483, 0.05495232, 0.036686596, -0.013781798, + -0.010036754, 0.02576849, -0.08307328, 0.010112348, + 0.042521734, -0.05869831, -0.071689695, 0.03876447, + -0.13275425, -0.0352966, -0.023077697, 0.10285965, + 0.084736146, 0.15568255, -0.00040734606, 0.027835453, + -0.10292561, -0.032401145, 0.10053256, -0.026142767, + -0.08271222, -0.0030240538, -0.016368777, 0.1070414, + 0.042672627, 0.013456989, -0.0437609, -0.022309763, + 0.11576483, 0.04108048, 0.061026827, -0.0190714, + -0.0869359, 0.037901703, 0.0610107, 0.07202949, + 0.01675338, 0.086139716, -0.08795751, -0.014898893, + -0.023771819, -0.01965048, 0.007955471, -0.043740474, + 0.03346837, -0.10549954, 0.090567775, 0.042013682, + -0.03176985, 0.12569028, -0.02421228, -0.029526481, + 0.023851605, 0.031539805, 0.05292009, -0.02344001, + -0.07811758, -0.08834428, 0.10094801, 0.16594367, + -0.06861939, -0.021256343, -0.041093912, -0.06669611, + 0.035498552, 0.021757556, -0.09302526, -0.015403468, + -0.06614931, -0.051798206, -0.013874718, 0.03630673, + 0.010412845, -0.08077351, 0.046185967, 0.0035662893, + 0.03541868, -0.094149634, -0.034814864, 0.003128424, + -0.020674974, -0.03944324, -0.008110165, -0.11113267, + 0.08484226, 0.043586485, 0.040582247, 0.0968012, + -0.065249965, -0.028036479, 0.0050708856, 0.0017462453, + 0.0326779, 0.041296225, 0.09164146, -0.047743853, + -0.015952192, -0.034451712, 0.084197424, -0.05347844, + -0.11768019, 0.085926116, -0.08251791, -0.045081906, + 0.0948852, 0.068401024, 0.024856757, 0.06978981, + -0.057309967, -0.012775832, -0.0032452994, 0.01977615, + -0.041040014, -0.024264973, 0.063464895, 0.05431621, + }; + + cell_to_input_weights_ = { + 0.040369894, 0.030746894, 0.24704495, 0.018586371, -0.037586458, + -0.15312155, -0.11812848, -0.11465643, 0.20259799, 0.11418174, + -0.10116027, -0.011334949, 0.12411352, -0.076769054, -0.052169047, + 0.21198851, -0.38871562, -0.09061183, -0.09683246, -0.21929175}; + + cell_to_forget_weights_ = { + -0.01998659, -0.15568835, -0.24248174, -0.012770197, 0.041331276, + -0.072311886, -0.052123554, -0.0066330447, -0.043891653, 0.036225766, + -0.047248036, 0.021479502, 0.033189066, 0.11952997, -0.020432774, + 0.64658105, -0.06650122, -0.03467612, 0.095340036, 0.23647355}; + + cell_to_output_weights_ = { + 0.08286371, -0.08261836, -0.51210177, 0.002913762, 0.17764764, + -0.5495371, -0.08460716, -0.24552552, 0.030037103, 0.04123544, + -0.11940523, 0.007358328, 0.1890978, 0.4833202, -0.34441817, + 0.36312827, -0.26375428, 0.1457655, -0.19724406, 0.15548733}; + + projection_weights_ = { + -0.009802181, 0.09401916, 0.0717386, -0.13895074, + 0.09641832, 0.060420845, 0.08539281, 0.054285463, + 0.061395317, 0.034448683, -0.042991187, 0.019801661, + -0.16840284, -0.015726732, -0.23041931, -0.024478018, + -0.10959692, -0.013875541, 0.18600968, -0.061274476, + 0.0138165, -0.08160894, -0.07661644, 0.032372914, + 0.16169067, 0.22465782, -0.03993472, -0.004017731, + 0.08633481, -0.28869787, 0.08682067, 0.17240396, + 0.014975425, 0.056431185, 0.031037588, 0.16702051, + 0.0077946745, 0.15140012, 0.29405436, 0.120285, + -0.188994, -0.027265169, 0.043389652, -0.022061434, + 0.014777949, -0.20203483, 0.094781205, 0.19100232, + 0.13987629, -0.036132768, -0.06426278, -0.05108664, + 0.13221376, 0.009441198, -0.16715929, 0.15859416, + -0.040437475, 0.050779544, -0.022187516, 0.012166504, + 0.027685808, -0.07675938, -0.0055694645, -0.09444123, + 0.0046453946, 0.050794356, 0.10770313, -0.20790008, + -0.07149004, -0.11425117, 0.008225835, -0.035802525, + 0.14374903, 0.15262283, 0.048710253, 0.1847461, + -0.007487823, 0.11000021, -0.09542012, 0.22619456, + -0.029149994, 0.08527916, 0.009043713, 0.0042746216, + 0.016261552, 0.022461696, 0.12689082, -0.043589946, + -0.12035478, -0.08361797, -0.050666027, -0.1248618, + -0.1275799, -0.071875185, 0.07377272, 0.09944291, + -0.18897448, -0.1593054, -0.06526116, -0.040107165, + -0.004618631, -0.067624845, -0.007576253, 0.10727444, + 0.041546922, -0.20424393, 0.06907816, 0.050412357, + 0.00724631, 0.039827548, 0.12449835, 0.10747581, + 0.13708383, 0.09134148, -0.12617786, -0.06428341, + 0.09956831, 0.1208086, -0.14676677, -0.0727722, + 0.1126304, 0.010139365, 0.015571211, -0.038128063, + 0.022913318, -0.042050496, 0.16842307, -0.060597885, + 0.10531834, -0.06411776, -0.07451711, -0.03410368, + -0.13393489, 0.06534304, 0.003620307, 0.04490757, + 0.05970546, 0.05197996, 0.02839995, 0.10434969, + -0.013699693, -0.028353551, -0.07260381, 0.047201227, + -0.024575593, -0.036445823, 0.07155557, 0.009672501, + -0.02328883, 0.009533515, -0.03606021, -0.07421458, + -0.028082801, -0.2678904, -0.13221288, 0.18419984, + -0.13012612, -0.014588381, -0.035059117, -0.04824723, + 0.07830115, -0.056184657, 0.03277091, 0.025466874, + 0.14494097, -0.12522776, -0.098633975, -0.10766018, + -0.08317623, 0.08594209, 0.07749552, 0.039474737, + 0.1776665, -0.07409566, -0.0477268, 0.29323658, + 0.10801441, 0.1154011, 0.013952499, 0.10739139, + 0.10708251, -0.051456142, 0.0074137426, -0.10430189, + 0.10034707, 0.045594677, 0.0635285, -0.0715442, + -0.089667566, -0.10811871, 0.00026344223, 0.08298446, + -0.009525053, 0.006585689, -0.24567553, -0.09450807, + 0.09648481, 0.026996298, -0.06419476, -0.04752702, + -0.11063944, -0.23441927, -0.17608605, -0.052156363, + 0.067035615, 0.19271925, -0.0032889997, -0.043264326, + 0.09663576, -0.057112187, -0.10100678, 0.0628376, + 0.04447668, 0.017961001, -0.10094388, -0.10190601, + 0.18335468, 0.10494553, -0.052095775, -0.0026118709, + 0.10539724, -0.04383912, -0.042349473, 0.08438151, + -0.1947263, 0.02251204, 0.11216432, -0.10307853, + 0.17351969, -0.039091777, 0.08066188, -0.00561982, + 0.12633002, 0.11335965, -0.0088127935, -0.019777594, + 0.06864014, -0.059751723, 0.016233567, -0.06894641, + -0.28651384, -0.004228674, 0.019708522, -0.16305895, + -0.07468996, -0.0855457, 0.099339016, -0.07580735, + -0.13775392, 0.08434318, 0.08330512, -0.12131499, + 0.031935584, 0.09180414, -0.08876437, -0.08049874, + 0.008753825, 0.03498998, 0.030215185, 0.03907079, + 0.089751154, 0.029194152, -0.03337423, -0.019092513, + 0.04331237, 0.04299654, -0.036394123, -0.12915532, + 0.09793732, 0.07512415, -0.11319543, -0.032502122, + 0.15661901, 0.07671967, -0.005491124, -0.19379048, + -0.218606, 0.21448623, 0.017840758, 0.1416943, + -0.07051762, 0.19488361, 0.02664691, -0.18104725, + -0.09334311, 0.15026465, -0.15493552, -0.057762887, + -0.11604192, -0.262013, -0.01391798, 0.012185008, + 0.11156489, -0.07483202, 0.06693364, -0.26151478, + 0.046425626, 0.036540434, -0.16435726, 0.17338543, + -0.21401681, -0.11385144, -0.08283257, -0.069031075, + 0.030635102, 0.010969227, 0.11109743, 0.010919218, + 0.027526086, 0.13519906, 0.01891392, -0.046839405, + -0.040167913, 0.017953383, -0.09700955, 0.0061885654, + -0.07000971, 0.026893595, -0.038844477, 0.14543656}; + + lstm_input_ = { + {// Batch0: 4 (input_sequence_size) * 5 (n_input) + 0.787926, 0.151646, 0.071352, 0.118426, 0.458058, // step 0 + 0.596268, 0.998386, 0.568695, 0.864524, 0.571277, // step 1 + 0.073204, 0.296072, 0.743333, 0.069199, 0.045348, // step 2 + 0.867394, 0.291279, 0.013714, 0.482521, 0.626339}, // step 3 + + {// Batch1: 4 (input_sequence_size) * 5 (n_input) + 0.295743, 0.544053, 0.690064, 0.858138, 0.497181, // step 0 + 0.642421, 0.524260, 0.134799, 0.003639, 0.162482, // step 1 + 0.640394, 0.930399, 0.050782, 0.432485, 0.988078, // step 2 + 0.082922, 0.563329, 0.865614, 0.333232, 0.259916} // step 3 + }; + + lstm_golden_output_ = { + {// Batch0: 4 (input_sequence_size) * 16 (n_output) + -0.00396806, 0.029352, -0.00279226, 0.0159977, -0.00835576, + -0.0211779, 0.0283512, -0.0114597, 0.00907307, -0.0244004, + -0.0152191, -0.0259063, 0.00914318, 0.00415118, 0.017147, + 0.0134203, -0.0166936, 0.0381209, 0.000889694, 0.0143363, + -0.0328911, -0.0234288, 0.0333051, -0.012229, 0.0110322, + -0.0457725, -0.000832209, -0.0202817, 0.0327257, 0.0121308, + 0.0155969, 0.0312091, -0.0213783, 0.0350169, 0.000324794, + 0.0276012, -0.0263374, -0.0371449, 0.0446149, -0.0205474, + 0.0103729, -0.0576349, -0.0150052, -0.0292043, 0.0376827, + 0.0136115, 0.0243435, 0.0354492, -0.0189322, 0.0464512, + -0.00251373, 0.0225745, -0.0308346, -0.0317124, 0.0460407, + -0.0189395, 0.0149363, -0.0530162, -0.0150767, -0.0340193, + 0.0286833, 0.00824207, 0.0264887, 0.0305169}, + {// Batch1: 4 (input_sequence_size) * 16 (n_output) + -0.013869, 0.0287268, -0.00334693, 0.00733398, -0.0287926, + -0.0186926, 0.0193662, -0.0115437, 0.00422612, -0.0345232, + 0.00223253, -0.00957321, 0.0210624, 0.013331, 0.0150954, + 0.02168, -0.0141913, 0.0322082, 0.00227024, 0.0260507, + -0.0188721, -0.0296489, 0.0399134, -0.0160509, 0.0116039, + -0.0447318, -0.0150515, -0.0277406, 0.0316596, 0.0118233, + 0.0214762, 0.0293641, -0.0204549, 0.0450315, -0.00117378, + 0.0167673, -0.0375007, -0.0238314, 0.038784, -0.0174034, + 0.0131743, -0.0506589, -0.0048447, -0.0240239, 0.0325789, + 0.00790065, 0.0220157, 0.0333314, -0.0264787, 0.0387855, + -0.000764675, 0.0217599, -0.037537, -0.0335206, 0.0431679, + -0.0211424, 0.010203, -0.062785, -0.00832363, -0.025181, + 0.0412031, 0.0118723, 0.0239643, 0.0394009}}; + } +}; + +TEST_F(NoCifgPeepholeProjectionClippingLstmTest, LstmBlackBoxTest) { + const int n_batch = 2; + const int n_input = 5; + const int n_cell = 20; + const int n_output = 16; + + LSTMOpModel lstm(n_batch, n_input, n_cell, n_output, + /*use_cifg=*/false, /*use_peephole=*/true, + /*use_projection_weights=*/true, + /*use_projection_bias=*/false, + /*cell_clip=*/0.0, /*proj_clip=*/0.0, + { + {n_batch, n_input}, // input tensor + + {n_cell, n_input}, // input_to_input_weight tensor + {n_cell, n_input}, // input_to_forget_weight tensor + {n_cell, n_input}, // input_to_cell_weight tensor + {n_cell, n_input}, // input_to_output_weight tensor + + {n_cell, n_output}, // recurrent_to_input_weight tensor + {n_cell, n_output}, // recurrent_to_forget_weight tensor + {n_cell, n_output}, // recurrent_to_cell_weight tensor + {n_cell, n_output}, // recurrent_to_output_weight tensor + + {n_cell}, // cell_to_input_weight tensor + {n_cell}, // cell_to_forget_weight tensor + {n_cell}, // cell_to_output_weight tensor + + {n_cell}, // input_gate_bias tensor + {n_cell}, // forget_gate_bias tensor + {n_cell}, // cell_bias tensor + {n_cell}, // output_gate_bias tensor + + {n_output, n_cell}, // projection_weight tensor + {0}, // projection_bias tensor + }); + + lstm.SetInputToInputWeights(input_to_input_weights_); + lstm.SetInputToCellWeights(input_to_cell_weights_); + lstm.SetInputToForgetWeights(input_to_forget_weights_); + lstm.SetInputToOutputWeights(input_to_output_weights_); + + lstm.SetInputGateBias(input_gate_bias_); + lstm.SetCellBias(cell_gate_bias_); + lstm.SetForgetGateBias(forget_gate_bias_); + lstm.SetOutputGateBias(output_gate_bias_); + + lstm.SetRecurrentToInputWeights(recurrent_to_input_weights_); + lstm.SetRecurrentToCellWeights(recurrent_to_cell_weights_); + lstm.SetRecurrentToForgetWeights(recurrent_to_forget_weights_); + lstm.SetRecurrentToOutputWeights(recurrent_to_output_weights_); + + lstm.SetCellToInputWeights(cell_to_input_weights_); + lstm.SetCellToForgetWeights(cell_to_forget_weights_); + lstm.SetCellToOutputWeights(cell_to_output_weights_); + + lstm.SetProjectionWeights(projection_weights_); + + // Resetting cell_state and output_state + lstm.ResetCellState(); + lstm.ResetOutputState(); + + VerifyGoldens(lstm_input_, lstm_golden_output_, &lstm); +} + +class BaseReduceOpModel : public SingleOpModelWithNNAPI { + public: + void SetAxis(const std::vector& data) { PopulateTensor(axis_, data); } + + template + void SetInput(std::vector data) { + PopulateTensor(input_, data); + } + + template + std::vector GetOutput() { + return ExtractVector(output_); + } + + std::vector GetDequantizedOutput() { + return Dequantize(ExtractVector(output_), + GetScale(output_), GetZeroPoint(output_)); + } + + std::vector GetOutputShape() { return GetTensorShape(output_); } + + int Input() { return input_; } + + protected: + int input_; + int axis_; + int output_; +}; + +// Model for the tests case where axis is a const tensor. +class MeanOpConstModel : public BaseReduceOpModel { + public: + MeanOpConstModel(const TensorData& input, const TensorData& output, + std::initializer_list axis_shape, + std::initializer_list axis, bool keep_dims) { + input_ = AddInput(input); + axis_ = AddConstInput(TensorType_INT32, axis, axis_shape); + output_ = AddOutput(output); + SetBuiltinOp(BuiltinOperator_MEAN, BuiltinOptions_ReducerOptions, + CreateReducerOptions(builder_, keep_dims).Union()); + BuildInterpreter({GetShape(input_)}); + } +}; + +// Tests for reduce_mean +TEST(NNAPIDelegate, MeanFloatNotKeepDims) { + std::vector data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, + 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, + 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0}; + MeanOpConstModel m({TensorType_FLOAT32, {4, 3, 2}}, {TensorType_FLOAT32, {2}}, + {4}, {1, 0, -3, -3}, false); + m.SetInput(data); + m.Invoke(); + EXPECT_THAT(m.GetOutputShape(), ElementsAreArray({2})); + EXPECT_THAT(m.GetOutput(), ElementsAreArray(ArrayFloatNear({12, 13}))); +} + +TEST(NNAPIDelegate, MeanFloatKeepDims) { + std::vector data = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, + 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, + 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0}; + MeanOpConstModel m({TensorType_FLOAT32, {4, 3, 2}}, {TensorType_FLOAT32, {3}}, + {2}, {0, 2}, true); + m.SetInput(data); + m.Invoke(); + EXPECT_THAT(m.GetOutputShape(), ElementsAreArray({1, 3, 1})); + EXPECT_THAT(m.GetOutput(), + ElementsAreArray(ArrayFloatNear({10.5, 12.5, 14.5}))); +} + +class BaseEmbeddingLookupOpModel : public SingleOpModelWithNNAPI { + public: + BaseEmbeddingLookupOpModel(std::initializer_list index_shape, + std::initializer_list weight_shape, + TensorType weight_type = TensorType_FLOAT32) { + input_ = AddInput(TensorType_INT32); + weight_ = AddInput(weight_type); + output_ = AddOutput(TensorType_FLOAT32); + SetBuiltinOp(BuiltinOperator_EMBEDDING_LOOKUP, BuiltinOptions_NONE, 0); + BuildInterpreter({index_shape, weight_shape}); + } + + void SetInput(std::initializer_list data) { + PopulateTensor(input_, data); + } + + std::vector GetOutput() { return ExtractVector(output_); } + + protected: + int input_; + int weight_; + int output_; +}; + +class EmbeddingLookupOpModel : public BaseEmbeddingLookupOpModel { + public: + using BaseEmbeddingLookupOpModel::BaseEmbeddingLookupOpModel; + + void Set3DWeightMatrix(const std::function& function) { + TfLiteTensor* tensor = interpreter_->tensor(weight_); + int rows = tensor->dims->data[0]; + int columns = tensor->dims->data[1]; + int features = tensor->dims->data[2]; + for (int i = 0; i < rows; i++) { + for (int j = 0; j < columns; j++) { + for (int k = 0; k < features; k++) { + tensor->data.f[(i * columns + j) * features + k] = function(i, j, k); + } + } + } + } +}; + +TEST(NNAPIDelegate, EmbeddingLookupSimpleTest) { + EmbeddingLookupOpModel m({3}, {3, 2, 4}); + m.SetInput({1, 0, 2}); + m.Set3DWeightMatrix( + [](int i, int j, int k) { return i + j / 10.0f + k / 100.0f; }); + + m.Invoke(); + + EXPECT_THAT(m.GetOutput(), + ElementsAreArray(ArrayFloatNear({ + 1.00, 1.01, 1.02, 1.03, 1.10, 1.11, 1.12, 1.13, // Row 1 + 0.00, 0.01, 0.02, 0.03, 0.10, 0.11, 0.12, 0.13, // Row 0 + 2.00, 2.01, 2.02, 2.03, 2.10, 2.11, 2.12, 2.13, // Row 2 + }))); +} + +class HashtableLookupOpModel : public SingleOpModelWithNNAPI { + public: + HashtableLookupOpModel(std::initializer_list lookup_shape, + std::initializer_list key_shape, + std::initializer_list value_shape, + TensorType type) { + lookup_ = AddInput(TensorType_INT32); + key_ = AddInput(TensorType_INT32); + value_ = AddInput(type); + output_ = AddOutput(type); + hit_ = AddOutput(TensorType_UINT8); + SetBuiltinOp(BuiltinOperator_HASHTABLE_LOOKUP, BuiltinOptions_NONE, 0); + BuildInterpreter({lookup_shape, key_shape, value_shape}); + } + + void SetLookup(std::initializer_list data) { + PopulateTensor(lookup_, data); + } + + void SetHashtableKey(std::initializer_list data) { + PopulateTensor(key_, data); + } + + void SetHashtableValue(const std::vector& content) { + PopulateStringTensor(value_, content); + } + + void SetHashtableValue(const std::function& function) { + TfLiteTensor* tensor = interpreter_->tensor(value_); + int rows = tensor->dims->data[0]; + for (int i = 0; i < rows; i++) { + tensor->data.f[i] = function(i); + } + } + + void SetHashtableValue(const std::function& function) { + TfLiteTensor* tensor = interpreter_->tensor(value_); + int rows = tensor->dims->data[0]; + int features = tensor->dims->data[1]; + for (int i = 0; i < rows; i++) { + for (int j = 0; j < features; j++) { + tensor->data.f[i * features + j] = function(i, j); + } + } + } + + std::vector GetStringOutput() { + TfLiteTensor* output = interpreter_->tensor(output_); + int num = GetStringCount(output); + std::vector result(num); + for (int i = 0; i < num; i++) { + auto ref = GetString(output, i); + result[i] = string(ref.str, ref.len); + } + return result; + } + + std::vector GetOutput() { return ExtractVector(output_); } + std::vector GetHit() { return ExtractVector(hit_); } + + private: + int lookup_; + int key_; + int value_; + int output_; + int hit_; +}; + +TEST(NNAPIDelegate, HashtableLookupTest2DInput) { + HashtableLookupOpModel m({4}, {3}, {3, 2}, TensorType_FLOAT32); + + m.SetLookup({1234, -292, -11, 0}); + m.SetHashtableKey({-11, 0, 1234}); + m.SetHashtableValue([](int i, int j) { return i + j / 10.0f; }); + + m.Invoke(); + + EXPECT_THAT(m.GetOutput(), ElementsAreArray(ArrayFloatNear({ + 2.0, 2.1, // 2-nd item + 0, 0, // Not found + 0.0, 0.1, // 0-th item + 1.0, 1.1, // 1-st item + }))); + EXPECT_THAT(m.GetHit(), ElementsAreArray({ + 1, + 0, + 1, + 1, + })); +} + +TEST(NNAPIDelegate, HashtableLookupTest1DInput) { + HashtableLookupOpModel m({4}, {3}, {3}, TensorType_FLOAT32); + + m.SetLookup({1234, -292, -11, 0}); + m.SetHashtableKey({-11, 0, 1234}); + m.SetHashtableValue([](int i) { return i * i / 10.0f; }); + + m.Invoke(); + + EXPECT_THAT(m.GetOutput(), ElementsAreArray(ArrayFloatNear({ + 0.4, // 2-nd item + 0, // Not found + 0.0, // 0-th item + 0.1, // 1-st item + }))); + EXPECT_THAT(m.GetHit(), ElementsAreArray({ + 1, + 0, + 1, + 1, + })); +} } // namespace } // namespace tflite diff --git a/tensorflow/contrib/lite/nnapi_delegate.cc b/tensorflow/contrib/lite/nnapi_delegate.cc index c91f488175..13325a8c7c 100644 --- a/tensorflow/contrib/lite/nnapi_delegate.cc +++ b/tensorflow/contrib/lite/nnapi_delegate.cc @@ -568,9 +568,17 @@ TfLiteStatus AddOpsAndParams( "NNAPI does not support L2Normalization with fused activations"); } break; + case tflite::BuiltinOperator_HASHTABLE_LOOKUP: + if (interpreter->tensor(node.outputs->data[0])->type != + kTfLiteFloat32) { + logError("NNAPI only support HASHTABLE_LOOKUP with float32 output", + builtin); + return kTfLiteError; + } + nn_op_type = ANEURALNETWORKS_HASHTABLE_LOOKUP; + break; case tflite::BuiltinOperator_CONCAT_EMBEDDINGS: case tflite::BuiltinOperator_LSH_PROJECTION: - case tflite::BuiltinOperator_HASHTABLE_LOOKUP: case tflite::BuiltinOperator_BIDIRECTIONAL_SEQUENCE_RNN: case tflite::BuiltinOperator_UNIDIRECTIONAL_SEQUENCE_RNN: case tflite::BuiltinOperator_EMBEDDING_LOOKUP_SPARSE: -- GitLab From b7950bce77bf74dcf2c11fb2f4bb45f6e673f82d Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Tue, 7 Aug 2018 10:18:53 -0700 Subject: [PATCH 155/437] Fix Windows TFLite builds The Unity TFLite plugin should now run successfully on Windows, though it requires renaming `libtensorflowlite_c.so` to `tensorflowlite_c.dll` in the Plugins folder. PiperOrigin-RevId: 207736531 --- .../examples/unity/TensorFlowLitePlugin/README.md | 4 +++- .../lite/kernels/internal/reference/portable_tensor_utils.cc | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tensorflow/contrib/lite/experimental/examples/unity/TensorFlowLitePlugin/README.md b/tensorflow/contrib/lite/experimental/examples/unity/TensorFlowLitePlugin/README.md index c0dcb090b4..f480c49cd0 100644 --- a/tensorflow/contrib/lite/experimental/examples/unity/TensorFlowLitePlugin/README.md +++ b/tensorflow/contrib/lite/experimental/examples/unity/TensorFlowLitePlugin/README.md @@ -1,6 +1,6 @@ # TF Lite Experimental Unity Plugin -This directoryy contains an experimental sample Unity (2017) Plugin, based on +This directory contains an experimental sample Unity (2017) Plugin, based on the experimental TF Lite C API. The sample demonstrates running inference within Unity by way of a C# `Interpreter` wrapper. @@ -25,3 +25,5 @@ bazel build -c opt --cxxopt=--std=c++11 \ If you encounter issues with native plugin discovery on Mac ("Darwin") platforms, try renaming `libtensorflowlite_c.so` to `tensorflowlite_c.bundle`. +Similarly, on Windows you'll likely need to rename `libtensorflowlite_c.so` to +`tensorflowlite_c.dll`. diff --git a/tensorflow/contrib/lite/kernels/internal/reference/portable_tensor_utils.cc b/tensorflow/contrib/lite/kernels/internal/reference/portable_tensor_utils.cc index e6ccd7a32c..a5f4addd5e 100644 --- a/tensorflow/contrib/lite/kernels/internal/reference/portable_tensor_utils.cc +++ b/tensorflow/contrib/lite/kernels/internal/reference/portable_tensor_utils.cc @@ -84,9 +84,8 @@ void PortableMatrixBatchVectorMultiplyAccumulate(const float* matrix, void PortableMatrixBatchVectorMultiplyAccumulate( const int8_t* __restrict__ matrix, const int m_rows, const int m_cols, - const int8_t* __restrict__ vectors, - const float* __restrict__ scaling_factors, int n_batch, - float* __restrict__ result, int result_stride) { + const int8_t* __restrict__ vectors, const float* scaling_factors, + int n_batch, float* __restrict__ result, int result_stride) { int batch, row, col; for (batch = 0; batch < n_batch; ++batch, vectors += m_cols) { const float batch_scaling_factor = scaling_factors[batch]; -- GitLab From b8886649c75ae864f2532bca044e2f44fb138c95 Mon Sep 17 00:00:00 2001 From: Derek Murray Date: Tue, 7 Aug 2018 10:26:06 -0700 Subject: [PATCH 156/437] [tf.data] Add feature statistics collection hooks to the tf.Example parsers. PiperOrigin-RevId: 207737913 --- .../core/util/example_proto_fast_parsing.cc | 89 ++++++++++++++++++- .../core/util/example_proto_fast_parsing.h | 24 +++++ .../util/example_proto_fast_parsing_test.cc | 80 ++++++++++++++++- 3 files changed, 187 insertions(+), 6 deletions(-) diff --git a/tensorflow/core/util/example_proto_fast_parsing.cc b/tensorflow/core/util/example_proto_fast_parsing.cc index 418e97ac24..1fec0010a1 100644 --- a/tensorflow/core/util/example_proto_fast_parsing.cc +++ b/tensorflow/core/util/example_proto_fast_parsing.cc @@ -495,7 +495,8 @@ Status FastParseSerializedExample( const PresizedCuckooMap>& config_index, SeededHasher hasher, std::vector* output_dense, std::vector* output_varlen_dense, - std::vector* output_sparse) { + std::vector* output_sparse, + PerExampleFeatureStats* output_stats) { DCHECK(output_dense != nullptr); DCHECK(output_sparse != nullptr); parsed::Example parsed_example; @@ -508,6 +509,14 @@ Status FastParseSerializedExample( // Handle features present in the example. const size_t parsed_example_size = parsed_example.size(); + + if (output_stats) { + // TODO(b/111553342): This may over-count the number of features if there + // are duplicate keys in the feature map. Consider deduplicating the keys + // before computing the count. + output_stats->features_count = parsed_example_size; + } + for (size_t i = 0; i < parsed_example_size; ++i) { // This is a logic that standard protobuf parsing is implementing. // I.e. last entry in the map overwrites all the previous ones. @@ -567,6 +576,13 @@ Status FastParseSerializedExample( Tensor& out = (*output_dense)[d]; const std::size_t num_elements = config.dense[d].elements_per_stride; + if (output_stats) { + // TODO(b/111553342): If desirable, we could add support for counting + // elements in the features that aren't parsed, but this could add + // considerable runtime cost. + output_stats->feature_values_count += num_elements; + } + const std::size_t offset = example_index * num_elements; auto shape_error = [&](size_t size, StringPiece type_str) { @@ -669,6 +685,23 @@ Status FastParseSerializedExample( default: LOG(FATAL) << "Should not happen."; } + + if (output_stats) { + // Use `out.example_end_indices` to determine the feature-value count + // for this feature, because the preceding switch statement pushes + // the length of the appropriate feature list to that vector. + // TODO(b/111553342): If desirable, we could add support for counting + // elements in the features that aren't parsed, but this could add + // considerable runtime cost. + const size_t out_examples_count = out.example_end_indices.size(); + if (out_examples_count == 1) { + output_stats->feature_values_count += out.example_end_indices[0]; + } else { + output_stats->feature_values_count += + out.example_end_indices[out_examples_count - 1] - + out.example_end_indices[out_examples_count - 2]; + } + } } } else { // If feature was already visited, skip. @@ -720,6 +753,23 @@ Status FastParseSerializedExample( default: LOG(FATAL) << "Should not happen."; } + + if (output_stats) { + // Use `out.example_end_indices` to determine the feature-value count + // for this feature, because the preceding switch statement pushes + // the length of the appropriate feature list to that vector. + // TODO(b/111553342): If desirable, we could add support for counting + // elements in the features that aren't parsed, but this could add + // considerable runtime cost. + const size_t out_examples_count = out.example_end_indices.size(); + if (out_examples_count == 1) { + output_stats->feature_values_count += out.example_end_indices[0]; + } else { + output_stats->feature_values_count += + out.example_end_indices[out_examples_count - 1] - + out.example_end_indices[out_examples_count - 2]; + } + } } } @@ -877,6 +927,10 @@ Status FastParseExample(const Config& config, TF_RETURN_IF_ERROR(CheckConfigDataType(c.dtype)); } + if (config.collect_feature_stats) { + result->feature_stats.resize(serialized.size()); + } + size_t config_size = config.dense.size() + config.sparse.size(); SeededHasher hasher; // Build config index. @@ -962,11 +1016,15 @@ Status FastParseExample(const Config& config, size_t start = first_example_of_minibatch(minibatch); size_t end = first_example_of_minibatch(minibatch + 1); for (size_t e = start; e < end; ++e) { + PerExampleFeatureStats* stats = nullptr; + if (config.collect_feature_stats) { + stats = &result->feature_stats[e]; + } status_of_minibatch[minibatch] = FastParseSerializedExample( serialized[e], (!example_names.empty() ? example_names[e] : ""), e, config, config_index, hasher, &fixed_dense_values, - &varlen_dense_buffers[minibatch], &sparse_buffers[minibatch]); + &varlen_dense_buffers[minibatch], &sparse_buffers[minibatch], stats); if (!status_of_minibatch[minibatch].ok()) break; } }; @@ -1079,7 +1137,7 @@ Status FastParseExample(const Config& config, const size_t stride_size = config.dense[d].elements_per_stride; const size_t max_num_elements = max_num_features / stride_size; TensorShape values_shape; - DCHECK(max_num_features % config.dense[d].elements_per_stride == 0); + DCHECK_EQ(max_num_features % config.dense[d].elements_per_stride, 0); const size_t batch_size = serialized.size(); values_shape.AddDim(batch_size); values_shape.AddDim(max_num_elements); @@ -1138,6 +1196,12 @@ Status FastParseSingleExample(const Config& config, const string& serialized, TF_RETURN_IF_ERROR(CheckConfigDataType(c.dtype)); } + PerExampleFeatureStats* stats = nullptr; + if (config.collect_feature_stats) { + result->feature_stats.emplace_back(); + stats = &result->feature_stats.back(); + } + // TODO(mrry): Cache the construction of this map at Op construction time. size_t config_size = config.dense.size() + config.sparse.size(); SeededHasher hasher; @@ -1196,6 +1260,13 @@ Status FastParseSingleExample(const Config& config, const string& serialized, std::vector sparse_feature_already_seen(config.sparse.size(), false); std::vector dense_feature_already_seen(config.dense.size(), false); + if (stats) { + // TODO(b/111553342): This may over-count the number of features if there + // are duplicate keys in the feature map. Consider deduplicating the keys + // before computing the count. + stats->features_count = parsed_example.size(); + } + // Handle features present in the example. const size_t parsed_example_size = parsed_example.size(); for (size_t i = 0; i < parsed_example_size; ++i) { @@ -1254,7 +1325,12 @@ Status FastParseSingleExample(const Config& config, const string& serialized, Tensor* out = &result->dense_values[d]; const std::size_t num_elements = config.dense[d].elements_per_stride; - + if (stats) { + // TODO(b/111553342): If desirable, we could add support for counting + // elements in the features that aren't parsed, but this could add + // considerable runtime cost. + stats->feature_values_count += num_elements; + } switch (example_dtype) { case DT_INT64: { auto out_p = out->flat().data(); @@ -1362,6 +1438,10 @@ Status FastParseSingleExample(const Config& config, const string& serialized, return parse_error(); } + if (stats) { + stats->feature_values_count += num_elements; + } + Tensor* out; if (is_dense) { TensorShape values_shape; @@ -1636,6 +1716,7 @@ inline bool SkipEmptyFeature(protobuf::io::CodedInputStream* stream, } // TODO(sundberg): Use the threadpool to parallelize example parsing. +// TODO(b/111553342): Support extracting feature statistics from the examples. Status FastParseSequenceExample( const FastParseExampleConfig& context_config, const FastParseExampleConfig& feature_list_config, diff --git a/tensorflow/core/util/example_proto_fast_parsing.h b/tensorflow/core/util/example_proto_fast_parsing.h index 024a4518ee..db5b5ff929 100644 --- a/tensorflow/core/util/example_proto_fast_parsing.h +++ b/tensorflow/core/util/example_proto_fast_parsing.h @@ -59,6 +59,26 @@ struct FastParseExampleConfig { std::vector dense; std::vector sparse; + + // If `true`, `Result::feature_stats` will contain one + // `PerExampleFeatureStats` for each serialized example in the input. + bool collect_feature_stats = false; +}; + +// Statistics about the features in each example passed to +// `FastParse[Single]Example()`. +// +// TODO(b/111553342): The gathered statistics currently have two limitations: +// * Feature names that appear more than once will be counted multiple times. +// * The feature values count only represents the counts for features that were +// requested in the `FastParseExampleConfig`. +// These could be addressed with additional work at runtime. +struct PerExampleFeatureStats { + // The number of feature names in an example. + size_t features_count = 0; + + // The sum of the number of values in each feature that is parsed. + size_t feature_values_count = 0; }; // This is exactly the output of TF's ParseExample Op. @@ -68,6 +88,10 @@ struct Result { std::vector sparse_values; std::vector sparse_shapes; std::vector dense_values; + + // This vector will be populated with one element per example if + // `FastParseExampleConfig::collect_feature_stats` is set to `true`. + std::vector feature_stats; }; // Parses a batch of serialized Example protos and converts them into result diff --git a/tensorflow/core/util/example_proto_fast_parsing_test.cc b/tensorflow/core/util/example_proto_fast_parsing_test.cc index 1a804e154c..37faa927bf 100644 --- a/tensorflow/core/util/example_proto_fast_parsing_test.cc +++ b/tensorflow/core/util/example_proto_fast_parsing_test.cc @@ -13,6 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ +#include + #include "tensorflow/core/util/example_proto_fast_parsing.h" #include "tensorflow/core/example/example.pb.h" @@ -211,7 +213,7 @@ TEST(FastParse, SingleInt64) { TestCorrectness(Serialize(example)); } -TEST(FastParse, SomeFeatures) { +static string ExampleWithSomeFeatures() { Example example; (*example.mutable_features()->mutable_feature())[""]; @@ -242,7 +244,81 @@ TEST(FastParse, SomeFeatures) { int64_list->add_value(270); int64_list->add_value(86942); - TestCorrectness(Serialize(example)); + return Serialize(example); +} + +TEST(FastParse, SomeFeatures) { TestCorrectness(ExampleWithSomeFeatures()); } + +static void AddDenseFeature(const char* feature_name, DataType dtype, + PartialTensorShape shape, bool variable_length, + size_t elements_per_stride, + FastParseExampleConfig* out_config) { + out_config->dense.emplace_back(); + auto& new_feature = out_config->dense.back(); + new_feature.feature_name = feature_name; + new_feature.dtype = dtype; + new_feature.shape = std::move(shape); + new_feature.default_value = Tensor(dtype, {}); + new_feature.variable_length = variable_length; + new_feature.elements_per_stride = elements_per_stride; +} + +static void AddSparseFeature(const char* feature_name, DataType dtype, + FastParseExampleConfig* out_config) { + out_config->sparse.emplace_back(); + auto& new_feature = out_config->sparse.back(); + new_feature.feature_name = feature_name; + new_feature.dtype = dtype; +} + +TEST(FastParse, StatsCollection) { + const size_t kNumExamples = 13; + std::vector serialized(kNumExamples, ExampleWithSomeFeatures()); + + FastParseExampleConfig config_dense; + AddDenseFeature("bytes_list", DT_STRING, {2}, false, 2, &config_dense); + AddDenseFeature("float_list", DT_FLOAT, {2}, false, 2, &config_dense); + AddDenseFeature("int64_list", DT_INT64, {3}, false, 3, &config_dense); + config_dense.collect_feature_stats = true; + + FastParseExampleConfig config_varlen; + AddDenseFeature("bytes_list", DT_STRING, {-1}, true, 1, &config_varlen); + AddDenseFeature("float_list", DT_FLOAT, {-1}, true, 1, &config_varlen); + AddDenseFeature("int64_list", DT_INT64, {-1}, true, 1, &config_varlen); + config_varlen.collect_feature_stats = true; + + FastParseExampleConfig config_sparse; + AddSparseFeature("bytes_list", DT_STRING, &config_sparse); + AddSparseFeature("float_list", DT_FLOAT, &config_sparse); + AddSparseFeature("int64_list", DT_INT64, &config_sparse); + config_sparse.collect_feature_stats = true; + + FastParseExampleConfig config_mixed; + AddDenseFeature("bytes_list", DT_STRING, {2}, false, 2, &config_mixed); + AddDenseFeature("float_list", DT_FLOAT, {-1}, true, 1, &config_mixed); + AddSparseFeature("int64_list", DT_INT64, &config_mixed); + config_mixed.collect_feature_stats = true; + + for (const FastParseExampleConfig& config : + {config_dense, config_varlen, config_sparse, config_mixed}) { + { + Result result; + TF_CHECK_OK(FastParseExample(config, serialized, {}, nullptr, &result)); + EXPECT_EQ(kNumExamples, result.feature_stats.size()); + for (const PerExampleFeatureStats& stats : result.feature_stats) { + EXPECT_EQ(7, stats.features_count); + EXPECT_EQ(7, stats.feature_values_count); + } + } + + { + Result result; + TF_CHECK_OK(FastParseSingleExample(config, serialized[0], &result)); + EXPECT_EQ(1, result.feature_stats.size()); + EXPECT_EQ(7, result.feature_stats[0].features_count); + EXPECT_EQ(7, result.feature_stats[0].feature_values_count); + } + } } string RandStr(random::SimplePhilox* rng) { -- GitLab From ff3de98d531c23a574a3531d13c47ec3c27543e1 Mon Sep 17 00:00:00 2001 From: Katherine Wu Date: Tue, 7 Aug 2018 10:39:05 -0700 Subject: [PATCH 157/437] Fix bug causing TFOptimizer iterations variable to increment twice when gradients are applied. PiperOrigin-RevId: 207740606 --- tensorflow/python/keras/optimizers.py | 5 +++- tensorflow/python/keras/optimizers_test.py | 30 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/tensorflow/python/keras/optimizers.py b/tensorflow/python/keras/optimizers.py index 0b440185ca..4f97442e82 100644 --- a/tensorflow/python/keras/optimizers.py +++ b/tensorflow/python/keras/optimizers.py @@ -718,10 +718,13 @@ class TFOptimizer(Optimizer, checkpointable.CheckpointableBase): global_step = training_util.get_global_step() opt_update = self.optimizer.apply_gradients(grads, global_step) else: - self.updates = [state_ops.assign_add(self.iterations, 1)] if not params: + self.updates = [state_ops.assign_add(self.iterations, 1)] return self.updates + # Updates list starts out empty because the iterations variable is + # incremented in optimizer.apply_gradients() + self.updates = [] grads = self.optimizer.compute_gradients(loss, params) opt_update = self.optimizer.apply_gradients( grads, global_step=self.iterations) diff --git a/tensorflow/python/keras/optimizers_test.py b/tensorflow/python/keras/optimizers_test.py index 55fc3fdcf4..4d295351f5 100644 --- a/tensorflow/python/keras/optimizers_test.py +++ b/tensorflow/python/keras/optimizers_test.py @@ -46,7 +46,11 @@ def _test_optimizer(optimizer, target=0.75): model.compile(loss='categorical_crossentropy', optimizer=optimizer, metrics=['accuracy']) + np.testing.assert_equal(keras.backend.get_value(model.optimizer.iterations), + 0) history = model.fit(x_train, y_train, epochs=2, batch_size=16, verbose=0) + np.testing.assert_equal(keras.backend.get_value(model.optimizer.iterations), + 126) # 63 steps per epoch assert history.history['acc'][-1] >= target config = keras.optimizers.serialize(optimizer) optim = keras.optimizers.deserialize(config) @@ -66,7 +70,11 @@ def _test_optimizer(optimizer, target=0.75): model.compile(loss='categorical_crossentropy', optimizer=optimizer, metrics=['accuracy']) + np.testing.assert_equal(keras.backend.get_value(model.optimizer.iterations), + 126) # Using same optimizer from before model.train_on_batch(x_train[:10], y_train[:10]) + np.testing.assert_equal(keras.backend.get_value(model.optimizer.iterations), + 127) kernel, bias = dense.get_weights() np.testing.assert_allclose(kernel, 1., atol=1e-3) np.testing.assert_allclose(bias, 2., atol=1e-3) @@ -145,6 +153,28 @@ class KerasOptimizersTest(test.TestCase): with self.assertRaises(NotImplementedError): optimizer.from_config(None) + def test_tfoptimizer_iterations(self): + with self.test_session(): + optimizer = keras.optimizers.TFOptimizer(AdamOptimizer(0.01)) + model = keras.models.Sequential() + model.add(keras.layers.Dense( + 2, input_shape=(3,), kernel_constraint=keras.constraints.MaxNorm(1))) + model.compile(loss='mean_squared_error', optimizer=optimizer) + self.assertEqual(keras.backend.get_value(model.optimizer.iterations), 0) + + model.fit(np.random.random((55, 3)), + np.random.random((55, 2)), + epochs=1, + batch_size=5, + verbose=0) + self.assertEqual(keras.backend.get_value(model.optimizer.iterations), 11) + + model.fit(np.random.random((20, 3)), + np.random.random((20, 2)), + steps_per_epoch=8, + verbose=0) + self.assertEqual(keras.backend.get_value(model.optimizer.iterations), 19) + def test_negative_clipvalue_or_clipnorm(self): with self.assertRaises(ValueError): _ = keras.optimizers.SGD(lr=0.01, clipvalue=-0.5) -- GitLab From 14a7b8aee0ddec4e3431f7161e9b976e7157aef7 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 7 Aug 2018 10:41:13 -0700 Subject: [PATCH 158/437] Set depth_multiplier default value, so that one can use separable_conv2d and conv2d interchangeably (conv2d does not have depth_multiplier arg). For example: if use_separable: conv_op = separable_conv2d else: conv_op = conv2d net = conv_op(....) Most common usage of separable conv use depth_multiplier=1, e.g. in MobileNet and Xception. PiperOrigin-RevId: 207741004 --- tensorflow/contrib/layers/python/layers/layers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/contrib/layers/python/layers/layers.py b/tensorflow/contrib/layers/python/layers/layers.py index fa334070ad..6250f88529 100644 --- a/tensorflow/contrib/layers/python/layers/layers.py +++ b/tensorflow/contrib/layers/python/layers/layers.py @@ -2660,7 +2660,7 @@ def separable_convolution2d( inputs, num_outputs, kernel_size, - depth_multiplier, + depth_multiplier=1, stride=1, padding='SAME', data_format=DATA_FORMAT_NHWC, -- GitLab From f545b67f8e250a03e01f1926e1c2429696a7246f Mon Sep 17 00:00:00 2001 From: Rohan Jain Date: Tue, 7 Aug 2018 10:53:35 -0700 Subject: [PATCH 159/437] Adding alwayslink=1 to contrib data kernel BUILD rules. PiperOrigin-RevId: 207743274 --- tensorflow/contrib/data/kernels/BUILD | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tensorflow/contrib/data/kernels/BUILD b/tensorflow/contrib/data/kernels/BUILD index 566cbb246a..2e249f5c14 100644 --- a/tensorflow/contrib/data/kernels/BUILD +++ b/tensorflow/contrib/data/kernels/BUILD @@ -37,6 +37,7 @@ cc_library( "//third_party/eigen3", "@protobuf_archive//:protobuf_headers", ], + alwayslink = 1, ) cc_library( @@ -58,6 +59,7 @@ cc_library( "//third_party/eigen3", "@protobuf_archive//:protobuf_headers", ], + alwayslink = 1, ) cc_library( @@ -68,6 +70,7 @@ cc_library( "//third_party/eigen3", "@protobuf_archive//:protobuf_headers", ], + alwayslink = 1, ) cc_library( @@ -78,6 +81,7 @@ cc_library( "//third_party/eigen3", "@protobuf_archive//:protobuf_headers", ], + alwayslink = 1, ) cc_library( -- GitLab From b6b52565b892511720d2c10583be0da79d9483a0 Mon Sep 17 00:00:00 2001 From: "William D. Irons" Date: Tue, 7 Aug 2018 13:03:57 -0500 Subject: [PATCH 160/437] Need to export TF_NCCL_VERSION in Dockerfile because ci_build.sh calls builds/configured which calls configure.py before the linux gpu scripts are called to set TF_NCCL_VERSION --- tensorflow/tools/ci_build/Dockerfile.gpu.ppc64le | 3 +++ tensorflow/tools/ci_build/linux/ppc64le/gpu/run_cc_core.sh | 3 --- tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2_core.sh | 5 +---- tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh | 3 --- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/tensorflow/tools/ci_build/Dockerfile.gpu.ppc64le b/tensorflow/tools/ci_build/Dockerfile.gpu.ppc64le index a404f129ab..a99d2c1af2 100644 --- a/tensorflow/tools/ci_build/Dockerfile.gpu.ppc64le +++ b/tensorflow/tools/ci_build/Dockerfile.gpu.ppc64le @@ -26,3 +26,6 @@ ENV LD_LIBRARY_PATH /usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH # Configure the build for our CUDA configuration. ENV TF_NEED_CUDA 1 ENV TF_CUDA_COMPUTE_CAPABILITIES 3.0 + +#TODO get NCCL 2 in the docker image +ENV TF_NCCL_VERSION 1 diff --git a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_cc_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_cc_core.sh index b220676b77..728b89af28 100755 --- a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_cc_core.sh +++ b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_cc_core.sh @@ -28,9 +28,6 @@ echo "" export PYTHON_BIN_PATH=`which python3` export CC_OPT_FLAGS='-mcpu=power8 -mtune=power8' -#TODO get NCCL 2 in the docker image -export TF_NCCL_VERSION=1 - export TF_NEED_CUDA=1 export TF_CUDA_COMPUTE_CAPABILITIES=3.7 diff --git a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2_core.sh index 019b52d8a0..3798498abf 100755 --- a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2_core.sh +++ b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2_core.sh @@ -25,12 +25,9 @@ echo "Bazel will use ${N_JOBS} concurrent job(s)." echo "" # Run configure. -export PYTHON_BIN_PATH=`which python` +export PYTHON_BIN_PATH=`which python2` export CC_OPT_FLAGS='-mcpu=power8 -mtune=power8' -#TODO get NCCL 2 in the docker image -export TF_NCCL_VERSION=1 - export TF_NEED_CUDA=1 export TF_CUDA_COMPUTE_CAPABILITIES=3.7 diff --git a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh index 7a28ee87c0..cb43384013 100755 --- a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh +++ b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh @@ -28,9 +28,6 @@ echo "" export PYTHON_BIN_PATH=`which python3` export CC_OPT_FLAGS='-mcpu=power8 -mtune=power8' -#TODO get NCCL 2 in the docker image -export TF_NCCL_VERSION=1 - export TF_NEED_CUDA=1 export TF_CUDA_COMPUTE_CAPABILITIES=3.7 -- GitLab From a196cf1ba46155228d2ff7ebf31f85fb483d9ef3 Mon Sep 17 00:00:00 2001 From: "William D. Irons" Date: Tue, 7 Aug 2018 13:04:41 -0500 Subject: [PATCH 161/437] Use pip to install hd5py Because using easy_install3 to install hd5py was causing the python3 test to seg fault --- .../tools/ci_build/install/install_hdf5_ppc64le.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tensorflow/tools/ci_build/install/install_hdf5_ppc64le.sh b/tensorflow/tools/ci_build/install/install_hdf5_ppc64le.sh index 4989d986b8..2fc3012b64 100755 --- a/tensorflow/tools/ci_build/install/install_hdf5_ppc64le.sh +++ b/tensorflow/tools/ci_build/install/install_hdf5_ppc64le.sh @@ -24,7 +24,10 @@ apt-get install -y libhdf5-dev ln -s /usr/lib/powerpc64le-linux-gnu/libhdf5_serial.so /usr/lib/powerpc64le-linux-gnu/libhdf5.so ln -s /usr/lib/powerpc64le-linux-gnu/libhdf5_serial_hl.so /usr/lib/powerpc64le-linux-gnu/libhdf5_hl.so -#pip is not installed yet, so use easy_install +#Install pip here because h5py seg faults with python3 when installed via easy_install +easy_install -U pip==9.0.3 +easy_install3 -U pip==9.0.3 + #CPATH is the location of hdf5.h -CPATH=/usr/include/hdf5/serial/ easy_install -U h5py -CPATH=/usr/include/hdf5/serial/ easy_install3 -U h5py +CPATH=/usr/include/hdf5/serial/ pip2 install --upgrade h5py +CPATH=/usr/include/hdf5/serial/ pip3 install --upgrade h5py -- GitLab From f53c888a9ed9d37d022f93d76324dbd9e35f0948 Mon Sep 17 00:00:00 2001 From: Bixia Zheng Date: Tue, 7 Aug 2018 11:36:29 -0700 Subject: [PATCH 162/437] [XLA:CPU/GPU] Turn on random_ops_test for the CPU and GPU backends. Slightly increase the tolerances for testTruncatedNormalIsInRange to make it pass on the CPU and GPU backends. Partially skip two tests for the CPU and GPU backends due to known issues. PiperOrigin-RevId: 207752048 --- tensorflow/compiler/tests/BUILD | 4 ---- tensorflow/compiler/tests/random_ops_test.py | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tensorflow/compiler/tests/BUILD b/tensorflow/compiler/tests/BUILD index b7dc5d4c74..ae98b3f0f9 100644 --- a/tensorflow/compiler/tests/BUILD +++ b/tensorflow/compiler/tests/BUILD @@ -691,11 +691,7 @@ tf_xla_py_test( size = "small", srcs = ["random_ops_test.py"], disabled_backends = [ - # TODO(b/110300529): RngNormal doesn't return values with the expected variance - "cpu", "cpu_ondemand", - # TODO(b/31361304): enable RNG ops on GPU when parallelized. - "gpu", ], deps = [ ":xla_test", diff --git a/tensorflow/compiler/tests/random_ops_test.py b/tensorflow/compiler/tests/random_ops_test.py index 8124955afd..cc0e9b2f98 100644 --- a/tensorflow/compiler/tests/random_ops_test.py +++ b/tensorflow/compiler/tests/random_ops_test.py @@ -74,6 +74,11 @@ class RandomOpsTest(xla_test.XLATestCase): def testRandomUniformIsInRange(self): for dtype in self._random_types(): + # TODO (b/112272078): enable bfloat16 for CPU and GPU when the bug is + # fixed. + if (self.device in ["XLA_GPU", "XLA_CPU" + ]) and (dtype in [dtypes.bfloat16, dtypes.half]): + continue with self.test_session() as sess: with self.test_scope(): x = random_ops.random_uniform( @@ -125,7 +130,10 @@ class RandomOpsTest(xla_test.XLATestCase): # Department of Scientific Computing website. Florida State University. expected_mean = mu + (normal_pdf(alpha) - normal_pdf(beta)) / z * sigma actual_mean = np.mean(y) - self.assertAllClose(actual_mean, expected_mean, atol=2e-4) + atol = 2e-4 + if self.device in ["XLA_GPU", "XLA_CPU"]: + atol = 2.2e-4 + self.assertAllClose(actual_mean, expected_mean, atol=atol) expected_median = mu + probit( (normal_cdf(alpha) + normal_cdf(beta)) / 2.) * sigma @@ -136,9 +144,15 @@ class RandomOpsTest(xla_test.XLATestCase): (alpha * normal_pdf(alpha) - beta * normal_pdf(beta)) / z) - ( (normal_pdf(alpha) - normal_pdf(beta)) / z)**2) actual_variance = np.var(y) - self.assertAllClose(actual_variance, expected_variance, atol=1e-3) + rtol = 1e-3 + if self.device in ["XLA_GPU", "XLA_CPU"]: + rtol = 4e-4 + self.assertAllClose(actual_variance, expected_variance, rtol=rtol) def testShuffle1d(self): + # TODO(b/26783907): this test requires the CPU backend to implement sort. + if self.device in ["XLA_CPU"]: + return with self.test_session() as sess: with self.test_scope(): x = math_ops.range(1 << 16) -- GitLab From c3d1f4bc30c2cc5e0999ac2b0f04d41d607cb1fe Mon Sep 17 00:00:00 2001 From: Asim Shankar Date: Tue, 7 Aug 2018 11:42:23 -0700 Subject: [PATCH 163/437] [Docs]: Reduce over-estimation while measuring compute time. Inspired by: https://stackoverflow.com/questions/51717817/performance-measurement-in-tensorflows-eager-mode PiperOrigin-RevId: 207752918 --- tensorflow/docs_src/guide/eager.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tensorflow/docs_src/guide/eager.md b/tensorflow/docs_src/guide/eager.md index 3b54d6d2bb..24f6e4ee95 100644 --- a/tensorflow/docs_src/guide/eager.md +++ b/tensorflow/docs_src/guide/eager.md @@ -727,7 +727,13 @@ def measure(x, steps): start = time.time() for i in range(steps): x = tf.matmul(x, x) - _ = x.numpy() # Make sure to execute op and not just enqueue it + # tf.matmul can return before completing the matrix multiplication + # (e.g., can return after enqueing the operation on a CUDA stream). + # The x.numpy() call below will ensure that all enqueued operations + # have completed (and will also copy the result to host memory, + # so we're including a little more than just the matmul operation + # time). + _ = x.numpy() end = time.time() return end - start @@ -751,8 +757,8 @@ Output (exact numbers depend on hardware): ``` Time to multiply a (1000, 1000) matrix by itself 200 times: -CPU: 4.614904403686523 secs -GPU: 0.5581181049346924 secs +CPU: 1.46628093719 secs +GPU: 0.0593810081482 secs ``` A `tf.Tensor` object can be copied to a different device to execute its -- GitLab From 1a5256fbc379a01f2c7289d5cfbd8522653941e0 Mon Sep 17 00:00:00 2001 From: Sanjoy Das Date: Tue, 7 Aug 2018 11:54:03 -0700 Subject: [PATCH 164/437] [TF:XLA] Bump open source llvm revision to r339148 PiperOrigin-RevId: 207754971 --- tensorflow/workspace.bzl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl index f9c26fb963..5ad05b2d91 100644 --- a/tensorflow/workspace.bzl +++ b/tensorflow/workspace.bzl @@ -486,11 +486,11 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""): tf_http_archive( name = "llvm", urls = [ - "https://mirror.bazel.build/github.com/llvm-mirror/llvm/archive/7b3bfc8151f3a6bcd9642c49c1f86f66cc43a428.tar.gz", - "https://github.com/llvm-mirror/llvm/archive/7b3bfc8151f3a6bcd9642c49c1f86f66cc43a428.tar.gz", + "https://mirror.bazel.build/github.com/llvm-mirror/llvm/archive/5aa74422b69e309587c4e60e98649fb8a027d260.tar.gz", + "https://github.com/llvm-mirror/llvm/archive/5aa74422b69e309587c4e60e98649fb8a027d260.tar.gz", ], - sha256 = "c6cbb21acd46e3e00faa8c379595ecffb99ef77622da17f29371db2bfad1d3d3", - strip_prefix = "llvm-7b3bfc8151f3a6bcd9642c49c1f86f66cc43a428", + sha256 = "23371dc9cc589c2226780361012547a49c1125db6f755731216887238fb4738e", + strip_prefix = "llvm-5aa74422b69e309587c4e60e98649fb8a027d260", build_file = clean_dep("//third_party/llvm:llvm.autogenerated.BUILD"), ) -- GitLab From 37c58b8ebbb702f030c1e5b7bf7c3ee3d520fe38 Mon Sep 17 00:00:00 2001 From: Sanjoy Das Date: Tue, 7 Aug 2018 11:57:59 -0700 Subject: [PATCH 165/437] [XLA:GPU] Remove aggressive while licm from the pipeline. We used to have to copy constants from host to device before passing them to black-box conv/matmul routines. In that setting LICM'ing constant instructions used to make sense (constants weren't "free"). However, with cr/207204478, constants reside on the device (like normal buffers) and so we no longer need to H2D copy constants to pass them to black-box conv/matmul. Therefore LICM'ing constants is no longer necessary. PiperOrigin-RevId: 207755572 --- tensorflow/compiler/xla/service/gpu/BUILD | 1 - tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc | 9 --------- 2 files changed, 10 deletions(-) diff --git a/tensorflow/compiler/xla/service/gpu/BUILD b/tensorflow/compiler/xla/service/gpu/BUILD index 4947dd278e..6a0aedc949 100644 --- a/tensorflow/compiler/xla/service/gpu/BUILD +++ b/tensorflow/compiler/xla/service/gpu/BUILD @@ -655,7 +655,6 @@ cc_library( "//tensorflow/compiler/xla/service:transpose_folding", "//tensorflow/compiler/xla/service:tuple_simplifier", "//tensorflow/compiler/xla/service:while_loop_constant_sinking", - "//tensorflow/compiler/xla/service:while_loop_invariant_code_motion", "//tensorflow/compiler/xla/service:while_loop_simplifier", "//tensorflow/compiler/xla/service:zero_sized_hlo_elimination", "//tensorflow/compiler/xla/service/gpu:cudnn_batchnorm_rewriter", diff --git a/tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc b/tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc index 8fa0439006..76c9b6ab33 100644 --- a/tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc +++ b/tensorflow/compiler/xla/service/gpu/nvptx_compiler.cc @@ -75,7 +75,6 @@ limitations under the License. #include "tensorflow/compiler/xla/service/transpose_folding.h" #include "tensorflow/compiler/xla/service/tuple_simplifier.h" #include "tensorflow/compiler/xla/service/while_loop_constant_sinking.h" -#include "tensorflow/compiler/xla/service/while_loop_invariant_code_motion.h" #include "tensorflow/compiler/xla/service/while_loop_simplifier.h" #include "tensorflow/compiler/xla/service/zero_sized_hlo_elimination.h" #include "tensorflow/compiler/xla/status_macros.h" @@ -281,14 +280,6 @@ Status OptimizeHloModule(HloModule* hlo_module, se::StreamExecutor* stream_exec, } } - { - // Do an aggressive LICM pass over while loops. In particular, this hoists - // constants that were sunk by WhileLoopConstantSinking. Leaving them in - // the while loop may result in unnecessary copies. - HloPassPipeline pipeline("while-loop-licm"); - pipeline.AddPass(true); - TF_RETURN_IF_ERROR(pipeline.Run(hlo_module).status()); - } return Status::OK(); } -- GitLab From 858c5657d8e4ed3b30fa4a8fdfc28e35de283f7e Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 7 Aug 2018 12:02:34 -0700 Subject: [PATCH 166/437] [TF:XLA] Add initial XLA pooling library Generalize pooling operations from tf2xla and put them into a library to make them reusable by any XLA frontend. PiperOrigin-RevId: 207756300 --- tensorflow/compiler/xla/client/lib/BUILD | 24 +++ tensorflow/compiler/xla/client/lib/pooling.cc | 183 +++++++++++++++++ tensorflow/compiler/xla/client/lib/pooling.h | 73 +++++++ .../compiler/xla/client/lib/pooling_test.cc | 185 ++++++++++++++++++ 4 files changed, 465 insertions(+) create mode 100644 tensorflow/compiler/xla/client/lib/pooling.cc create mode 100644 tensorflow/compiler/xla/client/lib/pooling.h create mode 100644 tensorflow/compiler/xla/client/lib/pooling_test.cc diff --git a/tensorflow/compiler/xla/client/lib/BUILD b/tensorflow/compiler/xla/client/lib/BUILD index 39d5582d19..8bf0773928 100644 --- a/tensorflow/compiler/xla/client/lib/BUILD +++ b/tensorflow/compiler/xla/client/lib/BUILD @@ -121,6 +121,30 @@ xla_test( ], ) +cc_library( + name = "pooling", + srcs = ["pooling.cc"], + hdrs = ["pooling.h"], + deps = [ + ":arithmetic", + ":constants", + "//tensorflow/compiler/tf2xla/lib:util", + "//tensorflow/compiler/xla/client/xla_client:xla_builder", + "//tensorflow/core:lib", + ], +) + +xla_test( + name = "pooling_test", + srcs = ["pooling_test.cc"], + deps = [ + ":pooling", + "//tensorflow/compiler/xla:test", + "//tensorflow/compiler/xla/tests:client_library_test_base", + "//tensorflow/compiler/xla/tests:xla_internal_test_main", + ], +) + cc_library( name = "prng", srcs = ["prng.cc"], diff --git a/tensorflow/compiler/xla/client/lib/pooling.cc b/tensorflow/compiler/xla/client/lib/pooling.cc new file mode 100644 index 0000000000..7199269a6c --- /dev/null +++ b/tensorflow/compiler/xla/client/lib/pooling.cc @@ -0,0 +1,183 @@ +/* Copyright 2017 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#include "tensorflow/compiler/xla/client/lib/pooling.h" +#include "tensorflow/compiler/tf2xla/lib/util.h" +#include "tensorflow/compiler/xla/client/lib/arithmetic.h" +#include "tensorflow/compiler/xla/client/lib/constants.h" + +namespace xla { + +namespace { + +// Common computation shared between AvgPool and AvgPoolGrad. Divide each +// element of an image by the count of elements that contributed to that +// element during pooling. +XlaOp AvgPoolDivideByCountWithGeneralPadding( + XlaOp sums, PrimitiveType dtype, + tensorflow::gtl::ArraySlice input_shape, + tensorflow::gtl::ArraySlice> spatial_padding, + tensorflow::gtl::ArraySlice ksize, + tensorflow::gtl::ArraySlice stride, + const TensorFormat& data_format) { + // The padding shouldn't be included in the counts. We use another + // ReduceWindow to find the right counts. + const int num_spatial_dims = spatial_padding.size(); + + std::vector input_dim_sizes(num_spatial_dims); + std::vector window_dims(num_spatial_dims); + std::vector window_ksize(num_spatial_dims); + std::vector window_stride(num_spatial_dims); + CHECK_EQ(data_format.num_spatial_dims(), num_spatial_dims) + << "Invalid number of spatial dimentions in data format specification"; + for (int i = 0; i < num_spatial_dims; ++i) { + int dim = data_format.spatial_dimension(i); + input_dim_sizes[i] = input_shape[dim]; + window_dims[i] = dim; + window_ksize[i] = ksize[dim]; + window_stride[i] = stride[dim]; + } + + XlaBuilder* b = sums.builder(); + // Build a matrix of all 1s, with the same width/height as the input. + auto ones = Broadcast(One(b, dtype), input_dim_sizes); + PaddingConfig padding_config; + for (int i = 0; i < num_spatial_dims; ++i) { + auto dims = padding_config.add_dimensions(); + dims->set_edge_padding_low(spatial_padding[i].first); + dims->set_edge_padding_high(spatial_padding[i].second); + } + auto zero = Zero(b, dtype); + auto padded_ones = Pad(ones, zero, padding_config); + + // Perform a ReduceWindow with the same window size, strides, and padding + // to count the number of contributions to each result element. + auto counts = + ReduceWindow(padded_ones, zero, CreateScalarAddComputation(dtype, b), + window_ksize, window_stride, Padding::kValid); + + return Div(sums, counts, window_dims); +} + +// Sums all elements in the window specified by 'kernel_size' and 'stride'. +XlaOp ComputeSums(XlaOp operand, XlaOp init_value, + tensorflow::gtl::ArraySlice kernel_size, + tensorflow::gtl::ArraySlice stride, + const TensorFormat& data_format) { + XlaBuilder* b = operand.builder(); + return b->ReportErrorOrReturn([&]() -> StatusOr { + TF_ASSIGN_OR_RETURN(Shape operand_shape, b->GetShape(operand)); + TF_ASSIGN_OR_RETURN(Shape init_shape, b->GetShape(init_value)); + PrimitiveType accumulation_type = init_shape.element_type(); + auto add_computation = CreateScalarAddComputation(accumulation_type, b); + return ReduceWindow(operand, init_value, add_computation, kernel_size, + stride, Padding::kValid); + }); +} + +// Creates a padding configuration out of spatial padding values. +PaddingConfig MakeSpatialPaddingConfig( + tensorflow::gtl::ArraySlice> spatial_padding, + tensorflow::gtl::ArraySlice kernel_size, + tensorflow::gtl::ArraySlice stride, + const TensorFormat& data_format) { + const int num_spatial_dims = kernel_size.size() - 2; + PaddingConfig padding_config; + for (int i = 0; i < 2 + num_spatial_dims; ++i) { + padding_config.add_dimensions(); + } + CHECK_EQ(data_format.num_spatial_dims(), num_spatial_dims) + << "Invalid number of spatial dimentions in data format specification"; + for (int i = 0; i < num_spatial_dims; ++i) { + int dim = data_format.spatial_dimension(i); + auto padding_dimension = padding_config.mutable_dimensions(dim); + padding_dimension->set_edge_padding_low(spatial_padding[i].first); + padding_dimension->set_edge_padding_high(spatial_padding[i].second); + } + return padding_config; +} + +} // namespace + +XlaOp MaxPool(XlaOp operand, tensorflow::gtl::ArraySlice kernel_size, + tensorflow::gtl::ArraySlice stride, Padding padding, + const TensorFormat& data_format) { + XlaBuilder* b = operand.builder(); + return b->ReportErrorOrReturn([&]() -> StatusOr { + TF_ASSIGN_OR_RETURN(Shape operand_shape, b->GetShape(operand)); + PrimitiveType dtype = operand_shape.element_type(); + auto max_computation = CreateScalarMaxComputation(dtype, b); + auto init_value = MinValue(b, dtype); + return ReduceWindow(operand, init_value, max_computation, kernel_size, + stride, padding); + }); +} + +XlaOp AvgPool(XlaOp operand, tensorflow::gtl::ArraySlice kernel_size, + tensorflow::gtl::ArraySlice stride, + tensorflow::gtl::ArraySlice> padding, + const TensorFormat& data_format, + const bool counts_include_padding) { + XlaBuilder* b = operand.builder(); + return b->ReportErrorOrReturn([&]() -> StatusOr { + TF_ASSIGN_OR_RETURN(Shape operand_shape, b->GetShape(operand)); + PrimitiveType dtype = operand_shape.element_type(); + auto init_value = Zero(b, dtype); + std::vector input_size(operand_shape.dimensions().begin(), + operand_shape.dimensions().end()); + auto padding_config = + MakeSpatialPaddingConfig(padding, kernel_size, stride, data_format); + auto padded_operand = Pad(operand, Zero(b, dtype), padding_config); + auto pooled = ComputeSums(padded_operand, init_value, kernel_size, stride, + data_format); + if (counts_include_padding) { + // If counts include padding, all windows have the same number of elements + // contributing to each average. Divide by the window size everywhere to + // get the average. + int64 window_size = + std::accumulate(kernel_size.begin(), kernel_size.end(), 1, + [](int64 x, int64 y) { return x * y; }); + + auto divisor = ConstantR0WithType(b, dtype, window_size); + return pooled / divisor; + } else { + return AvgPoolDivideByCountWithGeneralPadding( + pooled, dtype, input_size, padding, kernel_size, stride, data_format); + } + }); +} + +std::vector> MakeSpatialPadding( + tensorflow::gtl::ArraySlice input_size, + tensorflow::gtl::ArraySlice kernel_size, + tensorflow::gtl::ArraySlice stride, Padding padding, + const TensorFormat& data_format) { + const int num_spatial_dims = kernel_size.size() - 2; + std::vector input_spatial_dimensions; + std::vector kernel_size_spatial_dimensions; + std::vector stride_spatial_dimensions; + CHECK_EQ(data_format.num_spatial_dims(), num_spatial_dims) + << "Invalid number of spatial dimentions in data format specification"; + for (int i = 0; i < num_spatial_dims; ++i) { + int dim = data_format.spatial_dimension(i); + input_spatial_dimensions.push_back(input_size[dim]); + kernel_size_spatial_dimensions.push_back(kernel_size[dim]); + stride_spatial_dimensions.push_back(stride[dim]); + } + return MakePadding(input_spatial_dimensions, kernel_size_spatial_dimensions, + stride_spatial_dimensions, padding); +} + +} // namespace xla diff --git a/tensorflow/compiler/xla/client/lib/pooling.h b/tensorflow/compiler/xla/client/lib/pooling.h new file mode 100644 index 0000000000..66d8006aae --- /dev/null +++ b/tensorflow/compiler/xla/client/lib/pooling.h @@ -0,0 +1,73 @@ +/* Copyright 2017 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_COMPILER_XLA_CLIENT_LIB_POOLING_H_ +#define TENSORFLOW_COMPILER_XLA_CLIENT_LIB_POOLING_H_ + +#include "tensorflow/compiler/xla/client/xla_client/xla_builder.h" +#include "tensorflow/core/lib/gtl/inlined_vector.h" + +namespace xla { + +// Tensor format for reduce window operations. +class TensorFormat { + public: + TensorFormat(int batch_dimension, int feature_dimension, + tensorflow::gtl::ArraySlice spatial_dimensions) + : batch_dimension_(batch_dimension), + feature_dimension_(feature_dimension), + spatial_dimensions_(spatial_dimensions.begin(), + spatial_dimensions.end()) {} + + int batch_dimension() const { return batch_dimension_; } + + int feature_dimension() const { return feature_dimension_; } + + int spatial_dimension(int dim) const { return spatial_dimensions_[dim]; } + + int num_spatial_dims() const { return spatial_dimensions_.size(); } + + private: + // The number of the dimension that represents the batch. + int batch_dimension_; + // The number of the dimension that represents the features. + int feature_dimension_; + // The dimension numbers for the spatial dimensions. + tensorflow::gtl::InlinedVector spatial_dimensions_; +}; + +// Computes the max pool of 'operand'. +XlaOp MaxPool(XlaOp operand, tensorflow::gtl::ArraySlice kernel_size, + tensorflow::gtl::ArraySlice stride, Padding padding, + const TensorFormat& data_format); + +// Computes the average pool of 'operand'. +XlaOp AvgPool(XlaOp operand, tensorflow::gtl::ArraySlice kernel_size, + tensorflow::gtl::ArraySlice stride, + tensorflow::gtl::ArraySlice> padding, + const TensorFormat& data_format, + const bool counts_include_padding); + +// Returns the list of low and high padding elements in each spatial dimension +// for the given 'padding' specification. +std::vector> MakeSpatialPadding( + tensorflow::gtl::ArraySlice input_size, + tensorflow::gtl::ArraySlice kernel_size, + tensorflow::gtl::ArraySlice stride, Padding padding, + const TensorFormat& data_format); + +} // namespace xla + +#endif // TENSORFLOW_COMPILER_XLA_CLIENT_LIB_POOLING_H_ diff --git a/tensorflow/compiler/xla/client/lib/pooling_test.cc b/tensorflow/compiler/xla/client/lib/pooling_test.cc new file mode 100644 index 0000000000..4b4553b60d --- /dev/null +++ b/tensorflow/compiler/xla/client/lib/pooling_test.cc @@ -0,0 +1,185 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#include "tensorflow/compiler/xla/client/lib/pooling.h" +#include "tensorflow/compiler/xla/test.h" +#include "tensorflow/compiler/xla/tests/client_library_test_base.h" +#include "tensorflow/compiler/xla/tests/test_macros.h" + +namespace xla { +namespace { + +TensorFormat MakeNCHWFormat(int num_spatial_dims) { + tensorflow::gtl::InlinedVector spatial_dimensions; + for (int i = 0; i < num_spatial_dims; ++i) { + spatial_dimensions.push_back(i + 2); + } + return TensorFormat(/*batch_dimension=*/0, /*feature_dimension=*/1, + /*spatial_dimensions=*/spatial_dimensions); +} + +std::vector> MakeGeneralPadding( + XlaOp input, tensorflow::gtl::ArraySlice kernel_size, + tensorflow::gtl::ArraySlice stride, Padding padding, + const xla::TensorFormat& data_format) { + XlaBuilder* b = input.builder(); + Shape operand_shape = b->GetShape(input).ValueOrDie(); + std::vector input_size(operand_shape.dimensions().begin(), + operand_shape.dimensions().end()); + return MakeSpatialPadding(input_size, kernel_size, stride, padding, + data_format); +} + +// Add singleton batch and feature dimensions to spatial dimensions, according +// to 'data_format' specification. +std::vector ExpandWithBatchAndFeatureDimensions( + tensorflow::gtl::ArraySlice spatial_dim_sizes, + const xla::TensorFormat& data_format) { + const int num_spatial_dims = spatial_dim_sizes.size(); + std::vector tensor_sizes(num_spatial_dims + 2, 1); + for (int i = 0; i < num_spatial_dims; ++i) { + int dim = data_format.spatial_dimension(i); + tensor_sizes[dim] = spatial_dim_sizes[i]; + } + return tensor_sizes; +} + +class PoolingTest : public ClientLibraryTestBase { + public: + ErrorSpec error_spec_{0.0001}; +}; + +XLA_TEST_F(PoolingTest, MaxPool2D) { + XlaBuilder builder(TestName()); + + XlaOp input = ConstantR4FromArray4D( + &builder, {{{{1, 2, 3, 4, 5}, {5, 4, 3, 2, 1}}}}); + auto data_format = MakeNCHWFormat(2); + auto kernel_size = ExpandWithBatchAndFeatureDimensions({2, 2}, data_format); + auto stride = kernel_size; + MaxPool(input, kernel_size, stride, Padding::kValid, data_format); + + ComputeAndCompareR4(&builder, {{{{5, 4}}}}, {}, error_spec_); +} + +XLA_TEST_F(PoolingTest, MaxPool2DWithPadding) { + XlaBuilder builder(TestName()); + + XlaOp input = ConstantR4FromArray4D( + &builder, {{{{1, 2, 3, 4, 5}, {5, 4, 3, 2, 1}}}}); + auto data_format = MakeNCHWFormat(2); + auto kernel_size = ExpandWithBatchAndFeatureDimensions({2, 2}, data_format); + auto stride = kernel_size; + MaxPool(input, kernel_size, stride, Padding::kSame, data_format); + + ComputeAndCompareR4(&builder, {{{{5, 4, 5}}}}, {}, error_spec_); +} + +XLA_TEST_F(PoolingTest, MaxPool2DWithPaddingAndStride) { + XlaBuilder builder(TestName()); + + XlaOp input = ConstantR4FromArray4D( + &builder, {{{{1, 2, 3, 4, 5}, {5, 4, 3, 2, 1}}}}); + auto data_format = MakeNCHWFormat(2); + auto kernel_size = ExpandWithBatchAndFeatureDimensions({2, 2}, data_format); + auto stride = ExpandWithBatchAndFeatureDimensions({1, 1}, data_format); + MaxPool(input, kernel_size, stride, Padding::kSame, data_format); + + ComputeAndCompareR4(&builder, {{{{5, 4, 4, 5, 5}, {5, 4, 3, 2, 1}}}}, + {}, error_spec_); +} + +XLA_TEST_F(PoolingTest, AvgPool2D) { + XlaBuilder builder(TestName()); + + XlaOp input = ConstantR4FromArray4D( + &builder, {{{{1, 2, 3, 4, 5}, {5, 4, 3, 2, 1}}}}); + auto data_format = MakeNCHWFormat(2); + auto kernel_size = ExpandWithBatchAndFeatureDimensions({2, 2}, data_format); + auto stride = kernel_size; + auto padding = MakeGeneralPadding(input, kernel_size, stride, Padding::kValid, + data_format); + AvgPool(input, kernel_size, stride, padding, data_format, + /*counts_include_padding=*/true); + + ComputeAndCompareR4(&builder, {{{{3, 3}}}}, {}, error_spec_); +} + +XLA_TEST_F(PoolingTest, AvgPool2DWithPadding) { + XlaBuilder builder(TestName()); + + XlaOp input = ConstantR4FromArray4D( + &builder, {{{{1, 2, 3, 4, 5}, {5, 4, 3, 2, 1}}}}); + auto data_format = MakeNCHWFormat(2); + auto kernel_size = ExpandWithBatchAndFeatureDimensions({2, 2}, data_format); + auto stride = kernel_size; + auto padding = MakeGeneralPadding(input, kernel_size, stride, Padding::kSame, + data_format); + AvgPool(input, kernel_size, stride, padding, data_format, + /*counts_include_padding=*/false); + + ComputeAndCompareR4(&builder, {{{{3, 3, 3}}}}, {}, error_spec_); +} + +XLA_TEST_F(PoolingTest, AvgPool2DWithPaddingAndStride) { + XlaBuilder builder(TestName()); + + XlaOp input = ConstantR4FromArray4D( + &builder, {{{{1, 2, 3, 4, 5}, {5, 4, 3, 2, 1}}}}); + auto data_format = MakeNCHWFormat(2); + auto kernel_size = ExpandWithBatchAndFeatureDimensions({2, 2}, data_format); + auto stride = ExpandWithBatchAndFeatureDimensions({1, 1}, data_format); + auto padding = MakeGeneralPadding(input, kernel_size, stride, Padding::kSame, + data_format); + AvgPool(input, kernel_size, stride, padding, data_format, + /*counts_include_padding=*/false); + + ComputeAndCompareR4(&builder, + {{{{3, 3, 3, 3, 3}, {4.5, 3.5, 2.5, 1.5, 1}}}}, {}, + error_spec_); +} + +XLA_TEST_F(PoolingTest, AvgPool2DWithGeneralPaddingCountNotIncludePadding) { + XlaBuilder builder(TestName()); + + XlaOp input = ConstantR4FromArray4D( + &builder, {{{{1, 2, 3, 4, 5}, {5, 4, 3, 2, 1}}}}); + auto data_format = MakeNCHWFormat(2); + auto kernel_size = ExpandWithBatchAndFeatureDimensions({3, 3}, data_format); + auto stride = kernel_size; + AvgPool(input, kernel_size, stride, {{1, 1}, {2, 1}}, data_format, + /*counts_include_padding=*/false); + + ComputeAndCompareR4(&builder, {{{{3, 3}}}}, {}, error_spec_); +} + +XLA_TEST_F(PoolingTest, + AvgPool2DWithGeneralPaddingCountNotIncludePaddingAndStride) { + XlaBuilder builder(TestName()); + + XlaOp input = ConstantR4FromArray4D( + &builder, {{{{1, 2, 3, 4, 5}, {5, 4, 3, 2, 1}}}}); + auto data_format = MakeNCHWFormat(2); + auto kernel_size = ExpandWithBatchAndFeatureDimensions({3, 3}, data_format); + auto stride = ExpandWithBatchAndFeatureDimensions({2, 2}, data_format); + AvgPool(input, kernel_size, stride, {{2, 1}, {1, 1}}, data_format, + /*counts_include_padding=*/false); + + ComputeAndCompareR4(&builder, {{{{1.5, 3, 4.5}, {3, 3, 3}}}}, {}, + error_spec_); +} + +} // namespace +} // namespace xla -- GitLab From 201a27e0eaeb7dea564ad66871408cc7e7d60cbc Mon Sep 17 00:00:00 2001 From: Mark Daoust Date: Tue, 7 Aug 2018 12:05:09 -0700 Subject: [PATCH 167/437] Fix TensorFlow docs cannonical name chooser Prefer `tf.submodule.thing` to `tf.thing` as the canonical doc location. For class members, prefer the defining class. Always prefer the non-contrib version. Choose the shortest name, but prefer sub-modules. (1.10 is includes submodules like tf.io and tf.math) PiperOrigin-RevId: 207756817 --- tensorflow/tools/docs/BUILD | 1 + .../tools/docs/doc_generator_visitor.py | 58 ++++- .../tools/docs/doc_generator_visitor_test.py | 233 ++++++++++++++---- tensorflow/tools/docs/generate_lib.py | 7 +- 4 files changed, 249 insertions(+), 50 deletions(-) diff --git a/tensorflow/tools/docs/BUILD b/tensorflow/tools/docs/BUILD index 66b10478ac..cc7885ab1b 100644 --- a/tensorflow/tools/docs/BUILD +++ b/tensorflow/tools/docs/BUILD @@ -28,6 +28,7 @@ py_test( srcs_version = "PY2AND3", deps = [ ":doc_generator_visitor", + ":generate_lib", "//tensorflow/python:platform_test", ], ) diff --git a/tensorflow/tools/docs/doc_generator_visitor.py b/tensorflow/tools/docs/doc_generator_visitor.py index c090dbd8da..e5eaf8cc05 100644 --- a/tensorflow/tools/docs/doc_generator_visitor.py +++ b/tensorflow/tools/docs/doc_generator_visitor.py @@ -159,6 +159,55 @@ class DocGeneratorVisitor(object): self._index[full_name] = child self._tree[parent_name].append(name) + def _score_name(self, name): + """Return a tuple of scores indicating how to sort for the best name. + + This function is meant to be used as the `key` to the `sorted` function. + + This sorting in order: + Prefers names refering to the defining class, over a subclass. + Prefers names that are not in "contrib". + prefers submodules to the root namespace. + Prefers short names `tf.thing` over `tf.a.b.c.thing` + Sorts lexicographically on name parts. + + Args: + name: the full name to score, for example `tf.estimator.Estimator` + + Returns: + A tuple of scores. When sorted the preferred name will have the lowest + value. + """ + parts = name.split('.') + short_name = parts[-1] + + container = self._index['.'.join(parts[:-1])] + + defining_class_score = 1 + if tf_inspect.isclass(container): + if short_name in container.__dict__: + # prefer the defining class + defining_class_score = -1 + + contrib_score = -1 + if 'contrib' in parts: + contrib_score = 1 + + while parts: + parts.pop() + container = self._index['.'.join(parts)] + if tf_inspect.ismodule(container): + break + module_length = len(parts) + if len(parts) == 2: + # `tf.submodule.thing` is better than `tf.thing` + module_length_score = -1 + else: + # shorter is better + module_length_score = module_length + + return (defining_class_score, contrib_score, module_length_score, name) + def _maybe_find_duplicates(self): """Compute data structures containing information about duplicates. @@ -192,7 +241,7 @@ class DocGeneratorVisitor(object): if (py_object is not None and not isinstance(py_object, six.integer_types + six.string_types + (six.binary_type, six.text_type, float, complex, bool)) - and py_object is not ()): + and py_object is not ()): # pylint: disable=literal-comparison object_id = id(py_object) if object_id in reverse_index: master_name = reverse_index[object_id] @@ -217,9 +266,10 @@ class DocGeneratorVisitor(object): if master_name: master_name = 'tf.%s' % master_name else: - # Choose the lexicographically first name with the minimum number of - # submodules. This will prefer highest level namespace for any symbol. - master_name = min(names, key=lambda name: name.count('.')) + # Choose the master name with a lexical sort on the tuples returned by + # by _score_name. + master_name = min(names, key=self._score_name) + print(names, master_name) duplicates[master_name] = names for name in names: diff --git a/tensorflow/tools/docs/doc_generator_visitor_test.py b/tensorflow/tools/docs/doc_generator_visitor_test.py index cf5be45f40..1c2635d4a8 100644 --- a/tensorflow/tools/docs/doc_generator_visitor_test.py +++ b/tensorflow/tools/docs/doc_generator_visitor_test.py @@ -18,8 +18,21 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +import types + from tensorflow.python.platform import googletest from tensorflow.tools.docs import doc_generator_visitor +from tensorflow.tools.docs import generate_lib + + +class NoDunderVisitor(doc_generator_visitor.DocGeneratorVisitor): + + def __call__(self, parent_name, parent, children): + """Drop all the dunder methods to make testing easier.""" + children = [ + (name, obj) for (name, obj) in children if not name.startswith('_') + ] + super(NoDunderVisitor, self).__call__(parent_name, parent, children) class DocGeneratorVisitorTest(googletest.TestCase): @@ -57,52 +70,184 @@ class DocGeneratorVisitorTest(googletest.TestCase): with self.assertRaises(RuntimeError): visitor('non_class_or_module', 'non_class_or_module_object', []) - def test_duplicates(self): - visitor = doc_generator_visitor.DocGeneratorVisitor() - visitor( - 'submodule.DocGeneratorVisitor', - doc_generator_visitor.DocGeneratorVisitor, - [('index', doc_generator_visitor.DocGeneratorVisitor.index), - ('index2', doc_generator_visitor.DocGeneratorVisitor.index)]) - visitor( - 'submodule2.DocGeneratorVisitor', - doc_generator_visitor.DocGeneratorVisitor, - [('index', doc_generator_visitor.DocGeneratorVisitor.index), - ('index2', doc_generator_visitor.DocGeneratorVisitor.index)]) - visitor( - 'DocGeneratorVisitor2', - doc_generator_visitor.DocGeneratorVisitor, - [('index', doc_generator_visitor.DocGeneratorVisitor.index), - ('index2', doc_generator_visitor.DocGeneratorVisitor.index)]) - - # The shorter path should be master, or if equal, the lexicographically - # first will be. - self.assertEqual( - {'DocGeneratorVisitor2': sorted(['submodule.DocGeneratorVisitor', - 'submodule2.DocGeneratorVisitor', - 'DocGeneratorVisitor2']), - 'DocGeneratorVisitor2.index': sorted([ - 'submodule.DocGeneratorVisitor.index', - 'submodule.DocGeneratorVisitor.index2', - 'submodule2.DocGeneratorVisitor.index', - 'submodule2.DocGeneratorVisitor.index2', - 'DocGeneratorVisitor2.index', - 'DocGeneratorVisitor2.index2' - ]), - }, visitor.duplicates) - self.assertEqual({ - 'submodule.DocGeneratorVisitor': 'DocGeneratorVisitor2', - 'submodule.DocGeneratorVisitor.index': 'DocGeneratorVisitor2.index', - 'submodule.DocGeneratorVisitor.index2': 'DocGeneratorVisitor2.index', - 'submodule2.DocGeneratorVisitor': 'DocGeneratorVisitor2', - 'submodule2.DocGeneratorVisitor.index': 'DocGeneratorVisitor2.index', - 'submodule2.DocGeneratorVisitor.index2': 'DocGeneratorVisitor2.index', - 'DocGeneratorVisitor2.index2': 'DocGeneratorVisitor2.index' + def test_duplicates_module_class_depth(self): + + class Parent(object): + + class Nested(object): + pass + + tf = types.ModuleType('tf') + tf.Parent = Parent + tf.submodule = types.ModuleType('submodule') + tf.submodule.Parent = Parent + + visitor = generate_lib.extract( + [('tf', tf)], + private_map={}, + do_not_descend_map={}, + visitor_cls=NoDunderVisitor) + + self.assertEqual({ + 'tf.submodule.Parent': + sorted([ + 'tf.Parent', + 'tf.submodule.Parent', + ]), + 'tf.submodule.Parent.Nested': + sorted([ + 'tf.Parent.Nested', + 'tf.submodule.Parent.Nested', + ]), + }, visitor.duplicates) + + self.assertEqual({ + 'tf.Parent.Nested': 'tf.submodule.Parent.Nested', + 'tf.Parent': 'tf.submodule.Parent', + }, visitor.duplicate_of) + + self.assertEqual({ + id(Parent): 'tf.submodule.Parent', + id(Parent.Nested): 'tf.submodule.Parent.Nested', + id(tf): 'tf', + id(tf.submodule): 'tf.submodule', + }, visitor.reverse_index) + + def test_duplicates_contrib(self): + + class Parent(object): + pass + + tf = types.ModuleType('tf') + tf.contrib = types.ModuleType('contrib') + tf.submodule = types.ModuleType('submodule') + tf.contrib.Parent = Parent + tf.submodule.Parent = Parent + + visitor = generate_lib.extract( + [('tf', tf)], + private_map={}, + do_not_descend_map={}, + visitor_cls=NoDunderVisitor) + + self.assertEqual({ + 'tf.submodule.Parent': + sorted(['tf.contrib.Parent', 'tf.submodule.Parent']), + }, visitor.duplicates) + + self.assertEqual({ + 'tf.contrib.Parent': 'tf.submodule.Parent', + }, visitor.duplicate_of) + + self.assertEqual({ + id(tf): 'tf', + id(tf.submodule): 'tf.submodule', + id(Parent): 'tf.submodule.Parent', + id(tf.contrib): 'tf.contrib', + }, visitor.reverse_index) + + def test_duplicates_defining_class(self): + + class Parent(object): + obj1 = object() + + class Child(Parent): + pass + + tf = types.ModuleType('tf') + tf.Parent = Parent + tf.Child = Child + + visitor = generate_lib.extract( + [('tf', tf)], + private_map={}, + do_not_descend_map={}, + visitor_cls=NoDunderVisitor) + + self.assertEqual({ + 'tf.Parent.obj1': sorted([ + 'tf.Parent.obj1', + 'tf.Child.obj1', + ]), + }, visitor.duplicates) + + self.assertEqual({ + 'tf.Child.obj1': 'tf.Parent.obj1', }, visitor.duplicate_of) + + self.assertEqual({ + id(tf): 'tf', + id(Parent): 'tf.Parent', + id(Child): 'tf.Child', + id(Parent.obj1): 'tf.Parent.obj1', + }, visitor.reverse_index) + + def test_duplicates_module_depth(self): + + class Parent(object): + pass + + tf = types.ModuleType('tf') + tf.submodule = types.ModuleType('submodule') + tf.submodule.submodule2 = types.ModuleType('submodule2') + tf.Parent = Parent + tf.submodule.submodule2.Parent = Parent + + visitor = generate_lib.extract( + [('tf', tf)], + private_map={}, + do_not_descend_map={}, + visitor_cls=NoDunderVisitor) + + self.assertEqual({ + 'tf.Parent': sorted(['tf.Parent', 'tf.submodule.submodule2.Parent']), + }, visitor.duplicates) + + self.assertEqual({ + 'tf.submodule.submodule2.Parent': 'tf.Parent' + }, visitor.duplicate_of) + + self.assertEqual({ + id(tf): 'tf', + id(tf.submodule): 'tf.submodule', + id(tf.submodule.submodule2): 'tf.submodule.submodule2', + id(Parent): 'tf.Parent', + }, visitor.reverse_index) + + def test_duplicates_name(self): + + class Parent(object): + obj1 = object() + + Parent.obj2 = Parent.obj1 + + tf = types.ModuleType('tf') + tf.submodule = types.ModuleType('submodule') + tf.submodule.Parent = Parent + + visitor = generate_lib.extract( + [('tf', tf)], + private_map={}, + do_not_descend_map={}, + visitor_cls=NoDunderVisitor) + + self.assertEqual({ + 'tf.submodule.Parent.obj1': + sorted([ + 'tf.submodule.Parent.obj1', + 'tf.submodule.Parent.obj2', + ]), + }, visitor.duplicates) + + self.assertEqual({ + 'tf.submodule.Parent.obj2': 'tf.submodule.Parent.obj1', + }, visitor.duplicate_of) + self.assertEqual({ - id(doc_generator_visitor.DocGeneratorVisitor): 'DocGeneratorVisitor2', - id(doc_generator_visitor.DocGeneratorVisitor.index): - 'DocGeneratorVisitor2.index', + id(tf): 'tf', + id(tf.submodule): 'tf.submodule', + id(Parent): 'tf.submodule.Parent', + id(Parent.obj1): 'tf.submodule.Parent.obj1', }, visitor.reverse_index) if __name__ == '__main__': diff --git a/tensorflow/tools/docs/generate_lib.py b/tensorflow/tools/docs/generate_lib.py index 4f70a69364..7c8dbd5dc2 100644 --- a/tensorflow/tools/docs/generate_lib.py +++ b/tensorflow/tools/docs/generate_lib.py @@ -284,10 +284,13 @@ def _get_default_do_not_descend_map(): } -def extract(py_modules, private_map, do_not_descend_map): +def extract(py_modules, + private_map, + do_not_descend_map, + visitor_cls=doc_generator_visitor.DocGeneratorVisitor): """Extract docs from tf namespace and write them to disk.""" # Traverse the first module. - visitor = doc_generator_visitor.DocGeneratorVisitor(py_modules[0][0]) + visitor = visitor_cls(py_modules[0][0]) api_visitor = public_api.PublicAPIVisitor(visitor) api_visitor.set_root_name(py_modules[0][0]) add_dict_to_dict(private_map, api_visitor.private_map) -- GitLab From 892ad8e358b0f25aa7e366edce2551c5807391bb Mon Sep 17 00:00:00 2001 From: Monica Dinculescu Date: Tue, 7 Aug 2018 15:31:30 -0400 Subject: [PATCH 168/437] Correct links to documentation pages --- tensorflow/python/keras/engine/training.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tensorflow/python/keras/engine/training.py b/tensorflow/python/keras/engine/training.py index 04a2aa7664..5040ae6f83 100644 --- a/tensorflow/python/keras/engine/training.py +++ b/tensorflow/python/keras/engine/training.py @@ -127,9 +127,9 @@ class Model(Network): Arguments: optimizer: String (name of optimizer) or optimizer instance. - See [optimizers](/optimizers). + See [optimizers](/api_docs/python/tf/keras/optimizers). loss: String (name of objective function) or objective function. - See [losses](/losses). + See [losses](/api_docs/python/tf/losses). If the model has multiple outputs, you can use a different loss on each output by passing a dictionary or a list of losses. The loss value that will be minimized by the model @@ -1168,7 +1168,7 @@ class Model(Network): 0 = silent, 1 = progress bar, 2 = one line per epoch. callbacks: List of `keras.callbacks.Callback` instances. List of callbacks to apply during training. - See [callbacks](/callbacks). + See [callbacks](/api_docs/python/tf/keras/callbacks). validation_split: Float between 0 and 1. Fraction of the training data to be used as validation data. The model will set apart this fraction of the training data, -- GitLab From 4b5832226fbfd1ef4f1cd3da38efa565d2e33f84 Mon Sep 17 00:00:00 2001 From: "William D. Irons" Date: Tue, 7 Aug 2018 14:42:48 -0500 Subject: [PATCH 169/437] Limit the number of local jobs to the number of GPU Limit the number of local jobs in bazel to the number of GPU so we don't have test running in parallel using the same GPU and causing unnecessary failures. --- tensorflow/tools/ci_build/linux/ppc64le/gpu/run_cc_core.sh | 4 +++- tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2_core.sh | 4 +++- tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_cc_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_cc_core.sh index 728b89af28..8efa580dbd 100755 --- a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_cc_core.sh +++ b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_cc_core.sh @@ -19,9 +19,11 @@ set -e set -x N_JOBS=$(grep -c ^processor /proc/cpuinfo) +LT_JOBS=$(nvidia-smi --query-gpu=gpu_name --format=csv,noheader | wc -l) echo "" echo "Bazel will use ${N_JOBS} concurrent job(s)." +echo "Bazel will use ${LT_JOBS} local test job(s)." echo "" # Run configure. @@ -36,7 +38,7 @@ yes "" | $PYTHON_BIN_PATH configure.py # Run bazel test command. Double test timeouts to avoid flakes. bazel test --config=cuda --test_tag_filters=-no_oss,-oss_serial,-no_gpu,-benchmark-test -k \ --test_lang_filters=cc --jobs=${N_JOBS} --test_timeout 300,450,1200,3600 \ - --build_tests_only --test_output=errors --local_test_jobs=8 --config=opt \ + --build_tests_only --test_output=errors --local_test_jobs=${LT_JOBS} --config=opt \ --test_size_filters=small,medium \ --run_under=//tensorflow/tools/ci_build/gpu_build:parallel_gpu_execute -- \ //tensorflow/... -//tensorflow/compiler/... -//tensorflow/contrib/... diff --git a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2_core.sh index 3798498abf..caa9f188f0 100755 --- a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2_core.sh +++ b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2_core.sh @@ -19,9 +19,11 @@ set -e set -x N_JOBS=$(grep -c ^processor /proc/cpuinfo) +LT_JOBS=$(nvidia-smi --query-gpu=gpu_name --format=csv,noheader | wc -l) echo "" echo "Bazel will use ${N_JOBS} concurrent job(s)." +echo "Bazel will use ${LT_JOBS} local test job(s)." echo "" # Run configure. @@ -36,7 +38,7 @@ yes "" | $PYTHON_BIN_PATH configure.py # Run bazel test command. Double test timeouts to avoid flakes. bazel test --config=cuda --test_tag_filters=-no_oss,-oss_serial,-no_gpu,-benchmark-test -k \ --test_lang_filters=py --jobs=${N_JOBS} --test_timeout 300,450,1200,3600 \ - --build_tests_only --test_output=errors --local_test_jobs=8 --config=opt \ + --build_tests_only --test_output=errors --local_test_jobs=${LT_JOBS} --config=opt \ --test_size_filters=small,medium \ --run_under=//tensorflow/tools/ci_build/gpu_build:parallel_gpu_execute -- \ //tensorflow/... -//tensorflow/compiler/... -//tensorflow/contrib/... diff --git a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh index cb43384013..05815e0a58 100755 --- a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh +++ b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh @@ -19,9 +19,11 @@ set -e set -x N_JOBS=$(grep -c ^processor /proc/cpuinfo) +LT_JOBS=$(nvidia-smi --query-gpu=gpu_name --format=csv,noheader | wc -l) echo "" echo "Bazel will use ${N_JOBS} concurrent job(s)." +echo "Bazel will use ${LT_JOBS} local test job(s)." echo "" # Run configure. @@ -36,7 +38,7 @@ yes "" | $PYTHON_BIN_PATH configure.py # Run bazel test command. Double test timeouts to avoid flakes. bazel test --config=cuda --test_tag_filters=-no_oss,-oss_serial,-no_gpu,-benchmark-test -k \ --test_lang_filters=py --jobs=${N_JOBS} --test_timeout 300,450,1200,3600 \ - --build_tests_only --test_output=errors --local_test_jobs=8 --config=opt \ + --build_tests_only --test_output=errors --local_test_jobs=${LT_JOBS} --config=opt \ --test_size_filters=small,medium \ --run_under=//tensorflow/tools/ci_build/gpu_build:parallel_gpu_execute -- \ //tensorflow/... -//tensorflow/compiler/... -//tensorflow/contrib/... -- GitLab From acb87b0fd588c0423d923ecb1ed439deab7e79cf Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 7 Aug 2018 12:51:28 -0700 Subject: [PATCH 170/437] [TF:XLA] Start using XLA pooling library in tf2xla PiperOrigin-RevId: 207763624 --- tensorflow/compiler/tf2xla/kernels/BUILD | 1 + .../compiler/tf2xla/kernels/pooling_ops.cc | 184 ++++++++++-------- 2 files changed, 109 insertions(+), 76 deletions(-) diff --git a/tensorflow/compiler/tf2xla/kernels/BUILD b/tensorflow/compiler/tf2xla/kernels/BUILD index 0609e22338..3bfe74521f 100644 --- a/tensorflow/compiler/tf2xla/kernels/BUILD +++ b/tensorflow/compiler/tf2xla/kernels/BUILD @@ -129,6 +129,7 @@ tf_kernel_library( "//tensorflow/compiler/xla/client/lib:constants", "//tensorflow/compiler/xla/client/lib:math", "//tensorflow/compiler/xla/client/lib:numeric", + "//tensorflow/compiler/xla/client/lib:pooling", "//tensorflow/compiler/xla/client/lib:prng", "//tensorflow/compiler/xla/client/lib:sorting", "//tensorflow/core:framework", diff --git a/tensorflow/compiler/tf2xla/kernels/pooling_ops.cc b/tensorflow/compiler/tf2xla/kernels/pooling_ops.cc index 3d506e71e0..d4d180aff8 100644 --- a/tensorflow/compiler/tf2xla/kernels/pooling_ops.cc +++ b/tensorflow/compiler/tf2xla/kernels/pooling_ops.cc @@ -21,6 +21,7 @@ limitations under the License. #include "tensorflow/compiler/tf2xla/xla_op_registry.h" #include "tensorflow/compiler/xla/client/lib/arithmetic.h" #include "tensorflow/compiler/xla/client/lib/constants.h" +#include "tensorflow/compiler/xla/client/lib/pooling.h" #include "tensorflow/compiler/xla/client/xla_builder.h" #include "tensorflow/compiler/xla/client/xla_computation.h" #include "tensorflow/compiler/xla/literal.h" @@ -71,59 +72,53 @@ class PoolingOp : public XlaOpKernel { int num_dims() const { return num_spatial_dims_ + 2; } - // Method that builds an initial value to use in reductions. - virtual xla::XlaOp InitValue(xla::XlaBuilder* b) = 0; - - // The reduction operation to apply to each window. - virtual const xla::XlaComputation* Reduction(XlaOpKernelContext* ctx) = 0; - - // A post-processing operation to apply on the outputs of the ReduceWindow. - virtual xla::XlaOp PostProcessOutput(XlaOpKernelContext* ctx, - const xla::XlaOp& output, DataType dtype, - const TensorShape& input_shape) = 0; - - void Compile(XlaOpKernelContext* ctx) override { - std::vector ksize = ksize_; - std::vector stride = stride_; - if (ctx->num_inputs() != 1) { - const TensorShape ksize_shape = ctx->InputShape(1); - // Validate input sizes. - OP_REQUIRES(ctx, TensorShapeUtils::IsVector(ksize_shape), - errors::InvalidArgument("ksize must be a vector, not shape ", - ksize_shape.DebugString())); - OP_REQUIRES(ctx, ksize_shape.num_elements() == num_dims(), - errors::InvalidArgument("Sliding window ksize field must " - "specify ", - num_dims(), " dimensions")); - ksize.clear(); - OP_REQUIRES_OK(ctx, ctx->ConstantInputAsIntVector(1, &ksize)); - - const TensorShape stride_shape = ctx->InputShape(2); - // Validate input sizes. - OP_REQUIRES(ctx, TensorShapeUtils::IsVector(stride_shape), - errors::InvalidArgument("stride must be a vector, not shape ", - stride_shape.DebugString())); - OP_REQUIRES(ctx, stride_shape.num_elements() == num_dims(), - errors::InvalidArgument("Sliding window stride field must " - "specify ", - num_dims(), " dimensions")); - stride.clear(); - OP_REQUIRES_OK(ctx, ctx->ConstantInputAsIntVector(2, &stride)); + protected: + xla::StatusOr> GetKernelSize(XlaOpKernelContext* ctx) { + if (ctx->num_inputs() == 1) { + return ksize_; } - const TensorShape input_shape = ctx->InputShape(0); - OP_REQUIRES(ctx, input_shape.dims() == num_dims(), - errors::InvalidArgument("Input to ", type_string(), - " operator must have ", num_dims(), - " dimensions")); + const TensorShape ksize_shape = ctx->InputShape(1); + // Validate input sizes. + if (!TensorShapeUtils::IsVector(ksize_shape)) { + return errors::InvalidArgument("ksize must be a vector, not shape ", + ksize_shape.DebugString()); + } + if (ksize_shape.num_elements() != num_dims()) { + return errors::InvalidArgument( + "Sliding window ksize field must " + "specify ", + num_dims(), " dimensions"); + } + std::vector ksize; + auto status = ctx->ConstantInputAsIntVector(1, &ksize); + if (!status.ok()) { + return status; + } + return ksize; + } - xla::XlaBuilder* const b = ctx->builder(); - auto input = - XlaHelpers::ConvertElementType(b, ctx->Input(0), reduction_type_); - auto reduce = xla::ReduceWindow(input, InitValue(b), *Reduction(ctx), ksize, - stride, padding_); - auto pooled = XlaHelpers::ConvertElementType(b, reduce, input_type(0)); - ctx->SetOutput(0, - PostProcessOutput(ctx, pooled, input_type(0), input_shape)); + xla::StatusOr> GetStride(XlaOpKernelContext* ctx) { + if (ctx->num_inputs() == 1) { + return stride_; + } + const TensorShape stride_shape = ctx->InputShape(2); + // Validate input sizes. + if (!TensorShapeUtils::IsVector(stride_shape)) { + return errors::InvalidArgument("stride must be a vector, not shape ", + stride_shape.DebugString()); + } + if (stride_shape.num_elements() != num_dims()) { + return errors::InvalidArgument( + "Sliding window stride field must " + "specify ", + num_dims(), " dimensions"); + } + std::vector stride; + auto status = ctx->ConstantInputAsIntVector(2, &stride); + if (!status.ok()) { + return status; + } + return stride; } protected: @@ -136,24 +131,48 @@ class PoolingOp : public XlaOpKernel { xla::PrimitiveType xla_reduction_type_; }; +// Converts the tensor data format to the one required by the XLA pooling +// library. +xla::TensorFormat XlaTensorFormat(tensorflow::TensorFormat data_format, + int num_spatial_dims) { + int num_dims = num_spatial_dims + 2; + int batch_dimension = GetTensorBatchDimIndex(num_dims, data_format); + int feature_dimension = GetTensorFeatureDimIndex(num_dims, data_format); + gtl::InlinedVector spatial_dimensions(num_spatial_dims); + for (int spatial_dim = 0; spatial_dim < num_spatial_dims; ++spatial_dim) { + spatial_dimensions[spatial_dim] = + GetTensorSpatialDimIndex(num_dims, data_format, spatial_dim); + } + return xla::TensorFormat(/*batch_dimension=*/batch_dimension, + /*feature_dimension=*/feature_dimension, + /*spatial_dimensions=*/spatial_dimensions); +} + class MaxPoolOp : public PoolingOp { public: MaxPoolOp(OpKernelConstruction* ctx, int num_spatial_dims) : PoolingOp(ctx, /*num_spatial_dims=*/num_spatial_dims, /*reduction_type=*/ctx->input_type(0)) {} - xla::XlaOp InitValue(xla::XlaBuilder* b) override { - return xla::MinValue(b, xla_reduction_type_); - } + void Compile(XlaOpKernelContext* ctx) override { + auto ksize_or_error = GetKernelSize(ctx); + OP_REQUIRES_OK(ctx, ksize_or_error.status()); + std::vector ksize = ksize_or_error.ValueOrDie(); - const xla::XlaComputation* Reduction(XlaOpKernelContext* ctx) override { - return ctx->GetOrCreateMax(reduction_type_); - } + auto stride_or_error = GetStride(ctx); + OP_REQUIRES_OK(ctx, stride_or_error.status()); + std::vector stride = stride_or_error.ValueOrDie(); + + const TensorShape input_shape = ctx->InputShape(0); + OP_REQUIRES(ctx, input_shape.dims() == num_dims(), + errors::InvalidArgument("Input to ", type_string(), + " operator must have ", num_dims(), + " dimensions")); - xla::XlaOp PostProcessOutput(XlaOpKernelContext* ctx, - const xla::XlaOp& output, DataType dtype, - const TensorShape& input_shape) override { - return output; + auto pooling = + xla::MaxPool(ctx->Input(0), ksize, stride, padding_, + XlaTensorFormat(data_format_, input_shape.dims() - 2)); + ctx->SetOutput(0, pooling); } }; @@ -180,9 +199,8 @@ class MaxPool3DOp : public MaxPoolOp { }; REGISTER_XLA_OP(Name("MaxPool3D"), MaxPool3DOp); -// Common computation shared between AvgPool and AvgPoolGrad. Divide each -// element of an image by the count of elements that contributed to that -// element during pooling. +// Divide each element of an image by the count of elements that contributed to +// that element during pooling. static xla::XlaOp AvgPoolDivideByCount( XlaOpKernelContext* ctx, const xla::XlaOp& output, DataType dtype, const TensorShape& input_shape, xla::Padding padding, @@ -241,20 +259,34 @@ class AvgPoolOp : public PoolingOp { /*reduction_type=*/ XlaHelpers::SumAccumulationType(ctx->input_type(0))) {} - xla::XlaOp InitValue(xla::XlaBuilder* b) override { - return xla::Zero(b, xla_reduction_type_); - } + void Compile(XlaOpKernelContext* ctx) override { + auto ksize_or_error = GetKernelSize(ctx); + OP_REQUIRES_OK(ctx, ksize_or_error.status()); + std::vector ksize = ksize_or_error.ValueOrDie(); - const xla::XlaComputation* Reduction(XlaOpKernelContext* ctx) override { - return ctx->GetOrCreateAdd(reduction_type_); - } + auto stride_or_error = GetStride(ctx); + OP_REQUIRES_OK(ctx, stride_or_error.status()); + std::vector stride = stride_or_error.ValueOrDie(); + + const TensorShape input_shape = ctx->InputShape(0); + OP_REQUIRES(ctx, input_shape.dims() == num_dims(), + errors::InvalidArgument("Input to ", type_string(), + " operator must have ", num_dims(), + " dimensions")); - xla::XlaOp PostProcessOutput(XlaOpKernelContext* ctx, - const xla::XlaOp& output, DataType dtype, - const TensorShape& input_shape) override { - return AvgPoolDivideByCount(ctx, output, dtype, input_shape, padding_, - ksize_, stride_, num_spatial_dims_, - data_format_); + auto xla_data_format = + XlaTensorFormat(data_format_, input_shape.dims() - 2); + auto spatial_padding = MakeSpatialPadding( + input_shape.dim_sizes(), ksize, stride, padding_, xla_data_format); + + // Convert the input to the reduction type. + auto converted_input = + ConvertElementType(ctx->Input(0), xla_reduction_type_); + auto pooling = + xla::AvgPool(converted_input, ksize, stride, spatial_padding, + xla_data_format, padding_ == xla::Padding::kValid); + // Convert the pooling result back to the input type before returning it. + ctx->SetOutput(0, ConvertElementType(pooling, ctx->input_xla_type(0))); } }; -- GitLab From 16c2b25e7e23fb1ac373cd2162ce18ca71e9b0a8 Mon Sep 17 00:00:00 2001 From: Peng Yu Date: Tue, 7 Aug 2018 16:04:41 -0400 Subject: [PATCH 171/437] make the line shorter --- tensorflow/cc/saved_model/loader.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tensorflow/cc/saved_model/loader.cc b/tensorflow/cc/saved_model/loader.cc index a5eae97f6e..3830416159 100644 --- a/tensorflow/cc/saved_model/loader.cc +++ b/tensorflow/cc/saved_model/loader.cc @@ -170,7 +170,8 @@ Status RunRestore(const RunOptions& run_options, const string& export_dir, variables_directory, MetaFilename(kSavedModelVariablesFilename)); if (!Env::Default()->FileExists(variables_index_path).ok()) { LOG(INFO) << "The specified SavedModel has no variables; no checkpoints " - "were restored. File does not exist: " << variables_index_path; + "were restored. File does not exist: " + << variables_index_path; return Status::OK(); } const string variables_path = -- GitLab From 2e2486adedb5164b82b0c2fcb8b1d27f987c1428 Mon Sep 17 00:00:00 2001 From: Yu-Cheng Ling Date: Tue, 7 Aug 2018 13:00:25 -0700 Subject: [PATCH 172/437] Pin TFLite iOS examples with TFLite 0.1.7 CocoaPod. PiperOrigin-RevId: 207764971 --- tensorflow/contrib/lite/examples/ios/camera/Podfile | 2 +- tensorflow/contrib/lite/examples/ios/simple/Podfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow/contrib/lite/examples/ios/camera/Podfile b/tensorflow/contrib/lite/examples/ios/camera/Podfile index c7d3b1c966..cd8c39043f 100644 --- a/tensorflow/contrib/lite/examples/ios/camera/Podfile +++ b/tensorflow/contrib/lite/examples/ios/camera/Podfile @@ -2,4 +2,4 @@ platform :ios, '8.0' inhibit_all_warnings! target 'tflite_camera_example' - pod 'TensorFlowLite' + pod 'TensorFlowLite', '0.1.7' diff --git a/tensorflow/contrib/lite/examples/ios/simple/Podfile b/tensorflow/contrib/lite/examples/ios/simple/Podfile index e4aca2be82..c885398f44 100644 --- a/tensorflow/contrib/lite/examples/ios/simple/Podfile +++ b/tensorflow/contrib/lite/examples/ios/simple/Podfile @@ -2,4 +2,4 @@ platform :ios, '8.0' inhibit_all_warnings! target 'tflite_simple_example' - pod 'TensorFlowLite' + pod 'TensorFlowLite', '0.1.7' -- GitLab From 452f995e2c23cbd67c14b15b678bb3a352212633 Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Tue, 7 Aug 2018 13:33:47 -0700 Subject: [PATCH 173/437] Fix toco compilation on Windows The toco utility should now build successfully on Windows. However, there are a few lingering issues with execution that need to be resolved before the utility is fully functional. PiperOrigin-RevId: 207770586 --- tensorflow/contrib/lite/toco/BUILD | 3 ++- .../contrib/lite/toco/import_tensorflow.cc | 24 +++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/tensorflow/contrib/lite/toco/BUILD b/tensorflow/contrib/lite/toco/BUILD index c88079717d..7243e584e9 100644 --- a/tensorflow/contrib/lite/toco/BUILD +++ b/tensorflow/contrib/lite/toco/BUILD @@ -11,6 +11,7 @@ load( "//tensorflow:tensorflow.bzl", "tf_cc_binary", "tf_cc_test", + "tf_copts", ) tf_proto_library_cc( @@ -305,7 +306,7 @@ cc_library( "tensorflow_util.h", "toco_tooling.h", ], - copts = select({ + copts = tf_copts() + select({ "//tensorflow:darwin": ["-DTOCO_SUPPORT_PORTABLE_PROTOS=0"], "//conditions:default": [], }), diff --git a/tensorflow/contrib/lite/toco/import_tensorflow.cc b/tensorflow/contrib/lite/toco/import_tensorflow.cc index d8d331f3d4..b7fffbce22 100644 --- a/tensorflow/contrib/lite/toco/import_tensorflow.cc +++ b/tensorflow/contrib/lite/toco/import_tensorflow.cc @@ -1223,11 +1223,10 @@ tensorflow::Status ConvertGatherOperator( return tensorflow::Status::OK(); } -template +template tensorflow::Status ConvertArgMinMaxOperator( const NodeDef& node, const TensorFlowImportFlags& tf_import_flags, Model* model) { - CHECK_EQ(node.op(), op_name); TF_QCHECK_OK(CheckInputsCount(node, tf_import_flags, 2)); const auto axis_data_type = HasAttr(node, "Tidx") ? GetDataTypeAttr(node, "Tidx") : DT_INT32; @@ -1245,6 +1244,20 @@ tensorflow::Status ConvertArgMinMaxOperator( return tensorflow::Status::OK(); } +tensorflow::Status ConvertArgMaxOperator( + const NodeDef& node, const TensorFlowImportFlags& tf_import_flags, + Model* model) { + CHECK_EQ(node.op(), "ArgMax"); + return ConvertArgMinMaxOperator(node, tf_import_flags, model); +} + +tensorflow::Status ConvertArgMinOperator( + const NodeDef& node, const TensorFlowImportFlags& tf_import_flags, + Model* model) { + CHECK_EQ(node.op(), "ArgMin"); + return ConvertArgMinMaxOperator(node, tf_import_flags, model); +} + tensorflow::Status ConvertResizeBilinearOperator( const NodeDef& node, const TensorFlowImportFlags& tf_import_flags, Model* model) { @@ -1899,17 +1912,14 @@ using ConverterType = tensorflow::Status (*)( Model* model); using ConverterMapType = std::unordered_map; -constexpr char kArgMax[] = "ArgMax"; -constexpr char kArgMin[] = "ArgMin"; - ConverterMapType GetTensorFlowNodeConverterMap() { return std::unordered_map({ {"Add", ConvertSimpleOperator}, {"AddN", ConvertSimpleOperator}, {"All", ConvertSimpleOperator}, {"Any", ConvertAnyOperator}, - {"ArgMax", ConvertArgMinMaxOperator}, - {"ArgMin", ConvertArgMinMaxOperator}, + {"ArgMax", ConvertArgMaxOperator}, + {"ArgMin", ConvertArgMinOperator}, {"Assert", ConvertSimpleOperator}, {"AvgPool", ConvertAvgPoolOperator}, {"BatchMatMul", ConvertBatchMatMulOperator}, -- GitLab From 02df0f46d562a0c48b6f24803eba6330d13d7213 Mon Sep 17 00:00:00 2001 From: Mark Daoust Date: Tue, 7 Aug 2018 14:28:32 -0700 Subject: [PATCH 174/437] Remove usage of magic-api-link syntax from docs. Back-ticks are now converted to links in the api_docs generator. With the new docs repo we're moving to simplify the docs pipeline, and make everything more readable. By doing this we no longer get test failures for symbols that don't exist (`tf.does_not_exist` will not get a link). There is also no way to set custom link text now. That's okay. This is the result of the following regex replacement (+ a couple of manual edits.): re: @\{([^$].*?)(\$.+?)?} sub: `\1` Which does the following replacements: "@{tf.symbol}" --> "`tf.symbol`" "@{tf.symbol$link_text}" --> "`tf.symbol`" PiperOrigin-RevId: 207780049 --- tensorflow/docs_src/api_guides/cc/guide.md | 12 +- .../docs_src/api_guides/python/array_ops.md | 120 ++++----- .../docs_src/api_guides/python/check_ops.md | 34 +-- .../docs_src/api_guides/python/client.md | 48 ++-- .../docs_src/api_guides/python/constant_op.md | 38 +-- .../docs_src/api_guides/python/contrib.crf.md | 14 +- .../api_guides/python/contrib.ffmpeg.md | 4 +- .../api_guides/python/contrib.framework.md | 94 +++---- .../api_guides/python/contrib.graph_editor.md | 114 ++++----- .../api_guides/python/contrib.integrate.md | 2 +- .../api_guides/python/contrib.layers.md | 118 ++++----- .../api_guides/python/contrib.learn.md | 76 +++--- .../api_guides/python/contrib.linalg.md | 16 +- .../api_guides/python/contrib.losses.md | 30 +-- .../api_guides/python/contrib.metrics.md | 84 +++---- .../docs_src/api_guides/python/contrib.rnn.md | 60 ++--- .../api_guides/python/contrib.seq2seq.md | 32 +-- .../api_guides/python/contrib.signal.md | 16 +- .../api_guides/python/contrib.staging.md | 2 +- .../api_guides/python/contrib.training.md | 34 +-- .../api_guides/python/contrib.util.md | 10 +- .../api_guides/python/control_flow_ops.md | 56 ++--- .../docs_src/api_guides/python/framework.md | 58 ++--- .../api_guides/python/functional_ops.md | 10 +- .../docs_src/api_guides/python/image.md | 98 ++++---- .../api_guides/python/input_dataset.md | 96 ++++---- .../docs_src/api_guides/python/io_ops.md | 100 ++++---- .../docs_src/api_guides/python/math_ops.md | 230 +++++++++--------- .../docs_src/api_guides/python/meta_graph.md | 10 +- tensorflow/docs_src/api_guides/python/nn.md | 156 ++++++------ .../docs_src/api_guides/python/python_io.md | 8 +- .../api_guides/python/reading_data.md | 58 ++--- .../api_guides/python/regression_examples.md | 12 +- .../docs_src/api_guides/python/session_ops.md | 8 +- .../docs_src/api_guides/python/sparse_ops.md | 44 ++-- .../api_guides/python/spectral_ops.md | 30 +-- .../docs_src/api_guides/python/state_ops.md | 122 +++++----- .../docs_src/api_guides/python/string_ops.md | 28 +-- .../docs_src/api_guides/python/summary.md | 20 +- tensorflow/docs_src/api_guides/python/test.md | 20 +- .../docs_src/api_guides/python/tfdbg.md | 22 +- .../api_guides/python/threading_and_queues.md | 36 +-- .../docs_src/api_guides/python/train.md | 138 +++++------ tensorflow/docs_src/deploy/distributed.md | 18 +- tensorflow/docs_src/extend/adding_an_op.md | 25 +- tensorflow/docs_src/extend/architecture.md | 4 +- .../docs_src/extend/new_data_formats.md | 33 ++- tensorflow/docs_src/guide/checkpoints.md | 2 +- .../docs_src/guide/custom_estimators.md | 50 ++-- tensorflow/docs_src/guide/datasets.md | 24 +- .../docs_src/guide/datasets_for_estimators.md | 26 +- tensorflow/docs_src/guide/debugger.md | 22 +- tensorflow/docs_src/guide/estimators.md | 18 +- tensorflow/docs_src/guide/faq.md | 71 +++--- tensorflow/docs_src/guide/feature_columns.md | 36 +-- tensorflow/docs_src/guide/graph_viz.md | 2 +- tensorflow/docs_src/guide/graphs.md | 204 ++++++++-------- tensorflow/docs_src/guide/low_level_intro.md | 46 ++-- .../docs_src/guide/premade_estimators.md | 14 +- tensorflow/docs_src/guide/saved_model.md | 60 ++--- .../guide/summaries_and_tensorboard.md | 8 +- tensorflow/docs_src/guide/tensors.md | 2 +- tensorflow/docs_src/guide/using_tpu.md | 32 +-- tensorflow/docs_src/guide/variables.md | 4 +- tensorflow/docs_src/guide/version_compat.md | 10 +- .../performance/datasets_performance.md | 22 +- .../docs_src/performance/performance_guide.md | 42 ++-- .../performance/performance_models.md | 18 +- .../docs_src/performance/quantization.md | 2 +- .../performance/xla/operation_semantics.md | 12 +- .../docs_src/tutorials/estimators/cnn.md | 16 +- .../docs_src/tutorials/images/deep_cnn.md | 72 +++--- .../tutorials/images/image_recognition.md | 2 +- .../representation/kernel_methods.md | 11 +- .../tutorials/representation/linear.md | 2 +- .../tutorials/representation/word2vec.md | 2 +- 76 files changed, 1612 insertions(+), 1618 deletions(-) diff --git a/tensorflow/docs_src/api_guides/cc/guide.md b/tensorflow/docs_src/api_guides/cc/guide.md index 4e51ada58a..0cea1d266e 100644 --- a/tensorflow/docs_src/api_guides/cc/guide.md +++ b/tensorflow/docs_src/api_guides/cc/guide.md @@ -92,7 +92,7 @@ We will delve into the details of each below. ### Scope -@{tensorflow::Scope} is the main data structure that holds the current state +`tensorflow::Scope` is the main data structure that holds the current state of graph construction. A `Scope` acts as a handle to the graph being constructed, as well as storing TensorFlow operation properties. The `Scope` object is the first argument to operation constructors, and operations that use @@ -102,7 +102,7 @@ explained further below. Create a new `Scope` object by calling `Scope::NewRootScope`. This creates some resources such as a graph to which operations are added. It also creates a -@{tensorflow::Status} object which will be used to indicate errors encountered +`tensorflow::Status` object which will be used to indicate errors encountered when constructing operations. The `Scope` class has value semantics, thus, a `Scope` object can be freely copied and passed around. @@ -121,7 +121,7 @@ Here are some of the properties controlled by a `Scope` object: * Device placement for an operation * Kernel attribute for an operation -Please refer to @{tensorflow::Scope} for the complete list of member functions +Please refer to `tensorflow::Scope` for the complete list of member functions that let you create child scopes with new properties. ### Operation Constructors @@ -213,7 +213,7 @@ auto c = Concat(scope, s, 0); You may pass many different types of C++ values directly to tensor constants. You may explicitly create a tensor constant by calling the -@{tensorflow::ops::Const} function from various kinds of C++ values. For +`tensorflow::ops::Const` function from various kinds of C++ values. For example: * Scalars @@ -257,7 +257,7 @@ auto y = Add(scope, {1, 2, 3, 4}, 10); ## Graph Execution When executing a graph, you will need a session. The C++ API provides a -@{tensorflow::ClientSession} class that will execute ops created by the +`tensorflow::ClientSession` class that will execute ops created by the operation constructors. TensorFlow will automatically determine which parts of the graph need to be executed, and what values need feeding. For example: @@ -291,5 +291,5 @@ session.Run({ {a, { {1, 2}, {3, 4} } } }, {c}, &outputs); // outputs[0] == [4 5; 6 7] ``` -Please see the @{tensorflow::Tensor} documentation for more information on how +Please see the `tensorflow::Tensor` documentation for more information on how to use the execution output. diff --git a/tensorflow/docs_src/api_guides/python/array_ops.md b/tensorflow/docs_src/api_guides/python/array_ops.md index a34f01f073..ddeea80c56 100644 --- a/tensorflow/docs_src/api_guides/python/array_ops.md +++ b/tensorflow/docs_src/api_guides/python/array_ops.md @@ -1,7 +1,7 @@ # Tensor Transformations Note: Functions taking `Tensor` arguments can also take anything accepted by -@{tf.convert_to_tensor}. +`tf.convert_to_tensor`. [TOC] @@ -10,78 +10,78 @@ Note: Functions taking `Tensor` arguments can also take anything accepted by TensorFlow provides several operations that you can use to cast tensor data types in your graph. -* @{tf.string_to_number} -* @{tf.to_double} -* @{tf.to_float} -* @{tf.to_bfloat16} -* @{tf.to_int32} -* @{tf.to_int64} -* @{tf.cast} -* @{tf.bitcast} -* @{tf.saturate_cast} +* `tf.string_to_number` +* `tf.to_double` +* `tf.to_float` +* `tf.to_bfloat16` +* `tf.to_int32` +* `tf.to_int64` +* `tf.cast` +* `tf.bitcast` +* `tf.saturate_cast` ## Shapes and Shaping TensorFlow provides several operations that you can use to determine the shape of a tensor and change the shape of a tensor. -* @{tf.broadcast_dynamic_shape} -* @{tf.broadcast_static_shape} -* @{tf.shape} -* @{tf.shape_n} -* @{tf.size} -* @{tf.rank} -* @{tf.reshape} -* @{tf.squeeze} -* @{tf.expand_dims} -* @{tf.meshgrid} +* `tf.broadcast_dynamic_shape` +* `tf.broadcast_static_shape` +* `tf.shape` +* `tf.shape_n` +* `tf.size` +* `tf.rank` +* `tf.reshape` +* `tf.squeeze` +* `tf.expand_dims` +* `tf.meshgrid` ## Slicing and Joining TensorFlow provides several operations to slice or extract parts of a tensor, or join multiple tensors together. -* @{tf.slice} -* @{tf.strided_slice} -* @{tf.split} -* @{tf.tile} -* @{tf.pad} -* @{tf.concat} -* @{tf.stack} -* @{tf.parallel_stack} -* @{tf.unstack} -* @{tf.reverse_sequence} -* @{tf.reverse} -* @{tf.reverse_v2} -* @{tf.transpose} -* @{tf.extract_image_patches} -* @{tf.space_to_batch_nd} -* @{tf.space_to_batch} -* @{tf.required_space_to_batch_paddings} -* @{tf.batch_to_space_nd} -* @{tf.batch_to_space} -* @{tf.space_to_depth} -* @{tf.depth_to_space} -* @{tf.gather} -* @{tf.gather_nd} -* @{tf.unique_with_counts} -* @{tf.scatter_nd} -* @{tf.dynamic_partition} -* @{tf.dynamic_stitch} -* @{tf.boolean_mask} -* @{tf.one_hot} -* @{tf.sequence_mask} -* @{tf.dequantize} -* @{tf.quantize_v2} -* @{tf.quantized_concat} -* @{tf.setdiff1d} +* `tf.slice` +* `tf.strided_slice` +* `tf.split` +* `tf.tile` +* `tf.pad` +* `tf.concat` +* `tf.stack` +* `tf.parallel_stack` +* `tf.unstack` +* `tf.reverse_sequence` +* `tf.reverse` +* `tf.reverse_v2` +* `tf.transpose` +* `tf.extract_image_patches` +* `tf.space_to_batch_nd` +* `tf.space_to_batch` +* `tf.required_space_to_batch_paddings` +* `tf.batch_to_space_nd` +* `tf.batch_to_space` +* `tf.space_to_depth` +* `tf.depth_to_space` +* `tf.gather` +* `tf.gather_nd` +* `tf.unique_with_counts` +* `tf.scatter_nd` +* `tf.dynamic_partition` +* `tf.dynamic_stitch` +* `tf.boolean_mask` +* `tf.one_hot` +* `tf.sequence_mask` +* `tf.dequantize` +* `tf.quantize_v2` +* `tf.quantized_concat` +* `tf.setdiff1d` ## Fake quantization Operations used to help train for better quantization accuracy. -* @{tf.fake_quant_with_min_max_args} -* @{tf.fake_quant_with_min_max_args_gradient} -* @{tf.fake_quant_with_min_max_vars} -* @{tf.fake_quant_with_min_max_vars_gradient} -* @{tf.fake_quant_with_min_max_vars_per_channel} -* @{tf.fake_quant_with_min_max_vars_per_channel_gradient} +* `tf.fake_quant_with_min_max_args` +* `tf.fake_quant_with_min_max_args_gradient` +* `tf.fake_quant_with_min_max_vars` +* `tf.fake_quant_with_min_max_vars_gradient` +* `tf.fake_quant_with_min_max_vars_per_channel` +* `tf.fake_quant_with_min_max_vars_per_channel_gradient` diff --git a/tensorflow/docs_src/api_guides/python/check_ops.md b/tensorflow/docs_src/api_guides/python/check_ops.md index 6f8a18af42..b52fdaa3ab 100644 --- a/tensorflow/docs_src/api_guides/python/check_ops.md +++ b/tensorflow/docs_src/api_guides/python/check_ops.md @@ -1,19 +1,19 @@ # Asserts and boolean checks -* @{tf.assert_negative} -* @{tf.assert_positive} -* @{tf.assert_proper_iterable} -* @{tf.assert_non_negative} -* @{tf.assert_non_positive} -* @{tf.assert_equal} -* @{tf.assert_integer} -* @{tf.assert_less} -* @{tf.assert_less_equal} -* @{tf.assert_greater} -* @{tf.assert_greater_equal} -* @{tf.assert_rank} -* @{tf.assert_rank_at_least} -* @{tf.assert_type} -* @{tf.is_non_decreasing} -* @{tf.is_numeric_tensor} -* @{tf.is_strictly_increasing} +* `tf.assert_negative` +* `tf.assert_positive` +* `tf.assert_proper_iterable` +* `tf.assert_non_negative` +* `tf.assert_non_positive` +* `tf.assert_equal` +* `tf.assert_integer` +* `tf.assert_less` +* `tf.assert_less_equal` +* `tf.assert_greater` +* `tf.assert_greater_equal` +* `tf.assert_rank` +* `tf.assert_rank_at_least` +* `tf.assert_type` +* `tf.is_non_decreasing` +* `tf.is_numeric_tensor` +* `tf.is_strictly_increasing` diff --git a/tensorflow/docs_src/api_guides/python/client.md b/tensorflow/docs_src/api_guides/python/client.md index 27fc8610bf..56367e6671 100644 --- a/tensorflow/docs_src/api_guides/python/client.md +++ b/tensorflow/docs_src/api_guides/python/client.md @@ -4,33 +4,33 @@ This library contains classes for launching graphs and executing operations. @{$guide/low_level_intro$This guide} has examples of how a graph -is launched in a @{tf.Session}. +is launched in a `tf.Session`. ## Session management -* @{tf.Session} -* @{tf.InteractiveSession} -* @{tf.get_default_session} +* `tf.Session` +* `tf.InteractiveSession` +* `tf.get_default_session` ## Error classes and convenience functions -* @{tf.OpError} -* @{tf.errors.CancelledError} -* @{tf.errors.UnknownError} -* @{tf.errors.InvalidArgumentError} -* @{tf.errors.DeadlineExceededError} -* @{tf.errors.NotFoundError} -* @{tf.errors.AlreadyExistsError} -* @{tf.errors.PermissionDeniedError} -* @{tf.errors.UnauthenticatedError} -* @{tf.errors.ResourceExhaustedError} -* @{tf.errors.FailedPreconditionError} -* @{tf.errors.AbortedError} -* @{tf.errors.OutOfRangeError} -* @{tf.errors.UnimplementedError} -* @{tf.errors.InternalError} -* @{tf.errors.UnavailableError} -* @{tf.errors.DataLossError} -* @{tf.errors.exception_type_from_error_code} -* @{tf.errors.error_code_from_exception_type} -* @{tf.errors.raise_exception_on_not_ok_status} +* `tf.OpError` +* `tf.errors.CancelledError` +* `tf.errors.UnknownError` +* `tf.errors.InvalidArgumentError` +* `tf.errors.DeadlineExceededError` +* `tf.errors.NotFoundError` +* `tf.errors.AlreadyExistsError` +* `tf.errors.PermissionDeniedError` +* `tf.errors.UnauthenticatedError` +* `tf.errors.ResourceExhaustedError` +* `tf.errors.FailedPreconditionError` +* `tf.errors.AbortedError` +* `tf.errors.OutOfRangeError` +* `tf.errors.UnimplementedError` +* `tf.errors.InternalError` +* `tf.errors.UnavailableError` +* `tf.errors.DataLossError` +* `tf.errors.exception_type_from_error_code` +* `tf.errors.error_code_from_exception_type` +* `tf.errors.raise_exception_on_not_ok_status` diff --git a/tensorflow/docs_src/api_guides/python/constant_op.md b/tensorflow/docs_src/api_guides/python/constant_op.md index db3410ce22..498ec3db5d 100644 --- a/tensorflow/docs_src/api_guides/python/constant_op.md +++ b/tensorflow/docs_src/api_guides/python/constant_op.md @@ -1,7 +1,7 @@ # Constants, Sequences, and Random Values Note: Functions taking `Tensor` arguments can also take anything accepted by -@{tf.convert_to_tensor}. +`tf.convert_to_tensor`. [TOC] @@ -9,17 +9,17 @@ Note: Functions taking `Tensor` arguments can also take anything accepted by TensorFlow provides several operations that you can use to generate constants. -* @{tf.zeros} -* @{tf.zeros_like} -* @{tf.ones} -* @{tf.ones_like} -* @{tf.fill} -* @{tf.constant} +* `tf.zeros` +* `tf.zeros_like` +* `tf.ones` +* `tf.ones_like` +* `tf.fill` +* `tf.constant` ## Sequences -* @{tf.linspace} -* @{tf.range} +* `tf.linspace` +* `tf.range` ## Random Tensors @@ -29,11 +29,11 @@ time they are evaluated. The `seed` keyword argument in these functions acts in conjunction with the graph-level random seed. Changing either the graph-level seed using -@{tf.set_random_seed} or the +`tf.set_random_seed` or the op-level seed will change the underlying seed of these operations. Setting neither graph-level nor op-level seed, results in a random seed for all operations. -See @{tf.set_random_seed} +See `tf.set_random_seed` for details on the interaction between operation-level and graph-level random seeds. @@ -77,11 +77,11 @@ sess.run(init) print(sess.run(var)) ``` -* @{tf.random_normal} -* @{tf.truncated_normal} -* @{tf.random_uniform} -* @{tf.random_shuffle} -* @{tf.random_crop} -* @{tf.multinomial} -* @{tf.random_gamma} -* @{tf.set_random_seed} +* `tf.random_normal` +* `tf.truncated_normal` +* `tf.random_uniform` +* `tf.random_shuffle` +* `tf.random_crop` +* `tf.multinomial` +* `tf.random_gamma` +* `tf.set_random_seed` diff --git a/tensorflow/docs_src/api_guides/python/contrib.crf.md b/tensorflow/docs_src/api_guides/python/contrib.crf.md index 428383fd41..a544f136b3 100644 --- a/tensorflow/docs_src/api_guides/python/contrib.crf.md +++ b/tensorflow/docs_src/api_guides/python/contrib.crf.md @@ -2,10 +2,10 @@ Linear-chain CRF layer. -* @{tf.contrib.crf.crf_sequence_score} -* @{tf.contrib.crf.crf_log_norm} -* @{tf.contrib.crf.crf_log_likelihood} -* @{tf.contrib.crf.crf_unary_score} -* @{tf.contrib.crf.crf_binary_score} -* @{tf.contrib.crf.CrfForwardRnnCell} -* @{tf.contrib.crf.viterbi_decode} +* `tf.contrib.crf.crf_sequence_score` +* `tf.contrib.crf.crf_log_norm` +* `tf.contrib.crf.crf_log_likelihood` +* `tf.contrib.crf.crf_unary_score` +* `tf.contrib.crf.crf_binary_score` +* `tf.contrib.crf.CrfForwardRnnCell` +* `tf.contrib.crf.viterbi_decode` diff --git a/tensorflow/docs_src/api_guides/python/contrib.ffmpeg.md b/tensorflow/docs_src/api_guides/python/contrib.ffmpeg.md index 27948689c5..7df7547131 100644 --- a/tensorflow/docs_src/api_guides/python/contrib.ffmpeg.md +++ b/tensorflow/docs_src/api_guides/python/contrib.ffmpeg.md @@ -19,5 +19,5 @@ uncompressed_binary = ffmpeg.encode_audio( waveform, file_format='wav', samples_per_second=44100) ``` -* @{tf.contrib.ffmpeg.decode_audio} -* @{tf.contrib.ffmpeg.encode_audio} +* `tf.contrib.ffmpeg.decode_audio` +* `tf.contrib.ffmpeg.encode_audio` diff --git a/tensorflow/docs_src/api_guides/python/contrib.framework.md b/tensorflow/docs_src/api_guides/python/contrib.framework.md index 6b4ce3a14d..00fb8b0ac3 100644 --- a/tensorflow/docs_src/api_guides/python/contrib.framework.md +++ b/tensorflow/docs_src/api_guides/python/contrib.framework.md @@ -3,62 +3,62 @@ Framework utilities. -* @{tf.contrib.framework.assert_same_float_dtype} -* @{tf.contrib.framework.assert_scalar} -* @{tf.contrib.framework.assert_scalar_int} -* @{tf.convert_to_tensor_or_sparse_tensor} -* @{tf.contrib.framework.get_graph_from_inputs} -* @{tf.is_numeric_tensor} -* @{tf.is_non_decreasing} -* @{tf.is_strictly_increasing} -* @{tf.contrib.framework.is_tensor} -* @{tf.contrib.framework.reduce_sum_n} -* @{tf.contrib.framework.remove_squeezable_dimensions} -* @{tf.contrib.framework.with_shape} -* @{tf.contrib.framework.with_same_shape} +* `tf.contrib.framework.assert_same_float_dtype` +* `tf.contrib.framework.assert_scalar` +* `tf.contrib.framework.assert_scalar_int` +* `tf.convert_to_tensor_or_sparse_tensor` +* `tf.contrib.framework.get_graph_from_inputs` +* `tf.is_numeric_tensor` +* `tf.is_non_decreasing` +* `tf.is_strictly_increasing` +* `tf.contrib.framework.is_tensor` +* `tf.contrib.framework.reduce_sum_n` +* `tf.contrib.framework.remove_squeezable_dimensions` +* `tf.contrib.framework.with_shape` +* `tf.contrib.framework.with_same_shape` ## Deprecation -* @{tf.contrib.framework.deprecated} -* @{tf.contrib.framework.deprecated_args} -* @{tf.contrib.framework.deprecated_arg_values} +* `tf.contrib.framework.deprecated` +* `tf.contrib.framework.deprecated_args` +* `tf.contrib.framework.deprecated_arg_values` ## Arg_Scope -* @{tf.contrib.framework.arg_scope} -* @{tf.contrib.framework.add_arg_scope} -* @{tf.contrib.framework.has_arg_scope} -* @{tf.contrib.framework.arg_scoped_arguments} +* `tf.contrib.framework.arg_scope` +* `tf.contrib.framework.add_arg_scope` +* `tf.contrib.framework.has_arg_scope` +* `tf.contrib.framework.arg_scoped_arguments` ## Variables -* @{tf.contrib.framework.add_model_variable} -* @{tf.train.assert_global_step} -* @{tf.contrib.framework.assert_or_get_global_step} -* @{tf.contrib.framework.assign_from_checkpoint} -* @{tf.contrib.framework.assign_from_checkpoint_fn} -* @{tf.contrib.framework.assign_from_values} -* @{tf.contrib.framework.assign_from_values_fn} -* @{tf.contrib.framework.create_global_step} -* @{tf.contrib.framework.filter_variables} -* @{tf.train.get_global_step} -* @{tf.contrib.framework.get_or_create_global_step} -* @{tf.contrib.framework.get_local_variables} -* @{tf.contrib.framework.get_model_variables} -* @{tf.contrib.framework.get_unique_variable} -* @{tf.contrib.framework.get_variables_by_name} -* @{tf.contrib.framework.get_variables_by_suffix} -* @{tf.contrib.framework.get_variables_to_restore} -* @{tf.contrib.framework.get_variables} -* @{tf.contrib.framework.local_variable} -* @{tf.contrib.framework.model_variable} -* @{tf.contrib.framework.variable} -* @{tf.contrib.framework.VariableDeviceChooser} -* @{tf.contrib.framework.zero_initializer} +* `tf.contrib.framework.add_model_variable` +* `tf.train.assert_global_step` +* `tf.contrib.framework.assert_or_get_global_step` +* `tf.contrib.framework.assign_from_checkpoint` +* `tf.contrib.framework.assign_from_checkpoint_fn` +* `tf.contrib.framework.assign_from_values` +* `tf.contrib.framework.assign_from_values_fn` +* `tf.contrib.framework.create_global_step` +* `tf.contrib.framework.filter_variables` +* `tf.train.get_global_step` +* `tf.contrib.framework.get_or_create_global_step` +* `tf.contrib.framework.get_local_variables` +* `tf.contrib.framework.get_model_variables` +* `tf.contrib.framework.get_unique_variable` +* `tf.contrib.framework.get_variables_by_name` +* `tf.contrib.framework.get_variables_by_suffix` +* `tf.contrib.framework.get_variables_to_restore` +* `tf.contrib.framework.get_variables` +* `tf.contrib.framework.local_variable` +* `tf.contrib.framework.model_variable` +* `tf.contrib.framework.variable` +* `tf.contrib.framework.VariableDeviceChooser` +* `tf.contrib.framework.zero_initializer` ## Checkpoint utilities -* @{tf.contrib.framework.load_checkpoint} -* @{tf.contrib.framework.list_variables} -* @{tf.contrib.framework.load_variable} -* @{tf.contrib.framework.init_from_checkpoint} +* `tf.contrib.framework.load_checkpoint` +* `tf.contrib.framework.list_variables` +* `tf.contrib.framework.load_variable` +* `tf.contrib.framework.init_from_checkpoint` diff --git a/tensorflow/docs_src/api_guides/python/contrib.graph_editor.md b/tensorflow/docs_src/api_guides/python/contrib.graph_editor.md index 20fe88a799..8ce49b952b 100644 --- a/tensorflow/docs_src/api_guides/python/contrib.graph_editor.md +++ b/tensorflow/docs_src/api_guides/python/contrib.graph_editor.md @@ -100,78 +100,78 @@ which to operate must always be given explicitly. This is the reason why ## Module: util -* @{tf.contrib.graph_editor.make_list_of_op} -* @{tf.contrib.graph_editor.get_tensors} -* @{tf.contrib.graph_editor.make_list_of_t} -* @{tf.contrib.graph_editor.get_generating_ops} -* @{tf.contrib.graph_editor.get_consuming_ops} -* @{tf.contrib.graph_editor.ControlOutputs} -* @{tf.contrib.graph_editor.placeholder_name} -* @{tf.contrib.graph_editor.make_placeholder_from_tensor} -* @{tf.contrib.graph_editor.make_placeholder_from_dtype_and_shape} +* `tf.contrib.graph_editor.make_list_of_op` +* `tf.contrib.graph_editor.get_tensors` +* `tf.contrib.graph_editor.make_list_of_t` +* `tf.contrib.graph_editor.get_generating_ops` +* `tf.contrib.graph_editor.get_consuming_ops` +* `tf.contrib.graph_editor.ControlOutputs` +* `tf.contrib.graph_editor.placeholder_name` +* `tf.contrib.graph_editor.make_placeholder_from_tensor` +* `tf.contrib.graph_editor.make_placeholder_from_dtype_and_shape` ## Module: select -* @{tf.contrib.graph_editor.filter_ts} -* @{tf.contrib.graph_editor.filter_ts_from_regex} -* @{tf.contrib.graph_editor.filter_ops} -* @{tf.contrib.graph_editor.filter_ops_from_regex} -* @{tf.contrib.graph_editor.get_name_scope_ops} -* @{tf.contrib.graph_editor.check_cios} -* @{tf.contrib.graph_editor.get_ops_ios} -* @{tf.contrib.graph_editor.compute_boundary_ts} -* @{tf.contrib.graph_editor.get_within_boundary_ops} -* @{tf.contrib.graph_editor.get_forward_walk_ops} -* @{tf.contrib.graph_editor.get_backward_walk_ops} -* @{tf.contrib.graph_editor.get_walks_intersection_ops} -* @{tf.contrib.graph_editor.get_walks_union_ops} -* @{tf.contrib.graph_editor.select_ops} -* @{tf.contrib.graph_editor.select_ts} -* @{tf.contrib.graph_editor.select_ops_and_ts} +* `tf.contrib.graph_editor.filter_ts` +* `tf.contrib.graph_editor.filter_ts_from_regex` +* `tf.contrib.graph_editor.filter_ops` +* `tf.contrib.graph_editor.filter_ops_from_regex` +* `tf.contrib.graph_editor.get_name_scope_ops` +* `tf.contrib.graph_editor.check_cios` +* `tf.contrib.graph_editor.get_ops_ios` +* `tf.contrib.graph_editor.compute_boundary_ts` +* `tf.contrib.graph_editor.get_within_boundary_ops` +* `tf.contrib.graph_editor.get_forward_walk_ops` +* `tf.contrib.graph_editor.get_backward_walk_ops` +* `tf.contrib.graph_editor.get_walks_intersection_ops` +* `tf.contrib.graph_editor.get_walks_union_ops` +* `tf.contrib.graph_editor.select_ops` +* `tf.contrib.graph_editor.select_ts` +* `tf.contrib.graph_editor.select_ops_and_ts` ## Module: subgraph -* @{tf.contrib.graph_editor.SubGraphView} -* @{tf.contrib.graph_editor.make_view} -* @{tf.contrib.graph_editor.make_view_from_scope} +* `tf.contrib.graph_editor.SubGraphView` +* `tf.contrib.graph_editor.make_view` +* `tf.contrib.graph_editor.make_view_from_scope` ## Module: reroute -* @{tf.contrib.graph_editor.swap_ts} -* @{tf.contrib.graph_editor.reroute_ts} -* @{tf.contrib.graph_editor.swap_inputs} -* @{tf.contrib.graph_editor.reroute_inputs} -* @{tf.contrib.graph_editor.swap_outputs} -* @{tf.contrib.graph_editor.reroute_outputs} -* @{tf.contrib.graph_editor.swap_ios} -* @{tf.contrib.graph_editor.reroute_ios} -* @{tf.contrib.graph_editor.remove_control_inputs} -* @{tf.contrib.graph_editor.add_control_inputs} +* `tf.contrib.graph_editor.swap_ts` +* `tf.contrib.graph_editor.reroute_ts` +* `tf.contrib.graph_editor.swap_inputs` +* `tf.contrib.graph_editor.reroute_inputs` +* `tf.contrib.graph_editor.swap_outputs` +* `tf.contrib.graph_editor.reroute_outputs` +* `tf.contrib.graph_editor.swap_ios` +* `tf.contrib.graph_editor.reroute_ios` +* `tf.contrib.graph_editor.remove_control_inputs` +* `tf.contrib.graph_editor.add_control_inputs` ## Module: edit -* @{tf.contrib.graph_editor.detach_control_inputs} -* @{tf.contrib.graph_editor.detach_control_outputs} -* @{tf.contrib.graph_editor.detach_inputs} -* @{tf.contrib.graph_editor.detach_outputs} -* @{tf.contrib.graph_editor.detach} -* @{tf.contrib.graph_editor.connect} -* @{tf.contrib.graph_editor.bypass} +* `tf.contrib.graph_editor.detach_control_inputs` +* `tf.contrib.graph_editor.detach_control_outputs` +* `tf.contrib.graph_editor.detach_inputs` +* `tf.contrib.graph_editor.detach_outputs` +* `tf.contrib.graph_editor.detach` +* `tf.contrib.graph_editor.connect` +* `tf.contrib.graph_editor.bypass` ## Module: transform -* @{tf.contrib.graph_editor.replace_t_with_placeholder_handler} -* @{tf.contrib.graph_editor.keep_t_if_possible_handler} -* @{tf.contrib.graph_editor.assign_renamed_collections_handler} -* @{tf.contrib.graph_editor.transform_op_if_inside_handler} -* @{tf.contrib.graph_editor.copy_op_handler} -* @{tf.contrib.graph_editor.Transformer} -* @{tf.contrib.graph_editor.copy} -* @{tf.contrib.graph_editor.copy_with_input_replacements} -* @{tf.contrib.graph_editor.graph_replace} +* `tf.contrib.graph_editor.replace_t_with_placeholder_handler` +* `tf.contrib.graph_editor.keep_t_if_possible_handler` +* `tf.contrib.graph_editor.assign_renamed_collections_handler` +* `tf.contrib.graph_editor.transform_op_if_inside_handler` +* `tf.contrib.graph_editor.copy_op_handler` +* `tf.contrib.graph_editor.Transformer` +* `tf.contrib.graph_editor.copy` +* `tf.contrib.graph_editor.copy_with_input_replacements` +* `tf.contrib.graph_editor.graph_replace` ## Useful aliases -* @{tf.contrib.graph_editor.ph} -* @{tf.contrib.graph_editor.sgv} -* @{tf.contrib.graph_editor.sgv_scope} +* `tf.contrib.graph_editor.ph` +* `tf.contrib.graph_editor.sgv` +* `tf.contrib.graph_editor.sgv_scope` diff --git a/tensorflow/docs_src/api_guides/python/contrib.integrate.md b/tensorflow/docs_src/api_guides/python/contrib.integrate.md index e95b5a2e68..a70d202ab5 100644 --- a/tensorflow/docs_src/api_guides/python/contrib.integrate.md +++ b/tensorflow/docs_src/api_guides/python/contrib.integrate.md @@ -38,4 +38,4 @@ plt.plot(x, z) ## Ops -* @{tf.contrib.integrate.odeint} +* `tf.contrib.integrate.odeint` diff --git a/tensorflow/docs_src/api_guides/python/contrib.layers.md b/tensorflow/docs_src/api_guides/python/contrib.layers.md index b85db4b96f..4c176a129c 100644 --- a/tensorflow/docs_src/api_guides/python/contrib.layers.md +++ b/tensorflow/docs_src/api_guides/python/contrib.layers.md @@ -9,29 +9,29 @@ This package provides several ops that take care of creating variables that are used internally in a consistent way and provide the building blocks for many common machine learning algorithms. -* @{tf.contrib.layers.avg_pool2d} -* @{tf.contrib.layers.batch_norm} -* @{tf.contrib.layers.convolution2d} -* @{tf.contrib.layers.conv2d_in_plane} -* @{tf.contrib.layers.convolution2d_in_plane} -* @{tf.nn.conv2d_transpose} -* @{tf.contrib.layers.convolution2d_transpose} -* @{tf.nn.dropout} -* @{tf.contrib.layers.flatten} -* @{tf.contrib.layers.fully_connected} -* @{tf.contrib.layers.layer_norm} -* @{tf.contrib.layers.max_pool2d} -* @{tf.contrib.layers.one_hot_encoding} -* @{tf.nn.relu} -* @{tf.nn.relu6} -* @{tf.contrib.layers.repeat} -* @{tf.contrib.layers.safe_embedding_lookup_sparse} -* @{tf.nn.separable_conv2d} -* @{tf.contrib.layers.separable_convolution2d} -* @{tf.nn.softmax} -* @{tf.stack} -* @{tf.contrib.layers.unit_norm} -* @{tf.contrib.layers.embed_sequence} +* `tf.contrib.layers.avg_pool2d` +* `tf.contrib.layers.batch_norm` +* `tf.contrib.layers.convolution2d` +* `tf.contrib.layers.conv2d_in_plane` +* `tf.contrib.layers.convolution2d_in_plane` +* `tf.nn.conv2d_transpose` +* `tf.contrib.layers.convolution2d_transpose` +* `tf.nn.dropout` +* `tf.contrib.layers.flatten` +* `tf.contrib.layers.fully_connected` +* `tf.contrib.layers.layer_norm` +* `tf.contrib.layers.max_pool2d` +* `tf.contrib.layers.one_hot_encoding` +* `tf.nn.relu` +* `tf.nn.relu6` +* `tf.contrib.layers.repeat` +* `tf.contrib.layers.safe_embedding_lookup_sparse` +* `tf.nn.separable_conv2d` +* `tf.contrib.layers.separable_convolution2d` +* `tf.nn.softmax` +* `tf.stack` +* `tf.contrib.layers.unit_norm` +* `tf.contrib.layers.embed_sequence` Aliases for fully_connected which set a default activation function are available: `relu`, `relu6` and `linear`. @@ -45,65 +45,65 @@ Regularization can help prevent overfitting. These have the signature `fn(weights)`. The loss is typically added to `tf.GraphKeys.REGULARIZATION_LOSSES`. -* @{tf.contrib.layers.apply_regularization} -* @{tf.contrib.layers.l1_regularizer} -* @{tf.contrib.layers.l2_regularizer} -* @{tf.contrib.layers.sum_regularizer} +* `tf.contrib.layers.apply_regularization` +* `tf.contrib.layers.l1_regularizer` +* `tf.contrib.layers.l2_regularizer` +* `tf.contrib.layers.sum_regularizer` ## Initializers Initializers are used to initialize variables with sensible values given their size, data type, and purpose. -* @{tf.contrib.layers.xavier_initializer} -* @{tf.contrib.layers.xavier_initializer_conv2d} -* @{tf.contrib.layers.variance_scaling_initializer} +* `tf.contrib.layers.xavier_initializer` +* `tf.contrib.layers.xavier_initializer_conv2d` +* `tf.contrib.layers.variance_scaling_initializer` ## Optimization Optimize weights given a loss. -* @{tf.contrib.layers.optimize_loss} +* `tf.contrib.layers.optimize_loss` ## Summaries Helper functions to summarize specific variables or ops. -* @{tf.contrib.layers.summarize_activation} -* @{tf.contrib.layers.summarize_tensor} -* @{tf.contrib.layers.summarize_tensors} -* @{tf.contrib.layers.summarize_collection} +* `tf.contrib.layers.summarize_activation` +* `tf.contrib.layers.summarize_tensor` +* `tf.contrib.layers.summarize_tensors` +* `tf.contrib.layers.summarize_collection` The layers module defines convenience functions `summarize_variables`, `summarize_weights` and `summarize_biases`, which set the `collection` argument of `summarize_collection` to `VARIABLES`, `WEIGHTS` and `BIASES`, respectively. -* @{tf.contrib.layers.summarize_activations} +* `tf.contrib.layers.summarize_activations` ## Feature columns Feature columns provide a mechanism to map data to a model. -* @{tf.contrib.layers.bucketized_column} -* @{tf.contrib.layers.check_feature_columns} -* @{tf.contrib.layers.create_feature_spec_for_parsing} -* @{tf.contrib.layers.crossed_column} -* @{tf.contrib.layers.embedding_column} -* @{tf.contrib.layers.scattered_embedding_column} -* @{tf.contrib.layers.input_from_feature_columns} -* @{tf.contrib.layers.joint_weighted_sum_from_feature_columns} -* @{tf.contrib.layers.make_place_holder_tensors_for_base_features} -* @{tf.contrib.layers.multi_class_target} -* @{tf.contrib.layers.one_hot_column} -* @{tf.contrib.layers.parse_feature_columns_from_examples} -* @{tf.contrib.layers.parse_feature_columns_from_sequence_examples} -* @{tf.contrib.layers.real_valued_column} -* @{tf.contrib.layers.shared_embedding_columns} -* @{tf.contrib.layers.sparse_column_with_hash_bucket} -* @{tf.contrib.layers.sparse_column_with_integerized_feature} -* @{tf.contrib.layers.sparse_column_with_keys} -* @{tf.contrib.layers.sparse_column_with_vocabulary_file} -* @{tf.contrib.layers.weighted_sparse_column} -* @{tf.contrib.layers.weighted_sum_from_feature_columns} -* @{tf.contrib.layers.infer_real_valued_columns} -* @{tf.contrib.layers.sequence_input_from_feature_columns} +* `tf.contrib.layers.bucketized_column` +* `tf.contrib.layers.check_feature_columns` +* `tf.contrib.layers.create_feature_spec_for_parsing` +* `tf.contrib.layers.crossed_column` +* `tf.contrib.layers.embedding_column` +* `tf.contrib.layers.scattered_embedding_column` +* `tf.contrib.layers.input_from_feature_columns` +* `tf.contrib.layers.joint_weighted_sum_from_feature_columns` +* `tf.contrib.layers.make_place_holder_tensors_for_base_features` +* `tf.contrib.layers.multi_class_target` +* `tf.contrib.layers.one_hot_column` +* `tf.contrib.layers.parse_feature_columns_from_examples` +* `tf.contrib.layers.parse_feature_columns_from_sequence_examples` +* `tf.contrib.layers.real_valued_column` +* `tf.contrib.layers.shared_embedding_columns` +* `tf.contrib.layers.sparse_column_with_hash_bucket` +* `tf.contrib.layers.sparse_column_with_integerized_feature` +* `tf.contrib.layers.sparse_column_with_keys` +* `tf.contrib.layers.sparse_column_with_vocabulary_file` +* `tf.contrib.layers.weighted_sparse_column` +* `tf.contrib.layers.weighted_sum_from_feature_columns` +* `tf.contrib.layers.infer_real_valued_columns` +* `tf.contrib.layers.sequence_input_from_feature_columns` diff --git a/tensorflow/docs_src/api_guides/python/contrib.learn.md b/tensorflow/docs_src/api_guides/python/contrib.learn.md index 03838dc5ae..635849ead5 100644 --- a/tensorflow/docs_src/api_guides/python/contrib.learn.md +++ b/tensorflow/docs_src/api_guides/python/contrib.learn.md @@ -7,57 +7,57 @@ High level API for learning with TensorFlow. Train and evaluate TensorFlow models. -* @{tf.contrib.learn.BaseEstimator} -* @{tf.contrib.learn.Estimator} -* @{tf.contrib.learn.Trainable} -* @{tf.contrib.learn.Evaluable} -* @{tf.contrib.learn.KMeansClustering} -* @{tf.contrib.learn.ModeKeys} -* @{tf.contrib.learn.ModelFnOps} -* @{tf.contrib.learn.MetricSpec} -* @{tf.contrib.learn.PredictionKey} -* @{tf.contrib.learn.DNNClassifier} -* @{tf.contrib.learn.DNNRegressor} -* @{tf.contrib.learn.DNNLinearCombinedRegressor} -* @{tf.contrib.learn.DNNLinearCombinedClassifier} -* @{tf.contrib.learn.LinearClassifier} -* @{tf.contrib.learn.LinearRegressor} -* @{tf.contrib.learn.LogisticRegressor} +* `tf.contrib.learn.BaseEstimator` +* `tf.contrib.learn.Estimator` +* `tf.contrib.learn.Trainable` +* `tf.contrib.learn.Evaluable` +* `tf.contrib.learn.KMeansClustering` +* `tf.contrib.learn.ModeKeys` +* `tf.contrib.learn.ModelFnOps` +* `tf.contrib.learn.MetricSpec` +* `tf.contrib.learn.PredictionKey` +* `tf.contrib.learn.DNNClassifier` +* `tf.contrib.learn.DNNRegressor` +* `tf.contrib.learn.DNNLinearCombinedRegressor` +* `tf.contrib.learn.DNNLinearCombinedClassifier` +* `tf.contrib.learn.LinearClassifier` +* `tf.contrib.learn.LinearRegressor` +* `tf.contrib.learn.LogisticRegressor` ## Distributed training utilities -* @{tf.contrib.learn.Experiment} -* @{tf.contrib.learn.ExportStrategy} -* @{tf.contrib.learn.TaskType} +* `tf.contrib.learn.Experiment` +* `tf.contrib.learn.ExportStrategy` +* `tf.contrib.learn.TaskType` ## Graph actions Perform various training, evaluation, and inference actions on a graph. -* @{tf.train.NanLossDuringTrainingError} -* @{tf.contrib.learn.RunConfig} -* @{tf.contrib.learn.evaluate} -* @{tf.contrib.learn.infer} -* @{tf.contrib.learn.run_feeds} -* @{tf.contrib.learn.run_n} -* @{tf.contrib.learn.train} +* `tf.train.NanLossDuringTrainingError` +* `tf.contrib.learn.RunConfig` +* `tf.contrib.learn.evaluate` +* `tf.contrib.learn.infer` +* `tf.contrib.learn.run_feeds` +* `tf.contrib.learn.run_n` +* `tf.contrib.learn.train` ## Input processing Queue and read batched input data. -* @{tf.contrib.learn.extract_dask_data} -* @{tf.contrib.learn.extract_dask_labels} -* @{tf.contrib.learn.extract_pandas_data} -* @{tf.contrib.learn.extract_pandas_labels} -* @{tf.contrib.learn.extract_pandas_matrix} -* @{tf.contrib.learn.infer_real_valued_columns_from_input} -* @{tf.contrib.learn.infer_real_valued_columns_from_input_fn} -* @{tf.contrib.learn.read_batch_examples} -* @{tf.contrib.learn.read_batch_features} -* @{tf.contrib.learn.read_batch_record_features} +* `tf.contrib.learn.extract_dask_data` +* `tf.contrib.learn.extract_dask_labels` +* `tf.contrib.learn.extract_pandas_data` +* `tf.contrib.learn.extract_pandas_labels` +* `tf.contrib.learn.extract_pandas_matrix` +* `tf.contrib.learn.infer_real_valued_columns_from_input` +* `tf.contrib.learn.infer_real_valued_columns_from_input_fn` +* `tf.contrib.learn.read_batch_examples` +* `tf.contrib.learn.read_batch_features` +* `tf.contrib.learn.read_batch_record_features` Export utilities -* @{tf.contrib.learn.build_parsing_serving_input_fn} -* @{tf.contrib.learn.ProblemType} +* `tf.contrib.learn.build_parsing_serving_input_fn` +* `tf.contrib.learn.ProblemType` diff --git a/tensorflow/docs_src/api_guides/python/contrib.linalg.md b/tensorflow/docs_src/api_guides/python/contrib.linalg.md index c0cb2b195c..3055449dc2 100644 --- a/tensorflow/docs_src/api_guides/python/contrib.linalg.md +++ b/tensorflow/docs_src/api_guides/python/contrib.linalg.md @@ -14,17 +14,17 @@ Subclasses of `LinearOperator` provide a access to common methods on a ### Base class -* @{tf.contrib.linalg.LinearOperator} +* `tf.contrib.linalg.LinearOperator` ### Individual operators -* @{tf.contrib.linalg.LinearOperatorDiag} -* @{tf.contrib.linalg.LinearOperatorIdentity} -* @{tf.contrib.linalg.LinearOperatorScaledIdentity} -* @{tf.contrib.linalg.LinearOperatorFullMatrix} -* @{tf.contrib.linalg.LinearOperatorLowerTriangular} -* @{tf.contrib.linalg.LinearOperatorLowRankUpdate} +* `tf.contrib.linalg.LinearOperatorDiag` +* `tf.contrib.linalg.LinearOperatorIdentity` +* `tf.contrib.linalg.LinearOperatorScaledIdentity` +* `tf.contrib.linalg.LinearOperatorFullMatrix` +* `tf.contrib.linalg.LinearOperatorLowerTriangular` +* `tf.contrib.linalg.LinearOperatorLowRankUpdate` ### Transformations and Combinations of operators -* @{tf.contrib.linalg.LinearOperatorComposition} +* `tf.contrib.linalg.LinearOperatorComposition` diff --git a/tensorflow/docs_src/api_guides/python/contrib.losses.md b/tensorflow/docs_src/api_guides/python/contrib.losses.md index 8b7442216c..8787454af6 100644 --- a/tensorflow/docs_src/api_guides/python/contrib.losses.md +++ b/tensorflow/docs_src/api_guides/python/contrib.losses.md @@ -2,7 +2,7 @@ ## Deprecated -This module is deprecated. Instructions for updating: Use @{tf.losses} instead. +This module is deprecated. Instructions for updating: Use `tf.losses` instead. ## Loss operations for use in neural networks. @@ -107,19 +107,19 @@ weighted average over the individual prediction errors: loss = tf.contrib.losses.mean_squared_error(predictions, depths, weight) ``` -* @{tf.contrib.losses.absolute_difference} -* @{tf.contrib.losses.add_loss} -* @{tf.contrib.losses.hinge_loss} -* @{tf.contrib.losses.compute_weighted_loss} -* @{tf.contrib.losses.cosine_distance} -* @{tf.contrib.losses.get_losses} -* @{tf.contrib.losses.get_regularization_losses} -* @{tf.contrib.losses.get_total_loss} -* @{tf.contrib.losses.log_loss} -* @{tf.contrib.losses.mean_pairwise_squared_error} -* @{tf.contrib.losses.mean_squared_error} -* @{tf.contrib.losses.sigmoid_cross_entropy} -* @{tf.contrib.losses.softmax_cross_entropy} -* @{tf.contrib.losses.sparse_softmax_cross_entropy} +* `tf.contrib.losses.absolute_difference` +* `tf.contrib.losses.add_loss` +* `tf.contrib.losses.hinge_loss` +* `tf.contrib.losses.compute_weighted_loss` +* `tf.contrib.losses.cosine_distance` +* `tf.contrib.losses.get_losses` +* `tf.contrib.losses.get_regularization_losses` +* `tf.contrib.losses.get_total_loss` +* `tf.contrib.losses.log_loss` +* `tf.contrib.losses.mean_pairwise_squared_error` +* `tf.contrib.losses.mean_squared_error` +* `tf.contrib.losses.sigmoid_cross_entropy` +* `tf.contrib.losses.softmax_cross_entropy` +* `tf.contrib.losses.sparse_softmax_cross_entropy` diff --git a/tensorflow/docs_src/api_guides/python/contrib.metrics.md b/tensorflow/docs_src/api_guides/python/contrib.metrics.md index 1eb9cf417a..de6346ca80 100644 --- a/tensorflow/docs_src/api_guides/python/contrib.metrics.md +++ b/tensorflow/docs_src/api_guides/python/contrib.metrics.md @@ -86,48 +86,48 @@ labels and predictions tensors and results in a weighted average of the metric. ## Metric `Ops` -* @{tf.contrib.metrics.streaming_accuracy} -* @{tf.contrib.metrics.streaming_mean} -* @{tf.contrib.metrics.streaming_recall} -* @{tf.contrib.metrics.streaming_recall_at_thresholds} -* @{tf.contrib.metrics.streaming_precision} -* @{tf.contrib.metrics.streaming_precision_at_thresholds} -* @{tf.contrib.metrics.streaming_auc} -* @{tf.contrib.metrics.streaming_recall_at_k} -* @{tf.contrib.metrics.streaming_mean_absolute_error} -* @{tf.contrib.metrics.streaming_mean_iou} -* @{tf.contrib.metrics.streaming_mean_relative_error} -* @{tf.contrib.metrics.streaming_mean_squared_error} -* @{tf.contrib.metrics.streaming_mean_tensor} -* @{tf.contrib.metrics.streaming_root_mean_squared_error} -* @{tf.contrib.metrics.streaming_covariance} -* @{tf.contrib.metrics.streaming_pearson_correlation} -* @{tf.contrib.metrics.streaming_mean_cosine_distance} -* @{tf.contrib.metrics.streaming_percentage_less} -* @{tf.contrib.metrics.streaming_sensitivity_at_specificity} -* @{tf.contrib.metrics.streaming_sparse_average_precision_at_k} -* @{tf.contrib.metrics.streaming_sparse_precision_at_k} -* @{tf.contrib.metrics.streaming_sparse_precision_at_top_k} -* @{tf.contrib.metrics.streaming_sparse_recall_at_k} -* @{tf.contrib.metrics.streaming_specificity_at_sensitivity} -* @{tf.contrib.metrics.streaming_concat} -* @{tf.contrib.metrics.streaming_false_negatives} -* @{tf.contrib.metrics.streaming_false_negatives_at_thresholds} -* @{tf.contrib.metrics.streaming_false_positives} -* @{tf.contrib.metrics.streaming_false_positives_at_thresholds} -* @{tf.contrib.metrics.streaming_true_negatives} -* @{tf.contrib.metrics.streaming_true_negatives_at_thresholds} -* @{tf.contrib.metrics.streaming_true_positives} -* @{tf.contrib.metrics.streaming_true_positives_at_thresholds} -* @{tf.contrib.metrics.auc_using_histogram} -* @{tf.contrib.metrics.accuracy} -* @{tf.contrib.metrics.aggregate_metrics} -* @{tf.contrib.metrics.aggregate_metric_map} -* @{tf.contrib.metrics.confusion_matrix} +* `tf.contrib.metrics.streaming_accuracy` +* `tf.contrib.metrics.streaming_mean` +* `tf.contrib.metrics.streaming_recall` +* `tf.contrib.metrics.streaming_recall_at_thresholds` +* `tf.contrib.metrics.streaming_precision` +* `tf.contrib.metrics.streaming_precision_at_thresholds` +* `tf.contrib.metrics.streaming_auc` +* `tf.contrib.metrics.streaming_recall_at_k` +* `tf.contrib.metrics.streaming_mean_absolute_error` +* `tf.contrib.metrics.streaming_mean_iou` +* `tf.contrib.metrics.streaming_mean_relative_error` +* `tf.contrib.metrics.streaming_mean_squared_error` +* `tf.contrib.metrics.streaming_mean_tensor` +* `tf.contrib.metrics.streaming_root_mean_squared_error` +* `tf.contrib.metrics.streaming_covariance` +* `tf.contrib.metrics.streaming_pearson_correlation` +* `tf.contrib.metrics.streaming_mean_cosine_distance` +* `tf.contrib.metrics.streaming_percentage_less` +* `tf.contrib.metrics.streaming_sensitivity_at_specificity` +* `tf.contrib.metrics.streaming_sparse_average_precision_at_k` +* `tf.contrib.metrics.streaming_sparse_precision_at_k` +* `tf.contrib.metrics.streaming_sparse_precision_at_top_k` +* `tf.contrib.metrics.streaming_sparse_recall_at_k` +* `tf.contrib.metrics.streaming_specificity_at_sensitivity` +* `tf.contrib.metrics.streaming_concat` +* `tf.contrib.metrics.streaming_false_negatives` +* `tf.contrib.metrics.streaming_false_negatives_at_thresholds` +* `tf.contrib.metrics.streaming_false_positives` +* `tf.contrib.metrics.streaming_false_positives_at_thresholds` +* `tf.contrib.metrics.streaming_true_negatives` +* `tf.contrib.metrics.streaming_true_negatives_at_thresholds` +* `tf.contrib.metrics.streaming_true_positives` +* `tf.contrib.metrics.streaming_true_positives_at_thresholds` +* `tf.contrib.metrics.auc_using_histogram` +* `tf.contrib.metrics.accuracy` +* `tf.contrib.metrics.aggregate_metrics` +* `tf.contrib.metrics.aggregate_metric_map` +* `tf.contrib.metrics.confusion_matrix` ## Set `Ops` -* @{tf.contrib.metrics.set_difference} -* @{tf.contrib.metrics.set_intersection} -* @{tf.contrib.metrics.set_size} -* @{tf.contrib.metrics.set_union} +* `tf.contrib.metrics.set_difference` +* `tf.contrib.metrics.set_intersection` +* `tf.contrib.metrics.set_size` +* `tf.contrib.metrics.set_union` diff --git a/tensorflow/docs_src/api_guides/python/contrib.rnn.md b/tensorflow/docs_src/api_guides/python/contrib.rnn.md index d089b0616f..d265ab6925 100644 --- a/tensorflow/docs_src/api_guides/python/contrib.rnn.md +++ b/tensorflow/docs_src/api_guides/python/contrib.rnn.md @@ -5,49 +5,49 @@ Module for constructing RNN Cells and additional RNN operations. ## Base interface for all RNN Cells -* @{tf.contrib.rnn.RNNCell} +* `tf.contrib.rnn.RNNCell` ## Core RNN Cells for use with TensorFlow's core RNN methods -* @{tf.contrib.rnn.BasicRNNCell} -* @{tf.contrib.rnn.BasicLSTMCell} -* @{tf.contrib.rnn.GRUCell} -* @{tf.contrib.rnn.LSTMCell} -* @{tf.contrib.rnn.LayerNormBasicLSTMCell} +* `tf.contrib.rnn.BasicRNNCell` +* `tf.contrib.rnn.BasicLSTMCell` +* `tf.contrib.rnn.GRUCell` +* `tf.contrib.rnn.LSTMCell` +* `tf.contrib.rnn.LayerNormBasicLSTMCell` ## Classes storing split `RNNCell` state -* @{tf.contrib.rnn.LSTMStateTuple} +* `tf.contrib.rnn.LSTMStateTuple` ## Core RNN Cell wrappers (RNNCells that wrap other RNNCells) -* @{tf.contrib.rnn.MultiRNNCell} -* @{tf.contrib.rnn.LSTMBlockWrapper} -* @{tf.contrib.rnn.DropoutWrapper} -* @{tf.contrib.rnn.EmbeddingWrapper} -* @{tf.contrib.rnn.InputProjectionWrapper} -* @{tf.contrib.rnn.OutputProjectionWrapper} -* @{tf.contrib.rnn.DeviceWrapper} -* @{tf.contrib.rnn.ResidualWrapper} +* `tf.contrib.rnn.MultiRNNCell` +* `tf.contrib.rnn.LSTMBlockWrapper` +* `tf.contrib.rnn.DropoutWrapper` +* `tf.contrib.rnn.EmbeddingWrapper` +* `tf.contrib.rnn.InputProjectionWrapper` +* `tf.contrib.rnn.OutputProjectionWrapper` +* `tf.contrib.rnn.DeviceWrapper` +* `tf.contrib.rnn.ResidualWrapper` ### Block RNNCells -* @{tf.contrib.rnn.LSTMBlockCell} -* @{tf.contrib.rnn.GRUBlockCell} +* `tf.contrib.rnn.LSTMBlockCell` +* `tf.contrib.rnn.GRUBlockCell` ### Fused RNNCells -* @{tf.contrib.rnn.FusedRNNCell} -* @{tf.contrib.rnn.FusedRNNCellAdaptor} -* @{tf.contrib.rnn.TimeReversedFusedRNN} -* @{tf.contrib.rnn.LSTMBlockFusedCell} +* `tf.contrib.rnn.FusedRNNCell` +* `tf.contrib.rnn.FusedRNNCellAdaptor` +* `tf.contrib.rnn.TimeReversedFusedRNN` +* `tf.contrib.rnn.LSTMBlockFusedCell` ### LSTM-like cells -* @{tf.contrib.rnn.CoupledInputForgetGateLSTMCell} -* @{tf.contrib.rnn.TimeFreqLSTMCell} -* @{tf.contrib.rnn.GridLSTMCell} +* `tf.contrib.rnn.CoupledInputForgetGateLSTMCell` +* `tf.contrib.rnn.TimeFreqLSTMCell` +* `tf.contrib.rnn.GridLSTMCell` ### RNNCell wrappers -* @{tf.contrib.rnn.AttentionCellWrapper} -* @{tf.contrib.rnn.CompiledWrapper} +* `tf.contrib.rnn.AttentionCellWrapper` +* `tf.contrib.rnn.CompiledWrapper` ## Recurrent Neural Networks @@ -55,7 +55,7 @@ Module for constructing RNN Cells and additional RNN operations. TensorFlow provides a number of methods for constructing Recurrent Neural Networks. -* @{tf.contrib.rnn.static_rnn} -* @{tf.contrib.rnn.static_state_saving_rnn} -* @{tf.contrib.rnn.static_bidirectional_rnn} -* @{tf.contrib.rnn.stack_bidirectional_dynamic_rnn} +* `tf.contrib.rnn.static_rnn` +* `tf.contrib.rnn.static_state_saving_rnn` +* `tf.contrib.rnn.static_bidirectional_rnn` +* `tf.contrib.rnn.stack_bidirectional_dynamic_rnn` diff --git a/tensorflow/docs_src/api_guides/python/contrib.seq2seq.md b/tensorflow/docs_src/api_guides/python/contrib.seq2seq.md index 143919fd84..54f2fafc71 100644 --- a/tensorflow/docs_src/api_guides/python/contrib.seq2seq.md +++ b/tensorflow/docs_src/api_guides/python/contrib.seq2seq.md @@ -2,18 +2,18 @@ [TOC] Module for constructing seq2seq models and dynamic decoding. Builds on top of -libraries in @{tf.contrib.rnn}. +libraries in `tf.contrib.rnn`. This library is composed of two primary components: -* New attention wrappers for @{tf.contrib.rnn.RNNCell} objects. +* New attention wrappers for `tf.contrib.rnn.RNNCell` objects. * A new object-oriented dynamic decoding framework. ## Attention Attention wrappers are `RNNCell` objects that wrap other `RNNCell` objects and implement attention. The form of attention is determined by a subclass of -@{tf.contrib.seq2seq.AttentionMechanism}. These subclasses describe the form +`tf.contrib.seq2seq.AttentionMechanism`. These subclasses describe the form of attention (e.g. additive vs. multiplicative) to use when creating the wrapper. An instance of an `AttentionMechanism` is constructed with a `memory` tensor, from which lookup keys and values tensors are created. @@ -22,9 +22,9 @@ wrapper. An instance of an `AttentionMechanism` is constructed with a The two basic attention mechanisms are: -* @{tf.contrib.seq2seq.BahdanauAttention} (additive attention, +* `tf.contrib.seq2seq.BahdanauAttention` (additive attention, [ref.](https://arxiv.org/abs/1409.0473)) -* @{tf.contrib.seq2seq.LuongAttention} (multiplicative attention, +* `tf.contrib.seq2seq.LuongAttention` (multiplicative attention, [ref.](https://arxiv.org/abs/1508.04025)) The `memory` tensor passed the attention mechanism's constructor is expected to @@ -41,7 +41,7 @@ depth. ### Attention Wrappers -The basic attention wrapper is @{tf.contrib.seq2seq.AttentionWrapper}. +The basic attention wrapper is `tf.contrib.seq2seq.AttentionWrapper`. This wrapper accepts an `RNNCell` instance, an instance of `AttentionMechanism`, and an attention depth parameter (`attention_size`); as well as several optional arguments that allow one to customize intermediate calculations. @@ -120,19 +120,19 @@ outputs, _ = tf.contrib.seq2seq.dynamic_decode( ### Decoder base class and functions -* @{tf.contrib.seq2seq.Decoder} -* @{tf.contrib.seq2seq.dynamic_decode} +* `tf.contrib.seq2seq.Decoder` +* `tf.contrib.seq2seq.dynamic_decode` ### Basic Decoder -* @{tf.contrib.seq2seq.BasicDecoderOutput} -* @{tf.contrib.seq2seq.BasicDecoder} +* `tf.contrib.seq2seq.BasicDecoderOutput` +* `tf.contrib.seq2seq.BasicDecoder` ### Decoder Helpers -* @{tf.contrib.seq2seq.Helper} -* @{tf.contrib.seq2seq.CustomHelper} -* @{tf.contrib.seq2seq.GreedyEmbeddingHelper} -* @{tf.contrib.seq2seq.ScheduledEmbeddingTrainingHelper} -* @{tf.contrib.seq2seq.ScheduledOutputTrainingHelper} -* @{tf.contrib.seq2seq.TrainingHelper} +* `tf.contrib.seq2seq.Helper` +* `tf.contrib.seq2seq.CustomHelper` +* `tf.contrib.seq2seq.GreedyEmbeddingHelper` +* `tf.contrib.seq2seq.ScheduledEmbeddingTrainingHelper` +* `tf.contrib.seq2seq.ScheduledOutputTrainingHelper` +* `tf.contrib.seq2seq.TrainingHelper` diff --git a/tensorflow/docs_src/api_guides/python/contrib.signal.md b/tensorflow/docs_src/api_guides/python/contrib.signal.md index 0f7690f80a..66df561084 100644 --- a/tensorflow/docs_src/api_guides/python/contrib.signal.md +++ b/tensorflow/docs_src/api_guides/python/contrib.signal.md @@ -1,7 +1,7 @@ # Signal Processing (contrib) [TOC] -@{tf.contrib.signal} is a module for signal processing primitives. All +`tf.contrib.signal` is a module for signal processing primitives. All operations have GPU support and are differentiable. This module is especially helpful for building TensorFlow models that process or generate audio, though the techniques are useful in many domains. @@ -10,7 +10,7 @@ the techniques are useful in many domains. When dealing with variable length signals (e.g. audio) it is common to "frame" them into multiple fixed length windows. These windows can overlap if the 'step' -of the frame is less than the frame length. @{tf.contrib.signal.frame} does +of the frame is less than the frame length. `tf.contrib.signal.frame` does exactly this. For example: ```python @@ -24,7 +24,7 @@ signals = tf.placeholder(tf.float32, [None, None]) frames = tf.contrib.signal.frame(signals, frame_length=128, frame_step=32) ``` -The `axis` parameter to @{tf.contrib.signal.frame} allows you to frame tensors +The `axis` parameter to `tf.contrib.signal.frame` allows you to frame tensors with inner structure (e.g. a spectrogram): ```python @@ -42,7 +42,7 @@ spectrogram_patches = tf.contrib.signal.frame( ## Reconstructing framed sequences and applying a tapering window -@{tf.contrib.signal.overlap_and_add} can be used to reconstruct a signal from a +`tf.contrib.signal.overlap_and_add` can be used to reconstruct a signal from a framed representation. For example, the following code reconstructs the signal produced in the preceding example: @@ -58,7 +58,7 @@ the resulting reconstruction will have a greater magnitude than the original window function satisfies the Constant Overlap-Add (COLA) property for the given frame step, then it will recover the original `signals`. -@{tf.contrib.signal.hamming_window} and @{tf.contrib.signal.hann_window} both +`tf.contrib.signal.hamming_window` and `tf.contrib.signal.hann_window` both satisfy the COLA property for a 75% overlap. ```python @@ -74,7 +74,7 @@ reconstructed_signals = tf.contrib.signal.overlap_and_add( A spectrogram is a time-frequency decomposition of a signal that indicates its frequency content over time. The most common approach to computing spectrograms is to take the magnitude of the [Short-time Fourier Transform][stft] (STFT), -which @{tf.contrib.signal.stft} can compute as follows: +which `tf.contrib.signal.stft` can compute as follows: ```python # A batch of float32 time-domain signals in the range [-1, 1] with shape @@ -121,7 +121,7 @@ When working with spectral representations of audio, the [mel scale][mel] is a common reweighting of the frequency dimension, which results in a lower-dimensional and more perceptually-relevant representation of the audio. -@{tf.contrib.signal.linear_to_mel_weight_matrix} produces a matrix you can use +`tf.contrib.signal.linear_to_mel_weight_matrix` produces a matrix you can use to convert a spectrogram to the mel scale. ```python @@ -156,7 +156,7 @@ log_mel_spectrograms = tf.log(mel_spectrograms + log_offset) ## Computing Mel-Frequency Cepstral Coefficients (MFCCs) -Call @{tf.contrib.signal.mfccs_from_log_mel_spectrograms} to compute +Call `tf.contrib.signal.mfccs_from_log_mel_spectrograms` to compute [MFCCs][mfcc] from log-magnitude, mel-scale spectrograms (as computed in the preceding example): diff --git a/tensorflow/docs_src/api_guides/python/contrib.staging.md b/tensorflow/docs_src/api_guides/python/contrib.staging.md index b0ac548342..de143a7bd3 100644 --- a/tensorflow/docs_src/api_guides/python/contrib.staging.md +++ b/tensorflow/docs_src/api_guides/python/contrib.staging.md @@ -3,4 +3,4 @@ This library contains utilities for adding pipelining to a model. -* @{tf.contrib.staging.StagingArea} +* `tf.contrib.staging.StagingArea` diff --git a/tensorflow/docs_src/api_guides/python/contrib.training.md b/tensorflow/docs_src/api_guides/python/contrib.training.md index 87395d930b..068efdc829 100644 --- a/tensorflow/docs_src/api_guides/python/contrib.training.md +++ b/tensorflow/docs_src/api_guides/python/contrib.training.md @@ -5,46 +5,46 @@ Training and input utilities. ## Splitting sequence inputs into minibatches with state saving -Use @{tf.contrib.training.SequenceQueueingStateSaver} or -its wrapper @{tf.contrib.training.batch_sequences_with_states} if +Use `tf.contrib.training.SequenceQueueingStateSaver` or +its wrapper `tf.contrib.training.batch_sequences_with_states` if you have input data with a dynamic primary time / frame count axis which you'd like to convert into fixed size segments during minibatching, and would like to store state in the forward direction across segments of an example. -* @{tf.contrib.training.batch_sequences_with_states} -* @{tf.contrib.training.NextQueuedSequenceBatch} -* @{tf.contrib.training.SequenceQueueingStateSaver} +* `tf.contrib.training.batch_sequences_with_states` +* `tf.contrib.training.NextQueuedSequenceBatch` +* `tf.contrib.training.SequenceQueueingStateSaver` ## Online data resampling To resample data with replacement on a per-example basis, use -@{tf.contrib.training.rejection_sample} or -@{tf.contrib.training.resample_at_rate}. For `rejection_sample`, provide +`tf.contrib.training.rejection_sample` or +`tf.contrib.training.resample_at_rate`. For `rejection_sample`, provide a boolean Tensor describing whether to accept or reject. Resulting batch sizes are always the same. For `resample_at_rate`, provide the desired rate for each example. Resulting batch sizes may vary. If you wish to specify relative -rates, rather than absolute ones, use @{tf.contrib.training.weighted_resample} +rates, rather than absolute ones, use `tf.contrib.training.weighted_resample` (which also returns the actual resampling rate used for each output example). -Use @{tf.contrib.training.stratified_sample} to resample without replacement +Use `tf.contrib.training.stratified_sample` to resample without replacement from the data to achieve a desired mix of class proportions that the Tensorflow graph sees. For instance, if you have a binary classification dataset that is 99.9% class 1, a common approach is to resample from the data so that the data is more balanced. -* @{tf.contrib.training.rejection_sample} -* @{tf.contrib.training.resample_at_rate} -* @{tf.contrib.training.stratified_sample} -* @{tf.contrib.training.weighted_resample} +* `tf.contrib.training.rejection_sample` +* `tf.contrib.training.resample_at_rate` +* `tf.contrib.training.stratified_sample` +* `tf.contrib.training.weighted_resample` ## Bucketing -Use @{tf.contrib.training.bucket} or -@{tf.contrib.training.bucket_by_sequence_length} to stratify +Use `tf.contrib.training.bucket` or +`tf.contrib.training.bucket_by_sequence_length` to stratify minibatches into groups ("buckets"). Use `bucket_by_sequence_length` with the argument `dynamic_pad=True` to receive minibatches of similarly sized sequences for efficient training via `dynamic_rnn`. -* @{tf.contrib.training.bucket} -* @{tf.contrib.training.bucket_by_sequence_length} +* `tf.contrib.training.bucket` +* `tf.contrib.training.bucket_by_sequence_length` diff --git a/tensorflow/docs_src/api_guides/python/contrib.util.md b/tensorflow/docs_src/api_guides/python/contrib.util.md index 6bc120d43d..e5fd97e9f2 100644 --- a/tensorflow/docs_src/api_guides/python/contrib.util.md +++ b/tensorflow/docs_src/api_guides/python/contrib.util.md @@ -5,8 +5,8 @@ Utilities for dealing with Tensors. ## Miscellaneous Utility Functions -* @{tf.contrib.util.constant_value} -* @{tf.contrib.util.make_tensor_proto} -* @{tf.contrib.util.make_ndarray} -* @{tf.contrib.util.ops_used_by_graph_def} -* @{tf.contrib.util.stripped_op_list_for_graph} +* `tf.contrib.util.constant_value` +* `tf.contrib.util.make_tensor_proto` +* `tf.contrib.util.make_ndarray` +* `tf.contrib.util.ops_used_by_graph_def` +* `tf.contrib.util.stripped_op_list_for_graph` diff --git a/tensorflow/docs_src/api_guides/python/control_flow_ops.md b/tensorflow/docs_src/api_guides/python/control_flow_ops.md index 68ea96d3dc..42c86d9978 100644 --- a/tensorflow/docs_src/api_guides/python/control_flow_ops.md +++ b/tensorflow/docs_src/api_guides/python/control_flow_ops.md @@ -1,7 +1,7 @@ # Control Flow Note: Functions taking `Tensor` arguments can also take anything accepted by -@{tf.convert_to_tensor}. +`tf.convert_to_tensor`. [TOC] @@ -10,48 +10,48 @@ Note: Functions taking `Tensor` arguments can also take anything accepted by TensorFlow provides several operations and classes that you can use to control the execution of operations and add conditional dependencies to your graph. -* @{tf.identity} -* @{tf.tuple} -* @{tf.group} -* @{tf.no_op} -* @{tf.count_up_to} -* @{tf.cond} -* @{tf.case} -* @{tf.while_loop} +* `tf.identity` +* `tf.tuple` +* `tf.group` +* `tf.no_op` +* `tf.count_up_to` +* `tf.cond` +* `tf.case` +* `tf.while_loop` ## Logical Operators TensorFlow provides several operations that you can use to add logical operators to your graph. -* @{tf.logical_and} -* @{tf.logical_not} -* @{tf.logical_or} -* @{tf.logical_xor} +* `tf.logical_and` +* `tf.logical_not` +* `tf.logical_or` +* `tf.logical_xor` ## Comparison Operators TensorFlow provides several operations that you can use to add comparison operators to your graph. -* @{tf.equal} -* @{tf.not_equal} -* @{tf.less} -* @{tf.less_equal} -* @{tf.greater} -* @{tf.greater_equal} -* @{tf.where} +* `tf.equal` +* `tf.not_equal` +* `tf.less` +* `tf.less_equal` +* `tf.greater` +* `tf.greater_equal` +* `tf.where` ## Debugging Operations TensorFlow provides several operations that you can use to validate values and debug your graph. -* @{tf.is_finite} -* @{tf.is_inf} -* @{tf.is_nan} -* @{tf.verify_tensor_all_finite} -* @{tf.check_numerics} -* @{tf.add_check_numerics_ops} -* @{tf.Assert} -* @{tf.Print} +* `tf.is_finite` +* `tf.is_inf` +* `tf.is_nan` +* `tf.verify_tensor_all_finite` +* `tf.check_numerics` +* `tf.add_check_numerics_ops` +* `tf.Assert` +* `tf.Print` diff --git a/tensorflow/docs_src/api_guides/python/framework.md b/tensorflow/docs_src/api_guides/python/framework.md index 42c3e57477..40a6c0783a 100644 --- a/tensorflow/docs_src/api_guides/python/framework.md +++ b/tensorflow/docs_src/api_guides/python/framework.md @@ -5,47 +5,47 @@ Classes and functions for building TensorFlow graphs. ## Core graph data structures -* @{tf.Graph} -* @{tf.Operation} -* @{tf.Tensor} +* `tf.Graph` +* `tf.Operation` +* `tf.Tensor` ## Tensor types -* @{tf.DType} -* @{tf.as_dtype} +* `tf.DType` +* `tf.as_dtype` ## Utility functions -* @{tf.device} -* @{tf.container} -* @{tf.name_scope} -* @{tf.control_dependencies} -* @{tf.convert_to_tensor} -* @{tf.convert_to_tensor_or_indexed_slices} -* @{tf.convert_to_tensor_or_sparse_tensor} -* @{tf.get_default_graph} -* @{tf.reset_default_graph} -* @{tf.import_graph_def} -* @{tf.load_file_system_library} -* @{tf.load_op_library} +* `tf.device` +* `tf.container` +* `tf.name_scope` +* `tf.control_dependencies` +* `tf.convert_to_tensor` +* `tf.convert_to_tensor_or_indexed_slices` +* `tf.convert_to_tensor_or_sparse_tensor` +* `tf.get_default_graph` +* `tf.reset_default_graph` +* `tf.import_graph_def` +* `tf.load_file_system_library` +* `tf.load_op_library` ## Graph collections -* @{tf.add_to_collection} -* @{tf.get_collection} -* @{tf.get_collection_ref} -* @{tf.GraphKeys} +* `tf.add_to_collection` +* `tf.get_collection` +* `tf.get_collection_ref` +* `tf.GraphKeys` ## Defining new operations -* @{tf.RegisterGradient} -* @{tf.NotDifferentiable} -* @{tf.NoGradient} -* @{tf.TensorShape} -* @{tf.Dimension} -* @{tf.op_scope} -* @{tf.get_seed} +* `tf.RegisterGradient` +* `tf.NotDifferentiable` +* `tf.NoGradient` +* `tf.TensorShape` +* `tf.Dimension` +* `tf.op_scope` +* `tf.get_seed` ## For libraries building on TensorFlow -* @{tf.register_tensor_conversion_function} +* `tf.register_tensor_conversion_function` diff --git a/tensorflow/docs_src/api_guides/python/functional_ops.md b/tensorflow/docs_src/api_guides/python/functional_ops.md index 9fd46066a8..0a9fe02ad5 100644 --- a/tensorflow/docs_src/api_guides/python/functional_ops.md +++ b/tensorflow/docs_src/api_guides/python/functional_ops.md @@ -1,7 +1,7 @@ # Higher Order Functions Note: Functions taking `Tensor` arguments can also take anything accepted by -@{tf.convert_to_tensor}. +`tf.convert_to_tensor`. [TOC] @@ -12,7 +12,7 @@ Functional operations. TensorFlow provides several higher order operators to simplify the common map-reduce programming patterns. -* @{tf.map_fn} -* @{tf.foldl} -* @{tf.foldr} -* @{tf.scan} +* `tf.map_fn` +* `tf.foldl` +* `tf.foldr` +* `tf.scan` diff --git a/tensorflow/docs_src/api_guides/python/image.md b/tensorflow/docs_src/api_guides/python/image.md index 051e4547ee..c51b92db05 100644 --- a/tensorflow/docs_src/api_guides/python/image.md +++ b/tensorflow/docs_src/api_guides/python/image.md @@ -1,7 +1,7 @@ # Images Note: Functions taking `Tensor` arguments can also take anything accepted by -@{tf.convert_to_tensor}. +`tf.convert_to_tensor`. [TOC] @@ -19,27 +19,27 @@ Note: The PNG encode and decode Ops support RGBA, but the conversions Ops presently only support RGB, HSV, and GrayScale. Presently, the alpha channel has to be stripped from the image and re-attached using slicing ops. -* @{tf.image.decode_bmp} -* @{tf.image.decode_gif} -* @{tf.image.decode_jpeg} -* @{tf.image.encode_jpeg} -* @{tf.image.decode_png} -* @{tf.image.encode_png} -* @{tf.image.decode_image} +* `tf.image.decode_bmp` +* `tf.image.decode_gif` +* `tf.image.decode_jpeg` +* `tf.image.encode_jpeg` +* `tf.image.decode_png` +* `tf.image.encode_png` +* `tf.image.decode_image` ## Resizing The resizing Ops accept input images as tensors of several types. They always output resized images as float32 tensors. -The convenience function @{tf.image.resize_images} supports both 4-D +The convenience function `tf.image.resize_images` supports both 4-D and 3-D tensors as input and output. 4-D tensors are for batches of images, 3-D tensors for individual images. Other resizing Ops only support 4-D batches of images as input: -@{tf.image.resize_area}, @{tf.image.resize_bicubic}, -@{tf.image.resize_bilinear}, -@{tf.image.resize_nearest_neighbor}. +`tf.image.resize_area`, `tf.image.resize_bicubic`, +`tf.image.resize_bilinear`, +`tf.image.resize_nearest_neighbor`. Example: @@ -49,29 +49,29 @@ image = tf.image.decode_jpeg(...) resized_image = tf.image.resize_images(image, [299, 299]) ``` -* @{tf.image.resize_images} -* @{tf.image.resize_area} -* @{tf.image.resize_bicubic} -* @{tf.image.resize_bilinear} -* @{tf.image.resize_nearest_neighbor} +* `tf.image.resize_images` +* `tf.image.resize_area` +* `tf.image.resize_bicubic` +* `tf.image.resize_bilinear` +* `tf.image.resize_nearest_neighbor` ## Cropping -* @{tf.image.resize_image_with_crop_or_pad} -* @{tf.image.central_crop} -* @{tf.image.pad_to_bounding_box} -* @{tf.image.crop_to_bounding_box} -* @{tf.image.extract_glimpse} -* @{tf.image.crop_and_resize} +* `tf.image.resize_image_with_crop_or_pad` +* `tf.image.central_crop` +* `tf.image.pad_to_bounding_box` +* `tf.image.crop_to_bounding_box` +* `tf.image.extract_glimpse` +* `tf.image.crop_and_resize` ## Flipping, Rotating and Transposing -* @{tf.image.flip_up_down} -* @{tf.image.random_flip_up_down} -* @{tf.image.flip_left_right} -* @{tf.image.random_flip_left_right} -* @{tf.image.transpose_image} -* @{tf.image.rot90} +* `tf.image.flip_up_down` +* `tf.image.random_flip_up_down` +* `tf.image.flip_left_right` +* `tf.image.random_flip_left_right` +* `tf.image.transpose_image` +* `tf.image.rot90` ## Converting Between Colorspaces @@ -94,7 +94,7 @@ per pixel (values are assumed to lie in `[0,255]`). TensorFlow can convert between images in RGB or HSV. The conversion functions work only on float images, so you need to convert images in other formats using -@{tf.image.convert_image_dtype}. +`tf.image.convert_image_dtype`. Example: @@ -105,11 +105,11 @@ rgb_image_float = tf.image.convert_image_dtype(rgb_image, tf.float32) hsv_image = tf.image.rgb_to_hsv(rgb_image) ``` -* @{tf.image.rgb_to_grayscale} -* @{tf.image.grayscale_to_rgb} -* @{tf.image.hsv_to_rgb} -* @{tf.image.rgb_to_hsv} -* @{tf.image.convert_image_dtype} +* `tf.image.rgb_to_grayscale` +* `tf.image.grayscale_to_rgb` +* `tf.image.hsv_to_rgb` +* `tf.image.rgb_to_hsv` +* `tf.image.convert_image_dtype` ## Image Adjustments @@ -122,23 +122,23 @@ If several adjustments are chained it is advisable to minimize the number of redundant conversions by first converting the images to the most natural data type and representation (RGB or HSV). -* @{tf.image.adjust_brightness} -* @{tf.image.random_brightness} -* @{tf.image.adjust_contrast} -* @{tf.image.random_contrast} -* @{tf.image.adjust_hue} -* @{tf.image.random_hue} -* @{tf.image.adjust_gamma} -* @{tf.image.adjust_saturation} -* @{tf.image.random_saturation} -* @{tf.image.per_image_standardization} +* `tf.image.adjust_brightness` +* `tf.image.random_brightness` +* `tf.image.adjust_contrast` +* `tf.image.random_contrast` +* `tf.image.adjust_hue` +* `tf.image.random_hue` +* `tf.image.adjust_gamma` +* `tf.image.adjust_saturation` +* `tf.image.random_saturation` +* `tf.image.per_image_standardization` ## Working with Bounding Boxes -* @{tf.image.draw_bounding_boxes} -* @{tf.image.non_max_suppression} -* @{tf.image.sample_distorted_bounding_box} +* `tf.image.draw_bounding_boxes` +* `tf.image.non_max_suppression` +* `tf.image.sample_distorted_bounding_box` ## Denoising -* @{tf.image.total_variation} +* `tf.image.total_variation` diff --git a/tensorflow/docs_src/api_guides/python/input_dataset.md b/tensorflow/docs_src/api_guides/python/input_dataset.md index a6612d1bf7..ab572e53d4 100644 --- a/tensorflow/docs_src/api_guides/python/input_dataset.md +++ b/tensorflow/docs_src/api_guides/python/input_dataset.md @@ -1,27 +1,27 @@ # Dataset Input Pipeline [TOC] -@{tf.data.Dataset} allows you to build complex input pipelines. See the +`tf.data.Dataset` allows you to build complex input pipelines. See the @{$guide/datasets} for an in-depth explanation of how to use this API. ## Reader classes Classes that create a dataset from input files. -* @{tf.data.FixedLengthRecordDataset} -* @{tf.data.TextLineDataset} -* @{tf.data.TFRecordDataset} +* `tf.data.FixedLengthRecordDataset` +* `tf.data.TextLineDataset` +* `tf.data.TFRecordDataset` ## Creating new datasets Static methods in `Dataset` that create new datasets. -* @{tf.data.Dataset.from_generator} -* @{tf.data.Dataset.from_tensor_slices} -* @{tf.data.Dataset.from_tensors} -* @{tf.data.Dataset.list_files} -* @{tf.data.Dataset.range} -* @{tf.data.Dataset.zip} +* `tf.data.Dataset.from_generator` +* `tf.data.Dataset.from_tensor_slices` +* `tf.data.Dataset.from_tensors` +* `tf.data.Dataset.list_files` +* `tf.data.Dataset.range` +* `tf.data.Dataset.zip` ## Transformations on existing datasets @@ -32,54 +32,54 @@ can be chained together, as shown in the example below: train_data = train_data.batch(100).shuffle().repeat() ``` -* @{tf.data.Dataset.apply} -* @{tf.data.Dataset.batch} -* @{tf.data.Dataset.cache} -* @{tf.data.Dataset.concatenate} -* @{tf.data.Dataset.filter} -* @{tf.data.Dataset.flat_map} -* @{tf.data.Dataset.interleave} -* @{tf.data.Dataset.map} -* @{tf.data.Dataset.padded_batch} -* @{tf.data.Dataset.prefetch} -* @{tf.data.Dataset.repeat} -* @{tf.data.Dataset.shard} -* @{tf.data.Dataset.shuffle} -* @{tf.data.Dataset.skip} -* @{tf.data.Dataset.take} +* `tf.data.Dataset.apply` +* `tf.data.Dataset.batch` +* `tf.data.Dataset.cache` +* `tf.data.Dataset.concatenate` +* `tf.data.Dataset.filter` +* `tf.data.Dataset.flat_map` +* `tf.data.Dataset.interleave` +* `tf.data.Dataset.map` +* `tf.data.Dataset.padded_batch` +* `tf.data.Dataset.prefetch` +* `tf.data.Dataset.repeat` +* `tf.data.Dataset.shard` +* `tf.data.Dataset.shuffle` +* `tf.data.Dataset.skip` +* `tf.data.Dataset.take` ### Custom transformation functions -Custom transformation functions can be applied to a `Dataset` using @{tf.data.Dataset.apply}. Below are custom transformation functions from `tf.contrib.data`: - -* @{tf.contrib.data.batch_and_drop_remainder} -* @{tf.contrib.data.dense_to_sparse_batch} -* @{tf.contrib.data.enumerate_dataset} -* @{tf.contrib.data.group_by_window} -* @{tf.contrib.data.ignore_errors} -* @{tf.contrib.data.map_and_batch} -* @{tf.contrib.data.padded_batch_and_drop_remainder} -* @{tf.contrib.data.parallel_interleave} -* @{tf.contrib.data.rejection_resample} -* @{tf.contrib.data.scan} -* @{tf.contrib.data.shuffle_and_repeat} -* @{tf.contrib.data.unbatch} +Custom transformation functions can be applied to a `Dataset` using `tf.data.Dataset.apply`. Below are custom transformation functions from `tf.contrib.data`: + +* `tf.contrib.data.batch_and_drop_remainder` +* `tf.contrib.data.dense_to_sparse_batch` +* `tf.contrib.data.enumerate_dataset` +* `tf.contrib.data.group_by_window` +* `tf.contrib.data.ignore_errors` +* `tf.contrib.data.map_and_batch` +* `tf.contrib.data.padded_batch_and_drop_remainder` +* `tf.contrib.data.parallel_interleave` +* `tf.contrib.data.rejection_resample` +* `tf.contrib.data.scan` +* `tf.contrib.data.shuffle_and_repeat` +* `tf.contrib.data.unbatch` ## Iterating over datasets -These functions make a @{tf.data.Iterator} from a `Dataset`. +These functions make a `tf.data.Iterator` from a `Dataset`. -* @{tf.data.Dataset.make_initializable_iterator} -* @{tf.data.Dataset.make_one_shot_iterator} +* `tf.data.Dataset.make_initializable_iterator` +* `tf.data.Dataset.make_one_shot_iterator` -The `Iterator` class also contains static methods that create a @{tf.data.Iterator} that can be used with multiple `Dataset` objects. +The `Iterator` class also contains static methods that create a `tf.data.Iterator` that can be used with multiple `Dataset` objects. -* @{tf.data.Iterator.from_structure} -* @{tf.data.Iterator.from_string_handle} +* `tf.data.Iterator.from_structure` +* `tf.data.Iterator.from_string_handle` ## Extra functions from `tf.contrib.data` -* @{tf.contrib.data.get_single_element} -* @{tf.contrib.data.make_saveable_from_iterator} -* @{tf.contrib.data.read_batch_features} +* `tf.contrib.data.get_single_element` +* `tf.contrib.data.make_saveable_from_iterator` +* `tf.contrib.data.read_batch_features` diff --git a/tensorflow/docs_src/api_guides/python/io_ops.md b/tensorflow/docs_src/api_guides/python/io_ops.md index 86b4b39409..ab3c70daa0 100644 --- a/tensorflow/docs_src/api_guides/python/io_ops.md +++ b/tensorflow/docs_src/api_guides/python/io_ops.md @@ -1,7 +1,7 @@ # Inputs and Readers Note: Functions taking `Tensor` arguments can also take anything accepted by -@{tf.convert_to_tensor}. +`tf.convert_to_tensor`. [TOC] @@ -10,33 +10,33 @@ Note: Functions taking `Tensor` arguments can also take anything accepted by TensorFlow provides a placeholder operation that must be fed with data on execution. For more info, see the section on @{$reading_data#Feeding$Feeding data}. -* @{tf.placeholder} -* @{tf.placeholder_with_default} +* `tf.placeholder` +* `tf.placeholder_with_default` For feeding `SparseTensor`s which are composite type, there is a convenience function: -* @{tf.sparse_placeholder} +* `tf.sparse_placeholder` ## Readers TensorFlow provides a set of Reader classes for reading data formats. For more information on inputs and readers, see @{$reading_data$Reading data}. -* @{tf.ReaderBase} -* @{tf.TextLineReader} -* @{tf.WholeFileReader} -* @{tf.IdentityReader} -* @{tf.TFRecordReader} -* @{tf.FixedLengthRecordReader} +* `tf.ReaderBase` +* `tf.TextLineReader` +* `tf.WholeFileReader` +* `tf.IdentityReader` +* `tf.TFRecordReader` +* `tf.FixedLengthRecordReader` ## Converting TensorFlow provides several operations that you can use to convert various data formats into tensors. -* @{tf.decode_csv} -* @{tf.decode_raw} +* `tf.decode_csv` +* `tf.decode_raw` - - - @@ -48,14 +48,14 @@ here](https://www.tensorflow.org/code/tensorflow/core/example/example.proto). They contain `Features`, [described here](https://www.tensorflow.org/code/tensorflow/core/example/feature.proto). -* @{tf.VarLenFeature} -* @{tf.FixedLenFeature} -* @{tf.FixedLenSequenceFeature} -* @{tf.SparseFeature} -* @{tf.parse_example} -* @{tf.parse_single_example} -* @{tf.parse_tensor} -* @{tf.decode_json_example} +* `tf.VarLenFeature` +* `tf.FixedLenFeature` +* `tf.FixedLenSequenceFeature` +* `tf.SparseFeature` +* `tf.parse_example` +* `tf.parse_single_example` +* `tf.parse_tensor` +* `tf.decode_json_example` ## Queues @@ -64,23 +64,23 @@ structures within the TensorFlow computation graph to stage pipelines of tensors together. The following describe the basic Queue interface and some implementations. To see an example use, see @{$threading_and_queues$Threading and Queues}. -* @{tf.QueueBase} -* @{tf.FIFOQueue} -* @{tf.PaddingFIFOQueue} -* @{tf.RandomShuffleQueue} -* @{tf.PriorityQueue} +* `tf.QueueBase` +* `tf.FIFOQueue` +* `tf.PaddingFIFOQueue` +* `tf.RandomShuffleQueue` +* `tf.PriorityQueue` ## Conditional Accumulators -* @{tf.ConditionalAccumulatorBase} -* @{tf.ConditionalAccumulator} -* @{tf.SparseConditionalAccumulator} +* `tf.ConditionalAccumulatorBase` +* `tf.ConditionalAccumulator` +* `tf.SparseConditionalAccumulator` ## Dealing with the filesystem -* @{tf.matching_files} -* @{tf.read_file} -* @{tf.write_file} +* `tf.matching_files` +* `tf.read_file` +* `tf.write_file` ## Input pipeline @@ -93,12 +93,12 @@ for context. The "producer" functions add a queue to the graph and a corresponding `QueueRunner` for running the subgraph that fills that queue. -* @{tf.train.match_filenames_once} -* @{tf.train.limit_epochs} -* @{tf.train.input_producer} -* @{tf.train.range_input_producer} -* @{tf.train.slice_input_producer} -* @{tf.train.string_input_producer} +* `tf.train.match_filenames_once` +* `tf.train.limit_epochs` +* `tf.train.input_producer` +* `tf.train.range_input_producer` +* `tf.train.slice_input_producer` +* `tf.train.string_input_producer` ### Batching at the end of an input pipeline @@ -106,25 +106,25 @@ These functions add a queue to the graph to assemble a batch of examples, with possible shuffling. They also add a `QueueRunner` for running the subgraph that fills that queue. -Use @{tf.train.batch} or @{tf.train.batch_join} for batching +Use `tf.train.batch` or `tf.train.batch_join` for batching examples that have already been well shuffled. Use -@{tf.train.shuffle_batch} or -@{tf.train.shuffle_batch_join} for examples that would +`tf.train.shuffle_batch` or +`tf.train.shuffle_batch_join` for examples that would benefit from additional shuffling. -Use @{tf.train.batch} or @{tf.train.shuffle_batch} if you want a +Use `tf.train.batch` or `tf.train.shuffle_batch` if you want a single thread producing examples to batch, or if you have a single subgraph producing examples but you want to run it in *N* threads (where you increase *N* until it can keep the queue full). Use -@{tf.train.batch_join} or @{tf.train.shuffle_batch_join} +`tf.train.batch_join` or `tf.train.shuffle_batch_join` if you have *N* different subgraphs producing examples to batch and you want them run by *N* threads. Use `maybe_*` to enqueue conditionally. -* @{tf.train.batch} -* @{tf.train.maybe_batch} -* @{tf.train.batch_join} -* @{tf.train.maybe_batch_join} -* @{tf.train.shuffle_batch} -* @{tf.train.maybe_shuffle_batch} -* @{tf.train.shuffle_batch_join} -* @{tf.train.maybe_shuffle_batch_join} +* `tf.train.batch` +* `tf.train.maybe_batch` +* `tf.train.batch_join` +* `tf.train.maybe_batch_join` +* `tf.train.shuffle_batch` +* `tf.train.maybe_shuffle_batch` +* `tf.train.shuffle_batch_join` +* `tf.train.maybe_shuffle_batch_join` diff --git a/tensorflow/docs_src/api_guides/python/math_ops.md b/tensorflow/docs_src/api_guides/python/math_ops.md index dee7f1618a..e738161e49 100644 --- a/tensorflow/docs_src/api_guides/python/math_ops.md +++ b/tensorflow/docs_src/api_guides/python/math_ops.md @@ -1,7 +1,7 @@ # Math Note: Functions taking `Tensor` arguments can also take anything accepted by -@{tf.convert_to_tensor}. +`tf.convert_to_tensor`. [TOC] @@ -13,97 +13,97 @@ broadcasting](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html). TensorFlow provides several operations that you can use to add basic arithmetic operators to your graph. -* @{tf.add} -* @{tf.subtract} -* @{tf.multiply} -* @{tf.scalar_mul} -* @{tf.div} -* @{tf.divide} -* @{tf.truediv} -* @{tf.floordiv} -* @{tf.realdiv} -* @{tf.truncatediv} -* @{tf.floor_div} -* @{tf.truncatemod} -* @{tf.floormod} -* @{tf.mod} -* @{tf.cross} +* `tf.add` +* `tf.subtract` +* `tf.multiply` +* `tf.scalar_mul` +* `tf.div` +* `tf.divide` +* `tf.truediv` +* `tf.floordiv` +* `tf.realdiv` +* `tf.truncatediv` +* `tf.floor_div` +* `tf.truncatemod` +* `tf.floormod` +* `tf.mod` +* `tf.cross` ## Basic Math Functions TensorFlow provides several operations that you can use to add basic mathematical functions to your graph. -* @{tf.add_n} -* @{tf.abs} -* @{tf.negative} -* @{tf.sign} -* @{tf.reciprocal} -* @{tf.square} -* @{tf.round} -* @{tf.sqrt} -* @{tf.rsqrt} -* @{tf.pow} -* @{tf.exp} -* @{tf.expm1} -* @{tf.log} -* @{tf.log1p} -* @{tf.ceil} -* @{tf.floor} -* @{tf.maximum} -* @{tf.minimum} -* @{tf.cos} -* @{tf.sin} -* @{tf.lbeta} -* @{tf.tan} -* @{tf.acos} -* @{tf.asin} -* @{tf.atan} -* @{tf.cosh} -* @{tf.sinh} -* @{tf.asinh} -* @{tf.acosh} -* @{tf.atanh} -* @{tf.lgamma} -* @{tf.digamma} -* @{tf.erf} -* @{tf.erfc} -* @{tf.squared_difference} -* @{tf.igamma} -* @{tf.igammac} -* @{tf.zeta} -* @{tf.polygamma} -* @{tf.betainc} -* @{tf.rint} +* `tf.add_n` +* `tf.abs` +* `tf.negative` +* `tf.sign` +* `tf.reciprocal` +* `tf.square` +* `tf.round` +* `tf.sqrt` +* `tf.rsqrt` +* `tf.pow` +* `tf.exp` +* `tf.expm1` +* `tf.log` +* `tf.log1p` +* `tf.ceil` +* `tf.floor` +* `tf.maximum` +* `tf.minimum` +* `tf.cos` +* `tf.sin` +* `tf.lbeta` +* `tf.tan` +* `tf.acos` +* `tf.asin` +* `tf.atan` +* `tf.cosh` +* `tf.sinh` +* `tf.asinh` +* `tf.acosh` +* `tf.atanh` +* `tf.lgamma` +* `tf.digamma` +* `tf.erf` +* `tf.erfc` +* `tf.squared_difference` +* `tf.igamma` +* `tf.igammac` +* `tf.zeta` +* `tf.polygamma` +* `tf.betainc` +* `tf.rint` ## Matrix Math Functions TensorFlow provides several operations that you can use to add linear algebra functions on matrices to your graph. -* @{tf.diag} -* @{tf.diag_part} -* @{tf.trace} -* @{tf.transpose} -* @{tf.eye} -* @{tf.matrix_diag} -* @{tf.matrix_diag_part} -* @{tf.matrix_band_part} -* @{tf.matrix_set_diag} -* @{tf.matrix_transpose} -* @{tf.matmul} -* @{tf.norm} -* @{tf.matrix_determinant} -* @{tf.matrix_inverse} -* @{tf.cholesky} -* @{tf.cholesky_solve} -* @{tf.matrix_solve} -* @{tf.matrix_triangular_solve} -* @{tf.matrix_solve_ls} -* @{tf.qr} -* @{tf.self_adjoint_eig} -* @{tf.self_adjoint_eigvals} -* @{tf.svd} +* `tf.diag` +* `tf.diag_part` +* `tf.trace` +* `tf.transpose` +* `tf.eye` +* `tf.matrix_diag` +* `tf.matrix_diag_part` +* `tf.matrix_band_part` +* `tf.matrix_set_diag` +* `tf.matrix_transpose` +* `tf.matmul` +* `tf.norm` +* `tf.matrix_determinant` +* `tf.matrix_inverse` +* `tf.cholesky` +* `tf.cholesky_solve` +* `tf.matrix_solve` +* `tf.matrix_triangular_solve` +* `tf.matrix_solve_ls` +* `tf.qr` +* `tf.self_adjoint_eig` +* `tf.self_adjoint_eigvals` +* `tf.svd` ## Tensor Math Function @@ -111,7 +111,7 @@ functions on matrices to your graph. TensorFlow provides operations that you can use to add tensor functions to your graph. -* @{tf.tensordot} +* `tf.tensordot` ## Complex Number Functions @@ -119,11 +119,11 @@ graph. TensorFlow provides several operations that you can use to add complex number functions to your graph. -* @{tf.complex} -* @{tf.conj} -* @{tf.imag} -* @{tf.angle} -* @{tf.real} +* `tf.complex` +* `tf.conj` +* `tf.imag` +* `tf.angle` +* `tf.real` ## Reduction @@ -131,25 +131,25 @@ functions to your graph. TensorFlow provides several operations that you can use to perform common math computations that reduce various dimensions of a tensor. -* @{tf.reduce_sum} -* @{tf.reduce_prod} -* @{tf.reduce_min} -* @{tf.reduce_max} -* @{tf.reduce_mean} -* @{tf.reduce_all} -* @{tf.reduce_any} -* @{tf.reduce_logsumexp} -* @{tf.count_nonzero} -* @{tf.accumulate_n} -* @{tf.einsum} +* `tf.reduce_sum` +* `tf.reduce_prod` +* `tf.reduce_min` +* `tf.reduce_max` +* `tf.reduce_mean` +* `tf.reduce_all` +* `tf.reduce_any` +* `tf.reduce_logsumexp` +* `tf.count_nonzero` +* `tf.accumulate_n` +* `tf.einsum` ## Scan TensorFlow provides several operations that you can use to perform scans (running totals) across one axis of a tensor. -* @{tf.cumsum} -* @{tf.cumprod} +* `tf.cumsum` +* `tf.cumprod` ## Segmentation @@ -172,15 +172,15 @@ tf.segment_sum(c, tf.constant([0, 0, 1])) [5 6 7 8]] ``` -* @{tf.segment_sum} -* @{tf.segment_prod} -* @{tf.segment_min} -* @{tf.segment_max} -* @{tf.segment_mean} -* @{tf.unsorted_segment_sum} -* @{tf.sparse_segment_sum} -* @{tf.sparse_segment_mean} -* @{tf.sparse_segment_sqrt_n} +* `tf.segment_sum` +* `tf.segment_prod` +* `tf.segment_min` +* `tf.segment_max` +* `tf.segment_mean` +* `tf.unsorted_segment_sum` +* `tf.sparse_segment_sum` +* `tf.sparse_segment_mean` +* `tf.sparse_segment_sqrt_n` ## Sequence Comparison and Indexing @@ -190,10 +190,10 @@ comparison and index extraction to your graph. You can use these operations to determine sequence differences and determine the indexes of specific values in a tensor. -* @{tf.argmin} -* @{tf.argmax} -* @{tf.setdiff1d} -* @{tf.where} -* @{tf.unique} -* @{tf.edit_distance} -* @{tf.invert_permutation} +* `tf.argmin` +* `tf.argmax` +* `tf.setdiff1d` +* `tf.where` +* `tf.unique` +* `tf.edit_distance` +* `tf.invert_permutation` diff --git a/tensorflow/docs_src/api_guides/python/meta_graph.md b/tensorflow/docs_src/api_guides/python/meta_graph.md index f1c3adc22c..7dbd9a56f4 100644 --- a/tensorflow/docs_src/api_guides/python/meta_graph.md +++ b/tensorflow/docs_src/api_guides/python/meta_graph.md @@ -7,10 +7,10 @@ term storage of graphs. The MetaGraph contains the information required to continue training, perform evaluation, or run inference on a previously trained graph. The APIs for exporting and importing the complete model are in -the @{tf.train.Saver} class: -@{tf.train.export_meta_graph} +the `tf.train.Saver` class: +`tf.train.export_meta_graph` and -@{tf.train.import_meta_graph}. +`tf.train.import_meta_graph`. ## What's in a MetaGraph @@ -24,7 +24,7 @@ protocol buffer. It contains the following fields: * [`CollectionDef`](https://www.tensorflow.org/code/tensorflow/core/protobuf/meta_graph.proto) map that further describes additional components of the model such as @{$python/state_ops$`Variables`}, -@{tf.train.QueueRunner}, etc. +`tf.train.QueueRunner`, etc. In order for a Python object to be serialized to and from `MetaGraphDef`, the Python class must implement `to_proto()` and @@ -122,7 +122,7 @@ The API for exporting a running model as a MetaGraph is `export_meta_graph()`. The MetaGraph is also automatically exported via the `save()` API in -@{tf.train.Saver}. +`tf.train.Saver`. ## Import a MetaGraph diff --git a/tensorflow/docs_src/api_guides/python/nn.md b/tensorflow/docs_src/api_guides/python/nn.md index 8d8daaae19..40dda3941d 100644 --- a/tensorflow/docs_src/api_guides/python/nn.md +++ b/tensorflow/docs_src/api_guides/python/nn.md @@ -1,7 +1,7 @@ # Neural Network Note: Functions taking `Tensor` arguments can also take anything accepted by -@{tf.convert_to_tensor}. +`tf.convert_to_tensor`. [TOC] @@ -16,17 +16,17 @@ functions (`relu`, `relu6`, `crelu` and `relu_x`), and random regularization All activation ops apply componentwise, and produce a tensor of the same shape as the input tensor. -* @{tf.nn.relu} -* @{tf.nn.relu6} -* @{tf.nn.crelu} -* @{tf.nn.elu} -* @{tf.nn.selu} -* @{tf.nn.softplus} -* @{tf.nn.softsign} -* @{tf.nn.dropout} -* @{tf.nn.bias_add} -* @{tf.sigmoid} -* @{tf.tanh} +* `tf.nn.relu` +* `tf.nn.relu6` +* `tf.nn.crelu` +* `tf.nn.elu` +* `tf.nn.selu` +* `tf.nn.softplus` +* `tf.nn.softsign` +* `tf.nn.dropout` +* `tf.nn.bias_add` +* `tf.sigmoid` +* `tf.tanh` ## Convolution @@ -112,22 +112,22 @@ vectors. For `depthwise_conv_2d`, each scalar component `input[b, i, j, k]` is multiplied by a vector `filter[di, dj, k]`, and all the vectors are concatenated. -* @{tf.nn.convolution} -* @{tf.nn.conv2d} -* @{tf.nn.depthwise_conv2d} -* @{tf.nn.depthwise_conv2d_native} -* @{tf.nn.separable_conv2d} -* @{tf.nn.atrous_conv2d} -* @{tf.nn.atrous_conv2d_transpose} -* @{tf.nn.conv2d_transpose} -* @{tf.nn.conv1d} -* @{tf.nn.conv3d} -* @{tf.nn.conv3d_transpose} -* @{tf.nn.conv2d_backprop_filter} -* @{tf.nn.conv2d_backprop_input} -* @{tf.nn.conv3d_backprop_filter_v2} -* @{tf.nn.depthwise_conv2d_native_backprop_filter} -* @{tf.nn.depthwise_conv2d_native_backprop_input} +* `tf.nn.convolution` +* `tf.nn.conv2d` +* `tf.nn.depthwise_conv2d` +* `tf.nn.depthwise_conv2d_native` +* `tf.nn.separable_conv2d` +* `tf.nn.atrous_conv2d` +* `tf.nn.atrous_conv2d_transpose` +* `tf.nn.conv2d_transpose` +* `tf.nn.conv1d` +* `tf.nn.conv3d` +* `tf.nn.conv3d_transpose` +* `tf.nn.conv2d_backprop_filter` +* `tf.nn.conv2d_backprop_input` +* `tf.nn.conv3d_backprop_filter_v2` +* `tf.nn.depthwise_conv2d_native_backprop_filter` +* `tf.nn.depthwise_conv2d_native_backprop_input` ## Pooling @@ -144,14 +144,14 @@ In detail, the output is where the indices also take into consideration the padding values. Please refer to the `Convolution` section for details about the padding calculation. -* @{tf.nn.avg_pool} -* @{tf.nn.max_pool} -* @{tf.nn.max_pool_with_argmax} -* @{tf.nn.avg_pool3d} -* @{tf.nn.max_pool3d} -* @{tf.nn.fractional_avg_pool} -* @{tf.nn.fractional_max_pool} -* @{tf.nn.pool} +* `tf.nn.avg_pool` +* `tf.nn.max_pool` +* `tf.nn.max_pool_with_argmax` +* `tf.nn.avg_pool3d` +* `tf.nn.max_pool3d` +* `tf.nn.fractional_avg_pool` +* `tf.nn.fractional_max_pool` +* `tf.nn.pool` ## Morphological filtering @@ -190,24 +190,24 @@ Dilation and erosion are dual to each other. The dilation of the input signal Striding and padding is carried out in exactly the same way as in standard convolution. Please refer to the `Convolution` section for details. -* @{tf.nn.dilation2d} -* @{tf.nn.erosion2d} -* @{tf.nn.with_space_to_batch} +* `tf.nn.dilation2d` +* `tf.nn.erosion2d` +* `tf.nn.with_space_to_batch` ## Normalization Normalization is useful to prevent neurons from saturating when inputs may have varying scale, and to aid generalization. -* @{tf.nn.l2_normalize} -* @{tf.nn.local_response_normalization} -* @{tf.nn.sufficient_statistics} -* @{tf.nn.normalize_moments} -* @{tf.nn.moments} -* @{tf.nn.weighted_moments} -* @{tf.nn.fused_batch_norm} -* @{tf.nn.batch_normalization} -* @{tf.nn.batch_norm_with_global_normalization} +* `tf.nn.l2_normalize` +* `tf.nn.local_response_normalization` +* `tf.nn.sufficient_statistics` +* `tf.nn.normalize_moments` +* `tf.nn.moments` +* `tf.nn.weighted_moments` +* `tf.nn.fused_batch_norm` +* `tf.nn.batch_normalization` +* `tf.nn.batch_norm_with_global_normalization` ## Losses @@ -215,29 +215,29 @@ The loss ops measure error between two tensors, or between a tensor and zero. These can be used for measuring accuracy of a network in a regression task or for regularization purposes (weight decay). -* @{tf.nn.l2_loss} -* @{tf.nn.log_poisson_loss} +* `tf.nn.l2_loss` +* `tf.nn.log_poisson_loss` ## Classification TensorFlow provides several operations that help you perform classification. -* @{tf.nn.sigmoid_cross_entropy_with_logits} -* @{tf.nn.softmax} -* @{tf.nn.log_softmax} -* @{tf.nn.softmax_cross_entropy_with_logits} -* @{tf.nn.softmax_cross_entropy_with_logits_v2} - identical to the base +* `tf.nn.sigmoid_cross_entropy_with_logits` +* `tf.nn.softmax` +* `tf.nn.log_softmax` +* `tf.nn.softmax_cross_entropy_with_logits` +* `tf.nn.softmax_cross_entropy_with_logits_v2` - identical to the base version, except it allows gradient propagation into the labels. -* @{tf.nn.sparse_softmax_cross_entropy_with_logits} -* @{tf.nn.weighted_cross_entropy_with_logits} +* `tf.nn.sparse_softmax_cross_entropy_with_logits` +* `tf.nn.weighted_cross_entropy_with_logits` ## Embeddings TensorFlow provides library support for looking up values in embedding tensors. -* @{tf.nn.embedding_lookup} -* @{tf.nn.embedding_lookup_sparse} +* `tf.nn.embedding_lookup` +* `tf.nn.embedding_lookup_sparse` ## Recurrent Neural Networks @@ -245,23 +245,23 @@ TensorFlow provides a number of methods for constructing Recurrent Neural Networks. Most accept an `RNNCell`-subclassed object (see the documentation for `tf.contrib.rnn`). -* @{tf.nn.dynamic_rnn} -* @{tf.nn.bidirectional_dynamic_rnn} -* @{tf.nn.raw_rnn} +* `tf.nn.dynamic_rnn` +* `tf.nn.bidirectional_dynamic_rnn` +* `tf.nn.raw_rnn` ## Connectionist Temporal Classification (CTC) -* @{tf.nn.ctc_loss} -* @{tf.nn.ctc_greedy_decoder} -* @{tf.nn.ctc_beam_search_decoder} +* `tf.nn.ctc_loss` +* `tf.nn.ctc_greedy_decoder` +* `tf.nn.ctc_beam_search_decoder` ## Evaluation The evaluation ops are useful for measuring the performance of a network. They are typically used at evaluation time. -* @{tf.nn.top_k} -* @{tf.nn.in_top_k} +* `tf.nn.top_k` +* `tf.nn.in_top_k` ## Candidate Sampling @@ -281,29 +281,29 @@ Reference](https://www.tensorflow.org/extras/candidate_sampling.pdf) TensorFlow provides the following sampled loss functions for faster training. -* @{tf.nn.nce_loss} -* @{tf.nn.sampled_softmax_loss} +* `tf.nn.nce_loss` +* `tf.nn.sampled_softmax_loss` ### Candidate Samplers TensorFlow provides the following samplers for randomly sampling candidate classes when using one of the sampled loss functions above. -* @{tf.nn.uniform_candidate_sampler} -* @{tf.nn.log_uniform_candidate_sampler} -* @{tf.nn.learned_unigram_candidate_sampler} -* @{tf.nn.fixed_unigram_candidate_sampler} +* `tf.nn.uniform_candidate_sampler` +* `tf.nn.log_uniform_candidate_sampler` +* `tf.nn.learned_unigram_candidate_sampler` +* `tf.nn.fixed_unigram_candidate_sampler` ### Miscellaneous candidate sampling utilities -* @{tf.nn.compute_accidental_hits} +* `tf.nn.compute_accidental_hits` ### Quantization ops -* @{tf.nn.quantized_conv2d} -* @{tf.nn.quantized_relu_x} -* @{tf.nn.quantized_max_pool} -* @{tf.nn.quantized_avg_pool} +* `tf.nn.quantized_conv2d` +* `tf.nn.quantized_relu_x` +* `tf.nn.quantized_max_pool` +* `tf.nn.quantized_avg_pool` ## Notes on SAME Convolution Padding diff --git a/tensorflow/docs_src/api_guides/python/python_io.md b/tensorflow/docs_src/api_guides/python/python_io.md index 06282e49d5..e7e82a8701 100644 --- a/tensorflow/docs_src/api_guides/python/python_io.md +++ b/tensorflow/docs_src/api_guides/python/python_io.md @@ -5,10 +5,10 @@ A TFRecords file represents a sequence of (binary) strings. The format is not random access, so it is suitable for streaming large amounts of data but not suitable if fast sharding or other non-sequential access is desired. -* @{tf.python_io.TFRecordWriter} -* @{tf.python_io.tf_record_iterator} -* @{tf.python_io.TFRecordCompressionType} -* @{tf.python_io.TFRecordOptions} +* `tf.python_io.TFRecordWriter` +* `tf.python_io.tf_record_iterator` +* `tf.python_io.TFRecordCompressionType` +* `tf.python_io.TFRecordOptions` - - - diff --git a/tensorflow/docs_src/api_guides/python/reading_data.md b/tensorflow/docs_src/api_guides/python/reading_data.md index d7d0904ae2..78c36d965c 100644 --- a/tensorflow/docs_src/api_guides/python/reading_data.md +++ b/tensorflow/docs_src/api_guides/python/reading_data.md @@ -16,7 +16,7 @@ There are four methods of getting data into a TensorFlow program: ## `tf.data` API -See the @{$guide/datasets} for an in-depth explanation of @{tf.data.Dataset}. +See the @{$guide/datasets} for an in-depth explanation of `tf.data.Dataset`. The `tf.data` API enables you to extract and preprocess data from different input/file formats, and apply transformations such as batching, shuffling, and mapping functions over the dataset. This is an improved version @@ -44,7 +44,7 @@ with tf.Session(): While you can replace any Tensor with feed data, including variables and constants, the best practice is to use a -@{tf.placeholder} node. A +`tf.placeholder` node. A `placeholder` exists solely to serve as the target of feeds. It is not initialized and contains no data. A placeholder generates an error if it is executed without a feed, so you won't forget to feed it. @@ -74,9 +74,9 @@ A typical queue-based pipeline for reading records from files has the following For the list of filenames, use either a constant string Tensor (like `["file0", "file1"]` or `[("file%d" % i) for i in range(2)]`) or the -@{tf.train.match_filenames_once} function. +`tf.train.match_filenames_once` function. -Pass the list of filenames to the @{tf.train.string_input_producer} function. +Pass the list of filenames to the `tf.train.string_input_producer` function. `string_input_producer` creates a FIFO queue for holding the filenames until the reader needs them. @@ -102,8 +102,8 @@ decode this string into the tensors that make up an example. To read text files in [comma-separated value (CSV) format](https://tools.ietf.org/html/rfc4180), use a -@{tf.TextLineReader} with the -@{tf.decode_csv} operation. For example: +`tf.TextLineReader` with the +`tf.decode_csv` operation. For example: ```python filename_queue = tf.train.string_input_producer(["file0.csv", "file1.csv"]) @@ -143,8 +143,8 @@ block while it waits for filenames from the queue. #### Fixed length records To read binary files in which each record is a fixed number of bytes, use -@{tf.FixedLengthRecordReader} -with the @{tf.decode_raw} operation. +`tf.FixedLengthRecordReader` +with the `tf.decode_raw` operation. The `decode_raw` op converts from a string to a uint8 tensor. For example, [the CIFAR-10 dataset](http://www.cs.toronto.edu/~kriz/cifar.html) @@ -169,12 +169,12 @@ containing as a field). You write a little program that gets your data, stuffs it in an `Example` protocol buffer, serializes the protocol buffer to a string, and then writes the string to a TFRecords file using the -@{tf.python_io.TFRecordWriter}. +`tf.python_io.TFRecordWriter`. For example, [`tensorflow/examples/how_tos/reading_data/convert_to_records.py`](https://www.tensorflow.org/code/tensorflow/examples/how_tos/reading_data/convert_to_records.py) converts MNIST data to this format. -The recommended way to read a TFRecord file is with a @{tf.data.TFRecordDataset}, [as in this example](https://www.tensorflow.org/code/tensorflow/examples/how_tos/reading_data/fully_connected_reader.py): +The recommended way to read a TFRecord file is with a `tf.data.TFRecordDataset`, [as in this example](https://www.tensorflow.org/code/tensorflow/examples/how_tos/reading_data/fully_connected_reader.py): ``` python dataset = tf.data.TFRecordDataset(filename) @@ -208,7 +208,7 @@ for an example. At the end of the pipeline we use another queue to batch together examples for training, evaluation, or inference. For this we use a queue that randomizes the order of examples, using the -@{tf.train.shuffle_batch}. +`tf.train.shuffle_batch`. Example: @@ -240,7 +240,7 @@ def input_pipeline(filenames, batch_size, num_epochs=None): If you need more parallelism or shuffling of examples between files, use multiple reader instances using the -@{tf.train.shuffle_batch_join}. +`tf.train.shuffle_batch_join`. For example: ``` @@ -266,7 +266,7 @@ epoch until all the files from the epoch have been started. (It is also usually sufficient to have a single thread filling the filename queue.) An alternative is to use a single reader via the -@{tf.train.shuffle_batch} +`tf.train.shuffle_batch` with `num_threads` bigger than 1. This will make it read from a single file at the same time (but faster than with 1 thread), instead of N files at once. This can be important: @@ -284,13 +284,13 @@ enough reading threads, that summary will stay above zero. You can ### Creating threads to prefetch using `QueueRunner` objects The short version: many of the `tf.train` functions listed above add -@{tf.train.QueueRunner} objects to your +`tf.train.QueueRunner` objects to your graph. These require that you call -@{tf.train.start_queue_runners} +`tf.train.start_queue_runners` before running any training or inference steps, or it will hang forever. This will start threads that run the input pipeline, filling the example queue so that the dequeue to get the examples will succeed. This is best combined with a -@{tf.train.Coordinator} to cleanly +`tf.train.Coordinator` to cleanly shut down these threads when there are errors. If you set a limit on the number of epochs, that will use an epoch counter that will need to be initialized. The recommended code pattern combining these is: @@ -343,25 +343,25 @@ queue. The helpers in `tf.train` that create these queues and enqueuing operations add -a @{tf.train.QueueRunner} to the +a `tf.train.QueueRunner` to the graph using the -@{tf.train.add_queue_runner} +`tf.train.add_queue_runner` function. Each `QueueRunner` is responsible for one stage, and holds the list of enqueue operations that need to be run in threads. Once the graph is constructed, the -@{tf.train.start_queue_runners} +`tf.train.start_queue_runners` function asks each QueueRunner in the graph to start its threads running the enqueuing operations. If all goes well, you can now run your training steps and the queues will be filled by the background threads. If you have set an epoch limit, at some point an attempt to dequeue examples will get an -@{tf.errors.OutOfRangeError}. This +`tf.errors.OutOfRangeError`. This is the TensorFlow equivalent of "end of file" (EOF) -- this means the epoch limit has been reached and no more examples are available. The last ingredient is the -@{tf.train.Coordinator}. This is responsible +`tf.train.Coordinator`. This is responsible for letting all the threads know if anything has signaled a shut down. Most commonly this would be because an exception was raised, for example one of the threads got an error when running some operation (or an ordinary Python @@ -396,21 +396,21 @@ associated with a single QueueRunner. If this isn't the last thread in the QueueRunner, the `OutOfRange` error just causes the one thread to exit. This allows the other threads, which are still finishing up their last file, to proceed until they finish as well. (Assuming you are using a -@{tf.train.Coordinator}, +`tf.train.Coordinator`, other types of errors will cause all the threads to stop.) Once all the reader threads hit the `OutOfRange` error, only then does the next queue, the example queue, gets closed. Again, the example queue will have some elements queued, so training will continue until those are exhausted. If the example queue is a -@{tf.RandomShuffleQueue}, say +`tf.RandomShuffleQueue`, say because you are using `shuffle_batch` or `shuffle_batch_join`, it normally will avoid ever having fewer than its `min_after_dequeue` attr elements buffered. However, once the queue is closed that restriction will be lifted and the queue will eventually empty. At that point the actual training threads, when they try and dequeue from example queue, will start getting `OutOfRange` errors and exiting. Once all the training threads are done, -@{tf.train.Coordinator.join} +`tf.train.Coordinator.join` will return and you can exit cleanly. ### Filtering records or producing multiple examples per record @@ -426,7 +426,7 @@ when calling one of the batching functions (such as `shuffle_batch` or SparseTensors don't play well with queues. If you use SparseTensors you have to decode the string records using -@{tf.parse_example} **after** +`tf.parse_example` **after** batching (instead of using `tf.parse_single_example` before batching). ## Preloaded data @@ -475,11 +475,11 @@ update it when training. Setting `collections=[]` keeps the variable out of the `GraphKeys.GLOBAL_VARIABLES` collection used for saving and restoring checkpoints. Either way, -@{tf.train.slice_input_producer} +`tf.train.slice_input_producer` can be used to produce a slice at a time. This shuffles the examples across an entire epoch, so further shuffling when batching is undesirable. So instead of using the `shuffle_batch` functions, we use the plain -@{tf.train.batch} function. To use +`tf.train.batch` function. To use multiple preprocessing threads, set the `num_threads` parameter to a number bigger than 1. @@ -500,7 +500,7 @@ sessions, maybe in separate processes: * The evaluation process restores the checkpoint files into an inference model that reads validation input data. -This is what is done @{tf.estimator$estimators} and manually in +This is what is done `tf.estimator` and manually in @{$deep_cnn#save-and-restore-checkpoints$the example CIFAR-10 model}. This has a couple of benefits: @@ -517,6 +517,6 @@ that allow the user to change the input pipeline without rebuilding the graph or session. Note: Regardless of the implementation, many -operations (like @{tf.layers.batch_normalization}, and @{tf.layers.dropout}) +operations (like `tf.layers.batch_normalization`, and `tf.layers.dropout`) need to know if they are in training or evaluation mode, and you must be careful to set this appropriately if you change the data source. diff --git a/tensorflow/docs_src/api_guides/python/regression_examples.md b/tensorflow/docs_src/api_guides/python/regression_examples.md index 7de2be0552..f8abbf0f97 100644 --- a/tensorflow/docs_src/api_guides/python/regression_examples.md +++ b/tensorflow/docs_src/api_guides/python/regression_examples.md @@ -8,25 +8,25 @@ to implement regression in Estimators: linear_regression.py - Use the @{tf.estimator.LinearRegressor} Estimator to train a + Use the `tf.estimator.LinearRegressor` Estimator to train a regression model on numeric data. linear_regression_categorical.py - Use the @{tf.estimator.LinearRegressor} Estimator to train a + Use the `tf.estimator.LinearRegressor` Estimator to train a regression model on categorical data. dnn_regression.py - Use the @{tf.estimator.DNNRegressor} Estimator to train a + Use the `tf.estimator.DNNRegressor` Estimator to train a regression model on discrete data with a deep neural network. custom_regression.py - Use @{tf.estimator.Estimator} to train a customized dnn + Use `tf.estimator.Estimator` to train a customized dnn regression model. @@ -219,7 +219,7 @@ The `custom_regression.py` example also trains a model that predicts the price of a car based on mixed real-valued and categorical input features, described by feature_columns. Unlike `linear_regression_categorical.py`, and `dnn_regression.py` this example does not use a pre-made estimator, but defines -a custom model using the base @{tf.estimator.Estimator$`Estimator`} class. The +a custom model using the base `tf.estimator.Estimator` class. The custom model is quite similar to the model defined by `dnn_regression.py`. The custom model is defined by the `model_fn` argument to the constructor. The @@ -227,6 +227,6 @@ customization is made more reusable through `params` dictionary, which is later passed through to the `model_fn` when the `model_fn` is called. The `model_fn` returns an -@{tf.estimator.EstimatorSpec$`EstimatorSpec`} which is a simple structure +`tf.estimator.EstimatorSpec` which is a simple structure indicating to the `Estimator` which operations should be run to accomplish various tasks. diff --git a/tensorflow/docs_src/api_guides/python/session_ops.md b/tensorflow/docs_src/api_guides/python/session_ops.md index 5176e3549c..5f41bcf209 100644 --- a/tensorflow/docs_src/api_guides/python/session_ops.md +++ b/tensorflow/docs_src/api_guides/python/session_ops.md @@ -1,7 +1,7 @@ # Tensor Handle Operations Note: Functions taking `Tensor` arguments can also take anything accepted by -@{tf.convert_to_tensor}. +`tf.convert_to_tensor`. [TOC] @@ -10,6 +10,6 @@ Note: Functions taking `Tensor` arguments can also take anything accepted by TensorFlow provides several operators that allows the user to keep tensors "in-place" across run calls. -* @{tf.get_session_handle} -* @{tf.get_session_tensor} -* @{tf.delete_session_tensor} +* `tf.get_session_handle` +* `tf.get_session_tensor` +* `tf.delete_session_tensor` diff --git a/tensorflow/docs_src/api_guides/python/sparse_ops.md b/tensorflow/docs_src/api_guides/python/sparse_ops.md index 19d5faba05..b360055ed0 100644 --- a/tensorflow/docs_src/api_guides/python/sparse_ops.md +++ b/tensorflow/docs_src/api_guides/python/sparse_ops.md @@ -1,7 +1,7 @@ # Sparse Tensors Note: Functions taking `Tensor` arguments can also take anything accepted by -@{tf.convert_to_tensor}. +`tf.convert_to_tensor`. [TOC] @@ -12,34 +12,34 @@ in multiple dimensions. Contrast this representation with `IndexedSlices`, which is efficient for representing tensors that are sparse in their first dimension, and dense along all other dimensions. -* @{tf.SparseTensor} -* @{tf.SparseTensorValue} +* `tf.SparseTensor` +* `tf.SparseTensorValue` ## Conversion -* @{tf.sparse_to_dense} -* @{tf.sparse_tensor_to_dense} -* @{tf.sparse_to_indicator} -* @{tf.sparse_merge} +* `tf.sparse_to_dense` +* `tf.sparse_tensor_to_dense` +* `tf.sparse_to_indicator` +* `tf.sparse_merge` ## Manipulation -* @{tf.sparse_concat} -* @{tf.sparse_reorder} -* @{tf.sparse_reshape} -* @{tf.sparse_split} -* @{tf.sparse_retain} -* @{tf.sparse_reset_shape} -* @{tf.sparse_fill_empty_rows} -* @{tf.sparse_transpose} +* `tf.sparse_concat` +* `tf.sparse_reorder` +* `tf.sparse_reshape` +* `tf.sparse_split` +* `tf.sparse_retain` +* `tf.sparse_reset_shape` +* `tf.sparse_fill_empty_rows` +* `tf.sparse_transpose` ## Reduction -* @{tf.sparse_reduce_sum} -* @{tf.sparse_reduce_sum_sparse} +* `tf.sparse_reduce_sum` +* `tf.sparse_reduce_sum_sparse` ## Math Operations -* @{tf.sparse_add} -* @{tf.sparse_softmax} -* @{tf.sparse_tensor_dense_matmul} -* @{tf.sparse_maximum} -* @{tf.sparse_minimum} +* `tf.sparse_add` +* `tf.sparse_softmax` +* `tf.sparse_tensor_dense_matmul` +* `tf.sparse_maximum` +* `tf.sparse_minimum` diff --git a/tensorflow/docs_src/api_guides/python/spectral_ops.md b/tensorflow/docs_src/api_guides/python/spectral_ops.md index dd13802f00..f6d109a3a0 100644 --- a/tensorflow/docs_src/api_guides/python/spectral_ops.md +++ b/tensorflow/docs_src/api_guides/python/spectral_ops.md @@ -2,25 +2,25 @@ [TOC] -The @{tf.spectral} module supports several spectral decomposition operations +The `tf.spectral` module supports several spectral decomposition operations that you can use to transform Tensors of real and complex signals. ## Discrete Fourier Transforms -* @{tf.spectral.fft} -* @{tf.spectral.ifft} -* @{tf.spectral.fft2d} -* @{tf.spectral.ifft2d} -* @{tf.spectral.fft3d} -* @{tf.spectral.ifft3d} -* @{tf.spectral.rfft} -* @{tf.spectral.irfft} -* @{tf.spectral.rfft2d} -* @{tf.spectral.irfft2d} -* @{tf.spectral.rfft3d} -* @{tf.spectral.irfft3d} +* `tf.spectral.fft` +* `tf.spectral.ifft` +* `tf.spectral.fft2d` +* `tf.spectral.ifft2d` +* `tf.spectral.fft3d` +* `tf.spectral.ifft3d` +* `tf.spectral.rfft` +* `tf.spectral.irfft` +* `tf.spectral.rfft2d` +* `tf.spectral.irfft2d` +* `tf.spectral.rfft3d` +* `tf.spectral.irfft3d` ## Discrete Cosine Transforms -* @{tf.spectral.dct} -* @{tf.spectral.idct} +* `tf.spectral.dct` +* `tf.spectral.idct` diff --git a/tensorflow/docs_src/api_guides/python/state_ops.md b/tensorflow/docs_src/api_guides/python/state_ops.md index ec2d877386..fc55ea1481 100644 --- a/tensorflow/docs_src/api_guides/python/state_ops.md +++ b/tensorflow/docs_src/api_guides/python/state_ops.md @@ -1,68 +1,68 @@ # Variables Note: Functions taking `Tensor` arguments can also take anything accepted by -@{tf.convert_to_tensor}. +`tf.convert_to_tensor`. [TOC] ## Variables -* @{tf.Variable} +* `tf.Variable` ## Variable helper functions TensorFlow provides a set of functions to help manage the set of variables collected in the graph. -* @{tf.global_variables} -* @{tf.local_variables} -* @{tf.model_variables} -* @{tf.trainable_variables} -* @{tf.moving_average_variables} -* @{tf.global_variables_initializer} -* @{tf.local_variables_initializer} -* @{tf.variables_initializer} -* @{tf.is_variable_initialized} -* @{tf.report_uninitialized_variables} -* @{tf.assert_variables_initialized} -* @{tf.assign} -* @{tf.assign_add} -* @{tf.assign_sub} +* `tf.global_variables` +* `tf.local_variables` +* `tf.model_variables` +* `tf.trainable_variables` +* `tf.moving_average_variables` +* `tf.global_variables_initializer` +* `tf.local_variables_initializer` +* `tf.variables_initializer` +* `tf.is_variable_initialized` +* `tf.report_uninitialized_variables` +* `tf.assert_variables_initialized` +* `tf.assign` +* `tf.assign_add` +* `tf.assign_sub` ## Saving and Restoring Variables -* @{tf.train.Saver} -* @{tf.train.latest_checkpoint} -* @{tf.train.get_checkpoint_state} -* @{tf.train.update_checkpoint_state} +* `tf.train.Saver` +* `tf.train.latest_checkpoint` +* `tf.train.get_checkpoint_state` +* `tf.train.update_checkpoint_state` ## Sharing Variables TensorFlow provides several classes and operations that you can use to create variables contingent on certain conditions. -* @{tf.get_variable} -* @{tf.get_local_variable} -* @{tf.VariableScope} -* @{tf.variable_scope} -* @{tf.variable_op_scope} -* @{tf.get_variable_scope} -* @{tf.make_template} -* @{tf.no_regularizer} -* @{tf.constant_initializer} -* @{tf.random_normal_initializer} -* @{tf.truncated_normal_initializer} -* @{tf.random_uniform_initializer} -* @{tf.uniform_unit_scaling_initializer} -* @{tf.zeros_initializer} -* @{tf.ones_initializer} -* @{tf.orthogonal_initializer} +* `tf.get_variable` +* `tf.get_local_variable` +* `tf.VariableScope` +* `tf.variable_scope` +* `tf.variable_op_scope` +* `tf.get_variable_scope` +* `tf.make_template` +* `tf.no_regularizer` +* `tf.constant_initializer` +* `tf.random_normal_initializer` +* `tf.truncated_normal_initializer` +* `tf.random_uniform_initializer` +* `tf.uniform_unit_scaling_initializer` +* `tf.zeros_initializer` +* `tf.ones_initializer` +* `tf.orthogonal_initializer` ## Variable Partitioners for Sharding -* @{tf.fixed_size_partitioner} -* @{tf.variable_axis_size_partitioner} -* @{tf.min_max_variable_partitioner} +* `tf.fixed_size_partitioner` +* `tf.variable_axis_size_partitioner` +* `tf.min_max_variable_partitioner` ## Sparse Variable Updates @@ -73,38 +73,38 @@ only a small subset of embedding vectors change in any given step. Since a sparse update of a large tensor may be generated automatically during gradient computation (as in the gradient of -@{tf.gather}), -an @{tf.IndexedSlices} class is provided that encapsulates a set +`tf.gather`), +an `tf.IndexedSlices` class is provided that encapsulates a set of sparse indices and values. `IndexedSlices` objects are detected and handled automatically by the optimizers in most cases. -* @{tf.scatter_update} -* @{tf.scatter_add} -* @{tf.scatter_sub} -* @{tf.scatter_mul} -* @{tf.scatter_div} -* @{tf.scatter_min} -* @{tf.scatter_max} -* @{tf.scatter_nd_update} -* @{tf.scatter_nd_add} -* @{tf.scatter_nd_sub} -* @{tf.sparse_mask} -* @{tf.IndexedSlices} +* `tf.scatter_update` +* `tf.scatter_add` +* `tf.scatter_sub` +* `tf.scatter_mul` +* `tf.scatter_div` +* `tf.scatter_min` +* `tf.scatter_max` +* `tf.scatter_nd_update` +* `tf.scatter_nd_add` +* `tf.scatter_nd_sub` +* `tf.sparse_mask` +* `tf.IndexedSlices` ### Read-only Lookup Tables -* @{tf.initialize_all_tables} -* @{tf.tables_initializer} +* `tf.initialize_all_tables` +* `tf.tables_initializer` ## Exporting and Importing Meta Graphs -* @{tf.train.export_meta_graph} -* @{tf.train.import_meta_graph} +* `tf.train.export_meta_graph` +* `tf.train.import_meta_graph` # Deprecated functions (removed after 2017-03-02). Please don't use them. -* @{tf.all_variables} -* @{tf.initialize_all_variables} -* @{tf.initialize_local_variables} -* @{tf.initialize_variables} +* `tf.all_variables` +* `tf.initialize_all_variables` +* `tf.initialize_local_variables` +* `tf.initialize_variables` diff --git a/tensorflow/docs_src/api_guides/python/string_ops.md b/tensorflow/docs_src/api_guides/python/string_ops.md index e9be4f156a..24a3aad642 100644 --- a/tensorflow/docs_src/api_guides/python/string_ops.md +++ b/tensorflow/docs_src/api_guides/python/string_ops.md @@ -1,7 +1,7 @@ # Strings Note: Functions taking `Tensor` arguments can also take anything accepted by -@{tf.convert_to_tensor}. +`tf.convert_to_tensor`. [TOC] @@ -10,30 +10,30 @@ Note: Functions taking `Tensor` arguments can also take anything accepted by String hashing ops take a string input tensor and map each element to an integer. -* @{tf.string_to_hash_bucket_fast} -* @{tf.string_to_hash_bucket_strong} -* @{tf.string_to_hash_bucket} +* `tf.string_to_hash_bucket_fast` +* `tf.string_to_hash_bucket_strong` +* `tf.string_to_hash_bucket` ## Joining String joining ops concatenate elements of input string tensors to produce a new string tensor. -* @{tf.reduce_join} -* @{tf.string_join} +* `tf.reduce_join` +* `tf.string_join` ## Splitting -* @{tf.string_split} -* @{tf.substr} +* `tf.string_split` +* `tf.substr` ## Conversion -* @{tf.as_string} -* @{tf.string_to_number} +* `tf.as_string` +* `tf.string_to_number` -* @{tf.decode_raw} -* @{tf.decode_csv} +* `tf.decode_raw` +* `tf.decode_csv` -* @{tf.encode_base64} -* @{tf.decode_base64} +* `tf.encode_base64` +* `tf.decode_base64` diff --git a/tensorflow/docs_src/api_guides/python/summary.md b/tensorflow/docs_src/api_guides/python/summary.md index eda119ab24..e290703b7d 100644 --- a/tensorflow/docs_src/api_guides/python/summary.md +++ b/tensorflow/docs_src/api_guides/python/summary.md @@ -7,17 +7,17 @@ then accessible in tools such as @{$summaries_and_tensorboard$TensorBoard}. ## Generation of Summaries ### Class for writing Summaries -* @{tf.summary.FileWriter} -* @{tf.summary.FileWriterCache} +* `tf.summary.FileWriter` +* `tf.summary.FileWriterCache` ### Summary Ops -* @{tf.summary.tensor_summary} -* @{tf.summary.scalar} -* @{tf.summary.histogram} -* @{tf.summary.audio} -* @{tf.summary.image} -* @{tf.summary.merge} -* @{tf.summary.merge_all} +* `tf.summary.tensor_summary` +* `tf.summary.scalar` +* `tf.summary.histogram` +* `tf.summary.audio` +* `tf.summary.image` +* `tf.summary.merge` +* `tf.summary.merge_all` ## Utilities -* @{tf.summary.get_summary_description} +* `tf.summary.get_summary_description` diff --git a/tensorflow/docs_src/api_guides/python/test.md b/tensorflow/docs_src/api_guides/python/test.md index 5dc88124e7..b6e0a332b9 100644 --- a/tensorflow/docs_src/api_guides/python/test.md +++ b/tensorflow/docs_src/api_guides/python/test.md @@ -23,25 +23,25 @@ which adds methods relevant to TensorFlow tests. Here is an example: ``` `tf.test.TestCase` inherits from `unittest.TestCase` but adds a few additional -methods. See @{tf.test.TestCase} for details. +methods. See `tf.test.TestCase` for details. -* @{tf.test.main} -* @{tf.test.TestCase} -* @{tf.test.test_src_dir_path} +* `tf.test.main` +* `tf.test.TestCase` +* `tf.test.test_src_dir_path` ## Utilities Note: `tf.test.mock` is an alias to the python `mock` or `unittest.mock` depending on the python version. -* @{tf.test.assert_equal_graph_def} -* @{tf.test.get_temp_dir} -* @{tf.test.is_built_with_cuda} -* @{tf.test.is_gpu_available} -* @{tf.test.gpu_device_name} +* `tf.test.assert_equal_graph_def` +* `tf.test.get_temp_dir` +* `tf.test.is_built_with_cuda` +* `tf.test.is_gpu_available` +* `tf.test.gpu_device_name` ## Gradient checking -@{tf.test.compute_gradient} and @{tf.test.compute_gradient_error} perform +`tf.test.compute_gradient` and `tf.test.compute_gradient_error` perform numerical differentiation of graphs for comparison against registered analytic gradients. diff --git a/tensorflow/docs_src/api_guides/python/tfdbg.md b/tensorflow/docs_src/api_guides/python/tfdbg.md index 2212a2da0e..9778cdc0b0 100644 --- a/tensorflow/docs_src/api_guides/python/tfdbg.md +++ b/tensorflow/docs_src/api_guides/python/tfdbg.md @@ -8,9 +8,9 @@ Public Python API of TensorFlow Debugger (tfdbg). These functions help you modify `RunOptions` to specify which `Tensor`s are to be watched when the TensorFlow graph is executed at runtime. -* @{tfdbg.add_debug_tensor_watch} -* @{tfdbg.watch_graph} -* @{tfdbg.watch_graph_with_blacklists} +* `tfdbg.add_debug_tensor_watch` +* `tfdbg.watch_graph` +* `tfdbg.watch_graph_with_blacklists` ## Classes for debug-dump data and directories @@ -18,13 +18,13 @@ be watched when the TensorFlow graph is executed at runtime. These classes allow you to load and inspect tensor values dumped from TensorFlow graphs during runtime. -* @{tfdbg.DebugTensorDatum} -* @{tfdbg.DebugDumpDir} +* `tfdbg.DebugTensorDatum` +* `tfdbg.DebugDumpDir` ## Functions for loading debug-dump data -* @{tfdbg.load_tensor_from_event_file} +* `tfdbg.load_tensor_from_event_file` ## Tensor-value predicates @@ -32,7 +32,7 @@ TensorFlow graphs during runtime. Built-in tensor-filter predicates to support conditional breakpoint between runs. See `DebugDumpDir.find()` for more details. -* @{tfdbg.has_inf_or_nan} +* `tfdbg.has_inf_or_nan` ## Session wrapper class and `SessionRunHook` implementations @@ -44,7 +44,7 @@ These classes allow you to * generate `SessionRunHook` objects to debug `tf.contrib.learn` models (see `DumpingDebugHook` and `LocalCLIDebugHook`). -* @{tfdbg.DumpingDebugHook} -* @{tfdbg.DumpingDebugWrapperSession} -* @{tfdbg.LocalCLIDebugHook} -* @{tfdbg.LocalCLIDebugWrapperSession} +* `tfdbg.DumpingDebugHook` +* `tfdbg.DumpingDebugWrapperSession` +* `tfdbg.LocalCLIDebugHook` +* `tfdbg.LocalCLIDebugWrapperSession` diff --git a/tensorflow/docs_src/api_guides/python/threading_and_queues.md b/tensorflow/docs_src/api_guides/python/threading_and_queues.md index 8ad4c4c075..48f0778b73 100644 --- a/tensorflow/docs_src/api_guides/python/threading_and_queues.md +++ b/tensorflow/docs_src/api_guides/python/threading_and_queues.md @@ -25,7 +25,7 @@ longer holds, the queue will unblock the step and allow execution to proceed. TensorFlow implements several classes of queue. The principal difference between these classes is the order that items are removed from the queue. To get a feel for queues, let's consider a simple example. We will create a "first in, first -out" queue (@{tf.FIFOQueue}) and fill it with zeros. Then we'll construct a +out" queue (`tf.FIFOQueue`) and fill it with zeros. Then we'll construct a graph that takes an item off the queue, adds one to that item, and puts it back on the end of the queue. Slowly, the numbers on the queue increase. @@ -47,8 +47,8 @@ Now that you have a bit of a feel for queues, let's dive into the details... ## Queue usage overview -Queues, such as @{tf.FIFOQueue} -and @{tf.RandomShuffleQueue}, +Queues, such as `tf.FIFOQueue` +and `tf.RandomShuffleQueue`, are important TensorFlow objects that aid in computing tensors asynchronously in a graph. @@ -59,11 +59,11 @@ prepare inputs for training a model as follows: * A training thread executes a training op that dequeues mini-batches from the queue -We recommend using the @{tf.data.Dataset.shuffle$`shuffle`} -and @{tf.data.Dataset.batch$`batch`} methods of a -@{tf.data.Dataset$`Dataset`} to accomplish this. However, if you'd prefer +We recommend using the `tf.data.Dataset.shuffle` +and `tf.data.Dataset.batch` methods of a +`tf.data.Dataset` to accomplish this. However, if you'd prefer to use a queue-based version instead, you can find a full implementation in the -@{tf.train.shuffle_batch} function. +`tf.train.shuffle_batch` function. For demonstration purposes a simplified implementation is given below. @@ -93,8 +93,8 @@ def simple_shuffle_batch(source, capacity, batch_size=10): return queue.dequeue_many(batch_size) ``` -Once started by @{tf.train.start_queue_runners}, or indirectly through -@{tf.train.MonitoredSession}, the `QueueRunner` will launch the +Once started by `tf.train.start_queue_runners`, or indirectly through +`tf.train.MonitoredSession`, the `QueueRunner` will launch the threads in the background to fill the queue. Meanwhile the main thread will execute the `dequeue_many` op to pull data from it. Note how these ops do not depend on each other, except indirectly through the internal state of the queue. @@ -126,7 +126,7 @@ with tf.train.MonitoredSession() as sess: ``` For most use cases, the automatic thread startup and management provided -by @{tf.train.MonitoredSession} is sufficient. In the rare case that it is not, +by `tf.train.MonitoredSession` is sufficient. In the rare case that it is not, TensorFlow provides tools for manually managing your threads and queues. ## Manual Thread Management @@ -139,8 +139,8 @@ threads must be able to stop together, exceptions must be caught and reported, and queues must be properly closed when stopping. TensorFlow provides two classes to help: -@{tf.train.Coordinator} and -@{tf.train.QueueRunner}. These two classes +`tf.train.Coordinator` and +`tf.train.QueueRunner`. These two classes are designed to be used together. The `Coordinator` class helps multiple threads stop together and report exceptions to a program that waits for them to stop. The `QueueRunner` class is used to create a number of threads cooperating to @@ -148,14 +148,14 @@ enqueue tensors in the same queue. ### Coordinator -The @{tf.train.Coordinator} class manages background threads in a TensorFlow +The `tf.train.Coordinator` class manages background threads in a TensorFlow program and helps multiple threads stop together. Its key methods are: -* @{tf.train.Coordinator.should_stop}: returns `True` if the threads should stop. -* @{tf.train.Coordinator.request_stop}: requests that threads should stop. -* @{tf.train.Coordinator.join}: waits until the specified threads have stopped. +* `tf.train.Coordinator.should_stop`: returns `True` if the threads should stop. +* `tf.train.Coordinator.request_stop`: requests that threads should stop. +* `tf.train.Coordinator.join`: waits until the specified threads have stopped. You first create a `Coordinator` object, and then create a number of threads that use the coordinator. The threads typically run loops that stop when @@ -191,11 +191,11 @@ coord.join(threads) Obviously, the coordinator can manage threads doing very different things. They don't have to be all the same as in the example above. The coordinator -also has support to capture and report exceptions. See the @{tf.train.Coordinator} documentation for more details. +also has support to capture and report exceptions. See the `tf.train.Coordinator` documentation for more details. ### QueueRunner -The @{tf.train.QueueRunner} class creates a number of threads that repeatedly +The `tf.train.QueueRunner` class creates a number of threads that repeatedly run an enqueue op. These threads can use a coordinator to stop together. In addition, a queue runner will run a *closer operation* that closes the queue if an exception is reported to the coordinator. diff --git a/tensorflow/docs_src/api_guides/python/train.md b/tensorflow/docs_src/api_guides/python/train.md index cbc5052946..a118123665 100644 --- a/tensorflow/docs_src/api_guides/python/train.md +++ b/tensorflow/docs_src/api_guides/python/train.md @@ -1,7 +1,7 @@ # Training [TOC] -@{tf.train} provides a set of classes and functions that help train models. +`tf.train` provides a set of classes and functions that help train models. ## Optimizers @@ -12,19 +12,19 @@ optimization algorithms such as GradientDescent and Adagrad. You never instantiate the Optimizer class itself, but instead instantiate one of the subclasses. -* @{tf.train.Optimizer} -* @{tf.train.GradientDescentOptimizer} -* @{tf.train.AdadeltaOptimizer} -* @{tf.train.AdagradOptimizer} -* @{tf.train.AdagradDAOptimizer} -* @{tf.train.MomentumOptimizer} -* @{tf.train.AdamOptimizer} -* @{tf.train.FtrlOptimizer} -* @{tf.train.ProximalGradientDescentOptimizer} -* @{tf.train.ProximalAdagradOptimizer} -* @{tf.train.RMSPropOptimizer} +* `tf.train.Optimizer` +* `tf.train.GradientDescentOptimizer` +* `tf.train.AdadeltaOptimizer` +* `tf.train.AdagradOptimizer` +* `tf.train.AdagradDAOptimizer` +* `tf.train.MomentumOptimizer` +* `tf.train.AdamOptimizer` +* `tf.train.FtrlOptimizer` +* `tf.train.ProximalGradientDescentOptimizer` +* `tf.train.ProximalAdagradOptimizer` +* `tf.train.RMSPropOptimizer` -See @{tf.contrib.opt} for more optimizers. +See `tf.contrib.opt` for more optimizers. ## Gradient Computation @@ -34,10 +34,10 @@ optimizer classes automatically compute derivatives on your graph, but creators of new Optimizers or expert users can call the lower-level functions below. -* @{tf.gradients} -* @{tf.AggregationMethod} -* @{tf.stop_gradient} -* @{tf.hessians} +* `tf.gradients` +* `tf.AggregationMethod` +* `tf.stop_gradient` +* `tf.hessians` ## Gradient Clipping @@ -47,22 +47,22 @@ functions to your graph. You can use these functions to perform general data clipping, but they're particularly useful for handling exploding or vanishing gradients. -* @{tf.clip_by_value} -* @{tf.clip_by_norm} -* @{tf.clip_by_average_norm} -* @{tf.clip_by_global_norm} -* @{tf.global_norm} +* `tf.clip_by_value` +* `tf.clip_by_norm` +* `tf.clip_by_average_norm` +* `tf.clip_by_global_norm` +* `tf.global_norm` ## Decaying the learning rate -* @{tf.train.exponential_decay} -* @{tf.train.inverse_time_decay} -* @{tf.train.natural_exp_decay} -* @{tf.train.piecewise_constant} -* @{tf.train.polynomial_decay} -* @{tf.train.cosine_decay} -* @{tf.train.linear_cosine_decay} -* @{tf.train.noisy_linear_cosine_decay} +* `tf.train.exponential_decay` +* `tf.train.inverse_time_decay` +* `tf.train.natural_exp_decay` +* `tf.train.piecewise_constant` +* `tf.train.polynomial_decay` +* `tf.train.cosine_decay` +* `tf.train.linear_cosine_decay` +* `tf.train.noisy_linear_cosine_decay` ## Moving Averages @@ -70,7 +70,7 @@ Some training algorithms, such as GradientDescent and Momentum often benefit from maintaining a moving average of variables during optimization. Using the moving averages for evaluations often improve results significantly. -* @{tf.train.ExponentialMovingAverage} +* `tf.train.ExponentialMovingAverage` ## Coordinator and QueueRunner @@ -79,61 +79,61 @@ for how to use threads and queues. For documentation on the Queue API, see @{$python/io_ops#queues$Queues}. -* @{tf.train.Coordinator} -* @{tf.train.QueueRunner} -* @{tf.train.LooperThread} -* @{tf.train.add_queue_runner} -* @{tf.train.start_queue_runners} +* `tf.train.Coordinator` +* `tf.train.QueueRunner` +* `tf.train.LooperThread` +* `tf.train.add_queue_runner` +* `tf.train.start_queue_runners` ## Distributed execution See @{$distributed$Distributed TensorFlow} for more information about how to configure a distributed TensorFlow program. -* @{tf.train.Server} -* @{tf.train.Supervisor} -* @{tf.train.SessionManager} -* @{tf.train.ClusterSpec} -* @{tf.train.replica_device_setter} -* @{tf.train.MonitoredTrainingSession} -* @{tf.train.MonitoredSession} -* @{tf.train.SingularMonitoredSession} -* @{tf.train.Scaffold} -* @{tf.train.SessionCreator} -* @{tf.train.ChiefSessionCreator} -* @{tf.train.WorkerSessionCreator} +* `tf.train.Server` +* `tf.train.Supervisor` +* `tf.train.SessionManager` +* `tf.train.ClusterSpec` +* `tf.train.replica_device_setter` +* `tf.train.MonitoredTrainingSession` +* `tf.train.MonitoredSession` +* `tf.train.SingularMonitoredSession` +* `tf.train.Scaffold` +* `tf.train.SessionCreator` +* `tf.train.ChiefSessionCreator` +* `tf.train.WorkerSessionCreator` ## Reading Summaries from Event Files See @{$summaries_and_tensorboard$Summaries and TensorBoard} for an overview of summaries, event files, and visualization in TensorBoard. -* @{tf.train.summary_iterator} +* `tf.train.summary_iterator` ## Training Hooks Hooks are tools that run in the process of training/evaluation of the model. -* @{tf.train.SessionRunHook} -* @{tf.train.SessionRunArgs} -* @{tf.train.SessionRunContext} -* @{tf.train.SessionRunValues} -* @{tf.train.LoggingTensorHook} -* @{tf.train.StopAtStepHook} -* @{tf.train.CheckpointSaverHook} -* @{tf.train.NewCheckpointReader} -* @{tf.train.StepCounterHook} -* @{tf.train.NanLossDuringTrainingError} -* @{tf.train.NanTensorHook} -* @{tf.train.SummarySaverHook} -* @{tf.train.GlobalStepWaiterHook} -* @{tf.train.FinalOpsHook} -* @{tf.train.FeedFnHook} +* `tf.train.SessionRunHook` +* `tf.train.SessionRunArgs` +* `tf.train.SessionRunContext` +* `tf.train.SessionRunValues` +* `tf.train.LoggingTensorHook` +* `tf.train.StopAtStepHook` +* `tf.train.CheckpointSaverHook` +* `tf.train.NewCheckpointReader` +* `tf.train.StepCounterHook` +* `tf.train.NanLossDuringTrainingError` +* `tf.train.NanTensorHook` +* `tf.train.SummarySaverHook` +* `tf.train.GlobalStepWaiterHook` +* `tf.train.FinalOpsHook` +* `tf.train.FeedFnHook` ## Training Utilities -* @{tf.train.global_step} -* @{tf.train.basic_train_loop} -* @{tf.train.get_global_step} -* @{tf.train.assert_global_step} -* @{tf.train.write_graph} +* `tf.train.global_step` +* `tf.train.basic_train_loop` +* `tf.train.get_global_step` +* `tf.train.assert_global_step` +* `tf.train.write_graph` diff --git a/tensorflow/docs_src/deploy/distributed.md b/tensorflow/docs_src/deploy/distributed.md index fc3a60603f..6a760f53c8 100644 --- a/tensorflow/docs_src/deploy/distributed.md +++ b/tensorflow/docs_src/deploy/distributed.md @@ -21,7 +21,7 @@ $ python ``` The -@{tf.train.Server.create_local_server} +`tf.train.Server.create_local_server` method creates a single-process cluster, with an in-process server. ## Create a cluster @@ -55,7 +55,7 @@ the following: The cluster specification dictionary maps job names to lists of network addresses. Pass this dictionary to -the @{tf.train.ClusterSpec} +the `tf.train.ClusterSpec` constructor. For example: @@ -84,10 +84,10 @@ tf.train.ClusterSpec({ ### Create a `tf.train.Server` instance in each task -A @{tf.train.Server} object contains a +A `tf.train.Server` object contains a set of local devices, a set of connections to other tasks in its `tf.train.ClusterSpec`, and a -@{tf.Session} that can use these +`tf.Session` that can use these to perform a distributed computation. Each server is a member of a specific named job and has a task index within that job. A server can communicate with any other server in the cluster. @@ -117,7 +117,7 @@ which you'd like to see support, please raise a ## Specifying distributed devices in your model To place operations on a particular process, you can use the same -@{tf.device} +`tf.device` function that is used to specify whether ops run on the CPU or GPU. For example: ```python @@ -165,7 +165,7 @@ simplify the work of specifying a replicated model. Possible approaches include: for each `/job:worker` task, typically in the same process as the worker task. Each client builds a similar graph containing the parameters (pinned to `/job:ps` as before using - @{tf.train.replica_device_setter} + `tf.train.replica_device_setter` to map them deterministically to the same tasks); and a single copy of the compute-intensive part of the model, pinned to the local task in `/job:worker`. @@ -180,7 +180,7 @@ simplify the work of specifying a replicated model. Possible approaches include: gradient averaging as in the [CIFAR-10 multi-GPU trainer](https://github.com/tensorflow/models/tree/master/tutorials/image/cifar10/cifar10_multi_gpu_train.py)), and between-graph replication (e.g. using the - @{tf.train.SyncReplicasOptimizer}). + `tf.train.SyncReplicasOptimizer`). ### Putting it all together: example trainer program @@ -318,7 +318,7 @@ A TensorFlow cluster comprises one or more "jobs", each divided into lists of one or more "tasks". A cluster is typically dedicated to a particular high-level objective, such as training a neural network, using many machines in parallel. A cluster is defined by -a @{tf.train.ClusterSpec} object. +a `tf.train.ClusterSpec` object. **Job** @@ -344,7 +344,7 @@ to a single process. A task belongs to a particular "job" and is identified by its index within that job's list of tasks. **TensorFlow server** A process running -a @{tf.train.Server} instance, which is +a `tf.train.Server` instance, which is a member of a cluster, and exports a "master service" and "worker service". **Worker service** diff --git a/tensorflow/docs_src/extend/adding_an_op.md b/tensorflow/docs_src/extend/adding_an_op.md index 1b028be4ea..6e96cfc532 100644 --- a/tensorflow/docs_src/extend/adding_an_op.md +++ b/tensorflow/docs_src/extend/adding_an_op.md @@ -46,7 +46,7 @@ To incorporate your custom op you'll need to: 4. Write a function to compute gradients for the op (optional). 5. Test the op. We usually do this in Python for convenience, but you can also test the op in C++. If you define gradients, you can verify them with the - Python @{tf.test.compute_gradient_error$gradient checker}. + Python `tf.test.compute_gradient_error`. See [`relu_op_test.py`](https://www.tensorflow.org/code/tensorflow/python/kernel_tests/relu_op_test.py) as an example that tests the forward functions of Relu-like operators and @@ -388,7 +388,7 @@ $ bazel build --config opt //tensorflow/core/user_ops:zero_out.so ## Use the op in Python TensorFlow Python API provides the -@{tf.load_op_library} function to +`tf.load_op_library` function to load the dynamic library and register the op with the TensorFlow framework. `load_op_library` returns a Python module that contains the Python wrappers for the op and the kernel. Thus, once you have built the op, you can @@ -538,7 +538,7 @@ REGISTER_OP("ZeroOut") ``` (Note that the set of [attribute types](#attr_types) is different from the -@{tf.DType$tensor types} used for inputs and outputs.) +`tf.DType` used for inputs and outputs.) Your kernel can then access this attr in its constructor via the `context` parameter: @@ -615,7 +615,7 @@ define an attr with constraints, you can use the following ``s: * `{, }`: The value is of type `type`, and must be one of `` or ``, where `` and `` are supported - @{tf.DType$tensor types}. You don't specify + `tf.DType`. You don't specify that the type of the attr is `type`. This is implied when you have a list of types in `{...}`. For example, in this case the attr `t` is a type that must be an `int32`, a `float`, or a `bool`: @@ -714,7 +714,7 @@ REGISTER_OP("AttrDefaultExampleForAllTypes") ``` Note in particular that the values of type `type` -use @{tf.DType$the `DT_*` names for the types}. +use `tf.DType`. #### Polymorphism @@ -1056,7 +1056,7 @@ expressions: `string`). This specifies a single tensor of the given type. See - @{tf.DType$the list of supported Tensor types}. + `tf.DType`. ```c++ REGISTER_OP("BuiltInTypesExample") @@ -1098,8 +1098,7 @@ expressions: * For a sequence of tensors with the same type: ` * `, where `` is the name of an [Attr](#attrs) with type `int`. The `` can - either be - @{tf.DType$a specific type like `int32` or `float`}, + either be a `tf.DType`, or the name of an attr with type `type`. As an example of the first, this op accepts a list of `int32` tensors: @@ -1202,7 +1201,7 @@ There are several examples of kernels with GPU support in Notice some kernels have a CPU version in a `.cc` file, a GPU version in a file ending in `_gpu.cu.cc`, and some code shared in common in a `.h` file. -For example, the @{tf.pad} has +For example, the `tf.pad` has everything but the GPU kernel in [`tensorflow/core/kernels/pad_op.cc`][pad_op]. The GPU kernel is in [`tensorflow/core/kernels/pad_op_gpu.cu.cc`](https://www.tensorflow.org/code/tensorflow/core/kernels/pad_op_gpu.cu.cc), @@ -1307,16 +1306,16 @@ def _zero_out_grad(op, grad): ``` Details about registering gradient functions with -@{tf.RegisterGradient}: +`tf.RegisterGradient`: * For an op with one output, the gradient function will take an - @{tf.Operation} `op` and a - @{tf.Tensor} `grad` and build new ops + `tf.Operation` `op` and a + `tf.Tensor` `grad` and build new ops out of the tensors [`op.inputs[i]`](../../api_docs/python/framework.md#Operation.inputs), [`op.outputs[i]`](../../api_docs/python/framework.md#Operation.outputs), and `grad`. Information about any attrs can be found via - @{tf.Operation.get_attr}. + `tf.Operation.get_attr`. * If the op has multiple outputs, the gradient function will take `op` and `grads`, where `grads` is a list of gradients with respect to each output. diff --git a/tensorflow/docs_src/extend/architecture.md b/tensorflow/docs_src/extend/architecture.md index 84435a57f2..83d70c9468 100644 --- a/tensorflow/docs_src/extend/architecture.md +++ b/tensorflow/docs_src/extend/architecture.md @@ -81,7 +81,7 @@ implementation from all client languages. Most of the training libraries are still Python-only, but C++ does have support for efficient inference. The client creates a session, which sends the graph definition to the -distributed master as a @{tf.GraphDef} +distributed master as a `tf.GraphDef` protocol buffer. When the client evaluates a node or nodes in the graph, the evaluation triggers a call to the distributed master to initiate computation. @@ -96,7 +96,7 @@ feature vector (x), adds a bias term (b) and saves the result in a variable ### Code -* @{tf.Session} +* `tf.Session` ## Distributed master diff --git a/tensorflow/docs_src/extend/new_data_formats.md b/tensorflow/docs_src/extend/new_data_formats.md index abbf47910e..47a8344b70 100644 --- a/tensorflow/docs_src/extend/new_data_formats.md +++ b/tensorflow/docs_src/extend/new_data_formats.md @@ -15,25 +15,24 @@ We divide the task of supporting a file format into two pieces: * Record formats: We use decoder or parsing ops to turn a string record into tensors usable by TensorFlow. -For example, to read a -[CSV file](https://en.wikipedia.org/wiki/Comma-separated_values), we use -@{tf.data.TextLineDataset$a dataset for reading text files line-by-line} -and then @{tf.data.Dataset.map$map} an -@{tf.decode_csv$op} that parses CSV data from each line of text in the dataset. +For example, to re-implement `tf.contrib.data.make_csv_dataset` function, we +could use `tf.data.TextLineDataset` to extract the records, and then +use `tf.data.Dataset.map` and `tf.decode_csv` to parses the CSV records from +each line of text in the dataset. [TOC] ## Writing a `Dataset` for a file format -A @{tf.data.Dataset} represents a sequence of *elements*, which can be the +A `tf.data.Dataset` represents a sequence of *elements*, which can be the individual records in a file. There are several examples of "reader" datasets that are already built into TensorFlow: -* @{tf.data.TFRecordDataset} +* `tf.data.TFRecordDataset` ([source in `kernels/data/reader_dataset_ops.cc`](https://www.tensorflow.org/code/tensorflow/core/kernels/data/reader_dataset_ops.cc)) -* @{tf.data.FixedLengthRecordDataset} +* `tf.data.FixedLengthRecordDataset` ([source in `kernels/data/reader_dataset_ops.cc`](https://www.tensorflow.org/code/tensorflow/core/kernels/data/reader_dataset_ops.cc)) -* @{tf.data.TextLineDataset} +* `tf.data.TextLineDataset` ([source in `kernels/data/reader_dataset_ops.cc`](https://www.tensorflow.org/code/tensorflow/core/kernels/data/reader_dataset_ops.cc)) Each of these implementations comprises three related classes: @@ -64,7 +63,7 @@ need to: that implement the reading logic. 2. In C++, register a new reader op and kernel with the name `"MyReaderDataset"`. -3. In Python, define a subclass of @{tf.data.Dataset} called `MyReaderDataset`. +3. In Python, define a subclass of `tf.data.Dataset` called `MyReaderDataset`. You can put all the C++ code in a single file, such as `my_reader_dataset_op.cc`. It will help if you are @@ -230,7 +229,7 @@ REGISTER_KERNEL_BUILDER(Name("MyReaderDataset").Device(tensorflow::DEVICE_CPU), The last step is to build the C++ code and add a Python wrapper. The easiest way to do this is by @{$adding_an_op#build_the_op_library$compiling a dynamic library} (e.g. called `"my_reader_dataset_op.so"`), and adding a Python class -that subclasses @{tf.data.Dataset} to wrap it. An example Python program is +that subclasses `tf.data.Dataset` to wrap it. An example Python program is given here: ```python @@ -293,14 +292,14 @@ track down where the bad data came from. Examples of Ops useful for decoding records: -* @{tf.parse_single_example} (and @{tf.parse_example}) -* @{tf.decode_csv} -* @{tf.decode_raw} +* `tf.parse_single_example` (and `tf.parse_example`) +* `tf.decode_csv` +* `tf.decode_raw` Note that it can be useful to use multiple Ops to decode a particular record format. For example, you may have an image saved as a string in [a `tf.train.Example` protocol buffer](https://www.tensorflow.org/code/tensorflow/core/example/example.proto). Depending on the format of that image, you might take the corresponding output -from a @{tf.parse_single_example} op and call @{tf.image.decode_jpeg}, -@{tf.image.decode_png}, or @{tf.decode_raw}. It is common to take the output -of `tf.decode_raw` and use @{tf.slice} and @{tf.reshape} to extract pieces. +from a `tf.parse_single_example` op and call `tf.image.decode_jpeg`, +`tf.image.decode_png`, or `tf.decode_raw`. It is common to take the output +of `tf.decode_raw` and use `tf.slice` and `tf.reshape` to extract pieces. diff --git a/tensorflow/docs_src/guide/checkpoints.md b/tensorflow/docs_src/guide/checkpoints.md index dfb2626b86..e1add29852 100644 --- a/tensorflow/docs_src/guide/checkpoints.md +++ b/tensorflow/docs_src/guide/checkpoints.md @@ -129,7 +129,7 @@ in the `model_dir` according to the following schedule: You may alter the default schedule by taking the following steps: -1. Create a @{tf.estimator.RunConfig$`RunConfig`} object that defines the +1. Create a `tf.estimator.RunConfig` object that defines the desired schedule. 2. When instantiating the Estimator, pass that `RunConfig` object to the Estimator's `config` argument. diff --git a/tensorflow/docs_src/guide/custom_estimators.md b/tensorflow/docs_src/guide/custom_estimators.md index 6e4ef2e0f2..199a0e93de 100644 --- a/tensorflow/docs_src/guide/custom_estimators.md +++ b/tensorflow/docs_src/guide/custom_estimators.md @@ -2,9 +2,9 @@ # Creating Custom Estimators This document introduces custom Estimators. In particular, this document -demonstrates how to create a custom @{tf.estimator.Estimator$Estimator} that +demonstrates how to create a custom `tf.estimator.Estimator` that mimics the behavior of the pre-made Estimator -@{tf.estimator.DNNClassifier$`DNNClassifier`} in solving the Iris problem. See +`tf.estimator.DNNClassifier` in solving the Iris problem. See the @{$premade_estimators$Pre-Made Estimators chapter} for details on the Iris problem. @@ -34,7 +34,7 @@ with ## Pre-made vs. custom As the following figure shows, pre-made Estimators are subclasses of the -@{tf.estimator.Estimator} base class, while custom Estimators are an instance +`tf.estimator.Estimator` base class, while custom Estimators are an instance of tf.estimator.Estimator:
@@ -144,7 +144,7 @@ The caller may pass `params` to an Estimator's constructor. Any `params` passed to the constructor are in turn passed on to the `model_fn`. In [`custom_estimator.py`](https://github.com/tensorflow/models/blob/master/samples/core/get_started/custom_estimator.py) the following lines create the estimator and set the params to configure the -model. This configuration step is similar to how we configured the @{tf.estimator.DNNClassifier} in +model. This configuration step is similar to how we configured the `tf.estimator.DNNClassifier` in @{$premade_estimators}. ```python @@ -178,7 +178,7 @@ The basic deep neural network model must define the following three sections: ### Define the input layer -The first line of the `model_fn` calls @{tf.feature_column.input_layer} to +The first line of the `model_fn` calls `tf.feature_column.input_layer` to convert the feature dictionary and `feature_columns` into input for your model, as follows: @@ -202,7 +202,7 @@ creating the model's input layer. If you are creating a deep neural network, you must define one or more hidden layers. The Layers API provides a rich set of functions to define all types of hidden layers, including convolutional, pooling, and dropout layers. For Iris, -we're simply going to call @{tf.layers.dense} to create hidden layers, with +we're simply going to call `tf.layers.dense` to create hidden layers, with dimensions defined by `params['hidden_layers']`. In a `dense` layer each node is connected to every node in the preceding layer. Here's the relevant code: @@ -231,14 +231,14 @@ simplicity, the figure does not show all the units in each layer. src="../images/custom_estimators/add_hidden_layer.png">
-Note that @{tf.layers.dense} provides many additional capabilities, including +Note that `tf.layers.dense` provides many additional capabilities, including the ability to set a multitude of regularization parameters. For the sake of simplicity, though, we're going to simply accept the default values of the other parameters. ### Output Layer -We'll define the output layer by calling @{tf.layers.dense} yet again, this +We'll define the output layer by calling `tf.layers.dense` yet again, this time without an activation function: ```python @@ -265,7 +265,7 @@ score, or "logit", calculated for the associated class of Iris: Setosa, Versicolor, or Virginica, respectively. Later on, these logits will be transformed into probabilities by the -@{tf.nn.softmax} function. +`tf.nn.softmax` function. ## Implement training, evaluation, and prediction {#modes} @@ -290,9 +290,9 @@ function with the mode parameter set as follows: | Estimator method | Estimator Mode | |:---------------------------------|:------------------| -|@{tf.estimator.Estimator.train$`train()`} |@{tf.estimator.ModeKeys.TRAIN$`ModeKeys.TRAIN`} | -|@{tf.estimator.Estimator.evaluate$`evaluate()`} |@{tf.estimator.ModeKeys.EVAL$`ModeKeys.EVAL`} | -|@{tf.estimator.Estimator.predict$`predict()`}|@{tf.estimator.ModeKeys.PREDICT$`ModeKeys.PREDICT`} | +|`tf.estimator.Estimator.train` |`tf.estimator.ModeKeys.TRAIN` | +|`tf.estimator.Estimator.evaluate` |`tf.estimator.ModeKeys.EVAL` | +|`tf.estimator.Estimator.predict`|`tf.estimator.ModeKeys.PREDICT` | For example, suppose you instantiate a custom Estimator to generate an object named `classifier`. Then, you make the following call: @@ -350,8 +350,8 @@ The `predictions` holds the following three key/value pairs: * `logit` holds the raw logit values (in this example, -1.3, 2.6, and -0.9) We return that dictionary to the caller via the `predictions` parameter of the -@{tf.estimator.EstimatorSpec}. The Estimator's -@{tf.estimator.Estimator.predict$`predict`} method will yield these +`tf.estimator.EstimatorSpec`. The Estimator's +`tf.estimator.Estimator.predict` method will yield these dictionaries. ### Calculate the loss @@ -361,7 +361,7 @@ model's loss. This is the [objective](https://developers.google.com/machine-learning/glossary/#objective) that will be optimized. -We can calculate the loss by calling @{tf.losses.sparse_softmax_cross_entropy}. +We can calculate the loss by calling `tf.losses.sparse_softmax_cross_entropy`. The value returned by this function will be approximately 0 at lowest, when the probability of the correct class (at index `label`) is near 1.0. The loss value returned is progressively larger as the probability of the @@ -382,12 +382,12 @@ When the Estimator's `evaluate` method is called, the `model_fn` receives or more metrics. Although returning metrics is optional, most custom Estimators do return at -least one metric. TensorFlow provides a Metrics module @{tf.metrics} to +least one metric. TensorFlow provides a Metrics module `tf.metrics` to calculate common metrics. For brevity's sake, we'll only return accuracy. The -@{tf.metrics.accuracy} function compares our predictions against the +`tf.metrics.accuracy` function compares our predictions against the true values, that is, against the labels provided by the input function. The -@{tf.metrics.accuracy} function requires the labels and predictions to have the -same shape. Here's the call to @{tf.metrics.accuracy}: +`tf.metrics.accuracy` function requires the labels and predictions to have the +same shape. Here's the call to `tf.metrics.accuracy`: ``` python # Compute evaluation metrics. @@ -396,7 +396,7 @@ accuracy = tf.metrics.accuracy(labels=labels, name='acc_op') ``` -The @{tf.estimator.EstimatorSpec$`EstimatorSpec`} returned for evaluation +The `tf.estimator.EstimatorSpec` returned for evaluation typically contains the following information: * `loss`, which is the model's loss @@ -416,7 +416,7 @@ if mode == tf.estimator.ModeKeys.EVAL: mode, loss=loss, eval_metric_ops=metrics) ``` -The @{tf.summary.scalar} will make accuracy available to TensorBoard +The `tf.summary.scalar` will make accuracy available to TensorBoard in both `TRAIN` and `EVAL` modes. (More on this later). ### Train @@ -426,7 +426,7 @@ with `mode = ModeKeys.TRAIN`. In this case, the model function must return an `EstimatorSpec` that contains the loss and a training operation. Building the training operation will require an optimizer. We will use -@{tf.train.AdagradOptimizer} because we're mimicking the `DNNClassifier`, which +`tf.train.AdagradOptimizer` because we're mimicking the `DNNClassifier`, which also uses `Adagrad` by default. The `tf.train` package provides many other optimizers—feel free to experiment with them. @@ -437,14 +437,14 @@ optimizer = tf.train.AdagradOptimizer(learning_rate=0.1) ``` Next, we build the training operation using the optimizer's -@{tf.train.Optimizer.minimize$`minimize`} method on the loss we calculated +`tf.train.Optimizer.minimize` method on the loss we calculated earlier. The `minimize` method also takes a `global_step` parameter. TensorFlow uses this parameter to count the number of training steps that have been processed (to know when to end a training run). Furthermore, the `global_step` is essential for TensorBoard graphs to work correctly. Simply call -@{tf.train.get_global_step} and pass the result to the `global_step` +`tf.train.get_global_step` and pass the result to the `global_step` argument of `minimize`. Here's the code to train the model: @@ -453,7 +453,7 @@ Here's the code to train the model: train_op = optimizer.minimize(loss, global_step=tf.train.get_global_step()) ``` -The @{tf.estimator.EstimatorSpec$`EstimatorSpec`} returned for training +The `tf.estimator.EstimatorSpec` returned for training must have the following fields set: * `loss`, which contains the value of the loss function. diff --git a/tensorflow/docs_src/guide/datasets.md b/tensorflow/docs_src/guide/datasets.md index 8b69860a68..bb18e8b79c 100644 --- a/tensorflow/docs_src/guide/datasets.md +++ b/tensorflow/docs_src/guide/datasets.md @@ -1,6 +1,6 @@ # Importing Data -The @{tf.data} API enables you to build complex input pipelines from +The `tf.data` API enables you to build complex input pipelines from simple, reusable pieces. For example, the pipeline for an image model might aggregate data from files in a distributed file system, apply random perturbations to each image, and merge randomly selected images into a batch @@ -51,7 +51,7 @@ Once you have a `Dataset` object, you can *transform* it into a new `Dataset` by chaining method calls on the `tf.data.Dataset` object. For example, you can apply per-element transformations such as `Dataset.map()` (to apply a function to each element), and multi-element transformations such as -`Dataset.batch()`. See the documentation for @{tf.data.Dataset} +`Dataset.batch()`. See the documentation for `tf.data.Dataset` for a complete list of transformations. The most common way to consume values from a `Dataset` is to make an @@ -211,13 +211,13 @@ for _ in range(20): sess.run(next_element) ``` -A **feedable** iterator can be used together with @{tf.placeholder} to select -what `Iterator` to use in each call to @{tf.Session.run}, via the familiar +A **feedable** iterator can be used together with `tf.placeholder` to select +what `Iterator` to use in each call to `tf.Session.run`, via the familiar `feed_dict` mechanism. It offers the same functionality as a reinitializable iterator, but it does not require you to initialize the iterator from the start of a dataset when you switch between iterators. For example, using the same training and validation example from above, you can use -@{tf.data.Iterator.from_string_handle} to define a feedable iterator +`tf.data.Iterator.from_string_handle` to define a feedable iterator that allows you to switch between the two datasets: ```python @@ -329,12 +329,12 @@ of an iterator will include all components in a single expression. ### Saving iterator state -The @{tf.contrib.data.make_saveable_from_iterator} function creates a +The `tf.contrib.data.make_saveable_from_iterator` function creates a `SaveableObject` from an iterator, which can be used to save and restore the current state of the iterator (and, effectively, the whole input -pipeline). A saveable object thus created can be added to @{tf.train.Saver} +pipeline). A saveable object thus created can be added to `tf.train.Saver` variables list or the `tf.GraphKeys.SAVEABLE_OBJECTS` collection for saving and -restoring in the same manner as a @{tf.Variable}. Refer to +restoring in the same manner as a `tf.Variable`. Refer to @{$saved_model$Saving and Restoring} for details on how to save and restore variables. @@ -488,7 +488,7 @@ dataset = dataset.flat_map( ### Consuming CSV data The CSV file format is a popular format for storing tabular data in plain text. -The @{tf.contrib.data.CsvDataset} class provides a way to extract records from +The `tf.contrib.data.CsvDataset` class provides a way to extract records from one or more CSV files that comply with [RFC 4180](https://tools.ietf.org/html/rfc4180). Given one or more filenames and a list of defaults, a `CsvDataset` will produce a tuple of elements whose types correspond to the types of the defaults @@ -757,9 +757,9 @@ dataset = dataset.repeat() ### Using high-level APIs -The @{tf.train.MonitoredTrainingSession} API simplifies many aspects of running +The `tf.train.MonitoredTrainingSession` API simplifies many aspects of running TensorFlow in a distributed setting. `MonitoredTrainingSession` uses the -@{tf.errors.OutOfRangeError} to signal that training has completed, so to use it +`tf.errors.OutOfRangeError` to signal that training has completed, so to use it with the `tf.data` API, we recommend using `Dataset.make_one_shot_iterator()`. For example: @@ -782,7 +782,7 @@ with tf.train.MonitoredTrainingSession(...) as sess: sess.run(training_op) ``` -To use a `Dataset` in the `input_fn` of a @{tf.estimator.Estimator}, we also +To use a `Dataset` in the `input_fn` of a `tf.estimator.Estimator`, we also recommend using `Dataset.make_one_shot_iterator()`. For example: ```python diff --git a/tensorflow/docs_src/guide/datasets_for_estimators.md b/tensorflow/docs_src/guide/datasets_for_estimators.md index b55a5731a4..969ea579f7 100644 --- a/tensorflow/docs_src/guide/datasets_for_estimators.md +++ b/tensorflow/docs_src/guide/datasets_for_estimators.md @@ -1,6 +1,6 @@ # Datasets for Estimators -The @{tf.data} module contains a collection of classes that allows you to +The `tf.data` module contains a collection of classes that allows you to easily load data, manipulate it, and pipe it into your model. This document introduces the API by walking through two simple examples: @@ -73,8 +73,8 @@ Let's walk through the `train_input_fn()`. ### Slices -The function starts by using the @{tf.data.Dataset.from_tensor_slices} function -to create a @{tf.data.Dataset} representing slices of the array. The array is +The function starts by using the `tf.data.Dataset.from_tensor_slices` function +to create a `tf.data.Dataset` representing slices of the array. The array is sliced across the first dimension. For example, an array containing the MNIST training data has a shape of `(60000, 28, 28)`. Passing this to `from_tensor_slices` returns a `Dataset` object containing 60000 slices, each one @@ -170,15 +170,15 @@ function takes advantage of several of these methods: dataset = dataset.shuffle(1000).repeat().batch(batch_size) ``` -The @{tf.data.Dataset.shuffle$`shuffle`} method uses a fixed-size buffer to +The `tf.data.Dataset.shuffle` method uses a fixed-size buffer to shuffle the items as they pass through. In this case the `buffer_size` is greater than the number of examples in the `Dataset`, ensuring that the data is completely shuffled (The Iris data set only contains 150 examples). -The @{tf.data.Dataset.repeat$`repeat`} method restarts the `Dataset` when +The `tf.data.Dataset.repeat` method restarts the `Dataset` when it reaches the end. To limit the number of epochs, set the `count` argument. -The @{tf.data.Dataset.batch$`batch`} method collects a number of examples and +The `tf.data.Dataset.batch` method collects a number of examples and stacks them, to create batches. This adds a dimension to their shape. The new dimension is added as the first dimension. The following code uses the `batch` method on the MNIST `Dataset`, from earlier. This results in a @@ -234,7 +234,7 @@ The `labels` can/should be omitted when using the `predict` method. ## Reading a CSV File The most common real-world use case for the `Dataset` class is to stream data -from files on disk. The @{tf.data} module includes a variety of +from files on disk. The `tf.data` module includes a variety of file readers. Let's see how parsing the Iris dataset from the csv file looks using a `Dataset`. @@ -255,9 +255,9 @@ from the local files. ### Build the `Dataset` -We start by building a @{tf.data.TextLineDataset$`TextLineDataset`} object to +We start by building a `tf.data.TextLineDataset` object to read the file one line at a time. Then, we call the -@{tf.data.Dataset.skip$`skip`} method to skip over the first line of the file, which contains a header, not an example: +`tf.data.Dataset.skip` method to skip over the first line of the file, which contains a header, not an example: ``` python ds = tf.data.TextLineDataset(train_path).skip(1) @@ -268,11 +268,11 @@ ds = tf.data.TextLineDataset(train_path).skip(1) We will start by building a function to parse a single line. The following `iris_data.parse_line` function accomplishes this task using the -@{tf.decode_csv} function, and some simple python code: +`tf.decode_csv` function, and some simple python code: We must parse each of the lines in the dataset in order to generate the necessary `(features, label)` pairs. The following `_parse_line` function -calls @{tf.decode_csv} to parse a single line into its features +calls `tf.decode_csv` to parse a single line into its features and the label. Since Estimators require that features be represented as a dictionary, we rely on Python's built-in `dict` and `zip` functions to build that dictionary. The feature names are the keys of that dictionary. @@ -301,7 +301,7 @@ def _parse_line(line): ### Parse the lines Datasets have many methods for manipulating the data while it is being piped -to a model. The most heavily-used method is @{tf.data.Dataset.map$`map`}, which +to a model. The most heavily-used method is `tf.data.Dataset.map`, which applies a transformation to each element of the `Dataset`. The `map` method takes a `map_func` argument that describes how each item in the @@ -311,7 +311,7 @@ The `map` method takes a `map_func` argument that describes how each item in the
-The @{tf.data.Dataset.map$`map`} method applies the `map_func` to +The `tf.data.Dataset.map` method applies the `map_func` to transform each item in the Dataset.
diff --git a/tensorflow/docs_src/guide/debugger.md b/tensorflow/docs_src/guide/debugger.md index f0e465214e..0b4a063c10 100644 --- a/tensorflow/docs_src/guide/debugger.md +++ b/tensorflow/docs_src/guide/debugger.md @@ -89,7 +89,7 @@ control the execution and inspect the graph's internal state. the diagnosis of issues. In this example, we have already registered a tensor filter called -@{tfdbg.has_inf_or_nan}, +`tfdbg.has_inf_or_nan`, which simply determines if there are any `nan` or `inf` values in any intermediate tensors (tensors that are neither inputs or outputs of the `Session.run()` call, but are in the path leading from the inputs to the @@ -98,13 +98,11 @@ we ship it with the @{$python/tfdbg#Classes_for_debug_dump_data_and_directories$`debug_data`} module. -Note: You can also write your own custom filters. See -the @{tfdbg.DebugDumpDir.find$API documentation} -of `DebugDumpDir.find()` for additional information. +Note: You can also write your own custom filters. See `tfdbg.DebugDumpDir.find` +for additional information. ## Debugging Model Training with tfdbg - Let's try training the model again, but with the `--debug` flag added this time: ```none @@ -429,9 +427,9 @@ described in the preceding sections inapplicable. Fortunately, you can still debug them by using special `hook`s provided by `tfdbg`. `tfdbg` can debug the -@{tf.estimator.Estimator.train$`train()`}, -@{tf.estimator.Estimator.evaluate$`evaluate()`} and -@{tf.estimator.Estimator.predict$`predict()`} +`tf.estimator.Estimator.train`, +`tf.estimator.Estimator.evaluate` and +`tf.estimator.Estimator.predict` methods of tf-learn `Estimator`s. To debug `Estimator.train()`, create a `LocalCLIDebugHook` and supply it in the `hooks` argument. For example: @@ -473,7 +471,7 @@ python -m tensorflow.python.debug.examples.debug_tflearn_iris --debug The `LocalCLIDebugHook` also allows you to configure a `watch_fn` that can be used to flexibly specify what `Tensor`s to watch on different `Session.run()` calls, as a function of the `fetches` and `feed_dict` and other states. See -@{tfdbg.DumpingDebugWrapperSession.__init__$this API doc} +`tfdbg.DumpingDebugWrapperSession.__init__` for more details. ## Debugging Keras Models with TFDBG @@ -556,7 +554,7 @@ and the higher-level `Estimator` API. If you interact directly with the `tf.Session` API in `python`, you can configure the `RunOptions` proto that you call your `Session.run()` method -with, by using the method @{tfdbg.watch_graph}. +with, by using the method `tfdbg.watch_graph`. This will cause the intermediate tensors and runtime graphs to be dumped to a shared storage location of your choice when the `Session.run()` call occurs (at the cost of slower performance). For example: @@ -715,7 +713,7 @@ You might encounter this problem in any of the following situations: * models with many intermediate tensors * very large intermediate tensors -* many @{tf.while_loop} iterations +* many `tf.while_loop` iterations There are three possible workarounds or solutions: @@ -775,7 +773,7 @@ sess.run(b) optimization folds the graph that contains `a` and `b` into a single node to speed up future runs of the graph, which is why `tfdbg` does not generate any intermediate tensor dumps. However, if `a` were a - @{tf.Variable}, as in the following example: + `tf.Variable`, as in the following example: ``` python import numpy as np diff --git a/tensorflow/docs_src/guide/estimators.md b/tensorflow/docs_src/guide/estimators.md index 78b30c3040..ed9a3da284 100644 --- a/tensorflow/docs_src/guide/estimators.md +++ b/tensorflow/docs_src/guide/estimators.md @@ -1,6 +1,6 @@ # Estimators -This document introduces @{tf.estimator$**Estimators**}--a high-level TensorFlow +This document introduces `tf.estimator`--a high-level TensorFlow API that greatly simplifies machine learning programming. Estimators encapsulate the following actions: @@ -11,10 +11,10 @@ the following actions: You may either use the pre-made Estimators we provide or write your own custom Estimators. All Estimators--whether pre-made or custom--are -classes based on the @{tf.estimator.Estimator} class. +classes based on the `tf.estimator.Estimator` class. Note: TensorFlow also includes a deprecated `Estimator` class at -@{tf.contrib.learn.Estimator}, which you should not use. +`tf.contrib.learn.Estimator`, which you should not use. ## Advantages of Estimators @@ -29,7 +29,7 @@ Estimators provide the following benefits: * You can develop a state of the art model with high-level intuitive code. In short, it is generally much easier to create models with Estimators than with the low-level TensorFlow APIs. -* Estimators are themselves built on @{tf.layers}, which +* Estimators are themselves built on `tf.layers`, which simplifies customization. * Estimators build the graph for you. * Estimators provide a safe distributed training loop that controls how and @@ -52,9 +52,9 @@ Pre-made Estimators enable you to work at a much higher conceptual level than the base TensorFlow APIs. You no longer have to worry about creating the computational graph or sessions since Estimators handle all the "plumbing" for you. That is, pre-made Estimators create and manage -@{tf.Graph$`Graph`} and @{tf.Session$`Session`} objects for you. Furthermore, +`tf.Graph` and `tf.Session` objects for you. Furthermore, pre-made Estimators let you experiment with different model architectures by -making only minimal code changes. @{tf.estimator.DNNClassifier$`DNNClassifier`}, +making only minimal code changes. `tf.estimator.DNNClassifier`, for example, is a pre-made Estimator class that trains classification models based on dense, feed-forward neural networks. @@ -83,7 +83,7 @@ of the following four steps: (See @{$guide/datasets} for full details.) -2. **Define the feature columns.** Each @{tf.feature_column} +2. **Define the feature columns.** Each `tf.feature_column` identifies a feature name, its type, and any input pre-processing. For example, the following snippet creates three feature columns that hold integer or floating-point data. The first two @@ -155,7 +155,7 @@ We recommend the following workflow: You can convert existing Keras models to Estimators. Doing so enables your Keras model to access Estimator's strengths, such as distributed training. Call -@{tf.keras.estimator.model_to_estimator} as in the +`tf.keras.estimator.model_to_estimator` as in the following sample: ```python @@ -190,4 +190,4 @@ and similarly, the predicted output names can be obtained from `keras_inception_v3.output_names`. For more details, please refer to the documentation for -@{tf.keras.estimator.model_to_estimator}. +`tf.keras.estimator.model_to_estimator`. diff --git a/tensorflow/docs_src/guide/faq.md b/tensorflow/docs_src/guide/faq.md index b6291a9ffa..8370097560 100644 --- a/tensorflow/docs_src/guide/faq.md +++ b/tensorflow/docs_src/guide/faq.md @@ -28,13 +28,13 @@ See also the #### Why does `c = tf.matmul(a, b)` not execute the matrix multiplication immediately? In the TensorFlow Python API, `a`, `b`, and `c` are -@{tf.Tensor} objects. A `Tensor` object is +`tf.Tensor` objects. A `Tensor` object is a symbolic handle to the result of an operation, but does not actually hold the values of the operation's output. Instead, TensorFlow encourages users to build up complicated expressions (such as entire neural networks and its gradients) as a dataflow graph. You then offload the computation of the entire dataflow graph (or a subgraph of it) to a TensorFlow -@{tf.Session}, which is able to execute the +`tf.Session`, which is able to execute the whole computation much more efficiently than executing the operations one-by-one. @@ -46,7 +46,7 @@ device, and `"/device:GPU:i"` (or `"/gpu:i"`) for the *i*th GPU device. #### How do I place operations on a particular device? To place a group of operations on a device, create them within a -@{tf.device$`with tf.device(name):`} context. See +`tf.device` context. See the how-to documentation on @{$using_gpu$using GPUs with TensorFlow} for details of how TensorFlow assigns operations to devices, and the @@ -63,17 +63,17 @@ See also the Feeding is a mechanism in the TensorFlow Session API that allows you to substitute different values for one or more tensors at run time. The `feed_dict` -argument to @{tf.Session.run} is a -dictionary that maps @{tf.Tensor} objects to +argument to `tf.Session.run` is a +dictionary that maps `tf.Tensor` objects to numpy arrays (and some other types), which will be used as the values of those tensors in the execution of a step. #### What is the difference between `Session.run()` and `Tensor.eval()`? -If `t` is a @{tf.Tensor} object, -@{tf.Tensor.eval} is shorthand for -@{tf.Session.run}, where `sess` is the -current @{tf.get_default_session}. The +If `t` is a `tf.Tensor` object, +`tf.Tensor.eval` is shorthand for +`tf.Session.run`, where `sess` is the +current `tf.get_default_session`. The two following snippets of code are equivalent: ```python @@ -99,11 +99,11 @@ sessions, it may be more straightforward to make explicit calls to #### Do Sessions have a lifetime? What about intermediate tensors? Sessions can own resources, such as -@{tf.Variable}, -@{tf.QueueBase}, and -@{tf.ReaderBase}. These resources can sometimes use +`tf.Variable`, +`tf.QueueBase`, and +`tf.ReaderBase`. These resources can sometimes use a significant amount of memory, and can be released when the session is closed by calling -@{tf.Session.close}. +`tf.Session.close`. The intermediate tensors that are created as part of a call to @{$python/client$`Session.run()`} will be freed at or before the @@ -120,7 +120,7 @@ dimensions: devices, which makes it possible to speed up @{$deep_cnn$CIFAR-10 training using multiple GPUs}. * The Session API allows multiple concurrent steps (i.e. calls to - @{tf.Session.run} in parallel). This + `tf.Session.run` in parallel). This enables the runtime to get higher throughput, if a single step does not use all of the resources in your computer. @@ -151,8 +151,8 @@ than 3.5. #### Why does `Session.run()` hang when using a reader or a queue? -The @{tf.ReaderBase} and -@{tf.QueueBase} classes provide special operations that +The `tf.ReaderBase` and +`tf.QueueBase` classes provide special operations that can *block* until input (or free space in a bounded queue) becomes available. These operations allow you to build sophisticated @{$reading_data$input pipelines}, at the cost of making the @@ -169,9 +169,9 @@ See also the how-to documentation on @{$variables$variables} and #### What is the lifetime of a variable? A variable is created when you first run the -@{tf.Variable.initializer} +`tf.Variable.initializer` operation for that variable in a session. It is destroyed when that -@{tf.Session.close}. +`tf.Session.close`. #### How do variables behave when they are concurrently accessed? @@ -179,32 +179,31 @@ Variables allow concurrent read and write operations. The value read from a variable may change if it is concurrently updated. By default, concurrent assignment operations to a variable are allowed to run with no mutual exclusion. To acquire a lock when assigning to a variable, pass `use_locking=True` to -@{tf.Variable.assign}. +`tf.Variable.assign`. ## Tensor shapes See also the -@{tf.TensorShape}. +`tf.TensorShape`. #### How can I determine the shape of a tensor in Python? In TensorFlow, a tensor has both a static (inferred) shape and a dynamic (true) shape. The static shape can be read using the -@{tf.Tensor.get_shape} +`tf.Tensor.get_shape` method: this shape is inferred from the operations that were used to create the -tensor, and may be -@{tf.TensorShape$partially complete}. If the static -shape is not fully defined, the dynamic shape of a `Tensor` `t` can be -determined by evaluating @{tf.shape$`tf.shape(t)`}. +tensor, and may be partially complete (the static-shape may contain `None`). If +the static shape is not fully defined, the dynamic shape of a `tf.Tensor`, `t` +can be determined using `tf.shape(t)`. #### What is the difference between `x.set_shape()` and `x = tf.reshape(x)`? -The @{tf.Tensor.set_shape} method updates +The `tf.Tensor.set_shape` method updates the static shape of a `Tensor` object, and it is typically used to provide additional shape information when this cannot be inferred directly. It does not change the dynamic shape of the tensor. -The @{tf.reshape} operation creates +The `tf.reshape` operation creates a new tensor with a different dynamic shape. #### How do I build a graph that works with variable batch sizes? @@ -212,9 +211,9 @@ a new tensor with a different dynamic shape. It is often useful to build a graph that works with variable batch sizes so that the same code can be used for (mini-)batch training, and single-instance inference. The resulting graph can be -@{tf.Graph.as_graph_def$saved as a protocol buffer} +`tf.Graph.as_graph_def` and -@{tf.import_graph_def$imported into another program}. +`tf.import_graph_def`. When building a variable-size graph, the most important thing to remember is not to encode the batch size as a Python constant, but instead to use a symbolic @@ -224,7 +223,7 @@ to encode the batch size as a Python constant, but instead to use a symbolic to extract the batch dimension from a `Tensor` called `input`, and store it in a `Tensor` called `batch_size`. -* Use @{tf.reduce_mean} instead +* Use `tf.reduce_mean` instead of `tf.reduce_sum(...) / batch_size`. @@ -259,19 +258,19 @@ See the how-to documentation for There are three main options for dealing with data in a custom format. The easiest option is to write parsing code in Python that transforms the data -into a numpy array. Then, use @{tf.data.Dataset.from_tensor_slices} to +into a numpy array. Then, use `tf.data.Dataset.from_tensor_slices` to create an input pipeline from the in-memory data. If your data doesn't fit in memory, try doing the parsing in the Dataset pipeline. Start with an appropriate file reader, like -@{tf.data.TextLineDataset}. Then convert the dataset by mapping -@{tf.data.Dataset.map$mapping} appropriate operations over it. -Prefer predefined TensorFlow operations such as @{tf.decode_raw}, -@{tf.decode_csv}, @{tf.parse_example}, or @{tf.image.decode_png}. +`tf.data.TextLineDataset`. Then convert the dataset by mapping +`tf.data.Dataset.map` appropriate operations over it. +Prefer predefined TensorFlow operations such as `tf.decode_raw`, +`tf.decode_csv`, `tf.parse_example`, or `tf.image.decode_png`. If your data is not easily parsable with the built-in TensorFlow operations, consider converting it, offline, to a format that is easily parsable, such -as @{tf.python_io.TFRecordWriter$`TFRecord`} format. +as `tf.python_io.TFRecordWriter` format. The most efficient method to customize the parsing behavior is to @{$adding_an_op$add a new op written in C++} that parses your diff --git a/tensorflow/docs_src/guide/feature_columns.md b/tensorflow/docs_src/guide/feature_columns.md index 41080e050b..9cd695cc25 100644 --- a/tensorflow/docs_src/guide/feature_columns.md +++ b/tensorflow/docs_src/guide/feature_columns.md @@ -6,10 +6,10 @@ enabling you to transform a diverse range of raw data into formats that Estimators can use, allowing easy experimentation. In @{$premade_estimators$Premade Estimators}, we used the premade -Estimator, @{tf.estimator.DNNClassifier$`DNNClassifier`} to train a model to +Estimator, `tf.estimator.DNNClassifier` to train a model to predict different types of Iris flowers from four input features. That example created only numerical feature columns (of type -@{tf.feature_column.numeric_column}). Although numerical feature columns model +`tf.feature_column.numeric_column`). Although numerical feature columns model the lengths of petals and sepals effectively, real world data sets contain all kinds of features, many of which are non-numerical. @@ -59,7 +59,7 @@ Feature columns bridge raw data with the data your model needs. To create feature columns, call functions from the -@{tf.feature_column} module. This document explains nine of the functions in +`tf.feature_column` module. This document explains nine of the functions in that module. As the following figure shows, all nine functions return either a Categorical-Column or a Dense-Column object, except `bucketized_column`, which inherits from both classes: @@ -75,7 +75,7 @@ Let's look at these functions in more detail. ### Numeric column -The Iris classifier calls the @{tf.feature_column.numeric_column} function for +The Iris classifier calls the `tf.feature_column.numeric_column` function for all input features: * `SepalLength` @@ -119,7 +119,7 @@ matrix_feature_column = tf.feature_column.numeric_column(key="MyMatrix", Often, you don't want to feed a number directly into the model, but instead split its value into different categories based on numerical ranges. To do so, -create a @{tf.feature_column.bucketized_column$bucketized column}. For +create a `tf.feature_column.bucketized_column`. For example, consider raw data that represents the year a house was built. Instead of representing that year as a scalar numeric column, we could split the year into the following four buckets: @@ -194,7 +194,7 @@ value. That is: * `1="electronics"` * `2="sport"` -Call @{tf.feature_column.categorical_column_with_identity} to implement a +Call `tf.feature_column.categorical_column_with_identity` to implement a categorical identity column. For example: ``` python @@ -230,8 +230,8 @@ As you can see, categorical vocabulary columns are kind of an enum version of categorical identity columns. TensorFlow provides two different functions to create categorical vocabulary columns: -* @{tf.feature_column.categorical_column_with_vocabulary_list} -* @{tf.feature_column.categorical_column_with_vocabulary_file} +* `tf.feature_column.categorical_column_with_vocabulary_list` +* `tf.feature_column.categorical_column_with_vocabulary_file` `categorical_column_with_vocabulary_list` maps each string to an integer based on an explicit vocabulary list. For example: @@ -281,7 +281,7 @@ categories can be so big that it's not possible to have individual categories for each vocabulary word or integer because that would consume too much memory. For these cases, we can instead turn the question around and ask, "How many categories am I willing to have for my input?" In fact, the -@{tf.feature_column.categorical_column_with_hash_bucket} function enables you +`tf.feature_column.categorical_column_with_hash_bucket` function enables you to specify the number of categories. For this type of feature column the model calculates a hash value of the input, then puts it into one of the `hash_bucket_size` categories using the modulo operator, as in the following @@ -349,7 +349,7 @@ equal size. For the solution, we used a combination of the `bucketized_column` we looked at -earlier, with the @{tf.feature_column.crossed_column} function. +earlier, with the `tf.feature_column.crossed_column` function. @@ -440,7 +440,7 @@ Representing data in indicator columns. Here's how you create an indicator column by calling -@{tf.feature_column.indicator_column}: +`tf.feature_column.indicator_column`: ``` python categorical_column = ... # Create any type of categorical column. @@ -521,7 +521,7 @@ number of dimensions is 3: Note that this is just a general guideline; you can set the number of embedding dimensions as you please. -Call @{tf.feature_column.embedding_column} to create an `embedding_column` as +Call `tf.feature_column.embedding_column` to create an `embedding_column` as suggested by the following snippet: ``` python @@ -543,15 +543,15 @@ columns. As the following list indicates, not all Estimators permit all types of `feature_columns` argument(s): -* @{tf.estimator.LinearClassifier$`LinearClassifier`} and - @{tf.estimator.LinearRegressor$`LinearRegressor`}: Accept all types of +* `tf.estimator.LinearClassifier` and + `tf.estimator.LinearRegressor`: Accept all types of feature column. -* @{tf.estimator.DNNClassifier$`DNNClassifier`} and - @{tf.estimator.DNNRegressor$`DNNRegressor`}: Only accept dense columns. Other +* `tf.estimator.DNNClassifier` and + `tf.estimator.DNNRegressor`: Only accept dense columns. Other column types must be wrapped in either an `indicator_column` or `embedding_column`. -* @{tf.estimator.DNNLinearCombinedClassifier$`DNNLinearCombinedClassifier`} and - @{tf.estimator.DNNLinearCombinedRegressor$`DNNLinearCombinedRegressor`}: +* `tf.estimator.DNNLinearCombinedClassifier` and + `tf.estimator.DNNLinearCombinedRegressor`: * The `linear_feature_columns` argument accepts any feature column type. * The `dnn_feature_columns` argument only accepts dense columns. diff --git a/tensorflow/docs_src/guide/graph_viz.md b/tensorflow/docs_src/guide/graph_viz.md index a8876da5a5..97b0e2d4de 100644 --- a/tensorflow/docs_src/guide/graph_viz.md +++ b/tensorflow/docs_src/guide/graph_viz.md @@ -15,7 +15,7 @@ variable names can be scoped and the visualization uses this information to define a hierarchy on the nodes in the graph. By default, only the top of this hierarchy is shown. Here is an example that defines three operations under the `hidden` name scope using -@{tf.name_scope}: +`tf.name_scope`: ```python import tensorflow as tf diff --git a/tensorflow/docs_src/guide/graphs.md b/tensorflow/docs_src/guide/graphs.md index 492f97c191..2bb44fbb32 100644 --- a/tensorflow/docs_src/guide/graphs.md +++ b/tensorflow/docs_src/guide/graphs.md @@ -7,7 +7,7 @@ TensorFlow **session** to run parts of the graph across a set of local and remote devices. This guide will be most useful if you intend to use the low-level programming -model directly. Higher-level APIs such as @{tf.estimator.Estimator} and Keras +model directly. Higher-level APIs such as `tf.estimator.Estimator` and Keras hide the details of graphs and sessions from the end user, but this guide may also be useful if you want to understand how these APIs are implemented. @@ -18,12 +18,12 @@ also be useful if you want to understand how these APIs are implemented. [Dataflow](https://en.wikipedia.org/wiki/Dataflow_programming) is a common programming model for parallel computing. In a dataflow graph, the nodes represent units of computation, and the edges represent the data consumed or -produced by a computation. For example, in a TensorFlow graph, the @{tf.matmul} +produced by a computation. For example, in a TensorFlow graph, the `tf.matmul` operation would correspond to a single node with two incoming edges (the matrices to be multiplied) and one outgoing edge (the result of the multiplication). - + Dataflow has several advantages that TensorFlow leverages when executing your programs: @@ -48,9 +48,9 @@ programs: low-latency inference. -## What is a @{tf.Graph}? +## What is a `tf.Graph`? -A @{tf.Graph} contains two relevant kinds of information: +A `tf.Graph` contains two relevant kinds of information: * **Graph structure.** The nodes and edges of the graph, indicating how individual operations are composed together, but not prescribing how they @@ -59,78 +59,78 @@ A @{tf.Graph} contains two relevant kinds of information: context that source code conveys. * **Graph collections.** TensorFlow provides a general mechanism for storing - collections of metadata in a @{tf.Graph}. The @{tf.add_to_collection} function - enables you to associate a list of objects with a key (where @{tf.GraphKeys} - defines some of the standard keys), and @{tf.get_collection} enables you to + collections of metadata in a `tf.Graph`. The `tf.add_to_collection` function + enables you to associate a list of objects with a key (where `tf.GraphKeys` + defines some of the standard keys), and `tf.get_collection` enables you to look up all objects associated with a key. Many parts of the TensorFlow - library use this facility: for example, when you create a @{tf.Variable}, it + library use this facility: for example, when you create a `tf.Variable`, it is added by default to collections representing "global variables" and - "trainable variables". When you later come to create a @{tf.train.Saver} or - @{tf.train.Optimizer}, the variables in these collections are used as the + "trainable variables". When you later come to create a `tf.train.Saver` or + `tf.train.Optimizer`, the variables in these collections are used as the default arguments. -## Building a @{tf.Graph} +## Building a `tf.Graph` Most TensorFlow programs start with a dataflow graph construction phase. In this -phase, you invoke TensorFlow API functions that construct new @{tf.Operation} -(node) and @{tf.Tensor} (edge) objects and add them to a @{tf.Graph} +phase, you invoke TensorFlow API functions that construct new `tf.Operation` +(node) and `tf.Tensor` (edge) objects and add them to a `tf.Graph` instance. TensorFlow provides a **default graph** that is an implicit argument to all API functions in the same context. For example: -* Calling `tf.constant(42.0)` creates a single @{tf.Operation} that produces the - value `42.0`, adds it to the default graph, and returns a @{tf.Tensor} that +* Calling `tf.constant(42.0)` creates a single `tf.Operation` that produces the + value `42.0`, adds it to the default graph, and returns a `tf.Tensor` that represents the value of the constant. -* Calling `tf.matmul(x, y)` creates a single @{tf.Operation} that multiplies - the values of @{tf.Tensor} objects `x` and `y`, adds it to the default graph, - and returns a @{tf.Tensor} that represents the result of the multiplication. +* Calling `tf.matmul(x, y)` creates a single `tf.Operation` that multiplies + the values of `tf.Tensor` objects `x` and `y`, adds it to the default graph, + and returns a `tf.Tensor` that represents the result of the multiplication. -* Executing `v = tf.Variable(0)` adds to the graph a @{tf.Operation} that will - store a writeable tensor value that persists between @{tf.Session.run} calls. - The @{tf.Variable} object wraps this operation, and can be used [like a +* Executing `v = tf.Variable(0)` adds to the graph a `tf.Operation` that will + store a writeable tensor value that persists between `tf.Session.run` calls. + The `tf.Variable` object wraps this operation, and can be used [like a tensor](#tensor-like_objects), which will read the current value of the - stored value. The @{tf.Variable} object also has methods such as - @{tf.Variable.assign$`assign`} and @{tf.Variable.assign_add$`assign_add`} that - create @{tf.Operation} objects that, when executed, update the stored value. + stored value. The `tf.Variable` object also has methods such as + `tf.Variable.assign` and `tf.Variable.assign_add` that + create `tf.Operation` objects that, when executed, update the stored value. (See @{$guide/variables} for more information about variables.) -* Calling @{tf.train.Optimizer.minimize} will add operations and tensors to the - default graph that calculates gradients, and return a @{tf.Operation} that, +* Calling `tf.train.Optimizer.minimize` will add operations and tensors to the + default graph that calculates gradients, and return a `tf.Operation` that, when run, will apply those gradients to a set of variables. Most programs rely solely on the default graph. However, see [Dealing with multiple graphs](#programming_with_multiple_graphs) for more -advanced use cases. High-level APIs such as the @{tf.estimator.Estimator} API +advanced use cases. High-level APIs such as the `tf.estimator.Estimator` API manage the default graph on your behalf, and--for example--may create different graphs for training and evaluation. Note: Calling most functions in the TensorFlow API merely adds operations and tensors to the default graph, but **does not** perform the actual -computation. Instead, you compose these functions until you have a @{tf.Tensor} -or @{tf.Operation} that represents the overall computation--such as performing -one step of gradient descent--and then pass that object to a @{tf.Session} to -perform the computation. See the section "Executing a graph in a @{tf.Session}" +computation. Instead, you compose these functions until you have a `tf.Tensor` +or `tf.Operation` that represents the overall computation--such as performing +one step of gradient descent--and then pass that object to a `tf.Session` to +perform the computation. See the section "Executing a graph in a `tf.Session`" for more details. ## Naming operations -A @{tf.Graph} object defines a **namespace** for the @{tf.Operation} objects it +A `tf.Graph` object defines a **namespace** for the `tf.Operation` objects it contains. TensorFlow automatically chooses a unique name for each operation in your graph, but giving operations descriptive names can make your program easier to read and debug. The TensorFlow API provides two ways to override the name of an operation: -* Each API function that creates a new @{tf.Operation} or returns a new - @{tf.Tensor} accepts an optional `name` argument. For example, - `tf.constant(42.0, name="answer")` creates a new @{tf.Operation} named - `"answer"` and returns a @{tf.Tensor} named `"answer:0"`. If the default graph +* Each API function that creates a new `tf.Operation` or returns a new + `tf.Tensor` accepts an optional `name` argument. For example, + `tf.constant(42.0, name="answer")` creates a new `tf.Operation` named + `"answer"` and returns a `tf.Tensor` named `"answer:0"`. If the default graph already contains an operation named `"answer"`, then TensorFlow would append `"_1"`, `"_2"`, and so on to the name, in order to make it unique. -* The @{tf.name_scope} function makes it possible to add a **name scope** prefix +* The `tf.name_scope` function makes it possible to add a **name scope** prefix to all operations created in a particular context. The current name scope - prefix is a `"/"`-delimited list of the names of all active @{tf.name_scope} + prefix is a `"/"`-delimited list of the names of all active `tf.name_scope` context managers. If a name scope has already been used in the current context, TensorFlow appends `"_1"`, `"_2"`, and so on. For example: @@ -160,7 +160,7 @@ The graph visualizer uses name scopes to group operations and reduce the visual complexity of a graph. See [Visualizing your graph](#visualizing-your-graph) for more information. -Note that @{tf.Tensor} objects are implicitly named after the @{tf.Operation} +Note that `tf.Tensor` objects are implicitly named after the `tf.Operation` that produces the tensor as output. A tensor name has the form `":"` where: @@ -171,7 +171,7 @@ where: ## Placing operations on different devices If you want your TensorFlow program to use multiple different devices, the -@{tf.device} function provides a convenient way to request that all operations +`tf.device` function provides a convenient way to request that all operations created in a particular context are placed on the same device (or type of device). @@ -186,7 +186,7 @@ where: * `` is an alpha-numeric string that does not start with a number. * `` is a registered device type (such as `GPU` or `CPU`). * `` is a non-negative integer representing the index of the task - in the job named ``. See @{tf.train.ClusterSpec} for an explanation + in the job named ``. See `tf.train.ClusterSpec` for an explanation of jobs and tasks. * `` is a non-negative integer representing the index of the device, for example, to distinguish between different GPU devices used in the @@ -194,7 +194,7 @@ where: You do not need to specify every part of a device specification. For example, if you are running in a single-machine configuration with a single GPU, you -might use @{tf.device} to pin some operations to the CPU and GPU: +might use `tf.device` to pin some operations to the CPU and GPU: ```python # Operations created outside either context will run on the "best possible" @@ -229,13 +229,13 @@ with tf.device("/job:worker"): layer_2 = tf.matmul(train_batch, weights_2) + biases_2 ``` -@{tf.device} gives you a lot of flexibility to choose placements for individual +`tf.device` gives you a lot of flexibility to choose placements for individual operations or broad regions of a TensorFlow graph. In many cases, there are simple heuristics that work well. For example, the -@{tf.train.replica_device_setter} API can be used with @{tf.device} to place +`tf.train.replica_device_setter` API can be used with `tf.device` to place operations for **data-parallel distributed training**. For example, the -following code fragment shows how @{tf.train.replica_device_setter} applies -different placement policies to @{tf.Variable} objects and other operations: +following code fragment shows how `tf.train.replica_device_setter` applies +different placement policies to `tf.Variable` objects and other operations: ```python with tf.device(tf.train.replica_device_setter(ps_tasks=3)): @@ -253,41 +253,41 @@ with tf.device(tf.train.replica_device_setter(ps_tasks=3)): ## Tensor-like objects -Many TensorFlow operations take one or more @{tf.Tensor} objects as arguments. -For example, @{tf.matmul} takes two @{tf.Tensor} objects, and @{tf.add_n} takes -a list of `n` @{tf.Tensor} objects. For convenience, these functions will accept -a **tensor-like object** in place of a @{tf.Tensor}, and implicitly convert it -to a @{tf.Tensor} using the @{tf.convert_to_tensor} method. Tensor-like objects +Many TensorFlow operations take one or more `tf.Tensor` objects as arguments. +For example, `tf.matmul` takes two `tf.Tensor` objects, and `tf.add_n` takes +a list of `n` `tf.Tensor` objects. For convenience, these functions will accept +a **tensor-like object** in place of a `tf.Tensor`, and implicitly convert it +to a `tf.Tensor` using the `tf.convert_to_tensor` method. Tensor-like objects include elements of the following types: -* @{tf.Tensor} -* @{tf.Variable} +* `tf.Tensor` +* `tf.Variable` * [`numpy.ndarray`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html) * `list` (and lists of tensor-like objects) * Scalar Python types: `bool`, `float`, `int`, `str` You can register additional tensor-like types using -@{tf.register_tensor_conversion_function}. +`tf.register_tensor_conversion_function`. -Note: By default, TensorFlow will create a new @{tf.Tensor} each time you use +Note: By default, TensorFlow will create a new `tf.Tensor` each time you use the same tensor-like object. If the tensor-like object is large (e.g. a `numpy.ndarray` containing a set of training examples) and you use it multiple times, you may run out of memory. To avoid this, manually call -@{tf.convert_to_tensor} on the tensor-like object once and use the returned -@{tf.Tensor} instead. +`tf.convert_to_tensor` on the tensor-like object once and use the returned +`tf.Tensor` instead. -## Executing a graph in a @{tf.Session} +## Executing a graph in a `tf.Session` -TensorFlow uses the @{tf.Session} class to represent a connection between the +TensorFlow uses the `tf.Session` class to represent a connection between the client program---typically a Python program, although a similar interface is -available in other languages---and the C++ runtime. A @{tf.Session} object +available in other languages---and the C++ runtime. A `tf.Session` object provides access to devices in the local machine, and remote devices using the distributed TensorFlow runtime. It also caches information about your -@{tf.Graph} so that you can efficiently run the same computation multiple times. +`tf.Graph` so that you can efficiently run the same computation multiple times. -### Creating a @{tf.Session} +### Creating a `tf.Session` -If you are using the low-level TensorFlow API, you can create a @{tf.Session} +If you are using the low-level TensorFlow API, you can create a `tf.Session` for the current default graph as follows: ```python @@ -300,50 +300,50 @@ with tf.Session("grpc://example.org:2222"): # ... ``` -Since a @{tf.Session} owns physical resources (such as GPUs and +Since a `tf.Session` owns physical resources (such as GPUs and network connections), it is typically used as a context manager (in a `with` block) that automatically closes the session when you exit the block. It is also possible to create a session without using a `with` block, but you should -explicitly call @{tf.Session.close} when you are finished with it to free the +explicitly call `tf.Session.close` when you are finished with it to free the resources. -Note: Higher-level APIs such as @{tf.train.MonitoredTrainingSession} or -@{tf.estimator.Estimator} will create and manage a @{tf.Session} for you. These +Note: Higher-level APIs such as `tf.train.MonitoredTrainingSession` or +`tf.estimator.Estimator` will create and manage a `tf.Session` for you. These APIs accept optional `target` and `config` arguments (either directly, or as -part of a @{tf.estimator.RunConfig} object), with the same meaning as +part of a `tf.estimator.RunConfig` object), with the same meaning as described below. -@{tf.Session.__init__} accepts three optional arguments: +`tf.Session.__init__` accepts three optional arguments: * **`target`.** If this argument is left empty (the default), the session will only use devices in the local machine. However, you may also specify a `grpc://` URL to specify the address of a TensorFlow server, which gives the session access to all devices on machines that this server controls. See - @{tf.train.Server} for details of how to create a TensorFlow + `tf.train.Server` for details of how to create a TensorFlow server. For example, in the common **between-graph replication** - configuration, the @{tf.Session} connects to a @{tf.train.Server} in the same + configuration, the `tf.Session` connects to a `tf.train.Server` in the same process as the client. The [distributed TensorFlow](../deploy/distributed.md) deployment guide describes other common scenarios. -* **`graph`.** By default, a new @{tf.Session} will be bound to---and only able +* **`graph`.** By default, a new `tf.Session` will be bound to---and only able to run operations in---the current default graph. If you are using multiple graphs in your program (see [Programming with multiple graphs](#programming_with_multiple_graphs) for more details), you can specify - an explicit @{tf.Graph} when you construct the session. + an explicit `tf.Graph` when you construct the session. -* **`config`.** This argument allows you to specify a @{tf.ConfigProto} that +* **`config`.** This argument allows you to specify a `tf.ConfigProto` that controls the behavior of the session. For example, some of the configuration options include: * `allow_soft_placement`. Set this to `True` to enable a "soft" device - placement algorithm, which ignores @{tf.device} annotations that attempt + placement algorithm, which ignores `tf.device` annotations that attempt to place CPU-only operations on a GPU device, and places them on the CPU instead. * `cluster_def`. When using distributed TensorFlow, this option allows you to specify what machines to use in the computation, and provide a mapping between job names, task indices, and network addresses. See - @{tf.train.ClusterSpec.as_cluster_def} for details. + `tf.train.ClusterSpec.as_cluster_def` for details. * `graph_options.optimizer_options`. Provides control over the optimizations that TensorFlow performs on your graph before executing it. @@ -353,21 +353,21 @@ described below. rather than allocating most of the memory at startup. -### Using @{tf.Session.run} to execute operations +### Using `tf.Session.run` to execute operations -The @{tf.Session.run} method is the main mechanism for running a @{tf.Operation} -or evaluating a @{tf.Tensor}. You can pass one or more @{tf.Operation} or -@{tf.Tensor} objects to @{tf.Session.run}, and TensorFlow will execute the +The `tf.Session.run` method is the main mechanism for running a `tf.Operation` +or evaluating a `tf.Tensor`. You can pass one or more `tf.Operation` or +`tf.Tensor` objects to `tf.Session.run`, and TensorFlow will execute the operations that are needed to compute the result. -@{tf.Session.run} requires you to specify a list of **fetches**, which determine -the return values, and may be a @{tf.Operation}, a @{tf.Tensor}, or -a [tensor-like type](#tensor-like_objects) such as @{tf.Variable}. These fetches -determine what **subgraph** of the overall @{tf.Graph} must be executed to +`tf.Session.run` requires you to specify a list of **fetches**, which determine +the return values, and may be a `tf.Operation`, a `tf.Tensor`, or +a [tensor-like type](#tensor-like_objects) such as `tf.Variable`. These fetches +determine what **subgraph** of the overall `tf.Graph` must be executed to produce the result: this is the subgraph that contains all operations named in the fetch list, plus all operations whose outputs are used to compute the value of the fetches. For example, the following code fragment shows how different -arguments to @{tf.Session.run} cause different subgraphs to be executed: +arguments to `tf.Session.run` cause different subgraphs to be executed: ```python x = tf.constant([[37.0, -23.0], [1.0, 4.0]]) @@ -390,8 +390,8 @@ with tf.Session() as sess: y_val, output_val = sess.run([y, output]) ``` -@{tf.Session.run} also optionally takes a dictionary of **feeds**, which is a -mapping from @{tf.Tensor} objects (typically @{tf.placeholder} tensors) to +`tf.Session.run` also optionally takes a dictionary of **feeds**, which is a +mapping from `tf.Tensor` objects (typically `tf.placeholder` tensors) to values (typically Python scalars, lists, or NumPy arrays) that will be substituted for those tensors in the execution. For example: @@ -415,7 +415,7 @@ with tf.Session() as sess: sess.run(y, {x: 37.0}) ``` -@{tf.Session.run} also accepts an optional `options` argument that enables you +`tf.Session.run` also accepts an optional `options` argument that enables you to specify options about the call, and an optional `run_metadata` argument that enables you to collect metadata about the execution. For example, you can use these options together to collect tracing information about the execution: @@ -447,8 +447,8 @@ with tf.Session() as sess: TensorFlow includes tools that can help you to understand the code in a graph. The **graph visualizer** is a component of TensorBoard that renders the structure of your graph visually in a browser. The easiest way to create a -visualization is to pass a @{tf.Graph} when creating the -@{tf.summary.FileWriter}: +visualization is to pass a `tf.Graph` when creating the +`tf.summary.FileWriter`: ```python # Build your graph. @@ -471,7 +471,7 @@ with tf.Session() as sess: writer.close() ``` -Note: If you are using a @{tf.estimator.Estimator}, the graph (and any +Note: If you are using a `tf.estimator.Estimator`, the graph (and any summaries) will be logged automatically to the `model_dir` that you specified when creating the estimator. @@ -495,8 +495,8 @@ graph for training your model, and a separate graph for evaluating or performing inference with a trained model. In many cases, the inference graph will be different from the training graph: for example, techniques like dropout and batch normalization use different operations in each case. Furthermore, by -default utilities like @{tf.train.Saver} use the names of @{tf.Variable} objects -(which have names based on an underlying @{tf.Operation}) to identify each +default utilities like `tf.train.Saver` use the names of `tf.Variable` objects +(which have names based on an underlying `tf.Operation`) to identify each variable in a saved checkpoint. When programming this way, you can either use completely separate Python processes to build and execute the graphs, or you can use multiple graphs in the same process. This section describes how to use @@ -507,21 +507,21 @@ to all API functions in the same context. For many applications, a single graph is sufficient. However, TensorFlow also provides methods for manipulating the default graph, which can be useful in more advanced use cases. For example: -* A @{tf.Graph} defines the namespace for @{tf.Operation} objects: each +* A `tf.Graph` defines the namespace for `tf.Operation` objects: each operation in a single graph must have a unique name. TensorFlow will "uniquify" the names of operations by appending `"_1"`, `"_2"`, and so on to their names if the requested name is already taken. Using multiple explicitly created graphs gives you more control over what name is given to each operation. -* The default graph stores information about every @{tf.Operation} and - @{tf.Tensor} that was ever added to it. If your program creates a large number +* The default graph stores information about every `tf.Operation` and + `tf.Tensor` that was ever added to it. If your program creates a large number of unconnected subgraphs, it may be more efficient to use a different - @{tf.Graph} to build each subgraph, so that unrelated state can be garbage + `tf.Graph` to build each subgraph, so that unrelated state can be garbage collected. -You can install a different @{tf.Graph} as the default graph, using the -@{tf.Graph.as_default} context manager: +You can install a different `tf.Graph` as the default graph, using the +`tf.Graph.as_default` context manager: ```python g_1 = tf.Graph() @@ -548,8 +548,8 @@ assert d.graph is g_2 assert sess_2.graph is g_2 ``` -To inspect the current default graph, call @{tf.get_default_graph}, which -returns a @{tf.Graph} object: +To inspect the current default graph, call `tf.get_default_graph`, which +returns a `tf.Graph` object: ```python # Print all of the operations in the default graph. diff --git a/tensorflow/docs_src/guide/low_level_intro.md b/tensorflow/docs_src/guide/low_level_intro.md index 665a5568b4..dc6cb9ee0d 100644 --- a/tensorflow/docs_src/guide/low_level_intro.md +++ b/tensorflow/docs_src/guide/low_level_intro.md @@ -63,17 +63,17 @@ TensorFlow uses numpy arrays to represent tensor **values**. You might think of TensorFlow Core programs as consisting of two discrete sections: -1. Building the computational graph (a @{tf.Graph}). -2. Running the computational graph (using a @{tf.Session}). +1. Building the computational graph (a `tf.Graph`). +2. Running the computational graph (using a `tf.Session`). ### Graph A **computational graph** is a series of TensorFlow operations arranged into a graph. The graph is composed of two types of objects. - * @{tf.Operation$Operations} (or "ops"): The nodes of the graph. + * `tf.Operation` (or "ops"): The nodes of the graph. Operations describe calculations that consume and produce tensors. - * @{tf.Tensor$Tensors}: The edges in the graph. These represent the values + * `tf.Tensor`: The edges in the graph. These represent the values that will flow through the graph. Most TensorFlow functions return `tf.Tensors`. @@ -149,7 +149,7 @@ For more about TensorBoard's graph visualization tools see @{$graph_viz}. ### Session -To evaluate tensors, instantiate a @{tf.Session} object, informally known as a +To evaluate tensors, instantiate a `tf.Session` object, informally known as a **session**. A session encapsulates the state of the TensorFlow runtime, and runs TensorFlow operations. If a `tf.Graph` is like a `.py` file, a `tf.Session` is like the `python` executable. @@ -232,7 +232,7 @@ z = x + y The preceding three lines are a bit like a function in which we define two input parameters (`x` and `y`) and then an operation on them. We can evaluate this graph with multiple inputs by using the `feed_dict` argument of -the @{tf.Session.run$run method} to feed concrete values to the placeholders: +the `tf.Session.run` method to feed concrete values to the placeholders: ```python print(sess.run(z, feed_dict={x: 3, y: 4.5})) @@ -251,15 +251,15 @@ that placeholders throw an error if no value is fed to them. ## Datasets -Placeholders work for simple experiments, but @{tf.data$Datasets} are the +Placeholders work for simple experiments, but `tf.data` are the preferred method of streaming data into a model. To get a runnable `tf.Tensor` from a Dataset you must first convert it to a -@{tf.data.Iterator}, and then call the Iterator's -@{tf.data.Iterator.get_next$`get_next`} method. +`tf.data.Iterator`, and then call the Iterator's +`tf.data.Iterator.get_next` method. The simplest way to create an Iterator is with the -@{tf.data.Dataset.make_one_shot_iterator$`make_one_shot_iterator`} method. +`tf.data.Dataset.make_one_shot_iterator` method. For example, in the following code the `next_item` tensor will return a row from the `my_data` array on each `run` call: @@ -275,7 +275,7 @@ next_item = slices.make_one_shot_iterator().get_next() ``` Reaching the end of the data stream causes `Dataset` to throw an -@{tf.errors.OutOfRangeError$`OutOfRangeError`}. For example, the following code +`tf.errors.OutOfRangeError`. For example, the following code reads the `next_item` until there is no more data to read: ``` python @@ -308,7 +308,7 @@ For more details on Datasets and Iterators see: @{$guide/datasets}. ## Layers A trainable model must modify the values in the graph to get new outputs with -the same input. @{tf.layers$Layers} are the preferred way to add trainable +the same input. `tf.layers` are the preferred way to add trainable parameters to a graph. Layers package together both the variables and the operations that act @@ -321,7 +321,7 @@ The connection weights and biases are managed by the layer object. ### Creating Layers -The following code creates a @{tf.layers.Dense$`Dense`} layer that takes a +The following code creates a `tf.layers.Dense` layer that takes a batch of input vectors, and produces a single output value for each. To apply a layer to an input, call the layer as if it were a function. For example: @@ -375,8 +375,8 @@ will generate a two-element output vector such as the following: ### Layer Function shortcuts -For each layer class (like @{tf.layers.Dense}) TensorFlow also supplies a -shortcut function (like @{tf.layers.dense}). The only difference is that the +For each layer class (like `tf.layers.Dense`) TensorFlow also supplies a +shortcut function (like `tf.layers.dense`). The only difference is that the shortcut function versions create and run the layer in a single call. For example, the following code is equivalent to the earlier version: @@ -390,17 +390,17 @@ sess.run(init) print(sess.run(y, {x: [[1, 2, 3], [4, 5, 6]]})) ``` -While convenient, this approach allows no access to the @{tf.layers.Layer} +While convenient, this approach allows no access to the `tf.layers.Layer` object. This makes introspection and debugging more difficult, and layer reuse impossible. ## Feature columns The easiest way to experiment with feature columns is using the -@{tf.feature_column.input_layer} function. This function only accepts +`tf.feature_column.input_layer` function. This function only accepts @{$feature_columns$dense columns} as inputs, so to view the result of a categorical column you must wrap it in an -@{tf.feature_column.indicator_column}. For example: +`tf.feature_column.indicator_column`. For example: ``` python features = { @@ -422,9 +422,9 @@ inputs = tf.feature_column.input_layer(features, columns) Running the `inputs` tensor will parse the `features` into a batch of vectors. Feature columns can have internal state, like layers, so they often need to be -initialized. Categorical columns use @{tf.contrib.lookup$lookup tables} +initialized. Categorical columns use `tf.contrib.lookup` internally and these require a separate initialization op, -@{tf.tables_initializer}. +`tf.tables_initializer`. ``` python var_init = tf.global_variables_initializer() @@ -501,7 +501,7 @@ To optimize a model, you first need to define the loss. We'll use the mean square error, a standard loss for regression problems. While you could do this manually with lower level math operations, -the @{tf.losses} module provides a set of common loss functions. You can use it +the `tf.losses` module provides a set of common loss functions. You can use it to calculate the mean square error as follows: ``` python @@ -520,10 +520,10 @@ This will produce a loss value, something like: TensorFlow provides [**optimizers**](https://developers.google.com/machine-learning/glossary/#optimizer) implementing standard optimization algorithms. These are implemented as -sub-classes of @{tf.train.Optimizer}. They incrementally change each +sub-classes of `tf.train.Optimizer`. They incrementally change each variable in order to minimize the loss. The simplest optimization algorithm is [**gradient descent**](https://developers.google.com/machine-learning/glossary/#gradient_descent), -implemented by @{tf.train.GradientDescentOptimizer}. It modifies each +implemented by `tf.train.GradientDescentOptimizer`. It modifies each variable according to the magnitude of the derivative of loss with respect to that variable. For example: diff --git a/tensorflow/docs_src/guide/premade_estimators.md b/tensorflow/docs_src/guide/premade_estimators.md index 3e910c1fe2..dc38f0c1d3 100644 --- a/tensorflow/docs_src/guide/premade_estimators.md +++ b/tensorflow/docs_src/guide/premade_estimators.md @@ -175,9 +175,9 @@ handles the details of initialization, logging, saving and restoring, and many other features so you can concentrate on your model. For more details see @{$guide/estimators}. -An Estimator is any class derived from @{tf.estimator.Estimator}. TensorFlow +An Estimator is any class derived from `tf.estimator.Estimator`. TensorFlow provides a collection of -@{tf.estimator$pre-made Estimators} +`tf.estimator` (for example, `LinearRegressor`) to implement common ML algorithms. Beyond those, you may write your own @{$custom_estimators$custom Estimators}. @@ -200,7 +200,7 @@ Let's see how those tasks are implemented for Iris classification. You must create input functions to supply data for training, evaluating, and prediction. -An **input function** is a function that returns a @{tf.data.Dataset} object +An **input function** is a function that returns a `tf.data.Dataset` object which outputs the following two-element tuple: * [`features`](https://developers.google.com/machine-learning/glossary/#feature) - A Python dictionary in which: @@ -271,7 +271,7 @@ A [**feature column**](https://developers.google.com/machine-learning/glossary/# is an object describing how the model should use raw input data from the features dictionary. When you build an Estimator model, you pass it a list of feature columns that describes each of the features you want the model to use. -The @{tf.feature_column} module provides many options for representing data +The `tf.feature_column` module provides many options for representing data to the model. For Iris, the 4 raw features are numeric values, so we'll build a list of @@ -299,10 +299,10 @@ features, we can build the estimator. The Iris problem is a classic classification problem. Fortunately, TensorFlow provides several pre-made classifier Estimators, including: -* @{tf.estimator.DNNClassifier} for deep models that perform multi-class +* `tf.estimator.DNNClassifier` for deep models that perform multi-class classification. -* @{tf.estimator.DNNLinearCombinedClassifier} for wide & deep models. -* @{tf.estimator.LinearClassifier} for classifiers based on linear models. +* `tf.estimator.DNNLinearCombinedClassifier` for wide & deep models. +* `tf.estimator.LinearClassifier` for classifiers based on linear models. For the Iris problem, `tf.estimator.DNNClassifier` seems like the best choice. Here's how we instantiated this Estimator: diff --git a/tensorflow/docs_src/guide/saved_model.md b/tensorflow/docs_src/guide/saved_model.md index 717488e7cc..c260da7966 100644 --- a/tensorflow/docs_src/guide/saved_model.md +++ b/tensorflow/docs_src/guide/saved_model.md @@ -1,8 +1,8 @@ # Save and Restore -The @{tf.train.Saver} class provides methods to save and restore models. The -@{tf.saved_model.simple_save} function is an easy way to build a -@{tf.saved_model$saved model} suitable for serving. [Estimators](./estimators) +The `tf.train.Saver` class provides methods to save and restore models. The +`tf.saved_model.simple_save` function is an easy way to build a +`tf.saved_model` suitable for serving. [Estimators](./estimators) automatically save and restore variables in the `model_dir`. ## Save and restore variables @@ -145,13 +145,13 @@ Notes: * If you only restore a subset of the model variables at the start of a session, you have to run an initialize op for the other variables. See - @{tf.variables_initializer} for more information. + `tf.variables_initializer` for more information. * To inspect the variables in a checkpoint, you can use the [`inspect_checkpoint`](https://www.tensorflow.org/code/tensorflow/python/tools/inspect_checkpoint.py) library, particularly the `print_tensors_in_checkpoint_file` function. -* By default, `Saver` uses the value of the @{tf.Variable.name} property +* By default, `Saver` uses the value of the `tf.Variable.name` property for each variable. However, when you create a `Saver` object, you may optionally choose names for the variables in the checkpoint files. @@ -196,15 +196,15 @@ Use `SavedModel` to save and load your model—variables, the graph, and the graph's metadata. This is a language-neutral, recoverable, hermetic serialization format that enables higher-level systems and tools to produce, consume, and transform TensorFlow models. TensorFlow provides several ways to -interact with `SavedModel`, including the @{tf.saved_model} APIs, -@{tf.estimator.Estimator}, and a command-line interface. +interact with `SavedModel`, including the `tf.saved_model` APIs, +`tf.estimator.Estimator`, and a command-line interface. ## Build and load a SavedModel ### Simple save -The easiest way to create a `SavedModel` is to use the @{tf.saved_model.simple_save} +The easiest way to create a `SavedModel` is to use the `tf.saved_model.simple_save` function: ```python @@ -218,14 +218,14 @@ This configures the `SavedModel` so it can be loaded by [TensorFlow serving](/serving/serving_basic) and supports the [Predict API](https://github.com/tensorflow/serving/blob/master/tensorflow_serving/apis/predict.proto). To access the classify, regress, or multi-inference APIs, use the manual -`SavedModel` builder APIs or an @{tf.estimator.Estimator}. +`SavedModel` builder APIs or an `tf.estimator.Estimator`. ### Manually build a SavedModel -If your use case isn't covered by @{tf.saved_model.simple_save}, use the manual -@{tf.saved_model.builder$builder APIs} to create a `SavedModel`. +If your use case isn't covered by `tf.saved_model.simple_save`, use the manual +`tf.saved_model.builder` to create a `SavedModel`. -The @{tf.saved_model.builder.SavedModelBuilder} class provides functionality to +The `tf.saved_model.builder.SavedModelBuilder` class provides functionality to save multiple `MetaGraphDef`s. A **MetaGraph** is a dataflow graph, plus its associated variables, assets, and signatures. A **`MetaGraphDef`** is the protocol buffer representation of a MetaGraph. A **signature** is @@ -272,16 +272,16 @@ builder.save() Following the guidance below gives you forward compatibility only if the set of Ops has not changed. -The @{tf.saved_model.builder.SavedModelBuilder$`SavedModelBuilder`} class allows +The `tf.saved_model.builder.SavedModelBuilder` class allows users to control whether default-valued attributes must be stripped from the @{$extend/tool_developers#nodes$`NodeDefs`} while adding a meta graph to the SavedModel bundle. Both -@{tf.saved_model.builder.SavedModelBuilder.add_meta_graph_and_variables$`SavedModelBuilder.add_meta_graph_and_variables`} -and @{tf.saved_model.builder.SavedModelBuilder.add_meta_graph$`SavedModelBuilder.add_meta_graph`} +`tf.saved_model.builder.SavedModelBuilder.add_meta_graph_and_variables` +and `tf.saved_model.builder.SavedModelBuilder.add_meta_graph` methods accept a Boolean flag `strip_default_attrs` that controls this behavior. -If `strip_default_attrs` is `False`, the exported @{tf.MetaGraphDef} will have -the default valued attributes in all its @{tf.NodeDef} instances. +If `strip_default_attrs` is `False`, the exported `tf.MetaGraphDef` will have +the default valued attributes in all its `tf.NodeDef` instances. This can break forward compatibility with a sequence of events such as the following: @@ -304,7 +304,7 @@ for more information. ### Loading a SavedModel in Python The Python version of the SavedModel -@{tf.saved_model.loader$loader} +`tf.saved_model.loader` provides load and restore capability for a SavedModel. The `load` operation requires the following information: @@ -423,20 +423,20 @@ the model. This function has the following purposes: * To add any additional ops needed to convert data from the input format into the feature `Tensor`s expected by the model. -The function returns a @{tf.estimator.export.ServingInputReceiver} object, +The function returns a `tf.estimator.export.ServingInputReceiver` object, which packages the placeholders and the resulting feature `Tensor`s together. A typical pattern is that inference requests arrive in the form of serialized `tf.Example`s, so the `serving_input_receiver_fn()` creates a single string placeholder to receive them. The `serving_input_receiver_fn()` is then also -responsible for parsing the `tf.Example`s by adding a @{tf.parse_example} op to +responsible for parsing the `tf.Example`s by adding a `tf.parse_example` op to the graph. When writing such a `serving_input_receiver_fn()`, you must pass a parsing -specification to @{tf.parse_example} to tell the parser what feature names to +specification to `tf.parse_example` to tell the parser what feature names to expect and how to map them to `Tensor`s. A parsing specification takes the -form of a dict from feature names to @{tf.FixedLenFeature}, @{tf.VarLenFeature}, -and @{tf.SparseFeature}. Note this parsing specification should not include +form of a dict from feature names to `tf.FixedLenFeature`, `tf.VarLenFeature`, +and `tf.SparseFeature`. Note this parsing specification should not include any label or weight columns, since those will not be available at serving time—in contrast to a parsing specification used in the `input_fn()` at training time. @@ -457,7 +457,7 @@ def serving_input_receiver_fn(): return tf.estimator.export.ServingInputReceiver(features, receiver_tensors) ``` -The @{tf.estimator.export.build_parsing_serving_input_receiver_fn} utility +The `tf.estimator.export.build_parsing_serving_input_receiver_fn` utility function provides that input receiver for the common case. > Note: when training a model to be served using the Predict API with a local @@ -468,7 +468,7 @@ Even if you require no parsing or other input processing—that is, if the serving system will feed feature `Tensor`s directly—you must still provide a `serving_input_receiver_fn()` that creates placeholders for the feature `Tensor`s and passes them through. The -@{tf.estimator.export.build_raw_serving_input_receiver_fn} utility provides for +`tf.estimator.export.build_raw_serving_input_receiver_fn` utility provides for this. If these utilities do not meet your needs, you are free to write your own @@ -488,7 +488,7 @@ By contrast, the *output* portion of the signature is determined by the model. ### Specify the outputs of a custom model When writing a custom `model_fn`, you must populate the `export_outputs` element -of the @{tf.estimator.EstimatorSpec} return value. This is a dict of +of the `tf.estimator.EstimatorSpec` return value. This is a dict of `{name: output}` describing the output signatures to be exported and used during serving. @@ -498,9 +498,9 @@ is represented by an entry in this dict. In this case the `name` is a string of your choice that can be used to request a specific head at serving time. Each `output` value must be an `ExportOutput` object such as -@{tf.estimator.export.ClassificationOutput}, -@{tf.estimator.export.RegressionOutput}, or -@{tf.estimator.export.PredictOutput}. +`tf.estimator.export.ClassificationOutput`, +`tf.estimator.export.RegressionOutput`, or +`tf.estimator.export.PredictOutput`. These output types map straightforwardly to the [TensorFlow Serving APIs](https://github.com/tensorflow/serving/blob/master/tensorflow_serving/apis/prediction_service.proto), @@ -520,7 +520,7 @@ does not specify one. ### Perform the export To export your trained Estimator, call -@{tf.estimator.Estimator.export_savedmodel} with the export base path and +`tf.estimator.Estimator.export_savedmodel` with the export base path and the `serving_input_receiver_fn`. ```py diff --git a/tensorflow/docs_src/guide/summaries_and_tensorboard.md b/tensorflow/docs_src/guide/summaries_and_tensorboard.md index fadfa03e78..6177c3393b 100644 --- a/tensorflow/docs_src/guide/summaries_and_tensorboard.md +++ b/tensorflow/docs_src/guide/summaries_and_tensorboard.md @@ -41,7 +41,7 @@ data from, and decide which nodes you would like to annotate with For example, suppose you are training a convolutional neural network for recognizing MNIST digits. You'd like to record how the learning rate varies over time, and how the objective function is changing. Collect these by -attaching @{tf.summary.scalar} ops +attaching `tf.summary.scalar` ops to the nodes that output the learning rate and loss respectively. Then, give each `scalar_summary` a meaningful `tag`, like `'learning rate'` or `'loss function'`. @@ -49,7 +49,7 @@ function'`. Perhaps you'd also like to visualize the distributions of activations coming off a particular layer, or the distribution of gradients or weights. Collect this data by attaching -@{tf.summary.histogram} ops to +`tf.summary.histogram` ops to the gradient outputs and to the variable that holds your weights, respectively. For details on all of the summary operations available, check out the docs on @@ -60,13 +60,13 @@ depends on their output. And the summary nodes that we've just created are peripheral to your graph: none of the ops you are currently running depend on them. So, to generate summaries, we need to run all of these summary nodes. Managing them by hand would be tedious, so use -@{tf.summary.merge_all} +`tf.summary.merge_all` to combine them into a single op that generates all the summary data. Then, you can just run the merged summary op, which will generate a serialized `Summary` protobuf object with all of your summary data at a given step. Finally, to write this summary data to disk, pass the summary protobuf to a -@{tf.summary.FileWriter}. +`tf.summary.FileWriter`. The `FileWriter` takes a logdir in its constructor - this logdir is quite important, it's the directory where all of the events will be written out. diff --git a/tensorflow/docs_src/guide/tensors.md b/tensorflow/docs_src/guide/tensors.md index 7227260f1a..6b5a110a1c 100644 --- a/tensorflow/docs_src/guide/tensors.md +++ b/tensorflow/docs_src/guide/tensors.md @@ -176,7 +176,7 @@ Rank | Shape | Dimension number | Example n | [D0, D1, ... Dn-1] | n-D | A tensor with shape [D0, D1, ... Dn-1]. Shapes can be represented via Python lists / tuples of ints, or with the -@{tf.TensorShape}. +`tf.TensorShape`. ### Getting a `tf.Tensor` object's shape diff --git a/tensorflow/docs_src/guide/using_tpu.md b/tensorflow/docs_src/guide/using_tpu.md index 41d80d9d60..90a663b75e 100644 --- a/tensorflow/docs_src/guide/using_tpu.md +++ b/tensorflow/docs_src/guide/using_tpu.md @@ -17,9 +17,9 @@ This doc is aimed at users who: ## TPUEstimator -@{tf.estimator.Estimator$Estimators} are TensorFlow's model-level abstraction. +`tf.estimator.Estimator` are TensorFlow's model-level abstraction. Standard `Estimators` can drive models on CPU and GPUs. You must use -@{tf.contrib.tpu.TPUEstimator} to drive a model on TPUs. +`tf.contrib.tpu.TPUEstimator` to drive a model on TPUs. Refer to TensorFlow's Getting Started section for an introduction to the basics of using a @{$premade_estimators$pre-made `Estimator`}, and @@ -44,10 +44,10 @@ my_estimator = tf.estimator.Estimator( model_fn=my_model_fn) ``` -The changes required to use a @{tf.contrib.tpu.TPUEstimator} on your local +The changes required to use a `tf.contrib.tpu.TPUEstimator` on your local machine are relatively minor. The constructor requires two additional arguments. You should set the `use_tpu` argument to `False`, and pass a -@{tf.contrib.tpu.RunConfig} as the `config` argument, as shown below: +`tf.contrib.tpu.RunConfig` as the `config` argument, as shown below: ``` python my_tpu_estimator = tf.contrib.tpu.TPUEstimator( @@ -117,7 +117,7 @@ my_tpu_run_config = tf.contrib.tpu.RunConfig( ) ``` -Then you must pass the @{tf.contrib.tpu.RunConfig} to the constructor: +Then you must pass the `tf.contrib.tpu.RunConfig` to the constructor: ``` python my_tpu_estimator = tf.contrib.tpu.TPUEstimator( @@ -137,7 +137,7 @@ training locally to training on a cloud TPU you would need to: ## Optimizer When training on a cloud TPU you **must** wrap the optimizer in a -@{tf.contrib.tpu.CrossShardOptimizer}, which uses an `allreduce` to aggregate +`tf.contrib.tpu.CrossShardOptimizer`, which uses an `allreduce` to aggregate gradients and broadcast the result to each shard (each TPU core). The `CrossShardOptimizer` is not compatible with local training. So, to have @@ -200,7 +200,7 @@ Build your evaluation metrics dictionary in a stand-alone `metric_fn`. Evaluation metrics are an essential part of training a model. These are fully supported on Cloud TPUs, but with a slightly different syntax. -A standard @{tf.metrics} returns two tensors. The first returns the running +A standard `tf.metrics` returns two tensors. The first returns the running average of the metric value, while the second updates the running average and returns the value for this batch: @@ -242,15 +242,15 @@ An `Estimator`'s `model_fn` must return an `EstimatorSpec`. An `EstimatorSpec` is a simple structure of named fields containing all the `tf.Tensors` of the model that the `Estimator` may need to interact with. -`TPUEstimators` use a @{tf.contrib.tpu.TPUEstimatorSpec}. There are a few -differences between it and a standard @{tf.estimator.EstimatorSpec}: +`TPUEstimators` use a `tf.contrib.tpu.TPUEstimatorSpec`. There are a few +differences between it and a standard `tf.estimator.EstimatorSpec`: * The `eval_metric_ops` must be wrapped into a `metrics_fn`, this field is renamed `eval_metrics` ([see above](#metrics)). -* The @{tf.train.SessionRunHook$hooks} are unsupported, so these fields are +* The `tf.train.SessionRunHook` are unsupported, so these fields are omitted. -* The @{tf.train.Scaffold$`scaffold`}, if used, must also be wrapped in a +* The `tf.train.Scaffold`, if used, must also be wrapped in a function. This field is renamed to `scaffold_fn`. `Scaffold` and `Hooks` are for advanced usage, and can typically be omitted. @@ -304,7 +304,7 @@ In many cases the batch size is the only unknown dimension. A typical input pipeline, using `tf.data`, will usually produce batches of a fixed size. The last batch of a finite `Dataset`, however, is typically smaller, containing just the remaining elements. Since a `Dataset` does not know its own -length or finiteness, the standard @{tf.data.Dataset.batch$`batch`} method +length or finiteness, the standard `tf.data.Dataset.batch` method cannot determine if all batches will have a fixed size batch on its own: ``` @@ -317,7 +317,7 @@ cannot determine if all batches will have a fixed size batch on its own: ``` The most straightforward fix is to -@{tf.data.Dataset.apply$apply} @{tf.contrib.data.batch_and_drop_remainder} +`tf.data.Dataset.apply` `tf.contrib.data.batch_and_drop_remainder` as follows: ``` @@ -346,19 +346,19 @@ TPU, as it is impossible to use the Cloud TPU's unless you can feed it data quickly enough. See @{$datasets_performance} for details on dataset performance. For all but the simplest experimentation (using -@{tf.data.Dataset.from_tensor_slices} or other in-graph data) you will need to +`tf.data.Dataset.from_tensor_slices` or other in-graph data) you will need to store all data files read by the `TPUEstimator`'s `Dataset` in Google Cloud Storage Buckets. For most use-cases, we recommend converting your data into `TFRecord` -format and using a @{tf.data.TFRecordDataset} to read it. This, however, is not +format and using a `tf.data.TFRecordDataset` to read it. This, however, is not a hard requirement and you can use other dataset readers (`FixedLengthRecordDataset` or `TextLineDataset`) if you prefer. Small datasets can be loaded entirely into memory using -@{tf.data.Dataset.cache}. +`tf.data.Dataset.cache`. Regardless of the data format used, it is strongly recommended that you @{$performance_guide#use_large_files$use large files}, on the order of diff --git a/tensorflow/docs_src/guide/variables.md b/tensorflow/docs_src/guide/variables.md index cd8c4b5b9a..5d5d73394c 100644 --- a/tensorflow/docs_src/guide/variables.md +++ b/tensorflow/docs_src/guide/variables.md @@ -119,7 +119,7 @@ It is particularly important for variables to be in the correct device in distributed settings. Accidentally putting variables on workers instead of parameter servers, for example, can severely slow down training or, in the worst case, let each worker blithely forge ahead with its own independent copy of each -variable. For this reason we provide @{tf.train.replica_device_setter}, which +variable. For this reason we provide `tf.train.replica_device_setter`, which can automatically place variables in parameter servers. For example: ``` python @@ -211,7 +211,7 @@ sess.run(assignment) # or assignment.op.run(), or assignment.eval() Most TensorFlow optimizers have specialized ops that efficiently update the values of variables according to some gradient descent-like algorithm. See -@{tf.train.Optimizer} for an explanation of how to use optimizers. +`tf.train.Optimizer` for an explanation of how to use optimizers. Because variables are mutable it's sometimes useful to know what version of a variable's value is being used at any point in time. To force a re-read of the diff --git a/tensorflow/docs_src/guide/version_compat.md b/tensorflow/docs_src/guide/version_compat.md index d2e5e41190..0e472c3381 100644 --- a/tensorflow/docs_src/guide/version_compat.md +++ b/tensorflow/docs_src/guide/version_compat.md @@ -66,7 +66,7 @@ patch versions. The public APIs consist of Some API functions are explicitly marked as "experimental" and can change in backward incompatible ways between minor releases. These include: -* **Experimental APIs**: The @{tf.contrib} module and its submodules in Python +* **Experimental APIs**: The `tf.contrib` module and its submodules in Python and any functions in the C API or fields in protocol buffers that are explicitly commented as being experimental. In particular, any field in a protocol buffer which is called "experimental" and all its fields and @@ -252,13 +252,13 @@ ops has not changed: 1. If forward compatibility is desired, set `strip_default_attrs` to `True` while exporting the model using either the - @{tf.saved_model.builder.SavedModelBuilder.add_meta_graph_and_variables$`add_meta_graph_and_variables`} - and @{tf.saved_model.builder.SavedModelBuilder.add_meta_graph$`add_meta_graph`} + `tf.saved_model.builder.SavedModelBuilder.add_meta_graph_and_variables` + and `tf.saved_model.builder.SavedModelBuilder.add_meta_graph` methods of the `SavedModelBuilder` class, or - @{tf.estimator.Estimator.export_savedmodel$`Estimator.export_savedmodel`} + `tf.estimator.Estimator.export_savedmodel` 2. This strips off the default valued attributes at the time of producing/exporting the models. This makes sure that the exported - @{tf.MetaGraphDef} does not contain the new op-attribute when the default + `tf.MetaGraphDef` does not contain the new op-attribute when the default value is used. 3. Having this control could allow out-of-date consumers (for example, serving binaries that lag behind training binaries) to continue loading the models diff --git a/tensorflow/docs_src/performance/datasets_performance.md b/tensorflow/docs_src/performance/datasets_performance.md index 46b43b7673..5d9e4ba392 100644 --- a/tensorflow/docs_src/performance/datasets_performance.md +++ b/tensorflow/docs_src/performance/datasets_performance.md @@ -38,9 +38,9 @@ the heavy lifting of training your model. In addition, viewing input pipelines as an ETL process provides structure that facilitates the application of performance optimizations. -When using the @{tf.estimator.Estimator} API, the first two phases (Extract and +When using the `tf.estimator.Estimator` API, the first two phases (Extract and Transform) are captured in the `input_fn` passed to -@{tf.estimator.Estimator.train}. In code, this might look like the following +`tf.estimator.Estimator.train`. In code, this might look like the following (naive, sequential) implementation: ``` @@ -99,7 +99,7 @@ With pipelining, idle time diminishes significantly: ![with pipelining](/images/datasets_with_pipelining.png) The `tf.data` API provides a software pipelining mechanism through the -@{tf.data.Dataset.prefetch} transformation, which can be used to decouple the +`tf.data.Dataset.prefetch` transformation, which can be used to decouple the time data is produced from the time it is consumed. In particular, the transformation uses a background thread and an internal buffer to prefetch elements from the input dataset ahead of the time they are requested. Thus, to @@ -130,7 +130,7 @@ The preceding recommendation is simply the most common application. ### Parallelize Data Transformation When preparing a batch, input elements may need to be pre-processed. To this -end, the `tf.data` API offers the @{tf.data.Dataset.map} transformation, which +end, the `tf.data` API offers the `tf.data.Dataset.map` transformation, which applies a user-defined function (for example, `parse_fn` from the running example) to each element of the input dataset. Because input elements are independent of one another, the pre-processing can be parallelized across @@ -164,7 +164,7 @@ dataset = dataset.map(map_func=parse_fn, num_parallel_calls=FLAGS.num_parallel_c Furthermore, if your batch size is in the hundreds or thousands, your pipeline will likely additionally benefit from parallelizing the batch creation. To this -end, the `tf.data` API provides the @{tf.contrib.data.map_and_batch} +end, the `tf.data` API provides the `tf.contrib.data.map_and_batch` transformation, which effectively "fuses" the map and batch transformations. To apply this change to our running example, change: @@ -205,7 +205,7 @@ is stored locally or remotely, but can be worse in the remote case if data is not prefetched effectively. To mitigate the impact of the various data extraction overheads, the `tf.data` -API offers the @{tf.contrib.data.parallel_interleave} transformation. Use this +API offers the `tf.contrib.data.parallel_interleave` transformation. Use this transformation to parallelize the execution of and interleave the contents of other datasets (such as data file readers). The number of datasets to overlap can be specified by the `cycle_length` argument. @@ -232,7 +232,7 @@ dataset = files.apply(tf.contrib.data.parallel_interleave( The throughput of remote storage systems can vary over time due to load or network events. To account for this variance, the `parallel_interleave` transformation can optionally use prefetching. (See -@{tf.contrib.data.parallel_interleave} for details). +`tf.contrib.data.parallel_interleave` for details). By default, the `parallel_interleave` transformation provides a deterministic ordering of elements to aid reproducibility. As an alternative to prefetching @@ -261,7 +261,7 @@ function (that is, have it operate over a batch of inputs at once) and apply the ### Map and Cache -The @{tf.data.Dataset.cache} transformation can cache a dataset, either in +The `tf.data.Dataset.cache` transformation can cache a dataset, either in memory or on local storage. If the user-defined function passed into the `map` transformation is expensive, apply the cache transformation after the map transformation as long as the resulting dataset can still fit into memory or @@ -281,9 +281,9 @@ performance (for example, to enable fusing of the map and batch transformations) ### Repeat and Shuffle -The @{tf.data.Dataset.repeat} transformation repeats the input data a finite (or +The `tf.data.Dataset.repeat` transformation repeats the input data a finite (or infinite) number of times; each repetition of the data is typically referred to -as an _epoch_. The @{tf.data.Dataset.shuffle} transformation randomizes the +as an _epoch_. The `tf.data.Dataset.shuffle` transformation randomizes the order of the dataset's examples. If the `repeat` transformation is applied before the `shuffle` transformation, @@ -296,7 +296,7 @@ internal state of the `shuffle` transformation. In other words, the former (`shuffle` before `repeat`) provides stronger ordering guarantees. When possible, we recommend using the fused -@{tf.contrib.data.shuffle_and_repeat} transformation, which combines the best of +`tf.contrib.data.shuffle_and_repeat` transformation, which combines the best of both worlds (good performance and strong ordering guarantees). Otherwise, we recommend shuffling before repeating. diff --git a/tensorflow/docs_src/performance/performance_guide.md b/tensorflow/docs_src/performance/performance_guide.md index dafacbe379..df70309568 100644 --- a/tensorflow/docs_src/performance/performance_guide.md +++ b/tensorflow/docs_src/performance/performance_guide.md @@ -94,7 +94,7 @@ sess.run(train_step, feed_dict={x: batch_xs, y_: batch_ys}) #### Fused decode and crop If inputs are JPEG images that also require cropping, use fused -@{tf.image.decode_and_crop_jpeg} to speed up preprocessing. +`tf.image.decode_and_crop_jpeg` to speed up preprocessing. `tf.image.decode_and_crop_jpeg` only decodes the part of the image within the crop window. This significantly speeds up the process if the crop window is much smaller than the full image. For imagenet data, this @@ -187,14 +187,14 @@ some models makes up a large percentage of the operation time. Using fused batch norm can result in a 12%-30% speedup. There are two commonly used batch norms and both support fusing. The core -@{tf.layers.batch_normalization} added fused starting in TensorFlow 1.3. +`tf.layers.batch_normalization` added fused starting in TensorFlow 1.3. ```python bn = tf.layers.batch_normalization( input_layer, fused=True, data_format='NCHW') ``` -The contrib @{tf.contrib.layers.batch_norm} method has had fused as an option +The contrib `tf.contrib.layers.batch_norm` method has had fused as an option since before TensorFlow 1.0. ```python @@ -205,43 +205,43 @@ bn = tf.contrib.layers.batch_norm(input_layer, fused=True, data_format='NCHW') There are many ways to specify an RNN computation in TensorFlow and they have trade-offs with respect to model flexibility and performance. The -@{tf.nn.rnn_cell.BasicLSTMCell} should be considered a reference implementation +`tf.nn.rnn_cell.BasicLSTMCell` should be considered a reference implementation and used only as a last resort when no other options will work. When using one of the cells, rather than the fully fused RNN layers, you have a -choice of whether to use @{tf.nn.static_rnn} or @{tf.nn.dynamic_rnn}. There +choice of whether to use `tf.nn.static_rnn` or `tf.nn.dynamic_rnn`. There shouldn't generally be a performance difference at runtime, but large unroll -amounts can increase the graph size of the @{tf.nn.static_rnn} and cause long -compile times. An additional advantage of @{tf.nn.dynamic_rnn} is that it can +amounts can increase the graph size of the `tf.nn.static_rnn` and cause long +compile times. An additional advantage of `tf.nn.dynamic_rnn` is that it can optionally swap memory from the GPU to the CPU to enable training of very long sequences. Depending on the model and hardware configuration, this can come at a performance cost. It is also possible to run multiple iterations of -@{tf.nn.dynamic_rnn} and the underlying @{tf.while_loop} construct in parallel, +`tf.nn.dynamic_rnn` and the underlying `tf.while_loop` construct in parallel, although this is rarely useful with RNN models as they are inherently sequential. -On NVIDIA GPUs, the use of @{tf.contrib.cudnn_rnn} should always be preferred +On NVIDIA GPUs, the use of `tf.contrib.cudnn_rnn` should always be preferred unless you want layer normalization, which it doesn't support. It is often at -least an order of magnitude faster than @{tf.contrib.rnn.BasicLSTMCell} and -@{tf.contrib.rnn.LSTMBlockCell} and uses 3-4x less memory than -@{tf.contrib.rnn.BasicLSTMCell}. +least an order of magnitude faster than `tf.contrib.rnn.BasicLSTMCell` and +`tf.contrib.rnn.LSTMBlockCell` and uses 3-4x less memory than +`tf.contrib.rnn.BasicLSTMCell`. If you need to run one step of the RNN at a time, as might be the case in reinforcement learning with a recurrent policy, then you should use the -@{tf.contrib.rnn.LSTMBlockCell} with your own environment interaction loop -inside a @{tf.while_loop} construct. Running one step of the RNN at a time and +`tf.contrib.rnn.LSTMBlockCell` with your own environment interaction loop +inside a `tf.while_loop` construct. Running one step of the RNN at a time and returning to Python is possible, but it will be slower. -On CPUs, mobile devices, and if @{tf.contrib.cudnn_rnn} is not available on +On CPUs, mobile devices, and if `tf.contrib.cudnn_rnn` is not available on your GPU, the fastest and most memory efficient option is -@{tf.contrib.rnn.LSTMBlockFusedCell}. +`tf.contrib.rnn.LSTMBlockFusedCell`. -For all of the less common cell types like @{tf.contrib.rnn.NASCell}, -@{tf.contrib.rnn.PhasedLSTMCell}, @{tf.contrib.rnn.UGRNNCell}, -@{tf.contrib.rnn.GLSTMCell}, @{tf.contrib.rnn.Conv1DLSTMCell}, -@{tf.contrib.rnn.Conv2DLSTMCell}, @{tf.contrib.rnn.LayerNormBasicLSTMCell}, +For all of the less common cell types like `tf.contrib.rnn.NASCell`, +`tf.contrib.rnn.PhasedLSTMCell`, `tf.contrib.rnn.UGRNNCell`, +`tf.contrib.rnn.GLSTMCell`, `tf.contrib.rnn.Conv1DLSTMCell`, +`tf.contrib.rnn.Conv2DLSTMCell`, `tf.contrib.rnn.LayerNormBasicLSTMCell`, etc., one should be aware that they are implemented in the graph like -@{tf.contrib.rnn.BasicLSTMCell} and as such will suffer from the same poor +`tf.contrib.rnn.BasicLSTMCell` and as such will suffer from the same poor performance and high memory usage. One should consider whether or not those trade-offs are worth it before using these cells. For example, while layer normalization can speed up convergence, because cuDNN is 20x faster the fastest diff --git a/tensorflow/docs_src/performance/performance_models.md b/tensorflow/docs_src/performance/performance_models.md index 359b0e904d..66bf684d5b 100644 --- a/tensorflow/docs_src/performance/performance_models.md +++ b/tensorflow/docs_src/performance/performance_models.md @@ -10,8 +10,8 @@ incorporated into high-level APIs. ## Input Pipeline The @{$performance_guide$Performance Guide} explains how to identify possible -input pipeline issues and best practices. We found that using @{tf.FIFOQueue} -and @{tf.train.queue_runner} could not saturate multiple current generation GPUs +input pipeline issues and best practices. We found that using `tf.FIFOQueue` +and `tf.train.queue_runner` could not saturate multiple current generation GPUs when using large inputs and processing with higher samples per second, such as training ImageNet with [AlexNet](http://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf). This is due to the use of Python threads as its underlying implementation. The @@ -29,7 +29,7 @@ implementation is made up of 3 stages: The dominant part of each stage is executed in parallel with the other stages using `data_flow_ops.StagingArea`. `StagingArea` is a queue-like operator -similar to @{tf.FIFOQueue}. The difference is that `StagingArea` does not +similar to `tf.FIFOQueue`. The difference is that `StagingArea` does not guarantee FIFO ordering, but offers simpler functionality and can be executed on both CPU and GPU in parallel with other stages. Breaking the input pipeline into 3 stages that operate independently in parallel is scalable and takes full @@ -62,10 +62,10 @@ and executed in parallel. The image preprocessing ops include operations such as image decoding, distortion, and resizing. Once the images are through preprocessing, they are concatenated together into 8 -tensors each with a batch-size of 32. Rather than using @{tf.concat} for this +tensors each with a batch-size of 32. Rather than using `tf.concat` for this purpose, which is implemented as a single op that waits for all the inputs to be -ready before concatenating them together, @{tf.parallel_stack} is used. -@{tf.parallel_stack} allocates an uninitialized tensor as an output, and each +ready before concatenating them together, `tf.parallel_stack` is used. +`tf.parallel_stack` allocates an uninitialized tensor as an output, and each input tensor is written to its designated portion of the output tensor as soon as the input is available. @@ -94,7 +94,7 @@ the GPU, all the tensors are already available. With all the stages capable of being driven by different processors, `data_flow_ops.StagingArea` is used between them so they run in parallel. -`StagingArea` is a queue-like operator similar to @{tf.FIFOQueue} that offers +`StagingArea` is a queue-like operator similar to `tf.FIFOQueue` that offers simpler functionalities that can be executed on both CPU and GPU. Before the model starts running all the stages, the input pipeline stages are @@ -153,7 +153,7 @@ weights obtained from training. The default batch-normalization in TensorFlow is implemented as composite operations. This is very general, but often leads to suboptimal performance. An alternative is to use fused batch-normalization which often has much better -performance on GPU. Below is an example of using @{tf.contrib.layers.batch_norm} +performance on GPU. Below is an example of using `tf.contrib.layers.batch_norm` to implement fused batch-normalization. ```python @@ -301,7 +301,7 @@ In order to broadcast variables and aggregate gradients across different GPUs within the same host machine, we can use the default TensorFlow implicit copy mechanism. -However, we can instead use the optional NCCL (@{tf.contrib.nccl}) support. NCCL +However, we can instead use the optional NCCL (`tf.contrib.nccl`) support. NCCL is an NVIDIA® library that can efficiently broadcast and aggregate data across different GPUs. It schedules a cooperating kernel on each GPU that knows how to best utilize the underlying hardware topology; this kernel uses a single SM of diff --git a/tensorflow/docs_src/performance/quantization.md b/tensorflow/docs_src/performance/quantization.md index c97f74139c..4499f5715c 100644 --- a/tensorflow/docs_src/performance/quantization.md +++ b/tensorflow/docs_src/performance/quantization.md @@ -163,7 +163,7 @@ bazel build tensorflow/contrib/lite/toco:toco && \ --std_value=127.5 --mean_value=127.5 ``` -See the documentation for @{tf.contrib.quantize} and +See the documentation for `tf.contrib.quantize` and [TensorFlow Lite](/mobile/tflite/). ## Quantized accuracy diff --git a/tensorflow/docs_src/performance/xla/operation_semantics.md b/tensorflow/docs_src/performance/xla/operation_semantics.md index edc777a3c7..8726fdb67a 100644 --- a/tensorflow/docs_src/performance/xla/operation_semantics.md +++ b/tensorflow/docs_src/performance/xla/operation_semantics.md @@ -270,7 +270,7 @@ Clamp(min, operand, max) = s32[3]{0, 5, 6}; See also [`XlaBuilder::Collapse`](https://www.tensorflow.org/code/tensorflow/compiler/xla/client/xla_builder.h) -and the @{tf.reshape} operation. +and the `tf.reshape` operation. Collapses dimensions of an array into one dimension. @@ -291,7 +291,7 @@ same position in the dimension sequence as those they replace, with the new dimension size equal to the product of original dimension sizes. The lowest dimension number in `dimensions` is the slowest varying dimension (most major) in the loop nest which collapses these dimension, and the highest dimension -number is fastest varying (most minor). See the @{tf.reshape} operator +number is fastest varying (most minor). See the `tf.reshape` operator if more general collapse ordering is needed. For example, let v be an array of 24 elements: @@ -490,8 +490,8 @@ array. The holes are filled with a no-op value, which for convolution means zeroes. Dilation of the rhs is also called atrous convolution. For more details, see -@{tf.nn.atrous_conv2d}. Dilation of the lhs is also called transposed -convolution. For more details, see @{tf.nn.conv2d_transpose}. +`tf.nn.atrous_conv2d`. Dilation of the lhs is also called transposed +convolution. For more details, see `tf.nn.conv2d_transpose`. The output shape has these dimensions, in this order: @@ -1270,7 +1270,7 @@ let t: (f32[10], s32) = tuple(v, s); let element_1: s32 = gettupleelement(t, 1); // Inferred shape matches s32. ``` -See also @{tf.tuple}. +See also `tf.tuple`. ## Infeed @@ -2250,7 +2250,7 @@ element types. ## Transpose -See also the @{tf.reshape} operation. +See also the `tf.reshape` operation. `Transpose(operand)` diff --git a/tensorflow/docs_src/tutorials/estimators/cnn.md b/tensorflow/docs_src/tutorials/estimators/cnn.md index 12a215b50c..100f501cc2 100644 --- a/tensorflow/docs_src/tutorials/estimators/cnn.md +++ b/tensorflow/docs_src/tutorials/estimators/cnn.md @@ -1,6 +1,6 @@ # Build a Convolutional Neural Network using Estimators -The TensorFlow @{tf.layers$`layers` module} provides a high-level API that makes +The `tf.layers` module provides a high-level API that makes it easy to construct a neural network. It provides methods that facilitate the creation of dense (fully connected) layers and convolutional layers, adding activation functions, and applying dropout regularization. In this tutorial, @@ -118,8 +118,8 @@ output from one layer-creation method and supply it as input to another. Open `cnn_mnist.py` and add the following `cnn_model_fn` function, which conforms to the interface expected by TensorFlow's Estimator API (more on this later in [Create the Estimator](#create-the-estimator)). `cnn_mnist.py` takes -MNIST feature data, labels, and -@{tf.estimator.ModeKeys$model mode} (`TRAIN`, `EVAL`, `PREDICT`) as arguments; +MNIST feature data, labels, and mode (from +`tf.estimator.ModeKeys`: `TRAIN`, `EVAL`, `PREDICT`) as arguments; configures the CNN; and returns predictions, loss, and a training operation: ```python @@ -277,7 +277,7 @@ a 5x5 convolution over a 28x28 tensor will produce a 24x24 tensor, as there are The `activation` argument specifies the activation function to apply to the output of the convolution. Here, we specify ReLU activation with -@{tf.nn.relu}. +`tf.nn.relu`. Our output tensor produced by `conv2d()` has a shape of [batch_size, 28, 28, 32]: the same height and width @@ -423,7 +423,7 @@ raw values into two different formats that our model function can return: For a given example, our predicted class is the element in the corresponding row of the logits tensor with the highest raw value. We can find the index of this -element using the @{tf.argmax} +element using the `tf.argmax` function: ```python @@ -438,7 +438,7 @@ value along the dimension with index of 1, which corresponds to our predictions 10]). We can derive probabilities from our logits layer by applying softmax activation -using @{tf.nn.softmax}: +using `tf.nn.softmax`: ```python tf.nn.softmax(logits, name="softmax_tensor") @@ -572,8 +572,8 @@ feel free to change to another directory of your choice). ### Set Up a Logging Hook {#set_up_a_logging_hook} Since CNNs can take a while to train, let's set up some logging so we can track -progress during training. We can use TensorFlow's @{tf.train.SessionRunHook} to create a -@{tf.train.LoggingTensorHook} +progress during training. We can use TensorFlow's `tf.train.SessionRunHook` to create a +`tf.train.LoggingTensorHook` that will log the probability values from the softmax layer of our CNN. Add the following to `main()`: diff --git a/tensorflow/docs_src/tutorials/images/deep_cnn.md b/tensorflow/docs_src/tutorials/images/deep_cnn.md index 27963575f5..42ad484bbf 100644 --- a/tensorflow/docs_src/tutorials/images/deep_cnn.md +++ b/tensorflow/docs_src/tutorials/images/deep_cnn.md @@ -31,26 +31,26 @@ new ideas and experimenting with new techniques. The CIFAR-10 tutorial demonstrates several important constructs for designing larger and more sophisticated models in TensorFlow: -* Core mathematical components including @{tf.nn.conv2d$convolution} +* Core mathematical components including `tf.nn.conv2d` ([wiki](https://en.wikipedia.org/wiki/Convolution)), -@{tf.nn.relu$rectified linear activations} +`tf.nn.relu` ([wiki](https://en.wikipedia.org/wiki/Rectifier_(neural_networks))), -@{tf.nn.max_pool$max pooling} +`tf.nn.max_pool` ([wiki](https://en.wikipedia.org/wiki/Convolutional_neural_network#Pooling_layer)) -and @{tf.nn.local_response_normalization$local response normalization} +and `tf.nn.local_response_normalization` (Chapter 3.3 in [AlexNet paper](https://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf)). * @{$summaries_and_tensorboard$Visualization} of network activities during training, including input images, losses and distributions of activations and gradients. * Routines for calculating the -@{tf.train.ExponentialMovingAverage$moving average} +`tf.train.ExponentialMovingAverage` of learned parameters and using these averages during evaluation to boost predictive performance. * Implementation of a -@{tf.train.exponential_decay$learning rate schedule} +`tf.train.exponential_decay` that systematically decrements over time. -* Prefetching @{tf.train.shuffle_batch$queues} +* Prefetching `tf.train.shuffle_batch` for input data to isolate the model from disk latency and expensive image pre-processing. @@ -113,27 +113,27 @@ gradients, variable updates and visualization summaries. The input part of the model is built by the functions `inputs()` and `distorted_inputs()` which read images from the CIFAR-10 binary data files. These files contain fixed byte length records, so we use -@{tf.FixedLengthRecordReader}. +`tf.FixedLengthRecordReader`. See @{$reading_data#reading-from-files$Reading Data} to learn more about how the `Reader` class works. The images are processed as follows: * They are cropped to 24 x 24 pixels, centrally for evaluation or - @{tf.random_crop$randomly} for training. -* They are @{tf.image.per_image_standardization$approximately whitened} + `tf.random_crop` for training. +* They are `tf.image.per_image_standardization` to make the model insensitive to dynamic range. For training, we additionally apply a series of random distortions to artificially increase the data set size: -* @{tf.image.random_flip_left_right$Randomly flip} the image from left to right. -* Randomly distort the @{tf.image.random_brightness$image brightness}. -* Randomly distort the @{tf.image.random_contrast$image contrast}. +* `tf.image.random_flip_left_right` the image from left to right. +* Randomly distort the `tf.image.random_brightness`. +* Randomly distort the `tf.image.random_contrast`. Please see the @{$python/image$Images} page for the list of available distortions. We also attach an -@{tf.summary.image} to the images +`tf.summary.image` to the images so that we may visualize them in @{$summaries_and_tensorboard$TensorBoard}. This is a good practice to verify that inputs are built correctly. @@ -144,7 +144,7 @@ This is a good practice to verify that inputs are built correctly. Reading images from disk and distorting them can use a non-trivial amount of processing time. To prevent these operations from slowing down training, we run them inside 16 separate threads which continuously fill a TensorFlow -@{tf.train.shuffle_batch$queue}. +`tf.train.shuffle_batch`. ### Model Prediction @@ -154,12 +154,12 @@ the model is organized as follows: Layer Name | Description --- | --- -`conv1` | @{tf.nn.conv2d$convolution} and @{tf.nn.relu$rectified linear} activation. -`pool1` | @{tf.nn.max_pool$max pooling}. -`norm1` | @{tf.nn.local_response_normalization$local response normalization}. -`conv2` | @{tf.nn.conv2d$convolution} and @{tf.nn.relu$rectified linear} activation. -`norm2` | @{tf.nn.local_response_normalization$local response normalization}. -`pool2` | @{tf.nn.max_pool$max pooling}. +`conv1` | `tf.nn.conv2d` and `tf.nn.relu` activation. +`pool1` | `tf.nn.max_pool`. +`norm1` | `tf.nn.local_response_normalization`. +`conv2` | `tf.nn.conv2d` and `tf.nn.relu` activation. +`norm2` | `tf.nn.local_response_normalization`. +`pool2` | `tf.nn.max_pool`. `local3` | @{$python/nn$fully connected layer with rectified linear activation}. `local4` | @{$python/nn$fully connected layer with rectified linear activation}. `softmax_linear` | linear transformation to produce logits. @@ -172,7 +172,7 @@ Here is a graph generated from TensorBoard describing the inference operation: > **EXERCISE**: The output of `inference` are un-normalized logits. Try editing the network architecture to return normalized predictions using -@{tf.nn.softmax}. +`tf.nn.softmax`. The `inputs()` and `inference()` functions provide all the components necessary to perform an evaluation of a model. We now shift our focus towards @@ -190,16 +190,16 @@ architecture in the top layer. The usual method for training a network to perform N-way classification is [multinomial logistic regression](https://en.wikipedia.org/wiki/Multinomial_logistic_regression), aka. *softmax regression*. Softmax regression applies a -@{tf.nn.softmax$softmax} nonlinearity to the +`tf.nn.softmax` nonlinearity to the output of the network and calculates the -@{tf.nn.sparse_softmax_cross_entropy_with_logits$cross-entropy} +`tf.nn.sparse_softmax_cross_entropy_with_logits` between the normalized predictions and the label index. For regularization, we also apply the usual -@{tf.nn.l2_loss$weight decay} losses to all learned +`tf.nn.l2_loss` losses to all learned variables. The objective function for the model is the sum of the cross entropy loss and all these weight decay terms, as returned by the `loss()` function. -We visualize it in TensorBoard with a @{tf.summary.scalar}: +We visualize it in TensorBoard with a `tf.summary.scalar`: ![CIFAR-10 Loss](https://www.tensorflow.org/images/cifar_loss.png "CIFAR-10 Total Loss") @@ -207,14 +207,14 @@ We train the model using standard [gradient descent](https://en.wikipedia.org/wiki/Gradient_descent) algorithm (see @{$python/train$Training} for other methods) with a learning rate that -@{tf.train.exponential_decay$exponentially decays} +`tf.train.exponential_decay` over time. ![CIFAR-10 Learning Rate Decay](https://www.tensorflow.org/images/cifar_lr_decay.png "CIFAR-10 Learning Rate Decay") The `train()` function adds the operations needed to minimize the objective by calculating the gradient and updating the learned variables (see -@{tf.train.GradientDescentOptimizer} +`tf.train.GradientDescentOptimizer` for details). It returns an operation that executes all the calculations needed to train and update the model for one batch of images. @@ -263,7 +263,7 @@ training step can take so long. Try decreasing the number of images that initially fill up the queue. Search for `min_fraction_of_examples_in_queue` in `cifar10_input.py`. -`cifar10_train.py` periodically @{tf.train.Saver$saves} +`cifar10_train.py` periodically uses a `tf.train.Saver` to save all model parameters in @{$guide/saved_model$checkpoint files} but it does *not* evaluate the model. The checkpoint file @@ -285,7 +285,7 @@ how the model is training. We want more insight into the model during training: @{$summaries_and_tensorboard$TensorBoard} provides this functionality, displaying data exported periodically from `cifar10_train.py` via a -@{tf.summary.FileWriter}. +`tf.summary.FileWriter`. For instance, we can watch how the distribution of activations and degree of sparsity in `local3` features evolve during training: @@ -300,7 +300,7 @@ interesting to track over time. However, the loss exhibits a considerable amount of noise due to the small batch size employed by training. In practice we find it extremely useful to visualize their moving averages in addition to their raw values. See how the scripts use -@{tf.train.ExponentialMovingAverage} +`tf.train.ExponentialMovingAverage` for this purpose. ## Evaluating a Model @@ -336,8 +336,8 @@ exports summaries that may be visualized in TensorBoard. These summaries provide additional insight into the model during evaluation. The training script calculates the -@{tf.train.ExponentialMovingAverage$moving average} -version of all learned variables. The evaluation script substitutes +`tf.train.ExponentialMovingAverage` of all learned variables. +The evaluation script substitutes all learned model parameters with the moving average version. This substitution boosts model performance at evaluation time. @@ -401,17 +401,17 @@ gradients for a single model replica. In the code we term this abstraction a "tower". We must set two attributes for each tower: * A unique name for all operations within a tower. -@{tf.name_scope} provides +`tf.name_scope` provides this unique name by prepending a scope. For instance, all operations in the first tower are prepended with `tower_0`, e.g. `tower_0/conv1/Conv2D`. * A preferred hardware device to run the operation within a tower. -@{tf.device} specifies this. For +`tf.device` specifies this. For instance, all operations in the first tower reside within `device('/device:GPU:0')` scope indicating that they should be run on the first GPU. All variables are pinned to the CPU and accessed via -@{tf.get_variable} +`tf.get_variable` in order to share them in a multi-GPU version. See how-to on @{$variables$Sharing Variables}. diff --git a/tensorflow/docs_src/tutorials/images/image_recognition.md b/tensorflow/docs_src/tutorials/images/image_recognition.md index d545de73df..83a8d97cf0 100644 --- a/tensorflow/docs_src/tutorials/images/image_recognition.md +++ b/tensorflow/docs_src/tutorials/images/image_recognition.md @@ -253,7 +253,7 @@ definition with the `ToGraphDef()` function. TF_RETURN_IF_ERROR(session->Run({}, {output_name}, {}, out_tensors)); return Status::OK(); ``` -Then we create a @{tf.Session} +Then we create a `tf.Session` object, which is the interface to actually running the graph, and run it, specifying which node we want to get the output from, and where to put the output data. diff --git a/tensorflow/docs_src/tutorials/representation/kernel_methods.md b/tensorflow/docs_src/tutorials/representation/kernel_methods.md index f3c232c511..71e87f4d3e 100644 --- a/tensorflow/docs_src/tutorials/representation/kernel_methods.md +++ b/tensorflow/docs_src/tutorials/representation/kernel_methods.md @@ -1,9 +1,8 @@ # Improving Linear Models Using Explicit Kernel Methods -Note: This document uses a deprecated version of @{tf.estimator}, -which has a @{tf.contrib.learn.Estimator$different interface}. -It also uses other `contrib` methods whose -@{$version_compat#not_covered$API may not be stable}. +Note: This document uses a deprecated version of `tf.estimator`, +`tf.contrib.learn.Estimator`, which has a different interface. It also uses +other `contrib` methods whose @{$version_compat#not_covered$API may not be stable}. In this tutorial, we demonstrate how combining (explicit) kernel methods with linear models can drastically increase the latters' quality of predictions @@ -90,7 +89,7 @@ eval_input_fn = get_input_fn(data.validation, batch_size=5000) ## Training a simple linear model We can now train a linear model over the MNIST dataset. We will use the -@{tf.contrib.learn.LinearClassifier} estimator with 10 classes representing the +`tf.contrib.learn.LinearClassifier` estimator with 10 classes representing the 10 digits. The input features form a 784-dimensional dense vector which can be specified as follows: @@ -195,7 +194,7 @@ much higher dimensional space than the original one. See for more details. ### Kernel classifier -@{tf.contrib.kernel_methods.KernelLinearClassifier} is a pre-packaged +`tf.contrib.kernel_methods.KernelLinearClassifier` is a pre-packaged `tf.contrib.learn` estimator that combines the power of explicit kernel mappings with linear models. Its constructor is almost identical to that of the LinearClassifier estimator with the additional option to specify a list of diff --git a/tensorflow/docs_src/tutorials/representation/linear.md b/tensorflow/docs_src/tutorials/representation/linear.md index 1b418cf065..014409c617 100644 --- a/tensorflow/docs_src/tutorials/representation/linear.md +++ b/tensorflow/docs_src/tutorials/representation/linear.md @@ -1,6 +1,6 @@ # Large-scale Linear Models with TensorFlow -@{tf.estimator$Estimators} provides (among other things) a rich set of tools for +`tf.estimator` provides (among other things) a rich set of tools for working with linear models in TensorFlow. This document provides an overview of those tools. It explains: diff --git a/tensorflow/docs_src/tutorials/representation/word2vec.md b/tensorflow/docs_src/tutorials/representation/word2vec.md index 0a1c41c84a..7964650e19 100644 --- a/tensorflow/docs_src/tutorials/representation/word2vec.md +++ b/tensorflow/docs_src/tutorials/representation/word2vec.md @@ -317,7 +317,7 @@ optimizer = tf.train.GradientDescentOptimizer(learning_rate=1.0).minimize(loss) Training the model is then as simple as using a `feed_dict` to push data into the placeholders and calling -@{tf.Session.run} with this new data +`tf.Session.run` with this new data in a loop. ```python -- GitLab From cf233f7281fbb841f5ea2df548e6e857308f222b Mon Sep 17 00:00:00 2001 From: Russell Power Date: Tue, 7 Aug 2018 14:30:02 -0700 Subject: [PATCH 175/437] Enable infeed enqueue, outfeed dequeue operations. PiperOrigin-RevId: 207780309 --- tensorflow/contrib/tpu/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tensorflow/contrib/tpu/__init__.py b/tensorflow/contrib/tpu/__init__.py index d0a37eb0ed..537d94b797 100644 --- a/tensorflow/contrib/tpu/__init__.py +++ b/tensorflow/contrib/tpu/__init__.py @@ -18,6 +18,10 @@ @@cross_replica_sum @@infeed_dequeue @@infeed_dequeue_tuple +@@infeed_enqueue +@@infeed_enqueue_tuple +@@outfeed_dequeue +@@outfeed_dequeue_tuple @@outfeed_enqueue @@outfeed_enqueue_tuple -- GitLab From 9b84c91b68915a26aa9d732988cbf13a7626c2dd Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 7 Aug 2018 14:31:49 -0700 Subject: [PATCH 176/437] Fix the output shape of functional_rnn for time-major inputs. PiperOrigin-RevId: 207780606 --- .../kernel_tests/functional_rnn_test.py | 158 ++++++++++++++++-- .../recurrent/python/ops/functional_rnn.py | 9 +- 2 files changed, 149 insertions(+), 18 deletions(-) diff --git a/tensorflow/contrib/recurrent/python/kernel_tests/functional_rnn_test.py b/tensorflow/contrib/recurrent/python/kernel_tests/functional_rnn_test.py index 0f19ac7dbe..f23194a6f2 100644 --- a/tensorflow/contrib/recurrent/python/kernel_tests/functional_rnn_test.py +++ b/tensorflow/contrib/recurrent/python/kernel_tests/functional_rnn_test.py @@ -61,10 +61,17 @@ class FunctionalRnnTest(test_util.TensorFlowTestCase): func, args = self._CELLDEFS[celldef_name] return func(*args) - def _CreateInputs(self): - inputs = np.random.random([FunctionalRnnTest._BATCH_SIZE, - FunctionalRnnTest._TOTAL_TIME, - FunctionalRnnTest._INPUT_SIZE]) + def _CreateInputs(self, time_major=False): + if time_major: + inputs = np.random.random([ + FunctionalRnnTest._TOTAL_TIME, FunctionalRnnTest._BATCH_SIZE, + FunctionalRnnTest._INPUT_SIZE + ]) + else: + inputs = np.random.random([ + FunctionalRnnTest._BATCH_SIZE, FunctionalRnnTest._TOTAL_TIME, + FunctionalRnnTest._INPUT_SIZE + ]) # Always leave one time slot empty, to check max_length behavior. sequence_length = np.random.randint( 0, high=FunctionalRnnTest._TOTAL_TIME - 1, @@ -72,15 +79,51 @@ class FunctionalRnnTest(test_util.TensorFlowTestCase): dtype=np.int) return (inputs, sequence_length) - def _CreateRnnGraph(self, create_rnn_computation_func, cell, tf_inputs, - tf_sequence_length, initial_state=None, - time_major=None, scope=None): - tf_result = create_rnn_computation_func(cell=cell, inputs=tf_inputs, - sequence_length=tf_sequence_length, - initial_state=initial_state, - dtype=dtypes.float32, - time_major=time_major, - scope=scope) + def _CreateSymmetricInputs(self): + # total time = batch size + inputs = np.zeros( + (FunctionalRnnTest._BATCH_SIZE, FunctionalRnnTest._BATCH_SIZE, + FunctionalRnnTest._INPUT_SIZE)) + for i in range(FunctionalRnnTest._BATCH_SIZE): + for j in range(i, FunctionalRnnTest._BATCH_SIZE): + inputs[i][j] = np.random.random([FunctionalRnnTest._INPUT_SIZE]) + inputs[j][i] = inputs[i][j] + + # Always leave one time slot empty, to check max_length behavior. + sequence_length = np.random.randint( + 0, + high=FunctionalRnnTest._BATCH_SIZE - 1, + size=FunctionalRnnTest._BATCH_SIZE, + dtype=np.int) + return (inputs, sequence_length) + + def _CreateRnnGraph(self, + create_rnn_computation_func, + cell, + tf_inputs, + tf_sequence_length, + is_bidirectional, + initial_state=None, + time_major=None, + scope=None): + if is_bidirectional: + tf_result = create_rnn_computation_func( + cell_fw=cell, + cell_bw=cell, + inputs=tf_inputs, + sequence_length=tf_sequence_length, + dtype=dtypes.float32, + time_major=time_major, + scope=scope) + else: + tf_result = create_rnn_computation_func( + cell=cell, + inputs=tf_inputs, + sequence_length=tf_sequence_length, + initial_state=initial_state, + dtype=dtypes.float32, + time_major=time_major, + scope=scope) grad = gradients_impl.gradients(tf_result, variables.trainable_variables()) return {'inference': tf_result, 'grad': grad} @@ -102,15 +145,26 @@ class FunctionalRnnTest(test_util.TensorFlowTestCase): variable_cache[n] = v def _RunRnn(self, numpy_inputs, numpy_slen, cell_name, variable_cache, - is_dynamic): + is_dynamic, time_major=None, is_bidirectional=False): with ops.Graph().as_default() as graph: tf_inputs = array_ops.placeholder( dtypes.float32, shape=numpy_inputs.shape) tf_slen = array_ops.placeholder(dtypes.int32) feeds = {tf_inputs: numpy_inputs, tf_slen: numpy_slen} cell = self._CreateCell(cell_name) - fn = rnn_lib.dynamic_rnn if is_dynamic else functional_rnn.functional_rnn - fetches = self._CreateRnnGraph(fn, cell, tf_inputs, tf_slen) + if is_dynamic: + if is_bidirectional: + fn = rnn_lib.bidirectional_dynamic_rnn + else: + fn = rnn_lib.dynamic_rnn + else: + if is_bidirectional: + fn = functional_rnn.bidirectional_functional_rnn + else: + fn = functional_rnn.functional_rnn + + fetches = self._CreateRnnGraph( + fn, cell, tf_inputs, tf_slen, is_bidirectional, time_major=time_major) with self.test_session(graph=graph) as sess: sess.run(variables.global_variables_initializer()) # Note that cell.trainable_variables it not always set. @@ -158,6 +212,78 @@ class FunctionalRnnTest(test_util.TensorFlowTestCase): self.assertAllClose(dyn_rnn['inference'], func_rnn['inference']) self.assertAllClose(dyn_rnn['grad'], func_rnn['grad']) + def testLstmWithTimeMajorInputs(self): + """Checks an LSTM against the reference implementation, with time_major.""" + time_major = True + np_inputs, np_slen = self._CreateInputs(time_major=True) + var_cache = {} + args = [np_inputs, np_slen, 'lstm', var_cache] + _, func_rnn = self._RunRnn(*(args + [False]), time_major=time_major) + _, dyn_rnn = self._RunRnn(*(args + [True]), time_major=time_major) + self.assertAllClose(dyn_rnn['inference'], func_rnn['inference']) + self.assertAllClose(dyn_rnn['grad'], func_rnn['grad']) + + def testBidirectionalLstmWithTimeMajorInputs(self): + """Checks a bi-directional LSTM with time-major inputs.""" + time_major = True + np_inputs, np_slen = self._CreateInputs(time_major) + var_cache = {} + args = [np_inputs, np_slen, 'lstm', var_cache] + _, func_rnn = self._RunRnn( + *(args + [False]), time_major=time_major, is_bidirectional=True) + _, dyn_rnn = self._RunRnn( + *(args + [True]), time_major=time_major, is_bidirectional=True) + self.assertAllClose(dyn_rnn['inference'], func_rnn['inference']) + # TODO(b/112170761): comment out this line after the bug is fixed. + # self.assertAllClose(dyn_rnn['grad'], func_rnn['grad']) + + def testBidirectionalLstm(self): + """Checks time-major and batch-major rnn produce consistent results.""" + time_major_inputs, np_slen = self._CreateInputs(True) + batch_major_inputs = np.transpose(time_major_inputs, [1, 0, 2]) + var_cache = {} + args = [np_slen, 'lstm', var_cache, False] + _, time_major_rnn = self._RunRnn( + *([time_major_inputs] + args), time_major=True, is_bidirectional=True) + _, batch_major_rnn = self._RunRnn( + *([batch_major_inputs]+ args), time_major=False, is_bidirectional=True) + # Convert the batch-major outputs to be time-major before the comparasion. + outputs, state = batch_major_rnn['inference'] + outputs = [np.transpose(x, [1, 0, 2]) for x in outputs] + batch_major_rnn['inference'] = [outputs, state] + self.assertAllClose(time_major_rnn['inference'], + batch_major_rnn['inference']) + self.assertAllClose(time_major_rnn['grad'], batch_major_rnn['grad']) + + def testBidirectionalLstmWithSymmetricInputs(self): + """Checks a bi-directional LSTM with symmetric inputs. + + time-major and batch-major rnn produce the same result with symmetric + inputs. + """ + np_inputs, np_slen = self._CreateSymmetricInputs() + var_cache = {} + args = [np_inputs, np_slen, 'lstm', var_cache] + _, time_major_func_rnn = self._RunRnn( + *(args + [False]), time_major=True, is_bidirectional=True) + _, batch_major_func_rnn = self._RunRnn( + *(args + [False]), time_major=False, is_bidirectional=True) + _, time_major_dyn_rnn = self._RunRnn( + *(args + [True]), time_major=True, is_bidirectional=True) + _, batch_major_dyn_rnn = self._RunRnn( + *(args + [True]), time_major=False, is_bidirectional=True) + self.assertAllClose(time_major_func_rnn['inference'], + batch_major_func_rnn['inference']) + self.assertAllClose(time_major_func_rnn['grad'], + batch_major_func_rnn['grad']) + self.assertAllClose(time_major_dyn_rnn['inference'], + batch_major_dyn_rnn['inference']) + self.assertAllClose(time_major_dyn_rnn['grad'], batch_major_dyn_rnn['grad']) + self.assertAllClose(time_major_func_rnn['inference'], + batch_major_dyn_rnn['inference']) + self.assertAllClose(time_major_func_rnn['grad'], + batch_major_dyn_rnn['grad']) + if __name__ == '__main__': test_lib.main() diff --git a/tensorflow/contrib/recurrent/python/ops/functional_rnn.py b/tensorflow/contrib/recurrent/python/ops/functional_rnn.py index a085474c1b..96cc3e997f 100644 --- a/tensorflow/contrib/recurrent/python/ops/functional_rnn.py +++ b/tensorflow/contrib/recurrent/python/ops/functional_rnn.py @@ -284,8 +284,13 @@ def functional_rnn(cell, inputs, sequence_length=None, inputs=inputs, cell_fn=func_cell.cell_step, use_tpu=use_tpu) - return _PostProcessOutput(extended_acc_state, extended_final_state, - func_cell, inputs_flat[0].shape[0], sequence_length) + tf_output, tf_state = _PostProcessOutput( + extended_acc_state, extended_final_state, func_cell, + inputs_flat[0].shape[0], sequence_length) + + if time_major: + tf_output = array_ops.transpose(tf_output, [1, 0, 2]) + return tf_output, tf_state def bidirectional_functional_rnn( -- GitLab From ff8f6371d9670101b5dfc5eb8cef118547d78dcc Mon Sep 17 00:00:00 2001 From: Anna R Date: Tue, 7 Aug 2018 14:36:05 -0700 Subject: [PATCH 177/437] Keep 2 sets of API Goldens (goldens/v1 and goldens/v2). PiperOrigin-RevId: 207781405 --- tensorflow/BUILD | 1 + tensorflow/tools/api/golden/BUILD | 9 +- .../tensorflow.-aggregation-method.pbtxt | 0 .../tensorflow.-attr-value.-list-value.pbtxt | 0 .../{ => v1}/tensorflow.-attr-value.pbtxt | 0 ...orflow.-conditional-accumulator-base.pbtxt | 0 .../tensorflow.-conditional-accumulator.pbtxt | 0 ...ow.-config-proto.-device-count-entry.pbtxt | 0 ...nsorflow.-config-proto.-experimental.pbtxt | 24 + .../golden/v1/tensorflow.-config-proto.pbtxt | 148 ++ .../golden/{ => v1}/tensorflow.-d-type.pbtxt | 0 .../{ => v1}/tensorflow.-device-spec.pbtxt | 0 .../{ => v1}/tensorflow.-dimension.pbtxt | 0 .../golden/{ => v1}/tensorflow.-event.pbtxt | 0 .../{ => v1}/tensorflow.-f-i-f-o-queue.pbtxt | 0 .../tensorflow.-fixed-len-feature.pbtxt | 0 ...nsorflow.-fixed-len-sequence-feature.pbtxt | 0 ...nsorflow.-fixed-length-record-reader.pbtxt | 0 .../{ => v1}/tensorflow.-g-p-u-options.pbtxt | 0 .../{ => v1}/tensorflow.-gradient-tape.pbtxt | 0 .../{ => v1}/tensorflow.-graph-def.pbtxt | 0 .../{ => v1}/tensorflow.-graph-keys.pbtxt | 0 .../{ => v1}/tensorflow.-graph-options.pbtxt | 0 .../golden/{ => v1}/tensorflow.-graph.pbtxt | 0 .../tensorflow.-histogram-proto.pbtxt | 0 .../tensorflow.-identity-reader.pbtxt | 0 .../{ => v1}/tensorflow.-indexed-slices.pbtxt | 0 .../tensorflow.-interactive-session.pbtxt | 0 .../{ => v1}/tensorflow.-l-m-d-b-reader.pbtxt | 0 .../{ => v1}/tensorflow.-log-message.pbtxt | 0 ...meta-graph-def.-collection-def-entry.pbtxt | 0 ...rflow.-meta-graph-def.-meta-info-def.pbtxt | 0 ...-meta-graph-def.-signature-def-entry.pbtxt | 0 .../{ => v1}/tensorflow.-meta-graph-def.pbtxt | 0 ...nsorflow.-name-attr-list.-attr-entry.pbtxt | 0 .../{ => v1}/tensorflow.-name-attr-list.pbtxt | 0 .../tensorflow.-node-def.-attr-entry.pbtxt | 0 .../{ => v1}/tensorflow.-node-def.pbtxt | 0 .../{ => v1}/tensorflow.-op-error.pbtxt | 0 .../{ => v1}/tensorflow.-operation.pbtxt | 0 .../tensorflow.-optimizer-options.pbtxt | 0 .../tensorflow.-padding-f-i-f-o-queue.pbtxt | 0 .../{ => v1}/tensorflow.-priority-queue.pbtxt | 0 .../{ => v1}/tensorflow.-queue-base.pbtxt | 0 .../tensorflow.-random-shuffle-queue.pbtxt | 0 .../{ => v1}/tensorflow.-reader-base.pbtxt | 0 .../tensorflow.-register-gradient.pbtxt | 0 .../{ => v1}/tensorflow.-run-metadata.pbtxt | 0 ...ensorflow.-run-options.-experimental.pbtxt | 0 .../{ => v1}/tensorflow.-run-options.pbtxt | 0 .../{ => v1}/tensorflow.-session-log.pbtxt | 0 .../golden/{ => v1}/tensorflow.-session.pbtxt | 0 ...flow.-sparse-conditional-accumulator.pbtxt | 0 .../{ => v1}/tensorflow.-sparse-feature.pbtxt | 0 .../tensorflow.-sparse-tensor-value.pbtxt | 0 .../{ => v1}/tensorflow.-sparse-tensor.pbtxt | 0 ...rflow.-summary-metadata.-plugin-data.pbtxt | 0 .../tensorflow.-summary-metadata.pbtxt | 0 .../{ => v1}/tensorflow.-summary.-audio.pbtxt | 0 .../{ => v1}/tensorflow.-summary.-image.pbtxt | 0 .../{ => v1}/tensorflow.-summary.-value.pbtxt | 0 .../golden/{ => v1}/tensorflow.-summary.pbtxt | 0 .../tensorflow.-t-f-record-reader.pbtxt | 0 .../{ => v1}/tensorflow.-tensor-array.pbtxt | 0 .../tensorflow.-tensor-info.-coo-sparse.pbtxt | 0 .../{ => v1}/tensorflow.-tensor-info.pbtxt | 0 .../{ => v1}/tensorflow.-tensor-shape.pbtxt | 0 .../golden/{ => v1}/tensorflow.-tensor.pbtxt | 0 .../tensorflow.-text-line-reader.pbtxt | 0 .../tensorflow.-var-len-feature.pbtxt | 0 .../tensorflow.-variable-aggregation.pbtxt | 0 .../{ => v1}/tensorflow.-variable-scope.pbtxt | 0 ...tensorflow.-variable-synchronization.pbtxt | 0 ...ensorflow.-variable.-save-slice-info.pbtxt | 0 .../{ => v1}/tensorflow.-variable.pbtxt | 0 .../tensorflow.-whole-file-reader.pbtxt | 0 .../api/golden/{ => v1}/tensorflow.app.pbtxt | 0 .../golden/{ => v1}/tensorflow.bitwise.pbtxt | 0 .../golden/{ => v1}/tensorflow.compat.pbtxt | 0 .../tensorflow.constant_initializer.pbtxt | 0 ...nsorflow.data.-dataset.__metaclass__.pbtxt | 0 .../{ => v1}/tensorflow.data.-dataset.pbtxt | 0 ...-length-record-dataset.__metaclass__.pbtxt | 0 ...ow.data.-fixed-length-record-dataset.pbtxt | 0 .../golden/v1/tensorflow.data.-iterator.pbtxt | 46 + ...ta.-t-f-record-dataset.__metaclass__.pbtxt | 0 .../tensorflow.data.-t-f-record-dataset.pbtxt | 0 ...ata.-text-line-dataset.__metaclass__.pbtxt | 0 .../tensorflow.data.-text-line-dataset.pbtxt | 0 .../api/golden/{ => v1}/tensorflow.data.pbtxt | 0 .../{ => v1}/tensorflow.debugging.pbtxt | 0 .../tensorflow.distributions.-bernoulli.pbtxt | 0 .../tensorflow.distributions.-beta.pbtxt | 0 ...ensorflow.distributions.-categorical.pbtxt | 0 ...distributions.-dirichlet-multinomial.pbtxt | 0 .../tensorflow.distributions.-dirichlet.pbtxt | 0 ...nsorflow.distributions.-distribution.pbtxt | 0 ...ensorflow.distributions.-exponential.pbtxt | 0 .../tensorflow.distributions.-gamma.pbtxt | 0 .../tensorflow.distributions.-laplace.pbtxt | 0 ...ensorflow.distributions.-multinomial.pbtxt | 0 .../tensorflow.distributions.-normal.pbtxt | 0 ...nsorflow.distributions.-register-k-l.pbtxt | 0 ...stributions.-reparameterization-type.pbtxt | 0 .../tensorflow.distributions.-student-t.pbtxt | 0 .../tensorflow.distributions.-uniform.pbtxt | 0 .../{ => v1}/tensorflow.distributions.pbtxt | 0 .../golden/{ => v1}/tensorflow.dtypes.pbtxt | 0 .../tensorflow.errors.-aborted-error.pbtxt | 0 ...sorflow.errors.-already-exists-error.pbtxt | 0 .../tensorflow.errors.-cancelled-error.pbtxt | 0 .../tensorflow.errors.-data-loss-error.pbtxt | 0 ...flow.errors.-deadline-exceeded-error.pbtxt | 0 ...ow.errors.-failed-precondition-error.pbtxt | 0 .../tensorflow.errors.-internal-error.pbtxt | 0 ...rflow.errors.-invalid-argument-error.pbtxt | 0 .../tensorflow.errors.-not-found-error.pbtxt | 0 .../tensorflow.errors.-op-error.pbtxt | 0 ...ensorflow.errors.-out-of-range-error.pbtxt | 0 ...flow.errors.-permission-denied-error.pbtxt | 0 ...low.errors.-resource-exhausted-error.pbtxt | 0 ...orflow.errors.-unauthenticated-error.pbtxt | 0 ...tensorflow.errors.-unavailable-error.pbtxt | 0 ...nsorflow.errors.-unimplemented-error.pbtxt | 0 .../tensorflow.errors.-unknown-error.pbtxt | 0 .../golden/{ => v1}/tensorflow.errors.pbtxt | 0 ...ors.raise_exception_on_not_ok_status.pbtxt | 0 ...rflow.estimator.-baseline-classifier.pbtxt | 0 ...orflow.estimator.-baseline-regressor.pbtxt | 0 .../tensorflow.estimator.-best-exporter.pbtxt | 0 ....estimator.-boosted-trees-classifier.pbtxt | 58 + ...w.estimator.-boosted-trees-regressor.pbtxt | 58 + ...nsorflow.estimator.-d-n-n-classifier.pbtxt | 0 ...or.-d-n-n-linear-combined-classifier.pbtxt | 0 ...tor.-d-n-n-linear-combined-regressor.pbtxt | 0 ...ensorflow.estimator.-d-n-n-regressor.pbtxt | 0 ...tensorflow.estimator.-estimator-spec.pbtxt | 0 .../tensorflow.estimator.-estimator.pbtxt | 0 .../tensorflow.estimator.-eval-spec.pbtxt | 0 .../tensorflow.estimator.-exporter.pbtxt | 0 ...tensorflow.estimator.-final-exporter.pbtxt | 0 ...ensorflow.estimator.-latest-exporter.pbtxt | 0 ...sorflow.estimator.-linear-classifier.pbtxt | 0 ...nsorflow.estimator.-linear-regressor.pbtxt | 0 .../tensorflow.estimator.-mode-keys.pbtxt | 0 .../v1/tensorflow.estimator.-run-config.pbtxt | 105 + .../tensorflow.estimator.-train-spec.pbtxt | 0 .../tensorflow.estimator.-vocab-info.pbtxt | 0 ...rflow.estimator.-warm-start-settings.pbtxt | 0 ...-classification-output.__metaclass__.pbtxt | 0 ...imator.export.-classification-output.pbtxt | 0 ....export.-export-output.__metaclass__.pbtxt | 0 ...flow.estimator.export.-export-output.pbtxt | 0 ...export.-predict-output.__metaclass__.pbtxt | 0 ...low.estimator.export.-predict-output.pbtxt | 0 ...ort.-regression-output.__metaclass__.pbtxt | 0 ....estimator.export.-regression-output.pbtxt | 0 ...mator.export.-serving-input-receiver.pbtxt | 0 ...xport.-tensor-serving-input-receiver.pbtxt | 0 .../tensorflow.estimator.export.pbtxt | 0 .../tensorflow.estimator.inputs.pbtxt | 0 .../{ => v1}/tensorflow.estimator.pbtxt | 0 .../{ => v1}/tensorflow.feature_column.pbtxt | 0 .../tensorflow.gfile.-fast-g-file.pbtxt | 0 .../{ => v1}/tensorflow.gfile.-g-file.pbtxt | 0 .../{ => v1}/tensorflow.gfile.-open.pbtxt | 0 .../golden/{ => v1}/tensorflow.gfile.pbtxt | 0 .../{ => v1}/tensorflow.graph_util.pbtxt | 0 .../tensorflow.image.-resize-method.pbtxt | 0 .../api/golden/v1/tensorflow.image.pbtxt | 251 ++ .../tensorflow.initializers.constant.pbtxt | 0 .../tensorflow.initializers.identity.pbtxt | 0 .../tensorflow.initializers.ones.pbtxt | 0 .../tensorflow.initializers.orthogonal.pbtxt | 0 .../{ => v1}/tensorflow.initializers.pbtxt | 0 ...ensorflow.initializers.random_normal.pbtxt | 0 ...nsorflow.initializers.random_uniform.pbtxt | 0 ...orflow.initializers.truncated_normal.pbtxt | 0 ...ow.initializers.uniform_unit_scaling.pbtxt | 0 ...orflow.initializers.variance_scaling.pbtxt | 0 .../tensorflow.initializers.zeros.pbtxt | 0 .../api/golden/{ => v1}/tensorflow.io.pbtxt | 0 .../golden/v1/tensorflow.keras.-model.pbtxt | 268 ++ .../v1/tensorflow.keras.-sequential.pbtxt | 289 +++ .../v1/tensorflow.keras.activations.pbtxt | 55 + ...nsorflow.keras.applications.densenet.pbtxt | 0 ...ras.applications.inception_resnet_v2.pbtxt | 0 ...flow.keras.applications.inception_v3.pbtxt | 0 ...sorflow.keras.applications.mobilenet.pbtxt | 0 ...tensorflow.keras.applications.nasnet.pbtxt | 0 .../tensorflow.keras.applications.pbtxt | 0 ...nsorflow.keras.applications.resnet50.pbtxt | 0 .../tensorflow.keras.applications.vgg16.pbtxt | 0 .../tensorflow.keras.applications.vgg19.pbtxt | 0 ...nsorflow.keras.applications.xception.pbtxt | 0 .../tensorflow.keras.backend.name_scope.pbtxt | 0 .../{ => v1}/tensorflow.keras.backend.pbtxt | 0 ...sorflow.keras.callbacks.-base-logger.pbtxt | 0 ...orflow.keras.callbacks.-c-s-v-logger.pbtxt | 0 ...tensorflow.keras.callbacks.-callback.pbtxt | 0 ...flow.keras.callbacks.-early-stopping.pbtxt | 0 .../tensorflow.keras.callbacks.-history.pbtxt | 0 ...low.keras.callbacks.-lambda-callback.pbtxt | 0 ...s.callbacks.-learning-rate-scheduler.pbtxt | 0 ...ow.keras.callbacks.-model-checkpoint.pbtxt | 0 ...flow.keras.callbacks.-progbar-logger.pbtxt | 0 ...ras.callbacks.-reduce-l-r-on-plateau.pbtxt | 0 ...flow.keras.callbacks.-remote-monitor.pbtxt | 0 ...orflow.keras.callbacks.-tensor-board.pbtxt | 0 ...w.keras.callbacks.-terminate-on-na-n.pbtxt | 0 .../{ => v1}/tensorflow.keras.callbacks.pbtxt | 0 ...orflow.keras.constraints.-constraint.pbtxt | 0 ...nsorflow.keras.constraints.-max-norm.pbtxt | 0 ...flow.keras.constraints.-min-max-norm.pbtxt | 0 ...ensorflow.keras.constraints.-non-neg.pbtxt | 0 ...sorflow.keras.constraints.-unit-norm.pbtxt | 0 ...ensorflow.keras.constraints.max_norm.pbtxt | 0 ...rflow.keras.constraints.min_max_norm.pbtxt | 0 ...tensorflow.keras.constraints.non_neg.pbtxt | 0 .../tensorflow.keras.constraints.pbtxt | 0 ...nsorflow.keras.constraints.unit_norm.pbtxt | 0 ...orflow.keras.datasets.boston_housing.pbtxt | 0 .../tensorflow.keras.datasets.cifar10.pbtxt | 0 .../tensorflow.keras.datasets.cifar100.pbtxt | 0 ...sorflow.keras.datasets.fashion_mnist.pbtxt | 0 .../tensorflow.keras.datasets.imdb.pbtxt | 0 .../tensorflow.keras.datasets.mnist.pbtxt | 0 .../{ => v1}/tensorflow.keras.datasets.pbtxt | 0 .../tensorflow.keras.datasets.reuters.pbtxt | 0 .../{ => v1}/tensorflow.keras.estimator.pbtxt | 0 ...sorflow.keras.initializers.-constant.pbtxt | 0 ...sorflow.keras.initializers.-identity.pbtxt | 0 ...flow.keras.initializers.-initializer.pbtxt | 0 .../tensorflow.keras.initializers.-ones.pbtxt | 0 ...rflow.keras.initializers.-orthogonal.pbtxt | 0 ...ow.keras.initializers.-random-normal.pbtxt | 0 ...w.keras.initializers.-random-uniform.pbtxt | 0 ...keras.initializers.-truncated-normal.pbtxt | 0 ...keras.initializers.-variance-scaling.pbtxt | 0 ...tensorflow.keras.initializers.-zeros.pbtxt | 0 ...nsorflow.keras.initializers.constant.pbtxt | 0 ...nsorflow.keras.initializers.identity.pbtxt | 0 ...tensorflow.keras.initializers.normal.pbtxt | 0 .../tensorflow.keras.initializers.ones.pbtxt | 0 ...orflow.keras.initializers.orthogonal.pbtxt | 0 .../tensorflow.keras.initializers.pbtxt | 0 ...low.keras.initializers.random_normal.pbtxt | 0 ...ow.keras.initializers.random_uniform.pbtxt | 0 ....keras.initializers.truncated_normal.pbtxt | 0 ...ensorflow.keras.initializers.uniform.pbtxt | 0 .../tensorflow.keras.initializers.zeros.pbtxt | 0 .../tensorflow.keras.layers.-activation.pbtxt | 0 ...eras.layers.-activity-regularization.pbtxt | 0 .../tensorflow.keras.layers.-add.pbtxt | 0 ...nsorflow.keras.layers.-alpha-dropout.pbtxt | 0 ...low.keras.layers.-average-pooling1-d.pbtxt | 0 ...low.keras.layers.-average-pooling2-d.pbtxt | 0 ...low.keras.layers.-average-pooling3-d.pbtxt | 0 .../tensorflow.keras.layers.-average.pbtxt | 0 ...tensorflow.keras.layers.-avg-pool1-d.pbtxt | 0 ...tensorflow.keras.layers.-avg-pool2-d.pbtxt | 0 ...tensorflow.keras.layers.-avg-pool3-d.pbtxt | 0 ...ow.keras.layers.-batch-normalization.pbtxt | 0 ...nsorflow.keras.layers.-bidirectional.pbtxt | 0 ...tensorflow.keras.layers.-concatenate.pbtxt | 0 ...orflow.keras.layers.-conv-l-s-t-m2-d.pbtxt | 0 .../tensorflow.keras.layers.-conv1-d.pbtxt | 0 ...flow.keras.layers.-conv2-d-transpose.pbtxt | 0 .../tensorflow.keras.layers.-conv2-d.pbtxt | 0 ...flow.keras.layers.-conv3-d-transpose.pbtxt | 0 .../tensorflow.keras.layers.-conv3-d.pbtxt | 0 ...sorflow.keras.layers.-convolution1-d.pbtxt | 0 ...ras.layers.-convolution2-d-transpose.pbtxt | 0 ...sorflow.keras.layers.-convolution2-d.pbtxt | 0 ...ras.layers.-convolution3-d-transpose.pbtxt | 0 ...sorflow.keras.layers.-convolution3-d.pbtxt | 0 ...tensorflow.keras.layers.-cropping1-d.pbtxt | 0 ...tensorflow.keras.layers.-cropping2-d.pbtxt | 0 ...tensorflow.keras.layers.-cropping3-d.pbtxt | 0 ...sorflow.keras.layers.-cu-d-n-n-g-r-u.pbtxt | 0 ...rflow.keras.layers.-cu-d-n-n-l-s-t-m.pbtxt | 0 .../tensorflow.keras.layers.-dense.pbtxt | 0 ...flow.keras.layers.-depthwise-conv2-d.pbtxt | 0 .../tensorflow.keras.layers.-dot.pbtxt | 0 .../tensorflow.keras.layers.-dropout.pbtxt | 0 .../tensorflow.keras.layers.-e-l-u.pbtxt | 0 .../tensorflow.keras.layers.-embedding.pbtxt | 0 .../tensorflow.keras.layers.-flatten.pbtxt | 0 .../tensorflow.keras.layers.-g-r-u-cell.pbtxt | 0 .../tensorflow.keras.layers.-g-r-u.pbtxt | 0 ...rflow.keras.layers.-gaussian-dropout.pbtxt | 0 ...sorflow.keras.layers.-gaussian-noise.pbtxt | 0 ...as.layers.-global-average-pooling1-d.pbtxt | 0 ...as.layers.-global-average-pooling2-d.pbtxt | 0 ...as.layers.-global-average-pooling3-d.pbtxt | 0 ...low.keras.layers.-global-avg-pool1-d.pbtxt | 0 ...low.keras.layers.-global-avg-pool2-d.pbtxt | 0 ...low.keras.layers.-global-avg-pool3-d.pbtxt | 0 ...low.keras.layers.-global-max-pool1-d.pbtxt | 0 ...low.keras.layers.-global-max-pool2-d.pbtxt | 0 ...low.keras.layers.-global-max-pool3-d.pbtxt | 0 ....keras.layers.-global-max-pooling1-d.pbtxt | 0 ....keras.layers.-global-max-pooling2-d.pbtxt | 0 ....keras.layers.-global-max-pooling3-d.pbtxt | 0 ...tensorflow.keras.layers.-input-layer.pbtxt | 0 .../tensorflow.keras.layers.-input-spec.pbtxt | 0 ...ensorflow.keras.layers.-l-s-t-m-cell.pbtxt | 0 .../tensorflow.keras.layers.-l-s-t-m.pbtxt | 0 .../tensorflow.keras.layers.-lambda.pbtxt | 0 .../tensorflow.keras.layers.-layer.pbtxt | 0 ...ensorflow.keras.layers.-leaky-re-l-u.pbtxt | 0 ...w.keras.layers.-locally-connected1-d.pbtxt | 0 ...w.keras.layers.-locally-connected2-d.pbtxt | 0 .../tensorflow.keras.layers.-masking.pbtxt | 0 ...tensorflow.keras.layers.-max-pool1-d.pbtxt | 0 ...tensorflow.keras.layers.-max-pool2-d.pbtxt | 0 ...tensorflow.keras.layers.-max-pool3-d.pbtxt | 0 ...sorflow.keras.layers.-max-pooling1-d.pbtxt | 0 ...sorflow.keras.layers.-max-pooling2-d.pbtxt | 0 ...sorflow.keras.layers.-max-pooling3-d.pbtxt | 0 .../tensorflow.keras.layers.-maximum.pbtxt | 0 .../tensorflow.keras.layers.-minimum.pbtxt | 0 .../tensorflow.keras.layers.-multiply.pbtxt | 0 .../tensorflow.keras.layers.-p-re-l-u.pbtxt | 0 .../tensorflow.keras.layers.-permute.pbtxt | 0 .../tensorflow.keras.layers.-r-n-n.pbtxt | 0 .../tensorflow.keras.layers.-re-l-u.pbtxt | 0 ...nsorflow.keras.layers.-repeat-vector.pbtxt | 0 .../tensorflow.keras.layers.-reshape.pbtxt | 0 ...flow.keras.layers.-separable-conv1-d.pbtxt | 0 ...flow.keras.layers.-separable-conv2-d.pbtxt | 0 ...ras.layers.-separable-convolution1-d.pbtxt | 0 ...ras.layers.-separable-convolution2-d.pbtxt | 0 ...flow.keras.layers.-simple-r-n-n-cell.pbtxt | 0 ...ensorflow.keras.layers.-simple-r-n-n.pbtxt | 0 .../tensorflow.keras.layers.-softmax.pbtxt | 0 ...low.keras.layers.-spatial-dropout1-d.pbtxt | 0 ...low.keras.layers.-spatial-dropout2-d.pbtxt | 0 ...low.keras.layers.-spatial-dropout3-d.pbtxt | 0 ...ow.keras.layers.-stacked-r-n-n-cells.pbtxt | 0 .../tensorflow.keras.layers.-subtract.pbtxt | 0 ...low.keras.layers.-thresholded-re-l-u.pbtxt | 0 ...rflow.keras.layers.-time-distributed.pbtxt | 0 ...sorflow.keras.layers.-up-sampling1-d.pbtxt | 0 ...sorflow.keras.layers.-up-sampling2-d.pbtxt | 0 ...sorflow.keras.layers.-up-sampling3-d.pbtxt | 0 .../tensorflow.keras.layers.-wrapper.pbtxt | 0 ...orflow.keras.layers.-zero-padding1-d.pbtxt | 0 ...orflow.keras.layers.-zero-padding2-d.pbtxt | 0 ...orflow.keras.layers.-zero-padding3-d.pbtxt | 0 .../{ => v1}/tensorflow.keras.layers.pbtxt | 0 .../{ => v1}/tensorflow.keras.losses.pbtxt | 0 .../{ => v1}/tensorflow.keras.metrics.pbtxt | 0 .../v1/tensorflow.keras.models.-model.pbtxt | 268 ++ .../tensorflow.keras.models.-sequential.pbtxt | 289 +++ .../{ => v1}/tensorflow.keras.models.pbtxt | 0 ...ensorflow.keras.optimizers.-adadelta.pbtxt | 0 ...tensorflow.keras.optimizers.-adagrad.pbtxt | 0 .../tensorflow.keras.optimizers.-adam.pbtxt | 0 .../tensorflow.keras.optimizers.-adamax.pbtxt | 0 .../tensorflow.keras.optimizers.-nadam.pbtxt | 0 ...nsorflow.keras.optimizers.-optimizer.pbtxt | 0 ...nsorflow.keras.optimizers.-r-m-sprop.pbtxt | 0 .../tensorflow.keras.optimizers.-s-g-d.pbtxt | 0 .../tensorflow.keras.optimizers.pbtxt | 0 .../golden/{ => v1}/tensorflow.keras.pbtxt | 0 ...processing.image.-directory-iterator.pbtxt | 0 ...ocessing.image.-image-data-generator.pbtxt | 0 ....keras.preprocessing.image.-iterator.pbtxt | 0 ...ocessing.image.-numpy-array-iterator.pbtxt | 0 ...tensorflow.keras.preprocessing.image.pbtxt | 0 .../tensorflow.keras.preprocessing.pbtxt | 0 ...ssing.sequence.-timeseries-generator.pbtxt | 0 ...sorflow.keras.preprocessing.sequence.pbtxt | 0 ....keras.preprocessing.text.-tokenizer.pbtxt | 0 .../tensorflow.keras.preprocessing.text.pbtxt | 0 ...tensorflow.keras.regularizers.-l1-l2.pbtxt | 0 ...flow.keras.regularizers.-regularizer.pbtxt | 0 .../tensorflow.keras.regularizers.pbtxt | 0 ...low.keras.utils.-custom-object-scope.pbtxt | 0 ...flow.keras.utils.-generator-enqueuer.pbtxt | 0 ...ensorflow.keras.utils.-h-d-f5-matrix.pbtxt | 0 .../tensorflow.keras.utils.-progbar.pbtxt | 0 ...rflow.keras.utils.-sequence-enqueuer.pbtxt | 0 .../tensorflow.keras.utils.-sequence.pbtxt | 0 .../{ => v1}/tensorflow.keras.utils.pbtxt | 0 .../{ => v1}/tensorflow.keras.wrappers.pbtxt | 0 ...ppers.scikit_learn.-keras-classifier.pbtxt | 0 ...appers.scikit_learn.-keras-regressor.pbtxt | 0 ...nsorflow.keras.wrappers.scikit_learn.pbtxt | 0 ...ensorflow.layers.-average-pooling1-d.pbtxt | 0 ...ensorflow.layers.-average-pooling2-d.pbtxt | 0 ...ensorflow.layers.-average-pooling3-d.pbtxt | 0 ...nsorflow.layers.-batch-normalization.pbtxt | 0 .../{ => v1}/tensorflow.layers.-conv1-d.pbtxt | 0 ...tensorflow.layers.-conv2-d-transpose.pbtxt | 0 .../{ => v1}/tensorflow.layers.-conv2-d.pbtxt | 0 ...tensorflow.layers.-conv3-d-transpose.pbtxt | 0 .../{ => v1}/tensorflow.layers.-conv3-d.pbtxt | 0 .../{ => v1}/tensorflow.layers.-dense.pbtxt | 0 .../{ => v1}/tensorflow.layers.-dropout.pbtxt | 0 .../{ => v1}/tensorflow.layers.-flatten.pbtxt | 0 .../tensorflow.layers.-input-spec.pbtxt | 0 .../{ => v1}/tensorflow.layers.-layer.pbtxt | 0 .../tensorflow.layers.-max-pooling1-d.pbtxt | 0 .../tensorflow.layers.-max-pooling2-d.pbtxt | 0 .../tensorflow.layers.-max-pooling3-d.pbtxt | 0 ...tensorflow.layers.-separable-conv1-d.pbtxt | 0 ...tensorflow.layers.-separable-conv2-d.pbtxt | 0 .../golden/{ => v1}/tensorflow.layers.pbtxt | 0 ...ar-operator-block-diag.__metaclass__.pbtxt | 0 ...w.linalg.-linear-operator-block-diag.pbtxt | 0 ...ear-operator-circulant.__metaclass__.pbtxt | 0 ...ow.linalg.-linear-operator-circulant.pbtxt | 0 ...-operator-circulant2-d.__metaclass__.pbtxt | 0 ...linalg.-linear-operator-circulant2-d.pbtxt | 0 ...-operator-circulant3-d.__metaclass__.pbtxt | 0 ...linalg.-linear-operator-circulant3-d.pbtxt | 0 ...r-operator-composition.__metaclass__.pbtxt | 0 ....linalg.-linear-operator-composition.pbtxt | 0 ....-linear-operator-diag.__metaclass__.pbtxt | 0 ...sorflow.linalg.-linear-operator-diag.pbtxt | 0 ...r-operator-full-matrix.__metaclass__.pbtxt | 0 ....linalg.-linear-operator-full-matrix.pbtxt | 0 ...near-operator-identity.__metaclass__.pbtxt | 0 ...low.linalg.-linear-operator-identity.pbtxt | 0 ...ear-operator-kronecker.__metaclass__.pbtxt | 0 ...ow.linalg.-linear-operator-kronecker.pbtxt | 0 ...erator-low-rank-update.__metaclass__.pbtxt | 0 ...alg.-linear-operator-low-rank-update.pbtxt | 0 ...rator-lower-triangular.__metaclass__.pbtxt | 0 ...lg.-linear-operator-lower-triangular.pbtxt | 0 ...erator-scaled-identity.__metaclass__.pbtxt | 0 ...alg.-linear-operator-scaled-identity.pbtxt | 0 ...-linear-operator-zeros.__metaclass__.pbtxt | 0 ...orflow.linalg.-linear-operator-zeros.pbtxt | 0 ...inalg.-linear-operator.__metaclass__.pbtxt | 0 .../tensorflow.linalg.-linear-operator.pbtxt | 0 .../golden/{ => v1}/tensorflow.linalg.pbtxt | 0 .../golden/{ => v1}/tensorflow.logging.pbtxt | 0 .../tensorflow.losses.-reduction.pbtxt | 0 .../golden/{ => v1}/tensorflow.losses.pbtxt | 0 .../golden/{ => v1}/tensorflow.manip.pbtxt | 0 .../api/golden/{ => v1}/tensorflow.math.pbtxt | 0 .../golden/{ => v1}/tensorflow.metrics.pbtxt | 0 .../{ => v1}/tensorflow.name_scope.pbtxt | 0 .../api/golden/{ => v1}/tensorflow.nn.pbtxt | 0 ...flow.nn.rnn_cell.-basic-l-s-t-m-cell.pbtxt | 0 ...orflow.nn.rnn_cell.-basic-r-n-n-cell.pbtxt | 0 ...nsorflow.nn.rnn_cell.-device-wrapper.pbtxt | 0 ...sorflow.nn.rnn_cell.-dropout-wrapper.pbtxt | 0 .../tensorflow.nn.rnn_cell.-g-r-u-cell.pbtxt | 0 ...tensorflow.nn.rnn_cell.-l-s-t-m-cell.pbtxt | 0 ...low.nn.rnn_cell.-l-s-t-m-state-tuple.pbtxt | 0 ...orflow.nn.rnn_cell.-multi-r-n-n-cell.pbtxt | 0 .../tensorflow.nn.rnn_cell.-r-n-n-cell.pbtxt | 0 ...orflow.nn.rnn_cell.-residual-wrapper.pbtxt | 0 .../{ => v1}/tensorflow.nn.rnn_cell.pbtxt | 0 .../tensorflow.ones_initializer.pbtxt | 0 .../tensorflow.orthogonal_initializer.pbtxt | 0 .../api/golden/{ => v1}/tensorflow.pbtxt | 0 ...flow.profiler.-advice-proto.-checker.pbtxt | 0 ...ofiler.-advice-proto.-checkers-entry.pbtxt | 0 .../tensorflow.profiler.-advice-proto.pbtxt | 0 ...graph-node-proto.-input-shapes-entry.pbtxt | 0 ...ensorflow.profiler.-graph-node-proto.pbtxt | 0 ...low.profiler.-multi-graph-node-proto.pbtxt | 0 ...er.-op-log-proto.-id-to-string-entry.pbtxt | 0 .../tensorflow.profiler.-op-log-proto.pbtxt | 0 ...low.profiler.-profile-option-builder.pbtxt | 0 .../tensorflow.profiler.-profiler.pbtxt | 0 .../golden/{ => v1}/tensorflow.profiler.pbtxt | 0 ...thon_io.-t-f-record-compression-type.pbtxt | 0 ...orflow.python_io.-t-f-record-options.pbtxt | 0 ...sorflow.python_io.-t-f-record-writer.pbtxt | 0 .../{ => v1}/tensorflow.python_io.pbtxt | 0 .../{ => v1}/tensorflow.quantization.pbtxt | 0 ...tensorflow.random_normal_initializer.pbtxt | 0 ...ensorflow.random_uniform_initializer.pbtxt | 0 .../{ => v1}/tensorflow.resource_loader.pbtxt | 0 ...d_model.builder.-saved-model-builder.pbtxt | 0 .../tensorflow.saved_model.builder.pbtxt | 0 .../tensorflow.saved_model.constants.pbtxt | 0 .../tensorflow.saved_model.loader.pbtxt | 0 .../tensorflow.saved_model.main_op.pbtxt | 0 .../{ => v1}/tensorflow.saved_model.pbtxt | 0 ...flow.saved_model.signature_constants.pbtxt | 0 ...flow.saved_model.signature_def_utils.pbtxt | 0 ...tensorflow.saved_model.tag_constants.pbtxt | 0 .../tensorflow.saved_model.utils.pbtxt | 0 .../api/golden/{ => v1}/tensorflow.sets.pbtxt | 0 .../golden/{ => v1}/tensorflow.sparse.pbtxt | 0 .../golden/{ => v1}/tensorflow.spectral.pbtxt | 0 .../golden/{ => v1}/tensorflow.strings.pbtxt | 0 .../{ => v1}/tensorflow.summary.-event.pbtxt | 0 ...ensorflow.summary.-file-writer-cache.pbtxt | 0 .../tensorflow.summary.-file-writer.pbtxt | 0 .../tensorflow.summary.-session-log.pbtxt | 0 ...sorflow.summary.-summary-description.pbtxt | 0 .../tensorflow.summary.-summary.-audio.pbtxt | 0 .../tensorflow.summary.-summary.-image.pbtxt | 0 .../tensorflow.summary.-summary.-value.pbtxt | 0 .../tensorflow.summary.-summary.pbtxt | 0 ...sorflow.summary.-tagged-run-metadata.pbtxt | 0 .../golden/{ => v1}/tensorflow.summary.pbtxt | 0 .../{ => v1}/tensorflow.sysconfig.pbtxt | 0 .../{ => v1}/tensorflow.test.-benchmark.pbtxt | 0 ...ensorflow.test.-stub-out-for-testing.pbtxt | 0 .../api/golden/{ => v1}/tensorflow.test.pbtxt | 0 ...tensorflow.train.-adadelta-optimizer.pbtxt | 0 ...sorflow.train.-adagrad-d-a-optimizer.pbtxt | 0 .../tensorflow.train.-adagrad-optimizer.pbtxt | 0 .../tensorflow.train.-adam-optimizer.pbtxt | 0 .../tensorflow.train.-bytes-list.pbtxt | 0 ...sorflow.train.-checkpoint-saver-hook.pbtxt | 0 ...low.train.-checkpoint-saver-listener.pbtxt | 0 .../tensorflow.train.-checkpoint.pbtxt | 0 ...sorflow.train.-chief-session-creator.pbtxt | 0 .../tensorflow.train.-cluster-def.pbtxt | 0 .../tensorflow.train.-cluster-spec.pbtxt | 0 .../tensorflow.train.-coordinator.pbtxt | 0 .../{ => v1}/tensorflow.train.-example.pbtxt | 0 ...ow.train.-exponential-moving-average.pbtxt | 0 .../tensorflow.train.-feature-list.pbtxt | 0 ...n.-feature-lists.-feature-list-entry.pbtxt | 0 .../tensorflow.train.-feature-lists.pbtxt | 0 .../{ => v1}/tensorflow.train.-feature.pbtxt | 0 ...rflow.train.-features.-feature-entry.pbtxt | 0 .../{ => v1}/tensorflow.train.-features.pbtxt | 0 .../tensorflow.train.-feed-fn-hook.pbtxt | 0 .../tensorflow.train.-final-ops-hook.pbtxt | 0 .../tensorflow.train.-float-list.pbtxt | 0 .../tensorflow.train.-ftrl-optimizer.pbtxt | 0 ...rflow.train.-global-step-waiter-hook.pbtxt | 0 ...ow.train.-gradient-descent-optimizer.pbtxt | 0 .../tensorflow.train.-int64-list.pbtxt | 0 ...nsorflow.train.-job-def.-tasks-entry.pbtxt | 0 .../{ => v1}/tensorflow.train.-job-def.pbtxt | 0 ...ensorflow.train.-logging-tensor-hook.pbtxt | 0 .../tensorflow.train.-looper-thread.pbtxt | 0 ...tensorflow.train.-momentum-optimizer.pbtxt | 0 ...ain.-monitored-session.-step-context.pbtxt | 0 .../tensorflow.train.-monitored-session.pbtxt | 0 ...rain.-nan-loss-during-training-error.pbtxt | 0 .../tensorflow.train.-nan-tensor-hook.pbtxt | 0 .../tensorflow.train.-optimizer.pbtxt | 0 .../tensorflow.train.-profiler-hook.pbtxt | 0 ...ow.train.-proximal-adagrad-optimizer.pbtxt | 0 ...-proximal-gradient-descent-optimizer.pbtxt | 0 .../tensorflow.train.-queue-runner.pbtxt | 0 ...nsorflow.train.-r-m-s-prop-optimizer.pbtxt | 0 .../tensorflow.train.-saver-def.pbtxt | 0 .../{ => v1}/tensorflow.train.-saver.pbtxt | 0 .../{ => v1}/tensorflow.train.-scaffold.pbtxt | 0 ...nsorflow.train.-second-or-step-timer.pbtxt | 0 .../tensorflow.train.-sequence-example.pbtxt | 0 .../tensorflow.train.-server-def.pbtxt | 0 .../{ => v1}/tensorflow.train.-server.pbtxt | 0 .../tensorflow.train.-session-creator.pbtxt | 0 .../tensorflow.train.-session-manager.pbtxt | 0 .../tensorflow.train.-session-run-args.pbtxt | 0 ...ensorflow.train.-session-run-context.pbtxt | 0 .../tensorflow.train.-session-run-hook.pbtxt | 0 ...tensorflow.train.-session-run-values.pbtxt | 0 ...ular-monitored-session.-step-context.pbtxt | 0 ...ow.train.-singular-monitored-session.pbtxt | 0 .../tensorflow.train.-step-counter-hook.pbtxt | 0 .../tensorflow.train.-stop-at-step-hook.pbtxt | 0 ...tensorflow.train.-summary-saver-hook.pbtxt | 0 .../tensorflow.train.-supervisor.pbtxt | 0 ...rflow.train.-sync-replicas-optimizer.pbtxt | 0 .../tensorflow.train.-vocab-info.pbtxt | 0 ...orflow.train.-worker-session-creator.pbtxt | 0 .../golden/{ => v1}/tensorflow.train.pbtxt | 0 ...low.train.queue_runner.-queue-runner.pbtxt | 0 .../tensorflow.train.queue_runner.pbtxt | 0 ...sorflow.truncated_normal_initializer.pbtxt | 0 ...low.uniform_unit_scaling_initializer.pbtxt | 0 .../{ => v1}/tensorflow.variable_scope.pbtxt | 0 ...sorflow.variance_scaling_initializer.pbtxt | 0 .../tensorflow.zeros_initializer.pbtxt | 0 .../v2/tensorflow.-aggregation-method.pbtxt | 24 + .../tensorflow.-attr-value.-list-value.pbtxt | 70 + .../golden/v2/tensorflow.-attr-value.pbtxt | 151 ++ ...orflow.-conditional-accumulator-base.pbtxt | 29 + .../tensorflow.-conditional-accumulator.pbtxt | 38 + ...ow.-config-proto.-device-count-entry.pbtxt | 21 + ...nsorflow.-config-proto.-experimental.pbtxt | 18 + .../golden/v2/tensorflow.-config-proto.pbtxt | 142 ++ .../api/golden/v2/tensorflow.-d-type.pbtxt | 77 + .../golden/v2/tensorflow.-device-spec.pbtxt | 37 + .../api/golden/v2/tensorflow.-dimension.pbtxt | 25 + .../api/golden/v2/tensorflow.-event.pbtxt | 74 + .../golden/v2/tensorflow.-f-i-f-o-queue.pbtxt | 66 + .../v2/tensorflow.-fixed-len-feature.pbtxt | 27 + ...nsorflow.-fixed-len-sequence-feature.pbtxt | 31 + ...nsorflow.-fixed-length-record-reader.pbtxt | 46 + .../golden/v2/tensorflow.-g-p-u-options.pbtxt | 92 + .../golden/v2/tensorflow.-gradient-tape.pbtxt | 29 + .../api/golden/v2/tensorflow.-graph-def.pbtxt | 36 + .../golden/v2/tensorflow.-graph-keys.pbtxt | 140 ++ .../golden/v2/tensorflow.-graph-options.pbtxt | 67 + .../api/golden/v2/tensorflow.-graph.pbtxt | 141 ++ .../v2/tensorflow.-histogram-proto.pbtxt | 54 + .../v2/tensorflow.-identity-reader.pbtxt | 46 + .../v2/tensorflow.-indexed-slices.pbtxt | 42 + .../v2/tensorflow.-interactive-session.pbtxt | 51 + .../v2/tensorflow.-l-m-d-b-reader.pbtxt | 46 + .../golden/v2/tensorflow.-log-message.pbtxt | 46 + ...meta-graph-def.-collection-def-entry.pbtxt | 22 + ...rflow.-meta-graph-def.-meta-info-def.pbtxt | 50 + ...-meta-graph-def.-signature-def-entry.pbtxt | 22 + .../v2/tensorflow.-meta-graph-def.pbtxt | 133 + ...nsorflow.-name-attr-list.-attr-entry.pbtxt | 22 + .../v2/tensorflow.-name-attr-list.pbtxt | 38 + .../v2/tensorflow.-node-def.-attr-entry.pbtxt | 22 + .../api/golden/v2/tensorflow.-node-def.pbtxt | 56 + .../api/golden/v2/tensorflow.-op-error.pbtxt | 29 + .../api/golden/v2/tensorflow.-operation.pbtxt | 69 + .../v2/tensorflow.-optimizer-options.pbtxt | 74 + .../tensorflow.-padding-f-i-f-o-queue.pbtxt | 66 + .../v2/tensorflow.-priority-queue.pbtxt | 66 + .../golden/v2/tensorflow.-queue-base.pbtxt | 65 + .../v2/tensorflow.-random-shuffle-queue.pbtxt | 66 + .../golden/v2/tensorflow.-reader-base.pbtxt | 45 + .../v2/tensorflow.-register-gradient.pbtxt | 9 + .../golden/v2/tensorflow.-run-metadata.pbtxt | 27 + ...ensorflow.-run-options.-experimental.pbtxt | 12 + .../golden/v2/tensorflow.-run-options.pbtxt | 83 + .../golden/v2/tensorflow.-session-log.pbtxt | 44 + .../api/golden/v2/tensorflow.-session.pbtxt | 55 + ...flow.-sparse-conditional-accumulator.pbtxt | 46 + .../v2/tensorflow.-sparse-feature.pbtxt | 35 + .../v2/tensorflow.-sparse-tensor-value.pbtxt | 26 + .../golden/v2/tensorflow.-sparse-tensor.pbtxt | 46 + ...rflow.-summary-metadata.-plugin-data.pbtxt | 18 + .../v2/tensorflow.-summary-metadata.pbtxt | 40 + .../v2/tensorflow.-summary.-audio.pbtxt | 36 + .../v2/tensorflow.-summary.-image.pbtxt | 30 + .../v2/tensorflow.-summary.-value.pbtxt | 74 + .../api/golden/v2/tensorflow.-summary.pbtxt | 144 ++ .../v2/tensorflow.-t-f-record-reader.pbtxt | 46 + .../golden/v2/tensorflow.-tensor-array.pbtxt | 69 + .../tensorflow.-tensor-info.-coo-sparse.pbtxt | 24 + .../golden/v2/tensorflow.-tensor-info.pbtxt | 59 + .../golden/v2/tensorflow.-tensor-shape.pbtxt | 77 + .../api/golden/v2/tensorflow.-tensor.pbtxt | 58 + .../v2/tensorflow.-text-line-reader.pbtxt | 46 + .../v2/tensorflow.-var-len-feature.pbtxt | 19 + .../v2/tensorflow.-variable-aggregation.pbtxt | 16 + .../v2/tensorflow.-variable-scope.pbtxt | 105 + ...tensorflow.-variable-synchronization.pbtxt | 20 + ...ensorflow.-variable.-save-slice-info.pbtxt | 17 + .../api/golden/v2/tensorflow.-variable.pbtxt | 110 + .../v2/tensorflow.-whole-file-reader.pbtxt | 46 + .../tools/api/golden/v2/tensorflow.app.pbtxt | 11 + .../api/golden/v2/tensorflow.bitwise.pbtxt | 27 + .../api/golden/v2/tensorflow.compat.pbtxt | 47 + .../v2/tensorflow.constant_initializer.pbtxt | 18 + ...nsorflow.data.-dataset.__metaclass__.pbtxt | 14 + .../golden/v2/tensorflow.data.-dataset.pbtxt | 117 + ...-length-record-dataset.__metaclass__.pbtxt | 14 + ...ow.data.-fixed-length-record-dataset.pbtxt | 118 + .../golden/v2/tensorflow.data.-iterator.pbtxt | 45 + ...ta.-t-f-record-dataset.__metaclass__.pbtxt | 14 + .../tensorflow.data.-t-f-record-dataset.pbtxt | 118 + ...ata.-text-line-dataset.__metaclass__.pbtxt | 14 + .../tensorflow.data.-text-line-dataset.pbtxt | 118 + .../tools/api/golden/v2/tensorflow.data.pbtxt | 23 + .../api/golden/v2/tensorflow.debugging.pbtxt | 19 + .../tensorflow.distributions.-bernoulli.pbtxt | 143 ++ .../v2/tensorflow.distributions.-beta.pbtxt | 147 ++ ...ensorflow.distributions.-categorical.pbtxt | 147 ++ ...distributions.-dirichlet-multinomial.pbtxt | 147 ++ .../tensorflow.distributions.-dirichlet.pbtxt | 143 ++ ...nsorflow.distributions.-distribution.pbtxt | 134 + ...ensorflow.distributions.-exponential.pbtxt | 144 ++ .../v2/tensorflow.distributions.-gamma.pbtxt | 143 ++ .../tensorflow.distributions.-laplace.pbtxt | 143 ++ ...ensorflow.distributions.-multinomial.pbtxt | 147 ++ .../v2/tensorflow.distributions.-normal.pbtxt | 143 ++ ...nsorflow.distributions.-register-k-l.pbtxt | 9 + ...stributions.-reparameterization-type.pbtxt | 9 + .../tensorflow.distributions.-student-t.pbtxt | 147 ++ .../tensorflow.distributions.-uniform.pbtxt | 147 ++ .../golden/v2/tensorflow.distributions.pbtxt | 75 + .../api/golden/v2/tensorflow.dtypes.pbtxt | 7 + .../v2/tensorflow.errors.-aborted-error.pbtxt | 30 + ...sorflow.errors.-already-exists-error.pbtxt | 30 + .../tensorflow.errors.-cancelled-error.pbtxt | 30 + .../tensorflow.errors.-data-loss-error.pbtxt | 30 + ...flow.errors.-deadline-exceeded-error.pbtxt | 30 + ...ow.errors.-failed-precondition-error.pbtxt | 30 + .../tensorflow.errors.-internal-error.pbtxt | 30 + ...rflow.errors.-invalid-argument-error.pbtxt | 30 + .../tensorflow.errors.-not-found-error.pbtxt | 30 + .../v2/tensorflow.errors.-op-error.pbtxt | 29 + ...ensorflow.errors.-out-of-range-error.pbtxt | 30 + ...flow.errors.-permission-denied-error.pbtxt | 30 + ...low.errors.-resource-exhausted-error.pbtxt | 30 + ...orflow.errors.-unauthenticated-error.pbtxt | 30 + ...tensorflow.errors.-unavailable-error.pbtxt | 30 + ...nsorflow.errors.-unimplemented-error.pbtxt | 30 + .../v2/tensorflow.errors.-unknown-error.pbtxt | 30 + .../api/golden/v2/tensorflow.errors.pbtxt | 151 ++ ...ors.raise_exception_on_not_ok_status.pbtxt | 8 + ...rflow.estimator.-baseline-classifier.pbtxt | 58 + ...orflow.estimator.-baseline-regressor.pbtxt | 58 + .../tensorflow.estimator.-best-exporter.pbtxt | 18 + ....estimator.-boosted-trees-classifier.pbtxt | 58 + ...w.estimator.-boosted-trees-regressor.pbtxt | 58 + ...nsorflow.estimator.-d-n-n-classifier.pbtxt | 58 + ...or.-d-n-n-linear-combined-classifier.pbtxt | 58 + ...tor.-d-n-n-linear-combined-regressor.pbtxt | 58 + ...ensorflow.estimator.-d-n-n-regressor.pbtxt | 58 + ...tensorflow.estimator.-estimator-spec.pbtxt | 59 + .../v2/tensorflow.estimator.-estimator.pbtxt | 57 + .../v2/tensorflow.estimator.-eval-spec.pbtxt | 43 + .../v2/tensorflow.estimator.-exporter.pbtxt | 16 + ...tensorflow.estimator.-final-exporter.pbtxt | 18 + ...ensorflow.estimator.-latest-exporter.pbtxt | 18 + ...sorflow.estimator.-linear-classifier.pbtxt | 58 + ...nsorflow.estimator.-linear-regressor.pbtxt | 58 + .../v2/tensorflow.estimator.-mode-keys.pbtxt | 20 + .../v2/tensorflow.estimator.-run-config.pbtxt | 101 + .../v2/tensorflow.estimator.-train-spec.pbtxt | 27 + .../v2/tensorflow.estimator.-vocab-info.pbtxt | 39 + ...rflow.estimator.-warm-start-settings.pbtxt | 31 + ...-classification-output.__metaclass__.pbtxt | 14 + ...imator.export.-classification-output.pbtxt | 22 + ....export.-export-output.__metaclass__.pbtxt | 14 + ...flow.estimator.export.-export-output.pbtxt | 12 + ...export.-predict-output.__metaclass__.pbtxt | 14 + ...low.estimator.export.-predict-output.pbtxt | 18 + ...ort.-regression-output.__metaclass__.pbtxt | 14 + ....estimator.export.-regression-output.pbtxt | 18 + ...mator.export.-serving-input-receiver.pbtxt | 27 + ...xport.-tensor-serving-input-receiver.pbtxt | 27 + .../v2/tensorflow.estimator.export.pbtxt | 35 + .../v2/tensorflow.estimator.inputs.pbtxt | 11 + .../api/golden/v2/tensorflow.estimator.pbtxt | 111 + .../golden/v2/tensorflow.feature_column.pbtxt | 59 + .../v2/tensorflow.gfile.-fast-g-file.pbtxt | 58 + .../golden/v2/tensorflow.gfile.-g-file.pbtxt | 58 + .../golden/v2/tensorflow.gfile.-open.pbtxt | 58 + .../api/golden/v2/tensorflow.gfile.pbtxt | 63 + .../api/golden/v2/tensorflow.graph_util.pbtxt | 23 + .../v2/tensorflow.image.-resize-method.pbtxt | 24 + .../api/golden/v2/tensorflow.image.pbtxt | 247 ++ .../v2/tensorflow.initializers.constant.pbtxt | 18 + .../v2/tensorflow.initializers.identity.pbtxt | 18 + .../v2/tensorflow.initializers.ones.pbtxt | 18 + .../tensorflow.initializers.orthogonal.pbtxt | 18 + .../golden/v2/tensorflow.initializers.pbtxt | 79 + ...ensorflow.initializers.random_normal.pbtxt | 18 + ...nsorflow.initializers.random_uniform.pbtxt | 18 + ...orflow.initializers.truncated_normal.pbtxt | 18 + ...ow.initializers.uniform_unit_scaling.pbtxt | 18 + ...orflow.initializers.variance_scaling.pbtxt | 18 + .../v2/tensorflow.initializers.zeros.pbtxt | 18 + .../tools/api/golden/v2/tensorflow.io.pbtxt | 39 + .../golden/v2/tensorflow.keras.-model.pbtxt | 268 ++ .../v2/tensorflow.keras.-sequential.pbtxt | 289 +++ .../v2/tensorflow.keras.activations.pbtxt | 55 + ...nsorflow.keras.applications.densenet.pbtxt | 23 + ...ras.applications.inception_resnet_v2.pbtxt | 15 + ...flow.keras.applications.inception_v3.pbtxt | 15 + ...sorflow.keras.applications.mobilenet.pbtxt | 15 + ...tensorflow.keras.applications.nasnet.pbtxt | 19 + .../v2/tensorflow.keras.applications.pbtxt | 87 + ...nsorflow.keras.applications.resnet50.pbtxt | 15 + .../tensorflow.keras.applications.vgg16.pbtxt | 15 + .../tensorflow.keras.applications.vgg19.pbtxt | 15 + ...nsorflow.keras.applications.xception.pbtxt | 15 + .../tensorflow.keras.backend.name_scope.pbtxt | 13 + .../golden/v2/tensorflow.keras.backend.pbtxt | 555 +++++ ...sorflow.keras.callbacks.-base-logger.pbtxt | 42 + ...orflow.keras.callbacks.-c-s-v-logger.pbtxt | 42 + ...tensorflow.keras.callbacks.-callback.pbtxt | 41 + ...flow.keras.callbacks.-early-stopping.pbtxt | 42 + .../tensorflow.keras.callbacks.-history.pbtxt | 42 + ...low.keras.callbacks.-lambda-callback.pbtxt | 42 + ...s.callbacks.-learning-rate-scheduler.pbtxt | 42 + ...ow.keras.callbacks.-model-checkpoint.pbtxt | 42 + ...flow.keras.callbacks.-progbar-logger.pbtxt | 42 + ...ras.callbacks.-reduce-l-r-on-plateau.pbtxt | 46 + ...flow.keras.callbacks.-remote-monitor.pbtxt | 42 + ...orflow.keras.callbacks.-tensor-board.pbtxt | 42 + ...w.keras.callbacks.-terminate-on-na-n.pbtxt | 42 + .../v2/tensorflow.keras.callbacks.pbtxt | 55 + ...orflow.keras.constraints.-constraint.pbtxt | 12 + ...nsorflow.keras.constraints.-max-norm.pbtxt | 14 + ...flow.keras.constraints.-min-max-norm.pbtxt | 14 + ...ensorflow.keras.constraints.-non-neg.pbtxt | 13 + ...sorflow.keras.constraints.-unit-norm.pbtxt | 14 + ...ensorflow.keras.constraints.max_norm.pbtxt | 14 + ...rflow.keras.constraints.min_max_norm.pbtxt | 14 + ...tensorflow.keras.constraints.non_neg.pbtxt | 13 + .../v2/tensorflow.keras.constraints.pbtxt | 51 + ...nsorflow.keras.constraints.unit_norm.pbtxt | 14 + ...orflow.keras.datasets.boston_housing.pbtxt | 7 + .../tensorflow.keras.datasets.cifar10.pbtxt | 7 + .../tensorflow.keras.datasets.cifar100.pbtxt | 7 + ...sorflow.keras.datasets.fashion_mnist.pbtxt | 7 + .../v2/tensorflow.keras.datasets.imdb.pbtxt | 11 + .../v2/tensorflow.keras.datasets.mnist.pbtxt | 7 + .../golden/v2/tensorflow.keras.datasets.pbtxt | 31 + .../tensorflow.keras.datasets.reuters.pbtxt | 11 + .../v2/tensorflow.keras.estimator.pbtxt | 7 + ...sorflow.keras.initializers.-constant.pbtxt | 18 + ...sorflow.keras.initializers.-identity.pbtxt | 18 + ...flow.keras.initializers.-initializer.pbtxt | 16 + .../tensorflow.keras.initializers.-ones.pbtxt | 18 + ...rflow.keras.initializers.-orthogonal.pbtxt | 18 + ...ow.keras.initializers.-random-normal.pbtxt | 18 + ...w.keras.initializers.-random-uniform.pbtxt | 18 + ...keras.initializers.-truncated-normal.pbtxt | 18 + ...keras.initializers.-variance-scaling.pbtxt | 18 + ...tensorflow.keras.initializers.-zeros.pbtxt | 18 + ...nsorflow.keras.initializers.constant.pbtxt | 18 + ...nsorflow.keras.initializers.identity.pbtxt | 18 + ...tensorflow.keras.initializers.normal.pbtxt | 18 + .../tensorflow.keras.initializers.ones.pbtxt | 18 + ...orflow.keras.initializers.orthogonal.pbtxt | 18 + .../v2/tensorflow.keras.initializers.pbtxt | 119 + ...low.keras.initializers.random_normal.pbtxt | 18 + ...ow.keras.initializers.random_uniform.pbtxt | 18 + ....keras.initializers.truncated_normal.pbtxt | 18 + ...ensorflow.keras.initializers.uniform.pbtxt | 18 + .../tensorflow.keras.initializers.zeros.pbtxt | 18 + .../tensorflow.keras.layers.-activation.pbtxt | 175 ++ ...eras.layers.-activity-regularization.pbtxt | 175 ++ .../v2/tensorflow.keras.layers.-add.pbtxt | 176 ++ ...nsorflow.keras.layers.-alpha-dropout.pbtxt | 175 ++ ...low.keras.layers.-average-pooling1-d.pbtxt | 176 ++ ...low.keras.layers.-average-pooling2-d.pbtxt | 176 ++ ...low.keras.layers.-average-pooling3-d.pbtxt | 176 ++ .../v2/tensorflow.keras.layers.-average.pbtxt | 176 ++ ...tensorflow.keras.layers.-avg-pool1-d.pbtxt | 176 ++ ...tensorflow.keras.layers.-avg-pool2-d.pbtxt | 176 ++ ...tensorflow.keras.layers.-avg-pool3-d.pbtxt | 176 ++ ...ow.keras.layers.-batch-normalization.pbtxt | 175 ++ ...nsorflow.keras.layers.-bidirectional.pbtxt | 188 ++ ...tensorflow.keras.layers.-concatenate.pbtxt | 176 ++ ...orflow.keras.layers.-conv-l-s-t-m2-d.pbtxt | 273 ++ .../v2/tensorflow.keras.layers.-conv1-d.pbtxt | 176 ++ ...flow.keras.layers.-conv2-d-transpose.pbtxt | 177 ++ .../v2/tensorflow.keras.layers.-conv2-d.pbtxt | 176 ++ ...flow.keras.layers.-conv3-d-transpose.pbtxt | 177 ++ .../v2/tensorflow.keras.layers.-conv3-d.pbtxt | 176 ++ ...sorflow.keras.layers.-convolution1-d.pbtxt | 176 ++ ...ras.layers.-convolution2-d-transpose.pbtxt | 177 ++ ...sorflow.keras.layers.-convolution2-d.pbtxt | 176 ++ ...ras.layers.-convolution3-d-transpose.pbtxt | 177 ++ ...sorflow.keras.layers.-convolution3-d.pbtxt | 176 ++ ...tensorflow.keras.layers.-cropping1-d.pbtxt | 175 ++ ...tensorflow.keras.layers.-cropping2-d.pbtxt | 175 ++ ...tensorflow.keras.layers.-cropping3-d.pbtxt | 175 ++ ...sorflow.keras.layers.-cu-d-n-n-g-r-u.pbtxt | 193 ++ ...rflow.keras.layers.-cu-d-n-n-l-s-t-m.pbtxt | 193 ++ .../v2/tensorflow.keras.layers.-dense.pbtxt | 175 ++ ...flow.keras.layers.-depthwise-conv2-d.pbtxt | 177 ++ .../v2/tensorflow.keras.layers.-dot.pbtxt | 176 ++ .../v2/tensorflow.keras.layers.-dropout.pbtxt | 175 ++ .../v2/tensorflow.keras.layers.-e-l-u.pbtxt | 175 ++ .../tensorflow.keras.layers.-embedding.pbtxt | 175 ++ .../v2/tensorflow.keras.layers.-flatten.pbtxt | 175 ++ .../tensorflow.keras.layers.-g-r-u-cell.pbtxt | 175 ++ .../v2/tensorflow.keras.layers.-g-r-u.pbtxt | 256 ++ ...rflow.keras.layers.-gaussian-dropout.pbtxt | 175 ++ ...sorflow.keras.layers.-gaussian-noise.pbtxt | 175 ++ ...as.layers.-global-average-pooling1-d.pbtxt | 176 ++ ...as.layers.-global-average-pooling2-d.pbtxt | 176 ++ ...as.layers.-global-average-pooling3-d.pbtxt | 176 ++ ...low.keras.layers.-global-avg-pool1-d.pbtxt | 176 ++ ...low.keras.layers.-global-avg-pool2-d.pbtxt | 176 ++ ...low.keras.layers.-global-avg-pool3-d.pbtxt | 176 ++ ...low.keras.layers.-global-max-pool1-d.pbtxt | 176 ++ ...low.keras.layers.-global-max-pool2-d.pbtxt | 176 ++ ...low.keras.layers.-global-max-pool3-d.pbtxt | 176 ++ ....keras.layers.-global-max-pooling1-d.pbtxt | 176 ++ ....keras.layers.-global-max-pooling2-d.pbtxt | 176 ++ ....keras.layers.-global-max-pooling3-d.pbtxt | 176 ++ ...tensorflow.keras.layers.-input-layer.pbtxt | 175 ++ .../tensorflow.keras.layers.-input-spec.pbtxt | 9 + ...ensorflow.keras.layers.-l-s-t-m-cell.pbtxt | 175 ++ .../v2/tensorflow.keras.layers.-l-s-t-m.pbtxt | 256 ++ .../v2/tensorflow.keras.layers.-lambda.pbtxt | 175 ++ .../v2/tensorflow.keras.layers.-layer.pbtxt | 174 ++ ...ensorflow.keras.layers.-leaky-re-l-u.pbtxt | 175 ++ ...w.keras.layers.-locally-connected1-d.pbtxt | 175 ++ ...w.keras.layers.-locally-connected2-d.pbtxt | 175 ++ .../v2/tensorflow.keras.layers.-masking.pbtxt | 175 ++ ...tensorflow.keras.layers.-max-pool1-d.pbtxt | 176 ++ ...tensorflow.keras.layers.-max-pool2-d.pbtxt | 176 ++ ...tensorflow.keras.layers.-max-pool3-d.pbtxt | 176 ++ ...sorflow.keras.layers.-max-pooling1-d.pbtxt | 176 ++ ...sorflow.keras.layers.-max-pooling2-d.pbtxt | 176 ++ ...sorflow.keras.layers.-max-pooling3-d.pbtxt | 176 ++ .../v2/tensorflow.keras.layers.-maximum.pbtxt | 176 ++ .../v2/tensorflow.keras.layers.-minimum.pbtxt | 176 ++ .../tensorflow.keras.layers.-multiply.pbtxt | 176 ++ .../tensorflow.keras.layers.-p-re-l-u.pbtxt | 175 ++ .../v2/tensorflow.keras.layers.-permute.pbtxt | 175 ++ .../v2/tensorflow.keras.layers.-r-n-n.pbtxt | 187 ++ .../v2/tensorflow.keras.layers.-re-l-u.pbtxt | 175 ++ ...nsorflow.keras.layers.-repeat-vector.pbtxt | 175 ++ .../v2/tensorflow.keras.layers.-reshape.pbtxt | 175 ++ ...flow.keras.layers.-separable-conv1-d.pbtxt | 177 ++ ...flow.keras.layers.-separable-conv2-d.pbtxt | 177 ++ ...ras.layers.-separable-convolution1-d.pbtxt | 177 ++ ...ras.layers.-separable-convolution2-d.pbtxt | 177 ++ ...flow.keras.layers.-simple-r-n-n-cell.pbtxt | 175 ++ ...ensorflow.keras.layers.-simple-r-n-n.pbtxt | 244 ++ .../v2/tensorflow.keras.layers.-softmax.pbtxt | 175 ++ ...low.keras.layers.-spatial-dropout1-d.pbtxt | 176 ++ ...low.keras.layers.-spatial-dropout2-d.pbtxt | 176 ++ ...low.keras.layers.-spatial-dropout3-d.pbtxt | 176 ++ ...ow.keras.layers.-stacked-r-n-n-cells.pbtxt | 179 ++ .../tensorflow.keras.layers.-subtract.pbtxt | 176 ++ ...low.keras.layers.-thresholded-re-l-u.pbtxt | 175 ++ ...rflow.keras.layers.-time-distributed.pbtxt | 180 ++ ...sorflow.keras.layers.-up-sampling1-d.pbtxt | 175 ++ ...sorflow.keras.layers.-up-sampling2-d.pbtxt | 175 ++ ...sorflow.keras.layers.-up-sampling3-d.pbtxt | 175 ++ .../v2/tensorflow.keras.layers.-wrapper.pbtxt | 179 ++ ...orflow.keras.layers.-zero-padding1-d.pbtxt | 175 ++ ...orflow.keras.layers.-zero-padding2-d.pbtxt | 175 ++ ...orflow.keras.layers.-zero-padding3-d.pbtxt | 175 ++ .../golden/v2/tensorflow.keras.layers.pbtxt | 435 ++++ .../golden/v2/tensorflow.keras.losses.pbtxt | 115 + .../golden/v2/tensorflow.keras.metrics.pbtxt | 123 + .../v2/tensorflow.keras.models.-model.pbtxt | 268 ++ .../tensorflow.keras.models.-sequential.pbtxt | 289 +++ .../golden/v2/tensorflow.keras.models.pbtxt | 31 + ...ensorflow.keras.optimizers.-adadelta.pbtxt | 34 + ...tensorflow.keras.optimizers.-adagrad.pbtxt | 34 + .../tensorflow.keras.optimizers.-adam.pbtxt | 34 + .../tensorflow.keras.optimizers.-adamax.pbtxt | 34 + .../tensorflow.keras.optimizers.-nadam.pbtxt | 34 + ...nsorflow.keras.optimizers.-optimizer.pbtxt | 33 + ...nsorflow.keras.optimizers.-r-m-sprop.pbtxt | 34 + .../tensorflow.keras.optimizers.-s-g-d.pbtxt | 34 + .../v2/tensorflow.keras.optimizers.pbtxt | 47 + .../api/golden/v2/tensorflow.keras.pbtxt | 83 + ...processing.image.-directory-iterator.pbtxt | 23 + ...ocessing.image.-image-data-generator.pbtxt | 29 + ....keras.preprocessing.image.-iterator.pbtxt | 18 + ...ocessing.image.-numpy-array-iterator.pbtxt | 23 + ...tensorflow.keras.preprocessing.image.pbtxt | 63 + .../v2/tensorflow.keras.preprocessing.pbtxt | 15 + ...ssing.sequence.-timeseries-generator.pbtxt | 14 + ...sorflow.keras.preprocessing.sequence.pbtxt | 19 + ....keras.preprocessing.text.-tokenizer.pbtxt | 33 + .../tensorflow.keras.preprocessing.text.pbtxt | 19 + ...tensorflow.keras.regularizers.-l1-l2.pbtxt | 18 + ...flow.keras.regularizers.-regularizer.pbtxt | 12 + .../v2/tensorflow.keras.regularizers.pbtxt | 35 + ...low.keras.utils.-custom-object-scope.pbtxt | 9 + ...flow.keras.utils.-generator-enqueuer.pbtxt | 26 + ...ensorflow.keras.utils.-h-d-f5-matrix.pbtxt | 29 + .../v2/tensorflow.keras.utils.-progbar.pbtxt | 17 + ...rflow.keras.utils.-sequence-enqueuer.pbtxt | 24 + .../v2/tensorflow.keras.utils.-sequence.pbtxt | 12 + .../golden/v2/tensorflow.keras.utils.pbtxt | 67 + .../golden/v2/tensorflow.keras.wrappers.pbtxt | 7 + ...ppers.scikit_learn.-keras-classifier.pbtxt | 42 + ...appers.scikit_learn.-keras-regressor.pbtxt | 38 + ...nsorflow.keras.wrappers.scikit_learn.pbtxt | 11 + ...ensorflow.layers.-average-pooling1-d.pbtxt | 186 ++ ...ensorflow.layers.-average-pooling2-d.pbtxt | 186 ++ ...ensorflow.layers.-average-pooling3-d.pbtxt | 186 ++ ...nsorflow.layers.-batch-normalization.pbtxt | 185 ++ .../v2/tensorflow.layers.-conv1-d.pbtxt | 186 ++ ...tensorflow.layers.-conv2-d-transpose.pbtxt | 187 ++ .../v2/tensorflow.layers.-conv2-d.pbtxt | 186 ++ ...tensorflow.layers.-conv3-d-transpose.pbtxt | 187 ++ .../v2/tensorflow.layers.-conv3-d.pbtxt | 186 ++ .../golden/v2/tensorflow.layers.-dense.pbtxt | 185 ++ .../v2/tensorflow.layers.-dropout.pbtxt | 185 ++ .../v2/tensorflow.layers.-flatten.pbtxt | 185 ++ .../v2/tensorflow.layers.-input-spec.pbtxt | 9 + .../golden/v2/tensorflow.layers.-layer.pbtxt | 183 ++ .../tensorflow.layers.-max-pooling1-d.pbtxt | 186 ++ .../tensorflow.layers.-max-pooling2-d.pbtxt | 186 ++ .../tensorflow.layers.-max-pooling3-d.pbtxt | 186 ++ ...tensorflow.layers.-separable-conv1-d.pbtxt | 187 ++ ...tensorflow.layers.-separable-conv2-d.pbtxt | 187 ++ .../api/golden/v2/tensorflow.layers.pbtxt | 147 ++ ...ar-operator-block-diag.__metaclass__.pbtxt | 14 + ...w.linalg.-linear-operator-block-diag.pbtxt | 134 + ...ear-operator-circulant.__metaclass__.pbtxt | 14 + ...ow.linalg.-linear-operator-circulant.pbtxt | 155 ++ ...-operator-circulant2-d.__metaclass__.pbtxt | 14 + ...linalg.-linear-operator-circulant2-d.pbtxt | 155 ++ ...-operator-circulant3-d.__metaclass__.pbtxt | 14 + ...linalg.-linear-operator-circulant3-d.pbtxt | 155 ++ ...r-operator-composition.__metaclass__.pbtxt | 14 + ....linalg.-linear-operator-composition.pbtxt | 134 + ....-linear-operator-diag.__metaclass__.pbtxt | 14 + ...sorflow.linalg.-linear-operator-diag.pbtxt | 134 + ...r-operator-full-matrix.__metaclass__.pbtxt | 14 + ....linalg.-linear-operator-full-matrix.pbtxt | 130 + ...near-operator-identity.__metaclass__.pbtxt | 14 + ...low.linalg.-linear-operator-identity.pbtxt | 131 + ...ear-operator-kronecker.__metaclass__.pbtxt | 14 + ...ow.linalg.-linear-operator-kronecker.pbtxt | 134 + ...erator-low-rank-update.__metaclass__.pbtxt | 14 + ...alg.-linear-operator-low-rank-update.pbtxt | 154 ++ ...rator-lower-triangular.__metaclass__.pbtxt | 14 + ...lg.-linear-operator-lower-triangular.pbtxt | 130 + ...erator-scaled-identity.__metaclass__.pbtxt | 14 + ...alg.-linear-operator-scaled-identity.pbtxt | 135 + ...-linear-operator-zeros.__metaclass__.pbtxt | 14 + ...orflow.linalg.-linear-operator-zeros.pbtxt | 130 + ...inalg.-linear-operator.__metaclass__.pbtxt | 14 + .../tensorflow.linalg.-linear-operator.pbtxt | 129 + .../api/golden/v2/tensorflow.linalg.pbtxt | 175 ++ .../api/golden/v2/tensorflow.logging.pbtxt | 83 + .../v2/tensorflow.losses.-reduction.pbtxt | 40 + .../api/golden/v2/tensorflow.losses.pbtxt | 71 + .../api/golden/v2/tensorflow.manip.pbtxt | 35 + .../tools/api/golden/v2/tensorflow.math.pbtxt | 239 ++ .../api/golden/v2/tensorflow.metrics.pbtxt | 135 + .../api/golden/v2/tensorflow.name_scope.pbtxt | 13 + .../tools/api/golden/v2/tensorflow.nn.pbtxt | 359 +++ ...flow.nn.rnn_cell.-basic-l-s-t-m-cell.pbtxt | 198 ++ ...orflow.nn.rnn_cell.-basic-r-n-n-cell.pbtxt | 198 ++ ...nsorflow.nn.rnn_cell.-device-wrapper.pbtxt | 197 ++ ...sorflow.nn.rnn_cell.-dropout-wrapper.pbtxt | 201 ++ .../tensorflow.nn.rnn_cell.-g-r-u-cell.pbtxt | 198 ++ ...tensorflow.nn.rnn_cell.-l-s-t-m-cell.pbtxt | 198 ++ ...low.nn.rnn_cell.-l-s-t-m-state-tuple.pbtxt | 27 + ...orflow.nn.rnn_cell.-multi-r-n-n-cell.pbtxt | 197 ++ .../tensorflow.nn.rnn_cell.-r-n-n-cell.pbtxt | 196 ++ ...orflow.nn.rnn_cell.-residual-wrapper.pbtxt | 197 ++ .../golden/v2/tensorflow.nn.rnn_cell.pbtxt | 43 + .../v2/tensorflow.ones_initializer.pbtxt | 18 + .../tensorflow.orthogonal_initializer.pbtxt | 18 + .../tools/api/golden/v2/tensorflow.pbtxt | 2215 +++++++++++++++++ ...flow.profiler.-advice-proto.-checker.pbtxt | 12 + ...ofiler.-advice-proto.-checkers-entry.pbtxt | 22 + .../tensorflow.profiler.-advice-proto.pbtxt | 41 + ...graph-node-proto.-input-shapes-entry.pbtxt | 22 + ...ensorflow.profiler.-graph-node-proto.pbtxt | 191 ++ ...low.profiler.-multi-graph-node-proto.pbtxt | 134 + ...er.-op-log-proto.-id-to-string-entry.pbtxt | 21 + .../tensorflow.profiler.-op-log-proto.pbtxt | 38 + ...low.profiler.-profile-option-builder.pbtxt | 93 + .../v2/tensorflow.profiler.-profiler.pbtxt | 37 + .../api/golden/v2/tensorflow.profiler.pbtxt | 39 + ...thon_io.-t-f-record-compression-type.pbtxt | 20 + ...orflow.python_io.-t-f-record-options.pbtxt | 17 + ...sorflow.python_io.-t-f-record-writer.pbtxt | 21 + .../api/golden/v2/tensorflow.python_io.pbtxt | 19 + .../golden/v2/tensorflow.quantization.pbtxt | 35 + ...tensorflow.random_normal_initializer.pbtxt | 18 + ...ensorflow.random_uniform_initializer.pbtxt | 18 + .../v2/tensorflow.resource_loader.pbtxt | 23 + ...d_model.builder.-saved-model-builder.pbtxt | 21 + .../v2/tensorflow.saved_model.builder.pbtxt | 7 + .../v2/tensorflow.saved_model.constants.pbtxt | 39 + .../v2/tensorflow.saved_model.loader.pbtxt | 11 + .../v2/tensorflow.saved_model.main_op.pbtxt | 11 + .../golden/v2/tensorflow.saved_model.pbtxt | 39 + ...flow.saved_model.signature_constants.pbtxt | 47 + ...flow.saved_model.signature_def_utils.pbtxt | 23 + ...tensorflow.saved_model.tag_constants.pbtxt | 19 + .../v2/tensorflow.saved_model.utils.pbtxt | 11 + .../tools/api/golden/v2/tensorflow.sets.pbtxt | 19 + .../api/golden/v2/tensorflow.sparse.pbtxt | 11 + .../api/golden/v2/tensorflow.spectral.pbtxt | 59 + .../api/golden/v2/tensorflow.strings.pbtxt | 43 + .../golden/v2/tensorflow.summary.-event.pbtxt | 74 + ...ensorflow.summary.-file-writer-cache.pbtxt | 16 + .../v2/tensorflow.summary.-file-writer.pbtxt | 50 + .../v2/tensorflow.summary.-session-log.pbtxt | 44 + ...sorflow.summary.-summary-description.pbtxt | 12 + .../tensorflow.summary.-summary.-audio.pbtxt | 36 + .../tensorflow.summary.-summary.-image.pbtxt | 30 + .../tensorflow.summary.-summary.-value.pbtxt | 74 + .../v2/tensorflow.summary.-summary.pbtxt | 144 ++ ...sorflow.summary.-tagged-run-metadata.pbtxt | 18 + .../api/golden/v2/tensorflow.summary.pbtxt | 67 + .../api/golden/v2/tensorflow.sysconfig.pbtxt | 19 + .../v2/tensorflow.test.-benchmark.pbtxt | 21 + ...ensorflow.test.-stub-out-for-testing.pbtxt | 28 + .../tools/api/golden/v2/tensorflow.test.pbtxt | 59 + ...tensorflow.train.-adadelta-optimizer.pbtxt | 51 + ...sorflow.train.-adagrad-d-a-optimizer.pbtxt | 51 + .../tensorflow.train.-adagrad-optimizer.pbtxt | 51 + .../v2/tensorflow.train.-adam-optimizer.pbtxt | 51 + .../v2/tensorflow.train.-bytes-list.pbtxt | 12 + ...sorflow.train.-checkpoint-saver-hook.pbtxt | 30 + ...low.train.-checkpoint-saver-listener.pbtxt | 24 + .../v2/tensorflow.train.-checkpoint.pbtxt | 23 + ...sorflow.train.-chief-session-creator.pbtxt | 14 + .../v2/tensorflow.train.-cluster-def.pbtxt | 13 + .../v2/tensorflow.train.-cluster-spec.pbtxt | 37 + .../v2/tensorflow.train.-coordinator.pbtxt | 45 + .../golden/v2/tensorflow.train.-example.pbtxt | 13 + ...ow.train.-exponential-moving-average.pbtxt | 29 + .../v2/tensorflow.train.-feature-list.pbtxt | 13 + ...n.-feature-lists.-feature-list-entry.pbtxt | 22 + .../v2/tensorflow.train.-feature-lists.pbtxt | 32 + .../golden/v2/tensorflow.train.-feature.pbtxt | 33 + ...rflow.train.-features.-feature-entry.pbtxt | 22 + .../v2/tensorflow.train.-features.pbtxt | 32 + .../v2/tensorflow.train.-feed-fn-hook.pbtxt | 30 + .../v2/tensorflow.train.-final-ops-hook.pbtxt | 34 + .../v2/tensorflow.train.-float-list.pbtxt | 15 + .../v2/tensorflow.train.-ftrl-optimizer.pbtxt | 51 + ...rflow.train.-global-step-waiter-hook.pbtxt | 30 + ...ow.train.-gradient-descent-optimizer.pbtxt | 51 + .../v2/tensorflow.train.-int64-list.pbtxt | 15 + ...nsorflow.train.-job-def.-tasks-entry.pbtxt | 21 + .../golden/v2/tensorflow.train.-job-def.pbtxt | 37 + ...ensorflow.train.-logging-tensor-hook.pbtxt | 30 + .../v2/tensorflow.train.-looper-thread.pbtxt | 73 + ...tensorflow.train.-momentum-optimizer.pbtxt | 51 + ...ain.-monitored-session.-step-context.pbtxt | 21 + .../tensorflow.train.-monitored-session.pbtxt | 34 + ...rain.-nan-loss-during-training-error.pbtxt | 16 + .../tensorflow.train.-nan-tensor-hook.pbtxt | 30 + .../v2/tensorflow.train.-optimizer.pbtxt | 50 + .../v2/tensorflow.train.-profiler-hook.pbtxt | 30 + ...ow.train.-proximal-adagrad-optimizer.pbtxt | 51 + ...-proximal-gradient-descent-optimizer.pbtxt | 51 + .../v2/tensorflow.train.-queue-runner.pbtxt | 49 + ...nsorflow.train.-r-m-s-prop-optimizer.pbtxt | 51 + .../v2/tensorflow.train.-saver-def.pbtxt | 64 + .../golden/v2/tensorflow.train.-saver.pbtxt | 53 + .../v2/tensorflow.train.-scaffold.pbtxt | 53 + ...nsorflow.train.-second-or-step-timer.pbtxt | 26 + .../tensorflow.train.-sequence-example.pbtxt | 20 + .../v2/tensorflow.train.-server-def.pbtxt | 38 + .../golden/v2/tensorflow.train.-server.pbtxt | 29 + .../tensorflow.train.-session-creator.pbtxt | 12 + .../tensorflow.train.-session-manager.pbtxt | 21 + .../tensorflow.train.-session-run-args.pbtxt | 27 + ...ensorflow.train.-session-run-context.pbtxt | 25 + .../tensorflow.train.-session-run-hook.pbtxt | 28 + ...tensorflow.train.-session-run-values.pbtxt | 27 + ...ular-monitored-session.-step-context.pbtxt | 21 + ...ow.train.-singular-monitored-session.pbtxt | 38 + .../tensorflow.train.-step-counter-hook.pbtxt | 30 + .../tensorflow.train.-stop-at-step-hook.pbtxt | 30 + ...tensorflow.train.-summary-saver-hook.pbtxt | 30 + .../v2/tensorflow.train.-supervisor.pbtxt | 153 ++ ...rflow.train.-sync-replicas-optimizer.pbtxt | 63 + .../v2/tensorflow.train.-vocab-info.pbtxt | 39 + ...orflow.train.-worker-session-creator.pbtxt | 14 + .../api/golden/v2/tensorflow.train.pbtxt | 459 ++++ ...low.train.queue_runner.-queue-runner.pbtxt | 49 + .../v2/tensorflow.train.queue_runner.pbtxt | 15 + ...sorflow.truncated_normal_initializer.pbtxt | 18 + ...low.uniform_unit_scaling_initializer.pbtxt | 18 + .../golden/v2/tensorflow.variable_scope.pbtxt | 9 + ...sorflow.variance_scaling_initializer.pbtxt | 18 + .../v2/tensorflow.zeros_initializer.pbtxt | 18 + tensorflow/tools/api/tests/BUILD | 3 +- .../tools/api/tests/api_compatibility_test.py | 39 +- 1162 files changed, 49727 insertions(+), 17 deletions(-) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-aggregation-method.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-attr-value.-list-value.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-attr-value.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-conditional-accumulator-base.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-conditional-accumulator.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-config-proto.-device-count-entry.pbtxt (100%) create mode 100644 tensorflow/tools/api/golden/v1/tensorflow.-config-proto.-experimental.pbtxt create mode 100644 tensorflow/tools/api/golden/v1/tensorflow.-config-proto.pbtxt rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-d-type.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-device-spec.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-dimension.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-event.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-f-i-f-o-queue.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-fixed-len-feature.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-fixed-len-sequence-feature.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-fixed-length-record-reader.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-g-p-u-options.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-gradient-tape.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-graph-def.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-graph-keys.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-graph-options.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-graph.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-histogram-proto.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-identity-reader.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-indexed-slices.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-interactive-session.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-l-m-d-b-reader.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-log-message.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-meta-graph-def.-collection-def-entry.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-meta-graph-def.-meta-info-def.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-meta-graph-def.-signature-def-entry.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-meta-graph-def.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-name-attr-list.-attr-entry.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-name-attr-list.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-node-def.-attr-entry.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-node-def.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-op-error.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-operation.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-optimizer-options.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-padding-f-i-f-o-queue.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-priority-queue.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-queue-base.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-random-shuffle-queue.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-reader-base.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-register-gradient.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-run-metadata.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-run-options.-experimental.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-run-options.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-session-log.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-session.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-sparse-conditional-accumulator.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-sparse-feature.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-sparse-tensor-value.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-sparse-tensor.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-summary-metadata.-plugin-data.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-summary-metadata.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-summary.-audio.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-summary.-image.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-summary.-value.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-summary.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-t-f-record-reader.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-tensor-array.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-tensor-info.-coo-sparse.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-tensor-info.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-tensor-shape.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-tensor.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-text-line-reader.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-var-len-feature.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-variable-aggregation.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-variable-scope.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-variable-synchronization.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-variable.-save-slice-info.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-variable.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.-whole-file-reader.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.app.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.bitwise.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.compat.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.constant_initializer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.data.-dataset.__metaclass__.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.data.-dataset.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.data.-fixed-length-record-dataset.__metaclass__.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.data.-fixed-length-record-dataset.pbtxt (100%) create mode 100644 tensorflow/tools/api/golden/v1/tensorflow.data.-iterator.pbtxt rename tensorflow/tools/api/golden/{ => v1}/tensorflow.data.-t-f-record-dataset.__metaclass__.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.data.-t-f-record-dataset.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.data.-text-line-dataset.__metaclass__.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.data.-text-line-dataset.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.data.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.debugging.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.distributions.-bernoulli.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.distributions.-beta.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.distributions.-categorical.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.distributions.-dirichlet-multinomial.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.distributions.-dirichlet.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.distributions.-distribution.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.distributions.-exponential.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.distributions.-gamma.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.distributions.-laplace.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.distributions.-multinomial.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.distributions.-normal.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.distributions.-register-k-l.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.distributions.-reparameterization-type.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.distributions.-student-t.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.distributions.-uniform.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.distributions.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.dtypes.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.errors.-aborted-error.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.errors.-already-exists-error.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.errors.-cancelled-error.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.errors.-data-loss-error.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.errors.-deadline-exceeded-error.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.errors.-failed-precondition-error.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.errors.-internal-error.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.errors.-invalid-argument-error.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.errors.-not-found-error.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.errors.-op-error.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.errors.-out-of-range-error.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.errors.-permission-denied-error.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.errors.-resource-exhausted-error.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.errors.-unauthenticated-error.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.errors.-unavailable-error.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.errors.-unimplemented-error.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.errors.-unknown-error.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.errors.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.errors.raise_exception_on_not_ok_status.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.-baseline-classifier.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.-baseline-regressor.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.-best-exporter.pbtxt (100%) create mode 100644 tensorflow/tools/api/golden/v1/tensorflow.estimator.-boosted-trees-classifier.pbtxt create mode 100644 tensorflow/tools/api/golden/v1/tensorflow.estimator.-boosted-trees-regressor.pbtxt rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.-d-n-n-classifier.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.-d-n-n-linear-combined-classifier.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.-d-n-n-linear-combined-regressor.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.-d-n-n-regressor.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.-estimator-spec.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.-estimator.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.-eval-spec.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.-exporter.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.-final-exporter.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.-latest-exporter.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.-linear-classifier.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.-linear-regressor.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.-mode-keys.pbtxt (100%) create mode 100644 tensorflow/tools/api/golden/v1/tensorflow.estimator.-run-config.pbtxt rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.-train-spec.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.-vocab-info.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.-warm-start-settings.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.export.-classification-output.__metaclass__.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.export.-classification-output.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.export.-export-output.__metaclass__.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.export.-export-output.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.export.-predict-output.__metaclass__.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.export.-predict-output.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.export.-regression-output.__metaclass__.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.export.-regression-output.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.export.-serving-input-receiver.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.export.-tensor-serving-input-receiver.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.export.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.inputs.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.estimator.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.feature_column.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.gfile.-fast-g-file.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.gfile.-g-file.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.gfile.-open.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.gfile.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.graph_util.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.image.-resize-method.pbtxt (100%) create mode 100644 tensorflow/tools/api/golden/v1/tensorflow.image.pbtxt rename tensorflow/tools/api/golden/{ => v1}/tensorflow.initializers.constant.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.initializers.identity.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.initializers.ones.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.initializers.orthogonal.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.initializers.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.initializers.random_normal.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.initializers.random_uniform.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.initializers.truncated_normal.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.initializers.uniform_unit_scaling.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.initializers.variance_scaling.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.initializers.zeros.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.io.pbtxt (100%) create mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.-model.pbtxt create mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.-sequential.pbtxt create mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.activations.pbtxt rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.applications.densenet.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.applications.inception_resnet_v2.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.applications.inception_v3.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.applications.mobilenet.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.applications.nasnet.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.applications.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.applications.resnet50.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.applications.vgg16.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.applications.vgg19.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.applications.xception.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.backend.name_scope.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.backend.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.callbacks.-base-logger.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.callbacks.-c-s-v-logger.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.callbacks.-callback.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.callbacks.-early-stopping.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.callbacks.-history.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.callbacks.-lambda-callback.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.callbacks.-learning-rate-scheduler.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.callbacks.-model-checkpoint.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.callbacks.-progbar-logger.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.callbacks.-reduce-l-r-on-plateau.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.callbacks.-remote-monitor.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.callbacks.-tensor-board.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.callbacks.-terminate-on-na-n.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.callbacks.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.constraints.-constraint.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.constraints.-max-norm.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.constraints.-min-max-norm.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.constraints.-non-neg.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.constraints.-unit-norm.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.constraints.max_norm.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.constraints.min_max_norm.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.constraints.non_neg.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.constraints.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.constraints.unit_norm.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.datasets.boston_housing.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.datasets.cifar10.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.datasets.cifar100.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.datasets.fashion_mnist.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.datasets.imdb.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.datasets.mnist.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.datasets.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.datasets.reuters.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.estimator.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.initializers.-constant.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.initializers.-identity.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.initializers.-initializer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.initializers.-ones.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.initializers.-orthogonal.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.initializers.-random-normal.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.initializers.-random-uniform.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.initializers.-truncated-normal.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.initializers.-variance-scaling.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.initializers.-zeros.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.initializers.constant.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.initializers.identity.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.initializers.normal.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.initializers.ones.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.initializers.orthogonal.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.initializers.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.initializers.random_normal.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.initializers.random_uniform.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.initializers.truncated_normal.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.initializers.uniform.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.initializers.zeros.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-activation.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-activity-regularization.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-add.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-alpha-dropout.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-average-pooling1-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-average-pooling2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-average-pooling3-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-average.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-avg-pool1-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-avg-pool2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-avg-pool3-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-batch-normalization.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-bidirectional.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-concatenate.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-conv-l-s-t-m2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-conv1-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-conv2-d-transpose.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-conv2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-conv3-d-transpose.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-conv3-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-convolution1-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-convolution2-d-transpose.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-convolution2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-convolution3-d-transpose.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-convolution3-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-cropping1-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-cropping2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-cropping3-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-cu-d-n-n-g-r-u.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-cu-d-n-n-l-s-t-m.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-dense.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-depthwise-conv2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-dot.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-dropout.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-e-l-u.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-embedding.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-flatten.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-g-r-u-cell.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-g-r-u.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-gaussian-dropout.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-gaussian-noise.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-global-average-pooling1-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-global-average-pooling2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-global-average-pooling3-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-global-avg-pool1-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-global-avg-pool2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-global-avg-pool3-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-global-max-pool1-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-global-max-pool2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-global-max-pool3-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-global-max-pooling1-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-global-max-pooling2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-global-max-pooling3-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-input-layer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-input-spec.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-l-s-t-m-cell.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-l-s-t-m.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-lambda.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-layer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-leaky-re-l-u.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-locally-connected1-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-locally-connected2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-masking.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-max-pool1-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-max-pool2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-max-pool3-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-max-pooling1-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-max-pooling2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-max-pooling3-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-maximum.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-minimum.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-multiply.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-p-re-l-u.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-permute.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-r-n-n.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-re-l-u.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-repeat-vector.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-reshape.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-separable-conv1-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-separable-conv2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-separable-convolution1-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-separable-convolution2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-simple-r-n-n-cell.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-simple-r-n-n.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-softmax.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-spatial-dropout1-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-spatial-dropout2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-spatial-dropout3-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-stacked-r-n-n-cells.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-subtract.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-thresholded-re-l-u.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-time-distributed.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-up-sampling1-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-up-sampling2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-up-sampling3-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-wrapper.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-zero-padding1-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-zero-padding2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.-zero-padding3-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.layers.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.losses.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.metrics.pbtxt (100%) create mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.models.-model.pbtxt create mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.models.-sequential.pbtxt rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.models.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.optimizers.-adadelta.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.optimizers.-adagrad.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.optimizers.-adam.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.optimizers.-adamax.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.optimizers.-nadam.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.optimizers.-optimizer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.optimizers.-r-m-sprop.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.optimizers.-s-g-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.optimizers.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.preprocessing.image.-directory-iterator.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.preprocessing.image.-image-data-generator.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.preprocessing.image.-iterator.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.preprocessing.image.-numpy-array-iterator.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.preprocessing.image.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.preprocessing.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.preprocessing.sequence.-timeseries-generator.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.preprocessing.sequence.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.preprocessing.text.-tokenizer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.preprocessing.text.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.regularizers.-l1-l2.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.regularizers.-regularizer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.regularizers.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.utils.-custom-object-scope.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.utils.-generator-enqueuer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.utils.-h-d-f5-matrix.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.utils.-progbar.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.utils.-sequence-enqueuer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.utils.-sequence.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.utils.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.wrappers.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.wrappers.scikit_learn.-keras-classifier.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.wrappers.scikit_learn.-keras-regressor.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.keras.wrappers.scikit_learn.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.layers.-average-pooling1-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.layers.-average-pooling2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.layers.-average-pooling3-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.layers.-batch-normalization.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.layers.-conv1-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.layers.-conv2-d-transpose.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.layers.-conv2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.layers.-conv3-d-transpose.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.layers.-conv3-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.layers.-dense.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.layers.-dropout.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.layers.-flatten.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.layers.-input-spec.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.layers.-layer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.layers.-max-pooling1-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.layers.-max-pooling2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.layers.-max-pooling3-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.layers.-separable-conv1-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.layers.-separable-conv2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.layers.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-block-diag.__metaclass__.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-block-diag.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-circulant.__metaclass__.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-circulant.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-circulant2-d.__metaclass__.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-circulant2-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-circulant3-d.__metaclass__.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-circulant3-d.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-composition.__metaclass__.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-composition.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-diag.__metaclass__.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-diag.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-full-matrix.__metaclass__.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-full-matrix.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-identity.__metaclass__.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-identity.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-kronecker.__metaclass__.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-kronecker.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-low-rank-update.__metaclass__.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-low-rank-update.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-lower-triangular.__metaclass__.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-lower-triangular.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-scaled-identity.__metaclass__.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-scaled-identity.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-zeros.__metaclass__.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator-zeros.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator.__metaclass__.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.-linear-operator.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.linalg.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.logging.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.losses.-reduction.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.losses.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.manip.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.math.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.metrics.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.name_scope.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.nn.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.nn.rnn_cell.-basic-l-s-t-m-cell.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.nn.rnn_cell.-basic-r-n-n-cell.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.nn.rnn_cell.-device-wrapper.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.nn.rnn_cell.-dropout-wrapper.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.nn.rnn_cell.-g-r-u-cell.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.nn.rnn_cell.-l-s-t-m-cell.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.nn.rnn_cell.-l-s-t-m-state-tuple.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.nn.rnn_cell.-multi-r-n-n-cell.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.nn.rnn_cell.-r-n-n-cell.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.nn.rnn_cell.-residual-wrapper.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.nn.rnn_cell.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.ones_initializer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.orthogonal_initializer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.profiler.-advice-proto.-checker.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.profiler.-advice-proto.-checkers-entry.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.profiler.-advice-proto.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.profiler.-graph-node-proto.-input-shapes-entry.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.profiler.-graph-node-proto.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.profiler.-multi-graph-node-proto.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.profiler.-op-log-proto.-id-to-string-entry.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.profiler.-op-log-proto.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.profiler.-profile-option-builder.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.profiler.-profiler.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.profiler.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.python_io.-t-f-record-compression-type.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.python_io.-t-f-record-options.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.python_io.-t-f-record-writer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.python_io.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.quantization.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.random_normal_initializer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.random_uniform_initializer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.resource_loader.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.saved_model.builder.-saved-model-builder.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.saved_model.builder.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.saved_model.constants.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.saved_model.loader.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.saved_model.main_op.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.saved_model.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.saved_model.signature_constants.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.saved_model.signature_def_utils.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.saved_model.tag_constants.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.saved_model.utils.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.sets.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.sparse.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.spectral.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.strings.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.summary.-event.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.summary.-file-writer-cache.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.summary.-file-writer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.summary.-session-log.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.summary.-summary-description.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.summary.-summary.-audio.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.summary.-summary.-image.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.summary.-summary.-value.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.summary.-summary.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.summary.-tagged-run-metadata.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.summary.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.sysconfig.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.test.-benchmark.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.test.-stub-out-for-testing.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.test.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-adadelta-optimizer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-adagrad-d-a-optimizer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-adagrad-optimizer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-adam-optimizer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-bytes-list.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-checkpoint-saver-hook.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-checkpoint-saver-listener.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-checkpoint.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-chief-session-creator.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-cluster-def.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-cluster-spec.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-coordinator.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-example.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-exponential-moving-average.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-feature-list.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-feature-lists.-feature-list-entry.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-feature-lists.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-feature.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-features.-feature-entry.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-features.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-feed-fn-hook.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-final-ops-hook.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-float-list.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-ftrl-optimizer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-global-step-waiter-hook.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-gradient-descent-optimizer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-int64-list.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-job-def.-tasks-entry.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-job-def.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-logging-tensor-hook.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-looper-thread.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-momentum-optimizer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-monitored-session.-step-context.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-monitored-session.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-nan-loss-during-training-error.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-nan-tensor-hook.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-optimizer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-profiler-hook.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-proximal-adagrad-optimizer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-proximal-gradient-descent-optimizer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-queue-runner.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-r-m-s-prop-optimizer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-saver-def.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-saver.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-scaffold.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-second-or-step-timer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-sequence-example.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-server-def.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-server.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-session-creator.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-session-manager.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-session-run-args.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-session-run-context.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-session-run-hook.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-session-run-values.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-singular-monitored-session.-step-context.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-singular-monitored-session.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-step-counter-hook.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-stop-at-step-hook.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-summary-saver-hook.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-supervisor.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-sync-replicas-optimizer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-vocab-info.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.-worker-session-creator.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.queue_runner.-queue-runner.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.train.queue_runner.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.truncated_normal_initializer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.uniform_unit_scaling_initializer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.variable_scope.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.variance_scaling_initializer.pbtxt (100%) rename tensorflow/tools/api/golden/{ => v1}/tensorflow.zeros_initializer.pbtxt (100%) create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-aggregation-method.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-attr-value.-list-value.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-attr-value.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-conditional-accumulator-base.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-conditional-accumulator.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-config-proto.-device-count-entry.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-config-proto.-experimental.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-config-proto.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-d-type.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-device-spec.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-dimension.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-event.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-f-i-f-o-queue.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-fixed-len-feature.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-fixed-len-sequence-feature.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-fixed-length-record-reader.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-g-p-u-options.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-gradient-tape.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-graph-def.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-graph-keys.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-graph-options.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-graph.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-histogram-proto.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-identity-reader.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-indexed-slices.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-interactive-session.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-l-m-d-b-reader.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-log-message.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-meta-graph-def.-collection-def-entry.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-meta-graph-def.-meta-info-def.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-meta-graph-def.-signature-def-entry.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-meta-graph-def.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-name-attr-list.-attr-entry.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-name-attr-list.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-node-def.-attr-entry.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-node-def.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-op-error.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-operation.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-optimizer-options.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-padding-f-i-f-o-queue.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-priority-queue.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-queue-base.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-random-shuffle-queue.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-reader-base.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-register-gradient.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-run-metadata.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-run-options.-experimental.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-run-options.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-session-log.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-session.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-sparse-conditional-accumulator.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-sparse-feature.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-sparse-tensor-value.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-sparse-tensor.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-summary-metadata.-plugin-data.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-summary-metadata.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-summary.-audio.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-summary.-image.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-summary.-value.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-summary.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-t-f-record-reader.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-tensor-array.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-tensor-info.-coo-sparse.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-tensor-info.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-tensor-shape.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-tensor.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-text-line-reader.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-var-len-feature.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-variable-aggregation.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-variable-scope.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-variable-synchronization.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-variable.-save-slice-info.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-variable.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.-whole-file-reader.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.app.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.bitwise.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.compat.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.constant_initializer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.data.-dataset.__metaclass__.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.data.-dataset.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.data.-fixed-length-record-dataset.__metaclass__.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.data.-fixed-length-record-dataset.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.data.-iterator.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.data.-t-f-record-dataset.__metaclass__.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.data.-t-f-record-dataset.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.data.-text-line-dataset.__metaclass__.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.data.-text-line-dataset.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.data.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.debugging.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.distributions.-bernoulli.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.distributions.-beta.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.distributions.-categorical.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.distributions.-dirichlet-multinomial.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.distributions.-dirichlet.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.distributions.-distribution.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.distributions.-exponential.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.distributions.-gamma.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.distributions.-laplace.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.distributions.-multinomial.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.distributions.-normal.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.distributions.-register-k-l.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.distributions.-reparameterization-type.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.distributions.-student-t.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.distributions.-uniform.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.distributions.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.dtypes.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.errors.-aborted-error.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.errors.-already-exists-error.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.errors.-cancelled-error.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.errors.-data-loss-error.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.errors.-deadline-exceeded-error.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.errors.-failed-precondition-error.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.errors.-internal-error.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.errors.-invalid-argument-error.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.errors.-not-found-error.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.errors.-op-error.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.errors.-out-of-range-error.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.errors.-permission-denied-error.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.errors.-resource-exhausted-error.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.errors.-unauthenticated-error.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.errors.-unavailable-error.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.errors.-unimplemented-error.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.errors.-unknown-error.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.errors.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.errors.raise_exception_on_not_ok_status.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.-baseline-classifier.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.-baseline-regressor.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.-best-exporter.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.-boosted-trees-classifier.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.-boosted-trees-regressor.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.-d-n-n-classifier.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.-d-n-n-linear-combined-classifier.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.-d-n-n-linear-combined-regressor.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.-d-n-n-regressor.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.-estimator-spec.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.-estimator.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.-eval-spec.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.-exporter.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.-final-exporter.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.-latest-exporter.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.-linear-classifier.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.-linear-regressor.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.-mode-keys.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.-run-config.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.-train-spec.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.-vocab-info.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.-warm-start-settings.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-classification-output.__metaclass__.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-classification-output.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-export-output.__metaclass__.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-export-output.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-predict-output.__metaclass__.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-predict-output.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-regression-output.__metaclass__.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-regression-output.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-serving-input-receiver.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-tensor-serving-input-receiver.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.export.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.inputs.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.estimator.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.feature_column.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.gfile.-fast-g-file.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.gfile.-g-file.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.gfile.-open.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.gfile.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.graph_util.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.image.-resize-method.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.image.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.initializers.constant.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.initializers.identity.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.initializers.ones.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.initializers.orthogonal.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.initializers.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.initializers.random_normal.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.initializers.random_uniform.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.initializers.truncated_normal.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.initializers.uniform_unit_scaling.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.initializers.variance_scaling.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.initializers.zeros.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.io.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.-model.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.-sequential.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.activations.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.applications.densenet.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.applications.inception_resnet_v2.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.applications.inception_v3.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.applications.mobilenet.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.applications.nasnet.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.applications.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.applications.resnet50.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.applications.vgg16.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.applications.vgg19.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.applications.xception.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.backend.name_scope.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.backend.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-base-logger.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-c-s-v-logger.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-callback.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-early-stopping.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-history.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-lambda-callback.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-learning-rate-scheduler.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-model-checkpoint.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-progbar-logger.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-reduce-l-r-on-plateau.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-remote-monitor.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-tensor-board.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-terminate-on-na-n.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.-constraint.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.-max-norm.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.-min-max-norm.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.-non-neg.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.-unit-norm.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.max_norm.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.min_max_norm.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.non_neg.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.unit_norm.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.boston_housing.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.cifar10.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.cifar100.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.fashion_mnist.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.imdb.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.mnist.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.reuters.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.estimator.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-constant.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-identity.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-initializer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-ones.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-orthogonal.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-random-normal.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-random-uniform.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-truncated-normal.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-variance-scaling.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-zeros.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.constant.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.identity.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.normal.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.ones.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.orthogonal.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.random_normal.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.random_uniform.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.truncated_normal.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.uniform.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.zeros.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-activation.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-activity-regularization.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-add.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-alpha-dropout.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-average-pooling1-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-average-pooling2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-average-pooling3-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-average.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-avg-pool1-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-avg-pool2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-avg-pool3-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-batch-normalization.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-bidirectional.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-concatenate.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv-l-s-t-m2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv1-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv2-d-transpose.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv3-d-transpose.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv3-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-convolution1-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-convolution2-d-transpose.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-convolution2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-convolution3-d-transpose.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-convolution3-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-cropping1-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-cropping2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-cropping3-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-cu-d-n-n-g-r-u.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-cu-d-n-n-l-s-t-m.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-dense.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-depthwise-conv2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-dot.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-dropout.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-e-l-u.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-embedding.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-flatten.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-g-r-u-cell.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-g-r-u.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-gaussian-dropout.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-gaussian-noise.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-average-pooling1-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-average-pooling2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-average-pooling3-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-avg-pool1-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-avg-pool2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-avg-pool3-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pool1-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pool2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pool3-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pooling1-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pooling2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pooling3-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-input-layer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-input-spec.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-l-s-t-m-cell.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-l-s-t-m.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-lambda.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-layer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-leaky-re-l-u.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-locally-connected1-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-locally-connected2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-masking.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pool1-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pool2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pool3-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pooling1-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pooling2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pooling3-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-maximum.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-minimum.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-multiply.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-p-re-l-u.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-permute.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-r-n-n.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-re-l-u.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-repeat-vector.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-reshape.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-separable-conv1-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-separable-conv2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-separable-convolution1-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-separable-convolution2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-simple-r-n-n-cell.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-simple-r-n-n.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-softmax.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-spatial-dropout1-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-spatial-dropout2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-spatial-dropout3-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-stacked-r-n-n-cells.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-subtract.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-thresholded-re-l-u.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-time-distributed.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-up-sampling1-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-up-sampling2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-up-sampling3-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-wrapper.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-zero-padding1-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-zero-padding2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-zero-padding3-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.layers.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.losses.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.metrics.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.models.-model.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.models.-sequential.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.models.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-adadelta.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-adagrad.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-adam.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-adamax.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-nadam.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-optimizer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-r-m-sprop.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-s-g-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.image.-directory-iterator.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.image.-image-data-generator.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.image.-iterator.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.image.-numpy-array-iterator.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.image.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.sequence.-timeseries-generator.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.sequence.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.text.-tokenizer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.text.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.regularizers.-l1-l2.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.regularizers.-regularizer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.regularizers.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-custom-object-scope.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-generator-enqueuer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-h-d-f5-matrix.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-progbar.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-sequence-enqueuer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-sequence.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.utils.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.wrappers.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.wrappers.scikit_learn.-keras-classifier.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.wrappers.scikit_learn.-keras-regressor.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.keras.wrappers.scikit_learn.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.layers.-average-pooling1-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.layers.-average-pooling2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.layers.-average-pooling3-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.layers.-batch-normalization.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.layers.-conv1-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.layers.-conv2-d-transpose.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.layers.-conv2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.layers.-conv3-d-transpose.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.layers.-conv3-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.layers.-dense.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.layers.-dropout.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.layers.-flatten.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.layers.-input-spec.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.layers.-layer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.layers.-max-pooling1-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.layers.-max-pooling2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.layers.-max-pooling3-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.layers.-separable-conv1-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.layers.-separable-conv2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.layers.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-block-diag.__metaclass__.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-block-diag.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant.__metaclass__.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant2-d.__metaclass__.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant2-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant3-d.__metaclass__.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant3-d.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-composition.__metaclass__.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-composition.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-diag.__metaclass__.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-diag.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-full-matrix.__metaclass__.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-full-matrix.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-identity.__metaclass__.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-identity.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-kronecker.__metaclass__.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-kronecker.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-low-rank-update.__metaclass__.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-low-rank-update.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-lower-triangular.__metaclass__.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-lower-triangular.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-scaled-identity.__metaclass__.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-scaled-identity.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-zeros.__metaclass__.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-zeros.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator.__metaclass__.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.linalg.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.logging.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.losses.-reduction.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.losses.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.manip.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.math.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.metrics.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.name_scope.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.nn.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-basic-l-s-t-m-cell.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-basic-r-n-n-cell.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-device-wrapper.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-dropout-wrapper.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-g-r-u-cell.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-l-s-t-m-cell.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-l-s-t-m-state-tuple.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-multi-r-n-n-cell.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-r-n-n-cell.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-residual-wrapper.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.ones_initializer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.orthogonal_initializer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.profiler.-advice-proto.-checker.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.profiler.-advice-proto.-checkers-entry.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.profiler.-advice-proto.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.profiler.-graph-node-proto.-input-shapes-entry.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.profiler.-graph-node-proto.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.profiler.-multi-graph-node-proto.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.profiler.-op-log-proto.-id-to-string-entry.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.profiler.-op-log-proto.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.profiler.-profile-option-builder.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.profiler.-profiler.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.profiler.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.python_io.-t-f-record-compression-type.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.python_io.-t-f-record-options.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.python_io.-t-f-record-writer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.python_io.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.quantization.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.random_normal_initializer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.random_uniform_initializer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.resource_loader.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.saved_model.builder.-saved-model-builder.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.saved_model.builder.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.saved_model.constants.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.saved_model.loader.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.saved_model.main_op.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.saved_model.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.saved_model.signature_constants.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.saved_model.signature_def_utils.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.saved_model.tag_constants.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.saved_model.utils.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.sets.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.sparse.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.spectral.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.strings.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.summary.-event.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.summary.-file-writer-cache.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.summary.-file-writer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.summary.-session-log.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.summary.-summary-description.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.summary.-summary.-audio.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.summary.-summary.-image.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.summary.-summary.-value.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.summary.-summary.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.summary.-tagged-run-metadata.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.summary.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.sysconfig.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.test.-benchmark.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.test.-stub-out-for-testing.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.test.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-adadelta-optimizer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-adagrad-d-a-optimizer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-adagrad-optimizer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-adam-optimizer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-bytes-list.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-checkpoint-saver-hook.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-checkpoint-saver-listener.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-checkpoint.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-chief-session-creator.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-cluster-def.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-cluster-spec.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-coordinator.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-example.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-exponential-moving-average.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-feature-list.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-feature-lists.-feature-list-entry.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-feature-lists.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-feature.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-features.-feature-entry.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-features.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-feed-fn-hook.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-final-ops-hook.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-float-list.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-ftrl-optimizer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-global-step-waiter-hook.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-gradient-descent-optimizer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-int64-list.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-job-def.-tasks-entry.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-job-def.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-logging-tensor-hook.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-looper-thread.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-momentum-optimizer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-monitored-session.-step-context.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-monitored-session.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-nan-loss-during-training-error.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-nan-tensor-hook.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-optimizer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-profiler-hook.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-proximal-adagrad-optimizer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-proximal-gradient-descent-optimizer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-queue-runner.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-r-m-s-prop-optimizer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-saver-def.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-saver.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-scaffold.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-second-or-step-timer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-sequence-example.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-server-def.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-server.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-session-creator.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-session-manager.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-session-run-args.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-session-run-context.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-session-run-hook.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-session-run-values.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-singular-monitored-session.-step-context.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-singular-monitored-session.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-step-counter-hook.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-stop-at-step-hook.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-summary-saver-hook.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-supervisor.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-sync-replicas-optimizer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-vocab-info.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.-worker-session-creator.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.queue_runner.-queue-runner.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.train.queue_runner.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.truncated_normal_initializer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.uniform_unit_scaling_initializer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.variable_scope.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.variance_scaling_initializer.pbtxt create mode 100644 tensorflow/tools/api/golden/v2/tensorflow.zeros_initializer.pbtxt diff --git a/tensorflow/BUILD b/tensorflow/BUILD index e13a5cf802..f8cd682024 100644 --- a/tensorflow/BUILD +++ b/tensorflow/BUILD @@ -584,6 +584,7 @@ exports_files( gen_api_init_files( name = "tensorflow_python_api_gen", srcs = ["api_template.__init__.py"], + api_version = 1, root_init_template = "api_template.__init__.py", ) diff --git a/tensorflow/tools/api/golden/BUILD b/tensorflow/tools/api/golden/BUILD index ebdf42df2c..1f041ef193 100644 --- a/tensorflow/tools/api/golden/BUILD +++ b/tensorflow/tools/api/golden/BUILD @@ -7,6 +7,11 @@ package( licenses(["notice"]) # Apache 2.0 filegroup( - name = "api_golden", - srcs = glob(["*.pbtxt"]), + name = "api_golden_v1", + srcs = glob(["v1/*.pbtxt"]), +) + +filegroup( + name = "api_golden_v2", + srcs = glob(["v1/*.pbtxt"]), ) diff --git a/tensorflow/tools/api/golden/tensorflow.-aggregation-method.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-aggregation-method.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-aggregation-method.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-aggregation-method.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-attr-value.-list-value.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-attr-value.-list-value.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-attr-value.-list-value.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-attr-value.-list-value.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-attr-value.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-attr-value.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-attr-value.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-attr-value.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-conditional-accumulator-base.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-conditional-accumulator-base.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-conditional-accumulator-base.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-conditional-accumulator-base.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-conditional-accumulator.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-conditional-accumulator.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-conditional-accumulator.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-conditional-accumulator.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-config-proto.-device-count-entry.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-config-proto.-device-count-entry.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-config-proto.-device-count-entry.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-config-proto.-device-count-entry.pbtxt diff --git a/tensorflow/tools/api/golden/v1/tensorflow.-config-proto.-experimental.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-config-proto.-experimental.pbtxt new file mode 100644 index 0000000000..eb41deee13 --- /dev/null +++ b/tensorflow/tools/api/golden/v1/tensorflow.-config-proto.-experimental.pbtxt @@ -0,0 +1,24 @@ +path: "tensorflow.ConfigProto.Experimental" +tf_proto { + descriptor { + name: "Experimental" + field { + name: "collective_group_leader" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "client_handles_error_formatting" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "executor_type" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + } +} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.-config-proto.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-config-proto.pbtxt new file mode 100644 index 0000000000..e565b903d2 --- /dev/null +++ b/tensorflow/tools/api/golden/v1/tensorflow.-config-proto.pbtxt @@ -0,0 +1,148 @@ +path: "tensorflow.ConfigProto" +tf_proto { + descriptor { + name: "ConfigProto" + field { + name: "device_count" + number: 1 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.ConfigProto.DeviceCountEntry" + } + field { + name: "intra_op_parallelism_threads" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "inter_op_parallelism_threads" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "use_per_session_threads" + number: 9 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "session_inter_op_thread_pool" + number: 12 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.ThreadPoolOptionProto" + } + field { + name: "placement_period" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "device_filters" + number: 4 + label: LABEL_REPEATED + type: TYPE_STRING + } + field { + name: "gpu_options" + number: 6 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.GPUOptions" + } + field { + name: "allow_soft_placement" + number: 7 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "log_device_placement" + number: 8 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "graph_options" + number: 10 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.GraphOptions" + } + field { + name: "operation_timeout_in_ms" + number: 11 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "rpc_options" + number: 13 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.RPCOptions" + } + field { + name: "cluster_def" + number: 14 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.ClusterDef" + } + field { + name: "isolate_session_state" + number: 15 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "experimental" + number: 16 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.ConfigProto.Experimental" + } + nested_type { + name: "DeviceCountEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + options { + map_entry: true + } + } + nested_type { + name: "Experimental" + field { + name: "collective_group_leader" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "client_handles_error_formatting" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "executor_type" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + } + } +} diff --git a/tensorflow/tools/api/golden/tensorflow.-d-type.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-d-type.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-d-type.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-d-type.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-device-spec.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-device-spec.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-device-spec.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-device-spec.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-dimension.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-dimension.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-dimension.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-dimension.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-event.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-event.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-event.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-event.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-f-i-f-o-queue.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-f-i-f-o-queue.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-f-i-f-o-queue.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-f-i-f-o-queue.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-fixed-len-feature.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-fixed-len-feature.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-fixed-len-feature.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-fixed-len-feature.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-fixed-len-sequence-feature.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-fixed-len-sequence-feature.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-fixed-len-sequence-feature.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-fixed-len-sequence-feature.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-fixed-length-record-reader.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-fixed-length-record-reader.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-fixed-length-record-reader.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-fixed-length-record-reader.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-g-p-u-options.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-g-p-u-options.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-g-p-u-options.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-g-p-u-options.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-gradient-tape.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-gradient-tape.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-gradient-tape.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-gradient-tape.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-graph-def.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-graph-def.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-graph-def.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-graph-def.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-graph-keys.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-graph-keys.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-graph-keys.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-graph-keys.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-graph-options.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-graph-options.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-graph-options.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-graph-options.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-graph.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-graph.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-graph.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-graph.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-histogram-proto.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-histogram-proto.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-histogram-proto.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-histogram-proto.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-identity-reader.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-identity-reader.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-identity-reader.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-identity-reader.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-indexed-slices.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-indexed-slices.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-indexed-slices.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-indexed-slices.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-interactive-session.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-interactive-session.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-interactive-session.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-interactive-session.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-l-m-d-b-reader.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-l-m-d-b-reader.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-l-m-d-b-reader.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-l-m-d-b-reader.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-log-message.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-log-message.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-log-message.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-log-message.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-meta-graph-def.-collection-def-entry.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-meta-graph-def.-collection-def-entry.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-meta-graph-def.-collection-def-entry.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-meta-graph-def.-collection-def-entry.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-meta-graph-def.-meta-info-def.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-meta-graph-def.-meta-info-def.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-meta-graph-def.-meta-info-def.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-meta-graph-def.-meta-info-def.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-meta-graph-def.-signature-def-entry.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-meta-graph-def.-signature-def-entry.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-meta-graph-def.-signature-def-entry.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-meta-graph-def.-signature-def-entry.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-meta-graph-def.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-meta-graph-def.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-meta-graph-def.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-meta-graph-def.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-name-attr-list.-attr-entry.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-name-attr-list.-attr-entry.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-name-attr-list.-attr-entry.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-name-attr-list.-attr-entry.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-name-attr-list.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-name-attr-list.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-name-attr-list.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-name-attr-list.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-node-def.-attr-entry.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-node-def.-attr-entry.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-node-def.-attr-entry.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-node-def.-attr-entry.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-node-def.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-node-def.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-node-def.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-node-def.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-op-error.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-op-error.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-op-error.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-op-error.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-operation.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-operation.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-operation.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-operation.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-optimizer-options.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-optimizer-options.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-optimizer-options.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-optimizer-options.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-padding-f-i-f-o-queue.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-padding-f-i-f-o-queue.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-padding-f-i-f-o-queue.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-padding-f-i-f-o-queue.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-priority-queue.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-priority-queue.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-priority-queue.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-priority-queue.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-queue-base.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-queue-base.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-queue-base.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-queue-base.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-random-shuffle-queue.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-random-shuffle-queue.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-random-shuffle-queue.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-random-shuffle-queue.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-reader-base.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-reader-base.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-reader-base.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-reader-base.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-register-gradient.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-register-gradient.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-register-gradient.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-register-gradient.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-run-metadata.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-run-metadata.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-run-metadata.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-run-metadata.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-run-options.-experimental.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-run-options.-experimental.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-run-options.-experimental.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-run-options.-experimental.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-run-options.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-run-options.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-run-options.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-run-options.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-session-log.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-session-log.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-session-log.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-session-log.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-session.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-session.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-session.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-session.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-sparse-conditional-accumulator.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-sparse-conditional-accumulator.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-sparse-conditional-accumulator.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-sparse-conditional-accumulator.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-sparse-feature.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-sparse-feature.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-sparse-feature.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-sparse-feature.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-sparse-tensor-value.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-sparse-tensor-value.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-sparse-tensor-value.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-sparse-tensor-value.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-sparse-tensor.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-sparse-tensor.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-sparse-tensor.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-sparse-tensor.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-summary-metadata.-plugin-data.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-summary-metadata.-plugin-data.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-summary-metadata.-plugin-data.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-summary-metadata.-plugin-data.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-summary-metadata.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-summary-metadata.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-summary-metadata.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-summary-metadata.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-summary.-audio.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-summary.-audio.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-summary.-audio.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-summary.-audio.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-summary.-image.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-summary.-image.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-summary.-image.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-summary.-image.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-summary.-value.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-summary.-value.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-summary.-value.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-summary.-value.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-summary.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-summary.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-summary.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-summary.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-t-f-record-reader.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-t-f-record-reader.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-t-f-record-reader.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-t-f-record-reader.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-tensor-array.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-tensor-array.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-tensor-array.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-tensor-array.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-tensor-info.-coo-sparse.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-tensor-info.-coo-sparse.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-tensor-info.-coo-sparse.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-tensor-info.-coo-sparse.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-tensor-info.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-tensor-info.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-tensor-info.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-tensor-info.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-tensor-shape.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-tensor-shape.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-tensor-shape.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-tensor-shape.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-tensor.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-tensor.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-tensor.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-tensor.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-text-line-reader.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-text-line-reader.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-text-line-reader.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-text-line-reader.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-var-len-feature.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-var-len-feature.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-var-len-feature.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-var-len-feature.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-variable-aggregation.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-variable-aggregation.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-variable-aggregation.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-variable-aggregation.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-variable-scope.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-variable-scope.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-variable-scope.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-variable-scope.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-variable-synchronization.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-variable-synchronization.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-variable-synchronization.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-variable-synchronization.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-variable.-save-slice-info.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-variable.-save-slice-info.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-variable.-save-slice-info.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-variable.-save-slice-info.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-variable.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-variable.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-variable.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-variable.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.-whole-file-reader.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.-whole-file-reader.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.-whole-file-reader.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.-whole-file-reader.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.app.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.app.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.app.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.app.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.bitwise.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.bitwise.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.bitwise.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.bitwise.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.compat.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.compat.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.compat.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.compat.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.constant_initializer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.constant_initializer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.constant_initializer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.constant_initializer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.data.-dataset.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.data.-dataset.__metaclass__.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.data.-dataset.__metaclass__.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.data.-dataset.__metaclass__.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.data.-dataset.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.data.-dataset.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.data.-dataset.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.data.-dataset.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.data.-fixed-length-record-dataset.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.data.-fixed-length-record-dataset.__metaclass__.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.data.-fixed-length-record-dataset.__metaclass__.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.data.-fixed-length-record-dataset.__metaclass__.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.data.-fixed-length-record-dataset.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.data.-fixed-length-record-dataset.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.data.-fixed-length-record-dataset.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.data.-fixed-length-record-dataset.pbtxt diff --git a/tensorflow/tools/api/golden/v1/tensorflow.data.-iterator.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.data.-iterator.pbtxt new file mode 100644 index 0000000000..4f0147a523 --- /dev/null +++ b/tensorflow/tools/api/golden/v1/tensorflow.data.-iterator.pbtxt @@ -0,0 +1,46 @@ +path: "tensorflow.data.Iterator" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "initializer" + mtype: "" + } + member { + name: "output_classes" + mtype: "" + } + member { + name: "output_shapes" + mtype: "" + } + member { + name: "output_types" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'iterator_resource\', \'initializer\', \'output_types\', \'output_shapes\', \'output_classes\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_string_handle" + argspec: "args=[\'string_handle\', \'output_types\', \'output_shapes\', \'output_classes\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "from_structure" + argspec: "args=[\'output_types\', \'output_shapes\', \'shared_name\', \'output_classes\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "get_next" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "make_initializer" + argspec: "args=[\'self\', \'dataset\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "string_handle" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/tensorflow.data.-t-f-record-dataset.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.data.-t-f-record-dataset.__metaclass__.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.data.-t-f-record-dataset.__metaclass__.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.data.-t-f-record-dataset.__metaclass__.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.data.-t-f-record-dataset.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.data.-t-f-record-dataset.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.data.-t-f-record-dataset.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.data.-t-f-record-dataset.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.data.-text-line-dataset.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.data.-text-line-dataset.__metaclass__.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.data.-text-line-dataset.__metaclass__.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.data.-text-line-dataset.__metaclass__.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.data.-text-line-dataset.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.data.-text-line-dataset.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.data.-text-line-dataset.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.data.-text-line-dataset.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.data.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.data.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.data.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.data.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.debugging.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.debugging.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.debugging.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.debugging.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.distributions.-bernoulli.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.distributions.-bernoulli.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.distributions.-bernoulli.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.distributions.-bernoulli.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.distributions.-beta.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.distributions.-beta.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.distributions.-beta.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.distributions.-beta.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.distributions.-categorical.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.distributions.-categorical.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.distributions.-categorical.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.distributions.-categorical.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.distributions.-dirichlet-multinomial.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.distributions.-dirichlet-multinomial.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.distributions.-dirichlet-multinomial.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.distributions.-dirichlet-multinomial.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.distributions.-dirichlet.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.distributions.-dirichlet.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.distributions.-dirichlet.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.distributions.-dirichlet.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.distributions.-distribution.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.distributions.-distribution.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.distributions.-distribution.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.distributions.-distribution.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.distributions.-exponential.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.distributions.-exponential.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.distributions.-exponential.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.distributions.-exponential.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.distributions.-gamma.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.distributions.-gamma.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.distributions.-gamma.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.distributions.-gamma.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.distributions.-laplace.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.distributions.-laplace.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.distributions.-laplace.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.distributions.-laplace.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.distributions.-multinomial.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.distributions.-multinomial.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.distributions.-multinomial.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.distributions.-multinomial.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.distributions.-normal.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.distributions.-normal.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.distributions.-normal.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.distributions.-normal.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.distributions.-register-k-l.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.distributions.-register-k-l.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.distributions.-register-k-l.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.distributions.-register-k-l.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.distributions.-reparameterization-type.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.distributions.-reparameterization-type.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.distributions.-reparameterization-type.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.distributions.-reparameterization-type.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.distributions.-student-t.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.distributions.-student-t.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.distributions.-student-t.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.distributions.-student-t.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.distributions.-uniform.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.distributions.-uniform.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.distributions.-uniform.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.distributions.-uniform.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.distributions.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.distributions.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.distributions.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.distributions.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.dtypes.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.dtypes.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.dtypes.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.dtypes.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.errors.-aborted-error.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.errors.-aborted-error.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.errors.-aborted-error.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.errors.-aborted-error.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.errors.-already-exists-error.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.errors.-already-exists-error.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.errors.-already-exists-error.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.errors.-already-exists-error.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.errors.-cancelled-error.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.errors.-cancelled-error.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.errors.-cancelled-error.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.errors.-cancelled-error.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.errors.-data-loss-error.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.errors.-data-loss-error.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.errors.-data-loss-error.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.errors.-data-loss-error.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.errors.-deadline-exceeded-error.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.errors.-deadline-exceeded-error.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.errors.-deadline-exceeded-error.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.errors.-deadline-exceeded-error.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.errors.-failed-precondition-error.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.errors.-failed-precondition-error.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.errors.-failed-precondition-error.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.errors.-failed-precondition-error.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.errors.-internal-error.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.errors.-internal-error.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.errors.-internal-error.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.errors.-internal-error.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.errors.-invalid-argument-error.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.errors.-invalid-argument-error.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.errors.-invalid-argument-error.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.errors.-invalid-argument-error.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.errors.-not-found-error.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.errors.-not-found-error.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.errors.-not-found-error.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.errors.-not-found-error.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.errors.-op-error.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.errors.-op-error.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.errors.-op-error.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.errors.-op-error.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.errors.-out-of-range-error.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.errors.-out-of-range-error.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.errors.-out-of-range-error.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.errors.-out-of-range-error.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.errors.-permission-denied-error.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.errors.-permission-denied-error.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.errors.-permission-denied-error.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.errors.-permission-denied-error.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.errors.-resource-exhausted-error.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.errors.-resource-exhausted-error.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.errors.-resource-exhausted-error.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.errors.-resource-exhausted-error.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.errors.-unauthenticated-error.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.errors.-unauthenticated-error.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.errors.-unauthenticated-error.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.errors.-unauthenticated-error.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.errors.-unavailable-error.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.errors.-unavailable-error.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.errors.-unavailable-error.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.errors.-unavailable-error.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.errors.-unimplemented-error.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.errors.-unimplemented-error.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.errors.-unimplemented-error.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.errors.-unimplemented-error.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.errors.-unknown-error.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.errors.-unknown-error.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.errors.-unknown-error.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.errors.-unknown-error.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.errors.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.errors.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.errors.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.errors.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.errors.raise_exception_on_not_ok_status.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.errors.raise_exception_on_not_ok_status.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.errors.raise_exception_on_not_ok_status.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.errors.raise_exception_on_not_ok_status.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.-baseline-classifier.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-baseline-classifier.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.-baseline-classifier.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.-baseline-classifier.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.-baseline-regressor.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-baseline-regressor.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.-baseline-regressor.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.-baseline-regressor.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.-best-exporter.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-best-exporter.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.-best-exporter.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.-best-exporter.pbtxt diff --git a/tensorflow/tools/api/golden/v1/tensorflow.estimator.-boosted-trees-classifier.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-boosted-trees-classifier.pbtxt new file mode 100644 index 0000000000..c23b04b4ef --- /dev/null +++ b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-boosted-trees-classifier.pbtxt @@ -0,0 +1,58 @@ +path: "tensorflow.estimator.BoostedTreesClassifier" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "config" + mtype: "" + } + member { + name: "model_dir" + mtype: "" + } + member { + name: "model_fn" + mtype: "" + } + member { + name: "params" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'feature_columns\', \'n_batches_per_layer\', \'model_dir\', \'n_classes\', \'weight_column\', \'label_vocabulary\', \'n_trees\', \'max_depth\', \'learning_rate\', \'l1_regularization\', \'l2_regularization\', \'tree_complexity\', \'min_node_weight\', \'config\', \'center_bias\', \'pruning_mode\'], varargs=None, keywords=None, defaults=[\'None\', \'\', \'None\', \'None\', \'100\', \'6\', \'0.1\', \'0.0\', \'0.0\', \'0.0\', \'0.0\', \'None\', \'False\', \'none\'], " + } + member_method { + name: "eval_dir" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "evaluate" + argspec: "args=[\'self\', \'input_fn\', \'steps\', \'hooks\', \'checkpoint_path\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "export_savedmodel" + argspec: "args=[\'self\', \'export_dir_base\', \'serving_input_receiver_fn\', \'assets_extra\', \'as_text\', \'checkpoint_path\', \'strip_default_attrs\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\', \'False\'], " + } + member_method { + name: "get_variable_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_variable_value" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "latest_checkpoint" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'input_fn\', \'predict_keys\', \'hooks\', \'checkpoint_path\', \'yield_single_examples\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\'], " + } + member_method { + name: "train" + argspec: "args=[\'self\', \'input_fn\', \'hooks\', \'steps\', \'max_steps\', \'saving_listeners\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.estimator.-boosted-trees-regressor.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-boosted-trees-regressor.pbtxt new file mode 100644 index 0000000000..6878d28fff --- /dev/null +++ b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-boosted-trees-regressor.pbtxt @@ -0,0 +1,58 @@ +path: "tensorflow.estimator.BoostedTreesRegressor" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "config" + mtype: "" + } + member { + name: "model_dir" + mtype: "" + } + member { + name: "model_fn" + mtype: "" + } + member { + name: "params" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'feature_columns\', \'n_batches_per_layer\', \'model_dir\', \'label_dimension\', \'weight_column\', \'n_trees\', \'max_depth\', \'learning_rate\', \'l1_regularization\', \'l2_regularization\', \'tree_complexity\', \'min_node_weight\', \'config\', \'center_bias\', \'pruning_mode\'], varargs=None, keywords=None, defaults=[\'None\', \'\', \'None\', \'100\', \'6\', \'0.1\', \'0.0\', \'0.0\', \'0.0\', \'0.0\', \'None\', \'False\', \'none\'], " + } + member_method { + name: "eval_dir" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "evaluate" + argspec: "args=[\'self\', \'input_fn\', \'steps\', \'hooks\', \'checkpoint_path\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "export_savedmodel" + argspec: "args=[\'self\', \'export_dir_base\', \'serving_input_receiver_fn\', \'assets_extra\', \'as_text\', \'checkpoint_path\', \'strip_default_attrs\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\', \'False\'], " + } + member_method { + name: "get_variable_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_variable_value" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "latest_checkpoint" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'input_fn\', \'predict_keys\', \'hooks\', \'checkpoint_path\', \'yield_single_examples\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\'], " + } + member_method { + name: "train" + argspec: "args=[\'self\', \'input_fn\', \'hooks\', \'steps\', \'max_steps\', \'saving_listeners\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.-d-n-n-classifier.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-d-n-n-classifier.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.-d-n-n-classifier.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.-d-n-n-classifier.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.-d-n-n-linear-combined-classifier.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-d-n-n-linear-combined-classifier.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.-d-n-n-linear-combined-classifier.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.-d-n-n-linear-combined-classifier.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.-d-n-n-linear-combined-regressor.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-d-n-n-linear-combined-regressor.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.-d-n-n-linear-combined-regressor.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.-d-n-n-linear-combined-regressor.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.-d-n-n-regressor.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-d-n-n-regressor.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.-d-n-n-regressor.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.-d-n-n-regressor.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.-estimator-spec.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-estimator-spec.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.-estimator-spec.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.-estimator-spec.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.-estimator.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-estimator.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.-estimator.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.-estimator.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.-eval-spec.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-eval-spec.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.-eval-spec.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.-eval-spec.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.-exporter.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-exporter.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.-exporter.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.-exporter.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.-final-exporter.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-final-exporter.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.-final-exporter.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.-final-exporter.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.-latest-exporter.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-latest-exporter.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.-latest-exporter.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.-latest-exporter.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.-linear-classifier.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-linear-classifier.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.-linear-classifier.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.-linear-classifier.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.-linear-regressor.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-linear-regressor.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.-linear-regressor.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.-linear-regressor.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.-mode-keys.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-mode-keys.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.-mode-keys.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.-mode-keys.pbtxt diff --git a/tensorflow/tools/api/golden/v1/tensorflow.estimator.-run-config.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-run-config.pbtxt new file mode 100644 index 0000000000..bf1f94b6ae --- /dev/null +++ b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-run-config.pbtxt @@ -0,0 +1,105 @@ +path: "tensorflow.estimator.RunConfig" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "cluster_spec" + mtype: "" + } + member { + name: "device_fn" + mtype: "" + } + member { + name: "eval_distribute" + mtype: "" + } + member { + name: "evaluation_master" + mtype: "" + } + member { + name: "global_id_in_cluster" + mtype: "" + } + member { + name: "is_chief" + mtype: "" + } + member { + name: "keep_checkpoint_every_n_hours" + mtype: "" + } + member { + name: "keep_checkpoint_max" + mtype: "" + } + member { + name: "log_step_count_steps" + mtype: "" + } + member { + name: "master" + mtype: "" + } + member { + name: "model_dir" + mtype: "" + } + member { + name: "num_ps_replicas" + mtype: "" + } + member { + name: "num_worker_replicas" + mtype: "" + } + member { + name: "protocol" + mtype: "" + } + member { + name: "save_checkpoints_secs" + mtype: "" + } + member { + name: "save_checkpoints_steps" + mtype: "" + } + member { + name: "save_summary_steps" + mtype: "" + } + member { + name: "service" + mtype: "" + } + member { + name: "session_config" + mtype: "" + } + member { + name: "task_id" + mtype: "" + } + member { + name: "task_type" + mtype: "" + } + member { + name: "tf_random_seed" + mtype: "" + } + member { + name: "train_distribute" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'model_dir\', \'tf_random_seed\', \'save_summary_steps\', \'save_checkpoints_steps\', \'save_checkpoints_secs\', \'session_config\', \'keep_checkpoint_max\', \'keep_checkpoint_every_n_hours\', \'log_step_count_steps\', \'train_distribute\', \'device_fn\', \'protocol\', \'eval_distribute\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'100\', \'\', \'\', \'None\', \'5\', \'10000\', \'100\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "replace" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.-train-spec.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-train-spec.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.-train-spec.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.-train-spec.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.-vocab-info.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-vocab-info.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.-vocab-info.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.-vocab-info.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.-warm-start-settings.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.-warm-start-settings.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.-warm-start-settings.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.-warm-start-settings.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.export.-classification-output.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.export.-classification-output.__metaclass__.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.export.-classification-output.__metaclass__.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.export.-classification-output.__metaclass__.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.export.-classification-output.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.export.-classification-output.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.export.-classification-output.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.export.-classification-output.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.export.-export-output.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.export.-export-output.__metaclass__.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.export.-export-output.__metaclass__.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.export.-export-output.__metaclass__.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.export.-export-output.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.export.-export-output.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.export.-export-output.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.export.-export-output.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.export.-predict-output.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.export.-predict-output.__metaclass__.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.export.-predict-output.__metaclass__.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.export.-predict-output.__metaclass__.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.export.-predict-output.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.export.-predict-output.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.export.-predict-output.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.export.-predict-output.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.export.-regression-output.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.export.-regression-output.__metaclass__.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.export.-regression-output.__metaclass__.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.export.-regression-output.__metaclass__.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.export.-regression-output.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.export.-regression-output.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.export.-regression-output.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.export.-regression-output.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.export.-serving-input-receiver.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.export.-serving-input-receiver.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.export.-serving-input-receiver.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.export.-serving-input-receiver.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.export.-tensor-serving-input-receiver.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.export.-tensor-serving-input-receiver.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.export.-tensor-serving-input-receiver.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.export.-tensor-serving-input-receiver.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.export.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.export.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.export.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.export.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.inputs.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.inputs.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.inputs.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.inputs.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.estimator.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.estimator.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.estimator.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.estimator.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.feature_column.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.feature_column.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.feature_column.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.feature_column.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.gfile.-fast-g-file.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.gfile.-fast-g-file.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.gfile.-fast-g-file.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.gfile.-fast-g-file.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.gfile.-g-file.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.gfile.-g-file.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.gfile.-g-file.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.gfile.-g-file.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.gfile.-open.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.gfile.-open.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.gfile.-open.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.gfile.-open.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.gfile.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.gfile.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.gfile.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.gfile.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.graph_util.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.graph_util.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.graph_util.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.graph_util.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.image.-resize-method.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.image.-resize-method.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.image.-resize-method.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.image.-resize-method.pbtxt diff --git a/tensorflow/tools/api/golden/v1/tensorflow.image.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.image.pbtxt new file mode 100644 index 0000000000..5c46dc5ee7 --- /dev/null +++ b/tensorflow/tools/api/golden/v1/tensorflow.image.pbtxt @@ -0,0 +1,251 @@ +path: "tensorflow.image" +tf_module { + member { + name: "ResizeMethod" + mtype: "" + } + member_method { + name: "adjust_brightness" + argspec: "args=[\'image\', \'delta\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "adjust_contrast" + argspec: "args=[\'images\', \'contrast_factor\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "adjust_gamma" + argspec: "args=[\'image\', \'gamma\', \'gain\'], varargs=None, keywords=None, defaults=[\'1\', \'1\'], " + } + member_method { + name: "adjust_hue" + argspec: "args=[\'image\', \'delta\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "adjust_jpeg_quality" + argspec: "args=[\'image\', \'jpeg_quality\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "adjust_saturation" + argspec: "args=[\'image\', \'saturation_factor\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "central_crop" + argspec: "args=[\'image\', \'central_fraction\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "convert_image_dtype" + argspec: "args=[\'image\', \'dtype\', \'saturate\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "crop_and_resize" + argspec: "args=[\'image\', \'boxes\', \'box_ind\', \'crop_size\', \'method\', \'extrapolation_value\', \'name\'], varargs=None, keywords=None, defaults=[\'bilinear\', \'0\', \'None\'], " + } + member_method { + name: "crop_to_bounding_box" + argspec: "args=[\'image\', \'offset_height\', \'offset_width\', \'target_height\', \'target_width\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "decode_and_crop_jpeg" + argspec: "args=[\'contents\', \'crop_window\', \'channels\', \'ratio\', \'fancy_upscaling\', \'try_recover_truncated\', \'acceptable_fraction\', \'dct_method\', \'name\'], varargs=None, keywords=None, defaults=[\'0\', \'1\', \'True\', \'False\', \'1\', \'\', \'None\'], " + } + member_method { + name: "decode_bmp" + argspec: "args=[\'contents\', \'channels\', \'name\'], varargs=None, keywords=None, defaults=[\'0\', \'None\'], " + } + member_method { + name: "decode_gif" + argspec: "args=[\'contents\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "decode_image" + argspec: "args=[\'contents\', \'channels\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \"\", \'None\'], " + } + member_method { + name: "decode_jpeg" + argspec: "args=[\'contents\', \'channels\', \'ratio\', \'fancy_upscaling\', \'try_recover_truncated\', \'acceptable_fraction\', \'dct_method\', \'name\'], varargs=None, keywords=None, defaults=[\'0\', \'1\', \'True\', \'False\', \'1\', \'\', \'None\'], " + } + member_method { + name: "decode_png" + argspec: "args=[\'contents\', \'channels\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\'0\', \"\", \'None\'], " + } + member_method { + name: "draw_bounding_boxes" + argspec: "args=[\'images\', \'boxes\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "encode_jpeg" + argspec: "args=[\'image\', \'format\', \'quality\', \'progressive\', \'optimize_size\', \'chroma_downsampling\', \'density_unit\', \'x_density\', \'y_density\', \'xmp_metadata\', \'name\'], varargs=None, keywords=None, defaults=[\'\', \'95\', \'False\', \'False\', \'True\', \'in\', \'300\', \'300\', \'\', \'None\'], " + } + member_method { + name: "encode_png" + argspec: "args=[\'image\', \'compression\', \'name\'], varargs=None, keywords=None, defaults=[\'-1\', \'None\'], " + } + member_method { + name: "extract_glimpse" + argspec: "args=[\'input\', \'size\', \'offsets\', \'centered\', \'normalized\', \'uniform_noise\', \'name\'], varargs=None, keywords=None, defaults=[\'True\', \'True\', \'True\', \'None\'], " + } + member_method { + name: "extract_image_patches" + argspec: "args=[\'images\', \'ksizes\', \'strides\', \'rates\', \'padding\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "extract_jpeg_shape" + argspec: "args=[\'contents\', \'output_type\', \'name\'], varargs=None, keywords=None, defaults=[\"\", \'None\'], " + } + member_method { + name: "flip_left_right" + argspec: "args=[\'image\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "flip_up_down" + argspec: "args=[\'image\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "grayscale_to_rgb" + argspec: "args=[\'images\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "hsv_to_rgb" + argspec: "args=[\'images\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "image_gradients" + argspec: "args=[\'image\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "is_jpeg" + argspec: "args=[\'contents\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "non_max_suppression" + argspec: "args=[\'boxes\', \'scores\', \'max_output_size\', \'iou_threshold\', \'score_threshold\', \'name\'], varargs=None, keywords=None, defaults=[\'0.5\', \'-inf\', \'None\'], " + } + member_method { + name: "non_max_suppression_overlaps" + argspec: "args=[\'overlaps\', \'scores\', \'max_output_size\', \'overlap_threshold\', \'score_threshold\', \'name\'], varargs=None, keywords=None, defaults=[\'0.5\', \'-inf\', \'None\'], " + } + member_method { + name: "non_max_suppression_padded" + argspec: "args=[\'boxes\', \'scores\', \'max_output_size\', \'iou_threshold\', \'score_threshold\', \'pad_to_max_output_size\', \'name\'], varargs=None, keywords=None, defaults=[\'0.5\', \'-inf\', \'False\', \'None\'], " + } + member_method { + name: "pad_to_bounding_box" + argspec: "args=[\'image\', \'offset_height\', \'offset_width\', \'target_height\', \'target_width\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "per_image_standardization" + argspec: "args=[\'image\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "psnr" + argspec: "args=[\'a\', \'b\', \'max_val\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "random_brightness" + argspec: "args=[\'image\', \'max_delta\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "random_contrast" + argspec: "args=[\'image\', \'lower\', \'upper\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "random_flip_left_right" + argspec: "args=[\'image\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "random_flip_up_down" + argspec: "args=[\'image\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "random_hue" + argspec: "args=[\'image\', \'max_delta\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "random_jpeg_quality" + argspec: "args=[\'image\', \'min_jpeg_quality\', \'max_jpeg_quality\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "random_saturation" + argspec: "args=[\'image\', \'lower\', \'upper\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "resize_area" + argspec: "args=[\'images\', \'size\', \'align_corners\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "resize_bicubic" + argspec: "args=[\'images\', \'size\', \'align_corners\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "resize_bilinear" + argspec: "args=[\'images\', \'size\', \'align_corners\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "resize_image_with_crop_or_pad" + argspec: "args=[\'image\', \'target_height\', \'target_width\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "resize_image_with_pad" + argspec: "args=[\'image\', \'target_height\', \'target_width\', \'method\'], varargs=None, keywords=None, defaults=[\'0\'], " + } + member_method { + name: "resize_images" + argspec: "args=[\'images\', \'size\', \'method\', \'align_corners\', \'preserve_aspect_ratio\'], varargs=None, keywords=None, defaults=[\'0\', \'False\', \'False\'], " + } + member_method { + name: "resize_nearest_neighbor" + argspec: "args=[\'images\', \'size\', \'align_corners\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "rgb_to_grayscale" + argspec: "args=[\'images\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "rgb_to_hsv" + argspec: "args=[\'images\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "rgb_to_yiq" + argspec: "args=[\'images\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "rgb_to_yuv" + argspec: "args=[\'images\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "rot90" + argspec: "args=[\'image\', \'k\', \'name\'], varargs=None, keywords=None, defaults=[\'1\', \'None\'], " + } + member_method { + name: "sample_distorted_bounding_box" + argspec: "args=[\'image_size\', \'bounding_boxes\', \'seed\', \'seed2\', \'min_object_covered\', \'aspect_ratio_range\', \'area_range\', \'max_attempts\', \'use_image_if_no_bounding_boxes\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'0.1\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "sobel_edges" + argspec: "args=[\'image\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "ssim" + argspec: "args=[\'img1\', \'img2\', \'max_val\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "ssim_multiscale" + argspec: "args=[\'img1\', \'img2\', \'max_val\', \'power_factors\'], varargs=None, keywords=None, defaults=[\'(0.0448, 0.2856, 0.3001, 0.2363, 0.1333)\'], " + } + member_method { + name: "total_variation" + argspec: "args=[\'images\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "transpose_image" + argspec: "args=[\'image\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "yiq_to_rgb" + argspec: "args=[\'images\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "yuv_to_rgb" + argspec: "args=[\'images\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/tensorflow.initializers.constant.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.initializers.constant.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.initializers.constant.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.initializers.constant.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.initializers.identity.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.initializers.identity.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.initializers.identity.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.initializers.identity.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.initializers.ones.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.initializers.ones.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.initializers.ones.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.initializers.ones.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.initializers.orthogonal.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.initializers.orthogonal.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.initializers.orthogonal.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.initializers.orthogonal.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.initializers.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.initializers.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.initializers.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.initializers.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.initializers.random_normal.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.initializers.random_normal.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.initializers.random_normal.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.initializers.random_normal.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.initializers.random_uniform.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.initializers.random_uniform.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.initializers.random_uniform.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.initializers.random_uniform.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.initializers.truncated_normal.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.initializers.truncated_normal.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.initializers.truncated_normal.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.initializers.truncated_normal.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.initializers.uniform_unit_scaling.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.initializers.uniform_unit_scaling.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.initializers.uniform_unit_scaling.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.initializers.uniform_unit_scaling.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.initializers.variance_scaling.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.initializers.variance_scaling.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.initializers.variance_scaling.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.initializers.variance_scaling.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.initializers.zeros.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.initializers.zeros.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.initializers.zeros.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.initializers.zeros.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.io.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.io.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.io.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.io.pbtxt diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.-model.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.-model.pbtxt new file mode 100644 index 0000000000..e579fe6a1a --- /dev/null +++ b/tensorflow/tools/api/golden/v1/tensorflow.keras.-model.pbtxt @@ -0,0 +1,268 @@ +path: "tensorflow.keras.Model" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "input_spec" + mtype: "" + } + member { + name: "layers" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "state_updates" + mtype: "" + } + member { + name: "stateful" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "uses_learning_phase" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\', \'None\'], " + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'training\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "compile" + argspec: "args=[\'self\', \'optimizer\', \'loss\', \'metrics\', \'loss_weights\', \'sample_weight_mode\', \'weighted_metrics\', \'target_tensors\', \'distribute\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "evaluate" + argspec: "args=[\'self\', \'x\', \'y\', \'batch_size\', \'verbose\', \'sample_weight\', \'steps\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'1\', \'None\', \'None\'], " + } + member_method { + name: "evaluate_generator" + argspec: "args=[\'self\', \'generator\', \'steps\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'verbose\'], varargs=None, keywords=None, defaults=[\'None\', \'10\', \'1\', \'False\', \'0\'], " + } + member_method { + name: "fit" + argspec: "args=[\'self\', \'x\', \'y\', \'batch_size\', \'epochs\', \'verbose\', \'callbacks\', \'validation_split\', \'validation_data\', \'shuffle\', \'class_weight\', \'sample_weight\', \'initial_epoch\', \'steps_per_epoch\', \'validation_steps\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\', \'None\', \'1\', \'1\', \'None\', \'0.0\', \'None\', \'True\', \'None\', \'None\', \'0\', \'None\', \'None\'], " + } + member_method { + name: "fit_generator" + argspec: "args=[\'self\', \'generator\', \'steps_per_epoch\', \'epochs\', \'verbose\', \'callbacks\', \'validation_data\', \'validation_steps\', \'class_weight\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'shuffle\', \'initial_epoch\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'1\', \'None\', \'None\', \'None\', \'None\', \'10\', \'1\', \'False\', \'True\', \'0\'], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_layer" + argspec: "args=[\'self\', \'name\', \'index\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "load_weights" + argspec: "args=[\'self\', \'filepath\', \'by_name\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'x\', \'batch_size\', \'verbose\', \'steps\'], varargs=None, keywords=None, defaults=[\'None\', \'0\', \'None\'], " + } + member_method { + name: "predict_generator" + argspec: "args=[\'self\', \'generator\', \'steps\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'verbose\'], varargs=None, keywords=None, defaults=[\'None\', \'10\', \'1\', \'False\', \'0\'], " + } + member_method { + name: "predict_on_batch" + argspec: "args=[\'self\', \'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "reset_states" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "save" + argspec: "args=[\'self\', \'filepath\', \'overwrite\', \'include_optimizer\'], varargs=None, keywords=None, defaults=[\'True\', \'True\'], " + } + member_method { + name: "save_weights" + argspec: "args=[\'self\', \'filepath\', \'overwrite\', \'save_format\'], varargs=None, keywords=None, defaults=[\'True\', \'None\'], " + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "summary" + argspec: "args=[\'self\', \'line_length\', \'positions\', \'print_fn\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "test_on_batch" + argspec: "args=[\'self\', \'x\', \'y\', \'sample_weight\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "to_json" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "to_yaml" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "train_on_batch" + argspec: "args=[\'self\', \'x\', \'y\', \'sample_weight\', \'class_weight\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.-sequential.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.-sequential.pbtxt new file mode 100644 index 0000000000..6f05cdd093 --- /dev/null +++ b/tensorflow/tools/api/golden/v1/tensorflow.keras.-sequential.pbtxt @@ -0,0 +1,289 @@ +path: "tensorflow.keras.Sequential" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "input_spec" + mtype: "" + } + member { + name: "layers" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "state_updates" + mtype: "" + } + member { + name: "stateful" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "uses_learning_phase" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'layers\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "add" + argspec: "args=[\'self\', \'layer\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\', \'None\'], " + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'training\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "compile" + argspec: "args=[\'self\', \'optimizer\', \'loss\', \'metrics\', \'loss_weights\', \'sample_weight_mode\', \'weighted_metrics\', \'target_tensors\', \'distribute\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "evaluate" + argspec: "args=[\'self\', \'x\', \'y\', \'batch_size\', \'verbose\', \'sample_weight\', \'steps\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'1\', \'None\', \'None\'], " + } + member_method { + name: "evaluate_generator" + argspec: "args=[\'self\', \'generator\', \'steps\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'verbose\'], varargs=None, keywords=None, defaults=[\'None\', \'10\', \'1\', \'False\', \'0\'], " + } + member_method { + name: "fit" + argspec: "args=[\'self\', \'x\', \'y\', \'batch_size\', \'epochs\', \'verbose\', \'callbacks\', \'validation_split\', \'validation_data\', \'shuffle\', \'class_weight\', \'sample_weight\', \'initial_epoch\', \'steps_per_epoch\', \'validation_steps\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\', \'None\', \'1\', \'1\', \'None\', \'0.0\', \'None\', \'True\', \'None\', \'None\', \'0\', \'None\', \'None\'], " + } + member_method { + name: "fit_generator" + argspec: "args=[\'self\', \'generator\', \'steps_per_epoch\', \'epochs\', \'verbose\', \'callbacks\', \'validation_data\', \'validation_steps\', \'class_weight\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'shuffle\', \'initial_epoch\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'1\', \'None\', \'None\', \'None\', \'None\', \'10\', \'1\', \'False\', \'True\', \'0\'], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_layer" + argspec: "args=[\'self\', \'name\', \'index\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "load_weights" + argspec: "args=[\'self\', \'filepath\', \'by_name\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "pop" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'x\', \'batch_size\', \'verbose\', \'steps\'], varargs=None, keywords=None, defaults=[\'None\', \'0\', \'None\'], " + } + member_method { + name: "predict_classes" + argspec: "args=[\'self\', \'x\', \'batch_size\', \'verbose\'], varargs=None, keywords=None, defaults=[\'32\', \'0\'], " + } + member_method { + name: "predict_generator" + argspec: "args=[\'self\', \'generator\', \'steps\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'verbose\'], varargs=None, keywords=None, defaults=[\'None\', \'10\', \'1\', \'False\', \'0\'], " + } + member_method { + name: "predict_on_batch" + argspec: "args=[\'self\', \'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "predict_proba" + argspec: "args=[\'self\', \'x\', \'batch_size\', \'verbose\'], varargs=None, keywords=None, defaults=[\'32\', \'0\'], " + } + member_method { + name: "reset_states" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "save" + argspec: "args=[\'self\', \'filepath\', \'overwrite\', \'include_optimizer\'], varargs=None, keywords=None, defaults=[\'True\', \'True\'], " + } + member_method { + name: "save_weights" + argspec: "args=[\'self\', \'filepath\', \'overwrite\', \'save_format\'], varargs=None, keywords=None, defaults=[\'True\', \'None\'], " + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "summary" + argspec: "args=[\'self\', \'line_length\', \'positions\', \'print_fn\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "symbolic_set_inputs" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "test_on_batch" + argspec: "args=[\'self\', \'x\', \'y\', \'sample_weight\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "to_json" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "to_yaml" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "train_on_batch" + argspec: "args=[\'self\', \'x\', \'y\', \'sample_weight\', \'class_weight\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.activations.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.activations.pbtxt new file mode 100644 index 0000000000..2e9de9ebb2 --- /dev/null +++ b/tensorflow/tools/api/golden/v1/tensorflow.keras.activations.pbtxt @@ -0,0 +1,55 @@ +path: "tensorflow.keras.activations" +tf_module { + member_method { + name: "deserialize" + argspec: "args=[\'name\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "elu" + argspec: "args=[\'x\', \'alpha\'], varargs=None, keywords=None, defaults=[\'1.0\'], " + } + member_method { + name: "get" + argspec: "args=[\'identifier\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "hard_sigmoid" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "linear" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "relu" + argspec: "args=[\'x\', \'alpha\', \'max_value\', \'threshold\'], varargs=None, keywords=None, defaults=[\'0.0\', \'None\', \'0\'], " + } + member_method { + name: "selu" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "serialize" + argspec: "args=[\'activation\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "sigmoid" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "softmax" + argspec: "args=[\'x\', \'axis\'], varargs=None, keywords=None, defaults=[\'-1\'], " + } + member_method { + name: "softplus" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "softsign" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "tanh" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/tensorflow.keras.applications.densenet.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.densenet.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.applications.densenet.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.applications.densenet.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.applications.inception_resnet_v2.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.inception_resnet_v2.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.applications.inception_resnet_v2.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.applications.inception_resnet_v2.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.applications.inception_v3.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.inception_v3.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.applications.inception_v3.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.applications.inception_v3.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.applications.mobilenet.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.mobilenet.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.applications.mobilenet.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.applications.mobilenet.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.applications.nasnet.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.nasnet.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.applications.nasnet.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.applications.nasnet.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.applications.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.applications.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.applications.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.applications.resnet50.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.resnet50.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.applications.resnet50.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.applications.resnet50.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.applications.vgg16.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.vgg16.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.applications.vgg16.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.applications.vgg16.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.applications.vgg19.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.vgg19.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.applications.vgg19.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.applications.vgg19.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.applications.xception.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.xception.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.applications.xception.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.applications.xception.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.backend.name_scope.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.backend.name_scope.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.backend.name_scope.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.backend.name_scope.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.backend.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.backend.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.backend.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.backend.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.callbacks.-base-logger.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-base-logger.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.callbacks.-base-logger.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-base-logger.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.callbacks.-c-s-v-logger.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-c-s-v-logger.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.callbacks.-c-s-v-logger.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-c-s-v-logger.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.callbacks.-callback.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-callback.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.callbacks.-callback.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-callback.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.callbacks.-early-stopping.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-early-stopping.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.callbacks.-early-stopping.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-early-stopping.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.callbacks.-history.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-history.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.callbacks.-history.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-history.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.callbacks.-lambda-callback.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-lambda-callback.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.callbacks.-lambda-callback.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-lambda-callback.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.callbacks.-learning-rate-scheduler.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-learning-rate-scheduler.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.callbacks.-learning-rate-scheduler.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-learning-rate-scheduler.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.callbacks.-model-checkpoint.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-model-checkpoint.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.callbacks.-model-checkpoint.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-model-checkpoint.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.callbacks.-progbar-logger.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-progbar-logger.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.callbacks.-progbar-logger.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-progbar-logger.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.callbacks.-reduce-l-r-on-plateau.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-reduce-l-r-on-plateau.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.callbacks.-reduce-l-r-on-plateau.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-reduce-l-r-on-plateau.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.callbacks.-remote-monitor.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-remote-monitor.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.callbacks.-remote-monitor.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-remote-monitor.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.callbacks.-tensor-board.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-tensor-board.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.callbacks.-tensor-board.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-tensor-board.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.callbacks.-terminate-on-na-n.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-terminate-on-na-n.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.callbacks.-terminate-on-na-n.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.-terminate-on-na-n.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.callbacks.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.callbacks.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.callbacks.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.constraints.-constraint.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.constraints.-constraint.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.constraints.-constraint.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.constraints.-constraint.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.constraints.-max-norm.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.constraints.-max-norm.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.constraints.-max-norm.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.constraints.-max-norm.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.constraints.-min-max-norm.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.constraints.-min-max-norm.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.constraints.-min-max-norm.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.constraints.-min-max-norm.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.constraints.-non-neg.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.constraints.-non-neg.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.constraints.-non-neg.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.constraints.-non-neg.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.constraints.-unit-norm.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.constraints.-unit-norm.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.constraints.-unit-norm.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.constraints.-unit-norm.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.constraints.max_norm.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.constraints.max_norm.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.constraints.max_norm.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.constraints.max_norm.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.constraints.min_max_norm.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.constraints.min_max_norm.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.constraints.min_max_norm.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.constraints.min_max_norm.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.constraints.non_neg.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.constraints.non_neg.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.constraints.non_neg.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.constraints.non_neg.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.constraints.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.constraints.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.constraints.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.constraints.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.constraints.unit_norm.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.constraints.unit_norm.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.constraints.unit_norm.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.constraints.unit_norm.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.datasets.boston_housing.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.datasets.boston_housing.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.datasets.boston_housing.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.datasets.boston_housing.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.datasets.cifar10.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.datasets.cifar10.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.datasets.cifar10.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.datasets.cifar10.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.datasets.cifar100.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.datasets.cifar100.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.datasets.cifar100.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.datasets.cifar100.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.datasets.fashion_mnist.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.datasets.fashion_mnist.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.datasets.fashion_mnist.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.datasets.fashion_mnist.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.datasets.imdb.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.datasets.imdb.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.datasets.imdb.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.datasets.imdb.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.datasets.mnist.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.datasets.mnist.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.datasets.mnist.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.datasets.mnist.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.datasets.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.datasets.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.datasets.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.datasets.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.datasets.reuters.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.datasets.reuters.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.datasets.reuters.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.datasets.reuters.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.estimator.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.estimator.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.estimator.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.estimator.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.initializers.-constant.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.-constant.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.initializers.-constant.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.-constant.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.initializers.-identity.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.-identity.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.initializers.-identity.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.-identity.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.initializers.-initializer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.-initializer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.initializers.-initializer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.-initializer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.initializers.-ones.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.-ones.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.initializers.-ones.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.-ones.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.initializers.-orthogonal.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.-orthogonal.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.initializers.-orthogonal.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.-orthogonal.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.initializers.-random-normal.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.-random-normal.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.initializers.-random-normal.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.-random-normal.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.initializers.-random-uniform.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.-random-uniform.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.initializers.-random-uniform.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.-random-uniform.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.initializers.-truncated-normal.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.-truncated-normal.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.initializers.-truncated-normal.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.-truncated-normal.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.initializers.-variance-scaling.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.-variance-scaling.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.initializers.-variance-scaling.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.-variance-scaling.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.initializers.-zeros.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.-zeros.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.initializers.-zeros.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.-zeros.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.initializers.constant.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.constant.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.initializers.constant.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.constant.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.initializers.identity.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.identity.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.initializers.identity.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.identity.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.initializers.normal.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.normal.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.initializers.normal.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.normal.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.initializers.ones.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.ones.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.initializers.ones.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.ones.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.initializers.orthogonal.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.orthogonal.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.initializers.orthogonal.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.orthogonal.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.initializers.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.initializers.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.initializers.random_normal.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.random_normal.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.initializers.random_normal.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.random_normal.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.initializers.random_uniform.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.random_uniform.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.initializers.random_uniform.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.random_uniform.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.initializers.truncated_normal.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.truncated_normal.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.initializers.truncated_normal.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.truncated_normal.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.initializers.uniform.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.uniform.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.initializers.uniform.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.uniform.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.initializers.zeros.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.zeros.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.initializers.zeros.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.initializers.zeros.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-activation.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-activation.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-activation.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-activation.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-activity-regularization.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-activity-regularization.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-activity-regularization.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-activity-regularization.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-add.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-add.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-add.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-add.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-alpha-dropout.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-alpha-dropout.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-alpha-dropout.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-alpha-dropout.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-average-pooling1-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-average-pooling1-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-average-pooling1-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-average-pooling1-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-average-pooling2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-average-pooling2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-average-pooling2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-average-pooling2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-average-pooling3-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-average-pooling3-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-average-pooling3-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-average-pooling3-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-average.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-average.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-average.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-average.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-avg-pool1-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-avg-pool1-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-avg-pool1-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-avg-pool1-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-avg-pool2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-avg-pool2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-avg-pool2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-avg-pool2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-avg-pool3-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-avg-pool3-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-avg-pool3-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-avg-pool3-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-batch-normalization.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-batch-normalization.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-batch-normalization.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-batch-normalization.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-bidirectional.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-bidirectional.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-bidirectional.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-bidirectional.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-concatenate.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-concatenate.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-concatenate.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-concatenate.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-conv-l-s-t-m2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-conv-l-s-t-m2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-conv-l-s-t-m2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-conv-l-s-t-m2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-conv1-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-conv1-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-conv1-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-conv1-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-conv2-d-transpose.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-conv2-d-transpose.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-conv2-d-transpose.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-conv2-d-transpose.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-conv2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-conv2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-conv2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-conv2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-conv3-d-transpose.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-conv3-d-transpose.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-conv3-d-transpose.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-conv3-d-transpose.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-conv3-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-conv3-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-conv3-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-conv3-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-convolution1-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-convolution1-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-convolution1-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-convolution1-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-convolution2-d-transpose.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-convolution2-d-transpose.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-convolution2-d-transpose.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-convolution2-d-transpose.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-convolution2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-convolution2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-convolution2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-convolution2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-convolution3-d-transpose.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-convolution3-d-transpose.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-convolution3-d-transpose.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-convolution3-d-transpose.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-convolution3-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-convolution3-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-convolution3-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-convolution3-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-cropping1-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-cropping1-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-cropping1-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-cropping1-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-cropping2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-cropping2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-cropping2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-cropping2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-cropping3-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-cropping3-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-cropping3-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-cropping3-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-cu-d-n-n-g-r-u.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-cu-d-n-n-g-r-u.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-cu-d-n-n-g-r-u.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-cu-d-n-n-g-r-u.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-cu-d-n-n-l-s-t-m.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-cu-d-n-n-l-s-t-m.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-cu-d-n-n-l-s-t-m.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-cu-d-n-n-l-s-t-m.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-dense.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-dense.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-dense.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-dense.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-depthwise-conv2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-depthwise-conv2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-depthwise-conv2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-depthwise-conv2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-dot.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-dot.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-dot.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-dot.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-dropout.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-dropout.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-dropout.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-dropout.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-e-l-u.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-e-l-u.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-e-l-u.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-e-l-u.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-embedding.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-embedding.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-embedding.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-embedding.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-flatten.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-flatten.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-flatten.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-flatten.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-g-r-u-cell.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-g-r-u-cell.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-g-r-u-cell.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-g-r-u-cell.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-g-r-u.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-g-r-u.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-g-r-u.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-g-r-u.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-gaussian-dropout.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-gaussian-dropout.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-gaussian-dropout.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-gaussian-dropout.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-gaussian-noise.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-gaussian-noise.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-gaussian-noise.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-gaussian-noise.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-global-average-pooling1-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-average-pooling1-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-global-average-pooling1-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-average-pooling1-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-global-average-pooling2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-average-pooling2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-global-average-pooling2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-average-pooling2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-global-average-pooling3-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-average-pooling3-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-global-average-pooling3-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-average-pooling3-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-global-avg-pool1-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-avg-pool1-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-global-avg-pool1-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-avg-pool1-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-global-avg-pool2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-avg-pool2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-global-avg-pool2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-avg-pool2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-global-avg-pool3-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-avg-pool3-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-global-avg-pool3-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-avg-pool3-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-global-max-pool1-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-max-pool1-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-global-max-pool1-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-max-pool1-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-global-max-pool2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-max-pool2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-global-max-pool2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-max-pool2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-global-max-pool3-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-max-pool3-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-global-max-pool3-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-max-pool3-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-global-max-pooling1-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-max-pooling1-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-global-max-pooling1-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-max-pooling1-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-global-max-pooling2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-max-pooling2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-global-max-pooling2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-max-pooling2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-global-max-pooling3-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-max-pooling3-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-global-max-pooling3-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-global-max-pooling3-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-input-layer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-input-layer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-input-layer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-input-layer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-input-spec.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-input-spec.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-input-spec.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-input-spec.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-l-s-t-m-cell.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-l-s-t-m-cell.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-l-s-t-m-cell.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-l-s-t-m-cell.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-l-s-t-m.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-l-s-t-m.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-l-s-t-m.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-l-s-t-m.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-lambda.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-lambda.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-lambda.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-lambda.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-layer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-layer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-layer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-layer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-leaky-re-l-u.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-leaky-re-l-u.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-leaky-re-l-u.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-leaky-re-l-u.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-locally-connected1-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-locally-connected1-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-locally-connected1-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-locally-connected1-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-locally-connected2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-locally-connected2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-locally-connected2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-locally-connected2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-masking.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-masking.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-masking.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-masking.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-max-pool1-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-max-pool1-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-max-pool1-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-max-pool1-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-max-pool2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-max-pool2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-max-pool2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-max-pool2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-max-pool3-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-max-pool3-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-max-pool3-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-max-pool3-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-max-pooling1-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-max-pooling1-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-max-pooling1-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-max-pooling1-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-max-pooling2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-max-pooling2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-max-pooling2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-max-pooling2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-max-pooling3-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-max-pooling3-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-max-pooling3-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-max-pooling3-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-maximum.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-maximum.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-maximum.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-maximum.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-minimum.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-minimum.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-minimum.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-minimum.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-multiply.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-multiply.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-multiply.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-multiply.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-p-re-l-u.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-p-re-l-u.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-p-re-l-u.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-p-re-l-u.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-permute.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-permute.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-permute.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-permute.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-r-n-n.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-r-n-n.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-r-n-n.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-r-n-n.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-re-l-u.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-re-l-u.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-re-l-u.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-re-l-u.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-repeat-vector.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-repeat-vector.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-repeat-vector.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-repeat-vector.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-reshape.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-reshape.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-reshape.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-reshape.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-separable-conv1-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-separable-conv1-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-separable-conv1-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-separable-conv1-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-separable-conv2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-separable-conv2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-separable-conv2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-separable-conv2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-separable-convolution1-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-separable-convolution1-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-separable-convolution1-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-separable-convolution1-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-separable-convolution2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-separable-convolution2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-separable-convolution2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-separable-convolution2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-simple-r-n-n-cell.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-simple-r-n-n-cell.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-simple-r-n-n-cell.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-simple-r-n-n-cell.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-simple-r-n-n.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-simple-r-n-n.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-simple-r-n-n.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-simple-r-n-n.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-softmax.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-softmax.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-softmax.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-softmax.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-spatial-dropout1-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-spatial-dropout1-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-spatial-dropout1-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-spatial-dropout1-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-spatial-dropout2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-spatial-dropout2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-spatial-dropout2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-spatial-dropout2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-spatial-dropout3-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-spatial-dropout3-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-spatial-dropout3-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-spatial-dropout3-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-stacked-r-n-n-cells.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-stacked-r-n-n-cells.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-stacked-r-n-n-cells.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-stacked-r-n-n-cells.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-subtract.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-subtract.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-subtract.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-subtract.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-thresholded-re-l-u.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-thresholded-re-l-u.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-thresholded-re-l-u.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-thresholded-re-l-u.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-time-distributed.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-time-distributed.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-time-distributed.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-time-distributed.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-up-sampling1-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-up-sampling1-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-up-sampling1-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-up-sampling1-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-up-sampling2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-up-sampling2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-up-sampling2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-up-sampling2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-up-sampling3-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-up-sampling3-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-up-sampling3-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-up-sampling3-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-wrapper.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-wrapper.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-wrapper.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-wrapper.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-zero-padding1-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-zero-padding1-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-zero-padding1-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-zero-padding1-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-zero-padding2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-zero-padding2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-zero-padding2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-zero-padding2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.-zero-padding3-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-zero-padding3-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.-zero-padding3-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-zero-padding3-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.layers.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.layers.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.layers.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.losses.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.losses.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.losses.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.losses.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.metrics.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.metrics.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.metrics.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.metrics.pbtxt diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.models.-model.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.models.-model.pbtxt new file mode 100644 index 0000000000..56914e1746 --- /dev/null +++ b/tensorflow/tools/api/golden/v1/tensorflow.keras.models.-model.pbtxt @@ -0,0 +1,268 @@ +path: "tensorflow.keras.models.Model" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "input_spec" + mtype: "" + } + member { + name: "layers" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "state_updates" + mtype: "" + } + member { + name: "stateful" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "uses_learning_phase" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\', \'None\'], " + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'training\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "compile" + argspec: "args=[\'self\', \'optimizer\', \'loss\', \'metrics\', \'loss_weights\', \'sample_weight_mode\', \'weighted_metrics\', \'target_tensors\', \'distribute\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "evaluate" + argspec: "args=[\'self\', \'x\', \'y\', \'batch_size\', \'verbose\', \'sample_weight\', \'steps\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'1\', \'None\', \'None\'], " + } + member_method { + name: "evaluate_generator" + argspec: "args=[\'self\', \'generator\', \'steps\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'verbose\'], varargs=None, keywords=None, defaults=[\'None\', \'10\', \'1\', \'False\', \'0\'], " + } + member_method { + name: "fit" + argspec: "args=[\'self\', \'x\', \'y\', \'batch_size\', \'epochs\', \'verbose\', \'callbacks\', \'validation_split\', \'validation_data\', \'shuffle\', \'class_weight\', \'sample_weight\', \'initial_epoch\', \'steps_per_epoch\', \'validation_steps\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\', \'None\', \'1\', \'1\', \'None\', \'0.0\', \'None\', \'True\', \'None\', \'None\', \'0\', \'None\', \'None\'], " + } + member_method { + name: "fit_generator" + argspec: "args=[\'self\', \'generator\', \'steps_per_epoch\', \'epochs\', \'verbose\', \'callbacks\', \'validation_data\', \'validation_steps\', \'class_weight\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'shuffle\', \'initial_epoch\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'1\', \'None\', \'None\', \'None\', \'None\', \'10\', \'1\', \'False\', \'True\', \'0\'], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_layer" + argspec: "args=[\'self\', \'name\', \'index\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "load_weights" + argspec: "args=[\'self\', \'filepath\', \'by_name\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'x\', \'batch_size\', \'verbose\', \'steps\'], varargs=None, keywords=None, defaults=[\'None\', \'0\', \'None\'], " + } + member_method { + name: "predict_generator" + argspec: "args=[\'self\', \'generator\', \'steps\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'verbose\'], varargs=None, keywords=None, defaults=[\'None\', \'10\', \'1\', \'False\', \'0\'], " + } + member_method { + name: "predict_on_batch" + argspec: "args=[\'self\', \'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "reset_states" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "save" + argspec: "args=[\'self\', \'filepath\', \'overwrite\', \'include_optimizer\'], varargs=None, keywords=None, defaults=[\'True\', \'True\'], " + } + member_method { + name: "save_weights" + argspec: "args=[\'self\', \'filepath\', \'overwrite\', \'save_format\'], varargs=None, keywords=None, defaults=[\'True\', \'None\'], " + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "summary" + argspec: "args=[\'self\', \'line_length\', \'positions\', \'print_fn\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "test_on_batch" + argspec: "args=[\'self\', \'x\', \'y\', \'sample_weight\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "to_json" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "to_yaml" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "train_on_batch" + argspec: "args=[\'self\', \'x\', \'y\', \'sample_weight\', \'class_weight\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.models.-sequential.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.models.-sequential.pbtxt new file mode 100644 index 0000000000..4c1c54001d --- /dev/null +++ b/tensorflow/tools/api/golden/v1/tensorflow.keras.models.-sequential.pbtxt @@ -0,0 +1,289 @@ +path: "tensorflow.keras.models.Sequential" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "input_spec" + mtype: "" + } + member { + name: "layers" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "state_updates" + mtype: "" + } + member { + name: "stateful" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "uses_learning_phase" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'layers\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "add" + argspec: "args=[\'self\', \'layer\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\', \'None\'], " + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'training\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "compile" + argspec: "args=[\'self\', \'optimizer\', \'loss\', \'metrics\', \'loss_weights\', \'sample_weight_mode\', \'weighted_metrics\', \'target_tensors\', \'distribute\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "evaluate" + argspec: "args=[\'self\', \'x\', \'y\', \'batch_size\', \'verbose\', \'sample_weight\', \'steps\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'1\', \'None\', \'None\'], " + } + member_method { + name: "evaluate_generator" + argspec: "args=[\'self\', \'generator\', \'steps\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'verbose\'], varargs=None, keywords=None, defaults=[\'None\', \'10\', \'1\', \'False\', \'0\'], " + } + member_method { + name: "fit" + argspec: "args=[\'self\', \'x\', \'y\', \'batch_size\', \'epochs\', \'verbose\', \'callbacks\', \'validation_split\', \'validation_data\', \'shuffle\', \'class_weight\', \'sample_weight\', \'initial_epoch\', \'steps_per_epoch\', \'validation_steps\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\', \'None\', \'1\', \'1\', \'None\', \'0.0\', \'None\', \'True\', \'None\', \'None\', \'0\', \'None\', \'None\'], " + } + member_method { + name: "fit_generator" + argspec: "args=[\'self\', \'generator\', \'steps_per_epoch\', \'epochs\', \'verbose\', \'callbacks\', \'validation_data\', \'validation_steps\', \'class_weight\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'shuffle\', \'initial_epoch\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'1\', \'None\', \'None\', \'None\', \'None\', \'10\', \'1\', \'False\', \'True\', \'0\'], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_layer" + argspec: "args=[\'self\', \'name\', \'index\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "load_weights" + argspec: "args=[\'self\', \'filepath\', \'by_name\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "pop" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'x\', \'batch_size\', \'verbose\', \'steps\'], varargs=None, keywords=None, defaults=[\'None\', \'0\', \'None\'], " + } + member_method { + name: "predict_classes" + argspec: "args=[\'self\', \'x\', \'batch_size\', \'verbose\'], varargs=None, keywords=None, defaults=[\'32\', \'0\'], " + } + member_method { + name: "predict_generator" + argspec: "args=[\'self\', \'generator\', \'steps\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'verbose\'], varargs=None, keywords=None, defaults=[\'None\', \'10\', \'1\', \'False\', \'0\'], " + } + member_method { + name: "predict_on_batch" + argspec: "args=[\'self\', \'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "predict_proba" + argspec: "args=[\'self\', \'x\', \'batch_size\', \'verbose\'], varargs=None, keywords=None, defaults=[\'32\', \'0\'], " + } + member_method { + name: "reset_states" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "save" + argspec: "args=[\'self\', \'filepath\', \'overwrite\', \'include_optimizer\'], varargs=None, keywords=None, defaults=[\'True\', \'True\'], " + } + member_method { + name: "save_weights" + argspec: "args=[\'self\', \'filepath\', \'overwrite\', \'save_format\'], varargs=None, keywords=None, defaults=[\'True\', \'None\'], " + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "summary" + argspec: "args=[\'self\', \'line_length\', \'positions\', \'print_fn\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "symbolic_set_inputs" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "test_on_batch" + argspec: "args=[\'self\', \'x\', \'y\', \'sample_weight\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "to_json" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "to_yaml" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "train_on_batch" + argspec: "args=[\'self\', \'x\', \'y\', \'sample_weight\', \'class_weight\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/tensorflow.keras.models.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.models.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.models.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.models.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.optimizers.-adadelta.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.optimizers.-adadelta.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.optimizers.-adadelta.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.optimizers.-adadelta.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.optimizers.-adagrad.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.optimizers.-adagrad.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.optimizers.-adagrad.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.optimizers.-adagrad.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.optimizers.-adam.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.optimizers.-adam.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.optimizers.-adam.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.optimizers.-adam.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.optimizers.-adamax.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.optimizers.-adamax.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.optimizers.-adamax.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.optimizers.-adamax.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.optimizers.-nadam.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.optimizers.-nadam.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.optimizers.-nadam.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.optimizers.-nadam.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.optimizers.-optimizer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.optimizers.-optimizer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.optimizers.-optimizer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.optimizers.-optimizer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.optimizers.-r-m-sprop.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.optimizers.-r-m-sprop.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.optimizers.-r-m-sprop.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.optimizers.-r-m-sprop.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.optimizers.-s-g-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.optimizers.-s-g-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.optimizers.-s-g-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.optimizers.-s-g-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.optimizers.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.optimizers.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.optimizers.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.optimizers.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.preprocessing.image.-directory-iterator.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-directory-iterator.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.preprocessing.image.-directory-iterator.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-directory-iterator.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.preprocessing.image.-image-data-generator.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-image-data-generator.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.preprocessing.image.-image-data-generator.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-image-data-generator.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.preprocessing.image.-iterator.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-iterator.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.preprocessing.image.-iterator.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-iterator.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.preprocessing.image.-numpy-array-iterator.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-numpy-array-iterator.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.preprocessing.image.-numpy-array-iterator.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-numpy-array-iterator.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.preprocessing.image.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.preprocessing.image.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.preprocessing.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.preprocessing.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.preprocessing.sequence.-timeseries-generator.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.sequence.-timeseries-generator.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.preprocessing.sequence.-timeseries-generator.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.sequence.-timeseries-generator.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.preprocessing.sequence.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.sequence.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.preprocessing.sequence.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.sequence.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.preprocessing.text.-tokenizer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.text.-tokenizer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.preprocessing.text.-tokenizer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.text.-tokenizer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.preprocessing.text.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.text.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.preprocessing.text.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.text.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.regularizers.-l1-l2.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.regularizers.-l1-l2.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.regularizers.-l1-l2.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.regularizers.-l1-l2.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.regularizers.-regularizer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.regularizers.-regularizer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.regularizers.-regularizer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.regularizers.-regularizer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.regularizers.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.regularizers.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.regularizers.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.regularizers.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.utils.-custom-object-scope.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.utils.-custom-object-scope.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.utils.-custom-object-scope.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.utils.-custom-object-scope.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.utils.-generator-enqueuer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.utils.-generator-enqueuer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.utils.-generator-enqueuer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.utils.-generator-enqueuer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.utils.-h-d-f5-matrix.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.utils.-h-d-f5-matrix.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.utils.-h-d-f5-matrix.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.utils.-h-d-f5-matrix.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.utils.-progbar.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.utils.-progbar.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.utils.-progbar.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.utils.-progbar.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.utils.-sequence-enqueuer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.utils.-sequence-enqueuer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.utils.-sequence-enqueuer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.utils.-sequence-enqueuer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.utils.-sequence.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.utils.-sequence.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.utils.-sequence.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.utils.-sequence.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.utils.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.utils.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.utils.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.utils.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.wrappers.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.wrappers.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.wrappers.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.wrappers.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.wrappers.scikit_learn.-keras-classifier.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.wrappers.scikit_learn.-keras-classifier.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.wrappers.scikit_learn.-keras-classifier.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.wrappers.scikit_learn.-keras-classifier.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.wrappers.scikit_learn.-keras-regressor.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.wrappers.scikit_learn.-keras-regressor.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.wrappers.scikit_learn.-keras-regressor.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.wrappers.scikit_learn.-keras-regressor.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.keras.wrappers.scikit_learn.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.wrappers.scikit_learn.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.keras.wrappers.scikit_learn.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.keras.wrappers.scikit_learn.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.layers.-average-pooling1-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.layers.-average-pooling1-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.layers.-average-pooling1-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.layers.-average-pooling1-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.layers.-average-pooling2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.layers.-average-pooling2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.layers.-average-pooling2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.layers.-average-pooling2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.layers.-average-pooling3-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.layers.-average-pooling3-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.layers.-average-pooling3-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.layers.-average-pooling3-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.layers.-batch-normalization.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.layers.-batch-normalization.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.layers.-batch-normalization.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.layers.-batch-normalization.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.layers.-conv1-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.layers.-conv1-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.layers.-conv1-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.layers.-conv1-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.layers.-conv2-d-transpose.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.layers.-conv2-d-transpose.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.layers.-conv2-d-transpose.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.layers.-conv2-d-transpose.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.layers.-conv2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.layers.-conv2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.layers.-conv2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.layers.-conv2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.layers.-conv3-d-transpose.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.layers.-conv3-d-transpose.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.layers.-conv3-d-transpose.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.layers.-conv3-d-transpose.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.layers.-conv3-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.layers.-conv3-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.layers.-conv3-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.layers.-conv3-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.layers.-dense.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.layers.-dense.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.layers.-dense.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.layers.-dense.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.layers.-dropout.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.layers.-dropout.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.layers.-dropout.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.layers.-dropout.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.layers.-flatten.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.layers.-flatten.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.layers.-flatten.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.layers.-flatten.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.layers.-input-spec.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.layers.-input-spec.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.layers.-input-spec.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.layers.-input-spec.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.layers.-layer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.layers.-layer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.layers.-layer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.layers.-layer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.layers.-max-pooling1-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.layers.-max-pooling1-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.layers.-max-pooling1-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.layers.-max-pooling1-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.layers.-max-pooling2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.layers.-max-pooling2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.layers.-max-pooling2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.layers.-max-pooling2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.layers.-max-pooling3-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.layers.-max-pooling3-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.layers.-max-pooling3-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.layers.-max-pooling3-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.layers.-separable-conv1-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.layers.-separable-conv1-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.layers.-separable-conv1-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.layers.-separable-conv1-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.layers.-separable-conv2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.layers.-separable-conv2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.layers.-separable-conv2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.layers.-separable-conv2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.layers.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.layers.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.layers.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.layers.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-block-diag.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-block-diag.__metaclass__.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-block-diag.__metaclass__.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-block-diag.__metaclass__.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-block-diag.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-block-diag.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-block-diag.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-block-diag.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-circulant.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-circulant.__metaclass__.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-circulant.__metaclass__.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-circulant.__metaclass__.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-circulant.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-circulant.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-circulant.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-circulant.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-circulant2-d.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-circulant2-d.__metaclass__.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-circulant2-d.__metaclass__.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-circulant2-d.__metaclass__.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-circulant2-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-circulant2-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-circulant2-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-circulant2-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-circulant3-d.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-circulant3-d.__metaclass__.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-circulant3-d.__metaclass__.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-circulant3-d.__metaclass__.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-circulant3-d.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-circulant3-d.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-circulant3-d.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-circulant3-d.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-composition.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-composition.__metaclass__.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-composition.__metaclass__.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-composition.__metaclass__.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-composition.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-composition.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-composition.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-composition.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-diag.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-diag.__metaclass__.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-diag.__metaclass__.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-diag.__metaclass__.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-diag.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-diag.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-diag.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-diag.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-full-matrix.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-full-matrix.__metaclass__.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-full-matrix.__metaclass__.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-full-matrix.__metaclass__.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-full-matrix.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-full-matrix.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-full-matrix.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-full-matrix.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-identity.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-identity.__metaclass__.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-identity.__metaclass__.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-identity.__metaclass__.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-identity.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-identity.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-identity.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-identity.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-kronecker.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-kronecker.__metaclass__.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-kronecker.__metaclass__.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-kronecker.__metaclass__.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-kronecker.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-kronecker.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-kronecker.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-kronecker.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-low-rank-update.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-low-rank-update.__metaclass__.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-low-rank-update.__metaclass__.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-low-rank-update.__metaclass__.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-low-rank-update.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-low-rank-update.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-low-rank-update.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-low-rank-update.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-lower-triangular.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-lower-triangular.__metaclass__.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-lower-triangular.__metaclass__.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-lower-triangular.__metaclass__.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-lower-triangular.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-lower-triangular.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-lower-triangular.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-lower-triangular.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-scaled-identity.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-scaled-identity.__metaclass__.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-scaled-identity.__metaclass__.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-scaled-identity.__metaclass__.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-scaled-identity.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-scaled-identity.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-scaled-identity.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-scaled-identity.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-zeros.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-zeros.__metaclass__.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-zeros.__metaclass__.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-zeros.__metaclass__.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-zeros.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-zeros.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator-zeros.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator-zeros.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator.__metaclass__.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator.__metaclass__.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator.__metaclass__.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.-linear-operator.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.-linear-operator.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.linalg.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.linalg.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.linalg.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.linalg.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.logging.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.logging.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.logging.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.logging.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.losses.-reduction.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.losses.-reduction.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.losses.-reduction.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.losses.-reduction.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.losses.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.losses.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.losses.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.losses.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.manip.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.manip.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.manip.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.manip.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.math.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.math.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.math.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.math.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.metrics.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.metrics.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.metrics.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.metrics.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.name_scope.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.name_scope.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.name_scope.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.name_scope.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.nn.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.nn.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.nn.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.nn.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.nn.rnn_cell.-basic-l-s-t-m-cell.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.nn.rnn_cell.-basic-l-s-t-m-cell.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.nn.rnn_cell.-basic-l-s-t-m-cell.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.nn.rnn_cell.-basic-l-s-t-m-cell.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.nn.rnn_cell.-basic-r-n-n-cell.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.nn.rnn_cell.-basic-r-n-n-cell.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.nn.rnn_cell.-basic-r-n-n-cell.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.nn.rnn_cell.-basic-r-n-n-cell.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.nn.rnn_cell.-device-wrapper.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.nn.rnn_cell.-device-wrapper.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.nn.rnn_cell.-device-wrapper.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.nn.rnn_cell.-device-wrapper.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.nn.rnn_cell.-dropout-wrapper.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.nn.rnn_cell.-dropout-wrapper.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.nn.rnn_cell.-dropout-wrapper.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.nn.rnn_cell.-dropout-wrapper.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.nn.rnn_cell.-g-r-u-cell.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.nn.rnn_cell.-g-r-u-cell.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.nn.rnn_cell.-g-r-u-cell.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.nn.rnn_cell.-g-r-u-cell.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.nn.rnn_cell.-l-s-t-m-cell.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.nn.rnn_cell.-l-s-t-m-cell.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.nn.rnn_cell.-l-s-t-m-cell.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.nn.rnn_cell.-l-s-t-m-cell.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.nn.rnn_cell.-l-s-t-m-state-tuple.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.nn.rnn_cell.-l-s-t-m-state-tuple.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.nn.rnn_cell.-l-s-t-m-state-tuple.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.nn.rnn_cell.-l-s-t-m-state-tuple.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.nn.rnn_cell.-multi-r-n-n-cell.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.nn.rnn_cell.-multi-r-n-n-cell.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.nn.rnn_cell.-multi-r-n-n-cell.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.nn.rnn_cell.-multi-r-n-n-cell.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.nn.rnn_cell.-r-n-n-cell.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.nn.rnn_cell.-r-n-n-cell.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.nn.rnn_cell.-r-n-n-cell.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.nn.rnn_cell.-r-n-n-cell.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.nn.rnn_cell.-residual-wrapper.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.nn.rnn_cell.-residual-wrapper.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.nn.rnn_cell.-residual-wrapper.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.nn.rnn_cell.-residual-wrapper.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.nn.rnn_cell.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.nn.rnn_cell.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.nn.rnn_cell.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.nn.rnn_cell.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.ones_initializer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.ones_initializer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.ones_initializer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.ones_initializer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.orthogonal_initializer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.orthogonal_initializer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.orthogonal_initializer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.orthogonal_initializer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.profiler.-advice-proto.-checker.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.profiler.-advice-proto.-checker.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.profiler.-advice-proto.-checker.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.profiler.-advice-proto.-checker.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.profiler.-advice-proto.-checkers-entry.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.profiler.-advice-proto.-checkers-entry.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.profiler.-advice-proto.-checkers-entry.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.profiler.-advice-proto.-checkers-entry.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.profiler.-advice-proto.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.profiler.-advice-proto.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.profiler.-advice-proto.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.profiler.-advice-proto.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.profiler.-graph-node-proto.-input-shapes-entry.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.profiler.-graph-node-proto.-input-shapes-entry.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.profiler.-graph-node-proto.-input-shapes-entry.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.profiler.-graph-node-proto.-input-shapes-entry.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.profiler.-graph-node-proto.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.profiler.-graph-node-proto.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.profiler.-graph-node-proto.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.profiler.-graph-node-proto.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.profiler.-multi-graph-node-proto.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.profiler.-multi-graph-node-proto.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.profiler.-multi-graph-node-proto.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.profiler.-multi-graph-node-proto.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.profiler.-op-log-proto.-id-to-string-entry.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.profiler.-op-log-proto.-id-to-string-entry.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.profiler.-op-log-proto.-id-to-string-entry.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.profiler.-op-log-proto.-id-to-string-entry.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.profiler.-op-log-proto.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.profiler.-op-log-proto.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.profiler.-op-log-proto.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.profiler.-op-log-proto.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.profiler.-profile-option-builder.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.profiler.-profile-option-builder.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.profiler.-profile-option-builder.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.profiler.-profile-option-builder.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.profiler.-profiler.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.profiler.-profiler.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.profiler.-profiler.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.profiler.-profiler.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.profiler.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.profiler.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.profiler.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.profiler.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.python_io.-t-f-record-compression-type.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.python_io.-t-f-record-compression-type.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.python_io.-t-f-record-compression-type.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.python_io.-t-f-record-compression-type.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.python_io.-t-f-record-options.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.python_io.-t-f-record-options.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.python_io.-t-f-record-options.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.python_io.-t-f-record-options.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.python_io.-t-f-record-writer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.python_io.-t-f-record-writer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.python_io.-t-f-record-writer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.python_io.-t-f-record-writer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.python_io.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.python_io.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.python_io.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.python_io.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.quantization.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.quantization.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.quantization.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.quantization.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.random_normal_initializer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.random_normal_initializer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.random_normal_initializer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.random_normal_initializer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.random_uniform_initializer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.random_uniform_initializer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.random_uniform_initializer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.random_uniform_initializer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.resource_loader.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.resource_loader.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.resource_loader.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.resource_loader.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.saved_model.builder.-saved-model-builder.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.saved_model.builder.-saved-model-builder.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.saved_model.builder.-saved-model-builder.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.saved_model.builder.-saved-model-builder.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.saved_model.builder.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.saved_model.builder.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.saved_model.builder.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.saved_model.builder.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.saved_model.constants.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.saved_model.constants.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.saved_model.constants.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.saved_model.constants.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.saved_model.loader.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.saved_model.loader.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.saved_model.loader.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.saved_model.loader.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.saved_model.main_op.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.saved_model.main_op.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.saved_model.main_op.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.saved_model.main_op.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.saved_model.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.saved_model.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.saved_model.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.saved_model.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.saved_model.signature_constants.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.saved_model.signature_constants.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.saved_model.signature_constants.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.saved_model.signature_constants.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.saved_model.signature_def_utils.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.saved_model.signature_def_utils.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.saved_model.signature_def_utils.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.saved_model.signature_def_utils.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.saved_model.tag_constants.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.saved_model.tag_constants.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.saved_model.tag_constants.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.saved_model.tag_constants.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.saved_model.utils.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.saved_model.utils.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.saved_model.utils.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.saved_model.utils.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.sets.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.sets.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.sets.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.sets.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.sparse.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.sparse.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.sparse.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.sparse.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.spectral.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.spectral.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.spectral.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.spectral.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.strings.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.strings.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.strings.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.strings.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.summary.-event.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.summary.-event.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.summary.-event.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.summary.-event.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.summary.-file-writer-cache.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.summary.-file-writer-cache.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.summary.-file-writer-cache.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.summary.-file-writer-cache.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.summary.-file-writer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.summary.-file-writer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.summary.-file-writer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.summary.-file-writer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.summary.-session-log.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.summary.-session-log.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.summary.-session-log.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.summary.-session-log.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.summary.-summary-description.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.summary.-summary-description.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.summary.-summary-description.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.summary.-summary-description.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.summary.-summary.-audio.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.summary.-summary.-audio.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.summary.-summary.-audio.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.summary.-summary.-audio.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.summary.-summary.-image.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.summary.-summary.-image.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.summary.-summary.-image.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.summary.-summary.-image.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.summary.-summary.-value.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.summary.-summary.-value.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.summary.-summary.-value.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.summary.-summary.-value.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.summary.-summary.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.summary.-summary.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.summary.-summary.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.summary.-summary.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.summary.-tagged-run-metadata.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.summary.-tagged-run-metadata.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.summary.-tagged-run-metadata.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.summary.-tagged-run-metadata.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.summary.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.summary.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.summary.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.summary.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.sysconfig.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.sysconfig.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.sysconfig.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.sysconfig.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.test.-benchmark.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.test.-benchmark.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.test.-benchmark.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.test.-benchmark.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.test.-stub-out-for-testing.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.test.-stub-out-for-testing.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.test.-stub-out-for-testing.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.test.-stub-out-for-testing.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.test.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.test.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.test.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.test.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-adadelta-optimizer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-adadelta-optimizer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-adadelta-optimizer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-adadelta-optimizer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-adagrad-d-a-optimizer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-adagrad-d-a-optimizer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-adagrad-d-a-optimizer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-adagrad-d-a-optimizer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-adagrad-optimizer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-adagrad-optimizer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-adagrad-optimizer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-adagrad-optimizer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-adam-optimizer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-adam-optimizer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-adam-optimizer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-adam-optimizer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-bytes-list.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-bytes-list.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-bytes-list.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-bytes-list.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-checkpoint-saver-hook.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-checkpoint-saver-hook.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-checkpoint-saver-hook.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-checkpoint-saver-hook.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-checkpoint-saver-listener.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-checkpoint-saver-listener.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-checkpoint-saver-listener.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-checkpoint-saver-listener.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-checkpoint.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-checkpoint.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-checkpoint.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-checkpoint.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-chief-session-creator.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-chief-session-creator.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-chief-session-creator.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-chief-session-creator.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-cluster-def.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-cluster-def.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-cluster-def.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-cluster-def.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-cluster-spec.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-cluster-spec.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-cluster-spec.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-cluster-spec.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-coordinator.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-coordinator.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-coordinator.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-coordinator.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-example.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-example.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-example.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-example.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-exponential-moving-average.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-exponential-moving-average.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-exponential-moving-average.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-exponential-moving-average.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-feature-list.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-feature-list.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-feature-list.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-feature-list.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-feature-lists.-feature-list-entry.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-feature-lists.-feature-list-entry.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-feature-lists.-feature-list-entry.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-feature-lists.-feature-list-entry.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-feature-lists.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-feature-lists.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-feature-lists.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-feature-lists.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-feature.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-feature.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-feature.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-feature.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-features.-feature-entry.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-features.-feature-entry.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-features.-feature-entry.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-features.-feature-entry.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-features.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-features.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-features.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-features.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-feed-fn-hook.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-feed-fn-hook.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-feed-fn-hook.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-feed-fn-hook.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-final-ops-hook.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-final-ops-hook.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-final-ops-hook.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-final-ops-hook.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-float-list.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-float-list.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-float-list.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-float-list.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-ftrl-optimizer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-ftrl-optimizer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-ftrl-optimizer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-ftrl-optimizer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-global-step-waiter-hook.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-global-step-waiter-hook.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-global-step-waiter-hook.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-global-step-waiter-hook.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-gradient-descent-optimizer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-gradient-descent-optimizer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-gradient-descent-optimizer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-gradient-descent-optimizer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-int64-list.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-int64-list.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-int64-list.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-int64-list.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-job-def.-tasks-entry.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-job-def.-tasks-entry.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-job-def.-tasks-entry.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-job-def.-tasks-entry.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-job-def.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-job-def.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-job-def.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-job-def.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-logging-tensor-hook.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-logging-tensor-hook.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-logging-tensor-hook.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-logging-tensor-hook.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-looper-thread.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-looper-thread.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-looper-thread.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-looper-thread.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-momentum-optimizer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-momentum-optimizer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-momentum-optimizer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-momentum-optimizer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-monitored-session.-step-context.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-monitored-session.-step-context.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-monitored-session.-step-context.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-monitored-session.-step-context.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-monitored-session.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-monitored-session.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-monitored-session.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-monitored-session.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-nan-loss-during-training-error.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-nan-loss-during-training-error.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-nan-loss-during-training-error.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-nan-loss-during-training-error.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-nan-tensor-hook.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-nan-tensor-hook.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-nan-tensor-hook.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-nan-tensor-hook.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-optimizer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-optimizer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-optimizer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-optimizer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-profiler-hook.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-profiler-hook.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-profiler-hook.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-profiler-hook.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-proximal-adagrad-optimizer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-proximal-adagrad-optimizer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-proximal-adagrad-optimizer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-proximal-adagrad-optimizer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-proximal-gradient-descent-optimizer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-proximal-gradient-descent-optimizer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-proximal-gradient-descent-optimizer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-proximal-gradient-descent-optimizer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-queue-runner.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-queue-runner.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-queue-runner.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-queue-runner.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-r-m-s-prop-optimizer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-r-m-s-prop-optimizer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-r-m-s-prop-optimizer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-r-m-s-prop-optimizer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-saver-def.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-saver-def.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-saver-def.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-saver-def.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-saver.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-saver.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-saver.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-saver.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-scaffold.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-scaffold.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-scaffold.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-scaffold.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-second-or-step-timer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-second-or-step-timer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-second-or-step-timer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-second-or-step-timer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-sequence-example.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-sequence-example.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-sequence-example.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-sequence-example.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-server-def.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-server-def.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-server-def.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-server-def.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-server.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-server.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-server.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-server.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-session-creator.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-session-creator.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-session-creator.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-session-creator.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-session-manager.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-session-manager.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-session-manager.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-session-manager.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-session-run-args.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-session-run-args.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-session-run-args.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-session-run-args.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-session-run-context.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-session-run-context.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-session-run-context.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-session-run-context.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-session-run-hook.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-session-run-hook.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-session-run-hook.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-session-run-hook.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-session-run-values.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-session-run-values.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-session-run-values.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-session-run-values.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-singular-monitored-session.-step-context.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-singular-monitored-session.-step-context.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-singular-monitored-session.-step-context.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-singular-monitored-session.-step-context.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-singular-monitored-session.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-singular-monitored-session.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-singular-monitored-session.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-singular-monitored-session.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-step-counter-hook.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-step-counter-hook.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-step-counter-hook.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-step-counter-hook.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-stop-at-step-hook.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-stop-at-step-hook.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-stop-at-step-hook.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-stop-at-step-hook.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-summary-saver-hook.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-summary-saver-hook.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-summary-saver-hook.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-summary-saver-hook.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-supervisor.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-supervisor.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-supervisor.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-supervisor.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-sync-replicas-optimizer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-sync-replicas-optimizer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-sync-replicas-optimizer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-sync-replicas-optimizer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-vocab-info.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-vocab-info.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-vocab-info.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-vocab-info.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.-worker-session-creator.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.-worker-session-creator.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.-worker-session-creator.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.-worker-session-creator.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.queue_runner.-queue-runner.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.queue_runner.-queue-runner.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.queue_runner.-queue-runner.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.queue_runner.-queue-runner.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.train.queue_runner.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.queue_runner.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.train.queue_runner.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.train.queue_runner.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.truncated_normal_initializer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.truncated_normal_initializer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.truncated_normal_initializer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.truncated_normal_initializer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.uniform_unit_scaling_initializer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.uniform_unit_scaling_initializer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.uniform_unit_scaling_initializer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.uniform_unit_scaling_initializer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.variable_scope.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.variable_scope.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.variable_scope.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.variable_scope.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.variance_scaling_initializer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.variance_scaling_initializer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.variance_scaling_initializer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.variance_scaling_initializer.pbtxt diff --git a/tensorflow/tools/api/golden/tensorflow.zeros_initializer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.zeros_initializer.pbtxt similarity index 100% rename from tensorflow/tools/api/golden/tensorflow.zeros_initializer.pbtxt rename to tensorflow/tools/api/golden/v1/tensorflow.zeros_initializer.pbtxt diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-aggregation-method.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-aggregation-method.pbtxt new file mode 100644 index 0000000000..f79029d3fe --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-aggregation-method.pbtxt @@ -0,0 +1,24 @@ +path: "tensorflow.AggregationMethod" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "ADD_N" + mtype: "" + } + member { + name: "DEFAULT" + mtype: "" + } + member { + name: "EXPERIMENTAL_ACCUMULATE_N" + mtype: "" + } + member { + name: "EXPERIMENTAL_TREE" + mtype: "" + } + member_method { + name: "__init__" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-attr-value.-list-value.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-attr-value.-list-value.pbtxt new file mode 100644 index 0000000000..f1dffd5952 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-attr-value.-list-value.pbtxt @@ -0,0 +1,70 @@ +path: "tensorflow.AttrValue.ListValue" +tf_proto { + descriptor { + name: "ListValue" + field { + name: "s" + number: 2 + label: LABEL_REPEATED + type: TYPE_BYTES + } + field { + name: "i" + number: 3 + label: LABEL_REPEATED + type: TYPE_INT64 + options { + packed: true + } + } + field { + name: "f" + number: 4 + label: LABEL_REPEATED + type: TYPE_FLOAT + options { + packed: true + } + } + field { + name: "b" + number: 5 + label: LABEL_REPEATED + type: TYPE_BOOL + options { + packed: true + } + } + field { + name: "type" + number: 6 + label: LABEL_REPEATED + type: TYPE_ENUM + type_name: ".tensorflow.DataType" + options { + packed: true + } + } + field { + name: "shape" + number: 7 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.TensorShapeProto" + } + field { + name: "tensor" + number: 8 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.TensorProto" + } + field { + name: "func" + number: 9 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.NameAttrList" + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-attr-value.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-attr-value.pbtxt new file mode 100644 index 0000000000..6ccd64f428 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-attr-value.pbtxt @@ -0,0 +1,151 @@ +path: "tensorflow.AttrValue" +tf_proto { + descriptor { + name: "AttrValue" + field { + name: "s" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_BYTES + oneof_index: 0 + } + field { + name: "i" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_INT64 + oneof_index: 0 + } + field { + name: "f" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_FLOAT + oneof_index: 0 + } + field { + name: "b" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_BOOL + oneof_index: 0 + } + field { + name: "type" + number: 6 + label: LABEL_OPTIONAL + type: TYPE_ENUM + type_name: ".tensorflow.DataType" + oneof_index: 0 + } + field { + name: "shape" + number: 7 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.TensorShapeProto" + oneof_index: 0 + } + field { + name: "tensor" + number: 8 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.TensorProto" + oneof_index: 0 + } + field { + name: "list" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.AttrValue.ListValue" + oneof_index: 0 + } + field { + name: "func" + number: 10 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.NameAttrList" + oneof_index: 0 + } + field { + name: "placeholder" + number: 9 + label: LABEL_OPTIONAL + type: TYPE_STRING + oneof_index: 0 + } + nested_type { + name: "ListValue" + field { + name: "s" + number: 2 + label: LABEL_REPEATED + type: TYPE_BYTES + } + field { + name: "i" + number: 3 + label: LABEL_REPEATED + type: TYPE_INT64 + options { + packed: true + } + } + field { + name: "f" + number: 4 + label: LABEL_REPEATED + type: TYPE_FLOAT + options { + packed: true + } + } + field { + name: "b" + number: 5 + label: LABEL_REPEATED + type: TYPE_BOOL + options { + packed: true + } + } + field { + name: "type" + number: 6 + label: LABEL_REPEATED + type: TYPE_ENUM + type_name: ".tensorflow.DataType" + options { + packed: true + } + } + field { + name: "shape" + number: 7 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.TensorShapeProto" + } + field { + name: "tensor" + number: 8 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.TensorProto" + } + field { + name: "func" + number: 9 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.NameAttrList" + } + } + oneof_decl { + name: "value" + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-conditional-accumulator-base.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-conditional-accumulator-base.pbtxt new file mode 100644 index 0000000000..c9a32c16b3 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-conditional-accumulator-base.pbtxt @@ -0,0 +1,29 @@ +path: "tensorflow.ConditionalAccumulatorBase" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "accumulator_ref" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'dtype\', \'shape\', \'accumulator_ref\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "num_accumulated" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_global_step" + argspec: "args=[\'self\', \'new_global_step\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-conditional-accumulator.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-conditional-accumulator.pbtxt new file mode 100644 index 0000000000..d23b3bd0ca --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-conditional-accumulator.pbtxt @@ -0,0 +1,38 @@ +path: "tensorflow.ConditionalAccumulator" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "accumulator_ref" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'dtype\', \'shape\', \'shared_name\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'conditional_accumulator\'], " + } + member_method { + name: "apply_grad" + argspec: "args=[\'self\', \'grad\', \'local_step\', \'name\'], varargs=None, keywords=None, defaults=[\'0\', \'None\'], " + } + member_method { + name: "num_accumulated" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_global_step" + argspec: "args=[\'self\', \'new_global_step\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "take_grad" + argspec: "args=[\'self\', \'num_required\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-config-proto.-device-count-entry.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-config-proto.-device-count-entry.pbtxt new file mode 100644 index 0000000000..d9b1426828 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-config-proto.-device-count-entry.pbtxt @@ -0,0 +1,21 @@ +path: "tensorflow.ConfigProto.DeviceCountEntry" +tf_proto { + descriptor { + name: "DeviceCountEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + options { + map_entry: true + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-config-proto.-experimental.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-config-proto.-experimental.pbtxt new file mode 100644 index 0000000000..ef9fe096a1 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-config-proto.-experimental.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.ConfigProto.Experimental" +tf_proto { + descriptor { + name: "Experimental" + field { + name: "collective_group_leader" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "client_handles_error_formatting" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-config-proto.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-config-proto.pbtxt new file mode 100644 index 0000000000..eeef15515d --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-config-proto.pbtxt @@ -0,0 +1,142 @@ +path: "tensorflow.ConfigProto" +tf_proto { + descriptor { + name: "ConfigProto" + field { + name: "device_count" + number: 1 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.ConfigProto.DeviceCountEntry" + } + field { + name: "intra_op_parallelism_threads" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "inter_op_parallelism_threads" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "use_per_session_threads" + number: 9 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "session_inter_op_thread_pool" + number: 12 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.ThreadPoolOptionProto" + } + field { + name: "placement_period" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "device_filters" + number: 4 + label: LABEL_REPEATED + type: TYPE_STRING + } + field { + name: "gpu_options" + number: 6 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.GPUOptions" + } + field { + name: "allow_soft_placement" + number: 7 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "log_device_placement" + number: 8 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "graph_options" + number: 10 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.GraphOptions" + } + field { + name: "operation_timeout_in_ms" + number: 11 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "rpc_options" + number: 13 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.RPCOptions" + } + field { + name: "cluster_def" + number: 14 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.ClusterDef" + } + field { + name: "isolate_session_state" + number: 15 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "experimental" + number: 16 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.ConfigProto.Experimental" + } + nested_type { + name: "DeviceCountEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + options { + map_entry: true + } + } + nested_type { + name: "Experimental" + field { + name: "collective_group_leader" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "client_handles_error_formatting" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-d-type.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-d-type.pbtxt new file mode 100644 index 0000000000..0b5b88bba8 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-d-type.pbtxt @@ -0,0 +1,77 @@ +path: "tensorflow.DType" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "as_datatype_enum" + mtype: "" + } + member { + name: "as_numpy_dtype" + mtype: "" + } + member { + name: "base_dtype" + mtype: "" + } + member { + name: "is_bool" + mtype: "" + } + member { + name: "is_complex" + mtype: "" + } + member { + name: "is_floating" + mtype: "" + } + member { + name: "is_integer" + mtype: "" + } + member { + name: "is_numpy_compatible" + mtype: "" + } + member { + name: "is_quantized" + mtype: "" + } + member { + name: "is_unsigned" + mtype: "" + } + member { + name: "limits" + mtype: "" + } + member { + name: "max" + mtype: "" + } + member { + name: "min" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "real_dtype" + mtype: "" + } + member { + name: "size" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'type_enum\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "is_compatible_with" + argspec: "args=[\'self\', \'other\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-device-spec.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-device-spec.pbtxt new file mode 100644 index 0000000000..92e535c341 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-device-spec.pbtxt @@ -0,0 +1,37 @@ +path: "tensorflow.DeviceSpec" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "job" + mtype: "" + } + member { + name: "replica" + mtype: "" + } + member { + name: "task" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'job\', \'replica\', \'task\', \'device_type\', \'device_index\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "from_string" + argspec: "args=[\'spec\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "merge_from" + argspec: "args=[\'self\', \'dev\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "parse_from_string" + argspec: "args=[\'self\', \'spec\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "to_string" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-dimension.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-dimension.pbtxt new file mode 100644 index 0000000000..a9ab27719b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-dimension.pbtxt @@ -0,0 +1,25 @@ +path: "tensorflow.Dimension" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "value" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'value\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "assert_is_compatible_with" + argspec: "args=[\'self\', \'other\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "is_compatible_with" + argspec: "args=[\'self\', \'other\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "merge_with" + argspec: "args=[\'self\', \'other\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-event.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-event.pbtxt new file mode 100644 index 0000000000..3b75a1735b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-event.pbtxt @@ -0,0 +1,74 @@ +path: "tensorflow.Event" +tf_proto { + descriptor { + name: "Event" + field { + name: "wall_time" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_DOUBLE + } + field { + name: "step" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "file_version" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_STRING + oneof_index: 0 + } + field { + name: "graph_def" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_BYTES + oneof_index: 0 + } + field { + name: "summary" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.Summary" + oneof_index: 0 + } + field { + name: "log_message" + number: 6 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.LogMessage" + oneof_index: 0 + } + field { + name: "session_log" + number: 7 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.SessionLog" + oneof_index: 0 + } + field { + name: "tagged_run_metadata" + number: 8 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.TaggedRunMetadata" + oneof_index: 0 + } + field { + name: "meta_graph_def" + number: 9 + label: LABEL_OPTIONAL + type: TYPE_BYTES + oneof_index: 0 + } + oneof_decl { + name: "what" + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-f-i-f-o-queue.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-f-i-f-o-queue.pbtxt new file mode 100644 index 0000000000..a095616c00 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-f-i-f-o-queue.pbtxt @@ -0,0 +1,66 @@ +path: "tensorflow.FIFOQueue" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "dtypes" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "names" + mtype: "" + } + member { + name: "queue_ref" + mtype: "" + } + member { + name: "shapes" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'capacity\', \'dtypes\', \'shapes\', \'names\', \'shared_name\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'fifo_queue\'], " + } + member_method { + name: "close" + argspec: "args=[\'self\', \'cancel_pending_enqueues\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "dequeue" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "dequeue_many" + argspec: "args=[\'self\', \'n\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "dequeue_up_to" + argspec: "args=[\'self\', \'n\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "enqueue" + argspec: "args=[\'self\', \'vals\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "enqueue_many" + argspec: "args=[\'self\', \'vals\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "from_list" + argspec: "args=[\'index\', \'queues\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "is_closed" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "size" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-fixed-len-feature.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-fixed-len-feature.pbtxt new file mode 100644 index 0000000000..6933814a7b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-fixed-len-feature.pbtxt @@ -0,0 +1,27 @@ +path: "tensorflow.FixedLenFeature" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "default_value" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "shape" + mtype: "" + } + member_method { + name: "__init__" + } + member_method { + name: "count" + } + member_method { + name: "index" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-fixed-len-sequence-feature.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-fixed-len-sequence-feature.pbtxt new file mode 100644 index 0000000000..c538787951 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-fixed-len-sequence-feature.pbtxt @@ -0,0 +1,31 @@ +path: "tensorflow.FixedLenSequenceFeature" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "allow_missing" + mtype: "" + } + member { + name: "default_value" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "shape" + mtype: "" + } + member_method { + name: "__init__" + } + member_method { + name: "count" + } + member_method { + name: "index" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-fixed-length-record-reader.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-fixed-length-record-reader.pbtxt new file mode 100644 index 0000000000..260c796fd6 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-fixed-length-record-reader.pbtxt @@ -0,0 +1,46 @@ +path: "tensorflow.FixedLengthRecordReader" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "reader_ref" + mtype: "" + } + member { + name: "supports_serialize" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'record_bytes\', \'header_bytes\', \'footer_bytes\', \'hop_bytes\', \'name\', \'encoding\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "num_records_produced" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "num_work_units_completed" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "read" + argspec: "args=[\'self\', \'queue\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "read_up_to" + argspec: "args=[\'self\', \'queue\', \'num_records\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "reset" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "restore_state" + argspec: "args=[\'self\', \'state\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "serialize_state" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-g-p-u-options.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-g-p-u-options.pbtxt new file mode 100644 index 0000000000..353e63127d --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-g-p-u-options.pbtxt @@ -0,0 +1,92 @@ +path: "tensorflow.GPUOptions" +tf_proto { + descriptor { + name: "GPUOptions" + field { + name: "per_process_gpu_memory_fraction" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_DOUBLE + } + field { + name: "allow_growth" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "allocator_type" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "deferred_deletion_bytes" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "visible_device_list" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "polling_active_delay_usecs" + number: 6 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "polling_inactive_delay_msecs" + number: 7 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "force_gpu_compatible" + number: 8 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "experimental" + number: 9 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.GPUOptions.Experimental" + } + nested_type { + name: "Experimental" + field { + name: "virtual_devices" + number: 1 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.GPUOptions.Experimental.VirtualDevices" + } + field { + name: "use_unified_memory" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "num_dev_to_dev_copy_streams" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + nested_type { + name: "VirtualDevices" + field { + name: "memory_limit_mb" + number: 1 + label: LABEL_REPEATED + type: TYPE_FLOAT + } + } + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-gradient-tape.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-gradient-tape.pbtxt new file mode 100644 index 0000000000..cbf655498c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-gradient-tape.pbtxt @@ -0,0 +1,29 @@ +path: "tensorflow.GradientTape" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'persistent\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "gradient" + argspec: "args=[\'self\', \'target\', \'sources\', \'output_gradients\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "reset" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "stop_recording" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "watch" + argspec: "args=[\'self\', \'tensor\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "watched_variables" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-graph-def.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-graph-def.pbtxt new file mode 100644 index 0000000000..19eccff03d --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-graph-def.pbtxt @@ -0,0 +1,36 @@ +path: "tensorflow.GraphDef" +tf_proto { + descriptor { + name: "GraphDef" + field { + name: "node" + number: 1 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.NodeDef" + } + field { + name: "versions" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.VersionDef" + } + field { + name: "version" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_INT32 + options { + deprecated: true + } + } + field { + name: "library" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.FunctionDefLibrary" + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-graph-keys.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-graph-keys.pbtxt new file mode 100644 index 0000000000..ffe4790933 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-graph-keys.pbtxt @@ -0,0 +1,140 @@ +path: "tensorflow.GraphKeys" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "ACTIVATIONS" + mtype: "" + } + member { + name: "ASSET_FILEPATHS" + mtype: "" + } + member { + name: "BIASES" + mtype: "" + } + member { + name: "CONCATENATED_VARIABLES" + mtype: "" + } + member { + name: "COND_CONTEXT" + mtype: "" + } + member { + name: "EVAL_STEP" + mtype: "" + } + member { + name: "GLOBAL_STEP" + mtype: "" + } + member { + name: "GLOBAL_VARIABLES" + mtype: "" + } + member { + name: "INIT_OP" + mtype: "" + } + member { + name: "LOCAL_INIT_OP" + mtype: "" + } + member { + name: "LOCAL_RESOURCES" + mtype: "" + } + member { + name: "LOCAL_VARIABLES" + mtype: "" + } + member { + name: "LOSSES" + mtype: "" + } + member { + name: "METRIC_VARIABLES" + mtype: "" + } + member { + name: "MODEL_VARIABLES" + mtype: "" + } + member { + name: "MOVING_AVERAGE_VARIABLES" + mtype: "" + } + member { + name: "QUEUE_RUNNERS" + mtype: "" + } + member { + name: "READY_FOR_LOCAL_INIT_OP" + mtype: "" + } + member { + name: "READY_OP" + mtype: "" + } + member { + name: "REGULARIZATION_LOSSES" + mtype: "" + } + member { + name: "RESOURCES" + mtype: "" + } + member { + name: "SAVEABLE_OBJECTS" + mtype: "" + } + member { + name: "SAVERS" + mtype: "" + } + member { + name: "SUMMARIES" + mtype: "" + } + member { + name: "SUMMARY_OP" + mtype: "" + } + member { + name: "TABLE_INITIALIZERS" + mtype: "" + } + member { + name: "TRAINABLE_RESOURCE_VARIABLES" + mtype: "" + } + member { + name: "TRAINABLE_VARIABLES" + mtype: "" + } + member { + name: "TRAIN_OP" + mtype: "" + } + member { + name: "UPDATE_OPS" + mtype: "" + } + member { + name: "VARIABLES" + mtype: "" + } + member { + name: "WEIGHTS" + mtype: "" + } + member { + name: "WHILE_CONTEXT" + mtype: "" + } + member_method { + name: "__init__" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-graph-options.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-graph-options.pbtxt new file mode 100644 index 0000000000..a9f99bc171 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-graph-options.pbtxt @@ -0,0 +1,67 @@ +path: "tensorflow.GraphOptions" +tf_proto { + descriptor { + name: "GraphOptions" + field { + name: "enable_recv_scheduling" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "optimizer_options" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.OptimizerOptions" + } + field { + name: "build_cost_model" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "build_cost_model_after" + number: 9 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "infer_shapes" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "place_pruned_graph" + number: 6 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "enable_bfloat16_sendrecv" + number: 7 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "timeline_step" + number: 8 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "rewrite_options" + number: 10 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.RewriterConfig" + } + reserved_range { + start: 1 + end: 2 + } + reserved_name: "skip_common_subexpression_elimination" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-graph.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-graph.pbtxt new file mode 100644 index 0000000000..cdaeb55e30 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-graph.pbtxt @@ -0,0 +1,141 @@ +path: "tensorflow.Graph" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "building_function" + mtype: "" + } + member { + name: "collections" + mtype: "" + } + member { + name: "finalized" + mtype: "" + } + member { + name: "graph_def_versions" + mtype: "" + } + member { + name: "seed" + mtype: "" + } + member { + name: "version" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "add_to_collection" + argspec: "args=[\'self\', \'name\', \'value\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "add_to_collections" + argspec: "args=[\'self\', \'names\', \'value\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "as_default" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "as_graph_def" + argspec: "args=[\'self\', \'from_version\', \'add_shapes\'], varargs=None, keywords=None, defaults=[\'None\', \'False\'], " + } + member_method { + name: "as_graph_element" + argspec: "args=[\'self\', \'obj\', \'allow_tensor\', \'allow_operation\'], varargs=None, keywords=None, defaults=[\'True\', \'True\'], " + } + member_method { + name: "clear_collection" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "colocate_with" + argspec: "args=[\'self\', \'op\', \'ignore_existing\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "container" + argspec: "args=[\'self\', \'container_name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "control_dependencies" + argspec: "args=[\'self\', \'control_inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "create_op" + argspec: "args=[\'self\', \'op_type\', \'inputs\', \'dtypes\', \'input_types\', \'name\', \'attrs\', \'op_def\', \'compute_shapes\', \'compute_device\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'True\', \'True\'], " + } + member_method { + name: "device" + argspec: "args=[\'self\', \'device_name_or_function\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "finalize" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_all_collection_keys" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_collection" + argspec: "args=[\'self\', \'name\', \'scope\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_collection_ref" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_name_scope" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_operation_by_name" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_operations" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_tensor_by_name" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "gradient_override_map" + argspec: "args=[\'self\', \'op_type_map\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "is_feedable" + argspec: "args=[\'self\', \'tensor\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "is_fetchable" + argspec: "args=[\'self\', \'tensor_or_op\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "name_scope" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "prevent_feeding" + argspec: "args=[\'self\', \'tensor\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "prevent_fetching" + argspec: "args=[\'self\', \'op\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "switch_to_thread_local" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "unique_name" + argspec: "args=[\'self\', \'name\', \'mark_as_used\'], varargs=None, keywords=None, defaults=[\'True\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-histogram-proto.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-histogram-proto.pbtxt new file mode 100644 index 0000000000..d4402f330b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-histogram-proto.pbtxt @@ -0,0 +1,54 @@ +path: "tensorflow.HistogramProto" +tf_proto { + descriptor { + name: "HistogramProto" + field { + name: "min" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_DOUBLE + } + field { + name: "max" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_DOUBLE + } + field { + name: "num" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_DOUBLE + } + field { + name: "sum" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_DOUBLE + } + field { + name: "sum_squares" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_DOUBLE + } + field { + name: "bucket_limit" + number: 6 + label: LABEL_REPEATED + type: TYPE_DOUBLE + options { + packed: true + } + } + field { + name: "bucket" + number: 7 + label: LABEL_REPEATED + type: TYPE_DOUBLE + options { + packed: true + } + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-identity-reader.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-identity-reader.pbtxt new file mode 100644 index 0000000000..2eda320d63 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-identity-reader.pbtxt @@ -0,0 +1,46 @@ +path: "tensorflow.IdentityReader" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "reader_ref" + mtype: "" + } + member { + name: "supports_serialize" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "num_records_produced" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "num_work_units_completed" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "read" + argspec: "args=[\'self\', \'queue\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "read_up_to" + argspec: "args=[\'self\', \'queue\', \'num_records\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "reset" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "restore_state" + argspec: "args=[\'self\', \'state\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "serialize_state" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-indexed-slices.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-indexed-slices.pbtxt new file mode 100644 index 0000000000..fee84d8530 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-indexed-slices.pbtxt @@ -0,0 +1,42 @@ +path: "tensorflow.IndexedSlices" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "dense_shape" + mtype: "" + } + member { + name: "device" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "indices" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "op" + mtype: "" + } + member { + name: "values" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'values\', \'indices\', \'dense_shape\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-interactive-session.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-interactive-session.pbtxt new file mode 100644 index 0000000000..0a3b81bf82 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-interactive-session.pbtxt @@ -0,0 +1,51 @@ +path: "tensorflow.InteractiveSession" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "graph" + mtype: "" + } + member { + name: "graph_def" + mtype: "" + } + member { + name: "sess_str" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'target\', \'graph\', \'config\'], varargs=None, keywords=None, defaults=[\'\', \'None\', \'None\'], " + } + member_method { + name: "as_default" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "close" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "list_devices" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "make_callable" + argspec: "args=[\'self\', \'fetches\', \'feed_list\', \'accept_options\'], varargs=None, keywords=None, defaults=[\'None\', \'False\'], " + } + member_method { + name: "partial_run" + argspec: "args=[\'self\', \'handle\', \'fetches\', \'feed_dict\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "partial_run_setup" + argspec: "args=[\'self\', \'fetches\', \'feeds\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "run" + argspec: "args=[\'self\', \'fetches\', \'feed_dict\', \'options\', \'run_metadata\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-l-m-d-b-reader.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-l-m-d-b-reader.pbtxt new file mode 100644 index 0000000000..f9b7e9bbca --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-l-m-d-b-reader.pbtxt @@ -0,0 +1,46 @@ +path: "tensorflow.LMDBReader" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "reader_ref" + mtype: "" + } + member { + name: "supports_serialize" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'name\', \'options\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "num_records_produced" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "num_work_units_completed" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "read" + argspec: "args=[\'self\', \'queue\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "read_up_to" + argspec: "args=[\'self\', \'queue\', \'num_records\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "reset" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "restore_state" + argspec: "args=[\'self\', \'state\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "serialize_state" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-log-message.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-log-message.pbtxt new file mode 100644 index 0000000000..5023aa96bf --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-log-message.pbtxt @@ -0,0 +1,46 @@ +path: "tensorflow.LogMessage" +tf_proto { + descriptor { + name: "LogMessage" + field { + name: "level" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_ENUM + type_name: ".tensorflow.LogMessage.Level" + } + field { + name: "message" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + enum_type { + name: "Level" + value { + name: "UNKNOWN" + number: 0 + } + value { + name: "DEBUGGING" + number: 10 + } + value { + name: "INFO" + number: 20 + } + value { + name: "WARN" + number: 30 + } + value { + name: "ERROR" + number: 40 + } + value { + name: "FATAL" + number: 50 + } + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-meta-graph-def.-collection-def-entry.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-meta-graph-def.-collection-def-entry.pbtxt new file mode 100644 index 0000000000..0ba09bec4b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-meta-graph-def.-collection-def-entry.pbtxt @@ -0,0 +1,22 @@ +path: "tensorflow.MetaGraphDef.CollectionDefEntry" +tf_proto { + descriptor { + name: "CollectionDefEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.CollectionDef" + } + options { + map_entry: true + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-meta-graph-def.-meta-info-def.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-meta-graph-def.-meta-info-def.pbtxt new file mode 100644 index 0000000000..41c62a407b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-meta-graph-def.-meta-info-def.pbtxt @@ -0,0 +1,50 @@ +path: "tensorflow.MetaGraphDef.MetaInfoDef" +tf_proto { + descriptor { + name: "MetaInfoDef" + field { + name: "meta_graph_version" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "stripped_op_list" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.OpList" + } + field { + name: "any_info" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".google.protobuf.Any" + } + field { + name: "tags" + number: 4 + label: LABEL_REPEATED + type: TYPE_STRING + } + field { + name: "tensorflow_version" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "tensorflow_git_version" + number: 6 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "stripped_default_attrs" + number: 7 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-meta-graph-def.-signature-def-entry.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-meta-graph-def.-signature-def-entry.pbtxt new file mode 100644 index 0000000000..73dc414a77 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-meta-graph-def.-signature-def-entry.pbtxt @@ -0,0 +1,22 @@ +path: "tensorflow.MetaGraphDef.SignatureDefEntry" +tf_proto { + descriptor { + name: "SignatureDefEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.SignatureDef" + } + options { + map_entry: true + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-meta-graph-def.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-meta-graph-def.pbtxt new file mode 100644 index 0000000000..d71c2358c9 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-meta-graph-def.pbtxt @@ -0,0 +1,133 @@ +path: "tensorflow.MetaGraphDef" +tf_proto { + descriptor { + name: "MetaGraphDef" + field { + name: "meta_info_def" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.MetaGraphDef.MetaInfoDef" + } + field { + name: "graph_def" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.GraphDef" + } + field { + name: "saver_def" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.SaverDef" + } + field { + name: "collection_def" + number: 4 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.MetaGraphDef.CollectionDefEntry" + } + field { + name: "signature_def" + number: 5 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.MetaGraphDef.SignatureDefEntry" + } + field { + name: "asset_file_def" + number: 6 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.AssetFileDef" + } + nested_type { + name: "MetaInfoDef" + field { + name: "meta_graph_version" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "stripped_op_list" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.OpList" + } + field { + name: "any_info" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".google.protobuf.Any" + } + field { + name: "tags" + number: 4 + label: LABEL_REPEATED + type: TYPE_STRING + } + field { + name: "tensorflow_version" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "tensorflow_git_version" + number: 6 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "stripped_default_attrs" + number: 7 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + } + nested_type { + name: "CollectionDefEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.CollectionDef" + } + options { + map_entry: true + } + } + nested_type { + name: "SignatureDefEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.SignatureDef" + } + options { + map_entry: true + } + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-name-attr-list.-attr-entry.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-name-attr-list.-attr-entry.pbtxt new file mode 100644 index 0000000000..b119b20877 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-name-attr-list.-attr-entry.pbtxt @@ -0,0 +1,22 @@ +path: "tensorflow.NameAttrList.AttrEntry" +tf_proto { + descriptor { + name: "AttrEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.AttrValue" + } + options { + map_entry: true + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-name-attr-list.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-name-attr-list.pbtxt new file mode 100644 index 0000000000..fcdb411ffc --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-name-attr-list.pbtxt @@ -0,0 +1,38 @@ +path: "tensorflow.NameAttrList" +tf_proto { + descriptor { + name: "NameAttrList" + field { + name: "name" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "attr" + number: 2 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.NameAttrList.AttrEntry" + } + nested_type { + name: "AttrEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.AttrValue" + } + options { + map_entry: true + } + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-node-def.-attr-entry.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-node-def.-attr-entry.pbtxt new file mode 100644 index 0000000000..622e4c3d0f --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-node-def.-attr-entry.pbtxt @@ -0,0 +1,22 @@ +path: "tensorflow.NodeDef.AttrEntry" +tf_proto { + descriptor { + name: "AttrEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.AttrValue" + } + options { + map_entry: true + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-node-def.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-node-def.pbtxt new file mode 100644 index 0000000000..646fa8abb9 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-node-def.pbtxt @@ -0,0 +1,56 @@ +path: "tensorflow.NodeDef" +tf_proto { + descriptor { + name: "NodeDef" + field { + name: "name" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "op" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "input" + number: 3 + label: LABEL_REPEATED + type: TYPE_STRING + } + field { + name: "device" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "attr" + number: 5 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.NodeDef.AttrEntry" + } + nested_type { + name: "AttrEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.AttrValue" + } + options { + map_entry: true + } + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-op-error.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-op-error.pbtxt new file mode 100644 index 0000000000..7e59615534 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-op-error.pbtxt @@ -0,0 +1,29 @@ +path: "tensorflow.OpError" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "args" + mtype: "" + } + member { + name: "error_code" + mtype: "" + } + member { + name: "message" + mtype: "" + } + member { + name: "node_def" + mtype: "" + } + member { + name: "op" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'node_def\', \'op\', \'message\', \'error_code\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-operation.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-operation.pbtxt new file mode 100644 index 0000000000..64240f7069 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-operation.pbtxt @@ -0,0 +1,69 @@ +path: "tensorflow.Operation" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "control_inputs" + mtype: "" + } + member { + name: "device" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inputs" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "node_def" + mtype: "" + } + member { + name: "op_def" + mtype: "" + } + member { + name: "outputs" + mtype: "" + } + member { + name: "traceback" + mtype: "" + } + member { + name: "traceback_with_start_lines" + mtype: "" + } + member { + name: "type" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'node_def\', \'g\', \'inputs\', \'output_types\', \'control_inputs\', \'input_types\', \'original_op\', \'op_def\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "colocation_groups" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_attr" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "run" + argspec: "args=[\'self\', \'feed_dict\', \'session\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "values" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-optimizer-options.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-optimizer-options.pbtxt new file mode 100644 index 0000000000..3ccf9d459b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-optimizer-options.pbtxt @@ -0,0 +1,74 @@ +path: "tensorflow.OptimizerOptions" +tf_proto { + descriptor { + name: "OptimizerOptions" + field { + name: "do_common_subexpression_elimination" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "do_constant_folding" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "max_folded_constant_in_bytes" + number: 6 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "do_function_inlining" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "opt_level" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_ENUM + type_name: ".tensorflow.OptimizerOptions.Level" + } + field { + name: "global_jit_level" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_ENUM + type_name: ".tensorflow.OptimizerOptions.GlobalJitLevel" + } + enum_type { + name: "Level" + value { + name: "L1" + number: 0 + } + value { + name: "L0" + number: -1 + } + } + enum_type { + name: "GlobalJitLevel" + value { + name: "DEFAULT" + number: 0 + } + value { + name: "OFF" + number: -1 + } + value { + name: "ON_1" + number: 1 + } + value { + name: "ON_2" + number: 2 + } + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-padding-f-i-f-o-queue.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-padding-f-i-f-o-queue.pbtxt new file mode 100644 index 0000000000..8fed133561 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-padding-f-i-f-o-queue.pbtxt @@ -0,0 +1,66 @@ +path: "tensorflow.PaddingFIFOQueue" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "dtypes" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "names" + mtype: "" + } + member { + name: "queue_ref" + mtype: "" + } + member { + name: "shapes" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'capacity\', \'dtypes\', \'shapes\', \'names\', \'shared_name\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'padding_fifo_queue\'], " + } + member_method { + name: "close" + argspec: "args=[\'self\', \'cancel_pending_enqueues\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "dequeue" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "dequeue_many" + argspec: "args=[\'self\', \'n\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "dequeue_up_to" + argspec: "args=[\'self\', \'n\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "enqueue" + argspec: "args=[\'self\', \'vals\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "enqueue_many" + argspec: "args=[\'self\', \'vals\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "from_list" + argspec: "args=[\'index\', \'queues\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "is_closed" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "size" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-priority-queue.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-priority-queue.pbtxt new file mode 100644 index 0000000000..ebb017e81b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-priority-queue.pbtxt @@ -0,0 +1,66 @@ +path: "tensorflow.PriorityQueue" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "dtypes" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "names" + mtype: "" + } + member { + name: "queue_ref" + mtype: "" + } + member { + name: "shapes" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'capacity\', \'types\', \'shapes\', \'names\', \'shared_name\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'priority_queue\'], " + } + member_method { + name: "close" + argspec: "args=[\'self\', \'cancel_pending_enqueues\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "dequeue" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "dequeue_many" + argspec: "args=[\'self\', \'n\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "dequeue_up_to" + argspec: "args=[\'self\', \'n\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "enqueue" + argspec: "args=[\'self\', \'vals\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "enqueue_many" + argspec: "args=[\'self\', \'vals\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "from_list" + argspec: "args=[\'index\', \'queues\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "is_closed" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "size" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-queue-base.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-queue-base.pbtxt new file mode 100644 index 0000000000..761f90989f --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-queue-base.pbtxt @@ -0,0 +1,65 @@ +path: "tensorflow.QueueBase" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "dtypes" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "names" + mtype: "" + } + member { + name: "queue_ref" + mtype: "" + } + member { + name: "shapes" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'dtypes\', \'shapes\', \'names\', \'queue_ref\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "close" + argspec: "args=[\'self\', \'cancel_pending_enqueues\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "dequeue" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "dequeue_many" + argspec: "args=[\'self\', \'n\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "dequeue_up_to" + argspec: "args=[\'self\', \'n\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "enqueue" + argspec: "args=[\'self\', \'vals\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "enqueue_many" + argspec: "args=[\'self\', \'vals\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "from_list" + argspec: "args=[\'index\', \'queues\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "is_closed" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "size" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-random-shuffle-queue.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-random-shuffle-queue.pbtxt new file mode 100644 index 0000000000..f3ca841393 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-random-shuffle-queue.pbtxt @@ -0,0 +1,66 @@ +path: "tensorflow.RandomShuffleQueue" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "dtypes" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "names" + mtype: "" + } + member { + name: "queue_ref" + mtype: "" + } + member { + name: "shapes" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'capacity\', \'min_after_dequeue\', \'dtypes\', \'shapes\', \'names\', \'seed\', \'shared_name\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'random_shuffle_queue\'], " + } + member_method { + name: "close" + argspec: "args=[\'self\', \'cancel_pending_enqueues\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "dequeue" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "dequeue_many" + argspec: "args=[\'self\', \'n\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "dequeue_up_to" + argspec: "args=[\'self\', \'n\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "enqueue" + argspec: "args=[\'self\', \'vals\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "enqueue_many" + argspec: "args=[\'self\', \'vals\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "from_list" + argspec: "args=[\'index\', \'queues\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "is_closed" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "size" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-reader-base.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-reader-base.pbtxt new file mode 100644 index 0000000000..f6a3ce76a1 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-reader-base.pbtxt @@ -0,0 +1,45 @@ +path: "tensorflow.ReaderBase" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "reader_ref" + mtype: "" + } + member { + name: "supports_serialize" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'reader_ref\', \'supports_serialize\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "num_records_produced" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "num_work_units_completed" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "read" + argspec: "args=[\'self\', \'queue\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "read_up_to" + argspec: "args=[\'self\', \'queue\', \'num_records\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "reset" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "restore_state" + argspec: "args=[\'self\', \'state\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "serialize_state" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-register-gradient.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-register-gradient.pbtxt new file mode 100644 index 0000000000..4d6e4137d1 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-register-gradient.pbtxt @@ -0,0 +1,9 @@ +path: "tensorflow.RegisterGradient" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'op_type\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-run-metadata.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-run-metadata.pbtxt new file mode 100644 index 0000000000..1287940326 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-run-metadata.pbtxt @@ -0,0 +1,27 @@ +path: "tensorflow.RunMetadata" +tf_proto { + descriptor { + name: "RunMetadata" + field { + name: "step_stats" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.StepStats" + } + field { + name: "cost_graph" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.CostGraphDef" + } + field { + name: "partition_graphs" + number: 3 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.GraphDef" + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-run-options.-experimental.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-run-options.-experimental.pbtxt new file mode 100644 index 0000000000..537e73aa89 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-run-options.-experimental.pbtxt @@ -0,0 +1,12 @@ +path: "tensorflow.RunOptions.Experimental" +tf_proto { + descriptor { + name: "Experimental" + field { + name: "collective_graph_key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-run-options.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-run-options.pbtxt new file mode 100644 index 0000000000..cec04a2bf0 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-run-options.pbtxt @@ -0,0 +1,83 @@ +path: "tensorflow.RunOptions" +tf_proto { + descriptor { + name: "RunOptions" + field { + name: "trace_level" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_ENUM + type_name: ".tensorflow.RunOptions.TraceLevel" + } + field { + name: "timeout_in_ms" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "inter_op_thread_pool" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "output_partition_graphs" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "debug_options" + number: 6 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.DebugOptions" + } + field { + name: "report_tensor_allocations_upon_oom" + number: 7 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "experimental" + number: 8 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.RunOptions.Experimental" + } + nested_type { + name: "Experimental" + field { + name: "collective_graph_key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + } + enum_type { + name: "TraceLevel" + value { + name: "NO_TRACE" + number: 0 + } + value { + name: "SOFTWARE_TRACE" + number: 1 + } + value { + name: "HARDWARE_TRACE" + number: 2 + } + value { + name: "FULL_TRACE" + number: 3 + } + } + reserved_range { + start: 4 + end: 5 + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-session-log.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-session-log.pbtxt new file mode 100644 index 0000000000..259f241874 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-session-log.pbtxt @@ -0,0 +1,44 @@ +path: "tensorflow.SessionLog" +tf_proto { + descriptor { + name: "SessionLog" + field { + name: "status" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_ENUM + type_name: ".tensorflow.SessionLog.SessionStatus" + } + field { + name: "checkpoint_path" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "msg" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + enum_type { + name: "SessionStatus" + value { + name: "STATUS_UNSPECIFIED" + number: 0 + } + value { + name: "START" + number: 1 + } + value { + name: "STOP" + number: 2 + } + value { + name: "CHECKPOINT" + number: 3 + } + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-session.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-session.pbtxt new file mode 100644 index 0000000000..1d6b037f9c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-session.pbtxt @@ -0,0 +1,55 @@ +path: "tensorflow.Session" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "graph" + mtype: "" + } + member { + name: "graph_def" + mtype: "" + } + member { + name: "sess_str" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'target\', \'graph\', \'config\'], varargs=None, keywords=None, defaults=[\'\', \'None\', \'None\'], " + } + member_method { + name: "as_default" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "close" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "list_devices" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "make_callable" + argspec: "args=[\'self\', \'fetches\', \'feed_list\', \'accept_options\'], varargs=None, keywords=None, defaults=[\'None\', \'False\'], " + } + member_method { + name: "partial_run" + argspec: "args=[\'self\', \'handle\', \'fetches\', \'feed_dict\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "partial_run_setup" + argspec: "args=[\'self\', \'fetches\', \'feeds\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "reset" + argspec: "args=[\'target\', \'containers\', \'config\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "run" + argspec: "args=[\'self\', \'fetches\', \'feed_dict\', \'options\', \'run_metadata\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-sparse-conditional-accumulator.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-sparse-conditional-accumulator.pbtxt new file mode 100644 index 0000000000..2260279ad2 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-sparse-conditional-accumulator.pbtxt @@ -0,0 +1,46 @@ +path: "tensorflow.SparseConditionalAccumulator" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "accumulator_ref" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'dtype\', \'shape\', \'shared_name\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'sparse_conditional_accumulator\'], " + } + member_method { + name: "apply_grad" + argspec: "args=[\'self\', \'grad_indices\', \'grad_values\', \'grad_shape\', \'local_step\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'0\', \'None\'], " + } + member_method { + name: "apply_indexed_slices_grad" + argspec: "args=[\'self\', \'grad\', \'local_step\', \'name\'], varargs=None, keywords=None, defaults=[\'0\', \'None\'], " + } + member_method { + name: "num_accumulated" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_global_step" + argspec: "args=[\'self\', \'new_global_step\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "take_grad" + argspec: "args=[\'self\', \'num_required\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "take_indexed_slices_grad" + argspec: "args=[\'self\', \'num_required\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-sparse-feature.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-sparse-feature.pbtxt new file mode 100644 index 0000000000..d875394fb5 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-sparse-feature.pbtxt @@ -0,0 +1,35 @@ +path: "tensorflow.SparseFeature" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "already_sorted" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "index_key" + mtype: "" + } + member { + name: "size" + mtype: "" + } + member { + name: "value_key" + mtype: "" + } + member_method { + name: "__init__" + } + member_method { + name: "count" + } + member_method { + name: "index" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-sparse-tensor-value.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-sparse-tensor-value.pbtxt new file mode 100644 index 0000000000..d33fd4d5d7 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-sparse-tensor-value.pbtxt @@ -0,0 +1,26 @@ +path: "tensorflow.SparseTensorValue" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "dense_shape" + mtype: "" + } + member { + name: "indices" + mtype: "" + } + member { + name: "values" + mtype: "" + } + member_method { + name: "__init__" + } + member_method { + name: "count" + } + member_method { + name: "index" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-sparse-tensor.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-sparse-tensor.pbtxt new file mode 100644 index 0000000000..eac236d498 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-sparse-tensor.pbtxt @@ -0,0 +1,46 @@ +path: "tensorflow.SparseTensor" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "dense_shape" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "indices" + mtype: "" + } + member { + name: "op" + mtype: "" + } + member { + name: "values" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'indices\', \'values\', \'dense_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "eval" + argspec: "args=[\'self\', \'feed_dict\', \'session\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "from_value" + argspec: "args=[\'cls\', \'sparse_tensor_value\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_shape" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-summary-metadata.-plugin-data.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-summary-metadata.-plugin-data.pbtxt new file mode 100644 index 0000000000..a66b74b315 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-summary-metadata.-plugin-data.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.SummaryMetadata.PluginData" +tf_proto { + descriptor { + name: "PluginData" + field { + name: "plugin_name" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "content" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_BYTES + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-summary-metadata.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-summary-metadata.pbtxt new file mode 100644 index 0000000000..c02575b962 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-summary-metadata.pbtxt @@ -0,0 +1,40 @@ +path: "tensorflow.SummaryMetadata" +tf_proto { + descriptor { + name: "SummaryMetadata" + field { + name: "plugin_data" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.SummaryMetadata.PluginData" + } + field { + name: "display_name" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "summary_description" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + nested_type { + name: "PluginData" + field { + name: "plugin_name" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "content" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_BYTES + } + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-summary.-audio.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-summary.-audio.pbtxt new file mode 100644 index 0000000000..94f712073e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-summary.-audio.pbtxt @@ -0,0 +1,36 @@ +path: "tensorflow.Summary.Audio" +tf_proto { + descriptor { + name: "Audio" + field { + name: "sample_rate" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_FLOAT + } + field { + name: "num_channels" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "length_frames" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "encoded_audio_string" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_BYTES + } + field { + name: "content_type" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-summary.-image.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-summary.-image.pbtxt new file mode 100644 index 0000000000..fc1acb483b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-summary.-image.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.Summary.Image" +tf_proto { + descriptor { + name: "Image" + field { + name: "height" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "width" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "colorspace" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "encoded_image_string" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_BYTES + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-summary.-value.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-summary.-value.pbtxt new file mode 100644 index 0000000000..feb84b6ee9 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-summary.-value.pbtxt @@ -0,0 +1,74 @@ +path: "tensorflow.Summary.Value" +tf_proto { + descriptor { + name: "Value" + field { + name: "node_name" + number: 7 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "tag" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "metadata" + number: 9 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.SummaryMetadata" + } + field { + name: "simple_value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_FLOAT + oneof_index: 0 + } + field { + name: "obsolete_old_style_histogram" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_BYTES + oneof_index: 0 + } + field { + name: "image" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.Summary.Image" + oneof_index: 0 + } + field { + name: "histo" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.HistogramProto" + oneof_index: 0 + } + field { + name: "audio" + number: 6 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.Summary.Audio" + oneof_index: 0 + } + field { + name: "tensor" + number: 8 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.TensorProto" + oneof_index: 0 + } + oneof_decl { + name: "value" + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-summary.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-summary.pbtxt new file mode 100644 index 0000000000..b2bdff7171 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-summary.pbtxt @@ -0,0 +1,144 @@ +path: "tensorflow.Summary" +tf_proto { + descriptor { + name: "Summary" + field { + name: "value" + number: 1 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.Summary.Value" + } + nested_type { + name: "Image" + field { + name: "height" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "width" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "colorspace" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "encoded_image_string" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_BYTES + } + } + nested_type { + name: "Audio" + field { + name: "sample_rate" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_FLOAT + } + field { + name: "num_channels" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "length_frames" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "encoded_audio_string" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_BYTES + } + field { + name: "content_type" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + } + nested_type { + name: "Value" + field { + name: "node_name" + number: 7 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "tag" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "metadata" + number: 9 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.SummaryMetadata" + } + field { + name: "simple_value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_FLOAT + oneof_index: 0 + } + field { + name: "obsolete_old_style_histogram" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_BYTES + oneof_index: 0 + } + field { + name: "image" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.Summary.Image" + oneof_index: 0 + } + field { + name: "histo" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.HistogramProto" + oneof_index: 0 + } + field { + name: "audio" + number: 6 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.Summary.Audio" + oneof_index: 0 + } + field { + name: "tensor" + number: 8 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.TensorProto" + oneof_index: 0 + } + oneof_decl { + name: "value" + } + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-t-f-record-reader.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-t-f-record-reader.pbtxt new file mode 100644 index 0000000000..cdf7937391 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-t-f-record-reader.pbtxt @@ -0,0 +1,46 @@ +path: "tensorflow.TFRecordReader" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "reader_ref" + mtype: "" + } + member { + name: "supports_serialize" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'name\', \'options\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "num_records_produced" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "num_work_units_completed" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "read" + argspec: "args=[\'self\', \'queue\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "read_up_to" + argspec: "args=[\'self\', \'queue\', \'num_records\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "reset" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "restore_state" + argspec: "args=[\'self\', \'state\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "serialize_state" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-tensor-array.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-tensor-array.pbtxt new file mode 100644 index 0000000000..ed088c41ed --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-tensor-array.pbtxt @@ -0,0 +1,69 @@ +path: "tensorflow.TensorArray" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "dtype" + mtype: "" + } + member { + name: "flow" + mtype: "" + } + member { + name: "handle" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'dtype\', \'size\', \'dynamic_size\', \'clear_after_read\', \'tensor_array_name\', \'handle\', \'flow\', \'infer_shape\', \'element_shape\', \'colocate_with_first_write_call\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'True\', \'None\', \'True\', \'None\'], " + } + member_method { + name: "close" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "concat" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "gather" + argspec: "args=[\'self\', \'indices\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "grad" + argspec: "args=[\'self\', \'source\', \'flow\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "identity" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "read" + argspec: "args=[\'self\', \'index\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "scatter" + argspec: "args=[\'self\', \'indices\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "size" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "split" + argspec: "args=[\'self\', \'value\', \'lengths\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "stack" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "unstack" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "write" + argspec: "args=[\'self\', \'index\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-tensor-info.-coo-sparse.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-tensor-info.-coo-sparse.pbtxt new file mode 100644 index 0000000000..0064c8460c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-tensor-info.-coo-sparse.pbtxt @@ -0,0 +1,24 @@ +path: "tensorflow.TensorInfo.CooSparse" +tf_proto { + descriptor { + name: "CooSparse" + field { + name: "values_tensor_name" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "indices_tensor_name" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "dense_shape_tensor_name" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-tensor-info.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-tensor-info.pbtxt new file mode 100644 index 0000000000..63566c808e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-tensor-info.pbtxt @@ -0,0 +1,59 @@ +path: "tensorflow.TensorInfo" +tf_proto { + descriptor { + name: "TensorInfo" + field { + name: "name" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + oneof_index: 0 + } + field { + name: "coo_sparse" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.TensorInfo.CooSparse" + oneof_index: 0 + } + field { + name: "dtype" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_ENUM + type_name: ".tensorflow.DataType" + } + field { + name: "tensor_shape" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.TensorShapeProto" + } + nested_type { + name: "CooSparse" + field { + name: "values_tensor_name" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "indices_tensor_name" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "dense_shape_tensor_name" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + } + oneof_decl { + name: "encoding" + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-tensor-shape.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-tensor-shape.pbtxt new file mode 100644 index 0000000000..8e3598fb24 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-tensor-shape.pbtxt @@ -0,0 +1,77 @@ +path: "tensorflow.TensorShape" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "dims" + mtype: "" + } + member { + name: "ndims" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'dims\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "as_list" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "as_proto" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "assert_has_rank" + argspec: "args=[\'self\', \'rank\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "assert_is_compatible_with" + argspec: "args=[\'self\', \'other\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "assert_is_fully_defined" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "assert_same_rank" + argspec: "args=[\'self\', \'other\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "concatenate" + argspec: "args=[\'self\', \'other\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "is_compatible_with" + argspec: "args=[\'self\', \'other\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "is_fully_defined" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "merge_with" + argspec: "args=[\'self\', \'other\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "most_specific_compatible_shape" + argspec: "args=[\'self\', \'other\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "num_elements" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "with_rank" + argspec: "args=[\'self\', \'rank\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "with_rank_at_least" + argspec: "args=[\'self\', \'rank\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "with_rank_at_most" + argspec: "args=[\'self\', \'rank\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-tensor.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-tensor.pbtxt new file mode 100644 index 0000000000..38d19bb537 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-tensor.pbtxt @@ -0,0 +1,58 @@ +path: "tensorflow.Tensor" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "OVERLOADABLE_OPERATORS" + mtype: "" + } + member { + name: "device" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "op" + mtype: "" + } + member { + name: "shape" + mtype: "" + } + member { + name: "value_index" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'op\', \'value_index\', \'dtype\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "consumers" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "eval" + argspec: "args=[\'self\', \'feed_dict\', \'session\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "get_shape" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_shape" + argspec: "args=[\'self\', \'shape\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-text-line-reader.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-text-line-reader.pbtxt new file mode 100644 index 0000000000..e9779f0762 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-text-line-reader.pbtxt @@ -0,0 +1,46 @@ +path: "tensorflow.TextLineReader" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "reader_ref" + mtype: "" + } + member { + name: "supports_serialize" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'skip_header_lines\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "num_records_produced" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "num_work_units_completed" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "read" + argspec: "args=[\'self\', \'queue\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "read_up_to" + argspec: "args=[\'self\', \'queue\', \'num_records\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "reset" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "restore_state" + argspec: "args=[\'self\', \'state\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "serialize_state" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-var-len-feature.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-var-len-feature.pbtxt new file mode 100644 index 0000000000..54b66f43f8 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-var-len-feature.pbtxt @@ -0,0 +1,19 @@ +path: "tensorflow.VarLenFeature" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "dtype" + mtype: "" + } + member_method { + name: "__init__" + } + member_method { + name: "count" + } + member_method { + name: "index" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-variable-aggregation.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-variable-aggregation.pbtxt new file mode 100644 index 0000000000..36b534af36 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-variable-aggregation.pbtxt @@ -0,0 +1,16 @@ +path: "tensorflow.VariableAggregation" +tf_class { + is_instance: "" + member { + name: "MEAN" + mtype: "" + } + member { + name: "NONE" + mtype: "" + } + member { + name: "SUM" + mtype: "" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-variable-scope.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-variable-scope.pbtxt new file mode 100644 index 0000000000..c13eb7b8bb --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-variable-scope.pbtxt @@ -0,0 +1,105 @@ +path: "tensorflow.VariableScope" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "caching_device" + mtype: "" + } + member { + name: "constraint" + mtype: "" + } + member { + name: "custom_getter" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "initializer" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "original_name_scope" + mtype: "" + } + member { + name: "partitioner" + mtype: "" + } + member { + name: "regularizer" + mtype: "" + } + member { + name: "reuse" + mtype: "" + } + member { + name: "use_resource" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'reuse\', \'name\', \'initializer\', \'regularizer\', \'caching_device\', \'partitioner\', \'custom_getter\', \'name_scope\', \'dtype\', \'use_resource\', \'constraint\'], varargs=None, keywords=None, defaults=[\'\', \'None\', \'None\', \'None\', \'None\', \'None\', \'\', \"\", \'None\', \'None\'], " + } + member_method { + name: "get_collection" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_variable" + argspec: "args=[\'self\', \'var_store\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'reuse\', \'trainable\', \'collections\', \'caching_device\', \'partitioner\', \'validate_shape\', \'use_resource\', \'custom_getter\', \'constraint\', \'synchronization\', \'aggregation\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'True\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\'], " + } + member_method { + name: "global_variables" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "local_variables" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "reuse_variables" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_caching_device" + argspec: "args=[\'self\', \'caching_device\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_custom_getter" + argspec: "args=[\'self\', \'custom_getter\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_dtype" + argspec: "args=[\'self\', \'dtype\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_initializer" + argspec: "args=[\'self\', \'initializer\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_partitioner" + argspec: "args=[\'self\', \'partitioner\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_regularizer" + argspec: "args=[\'self\', \'regularizer\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_use_resource" + argspec: "args=[\'self\', \'use_resource\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "trainable_variables" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-variable-synchronization.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-variable-synchronization.pbtxt new file mode 100644 index 0000000000..7589bb2888 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-variable-synchronization.pbtxt @@ -0,0 +1,20 @@ +path: "tensorflow.VariableSynchronization" +tf_class { + is_instance: "" + member { + name: "AUTO" + mtype: "" + } + member { + name: "NONE" + mtype: "" + } + member { + name: "ON_READ" + mtype: "" + } + member { + name: "ON_WRITE" + mtype: "" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-variable.-save-slice-info.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-variable.-save-slice-info.pbtxt new file mode 100644 index 0000000000..ac3ccd468b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-variable.-save-slice-info.pbtxt @@ -0,0 +1,17 @@ +path: "tensorflow.Variable.SaveSliceInfo" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "spec" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'full_name\', \'full_shape\', \'var_offset\', \'var_shape\', \'save_slice_info_def\', \'import_scope\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "to_proto" + argspec: "args=[\'self\', \'export_scope\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-variable.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-variable.pbtxt new file mode 100644 index 0000000000..e841c4ad89 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-variable.pbtxt @@ -0,0 +1,110 @@ +path: "tensorflow.Variable" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "SaveSliceInfo" + mtype: "" + } + member { + name: "constraint" + mtype: "" + } + member { + name: "device" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "initial_value" + mtype: "" + } + member { + name: "initializer" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "op" + mtype: "" + } + member { + name: "shape" + mtype: "" + } + member { + name: "trainable" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'initial_value\', \'trainable\', \'collections\', \'validate_shape\', \'caching_device\', \'name\', \'variable_def\', \'dtype\', \'expected_shape\', \'import_scope\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\'], varargs=None, keywords=None, defaults=[\'None\', \'True\', \'None\', \'True\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\'], " + } + member_method { + name: "assign" + argspec: "args=[\'self\', \'value\', \'use_locking\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "assign_add" + argspec: "args=[\'self\', \'delta\', \'use_locking\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "assign_sub" + argspec: "args=[\'self\', \'delta\', \'use_locking\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "count_up_to" + argspec: "args=[\'self\', \'limit\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "eval" + argspec: "args=[\'self\', \'session\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "from_proto" + argspec: "args=[\'variable_def\', \'import_scope\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_shape" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "initialized_value" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "load" + argspec: "args=[\'self\', \'value\', \'session\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "read_value" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "scatter_sub" + argspec: "args=[\'self\', \'sparse_delta\', \'use_locking\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "set_shape" + argspec: "args=[\'self\', \'shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "to_proto" + argspec: "args=[\'self\', \'export_scope\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "value" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.-whole-file-reader.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.-whole-file-reader.pbtxt new file mode 100644 index 0000000000..4ac759891c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.-whole-file-reader.pbtxt @@ -0,0 +1,46 @@ +path: "tensorflow.WholeFileReader" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "reader_ref" + mtype: "" + } + member { + name: "supports_serialize" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "num_records_produced" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "num_work_units_completed" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "read" + argspec: "args=[\'self\', \'queue\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "read_up_to" + argspec: "args=[\'self\', \'queue\', \'num_records\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "reset" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "restore_state" + argspec: "args=[\'self\', \'state\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "serialize_state" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.app.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.app.pbtxt new file mode 100644 index 0000000000..85044a8987 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.app.pbtxt @@ -0,0 +1,11 @@ +path: "tensorflow.app" +tf_module { + member { + name: "flags" + mtype: "" + } + member_method { + name: "run" + argspec: "args=[\'main\', \'argv\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.bitwise.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.bitwise.pbtxt new file mode 100644 index 0000000000..01cbd55c5d --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.bitwise.pbtxt @@ -0,0 +1,27 @@ +path: "tensorflow.bitwise" +tf_module { + member_method { + name: "bitwise_and" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "bitwise_or" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "bitwise_xor" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "invert" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "left_shift" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "right_shift" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.compat.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.compat.pbtxt new file mode 100644 index 0000000000..f1d760603e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.compat.pbtxt @@ -0,0 +1,47 @@ +path: "tensorflow.compat" +tf_module { + member { + name: "bytes_or_text_types" + mtype: "" + } + member { + name: "complex_types" + mtype: "" + } + member { + name: "integral_types" + mtype: "" + } + member { + name: "real_types" + mtype: "" + } + member_method { + name: "as_bytes" + argspec: "args=[\'bytes_or_text\', \'encoding\'], varargs=None, keywords=None, defaults=[\'utf-8\'], " + } + member_method { + name: "as_str" + argspec: "args=[\'bytes_or_text\', \'encoding\'], varargs=None, keywords=None, defaults=[\'utf-8\'], " + } + member_method { + name: "as_str_any" + argspec: "args=[\'value\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "as_text" + argspec: "args=[\'bytes_or_text\', \'encoding\'], varargs=None, keywords=None, defaults=[\'utf-8\'], " + } + member_method { + name: "forward_compatibility_horizon" + argspec: "args=[\'year\', \'month\', \'day\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "forward_compatible" + argspec: "args=[\'year\', \'month\', \'day\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "path_to_str" + argspec: "args=[\'path\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.constant_initializer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.constant_initializer.pbtxt new file mode 100644 index 0000000000..00ec669b16 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.constant_initializer.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.constant_initializer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'value\', \'dtype\', \'verify_shape\'], varargs=None, keywords=None, defaults=[\'0\', \"\", \'False\'], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.data.-dataset.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.data.-dataset.__metaclass__.pbtxt new file mode 100644 index 0000000000..af08c88d33 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.data.-dataset.__metaclass__.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.data.Dataset.__metaclass__" +tf_class { + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "mro" + } + member_method { + name: "register" + argspec: "args=[\'cls\', \'subclass\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.data.-dataset.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.data.-dataset.pbtxt new file mode 100644 index 0000000000..834f0954d5 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.data.-dataset.pbtxt @@ -0,0 +1,117 @@ +path: "tensorflow.data.Dataset" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "output_classes" + mtype: "" + } + member { + name: "output_shapes" + mtype: "" + } + member { + name: "output_types" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'transformation_func\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "batch" + argspec: "args=[\'self\', \'batch_size\', \'drop_remainder\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "cache" + argspec: "args=[\'self\', \'filename\'], varargs=None, keywords=None, defaults=[\'\'], " + } + member_method { + name: "concatenate" + argspec: "args=[\'self\', \'dataset\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "filter" + argspec: "args=[\'self\', \'predicate\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "flat_map" + argspec: "args=[\'self\', \'map_func\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_generator" + argspec: "args=[\'generator\', \'output_types\', \'output_shapes\', \'args\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "from_sparse_tensor_slices" + argspec: "args=[\'sparse_tensor\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_tensor_slices" + argspec: "args=[\'tensors\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_tensors" + argspec: "args=[\'tensors\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "interleave" + argspec: "args=[\'self\', \'map_func\', \'cycle_length\', \'block_length\'], varargs=None, keywords=None, defaults=[\'1\'], " + } + member_method { + name: "list_files" + argspec: "args=[\'file_pattern\', \'shuffle\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "make_initializable_iterator" + argspec: "args=[\'self\', \'shared_name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "make_one_shot_iterator" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "map" + argspec: "args=[\'self\', \'map_func\', \'num_parallel_calls\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "padded_batch" + argspec: "args=[\'self\', \'batch_size\', \'padded_shapes\', \'padding_values\', \'drop_remainder\'], varargs=None, keywords=None, defaults=[\'None\', \'False\'], " + } + member_method { + name: "prefetch" + argspec: "args=[\'self\', \'buffer_size\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "range" + argspec: "args=[], varargs=args, keywords=None, defaults=None" + } + member_method { + name: "repeat" + argspec: "args=[\'self\', \'count\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "shard" + argspec: "args=[\'self\', \'num_shards\', \'index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "shuffle" + argspec: "args=[\'self\', \'buffer_size\', \'seed\', \'reshuffle_each_iteration\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "skip" + argspec: "args=[\'self\', \'count\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "take" + argspec: "args=[\'self\', \'count\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "zip" + argspec: "args=[\'datasets\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.data.-fixed-length-record-dataset.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.data.-fixed-length-record-dataset.__metaclass__.pbtxt new file mode 100644 index 0000000000..f384323fc8 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.data.-fixed-length-record-dataset.__metaclass__.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.data.FixedLengthRecordDataset.__metaclass__" +tf_class { + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "mro" + } + member_method { + name: "register" + argspec: "args=[\'cls\', \'subclass\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.data.-fixed-length-record-dataset.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.data.-fixed-length-record-dataset.pbtxt new file mode 100644 index 0000000000..4d854a4cee --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.data.-fixed-length-record-dataset.pbtxt @@ -0,0 +1,118 @@ +path: "tensorflow.data.FixedLengthRecordDataset" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "output_classes" + mtype: "" + } + member { + name: "output_shapes" + mtype: "" + } + member { + name: "output_types" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filenames\', \'record_bytes\', \'header_bytes\', \'footer_bytes\', \'buffer_size\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'transformation_func\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "batch" + argspec: "args=[\'self\', \'batch_size\', \'drop_remainder\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "cache" + argspec: "args=[\'self\', \'filename\'], varargs=None, keywords=None, defaults=[\'\'], " + } + member_method { + name: "concatenate" + argspec: "args=[\'self\', \'dataset\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "filter" + argspec: "args=[\'self\', \'predicate\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "flat_map" + argspec: "args=[\'self\', \'map_func\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_generator" + argspec: "args=[\'generator\', \'output_types\', \'output_shapes\', \'args\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "from_sparse_tensor_slices" + argspec: "args=[\'sparse_tensor\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_tensor_slices" + argspec: "args=[\'tensors\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_tensors" + argspec: "args=[\'tensors\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "interleave" + argspec: "args=[\'self\', \'map_func\', \'cycle_length\', \'block_length\'], varargs=None, keywords=None, defaults=[\'1\'], " + } + member_method { + name: "list_files" + argspec: "args=[\'file_pattern\', \'shuffle\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "make_initializable_iterator" + argspec: "args=[\'self\', \'shared_name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "make_one_shot_iterator" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "map" + argspec: "args=[\'self\', \'map_func\', \'num_parallel_calls\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "padded_batch" + argspec: "args=[\'self\', \'batch_size\', \'padded_shapes\', \'padding_values\', \'drop_remainder\'], varargs=None, keywords=None, defaults=[\'None\', \'False\'], " + } + member_method { + name: "prefetch" + argspec: "args=[\'self\', \'buffer_size\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "range" + argspec: "args=[], varargs=args, keywords=None, defaults=None" + } + member_method { + name: "repeat" + argspec: "args=[\'self\', \'count\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "shard" + argspec: "args=[\'self\', \'num_shards\', \'index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "shuffle" + argspec: "args=[\'self\', \'buffer_size\', \'seed\', \'reshuffle_each_iteration\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "skip" + argspec: "args=[\'self\', \'count\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "take" + argspec: "args=[\'self\', \'count\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "zip" + argspec: "args=[\'datasets\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.data.-iterator.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.data.-iterator.pbtxt new file mode 100644 index 0000000000..1f9aeb6ad6 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.data.-iterator.pbtxt @@ -0,0 +1,45 @@ +path: "tensorflow.data.Iterator" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "initializer" + mtype: "" + } + member { + name: "output_classes" + mtype: "" + } + member { + name: "output_shapes" + mtype: "" + } + member { + name: "output_types" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'iterator_resource\', \'initializer\', \'output_types\', \'output_shapes\', \'output_classes\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_string_handle" + argspec: "args=[\'string_handle\', \'output_types\', \'output_shapes\', \'output_classes\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "from_structure" + argspec: "args=[\'output_types\', \'output_shapes\', \'shared_name\', \'output_classes\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "get_next" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "make_initializer" + argspec: "args=[\'self\', \'dataset\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "string_handle" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.data.-t-f-record-dataset.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.data.-t-f-record-dataset.__metaclass__.pbtxt new file mode 100644 index 0000000000..b12dec8a70 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.data.-t-f-record-dataset.__metaclass__.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.data.TFRecordDataset.__metaclass__" +tf_class { + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "mro" + } + member_method { + name: "register" + argspec: "args=[\'cls\', \'subclass\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.data.-t-f-record-dataset.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.data.-t-f-record-dataset.pbtxt new file mode 100644 index 0000000000..601f095a60 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.data.-t-f-record-dataset.pbtxt @@ -0,0 +1,118 @@ +path: "tensorflow.data.TFRecordDataset" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "output_classes" + mtype: "" + } + member { + name: "output_shapes" + mtype: "" + } + member { + name: "output_types" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filenames\', \'compression_type\', \'buffer_size\', \'num_parallel_reads\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'transformation_func\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "batch" + argspec: "args=[\'self\', \'batch_size\', \'drop_remainder\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "cache" + argspec: "args=[\'self\', \'filename\'], varargs=None, keywords=None, defaults=[\'\'], " + } + member_method { + name: "concatenate" + argspec: "args=[\'self\', \'dataset\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "filter" + argspec: "args=[\'self\', \'predicate\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "flat_map" + argspec: "args=[\'self\', \'map_func\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_generator" + argspec: "args=[\'generator\', \'output_types\', \'output_shapes\', \'args\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "from_sparse_tensor_slices" + argspec: "args=[\'sparse_tensor\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_tensor_slices" + argspec: "args=[\'tensors\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_tensors" + argspec: "args=[\'tensors\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "interleave" + argspec: "args=[\'self\', \'map_func\', \'cycle_length\', \'block_length\'], varargs=None, keywords=None, defaults=[\'1\'], " + } + member_method { + name: "list_files" + argspec: "args=[\'file_pattern\', \'shuffle\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "make_initializable_iterator" + argspec: "args=[\'self\', \'shared_name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "make_one_shot_iterator" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "map" + argspec: "args=[\'self\', \'map_func\', \'num_parallel_calls\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "padded_batch" + argspec: "args=[\'self\', \'batch_size\', \'padded_shapes\', \'padding_values\', \'drop_remainder\'], varargs=None, keywords=None, defaults=[\'None\', \'False\'], " + } + member_method { + name: "prefetch" + argspec: "args=[\'self\', \'buffer_size\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "range" + argspec: "args=[], varargs=args, keywords=None, defaults=None" + } + member_method { + name: "repeat" + argspec: "args=[\'self\', \'count\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "shard" + argspec: "args=[\'self\', \'num_shards\', \'index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "shuffle" + argspec: "args=[\'self\', \'buffer_size\', \'seed\', \'reshuffle_each_iteration\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "skip" + argspec: "args=[\'self\', \'count\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "take" + argspec: "args=[\'self\', \'count\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "zip" + argspec: "args=[\'datasets\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.data.-text-line-dataset.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.data.-text-line-dataset.__metaclass__.pbtxt new file mode 100644 index 0000000000..7ddcdce266 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.data.-text-line-dataset.__metaclass__.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.data.TextLineDataset.__metaclass__" +tf_class { + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "mro" + } + member_method { + name: "register" + argspec: "args=[\'cls\', \'subclass\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.data.-text-line-dataset.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.data.-text-line-dataset.pbtxt new file mode 100644 index 0000000000..587829a4c0 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.data.-text-line-dataset.pbtxt @@ -0,0 +1,118 @@ +path: "tensorflow.data.TextLineDataset" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "output_classes" + mtype: "" + } + member { + name: "output_shapes" + mtype: "" + } + member { + name: "output_types" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filenames\', \'compression_type\', \'buffer_size\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'transformation_func\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "batch" + argspec: "args=[\'self\', \'batch_size\', \'drop_remainder\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "cache" + argspec: "args=[\'self\', \'filename\'], varargs=None, keywords=None, defaults=[\'\'], " + } + member_method { + name: "concatenate" + argspec: "args=[\'self\', \'dataset\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "filter" + argspec: "args=[\'self\', \'predicate\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "flat_map" + argspec: "args=[\'self\', \'map_func\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_generator" + argspec: "args=[\'generator\', \'output_types\', \'output_shapes\', \'args\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "from_sparse_tensor_slices" + argspec: "args=[\'sparse_tensor\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_tensor_slices" + argspec: "args=[\'tensors\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_tensors" + argspec: "args=[\'tensors\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "interleave" + argspec: "args=[\'self\', \'map_func\', \'cycle_length\', \'block_length\'], varargs=None, keywords=None, defaults=[\'1\'], " + } + member_method { + name: "list_files" + argspec: "args=[\'file_pattern\', \'shuffle\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "make_initializable_iterator" + argspec: "args=[\'self\', \'shared_name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "make_one_shot_iterator" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "map" + argspec: "args=[\'self\', \'map_func\', \'num_parallel_calls\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "padded_batch" + argspec: "args=[\'self\', \'batch_size\', \'padded_shapes\', \'padding_values\', \'drop_remainder\'], varargs=None, keywords=None, defaults=[\'None\', \'False\'], " + } + member_method { + name: "prefetch" + argspec: "args=[\'self\', \'buffer_size\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "range" + argspec: "args=[], varargs=args, keywords=None, defaults=None" + } + member_method { + name: "repeat" + argspec: "args=[\'self\', \'count\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "shard" + argspec: "args=[\'self\', \'num_shards\', \'index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "shuffle" + argspec: "args=[\'self\', \'buffer_size\', \'seed\', \'reshuffle_each_iteration\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "skip" + argspec: "args=[\'self\', \'count\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "take" + argspec: "args=[\'self\', \'count\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "zip" + argspec: "args=[\'datasets\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.data.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.data.pbtxt new file mode 100644 index 0000000000..56fb270a49 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.data.pbtxt @@ -0,0 +1,23 @@ +path: "tensorflow.data" +tf_module { + member { + name: "Dataset" + mtype: "" + } + member { + name: "FixedLengthRecordDataset" + mtype: "" + } + member { + name: "Iterator" + mtype: "" + } + member { + name: "TFRecordDataset" + mtype: "" + } + member { + name: "TextLineDataset" + mtype: "" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.debugging.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.debugging.pbtxt new file mode 100644 index 0000000000..d9efe97821 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.debugging.pbtxt @@ -0,0 +1,19 @@ +path: "tensorflow.debugging" +tf_module { + member_method { + name: "check_numerics" + argspec: "args=[\'tensor\', \'message\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "is_finite" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "is_inf" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "is_nan" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.distributions.-bernoulli.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-bernoulli.pbtxt new file mode 100644 index 0000000000..ca96f4eaec --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-bernoulli.pbtxt @@ -0,0 +1,143 @@ +path: "tensorflow.distributions.Bernoulli" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "allow_nan_stats" + mtype: "" + } + member { + name: "batch_shape" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "event_shape" + mtype: "" + } + member { + name: "logits" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "parameters" + mtype: "" + } + member { + name: "probs" + mtype: "" + } + member { + name: "reparameterization_type" + mtype: "" + } + member { + name: "validate_args" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'logits\', \'probs\', \'dtype\', \'validate_args\', \'allow_nan_stats\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \"\", \'False\', \'True\', \'Bernoulli\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'cdf\'], " + } + member_method { + name: "copy" + argspec: "args=[\'self\'], varargs=None, keywords=override_parameters_kwargs, defaults=None" + } + member_method { + name: "covariance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'covariance\'], " + } + member_method { + name: "cross_entropy" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'cross_entropy\'], " + } + member_method { + name: "entropy" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'entropy\'], " + } + member_method { + name: "event_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'event_shape_tensor\'], " + } + member_method { + name: "is_scalar_batch" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_batch\'], " + } + member_method { + name: "is_scalar_event" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_event\'], " + } + member_method { + name: "kl_divergence" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'kl_divergence\'], " + } + member_method { + name: "log_cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_cdf\'], " + } + member_method { + name: "log_prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_prob\'], " + } + member_method { + name: "log_survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_survival_function\'], " + } + member_method { + name: "mean" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mean\'], " + } + member_method { + name: "mode" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mode\'], " + } + member_method { + name: "param_shapes" + argspec: "args=[\'cls\', \'sample_shape\', \'name\'], varargs=None, keywords=None, defaults=[\'DistributionParamShapes\'], " + } + member_method { + name: "param_static_shapes" + argspec: "args=[\'cls\', \'sample_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'prob\'], " + } + member_method { + name: "quantile" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'quantile\'], " + } + member_method { + name: "sample" + argspec: "args=[\'self\', \'sample_shape\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'()\', \'None\', \'sample\'], " + } + member_method { + name: "stddev" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'stddev\'], " + } + member_method { + name: "survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'survival_function\'], " + } + member_method { + name: "variance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'variance\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.distributions.-beta.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-beta.pbtxt new file mode 100644 index 0000000000..d0508acd9f --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-beta.pbtxt @@ -0,0 +1,147 @@ +path: "tensorflow.distributions.Beta" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "allow_nan_stats" + mtype: "" + } + member { + name: "batch_shape" + mtype: "" + } + member { + name: "concentration0" + mtype: "" + } + member { + name: "concentration1" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "event_shape" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "parameters" + mtype: "" + } + member { + name: "reparameterization_type" + mtype: "" + } + member { + name: "total_concentration" + mtype: "" + } + member { + name: "validate_args" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'concentration1\', \'concentration0\', \'validate_args\', \'allow_nan_stats\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'False\', \'True\', \'Beta\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'cdf\'], " + } + member_method { + name: "copy" + argspec: "args=[\'self\'], varargs=None, keywords=override_parameters_kwargs, defaults=None" + } + member_method { + name: "covariance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'covariance\'], " + } + member_method { + name: "cross_entropy" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'cross_entropy\'], " + } + member_method { + name: "entropy" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'entropy\'], " + } + member_method { + name: "event_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'event_shape_tensor\'], " + } + member_method { + name: "is_scalar_batch" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_batch\'], " + } + member_method { + name: "is_scalar_event" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_event\'], " + } + member_method { + name: "kl_divergence" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'kl_divergence\'], " + } + member_method { + name: "log_cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_cdf\'], " + } + member_method { + name: "log_prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_prob\'], " + } + member_method { + name: "log_survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_survival_function\'], " + } + member_method { + name: "mean" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mean\'], " + } + member_method { + name: "mode" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mode\'], " + } + member_method { + name: "param_shapes" + argspec: "args=[\'cls\', \'sample_shape\', \'name\'], varargs=None, keywords=None, defaults=[\'DistributionParamShapes\'], " + } + member_method { + name: "param_static_shapes" + argspec: "args=[\'cls\', \'sample_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'prob\'], " + } + member_method { + name: "quantile" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'quantile\'], " + } + member_method { + name: "sample" + argspec: "args=[\'self\', \'sample_shape\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'()\', \'None\', \'sample\'], " + } + member_method { + name: "stddev" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'stddev\'], " + } + member_method { + name: "survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'survival_function\'], " + } + member_method { + name: "variance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'variance\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.distributions.-categorical.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-categorical.pbtxt new file mode 100644 index 0000000000..ff0fbb56cd --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-categorical.pbtxt @@ -0,0 +1,147 @@ +path: "tensorflow.distributions.Categorical" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "allow_nan_stats" + mtype: "" + } + member { + name: "batch_shape" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "event_shape" + mtype: "" + } + member { + name: "event_size" + mtype: "" + } + member { + name: "logits" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "parameters" + mtype: "" + } + member { + name: "probs" + mtype: "" + } + member { + name: "reparameterization_type" + mtype: "" + } + member { + name: "validate_args" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'logits\', \'probs\', \'dtype\', \'validate_args\', \'allow_nan_stats\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \"\", \'False\', \'True\', \'Categorical\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'cdf\'], " + } + member_method { + name: "copy" + argspec: "args=[\'self\'], varargs=None, keywords=override_parameters_kwargs, defaults=None" + } + member_method { + name: "covariance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'covariance\'], " + } + member_method { + name: "cross_entropy" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'cross_entropy\'], " + } + member_method { + name: "entropy" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'entropy\'], " + } + member_method { + name: "event_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'event_shape_tensor\'], " + } + member_method { + name: "is_scalar_batch" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_batch\'], " + } + member_method { + name: "is_scalar_event" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_event\'], " + } + member_method { + name: "kl_divergence" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'kl_divergence\'], " + } + member_method { + name: "log_cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_cdf\'], " + } + member_method { + name: "log_prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_prob\'], " + } + member_method { + name: "log_survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_survival_function\'], " + } + member_method { + name: "mean" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mean\'], " + } + member_method { + name: "mode" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mode\'], " + } + member_method { + name: "param_shapes" + argspec: "args=[\'cls\', \'sample_shape\', \'name\'], varargs=None, keywords=None, defaults=[\'DistributionParamShapes\'], " + } + member_method { + name: "param_static_shapes" + argspec: "args=[\'cls\', \'sample_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'prob\'], " + } + member_method { + name: "quantile" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'quantile\'], " + } + member_method { + name: "sample" + argspec: "args=[\'self\', \'sample_shape\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'()\', \'None\', \'sample\'], " + } + member_method { + name: "stddev" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'stddev\'], " + } + member_method { + name: "survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'survival_function\'], " + } + member_method { + name: "variance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'variance\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.distributions.-dirichlet-multinomial.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-dirichlet-multinomial.pbtxt new file mode 100644 index 0000000000..d75e4a2f88 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-dirichlet-multinomial.pbtxt @@ -0,0 +1,147 @@ +path: "tensorflow.distributions.DirichletMultinomial" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "allow_nan_stats" + mtype: "" + } + member { + name: "batch_shape" + mtype: "" + } + member { + name: "concentration" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "event_shape" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "parameters" + mtype: "" + } + member { + name: "reparameterization_type" + mtype: "" + } + member { + name: "total_concentration" + mtype: "" + } + member { + name: "total_count" + mtype: "" + } + member { + name: "validate_args" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'total_count\', \'concentration\', \'validate_args\', \'allow_nan_stats\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'True\', \'DirichletMultinomial\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'cdf\'], " + } + member_method { + name: "copy" + argspec: "args=[\'self\'], varargs=None, keywords=override_parameters_kwargs, defaults=None" + } + member_method { + name: "covariance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'covariance\'], " + } + member_method { + name: "cross_entropy" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'cross_entropy\'], " + } + member_method { + name: "entropy" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'entropy\'], " + } + member_method { + name: "event_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'event_shape_tensor\'], " + } + member_method { + name: "is_scalar_batch" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_batch\'], " + } + member_method { + name: "is_scalar_event" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_event\'], " + } + member_method { + name: "kl_divergence" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'kl_divergence\'], " + } + member_method { + name: "log_cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_cdf\'], " + } + member_method { + name: "log_prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_prob\'], " + } + member_method { + name: "log_survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_survival_function\'], " + } + member_method { + name: "mean" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mean\'], " + } + member_method { + name: "mode" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mode\'], " + } + member_method { + name: "param_shapes" + argspec: "args=[\'cls\', \'sample_shape\', \'name\'], varargs=None, keywords=None, defaults=[\'DistributionParamShapes\'], " + } + member_method { + name: "param_static_shapes" + argspec: "args=[\'cls\', \'sample_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'prob\'], " + } + member_method { + name: "quantile" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'quantile\'], " + } + member_method { + name: "sample" + argspec: "args=[\'self\', \'sample_shape\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'()\', \'None\', \'sample\'], " + } + member_method { + name: "stddev" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'stddev\'], " + } + member_method { + name: "survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'survival_function\'], " + } + member_method { + name: "variance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'variance\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.distributions.-dirichlet.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-dirichlet.pbtxt new file mode 100644 index 0000000000..b838b9ae21 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-dirichlet.pbtxt @@ -0,0 +1,143 @@ +path: "tensorflow.distributions.Dirichlet" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "allow_nan_stats" + mtype: "" + } + member { + name: "batch_shape" + mtype: "" + } + member { + name: "concentration" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "event_shape" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "parameters" + mtype: "" + } + member { + name: "reparameterization_type" + mtype: "" + } + member { + name: "total_concentration" + mtype: "" + } + member { + name: "validate_args" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'concentration\', \'validate_args\', \'allow_nan_stats\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'True\', \'Dirichlet\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'cdf\'], " + } + member_method { + name: "copy" + argspec: "args=[\'self\'], varargs=None, keywords=override_parameters_kwargs, defaults=None" + } + member_method { + name: "covariance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'covariance\'], " + } + member_method { + name: "cross_entropy" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'cross_entropy\'], " + } + member_method { + name: "entropy" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'entropy\'], " + } + member_method { + name: "event_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'event_shape_tensor\'], " + } + member_method { + name: "is_scalar_batch" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_batch\'], " + } + member_method { + name: "is_scalar_event" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_event\'], " + } + member_method { + name: "kl_divergence" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'kl_divergence\'], " + } + member_method { + name: "log_cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_cdf\'], " + } + member_method { + name: "log_prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_prob\'], " + } + member_method { + name: "log_survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_survival_function\'], " + } + member_method { + name: "mean" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mean\'], " + } + member_method { + name: "mode" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mode\'], " + } + member_method { + name: "param_shapes" + argspec: "args=[\'cls\', \'sample_shape\', \'name\'], varargs=None, keywords=None, defaults=[\'DistributionParamShapes\'], " + } + member_method { + name: "param_static_shapes" + argspec: "args=[\'cls\', \'sample_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'prob\'], " + } + member_method { + name: "quantile" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'quantile\'], " + } + member_method { + name: "sample" + argspec: "args=[\'self\', \'sample_shape\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'()\', \'None\', \'sample\'], " + } + member_method { + name: "stddev" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'stddev\'], " + } + member_method { + name: "survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'survival_function\'], " + } + member_method { + name: "variance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'variance\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.distributions.-distribution.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-distribution.pbtxt new file mode 100644 index 0000000000..6f06b7d50d --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-distribution.pbtxt @@ -0,0 +1,134 @@ +path: "tensorflow.distributions.Distribution" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "allow_nan_stats" + mtype: "" + } + member { + name: "batch_shape" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "event_shape" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "parameters" + mtype: "" + } + member { + name: "reparameterization_type" + mtype: "" + } + member { + name: "validate_args" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'dtype\', \'reparameterization_type\', \'validate_args\', \'allow_nan_stats\', \'parameters\', \'graph_parents\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'cdf\'], " + } + member_method { + name: "copy" + argspec: "args=[\'self\'], varargs=None, keywords=override_parameters_kwargs, defaults=None" + } + member_method { + name: "covariance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'covariance\'], " + } + member_method { + name: "cross_entropy" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'cross_entropy\'], " + } + member_method { + name: "entropy" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'entropy\'], " + } + member_method { + name: "event_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'event_shape_tensor\'], " + } + member_method { + name: "is_scalar_batch" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_batch\'], " + } + member_method { + name: "is_scalar_event" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_event\'], " + } + member_method { + name: "kl_divergence" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'kl_divergence\'], " + } + member_method { + name: "log_cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_cdf\'], " + } + member_method { + name: "log_prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_prob\'], " + } + member_method { + name: "log_survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_survival_function\'], " + } + member_method { + name: "mean" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mean\'], " + } + member_method { + name: "mode" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mode\'], " + } + member_method { + name: "param_shapes" + argspec: "args=[\'cls\', \'sample_shape\', \'name\'], varargs=None, keywords=None, defaults=[\'DistributionParamShapes\'], " + } + member_method { + name: "param_static_shapes" + argspec: "args=[\'cls\', \'sample_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'prob\'], " + } + member_method { + name: "quantile" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'quantile\'], " + } + member_method { + name: "sample" + argspec: "args=[\'self\', \'sample_shape\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'()\', \'None\', \'sample\'], " + } + member_method { + name: "stddev" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'stddev\'], " + } + member_method { + name: "survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'survival_function\'], " + } + member_method { + name: "variance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'variance\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.distributions.-exponential.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-exponential.pbtxt new file mode 100644 index 0000000000..d34f9cde5d --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-exponential.pbtxt @@ -0,0 +1,144 @@ +path: "tensorflow.distributions.Exponential" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "allow_nan_stats" + mtype: "" + } + member { + name: "batch_shape" + mtype: "" + } + member { + name: "concentration" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "event_shape" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "parameters" + mtype: "" + } + member { + name: "rate" + mtype: "" + } + member { + name: "reparameterization_type" + mtype: "" + } + member { + name: "validate_args" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'rate\', \'validate_args\', \'allow_nan_stats\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'True\', \'Exponential\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'cdf\'], " + } + member_method { + name: "copy" + argspec: "args=[\'self\'], varargs=None, keywords=override_parameters_kwargs, defaults=None" + } + member_method { + name: "covariance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'covariance\'], " + } + member_method { + name: "cross_entropy" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'cross_entropy\'], " + } + member_method { + name: "entropy" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'entropy\'], " + } + member_method { + name: "event_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'event_shape_tensor\'], " + } + member_method { + name: "is_scalar_batch" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_batch\'], " + } + member_method { + name: "is_scalar_event" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_event\'], " + } + member_method { + name: "kl_divergence" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'kl_divergence\'], " + } + member_method { + name: "log_cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_cdf\'], " + } + member_method { + name: "log_prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_prob\'], " + } + member_method { + name: "log_survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_survival_function\'], " + } + member_method { + name: "mean" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mean\'], " + } + member_method { + name: "mode" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mode\'], " + } + member_method { + name: "param_shapes" + argspec: "args=[\'cls\', \'sample_shape\', \'name\'], varargs=None, keywords=None, defaults=[\'DistributionParamShapes\'], " + } + member_method { + name: "param_static_shapes" + argspec: "args=[\'cls\', \'sample_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'prob\'], " + } + member_method { + name: "quantile" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'quantile\'], " + } + member_method { + name: "sample" + argspec: "args=[\'self\', \'sample_shape\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'()\', \'None\', \'sample\'], " + } + member_method { + name: "stddev" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'stddev\'], " + } + member_method { + name: "survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'survival_function\'], " + } + member_method { + name: "variance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'variance\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.distributions.-gamma.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-gamma.pbtxt new file mode 100644 index 0000000000..df268b8d99 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-gamma.pbtxt @@ -0,0 +1,143 @@ +path: "tensorflow.distributions.Gamma" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "allow_nan_stats" + mtype: "" + } + member { + name: "batch_shape" + mtype: "" + } + member { + name: "concentration" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "event_shape" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "parameters" + mtype: "" + } + member { + name: "rate" + mtype: "" + } + member { + name: "reparameterization_type" + mtype: "" + } + member { + name: "validate_args" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'concentration\', \'rate\', \'validate_args\', \'allow_nan_stats\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'True\', \'Gamma\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'cdf\'], " + } + member_method { + name: "copy" + argspec: "args=[\'self\'], varargs=None, keywords=override_parameters_kwargs, defaults=None" + } + member_method { + name: "covariance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'covariance\'], " + } + member_method { + name: "cross_entropy" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'cross_entropy\'], " + } + member_method { + name: "entropy" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'entropy\'], " + } + member_method { + name: "event_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'event_shape_tensor\'], " + } + member_method { + name: "is_scalar_batch" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_batch\'], " + } + member_method { + name: "is_scalar_event" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_event\'], " + } + member_method { + name: "kl_divergence" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'kl_divergence\'], " + } + member_method { + name: "log_cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_cdf\'], " + } + member_method { + name: "log_prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_prob\'], " + } + member_method { + name: "log_survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_survival_function\'], " + } + member_method { + name: "mean" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mean\'], " + } + member_method { + name: "mode" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mode\'], " + } + member_method { + name: "param_shapes" + argspec: "args=[\'cls\', \'sample_shape\', \'name\'], varargs=None, keywords=None, defaults=[\'DistributionParamShapes\'], " + } + member_method { + name: "param_static_shapes" + argspec: "args=[\'cls\', \'sample_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'prob\'], " + } + member_method { + name: "quantile" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'quantile\'], " + } + member_method { + name: "sample" + argspec: "args=[\'self\', \'sample_shape\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'()\', \'None\', \'sample\'], " + } + member_method { + name: "stddev" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'stddev\'], " + } + member_method { + name: "survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'survival_function\'], " + } + member_method { + name: "variance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'variance\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.distributions.-laplace.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-laplace.pbtxt new file mode 100644 index 0000000000..303dcb4ed3 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-laplace.pbtxt @@ -0,0 +1,143 @@ +path: "tensorflow.distributions.Laplace" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "allow_nan_stats" + mtype: "" + } + member { + name: "batch_shape" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "event_shape" + mtype: "" + } + member { + name: "loc" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "parameters" + mtype: "" + } + member { + name: "reparameterization_type" + mtype: "" + } + member { + name: "scale" + mtype: "" + } + member { + name: "validate_args" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'loc\', \'scale\', \'validate_args\', \'allow_nan_stats\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'True\', \'Laplace\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'cdf\'], " + } + member_method { + name: "copy" + argspec: "args=[\'self\'], varargs=None, keywords=override_parameters_kwargs, defaults=None" + } + member_method { + name: "covariance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'covariance\'], " + } + member_method { + name: "cross_entropy" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'cross_entropy\'], " + } + member_method { + name: "entropy" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'entropy\'], " + } + member_method { + name: "event_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'event_shape_tensor\'], " + } + member_method { + name: "is_scalar_batch" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_batch\'], " + } + member_method { + name: "is_scalar_event" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_event\'], " + } + member_method { + name: "kl_divergence" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'kl_divergence\'], " + } + member_method { + name: "log_cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_cdf\'], " + } + member_method { + name: "log_prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_prob\'], " + } + member_method { + name: "log_survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_survival_function\'], " + } + member_method { + name: "mean" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mean\'], " + } + member_method { + name: "mode" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mode\'], " + } + member_method { + name: "param_shapes" + argspec: "args=[\'cls\', \'sample_shape\', \'name\'], varargs=None, keywords=None, defaults=[\'DistributionParamShapes\'], " + } + member_method { + name: "param_static_shapes" + argspec: "args=[\'cls\', \'sample_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'prob\'], " + } + member_method { + name: "quantile" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'quantile\'], " + } + member_method { + name: "sample" + argspec: "args=[\'self\', \'sample_shape\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'()\', \'None\', \'sample\'], " + } + member_method { + name: "stddev" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'stddev\'], " + } + member_method { + name: "survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'survival_function\'], " + } + member_method { + name: "variance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'variance\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.distributions.-multinomial.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-multinomial.pbtxt new file mode 100644 index 0000000000..ecda8acb15 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-multinomial.pbtxt @@ -0,0 +1,147 @@ +path: "tensorflow.distributions.Multinomial" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "allow_nan_stats" + mtype: "" + } + member { + name: "batch_shape" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "event_shape" + mtype: "" + } + member { + name: "logits" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "parameters" + mtype: "" + } + member { + name: "probs" + mtype: "" + } + member { + name: "reparameterization_type" + mtype: "" + } + member { + name: "total_count" + mtype: "" + } + member { + name: "validate_args" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'total_count\', \'logits\', \'probs\', \'validate_args\', \'allow_nan_stats\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'False\', \'True\', \'Multinomial\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'cdf\'], " + } + member_method { + name: "copy" + argspec: "args=[\'self\'], varargs=None, keywords=override_parameters_kwargs, defaults=None" + } + member_method { + name: "covariance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'covariance\'], " + } + member_method { + name: "cross_entropy" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'cross_entropy\'], " + } + member_method { + name: "entropy" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'entropy\'], " + } + member_method { + name: "event_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'event_shape_tensor\'], " + } + member_method { + name: "is_scalar_batch" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_batch\'], " + } + member_method { + name: "is_scalar_event" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_event\'], " + } + member_method { + name: "kl_divergence" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'kl_divergence\'], " + } + member_method { + name: "log_cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_cdf\'], " + } + member_method { + name: "log_prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_prob\'], " + } + member_method { + name: "log_survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_survival_function\'], " + } + member_method { + name: "mean" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mean\'], " + } + member_method { + name: "mode" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mode\'], " + } + member_method { + name: "param_shapes" + argspec: "args=[\'cls\', \'sample_shape\', \'name\'], varargs=None, keywords=None, defaults=[\'DistributionParamShapes\'], " + } + member_method { + name: "param_static_shapes" + argspec: "args=[\'cls\', \'sample_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'prob\'], " + } + member_method { + name: "quantile" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'quantile\'], " + } + member_method { + name: "sample" + argspec: "args=[\'self\', \'sample_shape\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'()\', \'None\', \'sample\'], " + } + member_method { + name: "stddev" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'stddev\'], " + } + member_method { + name: "survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'survival_function\'], " + } + member_method { + name: "variance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'variance\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.distributions.-normal.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-normal.pbtxt new file mode 100644 index 0000000000..92b9eeea22 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-normal.pbtxt @@ -0,0 +1,143 @@ +path: "tensorflow.distributions.Normal" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "allow_nan_stats" + mtype: "" + } + member { + name: "batch_shape" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "event_shape" + mtype: "" + } + member { + name: "loc" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "parameters" + mtype: "" + } + member { + name: "reparameterization_type" + mtype: "" + } + member { + name: "scale" + mtype: "" + } + member { + name: "validate_args" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'loc\', \'scale\', \'validate_args\', \'allow_nan_stats\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'True\', \'Normal\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'cdf\'], " + } + member_method { + name: "copy" + argspec: "args=[\'self\'], varargs=None, keywords=override_parameters_kwargs, defaults=None" + } + member_method { + name: "covariance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'covariance\'], " + } + member_method { + name: "cross_entropy" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'cross_entropy\'], " + } + member_method { + name: "entropy" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'entropy\'], " + } + member_method { + name: "event_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'event_shape_tensor\'], " + } + member_method { + name: "is_scalar_batch" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_batch\'], " + } + member_method { + name: "is_scalar_event" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_event\'], " + } + member_method { + name: "kl_divergence" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'kl_divergence\'], " + } + member_method { + name: "log_cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_cdf\'], " + } + member_method { + name: "log_prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_prob\'], " + } + member_method { + name: "log_survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_survival_function\'], " + } + member_method { + name: "mean" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mean\'], " + } + member_method { + name: "mode" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mode\'], " + } + member_method { + name: "param_shapes" + argspec: "args=[\'cls\', \'sample_shape\', \'name\'], varargs=None, keywords=None, defaults=[\'DistributionParamShapes\'], " + } + member_method { + name: "param_static_shapes" + argspec: "args=[\'cls\', \'sample_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'prob\'], " + } + member_method { + name: "quantile" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'quantile\'], " + } + member_method { + name: "sample" + argspec: "args=[\'self\', \'sample_shape\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'()\', \'None\', \'sample\'], " + } + member_method { + name: "stddev" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'stddev\'], " + } + member_method { + name: "survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'survival_function\'], " + } + member_method { + name: "variance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'variance\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.distributions.-register-k-l.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-register-k-l.pbtxt new file mode 100644 index 0000000000..e3db443c2b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-register-k-l.pbtxt @@ -0,0 +1,9 @@ +path: "tensorflow.distributions.RegisterKL" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'dist_cls_a\', \'dist_cls_b\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.distributions.-reparameterization-type.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-reparameterization-type.pbtxt new file mode 100644 index 0000000000..02e8d576dd --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-reparameterization-type.pbtxt @@ -0,0 +1,9 @@ +path: "tensorflow.distributions.ReparameterizationType" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'rep_type\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.distributions.-student-t.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-student-t.pbtxt new file mode 100644 index 0000000000..9aa7f9a634 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-student-t.pbtxt @@ -0,0 +1,147 @@ +path: "tensorflow.distributions.StudentT" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "allow_nan_stats" + mtype: "" + } + member { + name: "batch_shape" + mtype: "" + } + member { + name: "df" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "event_shape" + mtype: "" + } + member { + name: "loc" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "parameters" + mtype: "" + } + member { + name: "reparameterization_type" + mtype: "" + } + member { + name: "scale" + mtype: "" + } + member { + name: "validate_args" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'df\', \'loc\', \'scale\', \'validate_args\', \'allow_nan_stats\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'True\', \'StudentT\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'cdf\'], " + } + member_method { + name: "copy" + argspec: "args=[\'self\'], varargs=None, keywords=override_parameters_kwargs, defaults=None" + } + member_method { + name: "covariance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'covariance\'], " + } + member_method { + name: "cross_entropy" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'cross_entropy\'], " + } + member_method { + name: "entropy" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'entropy\'], " + } + member_method { + name: "event_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'event_shape_tensor\'], " + } + member_method { + name: "is_scalar_batch" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_batch\'], " + } + member_method { + name: "is_scalar_event" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_event\'], " + } + member_method { + name: "kl_divergence" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'kl_divergence\'], " + } + member_method { + name: "log_cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_cdf\'], " + } + member_method { + name: "log_prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_prob\'], " + } + member_method { + name: "log_survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_survival_function\'], " + } + member_method { + name: "mean" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mean\'], " + } + member_method { + name: "mode" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mode\'], " + } + member_method { + name: "param_shapes" + argspec: "args=[\'cls\', \'sample_shape\', \'name\'], varargs=None, keywords=None, defaults=[\'DistributionParamShapes\'], " + } + member_method { + name: "param_static_shapes" + argspec: "args=[\'cls\', \'sample_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'prob\'], " + } + member_method { + name: "quantile" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'quantile\'], " + } + member_method { + name: "sample" + argspec: "args=[\'self\', \'sample_shape\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'()\', \'None\', \'sample\'], " + } + member_method { + name: "stddev" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'stddev\'], " + } + member_method { + name: "survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'survival_function\'], " + } + member_method { + name: "variance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'variance\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.distributions.-uniform.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-uniform.pbtxt new file mode 100644 index 0000000000..d1b9d30696 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.distributions.-uniform.pbtxt @@ -0,0 +1,147 @@ +path: "tensorflow.distributions.Uniform" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "allow_nan_stats" + mtype: "" + } + member { + name: "batch_shape" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "event_shape" + mtype: "" + } + member { + name: "high" + mtype: "" + } + member { + name: "low" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "parameters" + mtype: "" + } + member { + name: "reparameterization_type" + mtype: "" + } + member { + name: "validate_args" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'low\', \'high\', \'validate_args\', \'allow_nan_stats\', \'name\'], varargs=None, keywords=None, defaults=[\'0.0\', \'1.0\', \'False\', \'True\', \'Uniform\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'cdf\'], " + } + member_method { + name: "copy" + argspec: "args=[\'self\'], varargs=None, keywords=override_parameters_kwargs, defaults=None" + } + member_method { + name: "covariance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'covariance\'], " + } + member_method { + name: "cross_entropy" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'cross_entropy\'], " + } + member_method { + name: "entropy" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'entropy\'], " + } + member_method { + name: "event_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'event_shape_tensor\'], " + } + member_method { + name: "is_scalar_batch" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_batch\'], " + } + member_method { + name: "is_scalar_event" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'is_scalar_event\'], " + } + member_method { + name: "kl_divergence" + argspec: "args=[\'self\', \'other\', \'name\'], varargs=None, keywords=None, defaults=[\'kl_divergence\'], " + } + member_method { + name: "log_cdf" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_cdf\'], " + } + member_method { + name: "log_prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_prob\'], " + } + member_method { + name: "log_survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'log_survival_function\'], " + } + member_method { + name: "mean" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mean\'], " + } + member_method { + name: "mode" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'mode\'], " + } + member_method { + name: "param_shapes" + argspec: "args=[\'cls\', \'sample_shape\', \'name\'], varargs=None, keywords=None, defaults=[\'DistributionParamShapes\'], " + } + member_method { + name: "param_static_shapes" + argspec: "args=[\'cls\', \'sample_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "prob" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'prob\'], " + } + member_method { + name: "quantile" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'quantile\'], " + } + member_method { + name: "range" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'range\'], " + } + member_method { + name: "sample" + argspec: "args=[\'self\', \'sample_shape\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'()\', \'None\', \'sample\'], " + } + member_method { + name: "stddev" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'stddev\'], " + } + member_method { + name: "survival_function" + argspec: "args=[\'self\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'survival_function\'], " + } + member_method { + name: "variance" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'variance\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.distributions.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.distributions.pbtxt new file mode 100644 index 0000000000..90b60ef074 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.distributions.pbtxt @@ -0,0 +1,75 @@ +path: "tensorflow.distributions" +tf_module { + member { + name: "Bernoulli" + mtype: "" + } + member { + name: "Beta" + mtype: "" + } + member { + name: "Categorical" + mtype: "" + } + member { + name: "Dirichlet" + mtype: "" + } + member { + name: "DirichletMultinomial" + mtype: "" + } + member { + name: "Distribution" + mtype: "" + } + member { + name: "Exponential" + mtype: "" + } + member { + name: "FULLY_REPARAMETERIZED" + mtype: "" + } + member { + name: "Gamma" + mtype: "" + } + member { + name: "Laplace" + mtype: "" + } + member { + name: "Multinomial" + mtype: "" + } + member { + name: "NOT_REPARAMETERIZED" + mtype: "" + } + member { + name: "Normal" + mtype: "" + } + member { + name: "RegisterKL" + mtype: "" + } + member { + name: "ReparameterizationType" + mtype: "" + } + member { + name: "StudentT" + mtype: "" + } + member { + name: "Uniform" + mtype: "" + } + member_method { + name: "kl_divergence" + argspec: "args=[\'distribution_a\', \'distribution_b\', \'allow_nan_stats\', \'name\'], varargs=None, keywords=None, defaults=[\'True\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.dtypes.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.dtypes.pbtxt new file mode 100644 index 0000000000..98e1feed00 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.dtypes.pbtxt @@ -0,0 +1,7 @@ +path: "tensorflow.dtypes" +tf_module { + member_method { + name: "as_string" + argspec: "args=[\'input\', \'precision\', \'scientific\', \'shortest\', \'width\', \'fill\', \'name\'], varargs=None, keywords=None, defaults=[\'-1\', \'False\', \'False\', \'-1\', \'\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.errors.-aborted-error.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.errors.-aborted-error.pbtxt new file mode 100644 index 0000000000..ea9186b0b9 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.errors.-aborted-error.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.errors.AbortedError" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "args" + mtype: "" + } + member { + name: "error_code" + mtype: "" + } + member { + name: "message" + mtype: "" + } + member { + name: "node_def" + mtype: "" + } + member { + name: "op" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'node_def\', \'op\', \'message\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.errors.-already-exists-error.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.errors.-already-exists-error.pbtxt new file mode 100644 index 0000000000..4e155081dd --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.errors.-already-exists-error.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.errors.AlreadyExistsError" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "args" + mtype: "" + } + member { + name: "error_code" + mtype: "" + } + member { + name: "message" + mtype: "" + } + member { + name: "node_def" + mtype: "" + } + member { + name: "op" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'node_def\', \'op\', \'message\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.errors.-cancelled-error.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.errors.-cancelled-error.pbtxt new file mode 100644 index 0000000000..b02a0e023a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.errors.-cancelled-error.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.errors.CancelledError" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "args" + mtype: "" + } + member { + name: "error_code" + mtype: "" + } + member { + name: "message" + mtype: "" + } + member { + name: "node_def" + mtype: "" + } + member { + name: "op" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'node_def\', \'op\', \'message\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.errors.-data-loss-error.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.errors.-data-loss-error.pbtxt new file mode 100644 index 0000000000..c1fa66342a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.errors.-data-loss-error.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.errors.DataLossError" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "args" + mtype: "" + } + member { + name: "error_code" + mtype: "" + } + member { + name: "message" + mtype: "" + } + member { + name: "node_def" + mtype: "" + } + member { + name: "op" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'node_def\', \'op\', \'message\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.errors.-deadline-exceeded-error.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.errors.-deadline-exceeded-error.pbtxt new file mode 100644 index 0000000000..8e03793619 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.errors.-deadline-exceeded-error.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.errors.DeadlineExceededError" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "args" + mtype: "" + } + member { + name: "error_code" + mtype: "" + } + member { + name: "message" + mtype: "" + } + member { + name: "node_def" + mtype: "" + } + member { + name: "op" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'node_def\', \'op\', \'message\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.errors.-failed-precondition-error.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.errors.-failed-precondition-error.pbtxt new file mode 100644 index 0000000000..384d4b534c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.errors.-failed-precondition-error.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.errors.FailedPreconditionError" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "args" + mtype: "" + } + member { + name: "error_code" + mtype: "" + } + member { + name: "message" + mtype: "" + } + member { + name: "node_def" + mtype: "" + } + member { + name: "op" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'node_def\', \'op\', \'message\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.errors.-internal-error.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.errors.-internal-error.pbtxt new file mode 100644 index 0000000000..ac5c4d7879 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.errors.-internal-error.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.errors.InternalError" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "args" + mtype: "" + } + member { + name: "error_code" + mtype: "" + } + member { + name: "message" + mtype: "" + } + member { + name: "node_def" + mtype: "" + } + member { + name: "op" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'node_def\', \'op\', \'message\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.errors.-invalid-argument-error.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.errors.-invalid-argument-error.pbtxt new file mode 100644 index 0000000000..161edd4a7c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.errors.-invalid-argument-error.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.errors.InvalidArgumentError" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "args" + mtype: "" + } + member { + name: "error_code" + mtype: "" + } + member { + name: "message" + mtype: "" + } + member { + name: "node_def" + mtype: "" + } + member { + name: "op" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'node_def\', \'op\', \'message\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.errors.-not-found-error.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.errors.-not-found-error.pbtxt new file mode 100644 index 0000000000..1e64730ac6 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.errors.-not-found-error.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.errors.NotFoundError" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "args" + mtype: "" + } + member { + name: "error_code" + mtype: "" + } + member { + name: "message" + mtype: "" + } + member { + name: "node_def" + mtype: "" + } + member { + name: "op" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'node_def\', \'op\', \'message\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.errors.-op-error.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.errors.-op-error.pbtxt new file mode 100644 index 0000000000..b1f14c0457 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.errors.-op-error.pbtxt @@ -0,0 +1,29 @@ +path: "tensorflow.errors.OpError" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "args" + mtype: "" + } + member { + name: "error_code" + mtype: "" + } + member { + name: "message" + mtype: "" + } + member { + name: "node_def" + mtype: "" + } + member { + name: "op" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'node_def\', \'op\', \'message\', \'error_code\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.errors.-out-of-range-error.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.errors.-out-of-range-error.pbtxt new file mode 100644 index 0000000000..6365e47286 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.errors.-out-of-range-error.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.errors.OutOfRangeError" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "args" + mtype: "" + } + member { + name: "error_code" + mtype: "" + } + member { + name: "message" + mtype: "" + } + member { + name: "node_def" + mtype: "" + } + member { + name: "op" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'node_def\', \'op\', \'message\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.errors.-permission-denied-error.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.errors.-permission-denied-error.pbtxt new file mode 100644 index 0000000000..dc8a66f9ea --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.errors.-permission-denied-error.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.errors.PermissionDeniedError" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "args" + mtype: "" + } + member { + name: "error_code" + mtype: "" + } + member { + name: "message" + mtype: "" + } + member { + name: "node_def" + mtype: "" + } + member { + name: "op" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'node_def\', \'op\', \'message\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.errors.-resource-exhausted-error.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.errors.-resource-exhausted-error.pbtxt new file mode 100644 index 0000000000..85bb384b46 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.errors.-resource-exhausted-error.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.errors.ResourceExhaustedError" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "args" + mtype: "" + } + member { + name: "error_code" + mtype: "" + } + member { + name: "message" + mtype: "" + } + member { + name: "node_def" + mtype: "" + } + member { + name: "op" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'node_def\', \'op\', \'message\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.errors.-unauthenticated-error.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.errors.-unauthenticated-error.pbtxt new file mode 100644 index 0000000000..d57d7ac2f2 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.errors.-unauthenticated-error.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.errors.UnauthenticatedError" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "args" + mtype: "" + } + member { + name: "error_code" + mtype: "" + } + member { + name: "message" + mtype: "" + } + member { + name: "node_def" + mtype: "" + } + member { + name: "op" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'node_def\', \'op\', \'message\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.errors.-unavailable-error.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.errors.-unavailable-error.pbtxt new file mode 100644 index 0000000000..cc33e6ed8d --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.errors.-unavailable-error.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.errors.UnavailableError" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "args" + mtype: "" + } + member { + name: "error_code" + mtype: "" + } + member { + name: "message" + mtype: "" + } + member { + name: "node_def" + mtype: "" + } + member { + name: "op" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'node_def\', \'op\', \'message\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.errors.-unimplemented-error.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.errors.-unimplemented-error.pbtxt new file mode 100644 index 0000000000..b8c2e22dbd --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.errors.-unimplemented-error.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.errors.UnimplementedError" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "args" + mtype: "" + } + member { + name: "error_code" + mtype: "" + } + member { + name: "message" + mtype: "" + } + member { + name: "node_def" + mtype: "" + } + member { + name: "op" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'node_def\', \'op\', \'message\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.errors.-unknown-error.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.errors.-unknown-error.pbtxt new file mode 100644 index 0000000000..8ffcfae95b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.errors.-unknown-error.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.errors.UnknownError" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "args" + mtype: "" + } + member { + name: "error_code" + mtype: "" + } + member { + name: "message" + mtype: "" + } + member { + name: "node_def" + mtype: "" + } + member { + name: "op" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'node_def\', \'op\', \'message\', \'error_code\'], varargs=None, keywords=None, defaults=[\'2\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.errors.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.errors.pbtxt new file mode 100644 index 0000000000..c5fe49baab --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.errors.pbtxt @@ -0,0 +1,151 @@ +path: "tensorflow.errors" +tf_module { + member { + name: "ABORTED" + mtype: "" + } + member { + name: "ALREADY_EXISTS" + mtype: "" + } + member { + name: "AbortedError" + mtype: "" + } + member { + name: "AlreadyExistsError" + mtype: "" + } + member { + name: "CANCELLED" + mtype: "" + } + member { + name: "CancelledError" + mtype: "" + } + member { + name: "DATA_LOSS" + mtype: "" + } + member { + name: "DEADLINE_EXCEEDED" + mtype: "" + } + member { + name: "DataLossError" + mtype: "" + } + member { + name: "DeadlineExceededError" + mtype: "" + } + member { + name: "FAILED_PRECONDITION" + mtype: "" + } + member { + name: "FailedPreconditionError" + mtype: "" + } + member { + name: "INTERNAL" + mtype: "" + } + member { + name: "INVALID_ARGUMENT" + mtype: "" + } + member { + name: "InternalError" + mtype: "" + } + member { + name: "InvalidArgumentError" + mtype: "" + } + member { + name: "NOT_FOUND" + mtype: "" + } + member { + name: "NotFoundError" + mtype: "" + } + member { + name: "OK" + mtype: "" + } + member { + name: "OUT_OF_RANGE" + mtype: "" + } + member { + name: "OpError" + mtype: "" + } + member { + name: "OutOfRangeError" + mtype: "" + } + member { + name: "PERMISSION_DENIED" + mtype: "" + } + member { + name: "PermissionDeniedError" + mtype: "" + } + member { + name: "RESOURCE_EXHAUSTED" + mtype: "" + } + member { + name: "ResourceExhaustedError" + mtype: "" + } + member { + name: "UNAUTHENTICATED" + mtype: "" + } + member { + name: "UNAVAILABLE" + mtype: "" + } + member { + name: "UNIMPLEMENTED" + mtype: "" + } + member { + name: "UNKNOWN" + mtype: "" + } + member { + name: "UnauthenticatedError" + mtype: "" + } + member { + name: "UnavailableError" + mtype: "" + } + member { + name: "UnimplementedError" + mtype: "" + } + member { + name: "UnknownError" + mtype: "" + } + member { + name: "raise_exception_on_not_ok_status" + mtype: "" + } + member_method { + name: "error_code_from_exception_type" + argspec: "args=[\'cls\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "exception_type_from_error_code" + argspec: "args=[\'error_code\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.errors.raise_exception_on_not_ok_status.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.errors.raise_exception_on_not_ok_status.pbtxt new file mode 100644 index 0000000000..5d25ec769a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.errors.raise_exception_on_not_ok_status.pbtxt @@ -0,0 +1,8 @@ +path: "tensorflow.errors.raise_exception_on_not_ok_status" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.-baseline-classifier.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-baseline-classifier.pbtxt new file mode 100644 index 0000000000..cf22e39d4c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-baseline-classifier.pbtxt @@ -0,0 +1,58 @@ +path: "tensorflow.estimator.BaselineClassifier" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "config" + mtype: "" + } + member { + name: "model_dir" + mtype: "" + } + member { + name: "model_fn" + mtype: "" + } + member { + name: "params" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'model_dir\', \'n_classes\', \'weight_column\', \'label_vocabulary\', \'optimizer\', \'config\', \'loss_reduction\'], varargs=None, keywords=None, defaults=[\'None\', \'2\', \'None\', \'None\', \'Ftrl\', \'None\', \'weighted_sum\'], " + } + member_method { + name: "eval_dir" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "evaluate" + argspec: "args=[\'self\', \'input_fn\', \'steps\', \'hooks\', \'checkpoint_path\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "export_savedmodel" + argspec: "args=[\'self\', \'export_dir_base\', \'serving_input_receiver_fn\', \'assets_extra\', \'as_text\', \'checkpoint_path\', \'strip_default_attrs\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\', \'False\'], " + } + member_method { + name: "get_variable_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_variable_value" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "latest_checkpoint" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'input_fn\', \'predict_keys\', \'hooks\', \'checkpoint_path\', \'yield_single_examples\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\'], " + } + member_method { + name: "train" + argspec: "args=[\'self\', \'input_fn\', \'hooks\', \'steps\', \'max_steps\', \'saving_listeners\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.-baseline-regressor.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-baseline-regressor.pbtxt new file mode 100644 index 0000000000..a363bceae3 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-baseline-regressor.pbtxt @@ -0,0 +1,58 @@ +path: "tensorflow.estimator.BaselineRegressor" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "config" + mtype: "" + } + member { + name: "model_dir" + mtype: "" + } + member { + name: "model_fn" + mtype: "" + } + member { + name: "params" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'model_dir\', \'label_dimension\', \'weight_column\', \'optimizer\', \'config\', \'loss_reduction\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'None\', \'Ftrl\', \'None\', \'weighted_sum\'], " + } + member_method { + name: "eval_dir" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "evaluate" + argspec: "args=[\'self\', \'input_fn\', \'steps\', \'hooks\', \'checkpoint_path\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "export_savedmodel" + argspec: "args=[\'self\', \'export_dir_base\', \'serving_input_receiver_fn\', \'assets_extra\', \'as_text\', \'checkpoint_path\', \'strip_default_attrs\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\', \'False\'], " + } + member_method { + name: "get_variable_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_variable_value" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "latest_checkpoint" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'input_fn\', \'predict_keys\', \'hooks\', \'checkpoint_path\', \'yield_single_examples\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\'], " + } + member_method { + name: "train" + argspec: "args=[\'self\', \'input_fn\', \'hooks\', \'steps\', \'max_steps\', \'saving_listeners\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.-best-exporter.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-best-exporter.pbtxt new file mode 100644 index 0000000000..9694268199 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-best-exporter.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.estimator.BestExporter" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "name" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'name\', \'serving_input_receiver_fn\', \'event_file_pattern\', \'compare_fn\', \'assets_extra\', \'as_text\', \'exports_to_keep\'], varargs=None, keywords=None, defaults=[\'best_exporter\', \'None\', \'eval/*.tfevents.*\', \'\', \'None\', \'False\', \'5\'], " + } + member_method { + name: "export" + argspec: "args=[\'self\', \'estimator\', \'export_path\', \'checkpoint_path\', \'eval_result\', \'is_the_final_export\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.-boosted-trees-classifier.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-boosted-trees-classifier.pbtxt new file mode 100644 index 0000000000..9dbb5d16a4 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-boosted-trees-classifier.pbtxt @@ -0,0 +1,58 @@ +path: "tensorflow.estimator.BoostedTreesClassifier" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "config" + mtype: "" + } + member { + name: "model_dir" + mtype: "" + } + member { + name: "model_fn" + mtype: "" + } + member { + name: "params" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'feature_columns\', \'n_batches_per_layer\', \'model_dir\', \'n_classes\', \'weight_column\', \'label_vocabulary\', \'n_trees\', \'max_depth\', \'learning_rate\', \'l1_regularization\', \'l2_regularization\', \'tree_complexity\', \'min_node_weight\', \'config\', \'center_bias\'], varargs=None, keywords=None, defaults=[\'None\', \'\', \'None\', \'None\', \'100\', \'6\', \'0.1\', \'0.0\', \'0.0\', \'0.0\', \'0.0\', \'None\', \'False\'], " + } + member_method { + name: "eval_dir" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "evaluate" + argspec: "args=[\'self\', \'input_fn\', \'steps\', \'hooks\', \'checkpoint_path\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "export_savedmodel" + argspec: "args=[\'self\', \'export_dir_base\', \'serving_input_receiver_fn\', \'assets_extra\', \'as_text\', \'checkpoint_path\', \'strip_default_attrs\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\', \'False\'], " + } + member_method { + name: "get_variable_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_variable_value" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "latest_checkpoint" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'input_fn\', \'predict_keys\', \'hooks\', \'checkpoint_path\', \'yield_single_examples\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\'], " + } + member_method { + name: "train" + argspec: "args=[\'self\', \'input_fn\', \'hooks\', \'steps\', \'max_steps\', \'saving_listeners\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.-boosted-trees-regressor.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-boosted-trees-regressor.pbtxt new file mode 100644 index 0000000000..34a30c2874 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-boosted-trees-regressor.pbtxt @@ -0,0 +1,58 @@ +path: "tensorflow.estimator.BoostedTreesRegressor" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "config" + mtype: "" + } + member { + name: "model_dir" + mtype: "" + } + member { + name: "model_fn" + mtype: "" + } + member { + name: "params" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'feature_columns\', \'n_batches_per_layer\', \'model_dir\', \'label_dimension\', \'weight_column\', \'n_trees\', \'max_depth\', \'learning_rate\', \'l1_regularization\', \'l2_regularization\', \'tree_complexity\', \'min_node_weight\', \'config\', \'center_bias\'], varargs=None, keywords=None, defaults=[\'None\', \'\', \'None\', \'100\', \'6\', \'0.1\', \'0.0\', \'0.0\', \'0.0\', \'0.0\', \'None\', \'False\'], " + } + member_method { + name: "eval_dir" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "evaluate" + argspec: "args=[\'self\', \'input_fn\', \'steps\', \'hooks\', \'checkpoint_path\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "export_savedmodel" + argspec: "args=[\'self\', \'export_dir_base\', \'serving_input_receiver_fn\', \'assets_extra\', \'as_text\', \'checkpoint_path\', \'strip_default_attrs\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\', \'False\'], " + } + member_method { + name: "get_variable_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_variable_value" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "latest_checkpoint" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'input_fn\', \'predict_keys\', \'hooks\', \'checkpoint_path\', \'yield_single_examples\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\'], " + } + member_method { + name: "train" + argspec: "args=[\'self\', \'input_fn\', \'hooks\', \'steps\', \'max_steps\', \'saving_listeners\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.-d-n-n-classifier.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-d-n-n-classifier.pbtxt new file mode 100644 index 0000000000..0c6b7e4a82 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-d-n-n-classifier.pbtxt @@ -0,0 +1,58 @@ +path: "tensorflow.estimator.DNNClassifier" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "config" + mtype: "" + } + member { + name: "model_dir" + mtype: "" + } + member { + name: "model_fn" + mtype: "" + } + member { + name: "params" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'hidden_units\', \'feature_columns\', \'model_dir\', \'n_classes\', \'weight_column\', \'label_vocabulary\', \'optimizer\', \'activation_fn\', \'dropout\', \'input_layer_partitioner\', \'config\', \'warm_start_from\', \'loss_reduction\', \'batch_norm\'], varargs=None, keywords=None, defaults=[\'None\', \'2\', \'None\', \'None\', \'Adagrad\', \'\', \'None\', \'None\', \'None\', \'None\', \'weighted_sum\', \'False\'], " + } + member_method { + name: "eval_dir" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "evaluate" + argspec: "args=[\'self\', \'input_fn\', \'steps\', \'hooks\', \'checkpoint_path\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "export_savedmodel" + argspec: "args=[\'self\', \'export_dir_base\', \'serving_input_receiver_fn\', \'assets_extra\', \'as_text\', \'checkpoint_path\', \'strip_default_attrs\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\', \'False\'], " + } + member_method { + name: "get_variable_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_variable_value" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "latest_checkpoint" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'input_fn\', \'predict_keys\', \'hooks\', \'checkpoint_path\', \'yield_single_examples\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\'], " + } + member_method { + name: "train" + argspec: "args=[\'self\', \'input_fn\', \'hooks\', \'steps\', \'max_steps\', \'saving_listeners\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.-d-n-n-linear-combined-classifier.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-d-n-n-linear-combined-classifier.pbtxt new file mode 100644 index 0000000000..9c1c072124 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-d-n-n-linear-combined-classifier.pbtxt @@ -0,0 +1,58 @@ +path: "tensorflow.estimator.DNNLinearCombinedClassifier" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "config" + mtype: "" + } + member { + name: "model_dir" + mtype: "" + } + member { + name: "model_fn" + mtype: "" + } + member { + name: "params" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'model_dir\', \'linear_feature_columns\', \'linear_optimizer\', \'dnn_feature_columns\', \'dnn_optimizer\', \'dnn_hidden_units\', \'dnn_activation_fn\', \'dnn_dropout\', \'n_classes\', \'weight_column\', \'label_vocabulary\', \'input_layer_partitioner\', \'config\', \'warm_start_from\', \'loss_reduction\', \'batch_norm\', \'linear_sparse_combiner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'Ftrl\', \'None\', \'Adagrad\', \'None\', \'\', \'None\', \'2\', \'None\', \'None\', \'None\', \'None\', \'None\', \'weighted_sum\', \'False\', \'sum\'], " + } + member_method { + name: "eval_dir" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "evaluate" + argspec: "args=[\'self\', \'input_fn\', \'steps\', \'hooks\', \'checkpoint_path\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "export_savedmodel" + argspec: "args=[\'self\', \'export_dir_base\', \'serving_input_receiver_fn\', \'assets_extra\', \'as_text\', \'checkpoint_path\', \'strip_default_attrs\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\', \'False\'], " + } + member_method { + name: "get_variable_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_variable_value" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "latest_checkpoint" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'input_fn\', \'predict_keys\', \'hooks\', \'checkpoint_path\', \'yield_single_examples\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\'], " + } + member_method { + name: "train" + argspec: "args=[\'self\', \'input_fn\', \'hooks\', \'steps\', \'max_steps\', \'saving_listeners\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.-d-n-n-linear-combined-regressor.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-d-n-n-linear-combined-regressor.pbtxt new file mode 100644 index 0000000000..7391d4b07a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-d-n-n-linear-combined-regressor.pbtxt @@ -0,0 +1,58 @@ +path: "tensorflow.estimator.DNNLinearCombinedRegressor" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "config" + mtype: "" + } + member { + name: "model_dir" + mtype: "" + } + member { + name: "model_fn" + mtype: "" + } + member { + name: "params" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'model_dir\', \'linear_feature_columns\', \'linear_optimizer\', \'dnn_feature_columns\', \'dnn_optimizer\', \'dnn_hidden_units\', \'dnn_activation_fn\', \'dnn_dropout\', \'label_dimension\', \'weight_column\', \'input_layer_partitioner\', \'config\', \'warm_start_from\', \'loss_reduction\', \'batch_norm\', \'linear_sparse_combiner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'Ftrl\', \'None\', \'Adagrad\', \'None\', \'\', \'None\', \'1\', \'None\', \'None\', \'None\', \'None\', \'weighted_sum\', \'False\', \'sum\'], " + } + member_method { + name: "eval_dir" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "evaluate" + argspec: "args=[\'self\', \'input_fn\', \'steps\', \'hooks\', \'checkpoint_path\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "export_savedmodel" + argspec: "args=[\'self\', \'export_dir_base\', \'serving_input_receiver_fn\', \'assets_extra\', \'as_text\', \'checkpoint_path\', \'strip_default_attrs\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\', \'False\'], " + } + member_method { + name: "get_variable_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_variable_value" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "latest_checkpoint" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'input_fn\', \'predict_keys\', \'hooks\', \'checkpoint_path\', \'yield_single_examples\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\'], " + } + member_method { + name: "train" + argspec: "args=[\'self\', \'input_fn\', \'hooks\', \'steps\', \'max_steps\', \'saving_listeners\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.-d-n-n-regressor.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-d-n-n-regressor.pbtxt new file mode 100644 index 0000000000..f50e375f7c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-d-n-n-regressor.pbtxt @@ -0,0 +1,58 @@ +path: "tensorflow.estimator.DNNRegressor" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "config" + mtype: "" + } + member { + name: "model_dir" + mtype: "" + } + member { + name: "model_fn" + mtype: "" + } + member { + name: "params" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'hidden_units\', \'feature_columns\', \'model_dir\', \'label_dimension\', \'weight_column\', \'optimizer\', \'activation_fn\', \'dropout\', \'input_layer_partitioner\', \'config\', \'warm_start_from\', \'loss_reduction\', \'batch_norm\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'None\', \'Adagrad\', \'\', \'None\', \'None\', \'None\', \'None\', \'weighted_sum\', \'False\'], " + } + member_method { + name: "eval_dir" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "evaluate" + argspec: "args=[\'self\', \'input_fn\', \'steps\', \'hooks\', \'checkpoint_path\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "export_savedmodel" + argspec: "args=[\'self\', \'export_dir_base\', \'serving_input_receiver_fn\', \'assets_extra\', \'as_text\', \'checkpoint_path\', \'strip_default_attrs\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\', \'False\'], " + } + member_method { + name: "get_variable_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_variable_value" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "latest_checkpoint" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'input_fn\', \'predict_keys\', \'hooks\', \'checkpoint_path\', \'yield_single_examples\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\'], " + } + member_method { + name: "train" + argspec: "args=[\'self\', \'input_fn\', \'hooks\', \'steps\', \'max_steps\', \'saving_listeners\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.-estimator-spec.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-estimator-spec.pbtxt new file mode 100644 index 0000000000..aa6ac46613 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-estimator-spec.pbtxt @@ -0,0 +1,59 @@ +path: "tensorflow.estimator.EstimatorSpec" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "eval_metric_ops" + mtype: "" + } + member { + name: "evaluation_hooks" + mtype: "" + } + member { + name: "export_outputs" + mtype: "" + } + member { + name: "loss" + mtype: "" + } + member { + name: "mode" + mtype: "" + } + member { + name: "prediction_hooks" + mtype: "" + } + member { + name: "predictions" + mtype: "" + } + member { + name: "scaffold" + mtype: "" + } + member { + name: "train_op" + mtype: "" + } + member { + name: "training_chief_hooks" + mtype: "" + } + member { + name: "training_hooks" + mtype: "" + } + member_method { + name: "__init__" + } + member_method { + name: "count" + } + member_method { + name: "index" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.-estimator.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-estimator.pbtxt new file mode 100644 index 0000000000..d72b576977 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-estimator.pbtxt @@ -0,0 +1,57 @@ +path: "tensorflow.estimator.Estimator" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "config" + mtype: "" + } + member { + name: "model_dir" + mtype: "" + } + member { + name: "model_fn" + mtype: "" + } + member { + name: "params" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'model_fn\', \'model_dir\', \'config\', \'params\', \'warm_start_from\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "eval_dir" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "evaluate" + argspec: "args=[\'self\', \'input_fn\', \'steps\', \'hooks\', \'checkpoint_path\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "export_savedmodel" + argspec: "args=[\'self\', \'export_dir_base\', \'serving_input_receiver_fn\', \'assets_extra\', \'as_text\', \'checkpoint_path\', \'strip_default_attrs\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\', \'False\'], " + } + member_method { + name: "get_variable_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_variable_value" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "latest_checkpoint" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'input_fn\', \'predict_keys\', \'hooks\', \'checkpoint_path\', \'yield_single_examples\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\'], " + } + member_method { + name: "train" + argspec: "args=[\'self\', \'input_fn\', \'hooks\', \'steps\', \'max_steps\', \'saving_listeners\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.-eval-spec.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-eval-spec.pbtxt new file mode 100644 index 0000000000..db83ba1bd8 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-eval-spec.pbtxt @@ -0,0 +1,43 @@ +path: "tensorflow.estimator.EvalSpec" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "exporters" + mtype: "" + } + member { + name: "hooks" + mtype: "" + } + member { + name: "input_fn" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "start_delay_secs" + mtype: "" + } + member { + name: "steps" + mtype: "" + } + member { + name: "throttle_secs" + mtype: "" + } + member_method { + name: "__init__" + } + member_method { + name: "count" + } + member_method { + name: "index" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.-exporter.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-exporter.pbtxt new file mode 100644 index 0000000000..035af70e52 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-exporter.pbtxt @@ -0,0 +1,16 @@ +path: "tensorflow.estimator.Exporter" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "name" + mtype: "" + } + member_method { + name: "__init__" + } + member_method { + name: "export" + argspec: "args=[\'self\', \'estimator\', \'export_path\', \'checkpoint_path\', \'eval_result\', \'is_the_final_export\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.-final-exporter.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-final-exporter.pbtxt new file mode 100644 index 0000000000..ee37b1fa21 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-final-exporter.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.estimator.FinalExporter" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "name" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'name\', \'serving_input_receiver_fn\', \'assets_extra\', \'as_text\'], varargs=None, keywords=None, defaults=[\'None\', \'False\'], " + } + member_method { + name: "export" + argspec: "args=[\'self\', \'estimator\', \'export_path\', \'checkpoint_path\', \'eval_result\', \'is_the_final_export\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.-latest-exporter.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-latest-exporter.pbtxt new file mode 100644 index 0000000000..2a9d029029 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-latest-exporter.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.estimator.LatestExporter" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "name" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'name\', \'serving_input_receiver_fn\', \'assets_extra\', \'as_text\', \'exports_to_keep\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'5\'], " + } + member_method { + name: "export" + argspec: "args=[\'self\', \'estimator\', \'export_path\', \'checkpoint_path\', \'eval_result\', \'is_the_final_export\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.-linear-classifier.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-linear-classifier.pbtxt new file mode 100644 index 0000000000..154f171e89 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-linear-classifier.pbtxt @@ -0,0 +1,58 @@ +path: "tensorflow.estimator.LinearClassifier" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "config" + mtype: "" + } + member { + name: "model_dir" + mtype: "" + } + member { + name: "model_fn" + mtype: "" + } + member { + name: "params" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'feature_columns\', \'model_dir\', \'n_classes\', \'weight_column\', \'label_vocabulary\', \'optimizer\', \'config\', \'partitioner\', \'warm_start_from\', \'loss_reduction\', \'sparse_combiner\'], varargs=None, keywords=None, defaults=[\'None\', \'2\', \'None\', \'None\', \'Ftrl\', \'None\', \'None\', \'None\', \'weighted_sum\', \'sum\'], " + } + member_method { + name: "eval_dir" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "evaluate" + argspec: "args=[\'self\', \'input_fn\', \'steps\', \'hooks\', \'checkpoint_path\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "export_savedmodel" + argspec: "args=[\'self\', \'export_dir_base\', \'serving_input_receiver_fn\', \'assets_extra\', \'as_text\', \'checkpoint_path\', \'strip_default_attrs\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\', \'False\'], " + } + member_method { + name: "get_variable_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_variable_value" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "latest_checkpoint" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'input_fn\', \'predict_keys\', \'hooks\', \'checkpoint_path\', \'yield_single_examples\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\'], " + } + member_method { + name: "train" + argspec: "args=[\'self\', \'input_fn\', \'hooks\', \'steps\', \'max_steps\', \'saving_listeners\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.-linear-regressor.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-linear-regressor.pbtxt new file mode 100644 index 0000000000..4d46d1e6b6 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-linear-regressor.pbtxt @@ -0,0 +1,58 @@ +path: "tensorflow.estimator.LinearRegressor" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "config" + mtype: "" + } + member { + name: "model_dir" + mtype: "" + } + member { + name: "model_fn" + mtype: "" + } + member { + name: "params" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'feature_columns\', \'model_dir\', \'label_dimension\', \'weight_column\', \'optimizer\', \'config\', \'partitioner\', \'warm_start_from\', \'loss_reduction\', \'sparse_combiner\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'None\', \'Ftrl\', \'None\', \'None\', \'None\', \'weighted_sum\', \'sum\'], " + } + member_method { + name: "eval_dir" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "evaluate" + argspec: "args=[\'self\', \'input_fn\', \'steps\', \'hooks\', \'checkpoint_path\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "export_savedmodel" + argspec: "args=[\'self\', \'export_dir_base\', \'serving_input_receiver_fn\', \'assets_extra\', \'as_text\', \'checkpoint_path\', \'strip_default_attrs\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\', \'False\'], " + } + member_method { + name: "get_variable_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_variable_value" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "latest_checkpoint" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'input_fn\', \'predict_keys\', \'hooks\', \'checkpoint_path\', \'yield_single_examples\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\'], " + } + member_method { + name: "train" + argspec: "args=[\'self\', \'input_fn\', \'hooks\', \'steps\', \'max_steps\', \'saving_listeners\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.-mode-keys.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-mode-keys.pbtxt new file mode 100644 index 0000000000..6a1c24fa63 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-mode-keys.pbtxt @@ -0,0 +1,20 @@ +path: "tensorflow.estimator.ModeKeys" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "EVAL" + mtype: "" + } + member { + name: "PREDICT" + mtype: "" + } + member { + name: "TRAIN" + mtype: "" + } + member_method { + name: "__init__" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.-run-config.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-run-config.pbtxt new file mode 100644 index 0000000000..5aa4b3d4fb --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-run-config.pbtxt @@ -0,0 +1,101 @@ +path: "tensorflow.estimator.RunConfig" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "cluster_spec" + mtype: "" + } + member { + name: "device_fn" + mtype: "" + } + member { + name: "evaluation_master" + mtype: "" + } + member { + name: "global_id_in_cluster" + mtype: "" + } + member { + name: "is_chief" + mtype: "" + } + member { + name: "keep_checkpoint_every_n_hours" + mtype: "" + } + member { + name: "keep_checkpoint_max" + mtype: "" + } + member { + name: "log_step_count_steps" + mtype: "" + } + member { + name: "master" + mtype: "" + } + member { + name: "model_dir" + mtype: "" + } + member { + name: "num_ps_replicas" + mtype: "" + } + member { + name: "num_worker_replicas" + mtype: "" + } + member { + name: "protocol" + mtype: "" + } + member { + name: "save_checkpoints_secs" + mtype: "" + } + member { + name: "save_checkpoints_steps" + mtype: "" + } + member { + name: "save_summary_steps" + mtype: "" + } + member { + name: "service" + mtype: "" + } + member { + name: "session_config" + mtype: "" + } + member { + name: "task_id" + mtype: "" + } + member { + name: "task_type" + mtype: "" + } + member { + name: "tf_random_seed" + mtype: "" + } + member { + name: "train_distribute" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'model_dir\', \'tf_random_seed\', \'save_summary_steps\', \'save_checkpoints_steps\', \'save_checkpoints_secs\', \'session_config\', \'keep_checkpoint_max\', \'keep_checkpoint_every_n_hours\', \'log_step_count_steps\', \'train_distribute\', \'device_fn\', \'protocol\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'100\', \'\', \'\', \'None\', \'5\', \'10000\', \'100\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "replace" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.-train-spec.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-train-spec.pbtxt new file mode 100644 index 0000000000..7d2f77438a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-train-spec.pbtxt @@ -0,0 +1,27 @@ +path: "tensorflow.estimator.TrainSpec" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "hooks" + mtype: "" + } + member { + name: "input_fn" + mtype: "" + } + member { + name: "max_steps" + mtype: "" + } + member_method { + name: "__init__" + } + member_method { + name: "count" + } + member_method { + name: "index" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.-vocab-info.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-vocab-info.pbtxt new file mode 100644 index 0000000000..5301b94eb3 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-vocab-info.pbtxt @@ -0,0 +1,39 @@ +path: "tensorflow.estimator.VocabInfo" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "backup_initializer" + mtype: "" + } + member { + name: "new_vocab" + mtype: "" + } + member { + name: "new_vocab_size" + mtype: "" + } + member { + name: "num_oov_buckets" + mtype: "" + } + member { + name: "old_vocab" + mtype: "" + } + member { + name: "old_vocab_size" + mtype: "" + } + member_method { + name: "__init__" + } + member_method { + name: "count" + } + member_method { + name: "index" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.-warm-start-settings.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-warm-start-settings.pbtxt new file mode 100644 index 0000000000..43f5343359 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.-warm-start-settings.pbtxt @@ -0,0 +1,31 @@ +path: "tensorflow.estimator.WarmStartSettings" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "ckpt_to_initialize_from" + mtype: "" + } + member { + name: "var_name_to_prev_var_name" + mtype: "" + } + member { + name: "var_name_to_vocab_info" + mtype: "" + } + member { + name: "vars_to_warm_start" + mtype: "" + } + member_method { + name: "__init__" + } + member_method { + name: "count" + } + member_method { + name: "index" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-classification-output.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-classification-output.__metaclass__.pbtxt new file mode 100644 index 0000000000..3cf7af8da9 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-classification-output.__metaclass__.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.estimator.export.ClassificationOutput.__metaclass__" +tf_class { + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "mro" + } + member_method { + name: "register" + argspec: "args=[\'cls\', \'subclass\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-classification-output.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-classification-output.pbtxt new file mode 100644 index 0000000000..2df1840c4a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-classification-output.pbtxt @@ -0,0 +1,22 @@ +path: "tensorflow.estimator.export.ClassificationOutput" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "classes" + mtype: "" + } + member { + name: "scores" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'scores\', \'classes\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "as_signature_def" + argspec: "args=[\'self\', \'receiver_tensors\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-export-output.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-export-output.__metaclass__.pbtxt new file mode 100644 index 0000000000..5d165ccbf9 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-export-output.__metaclass__.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.estimator.export.ExportOutput.__metaclass__" +tf_class { + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "mro" + } + member_method { + name: "register" + argspec: "args=[\'cls\', \'subclass\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-export-output.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-export-output.pbtxt new file mode 100644 index 0000000000..fa62e8ced8 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-export-output.pbtxt @@ -0,0 +1,12 @@ +path: "tensorflow.estimator.export.ExportOutput" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "as_signature_def" + argspec: "args=[\'self\', \'receiver_tensors\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-predict-output.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-predict-output.__metaclass__.pbtxt new file mode 100644 index 0000000000..743495ba98 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-predict-output.__metaclass__.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.estimator.export.PredictOutput.__metaclass__" +tf_class { + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "mro" + } + member_method { + name: "register" + argspec: "args=[\'cls\', \'subclass\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-predict-output.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-predict-output.pbtxt new file mode 100644 index 0000000000..e0160b10ce --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-predict-output.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.estimator.export.PredictOutput" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "outputs" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'outputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "as_signature_def" + argspec: "args=[\'self\', \'receiver_tensors\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-regression-output.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-regression-output.__metaclass__.pbtxt new file mode 100644 index 0000000000..dbf4e3dec8 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-regression-output.__metaclass__.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.estimator.export.RegressionOutput.__metaclass__" +tf_class { + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "mro" + } + member_method { + name: "register" + argspec: "args=[\'cls\', \'subclass\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-regression-output.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-regression-output.pbtxt new file mode 100644 index 0000000000..905f0e0553 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-regression-output.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.estimator.export.RegressionOutput" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "value" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'value\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "as_signature_def" + argspec: "args=[\'self\', \'receiver_tensors\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-serving-input-receiver.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-serving-input-receiver.pbtxt new file mode 100644 index 0000000000..d71b2a4300 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-serving-input-receiver.pbtxt @@ -0,0 +1,27 @@ +path: "tensorflow.estimator.export.ServingInputReceiver" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "features" + mtype: "" + } + member { + name: "receiver_tensors" + mtype: "" + } + member { + name: "receiver_tensors_alternatives" + mtype: "" + } + member_method { + name: "__init__" + } + member_method { + name: "count" + } + member_method { + name: "index" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-tensor-serving-input-receiver.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-tensor-serving-input-receiver.pbtxt new file mode 100644 index 0000000000..4fe92643bf --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.-tensor-serving-input-receiver.pbtxt @@ -0,0 +1,27 @@ +path: "tensorflow.estimator.export.TensorServingInputReceiver" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "features" + mtype: "" + } + member { + name: "receiver_tensors" + mtype: "" + } + member { + name: "receiver_tensors_alternatives" + mtype: "" + } + member_method { + name: "__init__" + } + member_method { + name: "count" + } + member_method { + name: "index" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.pbtxt new file mode 100644 index 0000000000..bd72f6cd79 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.export.pbtxt @@ -0,0 +1,35 @@ +path: "tensorflow.estimator.export" +tf_module { + member { + name: "ClassificationOutput" + mtype: "" + } + member { + name: "ExportOutput" + mtype: "" + } + member { + name: "PredictOutput" + mtype: "" + } + member { + name: "RegressionOutput" + mtype: "" + } + member { + name: "ServingInputReceiver" + mtype: "" + } + member { + name: "TensorServingInputReceiver" + mtype: "" + } + member_method { + name: "build_parsing_serving_input_receiver_fn" + argspec: "args=[\'feature_spec\', \'default_batch_size\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "build_raw_serving_input_receiver_fn" + argspec: "args=[\'features\', \'default_batch_size\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.inputs.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.inputs.pbtxt new file mode 100644 index 0000000000..b318fea1f8 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.inputs.pbtxt @@ -0,0 +1,11 @@ +path: "tensorflow.estimator.inputs" +tf_module { + member_method { + name: "numpy_input_fn" + argspec: "args=[\'x\', \'y\', \'batch_size\', \'num_epochs\', \'shuffle\', \'queue_capacity\', \'num_threads\'], varargs=None, keywords=None, defaults=[\'None\', \'128\', \'1\', \'None\', \'1000\', \'1\'], " + } + member_method { + name: "pandas_input_fn" + argspec: "args=[\'x\', \'y\', \'batch_size\', \'num_epochs\', \'shuffle\', \'queue_capacity\', \'num_threads\', \'target_column\'], varargs=None, keywords=None, defaults=[\'None\', \'128\', \'1\', \'None\', \'1000\', \'1\', \'target\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.estimator.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.estimator.pbtxt new file mode 100644 index 0000000000..f1d204a3ef --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.estimator.pbtxt @@ -0,0 +1,111 @@ +path: "tensorflow.estimator" +tf_module { + member { + name: "BaselineClassifier" + mtype: "" + } + member { + name: "BaselineRegressor" + mtype: "" + } + member { + name: "BestExporter" + mtype: "" + } + member { + name: "BoostedTreesClassifier" + mtype: "" + } + member { + name: "BoostedTreesRegressor" + mtype: "" + } + member { + name: "DNNClassifier" + mtype: "" + } + member { + name: "DNNLinearCombinedClassifier" + mtype: "" + } + member { + name: "DNNLinearCombinedRegressor" + mtype: "" + } + member { + name: "DNNRegressor" + mtype: "" + } + member { + name: "Estimator" + mtype: "" + } + member { + name: "EstimatorSpec" + mtype: "" + } + member { + name: "EvalSpec" + mtype: "" + } + member { + name: "Exporter" + mtype: "" + } + member { + name: "FinalExporter" + mtype: "" + } + member { + name: "LatestExporter" + mtype: "" + } + member { + name: "LinearClassifier" + mtype: "" + } + member { + name: "LinearRegressor" + mtype: "" + } + member { + name: "ModeKeys" + mtype: "" + } + member { + name: "RunConfig" + mtype: "" + } + member { + name: "TrainSpec" + mtype: "" + } + member { + name: "VocabInfo" + mtype: "" + } + member { + name: "WarmStartSettings" + mtype: "" + } + member { + name: "export" + mtype: "" + } + member { + name: "inputs" + mtype: "" + } + member_method { + name: "classifier_parse_example_spec" + argspec: "args=[\'feature_columns\', \'label_key\', \'label_dtype\', \'label_default\', \'weight_column\'], varargs=None, keywords=None, defaults=[\"\", \'None\', \'None\'], " + } + member_method { + name: "regressor_parse_example_spec" + argspec: "args=[\'feature_columns\', \'label_key\', \'label_dtype\', \'label_default\', \'label_dimension\', \'weight_column\'], varargs=None, keywords=None, defaults=[\"\", \'None\', \'1\', \'None\'], " + } + member_method { + name: "train_and_evaluate" + argspec: "args=[\'estimator\', \'train_spec\', \'eval_spec\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.feature_column.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.feature_column.pbtxt new file mode 100644 index 0000000000..24a58fb118 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.feature_column.pbtxt @@ -0,0 +1,59 @@ +path: "tensorflow.feature_column" +tf_module { + member_method { + name: "bucketized_column" + argspec: "args=[\'source_column\', \'boundaries\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "categorical_column_with_hash_bucket" + argspec: "args=[\'key\', \'hash_bucket_size\', \'dtype\'], varargs=None, keywords=None, defaults=[\"\"], " + } + member_method { + name: "categorical_column_with_identity" + argspec: "args=[\'key\', \'num_buckets\', \'default_value\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "categorical_column_with_vocabulary_file" + argspec: "args=[\'key\', \'vocabulary_file\', \'vocabulary_size\', \'num_oov_buckets\', \'default_value\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\', \'0\', \'None\', \"\"], " + } + member_method { + name: "categorical_column_with_vocabulary_list" + argspec: "args=[\'key\', \'vocabulary_list\', \'dtype\', \'default_value\', \'num_oov_buckets\'], varargs=None, keywords=None, defaults=[\'None\', \'-1\', \'0\'], " + } + member_method { + name: "crossed_column" + argspec: "args=[\'keys\', \'hash_bucket_size\', \'hash_key\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "embedding_column" + argspec: "args=[\'categorical_column\', \'dimension\', \'combiner\', \'initializer\', \'ckpt_to_load_from\', \'tensor_name_in_ckpt\', \'max_norm\', \'trainable\'], varargs=None, keywords=None, defaults=[\'mean\', \'None\', \'None\', \'None\', \'None\', \'True\'], " + } + member_method { + name: "indicator_column" + argspec: "args=[\'categorical_column\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "input_layer" + argspec: "args=[\'features\', \'feature_columns\', \'weight_collections\', \'trainable\', \'cols_to_vars\'], varargs=None, keywords=None, defaults=[\'None\', \'True\', \'None\'], " + } + member_method { + name: "linear_model" + argspec: "args=[\'features\', \'feature_columns\', \'units\', \'sparse_combiner\', \'weight_collections\', \'trainable\', \'cols_to_vars\'], varargs=None, keywords=None, defaults=[\'1\', \'sum\', \'None\', \'True\', \'None\'], " + } + member_method { + name: "make_parse_example_spec" + argspec: "args=[\'feature_columns\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "numeric_column" + argspec: "args=[\'key\', \'shape\', \'default_value\', \'dtype\', \'normalizer_fn\'], varargs=None, keywords=None, defaults=[\'(1,)\', \'None\', \"\", \'None\'], " + } + member_method { + name: "shared_embedding_columns" + argspec: "args=[\'categorical_columns\', \'dimension\', \'combiner\', \'initializer\', \'shared_embedding_collection_name\', \'ckpt_to_load_from\', \'tensor_name_in_ckpt\', \'max_norm\', \'trainable\'], varargs=None, keywords=None, defaults=[\'mean\', \'None\', \'None\', \'None\', \'None\', \'None\', \'True\'], " + } + member_method { + name: "weighted_categorical_column" + argspec: "args=[\'categorical_column\', \'weight_feature_key\', \'dtype\'], varargs=None, keywords=None, defaults=[\"\"], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.gfile.-fast-g-file.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.gfile.-fast-g-file.pbtxt new file mode 100644 index 0000000000..eecfaffd0a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.gfile.-fast-g-file.pbtxt @@ -0,0 +1,58 @@ +path: "tensorflow.gfile.FastGFile" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "mode" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'name\', \'mode\'], varargs=None, keywords=None, defaults=[\'r\'], " + } + member_method { + name: "close" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "flush" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "next" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "read" + argspec: "args=[\'self\', \'n\'], varargs=None, keywords=None, defaults=[\'-1\'], " + } + member_method { + name: "readline" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "readlines" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "seek" + argspec: "args=[\'self\', \'offset\', \'whence\', \'position\'], varargs=None, keywords=None, defaults=[\'None\', \'0\', \'None\'], " + } + member_method { + name: "size" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "tell" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "write" + argspec: "args=[\'self\', \'file_content\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.gfile.-g-file.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.gfile.-g-file.pbtxt new file mode 100644 index 0000000000..305251059d --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.gfile.-g-file.pbtxt @@ -0,0 +1,58 @@ +path: "tensorflow.gfile.GFile" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "mode" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'name\', \'mode\'], varargs=None, keywords=None, defaults=[\'r\'], " + } + member_method { + name: "close" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "flush" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "next" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "read" + argspec: "args=[\'self\', \'n\'], varargs=None, keywords=None, defaults=[\'-1\'], " + } + member_method { + name: "readline" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "readlines" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "seek" + argspec: "args=[\'self\', \'offset\', \'whence\', \'position\'], varargs=None, keywords=None, defaults=[\'None\', \'0\', \'None\'], " + } + member_method { + name: "size" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "tell" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "write" + argspec: "args=[\'self\', \'file_content\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.gfile.-open.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.gfile.-open.pbtxt new file mode 100644 index 0000000000..6e8894180a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.gfile.-open.pbtxt @@ -0,0 +1,58 @@ +path: "tensorflow.gfile.Open" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "mode" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'name\', \'mode\'], varargs=None, keywords=None, defaults=[\'r\'], " + } + member_method { + name: "close" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "flush" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "next" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "read" + argspec: "args=[\'self\', \'n\'], varargs=None, keywords=None, defaults=[\'-1\'], " + } + member_method { + name: "readline" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "readlines" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "seek" + argspec: "args=[\'self\', \'offset\', \'whence\', \'position\'], varargs=None, keywords=None, defaults=[\'None\', \'0\', \'None\'], " + } + member_method { + name: "size" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "tell" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "write" + argspec: "args=[\'self\', \'file_content\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.gfile.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.gfile.pbtxt new file mode 100644 index 0000000000..65b55a8b7c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.gfile.pbtxt @@ -0,0 +1,63 @@ +path: "tensorflow.gfile" +tf_module { + member { + name: "FastGFile" + mtype: "" + } + member { + name: "GFile" + mtype: "" + } + member { + name: "Open" + mtype: "" + } + member_method { + name: "Copy" + argspec: "args=[\'oldpath\', \'newpath\', \'overwrite\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "DeleteRecursively" + argspec: "args=[\'dirname\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "Exists" + argspec: "args=[\'filename\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "Glob" + argspec: "args=[\'filename\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "IsDirectory" + argspec: "args=[\'dirname\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "ListDirectory" + argspec: "args=[\'dirname\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "MakeDirs" + argspec: "args=[\'dirname\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "MkDir" + argspec: "args=[\'dirname\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "Remove" + argspec: "args=[\'filename\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "Rename" + argspec: "args=[\'oldname\', \'newname\', \'overwrite\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "Stat" + argspec: "args=[\'filename\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "Walk" + argspec: "args=[\'top\', \'in_order\'], varargs=None, keywords=None, defaults=[\'True\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.graph_util.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.graph_util.pbtxt new file mode 100644 index 0000000000..eeabf845dc --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.graph_util.pbtxt @@ -0,0 +1,23 @@ +path: "tensorflow.graph_util" +tf_module { + member_method { + name: "convert_variables_to_constants" + argspec: "args=[\'sess\', \'input_graph_def\', \'output_node_names\', \'variable_names_whitelist\', \'variable_names_blacklist\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "extract_sub_graph" + argspec: "args=[\'graph_def\', \'dest_nodes\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "must_run_on_cpu" + argspec: "args=[\'node\', \'pin_variables_on_cpu\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "remove_training_nodes" + argspec: "args=[\'input_graph\', \'protected_nodes\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "tensor_shape_from_node_def_name" + argspec: "args=[\'graph\', \'input_name\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.image.-resize-method.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.image.-resize-method.pbtxt new file mode 100644 index 0000000000..dbc360b13e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.image.-resize-method.pbtxt @@ -0,0 +1,24 @@ +path: "tensorflow.image.ResizeMethod" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "AREA" + mtype: "" + } + member { + name: "BICUBIC" + mtype: "" + } + member { + name: "BILINEAR" + mtype: "" + } + member { + name: "NEAREST_NEIGHBOR" + mtype: "" + } + member_method { + name: "__init__" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.image.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.image.pbtxt new file mode 100644 index 0000000000..6ec3aba775 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.image.pbtxt @@ -0,0 +1,247 @@ +path: "tensorflow.image" +tf_module { + member { + name: "ResizeMethod" + mtype: "" + } + member_method { + name: "adjust_brightness" + argspec: "args=[\'image\', \'delta\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "adjust_contrast" + argspec: "args=[\'images\', \'contrast_factor\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "adjust_gamma" + argspec: "args=[\'image\', \'gamma\', \'gain\'], varargs=None, keywords=None, defaults=[\'1\', \'1\'], " + } + member_method { + name: "adjust_hue" + argspec: "args=[\'image\', \'delta\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "adjust_jpeg_quality" + argspec: "args=[\'image\', \'jpeg_quality\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "adjust_saturation" + argspec: "args=[\'image\', \'saturation_factor\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "central_crop" + argspec: "args=[\'image\', \'central_fraction\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "convert_image_dtype" + argspec: "args=[\'image\', \'dtype\', \'saturate\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "crop_and_resize" + argspec: "args=[\'image\', \'boxes\', \'box_ind\', \'crop_size\', \'method\', \'extrapolation_value\', \'name\'], varargs=None, keywords=None, defaults=[\'bilinear\', \'0\', \'None\'], " + } + member_method { + name: "crop_to_bounding_box" + argspec: "args=[\'image\', \'offset_height\', \'offset_width\', \'target_height\', \'target_width\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "decode_and_crop_jpeg" + argspec: "args=[\'contents\', \'crop_window\', \'channels\', \'ratio\', \'fancy_upscaling\', \'try_recover_truncated\', \'acceptable_fraction\', \'dct_method\', \'name\'], varargs=None, keywords=None, defaults=[\'0\', \'1\', \'True\', \'False\', \'1\', \'\', \'None\'], " + } + member_method { + name: "decode_bmp" + argspec: "args=[\'contents\', \'channels\', \'name\'], varargs=None, keywords=None, defaults=[\'0\', \'None\'], " + } + member_method { + name: "decode_gif" + argspec: "args=[\'contents\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "decode_image" + argspec: "args=[\'contents\', \'channels\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \"\", \'None\'], " + } + member_method { + name: "decode_jpeg" + argspec: "args=[\'contents\', \'channels\', \'ratio\', \'fancy_upscaling\', \'try_recover_truncated\', \'acceptable_fraction\', \'dct_method\', \'name\'], varargs=None, keywords=None, defaults=[\'0\', \'1\', \'True\', \'False\', \'1\', \'\', \'None\'], " + } + member_method { + name: "decode_png" + argspec: "args=[\'contents\', \'channels\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\'0\', \"\", \'None\'], " + } + member_method { + name: "draw_bounding_boxes" + argspec: "args=[\'images\', \'boxes\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "encode_jpeg" + argspec: "args=[\'image\', \'format\', \'quality\', \'progressive\', \'optimize_size\', \'chroma_downsampling\', \'density_unit\', \'x_density\', \'y_density\', \'xmp_metadata\', \'name\'], varargs=None, keywords=None, defaults=[\'\', \'95\', \'False\', \'False\', \'True\', \'in\', \'300\', \'300\', \'\', \'None\'], " + } + member_method { + name: "encode_png" + argspec: "args=[\'image\', \'compression\', \'name\'], varargs=None, keywords=None, defaults=[\'-1\', \'None\'], " + } + member_method { + name: "extract_glimpse" + argspec: "args=[\'input\', \'size\', \'offsets\', \'centered\', \'normalized\', \'uniform_noise\', \'name\'], varargs=None, keywords=None, defaults=[\'True\', \'True\', \'True\', \'None\'], " + } + member_method { + name: "extract_image_patches" + argspec: "args=[\'images\', \'ksizes\', \'strides\', \'rates\', \'padding\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "extract_jpeg_shape" + argspec: "args=[\'contents\', \'output_type\', \'name\'], varargs=None, keywords=None, defaults=[\"\", \'None\'], " + } + member_method { + name: "flip_left_right" + argspec: "args=[\'image\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "flip_up_down" + argspec: "args=[\'image\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "grayscale_to_rgb" + argspec: "args=[\'images\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "hsv_to_rgb" + argspec: "args=[\'images\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "image_gradients" + argspec: "args=[\'image\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "is_jpeg" + argspec: "args=[\'contents\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "non_max_suppression" + argspec: "args=[\'boxes\', \'scores\', \'max_output_size\', \'iou_threshold\', \'score_threshold\', \'name\'], varargs=None, keywords=None, defaults=[\'0.5\', \'-inf\', \'None\'], " + } + member_method { + name: "non_max_suppression_overlaps" + argspec: "args=[\'overlaps\', \'scores\', \'max_output_size\', \'overlap_threshold\', \'score_threshold\', \'name\'], varargs=None, keywords=None, defaults=[\'0.5\', \'-inf\', \'None\'], " + } + member_method { + name: "pad_to_bounding_box" + argspec: "args=[\'image\', \'offset_height\', \'offset_width\', \'target_height\', \'target_width\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "per_image_standardization" + argspec: "args=[\'image\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "psnr" + argspec: "args=[\'a\', \'b\', \'max_val\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "random_brightness" + argspec: "args=[\'image\', \'max_delta\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "random_contrast" + argspec: "args=[\'image\', \'lower\', \'upper\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "random_flip_left_right" + argspec: "args=[\'image\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "random_flip_up_down" + argspec: "args=[\'image\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "random_hue" + argspec: "args=[\'image\', \'max_delta\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "random_jpeg_quality" + argspec: "args=[\'image\', \'min_jpeg_quality\', \'max_jpeg_quality\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "random_saturation" + argspec: "args=[\'image\', \'lower\', \'upper\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "resize_area" + argspec: "args=[\'images\', \'size\', \'align_corners\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "resize_bicubic" + argspec: "args=[\'images\', \'size\', \'align_corners\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "resize_bilinear" + argspec: "args=[\'images\', \'size\', \'align_corners\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "resize_image_with_crop_or_pad" + argspec: "args=[\'image\', \'target_height\', \'target_width\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "resize_image_with_pad" + argspec: "args=[\'image\', \'target_height\', \'target_width\', \'method\'], varargs=None, keywords=None, defaults=[\'0\'], " + } + member_method { + name: "resize_images" + argspec: "args=[\'images\', \'size\', \'method\', \'align_corners\', \'preserve_aspect_ratio\'], varargs=None, keywords=None, defaults=[\'0\', \'False\', \'False\'], " + } + member_method { + name: "resize_nearest_neighbor" + argspec: "args=[\'images\', \'size\', \'align_corners\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "rgb_to_grayscale" + argspec: "args=[\'images\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "rgb_to_hsv" + argspec: "args=[\'images\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "rgb_to_yiq" + argspec: "args=[\'images\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "rgb_to_yuv" + argspec: "args=[\'images\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "rot90" + argspec: "args=[\'image\', \'k\', \'name\'], varargs=None, keywords=None, defaults=[\'1\', \'None\'], " + } + member_method { + name: "sample_distorted_bounding_box" + argspec: "args=[\'image_size\', \'bounding_boxes\', \'seed\', \'seed2\', \'min_object_covered\', \'aspect_ratio_range\', \'area_range\', \'max_attempts\', \'use_image_if_no_bounding_boxes\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'0.1\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "sobel_edges" + argspec: "args=[\'image\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "ssim" + argspec: "args=[\'img1\', \'img2\', \'max_val\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "ssim_multiscale" + argspec: "args=[\'img1\', \'img2\', \'max_val\', \'power_factors\'], varargs=None, keywords=None, defaults=[\'(0.0448, 0.2856, 0.3001, 0.2363, 0.1333)\'], " + } + member_method { + name: "total_variation" + argspec: "args=[\'images\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "transpose_image" + argspec: "args=[\'image\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "yiq_to_rgb" + argspec: "args=[\'images\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "yuv_to_rgb" + argspec: "args=[\'images\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.initializers.constant.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.initializers.constant.pbtxt new file mode 100644 index 0000000000..607a5aae21 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.initializers.constant.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.initializers.constant" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'value\', \'dtype\', \'verify_shape\'], varargs=None, keywords=None, defaults=[\'0\', \"\", \'False\'], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.initializers.identity.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.initializers.identity.pbtxt new file mode 100644 index 0000000000..37fcab9599 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.initializers.identity.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.initializers.identity" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'gain\', \'dtype\'], varargs=None, keywords=None, defaults=[\'1.0\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.initializers.ones.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.initializers.ones.pbtxt new file mode 100644 index 0000000000..18481d4815 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.initializers.ones.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.initializers.ones" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'dtype\'], varargs=None, keywords=None, defaults=[\"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.initializers.orthogonal.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.initializers.orthogonal.pbtxt new file mode 100644 index 0000000000..ff64efd60c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.initializers.orthogonal.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.initializers.orthogonal" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'gain\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'1.0\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.initializers.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.initializers.pbtxt new file mode 100644 index 0000000000..bc0426f2f1 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.initializers.pbtxt @@ -0,0 +1,79 @@ +path: "tensorflow.initializers" +tf_module { + member { + name: "constant" + mtype: "" + } + member { + name: "identity" + mtype: "" + } + member { + name: "ones" + mtype: "" + } + member { + name: "orthogonal" + mtype: "" + } + member { + name: "random_normal" + mtype: "" + } + member { + name: "random_uniform" + mtype: "" + } + member { + name: "truncated_normal" + mtype: "" + } + member { + name: "uniform_unit_scaling" + mtype: "" + } + member { + name: "variance_scaling" + mtype: "" + } + member { + name: "zeros" + mtype: "" + } + member_method { + name: "global_variables" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "glorot_normal" + argspec: "args=[\'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\', \"\"], " + } + member_method { + name: "glorot_uniform" + argspec: "args=[\'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\', \"\"], " + } + member_method { + name: "he_normal" + argspec: "args=[\'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "he_uniform" + argspec: "args=[\'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "lecun_normal" + argspec: "args=[\'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "lecun_uniform" + argspec: "args=[\'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "local_variables" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "variables" + argspec: "args=[\'var_list\', \'name\'], varargs=None, keywords=None, defaults=[\'init\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.initializers.random_normal.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.initializers.random_normal.pbtxt new file mode 100644 index 0000000000..133e61c1d9 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.initializers.random_normal.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.initializers.random_normal" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'mean\', \'stddev\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'0.0\', \'1.0\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.initializers.random_uniform.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.initializers.random_uniform.pbtxt new file mode 100644 index 0000000000..0cfa0080f5 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.initializers.random_uniform.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.initializers.random_uniform" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'minval\', \'maxval\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'0\', \'None\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.initializers.truncated_normal.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.initializers.truncated_normal.pbtxt new file mode 100644 index 0000000000..730390fba2 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.initializers.truncated_normal.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.initializers.truncated_normal" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'mean\', \'stddev\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'0.0\', \'1.0\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.initializers.uniform_unit_scaling.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.initializers.uniform_unit_scaling.pbtxt new file mode 100644 index 0000000000..13295ef375 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.initializers.uniform_unit_scaling.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.initializers.uniform_unit_scaling" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'factor\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'1.0\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.initializers.variance_scaling.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.initializers.variance_scaling.pbtxt new file mode 100644 index 0000000000..86340913e2 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.initializers.variance_scaling.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.initializers.variance_scaling" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'scale\', \'mode\', \'distribution\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'1.0\', \'fan_in\', \'truncated_normal\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.initializers.zeros.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.initializers.zeros.pbtxt new file mode 100644 index 0000000000..7df4237bb6 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.initializers.zeros.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.initializers.zeros" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'dtype\'], varargs=None, keywords=None, defaults=[\"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.io.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.io.pbtxt new file mode 100644 index 0000000000..3a36c168aa --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.io.pbtxt @@ -0,0 +1,39 @@ +path: "tensorflow.io" +tf_module { + member_method { + name: "decode_base64" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "decode_compressed" + argspec: "args=[\'bytes\', \'compression_type\', \'name\'], varargs=None, keywords=None, defaults=[\'\', \'None\'], " + } + member_method { + name: "decode_json_example" + argspec: "args=[\'json_examples\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "decode_raw" + argspec: "args=[\'bytes\', \'out_type\', \'little_endian\', \'name\'], varargs=None, keywords=None, defaults=[\'True\', \'None\'], " + } + member_method { + name: "encode_base64" + argspec: "args=[\'input\', \'pad\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "matching_files" + argspec: "args=[\'pattern\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "parse_tensor" + argspec: "args=[\'serialized\', \'out_type\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "read_file" + argspec: "args=[\'filename\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "write_file" + argspec: "args=[\'filename\', \'contents\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.-model.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.-model.pbtxt new file mode 100644 index 0000000000..40e82b18b6 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.-model.pbtxt @@ -0,0 +1,268 @@ +path: "tensorflow.keras.Model" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "input_spec" + mtype: "" + } + member { + name: "layers" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "state_updates" + mtype: "" + } + member { + name: "stateful" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "uses_learning_phase" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\', \'None\'], " + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'training\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "compile" + argspec: "args=[\'self\', \'optimizer\', \'loss\', \'metrics\', \'loss_weights\', \'sample_weight_mode\', \'weighted_metrics\', \'target_tensors\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "evaluate" + argspec: "args=[\'self\', \'x\', \'y\', \'batch_size\', \'verbose\', \'sample_weight\', \'steps\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'1\', \'None\', \'None\'], " + } + member_method { + name: "evaluate_generator" + argspec: "args=[\'self\', \'generator\', \'steps\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'verbose\'], varargs=None, keywords=None, defaults=[\'None\', \'10\', \'1\', \'False\', \'0\'], " + } + member_method { + name: "fit" + argspec: "args=[\'self\', \'x\', \'y\', \'batch_size\', \'epochs\', \'verbose\', \'callbacks\', \'validation_split\', \'validation_data\', \'shuffle\', \'class_weight\', \'sample_weight\', \'initial_epoch\', \'steps_per_epoch\', \'validation_steps\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\', \'None\', \'1\', \'1\', \'None\', \'0.0\', \'None\', \'True\', \'None\', \'None\', \'0\', \'None\', \'None\'], " + } + member_method { + name: "fit_generator" + argspec: "args=[\'self\', \'generator\', \'steps_per_epoch\', \'epochs\', \'verbose\', \'callbacks\', \'validation_data\', \'validation_steps\', \'class_weight\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'shuffle\', \'initial_epoch\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'1\', \'None\', \'None\', \'None\', \'None\', \'10\', \'1\', \'False\', \'True\', \'0\'], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_layer" + argspec: "args=[\'self\', \'name\', \'index\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "load_weights" + argspec: "args=[\'self\', \'filepath\', \'by_name\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'x\', \'batch_size\', \'verbose\', \'steps\'], varargs=None, keywords=None, defaults=[\'None\', \'0\', \'None\'], " + } + member_method { + name: "predict_generator" + argspec: "args=[\'self\', \'generator\', \'steps\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'verbose\'], varargs=None, keywords=None, defaults=[\'None\', \'10\', \'1\', \'False\', \'0\'], " + } + member_method { + name: "predict_on_batch" + argspec: "args=[\'self\', \'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "reset_states" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "save" + argspec: "args=[\'self\', \'filepath\', \'overwrite\', \'include_optimizer\'], varargs=None, keywords=None, defaults=[\'True\', \'True\'], " + } + member_method { + name: "save_weights" + argspec: "args=[\'self\', \'filepath\', \'overwrite\', \'save_format\'], varargs=None, keywords=None, defaults=[\'True\', \'None\'], " + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "summary" + argspec: "args=[\'self\', \'line_length\', \'positions\', \'print_fn\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "test_on_batch" + argspec: "args=[\'self\', \'x\', \'y\', \'sample_weight\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "to_json" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "to_yaml" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "train_on_batch" + argspec: "args=[\'self\', \'x\', \'y\', \'sample_weight\', \'class_weight\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.-sequential.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.-sequential.pbtxt new file mode 100644 index 0000000000..65cfad77d1 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.-sequential.pbtxt @@ -0,0 +1,289 @@ +path: "tensorflow.keras.Sequential" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "input_spec" + mtype: "" + } + member { + name: "layers" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "state_updates" + mtype: "" + } + member { + name: "stateful" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "uses_learning_phase" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'layers\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "add" + argspec: "args=[\'self\', \'layer\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\', \'None\'], " + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'training\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "compile" + argspec: "args=[\'self\', \'optimizer\', \'loss\', \'metrics\', \'loss_weights\', \'sample_weight_mode\', \'weighted_metrics\', \'target_tensors\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "evaluate" + argspec: "args=[\'self\', \'x\', \'y\', \'batch_size\', \'verbose\', \'sample_weight\', \'steps\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'1\', \'None\', \'None\'], " + } + member_method { + name: "evaluate_generator" + argspec: "args=[\'self\', \'generator\', \'steps\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'verbose\'], varargs=None, keywords=None, defaults=[\'None\', \'10\', \'1\', \'False\', \'0\'], " + } + member_method { + name: "fit" + argspec: "args=[\'self\', \'x\', \'y\', \'batch_size\', \'epochs\', \'verbose\', \'callbacks\', \'validation_split\', \'validation_data\', \'shuffle\', \'class_weight\', \'sample_weight\', \'initial_epoch\', \'steps_per_epoch\', \'validation_steps\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\', \'None\', \'1\', \'1\', \'None\', \'0.0\', \'None\', \'True\', \'None\', \'None\', \'0\', \'None\', \'None\'], " + } + member_method { + name: "fit_generator" + argspec: "args=[\'self\', \'generator\', \'steps_per_epoch\', \'epochs\', \'verbose\', \'callbacks\', \'validation_data\', \'validation_steps\', \'class_weight\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'shuffle\', \'initial_epoch\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'1\', \'None\', \'None\', \'None\', \'None\', \'10\', \'1\', \'False\', \'True\', \'0\'], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_layer" + argspec: "args=[\'self\', \'name\', \'index\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "load_weights" + argspec: "args=[\'self\', \'filepath\', \'by_name\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "pop" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'x\', \'batch_size\', \'verbose\', \'steps\'], varargs=None, keywords=None, defaults=[\'None\', \'0\', \'None\'], " + } + member_method { + name: "predict_classes" + argspec: "args=[\'self\', \'x\', \'batch_size\', \'verbose\'], varargs=None, keywords=None, defaults=[\'32\', \'0\'], " + } + member_method { + name: "predict_generator" + argspec: "args=[\'self\', \'generator\', \'steps\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'verbose\'], varargs=None, keywords=None, defaults=[\'None\', \'10\', \'1\', \'False\', \'0\'], " + } + member_method { + name: "predict_on_batch" + argspec: "args=[\'self\', \'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "predict_proba" + argspec: "args=[\'self\', \'x\', \'batch_size\', \'verbose\'], varargs=None, keywords=None, defaults=[\'32\', \'0\'], " + } + member_method { + name: "reset_states" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "save" + argspec: "args=[\'self\', \'filepath\', \'overwrite\', \'include_optimizer\'], varargs=None, keywords=None, defaults=[\'True\', \'True\'], " + } + member_method { + name: "save_weights" + argspec: "args=[\'self\', \'filepath\', \'overwrite\', \'save_format\'], varargs=None, keywords=None, defaults=[\'True\', \'None\'], " + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "summary" + argspec: "args=[\'self\', \'line_length\', \'positions\', \'print_fn\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "symbolic_set_inputs" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "test_on_batch" + argspec: "args=[\'self\', \'x\', \'y\', \'sample_weight\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "to_json" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "to_yaml" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "train_on_batch" + argspec: "args=[\'self\', \'x\', \'y\', \'sample_weight\', \'class_weight\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.activations.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.activations.pbtxt new file mode 100644 index 0000000000..2cd83baf65 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.activations.pbtxt @@ -0,0 +1,55 @@ +path: "tensorflow.keras.activations" +tf_module { + member_method { + name: "deserialize" + argspec: "args=[\'name\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "elu" + argspec: "args=[\'x\', \'alpha\'], varargs=None, keywords=None, defaults=[\'1.0\'], " + } + member_method { + name: "get" + argspec: "args=[\'identifier\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "hard_sigmoid" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "linear" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "relu" + argspec: "args=[\'x\', \'alpha\', \'max_value\'], varargs=None, keywords=None, defaults=[\'0.0\', \'None\'], " + } + member_method { + name: "selu" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "serialize" + argspec: "args=[\'activation\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "sigmoid" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "softmax" + argspec: "args=[\'x\', \'axis\'], varargs=None, keywords=None, defaults=[\'-1\'], " + } + member_method { + name: "softplus" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "softsign" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "tanh" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.densenet.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.densenet.pbtxt new file mode 100644 index 0000000000..42cb914450 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.densenet.pbtxt @@ -0,0 +1,23 @@ +path: "tensorflow.keras.applications.densenet" +tf_module { + member_method { + name: "DenseNet121" + argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "DenseNet169" + argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "DenseNet201" + argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "decode_predictions" + argspec: "args=[\'preds\', \'top\'], varargs=None, keywords=None, defaults=[\'5\'], " + } + member_method { + name: "preprocess_input" + argspec: "args=[\'x\', \'data_format\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.inception_resnet_v2.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.inception_resnet_v2.pbtxt new file mode 100644 index 0000000000..211080c19b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.inception_resnet_v2.pbtxt @@ -0,0 +1,15 @@ +path: "tensorflow.keras.applications.inception_resnet_v2" +tf_module { + member_method { + name: "InceptionResNetV2" + argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "decode_predictions" + argspec: "args=[\'preds\', \'top\'], varargs=None, keywords=None, defaults=[\'5\'], " + } + member_method { + name: "preprocess_input" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.inception_v3.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.inception_v3.pbtxt new file mode 100644 index 0000000000..b67cee80ab --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.inception_v3.pbtxt @@ -0,0 +1,15 @@ +path: "tensorflow.keras.applications.inception_v3" +tf_module { + member_method { + name: "InceptionV3" + argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "decode_predictions" + argspec: "args=[\'preds\', \'top\'], varargs=None, keywords=None, defaults=[\'5\'], " + } + member_method { + name: "preprocess_input" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.mobilenet.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.mobilenet.pbtxt new file mode 100644 index 0000000000..ef774e1dd7 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.mobilenet.pbtxt @@ -0,0 +1,15 @@ +path: "tensorflow.keras.applications.mobilenet" +tf_module { + member_method { + name: "MobileNet" + argspec: "args=[\'input_shape\', \'alpha\', \'depth_multiplier\', \'dropout\', \'include_top\', \'weights\', \'input_tensor\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'None\', \'1.0\', \'1\', \'0.001\', \'True\', \'imagenet\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "decode_predictions" + argspec: "args=[\'preds\', \'top\'], varargs=None, keywords=None, defaults=[\'5\'], " + } + member_method { + name: "preprocess_input" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.nasnet.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.nasnet.pbtxt new file mode 100644 index 0000000000..cd75b87540 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.nasnet.pbtxt @@ -0,0 +1,19 @@ +path: "tensorflow.keras.applications.nasnet" +tf_module { + member_method { + name: "NASNetLarge" + argspec: "args=[\'input_shape\', \'include_top\', \'weights\', \'input_tensor\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'None\', \'True\', \'imagenet\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "NASNetMobile" + argspec: "args=[\'input_shape\', \'include_top\', \'weights\', \'input_tensor\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'None\', \'True\', \'imagenet\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "decode_predictions" + argspec: "args=[\'preds\', \'top\'], varargs=None, keywords=None, defaults=[\'5\'], " + } + member_method { + name: "preprocess_input" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.pbtxt new file mode 100644 index 0000000000..9fc086eb8e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.pbtxt @@ -0,0 +1,87 @@ +path: "tensorflow.keras.applications" +tf_module { + member { + name: "densenet" + mtype: "" + } + member { + name: "inception_resnet_v2" + mtype: "" + } + member { + name: "inception_v3" + mtype: "" + } + member { + name: "mobilenet" + mtype: "" + } + member { + name: "nasnet" + mtype: "" + } + member { + name: "resnet50" + mtype: "" + } + member { + name: "vgg16" + mtype: "" + } + member { + name: "vgg19" + mtype: "" + } + member { + name: "xception" + mtype: "" + } + member_method { + name: "DenseNet121" + argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "DenseNet169" + argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "DenseNet201" + argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "InceptionResNetV2" + argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "InceptionV3" + argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "MobileNet" + argspec: "args=[\'input_shape\', \'alpha\', \'depth_multiplier\', \'dropout\', \'include_top\', \'weights\', \'input_tensor\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'None\', \'1.0\', \'1\', \'0.001\', \'True\', \'imagenet\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "NASNetLarge" + argspec: "args=[\'input_shape\', \'include_top\', \'weights\', \'input_tensor\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'None\', \'True\', \'imagenet\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "NASNetMobile" + argspec: "args=[\'input_shape\', \'include_top\', \'weights\', \'input_tensor\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'None\', \'True\', \'imagenet\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "ResNet50" + argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "VGG16" + argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "VGG19" + argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "Xception" + argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.resnet50.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.resnet50.pbtxt new file mode 100644 index 0000000000..7385af064d --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.resnet50.pbtxt @@ -0,0 +1,15 @@ +path: "tensorflow.keras.applications.resnet50" +tf_module { + member_method { + name: "ResNet50" + argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "decode_predictions" + argspec: "args=[\'preds\', \'top\'], varargs=None, keywords=None, defaults=[\'5\'], " + } + member_method { + name: "preprocess_input" + argspec: "args=[\'x\', \'data_format\', \'mode\'], varargs=None, keywords=None, defaults=[\'None\', \'caffe\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.vgg16.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.vgg16.pbtxt new file mode 100644 index 0000000000..ba66fba8f3 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.vgg16.pbtxt @@ -0,0 +1,15 @@ +path: "tensorflow.keras.applications.vgg16" +tf_module { + member_method { + name: "VGG16" + argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "decode_predictions" + argspec: "args=[\'preds\', \'top\'], varargs=None, keywords=None, defaults=[\'5\'], " + } + member_method { + name: "preprocess_input" + argspec: "args=[\'x\', \'data_format\', \'mode\'], varargs=None, keywords=None, defaults=[\'None\', \'caffe\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.vgg19.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.vgg19.pbtxt new file mode 100644 index 0000000000..e55a1345b6 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.vgg19.pbtxt @@ -0,0 +1,15 @@ +path: "tensorflow.keras.applications.vgg19" +tf_module { + member_method { + name: "VGG19" + argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "decode_predictions" + argspec: "args=[\'preds\', \'top\'], varargs=None, keywords=None, defaults=[\'5\'], " + } + member_method { + name: "preprocess_input" + argspec: "args=[\'x\', \'data_format\', \'mode\'], varargs=None, keywords=None, defaults=[\'None\', \'caffe\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.xception.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.xception.pbtxt new file mode 100644 index 0000000000..59dd2108f2 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.applications.xception.pbtxt @@ -0,0 +1,15 @@ +path: "tensorflow.keras.applications.xception" +tf_module { + member_method { + name: "Xception" + argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " + } + member_method { + name: "decode_predictions" + argspec: "args=[\'preds\', \'top\'], varargs=None, keywords=None, defaults=[\'5\'], " + } + member_method { + name: "preprocess_input" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.backend.name_scope.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.backend.name_scope.pbtxt new file mode 100644 index 0000000000..a2b98b1c27 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.backend.name_scope.pbtxt @@ -0,0 +1,13 @@ +path: "tensorflow.keras.backend.name_scope" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "name" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'name\', \'default_name\', \'values\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.backend.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.backend.pbtxt new file mode 100644 index 0000000000..fddac63b78 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.backend.pbtxt @@ -0,0 +1,555 @@ +path: "tensorflow.keras.backend" +tf_module { + member { + name: "name_scope" + mtype: "" + } + member_method { + name: "abs" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "all" + argspec: "args=[\'x\', \'axis\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'False\'], " + } + member_method { + name: "any" + argspec: "args=[\'x\', \'axis\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'False\'], " + } + member_method { + name: "arange" + argspec: "args=[\'start\', \'stop\', \'step\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'int32\'], " + } + member_method { + name: "argmax" + argspec: "args=[\'x\', \'axis\'], varargs=None, keywords=None, defaults=[\'-1\'], " + } + member_method { + name: "argmin" + argspec: "args=[\'x\', \'axis\'], varargs=None, keywords=None, defaults=[\'-1\'], " + } + member_method { + name: "backend" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "batch_dot" + argspec: "args=[\'x\', \'y\', \'axes\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "batch_flatten" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "batch_get_value" + argspec: "args=[\'tensors\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "batch_normalization" + argspec: "args=[\'x\', \'mean\', \'var\', \'beta\', \'gamma\', \'epsilon\'], varargs=None, keywords=None, defaults=[\'0.001\'], " + } + member_method { + name: "batch_set_value" + argspec: "args=[\'tuples\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "bias_add" + argspec: "args=[\'x\', \'bias\', \'data_format\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "binary_crossentropy" + argspec: "args=[\'target\', \'output\', \'from_logits\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "cast" + argspec: "args=[\'x\', \'dtype\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "cast_to_floatx" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "categorical_crossentropy" + argspec: "args=[\'target\', \'output\', \'from_logits\', \'axis\'], varargs=None, keywords=None, defaults=[\'False\', \'-1\'], " + } + member_method { + name: "clear_session" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "clip" + argspec: "args=[\'x\', \'min_value\', \'max_value\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "concatenate" + argspec: "args=[\'tensors\', \'axis\'], varargs=None, keywords=None, defaults=[\'-1\'], " + } + member_method { + name: "constant" + argspec: "args=[\'value\', \'dtype\', \'shape\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "conv1d" + argspec: "args=[\'x\', \'kernel\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\'], varargs=None, keywords=None, defaults=[\'1\', \'valid\', \'None\', \'1\'], " + } + member_method { + name: "conv2d" + argspec: "args=[\'x\', \'kernel\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\'], varargs=None, keywords=None, defaults=[\'(1, 1)\', \'valid\', \'None\', \'(1, 1)\'], " + } + member_method { + name: "conv2d_transpose" + argspec: "args=[\'x\', \'kernel\', \'output_shape\', \'strides\', \'padding\', \'data_format\'], varargs=None, keywords=None, defaults=[\'(1, 1)\', \'valid\', \'None\'], " + } + member_method { + name: "conv3d" + argspec: "args=[\'x\', \'kernel\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\'], varargs=None, keywords=None, defaults=[\'(1, 1, 1)\', \'valid\', \'None\', \'(1, 1, 1)\'], " + } + member_method { + name: "cos" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "ctc_batch_cost" + argspec: "args=[\'y_true\', \'y_pred\', \'input_length\', \'label_length\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "ctc_decode" + argspec: "args=[\'y_pred\', \'input_length\', \'greedy\', \'beam_width\', \'top_paths\'], varargs=None, keywords=None, defaults=[\'True\', \'100\', \'1\'], " + } + member_method { + name: "ctc_label_dense_to_sparse" + argspec: "args=[\'labels\', \'label_lengths\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "dot" + argspec: "args=[\'x\', \'y\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "dropout" + argspec: "args=[\'x\', \'level\', \'noise_shape\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "dtype" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "elu" + argspec: "args=[\'x\', \'alpha\'], varargs=None, keywords=None, defaults=[\'1.0\'], " + } + member_method { + name: "epsilon" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "equal" + argspec: "args=[\'x\', \'y\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "eval" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "exp" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "expand_dims" + argspec: "args=[\'x\', \'axis\'], varargs=None, keywords=None, defaults=[\'-1\'], " + } + member_method { + name: "eye" + argspec: "args=[\'size\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "flatten" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "floatx" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "foldl" + argspec: "args=[\'fn\', \'elems\', \'initializer\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "foldr" + argspec: "args=[\'fn\', \'elems\', \'initializer\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "function" + argspec: "args=[\'inputs\', \'outputs\', \'updates\'], varargs=None, keywords=kwargs, defaults=[\'None\'], " + } + member_method { + name: "gather" + argspec: "args=[\'reference\', \'indices\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_session" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_uid" + argspec: "args=[\'prefix\'], varargs=None, keywords=None, defaults=[\'\'], " + } + member_method { + name: "get_value" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "gradients" + argspec: "args=[\'loss\', \'variables\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "greater" + argspec: "args=[\'x\', \'y\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "greater_equal" + argspec: "args=[\'x\', \'y\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "hard_sigmoid" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "image_data_format" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "in_test_phase" + argspec: "args=[\'x\', \'alt\', \'training\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "in_top_k" + argspec: "args=[\'predictions\', \'targets\', \'k\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "in_train_phase" + argspec: "args=[\'x\', \'alt\', \'training\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "int_shape" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "is_sparse" + argspec: "args=[\'tensor\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "l2_normalize" + argspec: "args=[\'x\', \'axis\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "learning_phase" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "less" + argspec: "args=[\'x\', \'y\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "less_equal" + argspec: "args=[\'x\', \'y\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "log" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "manual_variable_initialization" + argspec: "args=[\'value\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "map_fn" + argspec: "args=[\'fn\', \'elems\', \'name\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "max" + argspec: "args=[\'x\', \'axis\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'False\'], " + } + member_method { + name: "maximum" + argspec: "args=[\'x\', \'y\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "mean" + argspec: "args=[\'x\', \'axis\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'False\'], " + } + member_method { + name: "min" + argspec: "args=[\'x\', \'axis\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'False\'], " + } + member_method { + name: "minimum" + argspec: "args=[\'x\', \'y\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "moving_average_update" + argspec: "args=[\'x\', \'value\', \'momentum\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "ndim" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "normalize_batch_in_training" + argspec: "args=[\'x\', \'gamma\', \'beta\', \'reduction_axes\', \'epsilon\'], varargs=None, keywords=None, defaults=[\'0.001\'], " + } + member_method { + name: "not_equal" + argspec: "args=[\'x\', \'y\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "one_hot" + argspec: "args=[\'indices\', \'num_classes\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "ones" + argspec: "args=[\'shape\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "ones_like" + argspec: "args=[\'x\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "permute_dimensions" + argspec: "args=[\'x\', \'pattern\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "placeholder" + argspec: "args=[\'shape\', \'ndim\', \'dtype\', \'sparse\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'False\', \'None\'], " + } + member_method { + name: "pool2d" + argspec: "args=[\'x\', \'pool_size\', \'strides\', \'padding\', \'data_format\', \'pool_mode\'], varargs=None, keywords=None, defaults=[\'(1, 1)\', \'valid\', \'None\', \'max\'], " + } + member_method { + name: "pool3d" + argspec: "args=[\'x\', \'pool_size\', \'strides\', \'padding\', \'data_format\', \'pool_mode\'], varargs=None, keywords=None, defaults=[\'(1, 1, 1)\', \'valid\', \'None\', \'max\'], " + } + member_method { + name: "pow" + argspec: "args=[\'x\', \'a\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "print_tensor" + argspec: "args=[\'x\', \'message\'], varargs=None, keywords=None, defaults=[\'\'], " + } + member_method { + name: "prod" + argspec: "args=[\'x\', \'axis\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'False\'], " + } + member_method { + name: "random_binomial" + argspec: "args=[\'shape\', \'p\', \'dtype\', \'seed\'], varargs=None, keywords=None, defaults=[\'0.0\', \'None\', \'None\'], " + } + member_method { + name: "random_normal" + argspec: "args=[\'shape\', \'mean\', \'stddev\', \'dtype\', \'seed\'], varargs=None, keywords=None, defaults=[\'0.0\', \'1.0\', \'None\', \'None\'], " + } + member_method { + name: "random_normal_variable" + argspec: "args=[\'shape\', \'mean\', \'scale\', \'dtype\', \'name\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "random_uniform" + argspec: "args=[\'shape\', \'minval\', \'maxval\', \'dtype\', \'seed\'], varargs=None, keywords=None, defaults=[\'0.0\', \'1.0\', \'None\', \'None\'], " + } + member_method { + name: "random_uniform_variable" + argspec: "args=[\'shape\', \'low\', \'high\', \'dtype\', \'name\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "relu" + argspec: "args=[\'x\', \'alpha\', \'max_value\'], varargs=None, keywords=None, defaults=[\'0.0\', \'None\'], " + } + member_method { + name: "repeat" + argspec: "args=[\'x\', \'n\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "repeat_elements" + argspec: "args=[\'x\', \'rep\', \'axis\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "reset_uids" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "reshape" + argspec: "args=[\'x\', \'shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "resize_images" + argspec: "args=[\'x\', \'height_factor\', \'width_factor\', \'data_format\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "resize_volumes" + argspec: "args=[\'x\', \'depth_factor\', \'height_factor\', \'width_factor\', \'data_format\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "reverse" + argspec: "args=[\'x\', \'axes\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "rnn" + argspec: "args=[\'step_function\', \'inputs\', \'initial_states\', \'go_backwards\', \'mask\', \'constants\', \'unroll\', \'input_length\'], varargs=None, keywords=None, defaults=[\'False\', \'None\', \'None\', \'False\', \'None\'], " + } + member_method { + name: "round" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "separable_conv2d" + argspec: "args=[\'x\', \'depthwise_kernel\', \'pointwise_kernel\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\'], varargs=None, keywords=None, defaults=[\'(1, 1)\', \'valid\', \'None\', \'(1, 1)\'], " + } + member_method { + name: "set_epsilon" + argspec: "args=[\'value\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_floatx" + argspec: "args=[\'value\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_image_data_format" + argspec: "args=[\'data_format\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_learning_phase" + argspec: "args=[\'value\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_session" + argspec: "args=[\'session\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_value" + argspec: "args=[\'x\', \'value\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "shape" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "sigmoid" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "sign" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "sin" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "softmax" + argspec: "args=[\'x\', \'axis\'], varargs=None, keywords=None, defaults=[\'-1\'], " + } + member_method { + name: "softplus" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "softsign" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "sparse_categorical_crossentropy" + argspec: "args=[\'target\', \'output\', \'from_logits\', \'axis\'], varargs=None, keywords=None, defaults=[\'False\', \'-1\'], " + } + member_method { + name: "spatial_2d_padding" + argspec: "args=[\'x\', \'padding\', \'data_format\'], varargs=None, keywords=None, defaults=[\'((1, 1), (1, 1))\', \'None\'], " + } + member_method { + name: "spatial_3d_padding" + argspec: "args=[\'x\', \'padding\', \'data_format\'], varargs=None, keywords=None, defaults=[\'((1, 1), (1, 1), (1, 1))\', \'None\'], " + } + member_method { + name: "sqrt" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "square" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "squeeze" + argspec: "args=[\'x\', \'axis\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "stack" + argspec: "args=[\'x\', \'axis\'], varargs=None, keywords=None, defaults=[\'0\'], " + } + member_method { + name: "std" + argspec: "args=[\'x\', \'axis\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'False\'], " + } + member_method { + name: "stop_gradient" + argspec: "args=[\'variables\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "sum" + argspec: "args=[\'x\', \'axis\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'False\'], " + } + member_method { + name: "switch" + argspec: "args=[\'condition\', \'then_expression\', \'else_expression\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "tanh" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "temporal_padding" + argspec: "args=[\'x\', \'padding\'], varargs=None, keywords=None, defaults=[\'(1, 1)\'], " + } + member_method { + name: "to_dense" + argspec: "args=[\'tensor\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "transpose" + argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "truncated_normal" + argspec: "args=[\'shape\', \'mean\', \'stddev\', \'dtype\', \'seed\'], varargs=None, keywords=None, defaults=[\'0.0\', \'1.0\', \'None\', \'None\'], " + } + member_method { + name: "update" + argspec: "args=[\'x\', \'new_x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "update_add" + argspec: "args=[\'x\', \'increment\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "update_sub" + argspec: "args=[\'x\', \'decrement\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "var" + argspec: "args=[\'x\', \'axis\', \'keepdims\'], varargs=None, keywords=None, defaults=[\'None\', \'False\'], " + } + member_method { + name: "variable" + argspec: "args=[\'value\', \'dtype\', \'name\', \'constraint\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "zeros" + argspec: "args=[\'shape\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "zeros_like" + argspec: "args=[\'x\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-base-logger.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-base-logger.pbtxt new file mode 100644 index 0000000000..9eee9b3789 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-base-logger.pbtxt @@ -0,0 +1,42 @@ +path: "tensorflow.keras.callbacks.BaseLogger" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'stateful_metrics\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_batch_begin" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_batch_end" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_begin" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_end" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_begin" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_end" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_model" + argspec: "args=[\'self\', \'model\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_params" + argspec: "args=[\'self\', \'params\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-c-s-v-logger.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-c-s-v-logger.pbtxt new file mode 100644 index 0000000000..5bb949c5bb --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-c-s-v-logger.pbtxt @@ -0,0 +1,42 @@ +path: "tensorflow.keras.callbacks.CSVLogger" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filename\', \'separator\', \'append\'], varargs=None, keywords=None, defaults=[\',\', \'False\'], " + } + member_method { + name: "on_batch_begin" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_batch_end" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_begin" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_end" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_begin" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_end" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_model" + argspec: "args=[\'self\', \'model\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_params" + argspec: "args=[\'self\', \'params\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-callback.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-callback.pbtxt new file mode 100644 index 0000000000..a5340d52c1 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-callback.pbtxt @@ -0,0 +1,41 @@ +path: "tensorflow.keras.callbacks.Callback" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "on_batch_begin" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_batch_end" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_begin" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_end" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_begin" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_end" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_model" + argspec: "args=[\'self\', \'model\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_params" + argspec: "args=[\'self\', \'params\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-early-stopping.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-early-stopping.pbtxt new file mode 100644 index 0000000000..f71292856c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-early-stopping.pbtxt @@ -0,0 +1,42 @@ +path: "tensorflow.keras.callbacks.EarlyStopping" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'monitor\', \'min_delta\', \'patience\', \'verbose\', \'mode\', \'baseline\'], varargs=None, keywords=None, defaults=[\'val_loss\', \'0\', \'0\', \'0\', \'auto\', \'None\'], " + } + member_method { + name: "on_batch_begin" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_batch_end" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_begin" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_end" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_begin" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_end" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_model" + argspec: "args=[\'self\', \'model\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_params" + argspec: "args=[\'self\', \'params\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-history.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-history.pbtxt new file mode 100644 index 0000000000..ee400b31c4 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-history.pbtxt @@ -0,0 +1,42 @@ +path: "tensorflow.keras.callbacks.History" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "on_batch_begin" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_batch_end" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_begin" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_end" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_begin" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_end" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_model" + argspec: "args=[\'self\', \'model\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_params" + argspec: "args=[\'self\', \'params\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-lambda-callback.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-lambda-callback.pbtxt new file mode 100644 index 0000000000..df8d7b0ef7 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-lambda-callback.pbtxt @@ -0,0 +1,42 @@ +path: "tensorflow.keras.callbacks.LambdaCallback" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'on_epoch_begin\', \'on_epoch_end\', \'on_batch_begin\', \'on_batch_end\', \'on_train_begin\', \'on_train_end\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "on_batch_begin" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_batch_end" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_begin" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_end" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_begin" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_end" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_model" + argspec: "args=[\'self\', \'model\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_params" + argspec: "args=[\'self\', \'params\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-learning-rate-scheduler.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-learning-rate-scheduler.pbtxt new file mode 100644 index 0000000000..ce1a9b694d --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-learning-rate-scheduler.pbtxt @@ -0,0 +1,42 @@ +path: "tensorflow.keras.callbacks.LearningRateScheduler" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'schedule\', \'verbose\'], varargs=None, keywords=None, defaults=[\'0\'], " + } + member_method { + name: "on_batch_begin" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_batch_end" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_begin" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_end" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_begin" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_end" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_model" + argspec: "args=[\'self\', \'model\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_params" + argspec: "args=[\'self\', \'params\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-model-checkpoint.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-model-checkpoint.pbtxt new file mode 100644 index 0000000000..48bb24a052 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-model-checkpoint.pbtxt @@ -0,0 +1,42 @@ +path: "tensorflow.keras.callbacks.ModelCheckpoint" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filepath\', \'monitor\', \'verbose\', \'save_best_only\', \'save_weights_only\', \'mode\', \'period\'], varargs=None, keywords=None, defaults=[\'val_loss\', \'0\', \'False\', \'False\', \'auto\', \'1\'], " + } + member_method { + name: "on_batch_begin" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_batch_end" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_begin" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_end" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_begin" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_end" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_model" + argspec: "args=[\'self\', \'model\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_params" + argspec: "args=[\'self\', \'params\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-progbar-logger.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-progbar-logger.pbtxt new file mode 100644 index 0000000000..d8bb8b2a7d --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-progbar-logger.pbtxt @@ -0,0 +1,42 @@ +path: "tensorflow.keras.callbacks.ProgbarLogger" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'count_mode\', \'stateful_metrics\'], varargs=None, keywords=None, defaults=[\'samples\', \'None\'], " + } + member_method { + name: "on_batch_begin" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_batch_end" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_begin" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_end" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_begin" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_end" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_model" + argspec: "args=[\'self\', \'model\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_params" + argspec: "args=[\'self\', \'params\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-reduce-l-r-on-plateau.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-reduce-l-r-on-plateau.pbtxt new file mode 100644 index 0000000000..dc27af9552 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-reduce-l-r-on-plateau.pbtxt @@ -0,0 +1,46 @@ +path: "tensorflow.keras.callbacks.ReduceLROnPlateau" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'monitor\', \'factor\', \'patience\', \'verbose\', \'mode\', \'min_delta\', \'cooldown\', \'min_lr\'], varargs=None, keywords=kwargs, defaults=[\'val_loss\', \'0.1\', \'10\', \'0\', \'auto\', \'0.0001\', \'0\', \'0\'], " + } + member_method { + name: "in_cooldown" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "on_batch_begin" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_batch_end" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_begin" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_end" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_begin" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_end" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_model" + argspec: "args=[\'self\', \'model\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_params" + argspec: "args=[\'self\', \'params\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-remote-monitor.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-remote-monitor.pbtxt new file mode 100644 index 0000000000..5a3b791c0a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-remote-monitor.pbtxt @@ -0,0 +1,42 @@ +path: "tensorflow.keras.callbacks.RemoteMonitor" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'root\', \'path\', \'field\', \'headers\', \'send_as_json\'], varargs=None, keywords=None, defaults=[\'http://localhost:9000\', \'/publish/epoch/end/\', \'data\', \'None\', \'False\'], " + } + member_method { + name: "on_batch_begin" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_batch_end" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_begin" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_end" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_begin" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_end" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_model" + argspec: "args=[\'self\', \'model\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_params" + argspec: "args=[\'self\', \'params\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-tensor-board.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-tensor-board.pbtxt new file mode 100644 index 0000000000..e58ba18c1c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-tensor-board.pbtxt @@ -0,0 +1,42 @@ +path: "tensorflow.keras.callbacks.TensorBoard" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'log_dir\', \'histogram_freq\', \'batch_size\', \'write_graph\', \'write_grads\', \'write_images\', \'embeddings_freq\', \'embeddings_layer_names\', \'embeddings_metadata\', \'embeddings_data\'], varargs=None, keywords=None, defaults=[\'./logs\', \'0\', \'32\', \'True\', \'False\', \'False\', \'0\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "on_batch_begin" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_batch_end" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_begin" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_end" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_begin" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_end" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_model" + argspec: "args=[\'self\', \'model\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_params" + argspec: "args=[\'self\', \'params\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-terminate-on-na-n.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-terminate-on-na-n.pbtxt new file mode 100644 index 0000000000..5c2d336353 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.-terminate-on-na-n.pbtxt @@ -0,0 +1,42 @@ +path: "tensorflow.keras.callbacks.TerminateOnNaN" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "on_batch_begin" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_batch_end" + argspec: "args=[\'self\', \'batch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_begin" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_epoch_end" + argspec: "args=[\'self\', \'epoch\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_begin" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "on_train_end" + argspec: "args=[\'self\', \'logs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_model" + argspec: "args=[\'self\', \'model\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_params" + argspec: "args=[\'self\', \'params\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.pbtxt new file mode 100644 index 0000000000..1e9085e034 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.callbacks.pbtxt @@ -0,0 +1,55 @@ +path: "tensorflow.keras.callbacks" +tf_module { + member { + name: "BaseLogger" + mtype: "" + } + member { + name: "CSVLogger" + mtype: "" + } + member { + name: "Callback" + mtype: "" + } + member { + name: "EarlyStopping" + mtype: "" + } + member { + name: "History" + mtype: "" + } + member { + name: "LambdaCallback" + mtype: "" + } + member { + name: "LearningRateScheduler" + mtype: "" + } + member { + name: "ModelCheckpoint" + mtype: "" + } + member { + name: "ProgbarLogger" + mtype: "" + } + member { + name: "ReduceLROnPlateau" + mtype: "" + } + member { + name: "RemoteMonitor" + mtype: "" + } + member { + name: "TensorBoard" + mtype: "" + } + member { + name: "TerminateOnNaN" + mtype: "" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.-constraint.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.-constraint.pbtxt new file mode 100644 index 0000000000..8e07b7d98e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.-constraint.pbtxt @@ -0,0 +1,12 @@ +path: "tensorflow.keras.constraints.Constraint" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.-max-norm.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.-max-norm.pbtxt new file mode 100644 index 0000000000..2b81174b6c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.-max-norm.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.keras.constraints.MaxNorm" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'max_value\', \'axis\'], varargs=None, keywords=None, defaults=[\'2\', \'0\'], " + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.-min-max-norm.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.-min-max-norm.pbtxt new file mode 100644 index 0000000000..a41eda86ac --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.-min-max-norm.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.keras.constraints.MinMaxNorm" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'min_value\', \'max_value\', \'rate\', \'axis\'], varargs=None, keywords=None, defaults=[\'0.0\', \'1.0\', \'1.0\', \'0\'], " + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.-non-neg.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.-non-neg.pbtxt new file mode 100644 index 0000000000..572e3eea4d --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.-non-neg.pbtxt @@ -0,0 +1,13 @@ +path: "tensorflow.keras.constraints.NonNeg" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.-unit-norm.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.-unit-norm.pbtxt new file mode 100644 index 0000000000..fe16c38cc8 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.-unit-norm.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.keras.constraints.UnitNorm" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'axis\'], varargs=None, keywords=None, defaults=[\'0\'], " + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.max_norm.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.max_norm.pbtxt new file mode 100644 index 0000000000..6650bae07a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.max_norm.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.keras.constraints.max_norm" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'max_value\', \'axis\'], varargs=None, keywords=None, defaults=[\'2\', \'0\'], " + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.min_max_norm.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.min_max_norm.pbtxt new file mode 100644 index 0000000000..9dd3bc92fc --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.min_max_norm.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.keras.constraints.min_max_norm" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'min_value\', \'max_value\', \'rate\', \'axis\'], varargs=None, keywords=None, defaults=[\'0.0\', \'1.0\', \'1.0\', \'0\'], " + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.non_neg.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.non_neg.pbtxt new file mode 100644 index 0000000000..a565840939 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.non_neg.pbtxt @@ -0,0 +1,13 @@ +path: "tensorflow.keras.constraints.non_neg" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.pbtxt new file mode 100644 index 0000000000..655685956f --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.pbtxt @@ -0,0 +1,51 @@ +path: "tensorflow.keras.constraints" +tf_module { + member { + name: "Constraint" + mtype: "" + } + member { + name: "MaxNorm" + mtype: "" + } + member { + name: "MinMaxNorm" + mtype: "" + } + member { + name: "NonNeg" + mtype: "" + } + member { + name: "UnitNorm" + mtype: "" + } + member { + name: "max_norm" + mtype: "" + } + member { + name: "min_max_norm" + mtype: "" + } + member { + name: "non_neg" + mtype: "" + } + member { + name: "unit_norm" + mtype: "" + } + member_method { + name: "deserialize" + argspec: "args=[\'config\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get" + argspec: "args=[\'identifier\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "serialize" + argspec: "args=[\'constraint\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.unit_norm.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.unit_norm.pbtxt new file mode 100644 index 0000000000..5cbe0da4c1 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.constraints.unit_norm.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.keras.constraints.unit_norm" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'axis\'], varargs=None, keywords=None, defaults=[\'0\'], " + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.boston_housing.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.boston_housing.pbtxt new file mode 100644 index 0000000000..bda31751d4 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.boston_housing.pbtxt @@ -0,0 +1,7 @@ +path: "tensorflow.keras.datasets.boston_housing" +tf_module { + member_method { + name: "load_data" + argspec: "args=[\'path\', \'test_split\', \'seed\'], varargs=None, keywords=None, defaults=[\'boston_housing.npz\', \'0.2\', \'113\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.cifar10.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.cifar10.pbtxt new file mode 100644 index 0000000000..8a5142f793 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.cifar10.pbtxt @@ -0,0 +1,7 @@ +path: "tensorflow.keras.datasets.cifar10" +tf_module { + member_method { + name: "load_data" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.cifar100.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.cifar100.pbtxt new file mode 100644 index 0000000000..16f184eeb5 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.cifar100.pbtxt @@ -0,0 +1,7 @@ +path: "tensorflow.keras.datasets.cifar100" +tf_module { + member_method { + name: "load_data" + argspec: "args=[\'label_mode\'], varargs=None, keywords=None, defaults=[\'fine\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.fashion_mnist.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.fashion_mnist.pbtxt new file mode 100644 index 0000000000..a0e14356fa --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.fashion_mnist.pbtxt @@ -0,0 +1,7 @@ +path: "tensorflow.keras.datasets.fashion_mnist" +tf_module { + member_method { + name: "load_data" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.imdb.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.imdb.pbtxt new file mode 100644 index 0000000000..ff962876b6 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.imdb.pbtxt @@ -0,0 +1,11 @@ +path: "tensorflow.keras.datasets.imdb" +tf_module { + member_method { + name: "get_word_index" + argspec: "args=[\'path\'], varargs=None, keywords=None, defaults=[\'imdb_word_index.json\'], " + } + member_method { + name: "load_data" + argspec: "args=[\'path\', \'num_words\', \'skip_top\', \'maxlen\', \'seed\', \'start_char\', \'oov_char\', \'index_from\'], varargs=None, keywords=kwargs, defaults=[\'imdb.npz\', \'None\', \'0\', \'None\', \'113\', \'1\', \'2\', \'3\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.mnist.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.mnist.pbtxt new file mode 100644 index 0000000000..530bb07550 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.mnist.pbtxt @@ -0,0 +1,7 @@ +path: "tensorflow.keras.datasets.mnist" +tf_module { + member_method { + name: "load_data" + argspec: "args=[\'path\'], varargs=None, keywords=None, defaults=[\'mnist.npz\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.pbtxt new file mode 100644 index 0000000000..36e3aafbe4 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.pbtxt @@ -0,0 +1,31 @@ +path: "tensorflow.keras.datasets" +tf_module { + member { + name: "boston_housing" + mtype: "" + } + member { + name: "cifar10" + mtype: "" + } + member { + name: "cifar100" + mtype: "" + } + member { + name: "fashion_mnist" + mtype: "" + } + member { + name: "imdb" + mtype: "" + } + member { + name: "mnist" + mtype: "" + } + member { + name: "reuters" + mtype: "" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.reuters.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.reuters.pbtxt new file mode 100644 index 0000000000..2da4a13067 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.datasets.reuters.pbtxt @@ -0,0 +1,11 @@ +path: "tensorflow.keras.datasets.reuters" +tf_module { + member_method { + name: "get_word_index" + argspec: "args=[\'path\'], varargs=None, keywords=None, defaults=[\'reuters_word_index.json\'], " + } + member_method { + name: "load_data" + argspec: "args=[\'path\', \'num_words\', \'skip_top\', \'maxlen\', \'test_split\', \'seed\', \'start_char\', \'oov_char\', \'index_from\'], varargs=None, keywords=kwargs, defaults=[\'reuters.npz\', \'None\', \'0\', \'None\', \'0.2\', \'113\', \'1\', \'2\', \'3\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.estimator.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.estimator.pbtxt new file mode 100644 index 0000000000..7a3fb39f77 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.estimator.pbtxt @@ -0,0 +1,7 @@ +path: "tensorflow.keras.estimator" +tf_module { + member_method { + name: "model_to_estimator" + argspec: "args=[\'keras_model\', \'keras_model_path\', \'custom_objects\', \'model_dir\', \'config\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-constant.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-constant.pbtxt new file mode 100644 index 0000000000..cbaba78ed5 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-constant.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.keras.initializers.Constant" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'value\', \'dtype\', \'verify_shape\'], varargs=None, keywords=None, defaults=[\'0\', \"\", \'False\'], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-identity.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-identity.pbtxt new file mode 100644 index 0000000000..a5f7f348de --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-identity.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.keras.initializers.Identity" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'gain\', \'dtype\'], varargs=None, keywords=None, defaults=[\'1.0\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-initializer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-initializer.pbtxt new file mode 100644 index 0000000000..8f10d1698e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-initializer.pbtxt @@ -0,0 +1,16 @@ +path: "tensorflow.keras.initializers.Initializer" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-ones.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-ones.pbtxt new file mode 100644 index 0000000000..2fbfa774f8 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-ones.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.keras.initializers.Ones" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'dtype\'], varargs=None, keywords=None, defaults=[\"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-orthogonal.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-orthogonal.pbtxt new file mode 100644 index 0000000000..874d320d73 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-orthogonal.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.keras.initializers.Orthogonal" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'gain\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'1.0\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-random-normal.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-random-normal.pbtxt new file mode 100644 index 0000000000..23cd02c0b0 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-random-normal.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.keras.initializers.RandomNormal" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'mean\', \'stddev\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'0.0\', \'1.0\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-random-uniform.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-random-uniform.pbtxt new file mode 100644 index 0000000000..d98628f422 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-random-uniform.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.keras.initializers.RandomUniform" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'minval\', \'maxval\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'0\', \'None\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-truncated-normal.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-truncated-normal.pbtxt new file mode 100644 index 0000000000..86d48257c1 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-truncated-normal.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.keras.initializers.TruncatedNormal" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'mean\', \'stddev\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'0.0\', \'1.0\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-variance-scaling.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-variance-scaling.pbtxt new file mode 100644 index 0000000000..03f4064b9e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-variance-scaling.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.keras.initializers.VarianceScaling" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'scale\', \'mode\', \'distribution\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'1.0\', \'fan_in\', \'truncated_normal\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-zeros.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-zeros.pbtxt new file mode 100644 index 0000000000..b6ab68e5be --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.-zeros.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.keras.initializers.Zeros" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'dtype\'], varargs=None, keywords=None, defaults=[\"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.constant.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.constant.pbtxt new file mode 100644 index 0000000000..bddc37b907 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.constant.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.keras.initializers.constant" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'value\', \'dtype\', \'verify_shape\'], varargs=None, keywords=None, defaults=[\'0\', \"\", \'False\'], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.identity.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.identity.pbtxt new file mode 100644 index 0000000000..a4c5a61490 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.identity.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.keras.initializers.identity" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'gain\', \'dtype\'], varargs=None, keywords=None, defaults=[\'1.0\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.normal.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.normal.pbtxt new file mode 100644 index 0000000000..7485772784 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.normal.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.keras.initializers.normal" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'mean\', \'stddev\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'0.0\', \'1.0\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.ones.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.ones.pbtxt new file mode 100644 index 0000000000..a89f78d1e1 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.ones.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.keras.initializers.ones" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'dtype\'], varargs=None, keywords=None, defaults=[\"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.orthogonal.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.orthogonal.pbtxt new file mode 100644 index 0000000000..ee1e9bbae2 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.orthogonal.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.keras.initializers.orthogonal" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'gain\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'1.0\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.pbtxt new file mode 100644 index 0000000000..8645e54302 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.pbtxt @@ -0,0 +1,119 @@ +path: "tensorflow.keras.initializers" +tf_module { + member { + name: "Constant" + mtype: "" + } + member { + name: "Identity" + mtype: "" + } + member { + name: "Initializer" + mtype: "" + } + member { + name: "Ones" + mtype: "" + } + member { + name: "Orthogonal" + mtype: "" + } + member { + name: "RandomNormal" + mtype: "" + } + member { + name: "RandomUniform" + mtype: "" + } + member { + name: "TruncatedNormal" + mtype: "" + } + member { + name: "VarianceScaling" + mtype: "" + } + member { + name: "Zeros" + mtype: "" + } + member { + name: "constant" + mtype: "" + } + member { + name: "identity" + mtype: "" + } + member { + name: "normal" + mtype: "" + } + member { + name: "ones" + mtype: "" + } + member { + name: "orthogonal" + mtype: "" + } + member { + name: "random_normal" + mtype: "" + } + member { + name: "random_uniform" + mtype: "" + } + member { + name: "truncated_normal" + mtype: "" + } + member { + name: "uniform" + mtype: "" + } + member { + name: "zeros" + mtype: "" + } + member_method { + name: "deserialize" + argspec: "args=[\'config\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get" + argspec: "args=[\'identifier\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "glorot_normal" + argspec: "args=[\'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\', \"\"], " + } + member_method { + name: "glorot_uniform" + argspec: "args=[\'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\', \"\"], " + } + member_method { + name: "he_normal" + argspec: "args=[\'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "he_uniform" + argspec: "args=[\'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "lecun_normal" + argspec: "args=[\'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "lecun_uniform" + argspec: "args=[\'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "serialize" + argspec: "args=[\'initializer\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.random_normal.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.random_normal.pbtxt new file mode 100644 index 0000000000..a6df1e87a3 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.random_normal.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.keras.initializers.random_normal" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'mean\', \'stddev\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'0.0\', \'1.0\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.random_uniform.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.random_uniform.pbtxt new file mode 100644 index 0000000000..37a0fa0d55 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.random_uniform.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.keras.initializers.random_uniform" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'minval\', \'maxval\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'0\', \'None\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.truncated_normal.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.truncated_normal.pbtxt new file mode 100644 index 0000000000..f97e93f0b7 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.truncated_normal.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.keras.initializers.truncated_normal" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'mean\', \'stddev\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'0.0\', \'1.0\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.uniform.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.uniform.pbtxt new file mode 100644 index 0000000000..58186b1383 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.uniform.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.keras.initializers.uniform" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'minval\', \'maxval\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'0\', \'None\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.zeros.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.zeros.pbtxt new file mode 100644 index 0000000000..a262390687 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.initializers.zeros.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.keras.initializers.zeros" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'dtype\'], varargs=None, keywords=None, defaults=[\"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-activation.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-activation.pbtxt new file mode 100644 index 0000000000..86e328888e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-activation.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.Activation" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'activation\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-activity-regularization.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-activity-regularization.pbtxt new file mode 100644 index 0000000000..b0ed545781 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-activity-regularization.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.ActivityRegularization" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'l1\', \'l2\'], varargs=None, keywords=kwargs, defaults=[\'0.0\', \'0.0\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-add.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-add.pbtxt new file mode 100644 index 0000000000..42f98ed03d --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-add.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.Add" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-alpha-dropout.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-alpha-dropout.pbtxt new file mode 100644 index 0000000000..000898a4be --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-alpha-dropout.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.AlphaDropout" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'rate\', \'noise_shape\', \'seed\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'training\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-average-pooling1-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-average-pooling1-d.pbtxt new file mode 100644 index 0000000000..380b49f99c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-average-pooling1-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.AveragePooling1D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'pool_size\', \'strides\', \'padding\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'2\', \'None\', \'valid\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-average-pooling2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-average-pooling2-d.pbtxt new file mode 100644 index 0000000000..82db5e6137 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-average-pooling2-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.AveragePooling2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'pool_size\', \'strides\', \'padding\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'(2, 2)\', \'None\', \'valid\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-average-pooling3-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-average-pooling3-d.pbtxt new file mode 100644 index 0000000000..b6ff688ec3 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-average-pooling3-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.AveragePooling3D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'pool_size\', \'strides\', \'padding\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'(2, 2, 2)\', \'None\', \'valid\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-average.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-average.pbtxt new file mode 100644 index 0000000000..b41290f8b0 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-average.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.Average" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-avg-pool1-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-avg-pool1-d.pbtxt new file mode 100644 index 0000000000..88a033e61f --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-avg-pool1-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.AvgPool1D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'pool_size\', \'strides\', \'padding\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'2\', \'None\', \'valid\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-avg-pool2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-avg-pool2-d.pbtxt new file mode 100644 index 0000000000..c1b9b96044 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-avg-pool2-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.AvgPool2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'pool_size\', \'strides\', \'padding\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'(2, 2)\', \'None\', \'valid\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-avg-pool3-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-avg-pool3-d.pbtxt new file mode 100644 index 0000000000..f59f7727a3 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-avg-pool3-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.AvgPool3D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'pool_size\', \'strides\', \'padding\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'(2, 2, 2)\', \'None\', \'valid\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-batch-normalization.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-batch-normalization.pbtxt new file mode 100644 index 0000000000..7d3744ed92 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-batch-normalization.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.BatchNormalization" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'axis\', \'momentum\', \'epsilon\', \'center\', \'scale\', \'beta_initializer\', \'gamma_initializer\', \'moving_mean_initializer\', \'moving_variance_initializer\', \'beta_regularizer\', \'gamma_regularizer\', \'beta_constraint\', \'gamma_constraint\', \'renorm\', \'renorm_clipping\', \'renorm_momentum\', \'fused\', \'trainable\', \'virtual_batch_size\', \'adjustment\', \'name\'], varargs=None, keywords=kwargs, defaults=[\'-1\', \'0.99\', \'0.001\', \'True\', \'True\', \'zeros\', \'ones\', \'zeros\', \'ones\', \'None\', \'None\', \'None\', \'None\', \'False\', \'None\', \'0.99\', \'None\', \'True\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'training\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-bidirectional.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-bidirectional.pbtxt new file mode 100644 index 0000000000..3fd4ccdab2 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-bidirectional.pbtxt @@ -0,0 +1,188 @@ +path: "tensorflow.keras.layers.Bidirectional" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "constraints" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'layer\', \'merge_mode\', \'weights\'], varargs=None, keywords=kwargs, defaults=[\'concat\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'training\', \'mask\', \'initial_state\', \'constants\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "reset_states" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-concatenate.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-concatenate.pbtxt new file mode 100644 index 0000000000..ba21b50be4 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-concatenate.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.Concatenate" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'axis\'], varargs=None, keywords=kwargs, defaults=[\'-1\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv-l-s-t-m2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv-l-s-t-m2-d.pbtxt new file mode 100644 index 0000000000..46f9fa2bbb --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv-l-s-t-m2-d.pbtxt @@ -0,0 +1,273 @@ +path: "tensorflow.keras.layers.ConvLSTM2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activation" + mtype: "" + } + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "bias_constraint" + mtype: "" + } + member { + name: "bias_initializer" + mtype: "" + } + member { + name: "bias_regularizer" + mtype: "" + } + member { + name: "data_format" + mtype: "" + } + member { + name: "dilation_rate" + mtype: "" + } + member { + name: "dropout" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "filters" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "kernel_constraint" + mtype: "" + } + member { + name: "kernel_initializer" + mtype: "" + } + member { + name: "kernel_regularizer" + mtype: "" + } + member { + name: "kernel_size" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "padding" + mtype: "" + } + member { + name: "recurrent_activation" + mtype: "" + } + member { + name: "recurrent_constraint" + mtype: "" + } + member { + name: "recurrent_dropout" + mtype: "" + } + member { + name: "recurrent_initializer" + mtype: "" + } + member { + name: "recurrent_regularizer" + mtype: "" + } + member { + name: "states" + mtype: "" + } + member { + name: "strides" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "unit_forget_bias" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "use_bias" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\', \'activation\', \'recurrent_activation\', \'use_bias\', \'kernel_initializer\', \'recurrent_initializer\', \'bias_initializer\', \'unit_forget_bias\', \'kernel_regularizer\', \'recurrent_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'recurrent_constraint\', \'bias_constraint\', \'return_sequences\', \'go_backwards\', \'stateful\', \'dropout\', \'recurrent_dropout\'], varargs=None, keywords=kwargs, defaults=[\'(1, 1)\', \'valid\', \'None\', \'(1, 1)\', \'tanh\', \'hard_sigmoid\', \'True\', \'glorot_uniform\', \'orthogonal\', \'zeros\', \'True\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'False\', \'False\', \'False\', \'0.0\', \'0.0\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'mask\', \'training\', \'initial_state\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_initial_state" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "reset_states" + argspec: "args=[\'self\', \'states\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv1-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv1-d.pbtxt new file mode 100644 index 0000000000..c3ad326589 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv1-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.Conv1D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\'], varargs=None, keywords=kwargs, defaults=[\'1\', \'valid\', \'channels_last\', \'1\', \'None\', \'True\', \'glorot_uniform\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv2-d-transpose.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv2-d-transpose.pbtxt new file mode 100644 index 0000000000..fd9eb43066 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv2-d-transpose.pbtxt @@ -0,0 +1,177 @@ +path: "tensorflow.keras.layers.Conv2DTranspose" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\'], varargs=None, keywords=kwargs, defaults=[\'(1, 1)\', \'valid\', \'None\', \'None\', \'True\', \'glorot_uniform\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv2-d.pbtxt new file mode 100644 index 0000000000..40d61688f2 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv2-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.Conv2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\'], varargs=None, keywords=kwargs, defaults=[\'(1, 1)\', \'valid\', \'None\', \'(1, 1)\', \'None\', \'True\', \'glorot_uniform\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv3-d-transpose.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv3-d-transpose.pbtxt new file mode 100644 index 0000000000..b8c227d725 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv3-d-transpose.pbtxt @@ -0,0 +1,177 @@ +path: "tensorflow.keras.layers.Conv3DTranspose" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\'], varargs=None, keywords=kwargs, defaults=[\'(1, 1, 1)\', \'valid\', \'None\', \'None\', \'True\', \'glorot_uniform\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv3-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv3-d.pbtxt new file mode 100644 index 0000000000..095d35e574 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-conv3-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.Conv3D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\'], varargs=None, keywords=kwargs, defaults=[\'(1, 1, 1)\', \'valid\', \'None\', \'(1, 1, 1)\', \'None\', \'True\', \'glorot_uniform\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-convolution1-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-convolution1-d.pbtxt new file mode 100644 index 0000000000..8f99961198 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-convolution1-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.Convolution1D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\'], varargs=None, keywords=kwargs, defaults=[\'1\', \'valid\', \'channels_last\', \'1\', \'None\', \'True\', \'glorot_uniform\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-convolution2-d-transpose.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-convolution2-d-transpose.pbtxt new file mode 100644 index 0000000000..96d522a016 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-convolution2-d-transpose.pbtxt @@ -0,0 +1,177 @@ +path: "tensorflow.keras.layers.Convolution2DTranspose" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\'], varargs=None, keywords=kwargs, defaults=[\'(1, 1)\', \'valid\', \'None\', \'None\', \'True\', \'glorot_uniform\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-convolution2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-convolution2-d.pbtxt new file mode 100644 index 0000000000..de2824dab4 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-convolution2-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.Convolution2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\'], varargs=None, keywords=kwargs, defaults=[\'(1, 1)\', \'valid\', \'None\', \'(1, 1)\', \'None\', \'True\', \'glorot_uniform\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-convolution3-d-transpose.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-convolution3-d-transpose.pbtxt new file mode 100644 index 0000000000..1d563241d8 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-convolution3-d-transpose.pbtxt @@ -0,0 +1,177 @@ +path: "tensorflow.keras.layers.Convolution3DTranspose" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\'], varargs=None, keywords=kwargs, defaults=[\'(1, 1, 1)\', \'valid\', \'None\', \'None\', \'True\', \'glorot_uniform\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-convolution3-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-convolution3-d.pbtxt new file mode 100644 index 0000000000..c87e52c537 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-convolution3-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.Convolution3D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\'], varargs=None, keywords=kwargs, defaults=[\'(1, 1, 1)\', \'valid\', \'None\', \'(1, 1, 1)\', \'None\', \'True\', \'glorot_uniform\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-cropping1-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-cropping1-d.pbtxt new file mode 100644 index 0000000000..dccf5523e3 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-cropping1-d.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.Cropping1D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'cropping\'], varargs=None, keywords=kwargs, defaults=[\'(1, 1)\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-cropping2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-cropping2-d.pbtxt new file mode 100644 index 0000000000..7ac4116d92 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-cropping2-d.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.Cropping2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'cropping\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'((0, 0), (0, 0))\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-cropping3-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-cropping3-d.pbtxt new file mode 100644 index 0000000000..024f72705d --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-cropping3-d.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.Cropping3D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'cropping\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'((1, 1), (1, 1), (1, 1))\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-cu-d-n-n-g-r-u.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-cu-d-n-n-g-r-u.pbtxt new file mode 100644 index 0000000000..4e0233331b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-cu-d-n-n-g-r-u.pbtxt @@ -0,0 +1,193 @@ +path: "tensorflow.keras.layers.CuDNNGRU" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "cell" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "states" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'units\', \'kernel_initializer\', \'recurrent_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'recurrent_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'recurrent_constraint\', \'bias_constraint\', \'return_sequences\', \'return_state\', \'go_backwards\', \'stateful\'], varargs=None, keywords=kwargs, defaults=[\'glorot_uniform\', \'orthogonal\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'False\', \'False\', \'False\', \'False\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'mask\', \'training\', \'initial_state\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_initial_state" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "reset_states" + argspec: "args=[\'self\', \'states\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-cu-d-n-n-l-s-t-m.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-cu-d-n-n-l-s-t-m.pbtxt new file mode 100644 index 0000000000..32d46ce8f3 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-cu-d-n-n-l-s-t-m.pbtxt @@ -0,0 +1,193 @@ +path: "tensorflow.keras.layers.CuDNNLSTM" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "cell" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "states" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'units\', \'kernel_initializer\', \'recurrent_initializer\', \'bias_initializer\', \'unit_forget_bias\', \'kernel_regularizer\', \'recurrent_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'recurrent_constraint\', \'bias_constraint\', \'return_sequences\', \'return_state\', \'go_backwards\', \'stateful\'], varargs=None, keywords=kwargs, defaults=[\'glorot_uniform\', \'orthogonal\', \'zeros\', \'True\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'False\', \'False\', \'False\', \'False\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'mask\', \'training\', \'initial_state\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_initial_state" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "reset_states" + argspec: "args=[\'self\', \'states\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-dense.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-dense.pbtxt new file mode 100644 index 0000000000..858486c725 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-dense.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.Dense" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'units\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'True\', \'glorot_uniform\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-depthwise-conv2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-depthwise-conv2-d.pbtxt new file mode 100644 index 0000000000..f65d750926 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-depthwise-conv2-d.pbtxt @@ -0,0 +1,177 @@ +path: "tensorflow.keras.layers.DepthwiseConv2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'kernel_size\', \'strides\', \'padding\', \'depth_multiplier\', \'data_format\', \'activation\', \'use_bias\', \'depthwise_initializer\', \'bias_initializer\', \'depthwise_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'depthwise_constraint\', \'bias_constraint\'], varargs=None, keywords=kwargs, defaults=[\'(1, 1)\', \'valid\', \'1\', \'None\', \'None\', \'True\', \'glorot_uniform\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'training\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-dot.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-dot.pbtxt new file mode 100644 index 0000000000..2e71ef503d --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-dot.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.Dot" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'axes\', \'normalize\'], varargs=None, keywords=kwargs, defaults=[\'False\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-dropout.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-dropout.pbtxt new file mode 100644 index 0000000000..42533bcd21 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-dropout.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.Dropout" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'rate\', \'noise_shape\', \'seed\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'training\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-e-l-u.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-e-l-u.pbtxt new file mode 100644 index 0000000000..b5df169417 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-e-l-u.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.ELU" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'alpha\'], varargs=None, keywords=kwargs, defaults=[\'1.0\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-embedding.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-embedding.pbtxt new file mode 100644 index 0000000000..0ea17919a9 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-embedding.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.Embedding" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'input_dim\', \'output_dim\', \'embeddings_initializer\', \'embeddings_regularizer\', \'activity_regularizer\', \'embeddings_constraint\', \'mask_zero\', \'input_length\'], varargs=None, keywords=kwargs, defaults=[\'uniform\', \'None\', \'None\', \'None\', \'False\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-flatten.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-flatten.pbtxt new file mode 100644 index 0000000000..a33248bc00 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-flatten.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.Flatten" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-g-r-u-cell.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-g-r-u-cell.pbtxt new file mode 100644 index 0000000000..4ba21a25cd --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-g-r-u-cell.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.GRUCell" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'units\', \'activation\', \'recurrent_activation\', \'use_bias\', \'kernel_initializer\', \'recurrent_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'recurrent_regularizer\', \'bias_regularizer\', \'kernel_constraint\', \'recurrent_constraint\', \'bias_constraint\', \'dropout\', \'recurrent_dropout\', \'implementation\', \'reset_after\'], varargs=None, keywords=kwargs, defaults=[\'tanh\', \'hard_sigmoid\', \'True\', \'glorot_uniform\', \'orthogonal\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'0.0\', \'0.0\', \'1\', \'False\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'states\', \'training\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-g-r-u.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-g-r-u.pbtxt new file mode 100644 index 0000000000..a7a570418e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-g-r-u.pbtxt @@ -0,0 +1,256 @@ +path: "tensorflow.keras.layers.GRU" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activation" + mtype: "" + } + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "bias_constraint" + mtype: "" + } + member { + name: "bias_initializer" + mtype: "" + } + member { + name: "bias_regularizer" + mtype: "" + } + member { + name: "dropout" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "implementation" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "kernel_constraint" + mtype: "" + } + member { + name: "kernel_initializer" + mtype: "" + } + member { + name: "kernel_regularizer" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "recurrent_activation" + mtype: "" + } + member { + name: "recurrent_constraint" + mtype: "" + } + member { + name: "recurrent_dropout" + mtype: "" + } + member { + name: "recurrent_initializer" + mtype: "" + } + member { + name: "recurrent_regularizer" + mtype: "" + } + member { + name: "reset_after" + mtype: "" + } + member { + name: "states" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "units" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "use_bias" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'units\', \'activation\', \'recurrent_activation\', \'use_bias\', \'kernel_initializer\', \'recurrent_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'recurrent_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'recurrent_constraint\', \'bias_constraint\', \'dropout\', \'recurrent_dropout\', \'implementation\', \'return_sequences\', \'return_state\', \'go_backwards\', \'stateful\', \'unroll\', \'reset_after\'], varargs=None, keywords=kwargs, defaults=[\'tanh\', \'hard_sigmoid\', \'True\', \'glorot_uniform\', \'orthogonal\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'0.0\', \'0.0\', \'1\', \'False\', \'False\', \'False\', \'False\', \'False\', \'False\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'mask\', \'training\', \'initial_state\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_initial_state" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "reset_states" + argspec: "args=[\'self\', \'states\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-gaussian-dropout.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-gaussian-dropout.pbtxt new file mode 100644 index 0000000000..763bc23113 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-gaussian-dropout.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.GaussianDropout" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'rate\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'training\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-gaussian-noise.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-gaussian-noise.pbtxt new file mode 100644 index 0000000000..3c50a3d7f2 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-gaussian-noise.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.GaussianNoise" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'stddev\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'training\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-average-pooling1-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-average-pooling1-d.pbtxt new file mode 100644 index 0000000000..ac78bdafad --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-average-pooling1-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.GlobalAveragePooling1D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-average-pooling2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-average-pooling2-d.pbtxt new file mode 100644 index 0000000000..275282d9d2 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-average-pooling2-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.GlobalAveragePooling2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-average-pooling3-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-average-pooling3-d.pbtxt new file mode 100644 index 0000000000..0e31e6058b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-average-pooling3-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.GlobalAveragePooling3D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-avg-pool1-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-avg-pool1-d.pbtxt new file mode 100644 index 0000000000..aacd0b1791 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-avg-pool1-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.GlobalAvgPool1D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-avg-pool2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-avg-pool2-d.pbtxt new file mode 100644 index 0000000000..c236548663 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-avg-pool2-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.GlobalAvgPool2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-avg-pool3-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-avg-pool3-d.pbtxt new file mode 100644 index 0000000000..6b9c0290aa --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-avg-pool3-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.GlobalAvgPool3D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pool1-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pool1-d.pbtxt new file mode 100644 index 0000000000..0d7b2211e6 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pool1-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.GlobalMaxPool1D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pool2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pool2-d.pbtxt new file mode 100644 index 0000000000..d080ad6aed --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pool2-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.GlobalMaxPool2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pool3-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pool3-d.pbtxt new file mode 100644 index 0000000000..fcb0a109da --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pool3-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.GlobalMaxPool3D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pooling1-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pooling1-d.pbtxt new file mode 100644 index 0000000000..1d0e22abd0 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pooling1-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.GlobalMaxPooling1D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pooling2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pooling2-d.pbtxt new file mode 100644 index 0000000000..653c9f547b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pooling2-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.GlobalMaxPooling2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pooling3-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pooling3-d.pbtxt new file mode 100644 index 0000000000..cdbaf82cf6 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-global-max-pooling3-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.GlobalMaxPooling3D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-input-layer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-input-layer.pbtxt new file mode 100644 index 0000000000..230c5e9034 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-input-layer.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.InputLayer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'input_shape\', \'batch_size\', \'dtype\', \'input_tensor\', \'sparse\', \'name\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\', \'None\', \'None\', \'False\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-input-spec.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-input-spec.pbtxt new file mode 100644 index 0000000000..5fd0a47a68 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-input-spec.pbtxt @@ -0,0 +1,9 @@ +path: "tensorflow.keras.layers.InputSpec" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'dtype\', \'shape\', \'ndim\', \'max_ndim\', \'min_ndim\', \'axes\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-l-s-t-m-cell.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-l-s-t-m-cell.pbtxt new file mode 100644 index 0000000000..511456e740 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-l-s-t-m-cell.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.LSTMCell" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'units\', \'activation\', \'recurrent_activation\', \'use_bias\', \'kernel_initializer\', \'recurrent_initializer\', \'bias_initializer\', \'unit_forget_bias\', \'kernel_regularizer\', \'recurrent_regularizer\', \'bias_regularizer\', \'kernel_constraint\', \'recurrent_constraint\', \'bias_constraint\', \'dropout\', \'recurrent_dropout\', \'implementation\'], varargs=None, keywords=kwargs, defaults=[\'tanh\', \'hard_sigmoid\', \'True\', \'glorot_uniform\', \'orthogonal\', \'zeros\', \'True\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'0.0\', \'0.0\', \'1\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'states\', \'training\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-l-s-t-m.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-l-s-t-m.pbtxt new file mode 100644 index 0000000000..4a3492ebd6 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-l-s-t-m.pbtxt @@ -0,0 +1,256 @@ +path: "tensorflow.keras.layers.LSTM" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activation" + mtype: "" + } + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "bias_constraint" + mtype: "" + } + member { + name: "bias_initializer" + mtype: "" + } + member { + name: "bias_regularizer" + mtype: "" + } + member { + name: "dropout" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "implementation" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "kernel_constraint" + mtype: "" + } + member { + name: "kernel_initializer" + mtype: "" + } + member { + name: "kernel_regularizer" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "recurrent_activation" + mtype: "" + } + member { + name: "recurrent_constraint" + mtype: "" + } + member { + name: "recurrent_dropout" + mtype: "" + } + member { + name: "recurrent_initializer" + mtype: "" + } + member { + name: "recurrent_regularizer" + mtype: "" + } + member { + name: "states" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "unit_forget_bias" + mtype: "" + } + member { + name: "units" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "use_bias" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'units\', \'activation\', \'recurrent_activation\', \'use_bias\', \'kernel_initializer\', \'recurrent_initializer\', \'bias_initializer\', \'unit_forget_bias\', \'kernel_regularizer\', \'recurrent_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'recurrent_constraint\', \'bias_constraint\', \'dropout\', \'recurrent_dropout\', \'implementation\', \'return_sequences\', \'return_state\', \'go_backwards\', \'stateful\', \'unroll\'], varargs=None, keywords=kwargs, defaults=[\'tanh\', \'hard_sigmoid\', \'True\', \'glorot_uniform\', \'orthogonal\', \'zeros\', \'True\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'0.0\', \'0.0\', \'1\', \'False\', \'False\', \'False\', \'False\', \'False\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'mask\', \'training\', \'initial_state\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_initial_state" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "reset_states" + argspec: "args=[\'self\', \'states\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-lambda.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-lambda.pbtxt new file mode 100644 index 0000000000..5d05cf689f --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-lambda.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.Lambda" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'function\', \'output_shape\', \'mask\', \'arguments\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-layer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-layer.pbtxt new file mode 100644 index 0000000000..7efa29be77 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-layer.pbtxt @@ -0,0 +1,174 @@ +path: "tensorflow.keras.layers.Layer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'trainable\', \'name\', \'dtype\'], varargs=None, keywords=kwargs, defaults=[\'True\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-leaky-re-l-u.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-leaky-re-l-u.pbtxt new file mode 100644 index 0000000000..0ca8e0b52c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-leaky-re-l-u.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.LeakyReLU" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'alpha\'], varargs=None, keywords=kwargs, defaults=[\'0.3\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-locally-connected1-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-locally-connected1-d.pbtxt new file mode 100644 index 0000000000..f754fa1da8 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-locally-connected1-d.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.LocallyConnected1D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\'], varargs=None, keywords=kwargs, defaults=[\'1\', \'valid\', \'None\', \'None\', \'True\', \'glorot_uniform\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-locally-connected2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-locally-connected2-d.pbtxt new file mode 100644 index 0000000000..c9516b8f07 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-locally-connected2-d.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.LocallyConnected2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\'], varargs=None, keywords=kwargs, defaults=[\'(1, 1)\', \'valid\', \'None\', \'None\', \'True\', \'glorot_uniform\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-masking.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-masking.pbtxt new file mode 100644 index 0000000000..850ecff974 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-masking.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.Masking" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'mask_value\'], varargs=None, keywords=kwargs, defaults=[\'0.0\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pool1-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pool1-d.pbtxt new file mode 100644 index 0000000000..7c69e31f9a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pool1-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.MaxPool1D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'pool_size\', \'strides\', \'padding\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'2\', \'None\', \'valid\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pool2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pool2-d.pbtxt new file mode 100644 index 0000000000..fba42642d7 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pool2-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.MaxPool2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'pool_size\', \'strides\', \'padding\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'(2, 2)\', \'None\', \'valid\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pool3-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pool3-d.pbtxt new file mode 100644 index 0000000000..9c277411ea --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pool3-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.MaxPool3D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'pool_size\', \'strides\', \'padding\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'(2, 2, 2)\', \'None\', \'valid\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pooling1-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pooling1-d.pbtxt new file mode 100644 index 0000000000..7c2f6ccc8a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pooling1-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.MaxPooling1D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'pool_size\', \'strides\', \'padding\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'2\', \'None\', \'valid\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pooling2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pooling2-d.pbtxt new file mode 100644 index 0000000000..802178dba6 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pooling2-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.MaxPooling2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'pool_size\', \'strides\', \'padding\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'(2, 2)\', \'None\', \'valid\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pooling3-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pooling3-d.pbtxt new file mode 100644 index 0000000000..e870dfe9ad --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-max-pooling3-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.MaxPooling3D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'pool_size\', \'strides\', \'padding\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'(2, 2, 2)\', \'None\', \'valid\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-maximum.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-maximum.pbtxt new file mode 100644 index 0000000000..c1337ce0cb --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-maximum.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.Maximum" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-minimum.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-minimum.pbtxt new file mode 100644 index 0000000000..ed27a62765 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-minimum.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.Minimum" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-multiply.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-multiply.pbtxt new file mode 100644 index 0000000000..b9f05cb3e5 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-multiply.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.Multiply" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-p-re-l-u.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-p-re-l-u.pbtxt new file mode 100644 index 0000000000..336d9f76fb --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-p-re-l-u.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.PReLU" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'alpha_initializer\', \'alpha_regularizer\', \'alpha_constraint\', \'shared_axes\'], varargs=None, keywords=kwargs, defaults=[\'zeros\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-permute.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-permute.pbtxt new file mode 100644 index 0000000000..46282217e0 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-permute.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.Permute" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'dims\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-r-n-n.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-r-n-n.pbtxt new file mode 100644 index 0000000000..42cd7e87ee --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-r-n-n.pbtxt @@ -0,0 +1,187 @@ +path: "tensorflow.keras.layers.RNN" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "states" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'cell\', \'return_sequences\', \'return_state\', \'go_backwards\', \'stateful\', \'unroll\'], varargs=None, keywords=kwargs, defaults=[\'False\', \'False\', \'False\', \'False\', \'False\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'mask\', \'training\', \'initial_state\', \'constants\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_initial_state" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "reset_states" + argspec: "args=[\'self\', \'states\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-re-l-u.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-re-l-u.pbtxt new file mode 100644 index 0000000000..c00fa79adf --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-re-l-u.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.ReLU" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'max_value\'], varargs=None, keywords=kwargs, defaults=[\'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-repeat-vector.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-repeat-vector.pbtxt new file mode 100644 index 0000000000..9f094a877a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-repeat-vector.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.RepeatVector" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'n\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-reshape.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-reshape.pbtxt new file mode 100644 index 0000000000..2f519a2438 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-reshape.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.Reshape" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'target_shape\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-separable-conv1-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-separable-conv1-d.pbtxt new file mode 100644 index 0000000000..6b93116ba0 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-separable-conv1-d.pbtxt @@ -0,0 +1,177 @@ +path: "tensorflow.keras.layers.SeparableConv1D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\', \'depth_multiplier\', \'activation\', \'use_bias\', \'depthwise_initializer\', \'pointwise_initializer\', \'bias_initializer\', \'depthwise_regularizer\', \'pointwise_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'depthwise_constraint\', \'pointwise_constraint\', \'bias_constraint\'], varargs=None, keywords=kwargs, defaults=[\'1\', \'valid\', \'None\', \'1\', \'1\', \'None\', \'True\', \'glorot_uniform\', \'glorot_uniform\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-separable-conv2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-separable-conv2-d.pbtxt new file mode 100644 index 0000000000..fd17115e27 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-separable-conv2-d.pbtxt @@ -0,0 +1,177 @@ +path: "tensorflow.keras.layers.SeparableConv2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\', \'depth_multiplier\', \'activation\', \'use_bias\', \'depthwise_initializer\', \'pointwise_initializer\', \'bias_initializer\', \'depthwise_regularizer\', \'pointwise_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'depthwise_constraint\', \'pointwise_constraint\', \'bias_constraint\'], varargs=None, keywords=kwargs, defaults=[\'(1, 1)\', \'valid\', \'None\', \'(1, 1)\', \'1\', \'None\', \'True\', \'glorot_uniform\', \'glorot_uniform\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-separable-convolution1-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-separable-convolution1-d.pbtxt new file mode 100644 index 0000000000..4b37a94478 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-separable-convolution1-d.pbtxt @@ -0,0 +1,177 @@ +path: "tensorflow.keras.layers.SeparableConvolution1D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\', \'depth_multiplier\', \'activation\', \'use_bias\', \'depthwise_initializer\', \'pointwise_initializer\', \'bias_initializer\', \'depthwise_regularizer\', \'pointwise_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'depthwise_constraint\', \'pointwise_constraint\', \'bias_constraint\'], varargs=None, keywords=kwargs, defaults=[\'1\', \'valid\', \'None\', \'1\', \'1\', \'None\', \'True\', \'glorot_uniform\', \'glorot_uniform\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-separable-convolution2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-separable-convolution2-d.pbtxt new file mode 100644 index 0000000000..5bdadca74a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-separable-convolution2-d.pbtxt @@ -0,0 +1,177 @@ +path: "tensorflow.keras.layers.SeparableConvolution2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\', \'depth_multiplier\', \'activation\', \'use_bias\', \'depthwise_initializer\', \'pointwise_initializer\', \'bias_initializer\', \'depthwise_regularizer\', \'pointwise_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'depthwise_constraint\', \'pointwise_constraint\', \'bias_constraint\'], varargs=None, keywords=kwargs, defaults=[\'(1, 1)\', \'valid\', \'None\', \'(1, 1)\', \'1\', \'None\', \'True\', \'glorot_uniform\', \'glorot_uniform\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-simple-r-n-n-cell.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-simple-r-n-n-cell.pbtxt new file mode 100644 index 0000000000..9dfda96fc8 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-simple-r-n-n-cell.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.SimpleRNNCell" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'units\', \'activation\', \'use_bias\', \'kernel_initializer\', \'recurrent_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'recurrent_regularizer\', \'bias_regularizer\', \'kernel_constraint\', \'recurrent_constraint\', \'bias_constraint\', \'dropout\', \'recurrent_dropout\'], varargs=None, keywords=kwargs, defaults=[\'tanh\', \'True\', \'glorot_uniform\', \'orthogonal\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'0.0\', \'0.0\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'states\', \'training\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-simple-r-n-n.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-simple-r-n-n.pbtxt new file mode 100644 index 0000000000..7b7684ccd2 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-simple-r-n-n.pbtxt @@ -0,0 +1,244 @@ +path: "tensorflow.keras.layers.SimpleRNN" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activation" + mtype: "" + } + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "bias_constraint" + mtype: "" + } + member { + name: "bias_initializer" + mtype: "" + } + member { + name: "bias_regularizer" + mtype: "" + } + member { + name: "dropout" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "kernel_constraint" + mtype: "" + } + member { + name: "kernel_initializer" + mtype: "" + } + member { + name: "kernel_regularizer" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "recurrent_constraint" + mtype: "" + } + member { + name: "recurrent_dropout" + mtype: "" + } + member { + name: "recurrent_initializer" + mtype: "" + } + member { + name: "recurrent_regularizer" + mtype: "" + } + member { + name: "states" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "units" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "use_bias" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'units\', \'activation\', \'use_bias\', \'kernel_initializer\', \'recurrent_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'recurrent_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'recurrent_constraint\', \'bias_constraint\', \'dropout\', \'recurrent_dropout\', \'return_sequences\', \'return_state\', \'go_backwards\', \'stateful\', \'unroll\'], varargs=None, keywords=kwargs, defaults=[\'tanh\', \'True\', \'glorot_uniform\', \'orthogonal\', \'zeros\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'0.0\', \'0.0\', \'False\', \'False\', \'False\', \'False\', \'False\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'mask\', \'training\', \'initial_state\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_initial_state" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "reset_states" + argspec: "args=[\'self\', \'states\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-softmax.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-softmax.pbtxt new file mode 100644 index 0000000000..3b15407fca --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-softmax.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.Softmax" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'axis\'], varargs=None, keywords=kwargs, defaults=[\'-1\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-spatial-dropout1-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-spatial-dropout1-d.pbtxt new file mode 100644 index 0000000000..6d04415267 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-spatial-dropout1-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.SpatialDropout1D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'rate\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'training\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-spatial-dropout2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-spatial-dropout2-d.pbtxt new file mode 100644 index 0000000000..04950654d5 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-spatial-dropout2-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.SpatialDropout2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'rate\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'training\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-spatial-dropout3-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-spatial-dropout3-d.pbtxt new file mode 100644 index 0000000000..c424e6dcc8 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-spatial-dropout3-d.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.SpatialDropout3D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'rate\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'training\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-stacked-r-n-n-cells.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-stacked-r-n-n-cells.pbtxt new file mode 100644 index 0000000000..1160d2840f --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-stacked-r-n-n-cells.pbtxt @@ -0,0 +1,179 @@ +path: "tensorflow.keras.layers.StackedRNNCells" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "state_size" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'cells\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'states\', \'constants\'], varargs=None, keywords=kwargs, defaults=[\'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-subtract.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-subtract.pbtxt new file mode 100644 index 0000000000..740a03367b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-subtract.pbtxt @@ -0,0 +1,176 @@ +path: "tensorflow.keras.layers.Subtract" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-thresholded-re-l-u.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-thresholded-re-l-u.pbtxt new file mode 100644 index 0000000000..a08c583adb --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-thresholded-re-l-u.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.ThresholdedReLU" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'theta\'], varargs=None, keywords=kwargs, defaults=[\'1.0\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-time-distributed.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-time-distributed.pbtxt new file mode 100644 index 0000000000..c1294fed0f --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-time-distributed.pbtxt @@ -0,0 +1,180 @@ +path: "tensorflow.keras.layers.TimeDistributed" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'layer\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'training\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-up-sampling1-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-up-sampling1-d.pbtxt new file mode 100644 index 0000000000..dc401d3ed0 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-up-sampling1-d.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.UpSampling1D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'size\'], varargs=None, keywords=kwargs, defaults=[\'2\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-up-sampling2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-up-sampling2-d.pbtxt new file mode 100644 index 0000000000..4b5165ae97 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-up-sampling2-d.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.UpSampling2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'size\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'(2, 2)\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-up-sampling3-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-up-sampling3-d.pbtxt new file mode 100644 index 0000000000..789af15fea --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-up-sampling3-d.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.UpSampling3D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'size\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'(2, 2, 2)\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-wrapper.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-wrapper.pbtxt new file mode 100644 index 0000000000..0536a7cee7 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-wrapper.pbtxt @@ -0,0 +1,179 @@ +path: "tensorflow.keras.layers.Wrapper" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'layer\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-zero-padding1-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-zero-padding1-d.pbtxt new file mode 100644 index 0000000000..8915353ec3 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-zero-padding1-d.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.ZeroPadding1D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'padding\'], varargs=None, keywords=kwargs, defaults=[\'1\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-zero-padding2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-zero-padding2-d.pbtxt new file mode 100644 index 0000000000..6efb5ef15a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-zero-padding2-d.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.ZeroPadding2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'padding\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'(1, 1)\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-zero-padding3-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-zero-padding3-d.pbtxt new file mode 100644 index 0000000000..4c33c5d0bf --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.-zero-padding3-d.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.keras.layers.ZeroPadding3D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'padding\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'(1, 1, 1)\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.pbtxt new file mode 100644 index 0000000000..9d7e5bb8c7 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.layers.pbtxt @@ -0,0 +1,435 @@ +path: "tensorflow.keras.layers" +tf_module { + member { + name: "Activation" + mtype: "" + } + member { + name: "ActivityRegularization" + mtype: "" + } + member { + name: "Add" + mtype: "" + } + member { + name: "AlphaDropout" + mtype: "" + } + member { + name: "Average" + mtype: "" + } + member { + name: "AveragePooling1D" + mtype: "" + } + member { + name: "AveragePooling2D" + mtype: "" + } + member { + name: "AveragePooling3D" + mtype: "" + } + member { + name: "AvgPool1D" + mtype: "" + } + member { + name: "AvgPool2D" + mtype: "" + } + member { + name: "AvgPool3D" + mtype: "" + } + member { + name: "BatchNormalization" + mtype: "" + } + member { + name: "Bidirectional" + mtype: "" + } + member { + name: "Concatenate" + mtype: "" + } + member { + name: "Conv1D" + mtype: "" + } + member { + name: "Conv2D" + mtype: "" + } + member { + name: "Conv2DTranspose" + mtype: "" + } + member { + name: "Conv3D" + mtype: "" + } + member { + name: "Conv3DTranspose" + mtype: "" + } + member { + name: "ConvLSTM2D" + mtype: "" + } + member { + name: "Convolution1D" + mtype: "" + } + member { + name: "Convolution2D" + mtype: "" + } + member { + name: "Convolution2DTranspose" + mtype: "" + } + member { + name: "Convolution3D" + mtype: "" + } + member { + name: "Convolution3DTranspose" + mtype: "" + } + member { + name: "Cropping1D" + mtype: "" + } + member { + name: "Cropping2D" + mtype: "" + } + member { + name: "Cropping3D" + mtype: "" + } + member { + name: "CuDNNGRU" + mtype: "" + } + member { + name: "CuDNNLSTM" + mtype: "" + } + member { + name: "Dense" + mtype: "" + } + member { + name: "DepthwiseConv2D" + mtype: "" + } + member { + name: "Dot" + mtype: "" + } + member { + name: "Dropout" + mtype: "" + } + member { + name: "ELU" + mtype: "" + } + member { + name: "Embedding" + mtype: "" + } + member { + name: "Flatten" + mtype: "" + } + member { + name: "GRU" + mtype: "" + } + member { + name: "GRUCell" + mtype: "" + } + member { + name: "GaussianDropout" + mtype: "" + } + member { + name: "GaussianNoise" + mtype: "" + } + member { + name: "GlobalAveragePooling1D" + mtype: "" + } + member { + name: "GlobalAveragePooling2D" + mtype: "" + } + member { + name: "GlobalAveragePooling3D" + mtype: "" + } + member { + name: "GlobalAvgPool1D" + mtype: "" + } + member { + name: "GlobalAvgPool2D" + mtype: "" + } + member { + name: "GlobalAvgPool3D" + mtype: "" + } + member { + name: "GlobalMaxPool1D" + mtype: "" + } + member { + name: "GlobalMaxPool2D" + mtype: "" + } + member { + name: "GlobalMaxPool3D" + mtype: "" + } + member { + name: "GlobalMaxPooling1D" + mtype: "" + } + member { + name: "GlobalMaxPooling2D" + mtype: "" + } + member { + name: "GlobalMaxPooling3D" + mtype: "" + } + member { + name: "InputLayer" + mtype: "" + } + member { + name: "InputSpec" + mtype: "" + } + member { + name: "LSTM" + mtype: "" + } + member { + name: "LSTMCell" + mtype: "" + } + member { + name: "Lambda" + mtype: "" + } + member { + name: "Layer" + mtype: "" + } + member { + name: "LeakyReLU" + mtype: "" + } + member { + name: "LocallyConnected1D" + mtype: "" + } + member { + name: "LocallyConnected2D" + mtype: "" + } + member { + name: "Masking" + mtype: "" + } + member { + name: "MaxPool1D" + mtype: "" + } + member { + name: "MaxPool2D" + mtype: "" + } + member { + name: "MaxPool3D" + mtype: "" + } + member { + name: "MaxPooling1D" + mtype: "" + } + member { + name: "MaxPooling2D" + mtype: "" + } + member { + name: "MaxPooling3D" + mtype: "" + } + member { + name: "Maximum" + mtype: "" + } + member { + name: "Minimum" + mtype: "" + } + member { + name: "Multiply" + mtype: "" + } + member { + name: "PReLU" + mtype: "" + } + member { + name: "Permute" + mtype: "" + } + member { + name: "RNN" + mtype: "" + } + member { + name: "ReLU" + mtype: "" + } + member { + name: "RepeatVector" + mtype: "" + } + member { + name: "Reshape" + mtype: "" + } + member { + name: "SeparableConv1D" + mtype: "" + } + member { + name: "SeparableConv2D" + mtype: "" + } + member { + name: "SeparableConvolution1D" + mtype: "" + } + member { + name: "SeparableConvolution2D" + mtype: "" + } + member { + name: "SimpleRNN" + mtype: "" + } + member { + name: "SimpleRNNCell" + mtype: "" + } + member { + name: "Softmax" + mtype: "" + } + member { + name: "SpatialDropout1D" + mtype: "" + } + member { + name: "SpatialDropout2D" + mtype: "" + } + member { + name: "SpatialDropout3D" + mtype: "" + } + member { + name: "StackedRNNCells" + mtype: "" + } + member { + name: "Subtract" + mtype: "" + } + member { + name: "ThresholdedReLU" + mtype: "" + } + member { + name: "TimeDistributed" + mtype: "" + } + member { + name: "UpSampling1D" + mtype: "" + } + member { + name: "UpSampling2D" + mtype: "" + } + member { + name: "UpSampling3D" + mtype: "" + } + member { + name: "Wrapper" + mtype: "" + } + member { + name: "ZeroPadding1D" + mtype: "" + } + member { + name: "ZeroPadding2D" + mtype: "" + } + member { + name: "ZeroPadding3D" + mtype: "" + } + member_method { + name: "Input" + argspec: "args=[\'shape\', \'batch_size\', \'name\', \'dtype\', \'sparse\', \'tensor\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\', \'None\', \'None\', \'False\', \'None\'], " + } + member_method { + name: "add" + argspec: "args=[\'inputs\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "average" + argspec: "args=[\'inputs\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "concatenate" + argspec: "args=[\'inputs\', \'axis\'], varargs=None, keywords=kwargs, defaults=[\'-1\'], " + } + member_method { + name: "dot" + argspec: "args=[\'inputs\', \'axes\', \'normalize\'], varargs=None, keywords=kwargs, defaults=[\'False\'], " + } + member_method { + name: "maximum" + argspec: "args=[\'inputs\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "minimum" + argspec: "args=[\'inputs\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "multiply" + argspec: "args=[\'inputs\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "subtract" + argspec: "args=[\'inputs\'], varargs=None, keywords=kwargs, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.losses.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.losses.pbtxt new file mode 100644 index 0000000000..eca6b91538 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.losses.pbtxt @@ -0,0 +1,115 @@ +path: "tensorflow.keras.losses" +tf_module { + member_method { + name: "KLD" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "MAE" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "MAPE" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "MSE" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "MSLE" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "binary_crossentropy" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "categorical_crossentropy" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "categorical_hinge" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "cosine" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "cosine_proximity" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "deserialize" + argspec: "args=[\'name\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get" + argspec: "args=[\'identifier\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "hinge" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "kld" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "kullback_leibler_divergence" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "logcosh" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "mae" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "mape" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "mean_absolute_error" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "mean_absolute_percentage_error" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "mean_squared_error" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "mean_squared_logarithmic_error" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "mse" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "msle" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "poisson" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "serialize" + argspec: "args=[\'loss\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "sparse_categorical_crossentropy" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "squared_hinge" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.metrics.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.metrics.pbtxt new file mode 100644 index 0000000000..73b577da37 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.metrics.pbtxt @@ -0,0 +1,123 @@ +path: "tensorflow.keras.metrics" +tf_module { + member_method { + name: "KLD" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "MAE" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "MAPE" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "MSE" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "MSLE" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "binary_accuracy" + argspec: "args=[\'y_true\', \'y_pred\', \'threshold\'], varargs=None, keywords=None, defaults=[\'0.5\'], " + } + member_method { + name: "binary_crossentropy" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "categorical_accuracy" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "categorical_crossentropy" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "cosine" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "cosine_proximity" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "deserialize" + argspec: "args=[\'config\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get" + argspec: "args=[\'identifier\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "hinge" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "kld" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "kullback_leibler_divergence" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "mae" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "mape" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "mean_absolute_error" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "mean_absolute_percentage_error" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "mean_squared_error" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "mean_squared_logarithmic_error" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "mse" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "msle" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "poisson" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "serialize" + argspec: "args=[\'metric\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "sparse_categorical_crossentropy" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "sparse_top_k_categorical_accuracy" + argspec: "args=[\'y_true\', \'y_pred\', \'k\'], varargs=None, keywords=None, defaults=[\'5\'], " + } + member_method { + name: "squared_hinge" + argspec: "args=[\'y_true\', \'y_pred\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "top_k_categorical_accuracy" + argspec: "args=[\'y_true\', \'y_pred\', \'k\'], varargs=None, keywords=None, defaults=[\'5\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.models.-model.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.models.-model.pbtxt new file mode 100644 index 0000000000..85f7c2bfed --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.models.-model.pbtxt @@ -0,0 +1,268 @@ +path: "tensorflow.keras.models.Model" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "input_spec" + mtype: "" + } + member { + name: "layers" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "state_updates" + mtype: "" + } + member { + name: "stateful" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "uses_learning_phase" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\', \'None\'], " + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'training\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "compile" + argspec: "args=[\'self\', \'optimizer\', \'loss\', \'metrics\', \'loss_weights\', \'sample_weight_mode\', \'weighted_metrics\', \'target_tensors\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "evaluate" + argspec: "args=[\'self\', \'x\', \'y\', \'batch_size\', \'verbose\', \'sample_weight\', \'steps\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'1\', \'None\', \'None\'], " + } + member_method { + name: "evaluate_generator" + argspec: "args=[\'self\', \'generator\', \'steps\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'verbose\'], varargs=None, keywords=None, defaults=[\'None\', \'10\', \'1\', \'False\', \'0\'], " + } + member_method { + name: "fit" + argspec: "args=[\'self\', \'x\', \'y\', \'batch_size\', \'epochs\', \'verbose\', \'callbacks\', \'validation_split\', \'validation_data\', \'shuffle\', \'class_weight\', \'sample_weight\', \'initial_epoch\', \'steps_per_epoch\', \'validation_steps\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\', \'None\', \'1\', \'1\', \'None\', \'0.0\', \'None\', \'True\', \'None\', \'None\', \'0\', \'None\', \'None\'], " + } + member_method { + name: "fit_generator" + argspec: "args=[\'self\', \'generator\', \'steps_per_epoch\', \'epochs\', \'verbose\', \'callbacks\', \'validation_data\', \'validation_steps\', \'class_weight\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'shuffle\', \'initial_epoch\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'1\', \'None\', \'None\', \'None\', \'None\', \'10\', \'1\', \'False\', \'True\', \'0\'], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_layer" + argspec: "args=[\'self\', \'name\', \'index\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "load_weights" + argspec: "args=[\'self\', \'filepath\', \'by_name\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'x\', \'batch_size\', \'verbose\', \'steps\'], varargs=None, keywords=None, defaults=[\'None\', \'0\', \'None\'], " + } + member_method { + name: "predict_generator" + argspec: "args=[\'self\', \'generator\', \'steps\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'verbose\'], varargs=None, keywords=None, defaults=[\'None\', \'10\', \'1\', \'False\', \'0\'], " + } + member_method { + name: "predict_on_batch" + argspec: "args=[\'self\', \'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "reset_states" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "save" + argspec: "args=[\'self\', \'filepath\', \'overwrite\', \'include_optimizer\'], varargs=None, keywords=None, defaults=[\'True\', \'True\'], " + } + member_method { + name: "save_weights" + argspec: "args=[\'self\', \'filepath\', \'overwrite\', \'save_format\'], varargs=None, keywords=None, defaults=[\'True\', \'None\'], " + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "summary" + argspec: "args=[\'self\', \'line_length\', \'positions\', \'print_fn\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "test_on_batch" + argspec: "args=[\'self\', \'x\', \'y\', \'sample_weight\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "to_json" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "to_yaml" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "train_on_batch" + argspec: "args=[\'self\', \'x\', \'y\', \'sample_weight\', \'class_weight\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.models.-sequential.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.models.-sequential.pbtxt new file mode 100644 index 0000000000..6a83129f7d --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.models.-sequential.pbtxt @@ -0,0 +1,289 @@ +path: "tensorflow.keras.models.Sequential" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "input_spec" + mtype: "" + } + member { + name: "layers" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "state_updates" + mtype: "" + } + member { + name: "stateful" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "uses_learning_phase" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'layers\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "add" + argspec: "args=[\'self\', \'layer\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\', \'None\'], " + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'partitioner\', \'use_resource\', \'synchronization\', \'aggregation\', \'getter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'training\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "compile" + argspec: "args=[\'self\', \'optimizer\', \'loss\', \'metrics\', \'loss_weights\', \'sample_weight_mode\', \'weighted_metrics\', \'target_tensors\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "evaluate" + argspec: "args=[\'self\', \'x\', \'y\', \'batch_size\', \'verbose\', \'sample_weight\', \'steps\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'1\', \'None\', \'None\'], " + } + member_method { + name: "evaluate_generator" + argspec: "args=[\'self\', \'generator\', \'steps\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'verbose\'], varargs=None, keywords=None, defaults=[\'None\', \'10\', \'1\', \'False\', \'0\'], " + } + member_method { + name: "fit" + argspec: "args=[\'self\', \'x\', \'y\', \'batch_size\', \'epochs\', \'verbose\', \'callbacks\', \'validation_split\', \'validation_data\', \'shuffle\', \'class_weight\', \'sample_weight\', \'initial_epoch\', \'steps_per_epoch\', \'validation_steps\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\', \'None\', \'1\', \'1\', \'None\', \'0.0\', \'None\', \'True\', \'None\', \'None\', \'0\', \'None\', \'None\'], " + } + member_method { + name: "fit_generator" + argspec: "args=[\'self\', \'generator\', \'steps_per_epoch\', \'epochs\', \'verbose\', \'callbacks\', \'validation_data\', \'validation_steps\', \'class_weight\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'shuffle\', \'initial_epoch\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'1\', \'None\', \'None\', \'None\', \'None\', \'10\', \'1\', \'False\', \'True\', \'0\'], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_layer" + argspec: "args=[\'self\', \'name\', \'index\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "load_weights" + argspec: "args=[\'self\', \'filepath\', \'by_name\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "pop" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'x\', \'batch_size\', \'verbose\', \'steps\'], varargs=None, keywords=None, defaults=[\'None\', \'0\', \'None\'], " + } + member_method { + name: "predict_classes" + argspec: "args=[\'self\', \'x\', \'batch_size\', \'verbose\'], varargs=None, keywords=None, defaults=[\'32\', \'0\'], " + } + member_method { + name: "predict_generator" + argspec: "args=[\'self\', \'generator\', \'steps\', \'max_queue_size\', \'workers\', \'use_multiprocessing\', \'verbose\'], varargs=None, keywords=None, defaults=[\'None\', \'10\', \'1\', \'False\', \'0\'], " + } + member_method { + name: "predict_on_batch" + argspec: "args=[\'self\', \'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "predict_proba" + argspec: "args=[\'self\', \'x\', \'batch_size\', \'verbose\'], varargs=None, keywords=None, defaults=[\'32\', \'0\'], " + } + member_method { + name: "reset_states" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "save" + argspec: "args=[\'self\', \'filepath\', \'overwrite\', \'include_optimizer\'], varargs=None, keywords=None, defaults=[\'True\', \'True\'], " + } + member_method { + name: "save_weights" + argspec: "args=[\'self\', \'filepath\', \'overwrite\', \'save_format\'], varargs=None, keywords=None, defaults=[\'True\', \'None\'], " + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "summary" + argspec: "args=[\'self\', \'line_length\', \'positions\', \'print_fn\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "symbolic_set_inputs" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "test_on_batch" + argspec: "args=[\'self\', \'x\', \'y\', \'sample_weight\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "to_json" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "to_yaml" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "train_on_batch" + argspec: "args=[\'self\', \'x\', \'y\', \'sample_weight\', \'class_weight\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.models.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.models.pbtxt new file mode 100644 index 0000000000..8ba0e7480b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.models.pbtxt @@ -0,0 +1,31 @@ +path: "tensorflow.keras.models" +tf_module { + member { + name: "Model" + mtype: "" + } + member { + name: "Sequential" + mtype: "" + } + member_method { + name: "load_model" + argspec: "args=[\'filepath\', \'custom_objects\', \'compile\'], varargs=None, keywords=None, defaults=[\'None\', \'True\'], " + } + member_method { + name: "model_from_config" + argspec: "args=[\'config\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "model_from_json" + argspec: "args=[\'json_string\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "model_from_yaml" + argspec: "args=[\'yaml_string\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "save_model" + argspec: "args=[\'model\', \'filepath\', \'overwrite\', \'include_optimizer\'], varargs=None, keywords=None, defaults=[\'True\', \'True\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-adadelta.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-adadelta.pbtxt new file mode 100644 index 0000000000..b9ce154bdd --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-adadelta.pbtxt @@ -0,0 +1,34 @@ +path: "tensorflow.keras.optimizers.Adadelta" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'lr\', \'rho\', \'epsilon\', \'decay\'], varargs=None, keywords=kwargs, defaults=[\'1.0\', \'0.95\', \'None\', \'0.0\'], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_gradients" + argspec: "args=[\'self\', \'loss\', \'params\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates" + argspec: "args=[\'self\', \'loss\', \'params\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-adagrad.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-adagrad.pbtxt new file mode 100644 index 0000000000..d0dc9e37a3 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-adagrad.pbtxt @@ -0,0 +1,34 @@ +path: "tensorflow.keras.optimizers.Adagrad" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'lr\', \'epsilon\', \'decay\'], varargs=None, keywords=kwargs, defaults=[\'0.01\', \'None\', \'0.0\'], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_gradients" + argspec: "args=[\'self\', \'loss\', \'params\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates" + argspec: "args=[\'self\', \'loss\', \'params\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-adam.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-adam.pbtxt new file mode 100644 index 0000000000..06815fa99a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-adam.pbtxt @@ -0,0 +1,34 @@ +path: "tensorflow.keras.optimizers.Adam" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'lr\', \'beta_1\', \'beta_2\', \'epsilon\', \'decay\', \'amsgrad\'], varargs=None, keywords=kwargs, defaults=[\'0.001\', \'0.9\', \'0.999\', \'None\', \'0.0\', \'False\'], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_gradients" + argspec: "args=[\'self\', \'loss\', \'params\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates" + argspec: "args=[\'self\', \'loss\', \'params\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-adamax.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-adamax.pbtxt new file mode 100644 index 0000000000..47b55fdb44 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-adamax.pbtxt @@ -0,0 +1,34 @@ +path: "tensorflow.keras.optimizers.Adamax" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'lr\', \'beta_1\', \'beta_2\', \'epsilon\', \'decay\'], varargs=None, keywords=kwargs, defaults=[\'0.002\', \'0.9\', \'0.999\', \'None\', \'0.0\'], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_gradients" + argspec: "args=[\'self\', \'loss\', \'params\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates" + argspec: "args=[\'self\', \'loss\', \'params\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-nadam.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-nadam.pbtxt new file mode 100644 index 0000000000..8c63a7dda9 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-nadam.pbtxt @@ -0,0 +1,34 @@ +path: "tensorflow.keras.optimizers.Nadam" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'lr\', \'beta_1\', \'beta_2\', \'epsilon\', \'schedule_decay\'], varargs=None, keywords=kwargs, defaults=[\'0.002\', \'0.9\', \'0.999\', \'None\', \'0.004\'], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_gradients" + argspec: "args=[\'self\', \'loss\', \'params\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates" + argspec: "args=[\'self\', \'loss\', \'params\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-optimizer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-optimizer.pbtxt new file mode 100644 index 0000000000..53d64dae93 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-optimizer.pbtxt @@ -0,0 +1,33 @@ +path: "tensorflow.keras.optimizers.Optimizer" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_gradients" + argspec: "args=[\'self\', \'loss\', \'params\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates" + argspec: "args=[\'self\', \'loss\', \'params\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-r-m-sprop.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-r-m-sprop.pbtxt new file mode 100644 index 0000000000..a1e9b8cceb --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-r-m-sprop.pbtxt @@ -0,0 +1,34 @@ +path: "tensorflow.keras.optimizers.RMSprop" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'lr\', \'rho\', \'epsilon\', \'decay\'], varargs=None, keywords=kwargs, defaults=[\'0.001\', \'0.9\', \'None\', \'0.0\'], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_gradients" + argspec: "args=[\'self\', \'loss\', \'params\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates" + argspec: "args=[\'self\', \'loss\', \'params\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-s-g-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-s-g-d.pbtxt new file mode 100644 index 0000000000..a67fefb1ba --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.-s-g-d.pbtxt @@ -0,0 +1,34 @@ +path: "tensorflow.keras.optimizers.SGD" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'lr\', \'momentum\', \'decay\', \'nesterov\'], varargs=None, keywords=kwargs, defaults=[\'0.01\', \'0.0\', \'0.0\', \'False\'], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_gradients" + argspec: "args=[\'self\', \'loss\', \'params\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates" + argspec: "args=[\'self\', \'loss\', \'params\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.pbtxt new file mode 100644 index 0000000000..7257b02087 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.optimizers.pbtxt @@ -0,0 +1,47 @@ +path: "tensorflow.keras.optimizers" +tf_module { + member { + name: "Adadelta" + mtype: "" + } + member { + name: "Adagrad" + mtype: "" + } + member { + name: "Adam" + mtype: "" + } + member { + name: "Adamax" + mtype: "" + } + member { + name: "Nadam" + mtype: "" + } + member { + name: "Optimizer" + mtype: "" + } + member { + name: "RMSprop" + mtype: "" + } + member { + name: "SGD" + mtype: "" + } + member_method { + name: "deserialize" + argspec: "args=[\'config\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get" + argspec: "args=[\'identifier\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "serialize" + argspec: "args=[\'optimizer\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.pbtxt new file mode 100644 index 0000000000..754b3b84b0 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.pbtxt @@ -0,0 +1,83 @@ +path: "tensorflow.keras" +tf_module { + member { + name: "Model" + mtype: "" + } + member { + name: "Sequential" + mtype: "" + } + member { + name: "activations" + mtype: "" + } + member { + name: "applications" + mtype: "" + } + member { + name: "backend" + mtype: "" + } + member { + name: "callbacks" + mtype: "" + } + member { + name: "constraints" + mtype: "" + } + member { + name: "datasets" + mtype: "" + } + member { + name: "estimator" + mtype: "" + } + member { + name: "initializers" + mtype: "" + } + member { + name: "layers" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "metrics" + mtype: "" + } + member { + name: "models" + mtype: "" + } + member { + name: "optimizers" + mtype: "" + } + member { + name: "preprocessing" + mtype: "" + } + member { + name: "regularizers" + mtype: "" + } + member { + name: "utils" + mtype: "" + } + member { + name: "wrappers" + mtype: "" + } + member_method { + name: "Input" + argspec: "args=[\'shape\', \'batch_size\', \'name\', \'dtype\', \'sparse\', \'tensor\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\', \'None\', \'None\', \'False\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.image.-directory-iterator.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.image.-directory-iterator.pbtxt new file mode 100644 index 0000000000..dddace87dc --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.image.-directory-iterator.pbtxt @@ -0,0 +1,23 @@ +path: "tensorflow.keras.preprocessing.image.DirectoryIterator" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'directory\', \'image_data_generator\', \'target_size\', \'color_mode\', \'classes\', \'class_mode\', \'batch_size\', \'shuffle\', \'seed\', \'data_format\', \'save_to_dir\', \'save_prefix\', \'save_format\', \'follow_links\', \'subset\', \'interpolation\'], varargs=None, keywords=None, defaults=[\'(256, 256)\', \'rgb\', \'None\', \'categorical\', \'32\', \'True\', \'None\', \'None\', \'None\', \'\', \'png\', \'False\', \'None\', \'nearest\'], " + } + member_method { + name: "next" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "on_epoch_end" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "reset" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.image.-image-data-generator.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.image.-image-data-generator.pbtxt new file mode 100644 index 0000000000..c1e2e94f0b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.image.-image-data-generator.pbtxt @@ -0,0 +1,29 @@ +path: "tensorflow.keras.preprocessing.image.ImageDataGenerator" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'featurewise_center\', \'samplewise_center\', \'featurewise_std_normalization\', \'samplewise_std_normalization\', \'zca_whitening\', \'zca_epsilon\', \'rotation_range\', \'width_shift_range\', \'height_shift_range\', \'brightness_range\', \'shear_range\', \'zoom_range\', \'channel_shift_range\', \'fill_mode\', \'cval\', \'horizontal_flip\', \'vertical_flip\', \'rescale\', \'preprocessing_function\', \'data_format\', \'validation_split\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'False\', \'False\', \'False\', \'1e-06\', \'0.0\', \'0.0\', \'0.0\', \'None\', \'0.0\', \'0.0\', \'0.0\', \'nearest\', \'0.0\', \'False\', \'False\', \'None\', \'None\', \'None\', \'0.0\'], " + } + member_method { + name: "fit" + argspec: "args=[\'self\', \'x\', \'augment\', \'rounds\', \'seed\'], varargs=None, keywords=None, defaults=[\'False\', \'1\', \'None\'], " + } + member_method { + name: "flow" + argspec: "args=[\'self\', \'x\', \'y\', \'batch_size\', \'shuffle\', \'seed\', \'save_to_dir\', \'save_prefix\', \'save_format\', \'subset\'], varargs=None, keywords=None, defaults=[\'None\', \'32\', \'True\', \'None\', \'None\', \'\', \'png\', \'None\'], " + } + member_method { + name: "flow_from_directory" + argspec: "args=[\'self\', \'directory\', \'target_size\', \'color_mode\', \'classes\', \'class_mode\', \'batch_size\', \'shuffle\', \'seed\', \'save_to_dir\', \'save_prefix\', \'save_format\', \'follow_links\', \'subset\', \'interpolation\'], varargs=None, keywords=None, defaults=[\'(256, 256)\', \'rgb\', \'None\', \'categorical\', \'32\', \'True\', \'None\', \'None\', \'\', \'png\', \'False\', \'None\', \'nearest\'], " + } + member_method { + name: "random_transform" + argspec: "args=[\'self\', \'x\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "standardize" + argspec: "args=[\'self\', \'x\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.image.-iterator.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.image.-iterator.pbtxt new file mode 100644 index 0000000000..825d9f1d1d --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.image.-iterator.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.keras.preprocessing.image.Iterator" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'n\', \'batch_size\', \'shuffle\', \'seed\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "on_epoch_end" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "reset" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.image.-numpy-array-iterator.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.image.-numpy-array-iterator.pbtxt new file mode 100644 index 0000000000..75924a254a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.image.-numpy-array-iterator.pbtxt @@ -0,0 +1,23 @@ +path: "tensorflow.keras.preprocessing.image.NumpyArrayIterator" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'x\', \'y\', \'image_data_generator\', \'batch_size\', \'shuffle\', \'seed\', \'data_format\', \'save_to_dir\', \'save_prefix\', \'save_format\', \'subset\'], varargs=None, keywords=None, defaults=[\'32\', \'False\', \'None\', \'None\', \'None\', \'\', \'png\', \'None\'], " + } + member_method { + name: "next" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "on_epoch_end" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "reset" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.image.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.image.pbtxt new file mode 100644 index 0000000000..6b850dd6b7 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.image.pbtxt @@ -0,0 +1,63 @@ +path: "tensorflow.keras.preprocessing.image" +tf_module { + member { + name: "DirectoryIterator" + mtype: "" + } + member { + name: "ImageDataGenerator" + mtype: "" + } + member { + name: "Iterator" + mtype: "" + } + member { + name: "NumpyArrayIterator" + mtype: "" + } + member_method { + name: "apply_transform" + argspec: "args=[\'x\', \'transform_matrix\', \'channel_axis\', \'fill_mode\', \'cval\'], varargs=None, keywords=None, defaults=[\'0\', \'nearest\', \'0.0\'], " + } + member_method { + name: "array_to_img" + argspec: "args=[\'x\', \'data_format\', \'scale\'], varargs=None, keywords=None, defaults=[\'None\', \'True\'], " + } + member_method { + name: "flip_axis" + argspec: "args=[\'x\', \'axis\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "img_to_array" + argspec: "args=[\'img\', \'data_format\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "load_img" + argspec: "args=[\'path\', \'grayscale\', \'target_size\', \'interpolation\'], varargs=None, keywords=None, defaults=[\'False\', \'None\', \'nearest\'], " + } + member_method { + name: "random_brightness" + argspec: "args=[\'x\', \'brightness_range\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "random_channel_shift" + argspec: "args=[\'x\', \'intensity\', \'channel_axis\'], varargs=None, keywords=None, defaults=[\'0\'], " + } + member_method { + name: "random_rotation" + argspec: "args=[\'x\', \'rg\', \'row_axis\', \'col_axis\', \'channel_axis\', \'fill_mode\', \'cval\'], varargs=None, keywords=None, defaults=[\'1\', \'2\', \'0\', \'nearest\', \'0.0\'], " + } + member_method { + name: "random_shear" + argspec: "args=[\'x\', \'intensity\', \'row_axis\', \'col_axis\', \'channel_axis\', \'fill_mode\', \'cval\'], varargs=None, keywords=None, defaults=[\'1\', \'2\', \'0\', \'nearest\', \'0.0\'], " + } + member_method { + name: "random_shift" + argspec: "args=[\'x\', \'wrg\', \'hrg\', \'row_axis\', \'col_axis\', \'channel_axis\', \'fill_mode\', \'cval\'], varargs=None, keywords=None, defaults=[\'1\', \'2\', \'0\', \'nearest\', \'0.0\'], " + } + member_method { + name: "random_zoom" + argspec: "args=[\'x\', \'zoom_range\', \'row_axis\', \'col_axis\', \'channel_axis\', \'fill_mode\', \'cval\'], varargs=None, keywords=None, defaults=[\'1\', \'2\', \'0\', \'nearest\', \'0.0\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.pbtxt new file mode 100644 index 0000000000..5a78581fc5 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.pbtxt @@ -0,0 +1,15 @@ +path: "tensorflow.keras.preprocessing" +tf_module { + member { + name: "image" + mtype: "" + } + member { + name: "sequence" + mtype: "" + } + member { + name: "text" + mtype: "" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.sequence.-timeseries-generator.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.sequence.-timeseries-generator.pbtxt new file mode 100644 index 0000000000..326b1fa4fd --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.sequence.-timeseries-generator.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.keras.preprocessing.sequence.TimeseriesGenerator" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'data\', \'targets\', \'length\', \'sampling_rate\', \'stride\', \'start_index\', \'end_index\', \'shuffle\', \'reverse\', \'batch_size\'], varargs=None, keywords=None, defaults=[\'1\', \'1\', \'0\', \'None\', \'False\', \'False\', \'128\'], " + } + member_method { + name: "on_epoch_end" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.sequence.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.sequence.pbtxt new file mode 100644 index 0000000000..cf59f8a272 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.sequence.pbtxt @@ -0,0 +1,19 @@ +path: "tensorflow.keras.preprocessing.sequence" +tf_module { + member { + name: "TimeseriesGenerator" + mtype: "" + } + member_method { + name: "make_sampling_table" + argspec: "args=[\'size\', \'sampling_factor\'], varargs=None, keywords=None, defaults=[\'1e-05\'], " + } + member_method { + name: "pad_sequences" + argspec: "args=[\'sequences\', \'maxlen\', \'dtype\', \'padding\', \'truncating\', \'value\'], varargs=None, keywords=None, defaults=[\'None\', \'int32\', \'pre\', \'pre\', \'0.0\'], " + } + member_method { + name: "skipgrams" + argspec: "args=[\'sequence\', \'vocabulary_size\', \'window_size\', \'negative_samples\', \'shuffle\', \'categorical\', \'sampling_table\', \'seed\'], varargs=None, keywords=None, defaults=[\'4\', \'1.0\', \'True\', \'False\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.text.-tokenizer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.text.-tokenizer.pbtxt new file mode 100644 index 0000000000..b42b12b6c0 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.text.-tokenizer.pbtxt @@ -0,0 +1,33 @@ +path: "tensorflow.keras.preprocessing.text.Tokenizer" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'num_words\', \'filters\', \'lower\', \'split\', \'char_level\', \'oov_token\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'!\"#$%&()*+,-./:;<=>?@[\\\\]^_`{|}~\\t\\n\', \'True\', \' \', \'False\', \'None\'], " + } + member_method { + name: "fit_on_sequences" + argspec: "args=[\'self\', \'sequences\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "fit_on_texts" + argspec: "args=[\'self\', \'texts\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "sequences_to_matrix" + argspec: "args=[\'self\', \'sequences\', \'mode\'], varargs=None, keywords=None, defaults=[\'binary\'], " + } + member_method { + name: "texts_to_matrix" + argspec: "args=[\'self\', \'texts\', \'mode\'], varargs=None, keywords=None, defaults=[\'binary\'], " + } + member_method { + name: "texts_to_sequences" + argspec: "args=[\'self\', \'texts\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "texts_to_sequences_generator" + argspec: "args=[\'self\', \'texts\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.text.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.text.pbtxt new file mode 100644 index 0000000000..50b54fc7e1 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.preprocessing.text.pbtxt @@ -0,0 +1,19 @@ +path: "tensorflow.keras.preprocessing.text" +tf_module { + member { + name: "Tokenizer" + mtype: "" + } + member_method { + name: "hashing_trick" + argspec: "args=[\'text\', \'n\', \'hash_function\', \'filters\', \'lower\', \'split\'], varargs=None, keywords=None, defaults=[\'None\', \'!\"#$%&()*+,-./:;<=>?@[\\\\]^_`{|}~\\t\\n\', \'True\', \' \'], " + } + member_method { + name: "one_hot" + argspec: "args=[\'text\', \'n\', \'filters\', \'lower\', \'split\'], varargs=None, keywords=None, defaults=[\'!\"#$%&()*+,-./:;<=>?@[\\\\]^_`{|}~\\t\\n\', \'True\', \' \'], " + } + member_method { + name: "text_to_word_sequence" + argspec: "args=[\'text\', \'filters\', \'lower\', \'split\'], varargs=None, keywords=None, defaults=[\'!\"#$%&()*+,-./:;<=>?@[\\\\]^_`{|}~\\t\\n\', \'True\', \' \'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.regularizers.-l1-l2.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.regularizers.-l1-l2.pbtxt new file mode 100644 index 0000000000..a45fb7b55e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.regularizers.-l1-l2.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.keras.regularizers.L1L2" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'l1\', \'l2\'], varargs=None, keywords=None, defaults=[\'0.0\', \'0.0\'], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.regularizers.-regularizer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.regularizers.-regularizer.pbtxt new file mode 100644 index 0000000000..641001a646 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.regularizers.-regularizer.pbtxt @@ -0,0 +1,12 @@ +path: "tensorflow.keras.regularizers.Regularizer" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.regularizers.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.regularizers.pbtxt new file mode 100644 index 0000000000..bb10d41d70 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.regularizers.pbtxt @@ -0,0 +1,35 @@ +path: "tensorflow.keras.regularizers" +tf_module { + member { + name: "L1L2" + mtype: "" + } + member { + name: "Regularizer" + mtype: "" + } + member_method { + name: "deserialize" + argspec: "args=[\'config\', \'custom_objects\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get" + argspec: "args=[\'identifier\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "l1" + argspec: "args=[\'l\'], varargs=None, keywords=None, defaults=[\'0.01\'], " + } + member_method { + name: "l1_l2" + argspec: "args=[\'l1\', \'l2\'], varargs=None, keywords=None, defaults=[\'0.01\', \'0.01\'], " + } + member_method { + name: "l2" + argspec: "args=[\'l\'], varargs=None, keywords=None, defaults=[\'0.01\'], " + } + member_method { + name: "serialize" + argspec: "args=[\'regularizer\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-custom-object-scope.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-custom-object-scope.pbtxt new file mode 100644 index 0000000000..109682046b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-custom-object-scope.pbtxt @@ -0,0 +1,9 @@ +path: "tensorflow.keras.utils.CustomObjectScope" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=args, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-generator-enqueuer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-generator-enqueuer.pbtxt new file mode 100644 index 0000000000..939fd547d0 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-generator-enqueuer.pbtxt @@ -0,0 +1,26 @@ +path: "tensorflow.keras.utils.GeneratorEnqueuer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'generator\', \'use_multiprocessing\', \'wait_time\', \'seed\'], varargs=None, keywords=None, defaults=[\'False\', \'0.05\', \'None\'], " + } + member_method { + name: "get" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "is_running" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "start" + argspec: "args=[\'self\', \'workers\', \'max_queue_size\'], varargs=None, keywords=None, defaults=[\'1\', \'10\'], " + } + member_method { + name: "stop" + argspec: "args=[\'self\', \'timeout\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-h-d-f5-matrix.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-h-d-f5-matrix.pbtxt new file mode 100644 index 0000000000..6b832051a9 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-h-d-f5-matrix.pbtxt @@ -0,0 +1,29 @@ +path: "tensorflow.keras.utils.HDF5Matrix" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "dtype" + mtype: "" + } + member { + name: "ndim" + mtype: "" + } + member { + name: "refs" + mtype: "" + } + member { + name: "shape" + mtype: "" + } + member { + name: "size" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'datapath\', \'dataset\', \'start\', \'end\', \'normalizer\'], varargs=None, keywords=None, defaults=[\'0\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-progbar.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-progbar.pbtxt new file mode 100644 index 0000000000..be4496e753 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-progbar.pbtxt @@ -0,0 +1,17 @@ +path: "tensorflow.keras.utils.Progbar" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'target\', \'width\', \'verbose\', \'interval\', \'stateful_metrics\'], varargs=None, keywords=None, defaults=[\'30\', \'1\', \'0.05\', \'None\'], " + } + member_method { + name: "add" + argspec: "args=[\'self\', \'n\', \'values\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "update" + argspec: "args=[\'self\', \'current\', \'values\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-sequence-enqueuer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-sequence-enqueuer.pbtxt new file mode 100644 index 0000000000..a9e499d100 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-sequence-enqueuer.pbtxt @@ -0,0 +1,24 @@ +path: "tensorflow.keras.utils.SequenceEnqueuer" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "get" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "is_running" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "start" + argspec: "args=[\'self\', \'workers\', \'max_queue_size\'], varargs=None, keywords=None, defaults=[\'1\', \'10\'], " + } + member_method { + name: "stop" + argspec: "args=[\'self\', \'timeout\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-sequence.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-sequence.pbtxt new file mode 100644 index 0000000000..e2dc932dc8 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.utils.-sequence.pbtxt @@ -0,0 +1,12 @@ +path: "tensorflow.keras.utils.Sequence" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "on_epoch_end" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.utils.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.utils.pbtxt new file mode 100644 index 0000000000..4d7a1519ce --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.utils.pbtxt @@ -0,0 +1,67 @@ +path: "tensorflow.keras.utils" +tf_module { + member { + name: "CustomObjectScope" + mtype: "" + } + member { + name: "GeneratorEnqueuer" + mtype: "" + } + member { + name: "HDF5Matrix" + mtype: "" + } + member { + name: "Progbar" + mtype: "" + } + member { + name: "Sequence" + mtype: "" + } + member { + name: "SequenceEnqueuer" + mtype: "" + } + member_method { + name: "convert_all_kernels_in_model" + argspec: "args=[\'model\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "custom_object_scope" + argspec: "args=[], varargs=args, keywords=None, defaults=None" + } + member_method { + name: "deserialize_keras_object" + argspec: "args=[\'identifier\', \'module_objects\', \'custom_objects\', \'printable_module_name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'object\'], " + } + member_method { + name: "get_custom_objects" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_file" + argspec: "args=[\'fname\', \'origin\', \'untar\', \'md5_hash\', \'file_hash\', \'cache_subdir\', \'hash_algorithm\', \'extract\', \'archive_format\', \'cache_dir\'], varargs=None, keywords=None, defaults=[\'False\', \'None\', \'None\', \'datasets\', \'auto\', \'False\', \'auto\', \'None\'], " + } + member_method { + name: "multi_gpu_model" + argspec: "args=[\'model\', \'gpus\', \'cpu_merge\', \'cpu_relocation\'], varargs=None, keywords=None, defaults=[\'True\', \'False\'], " + } + member_method { + name: "normalize" + argspec: "args=[\'x\', \'axis\', \'order\'], varargs=None, keywords=None, defaults=[\'-1\', \'2\'], " + } + member_method { + name: "plot_model" + argspec: "args=[\'model\', \'to_file\', \'show_shapes\', \'show_layer_names\', \'rankdir\'], varargs=None, keywords=None, defaults=[\'model.png\', \'False\', \'True\', \'TB\'], " + } + member_method { + name: "serialize_keras_object" + argspec: "args=[\'instance\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "to_categorical" + argspec: "args=[\'y\', \'num_classes\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.wrappers.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.wrappers.pbtxt new file mode 100644 index 0000000000..0b2fac9b7d --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.wrappers.pbtxt @@ -0,0 +1,7 @@ +path: "tensorflow.keras.wrappers" +tf_module { + member { + name: "scikit_learn" + mtype: "" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.wrappers.scikit_learn.-keras-classifier.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.wrappers.scikit_learn.-keras-classifier.pbtxt new file mode 100644 index 0000000000..67cca3af41 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.wrappers.scikit_learn.-keras-classifier.pbtxt @@ -0,0 +1,42 @@ +path: "tensorflow.keras.wrappers.scikit_learn.KerasClassifier" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'build_fn\'], varargs=None, keywords=sk_params, defaults=[\'None\'], " + } + member_method { + name: "check_params" + argspec: "args=[\'self\', \'params\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "filter_sk_params" + argspec: "args=[\'self\', \'fn\', \'override\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "fit" + argspec: "args=[\'self\', \'x\', \'y\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "get_params" + argspec: "args=[\'self\'], varargs=None, keywords=params, defaults=None" + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'x\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "predict_proba" + argspec: "args=[\'self\', \'x\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "score" + argspec: "args=[\'self\', \'x\', \'y\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "set_params" + argspec: "args=[\'self\'], varargs=None, keywords=params, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.wrappers.scikit_learn.-keras-regressor.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.wrappers.scikit_learn.-keras-regressor.pbtxt new file mode 100644 index 0000000000..f4b9b7e277 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.wrappers.scikit_learn.-keras-regressor.pbtxt @@ -0,0 +1,38 @@ +path: "tensorflow.keras.wrappers.scikit_learn.KerasRegressor" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'build_fn\'], varargs=None, keywords=sk_params, defaults=[\'None\'], " + } + member_method { + name: "check_params" + argspec: "args=[\'self\', \'params\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "filter_sk_params" + argspec: "args=[\'self\', \'fn\', \'override\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "fit" + argspec: "args=[\'self\', \'x\', \'y\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "get_params" + argspec: "args=[\'self\'], varargs=None, keywords=params, defaults=None" + } + member_method { + name: "predict" + argspec: "args=[\'self\', \'x\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "score" + argspec: "args=[\'self\', \'x\', \'y\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "set_params" + argspec: "args=[\'self\'], varargs=None, keywords=params, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.keras.wrappers.scikit_learn.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.keras.wrappers.scikit_learn.pbtxt new file mode 100644 index 0000000000..fbd4d13387 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.keras.wrappers.scikit_learn.pbtxt @@ -0,0 +1,11 @@ +path: "tensorflow.keras.wrappers.scikit_learn" +tf_module { + member { + name: "KerasClassifier" + mtype: "" + } + member { + name: "KerasRegressor" + mtype: "" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.layers.-average-pooling1-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.layers.-average-pooling1-d.pbtxt new file mode 100644 index 0000000000..c82e67526b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.layers.-average-pooling1-d.pbtxt @@ -0,0 +1,186 @@ +path: "tensorflow.layers.AveragePooling1D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'pool_size\', \'strides\', \'padding\', \'data_format\', \'name\'], varargs=None, keywords=kwargs, defaults=[\'valid\', \'channels_last\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.layers.-average-pooling2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.layers.-average-pooling2-d.pbtxt new file mode 100644 index 0000000000..1d031cb5f8 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.layers.-average-pooling2-d.pbtxt @@ -0,0 +1,186 @@ +path: "tensorflow.layers.AveragePooling2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'pool_size\', \'strides\', \'padding\', \'data_format\', \'name\'], varargs=None, keywords=kwargs, defaults=[\'valid\', \'channels_last\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.layers.-average-pooling3-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.layers.-average-pooling3-d.pbtxt new file mode 100644 index 0000000000..a8dda6655d --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.layers.-average-pooling3-d.pbtxt @@ -0,0 +1,186 @@ +path: "tensorflow.layers.AveragePooling3D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'pool_size\', \'strides\', \'padding\', \'data_format\', \'name\'], varargs=None, keywords=kwargs, defaults=[\'valid\', \'channels_last\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.layers.-batch-normalization.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.layers.-batch-normalization.pbtxt new file mode 100644 index 0000000000..97f65ed894 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.layers.-batch-normalization.pbtxt @@ -0,0 +1,185 @@ +path: "tensorflow.layers.BatchNormalization" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'axis\', \'momentum\', \'epsilon\', \'center\', \'scale\', \'beta_initializer\', \'gamma_initializer\', \'moving_mean_initializer\', \'moving_variance_initializer\', \'beta_regularizer\', \'gamma_regularizer\', \'beta_constraint\', \'gamma_constraint\', \'renorm\', \'renorm_clipping\', \'renorm_momentum\', \'fused\', \'trainable\', \'virtual_batch_size\', \'adjustment\', \'name\'], varargs=None, keywords=kwargs, defaults=[\'-1\', \'0.99\', \'0.001\', \'True\', \'True\', \'\', \'\', \'\', \'\', \'None\', \'None\', \'None\', \'None\', \'False\', \'None\', \'0.99\', \'None\', \'True\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'training\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.layers.-conv1-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.layers.-conv1-d.pbtxt new file mode 100644 index 0000000000..ccd9578f0d --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.layers.-conv1-d.pbtxt @@ -0,0 +1,186 @@ +path: "tensorflow.layers.Conv1D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\', \'trainable\', \'name\'], varargs=None, keywords=kwargs, defaults=[\'1\', \'valid\', \'channels_last\', \'1\', \'None\', \'True\', \'None\', \'\', \'None\', \'None\', \'None\', \'None\', \'None\', \'True\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.layers.-conv2-d-transpose.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.layers.-conv2-d-transpose.pbtxt new file mode 100644 index 0000000000..9cbb58d721 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.layers.-conv2-d-transpose.pbtxt @@ -0,0 +1,187 @@ +path: "tensorflow.layers.Conv2DTranspose" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\', \'trainable\', \'name\'], varargs=None, keywords=kwargs, defaults=[\'(1, 1)\', \'valid\', \'channels_last\', \'None\', \'True\', \'None\', \'\', \'None\', \'None\', \'None\', \'None\', \'None\', \'True\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.layers.-conv2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.layers.-conv2-d.pbtxt new file mode 100644 index 0000000000..c75ea3911e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.layers.-conv2-d.pbtxt @@ -0,0 +1,186 @@ +path: "tensorflow.layers.Conv2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\', \'trainable\', \'name\'], varargs=None, keywords=kwargs, defaults=[\'(1, 1)\', \'valid\', \'channels_last\', \'(1, 1)\', \'None\', \'True\', \'None\', \'\', \'None\', \'None\', \'None\', \'None\', \'None\', \'True\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.layers.-conv3-d-transpose.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.layers.-conv3-d-transpose.pbtxt new file mode 100644 index 0000000000..5dc834e514 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.layers.-conv3-d-transpose.pbtxt @@ -0,0 +1,187 @@ +path: "tensorflow.layers.Conv3DTranspose" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\', \'trainable\', \'name\'], varargs=None, keywords=kwargs, defaults=[\'(1, 1, 1)\', \'valid\', \'channels_last\', \'None\', \'True\', \'None\', \'\', \'None\', \'None\', \'None\', \'None\', \'None\', \'True\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.layers.-conv3-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.layers.-conv3-d.pbtxt new file mode 100644 index 0000000000..96ab209874 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.layers.-conv3-d.pbtxt @@ -0,0 +1,186 @@ +path: "tensorflow.layers.Conv3D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\', \'trainable\', \'name\'], varargs=None, keywords=kwargs, defaults=[\'(1, 1, 1)\', \'valid\', \'channels_last\', \'(1, 1, 1)\', \'None\', \'True\', \'None\', \'\', \'None\', \'None\', \'None\', \'None\', \'None\', \'True\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.layers.-dense.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.layers.-dense.pbtxt new file mode 100644 index 0000000000..7e9656b352 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.layers.-dense.pbtxt @@ -0,0 +1,185 @@ +path: "tensorflow.layers.Dense" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'units\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\', \'trainable\', \'name\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'True\', \'None\', \'\', \'None\', \'None\', \'None\', \'None\', \'None\', \'True\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.layers.-dropout.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.layers.-dropout.pbtxt new file mode 100644 index 0000000000..e9a2269a6e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.layers.-dropout.pbtxt @@ -0,0 +1,185 @@ +path: "tensorflow.layers.Dropout" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'rate\', \'noise_shape\', \'seed\', \'name\'], varargs=None, keywords=kwargs, defaults=[\'0.5\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'training\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.layers.-flatten.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.layers.-flatten.pbtxt new file mode 100644 index 0000000000..7d2eaaab2a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.layers.-flatten.pbtxt @@ -0,0 +1,185 @@ +path: "tensorflow.layers.Flatten" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'data_format\'], varargs=None, keywords=kwargs, defaults=[\'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.layers.-input-spec.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.layers.-input-spec.pbtxt new file mode 100644 index 0000000000..fd02c919ae --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.layers.-input-spec.pbtxt @@ -0,0 +1,9 @@ +path: "tensorflow.layers.InputSpec" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'dtype\', \'shape\', \'ndim\', \'max_ndim\', \'min_ndim\', \'axes\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.layers.-layer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.layers.-layer.pbtxt new file mode 100644 index 0000000000..8bc3eb26e9 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.layers.-layer.pbtxt @@ -0,0 +1,183 @@ +path: "tensorflow.layers.Layer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'trainable\', \'name\', \'dtype\'], varargs=None, keywords=kwargs, defaults=[\'True\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.layers.-max-pooling1-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.layers.-max-pooling1-d.pbtxt new file mode 100644 index 0000000000..6a0dcce56a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.layers.-max-pooling1-d.pbtxt @@ -0,0 +1,186 @@ +path: "tensorflow.layers.MaxPooling1D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'pool_size\', \'strides\', \'padding\', \'data_format\', \'name\'], varargs=None, keywords=kwargs, defaults=[\'valid\', \'channels_last\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.layers.-max-pooling2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.layers.-max-pooling2-d.pbtxt new file mode 100644 index 0000000000..b6c84edf2a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.layers.-max-pooling2-d.pbtxt @@ -0,0 +1,186 @@ +path: "tensorflow.layers.MaxPooling2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'pool_size\', \'strides\', \'padding\', \'data_format\', \'name\'], varargs=None, keywords=kwargs, defaults=[\'valid\', \'channels_last\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.layers.-max-pooling3-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.layers.-max-pooling3-d.pbtxt new file mode 100644 index 0000000000..062a02fa59 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.layers.-max-pooling3-d.pbtxt @@ -0,0 +1,186 @@ +path: "tensorflow.layers.MaxPooling3D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'pool_size\', \'strides\', \'padding\', \'data_format\', \'name\'], varargs=None, keywords=kwargs, defaults=[\'valid\', \'channels_last\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.layers.-separable-conv1-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.layers.-separable-conv1-d.pbtxt new file mode 100644 index 0000000000..eaad0fb23e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.layers.-separable-conv1-d.pbtxt @@ -0,0 +1,187 @@ +path: "tensorflow.layers.SeparableConv1D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\', \'depth_multiplier\', \'activation\', \'use_bias\', \'depthwise_initializer\', \'pointwise_initializer\', \'bias_initializer\', \'depthwise_regularizer\', \'pointwise_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'depthwise_constraint\', \'pointwise_constraint\', \'bias_constraint\', \'trainable\', \'name\'], varargs=None, keywords=kwargs, defaults=[\'1\', \'valid\', \'channels_last\', \'1\', \'1\', \'None\', \'True\', \'None\', \'None\', \'\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'True\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.layers.-separable-conv2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.layers.-separable-conv2-d.pbtxt new file mode 100644 index 0000000000..ece28a8ce9 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.layers.-separable-conv2-d.pbtxt @@ -0,0 +1,187 @@ +path: "tensorflow.layers.SeparableConv2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\', \'depth_multiplier\', \'activation\', \'use_bias\', \'depthwise_initializer\', \'pointwise_initializer\', \'bias_initializer\', \'depthwise_regularizer\', \'pointwise_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'depthwise_constraint\', \'pointwise_constraint\', \'bias_constraint\', \'trainable\', \'name\'], varargs=None, keywords=kwargs, defaults=[\'(1, 1)\', \'valid\', \'channels_last\', \'(1, 1)\', \'1\', \'None\', \'True\', \'None\', \'None\', \'\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'True\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.layers.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.layers.pbtxt new file mode 100644 index 0000000000..df74c32e1f --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.layers.pbtxt @@ -0,0 +1,147 @@ +path: "tensorflow.layers" +tf_module { + member { + name: "AveragePooling1D" + mtype: "" + } + member { + name: "AveragePooling2D" + mtype: "" + } + member { + name: "AveragePooling3D" + mtype: "" + } + member { + name: "BatchNormalization" + mtype: "" + } + member { + name: "Conv1D" + mtype: "" + } + member { + name: "Conv2D" + mtype: "" + } + member { + name: "Conv2DTranspose" + mtype: "" + } + member { + name: "Conv3D" + mtype: "" + } + member { + name: "Conv3DTranspose" + mtype: "" + } + member { + name: "Dense" + mtype: "" + } + member { + name: "Dropout" + mtype: "" + } + member { + name: "Flatten" + mtype: "" + } + member { + name: "InputSpec" + mtype: "" + } + member { + name: "Layer" + mtype: "" + } + member { + name: "MaxPooling1D" + mtype: "" + } + member { + name: "MaxPooling2D" + mtype: "" + } + member { + name: "MaxPooling3D" + mtype: "" + } + member { + name: "SeparableConv1D" + mtype: "" + } + member { + name: "SeparableConv2D" + mtype: "" + } + member_method { + name: "average_pooling1d" + argspec: "args=[\'inputs\', \'pool_size\', \'strides\', \'padding\', \'data_format\', \'name\'], varargs=None, keywords=None, defaults=[\'valid\', \'channels_last\', \'None\'], " + } + member_method { + name: "average_pooling2d" + argspec: "args=[\'inputs\', \'pool_size\', \'strides\', \'padding\', \'data_format\', \'name\'], varargs=None, keywords=None, defaults=[\'valid\', \'channels_last\', \'None\'], " + } + member_method { + name: "average_pooling3d" + argspec: "args=[\'inputs\', \'pool_size\', \'strides\', \'padding\', \'data_format\', \'name\'], varargs=None, keywords=None, defaults=[\'valid\', \'channels_last\', \'None\'], " + } + member_method { + name: "batch_normalization" + argspec: "args=[\'inputs\', \'axis\', \'momentum\', \'epsilon\', \'center\', \'scale\', \'beta_initializer\', \'gamma_initializer\', \'moving_mean_initializer\', \'moving_variance_initializer\', \'beta_regularizer\', \'gamma_regularizer\', \'beta_constraint\', \'gamma_constraint\', \'training\', \'trainable\', \'name\', \'reuse\', \'renorm\', \'renorm_clipping\', \'renorm_momentum\', \'fused\', \'virtual_batch_size\', \'adjustment\'], varargs=None, keywords=None, defaults=[\'-1\', \'0.99\', \'0.001\', \'True\', \'True\', \'\', \'\', \'\', \'\', \'None\', \'None\', \'None\', \'None\', \'False\', \'True\', \'None\', \'None\', \'False\', \'None\', \'0.99\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "conv1d" + argspec: "args=[\'inputs\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\', \'trainable\', \'name\', \'reuse\'], varargs=None, keywords=None, defaults=[\'1\', \'valid\', \'channels_last\', \'1\', \'None\', \'True\', \'None\', \'\', \'None\', \'None\', \'None\', \'None\', \'None\', \'True\', \'None\', \'None\'], " + } + member_method { + name: "conv2d" + argspec: "args=[\'inputs\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\', \'trainable\', \'name\', \'reuse\'], varargs=None, keywords=None, defaults=[\'(1, 1)\', \'valid\', \'channels_last\', \'(1, 1)\', \'None\', \'True\', \'None\', \'\', \'None\', \'None\', \'None\', \'None\', \'None\', \'True\', \'None\', \'None\'], " + } + member_method { + name: "conv2d_transpose" + argspec: "args=[\'inputs\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\', \'trainable\', \'name\', \'reuse\'], varargs=None, keywords=None, defaults=[\'(1, 1)\', \'valid\', \'channels_last\', \'None\', \'True\', \'None\', \'\', \'None\', \'None\', \'None\', \'None\', \'None\', \'True\', \'None\', \'None\'], " + } + member_method { + name: "conv3d" + argspec: "args=[\'inputs\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\', \'trainable\', \'name\', \'reuse\'], varargs=None, keywords=None, defaults=[\'(1, 1, 1)\', \'valid\', \'channels_last\', \'(1, 1, 1)\', \'None\', \'True\', \'None\', \'\', \'None\', \'None\', \'None\', \'None\', \'None\', \'True\', \'None\', \'None\'], " + } + member_method { + name: "conv3d_transpose" + argspec: "args=[\'inputs\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\', \'trainable\', \'name\', \'reuse\'], varargs=None, keywords=None, defaults=[\'(1, 1, 1)\', \'valid\', \'channels_last\', \'None\', \'True\', \'None\', \'\', \'None\', \'None\', \'None\', \'None\', \'None\', \'True\', \'None\', \'None\'], " + } + member_method { + name: "dense" + argspec: "args=[\'inputs\', \'units\', \'activation\', \'use_bias\', \'kernel_initializer\', \'bias_initializer\', \'kernel_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'kernel_constraint\', \'bias_constraint\', \'trainable\', \'name\', \'reuse\'], varargs=None, keywords=None, defaults=[\'None\', \'True\', \'None\', \'\', \'None\', \'None\', \'None\', \'None\', \'None\', \'True\', \'None\', \'None\'], " + } + member_method { + name: "dropout" + argspec: "args=[\'inputs\', \'rate\', \'noise_shape\', \'seed\', \'training\', \'name\'], varargs=None, keywords=None, defaults=[\'0.5\', \'None\', \'None\', \'False\', \'None\'], " + } + member_method { + name: "flatten" + argspec: "args=[\'inputs\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "max_pooling1d" + argspec: "args=[\'inputs\', \'pool_size\', \'strides\', \'padding\', \'data_format\', \'name\'], varargs=None, keywords=None, defaults=[\'valid\', \'channels_last\', \'None\'], " + } + member_method { + name: "max_pooling2d" + argspec: "args=[\'inputs\', \'pool_size\', \'strides\', \'padding\', \'data_format\', \'name\'], varargs=None, keywords=None, defaults=[\'valid\', \'channels_last\', \'None\'], " + } + member_method { + name: "max_pooling3d" + argspec: "args=[\'inputs\', \'pool_size\', \'strides\', \'padding\', \'data_format\', \'name\'], varargs=None, keywords=None, defaults=[\'valid\', \'channels_last\', \'None\'], " + } + member_method { + name: "separable_conv1d" + argspec: "args=[\'inputs\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\', \'depth_multiplier\', \'activation\', \'use_bias\', \'depthwise_initializer\', \'pointwise_initializer\', \'bias_initializer\', \'depthwise_regularizer\', \'pointwise_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'depthwise_constraint\', \'pointwise_constraint\', \'bias_constraint\', \'trainable\', \'name\', \'reuse\'], varargs=None, keywords=None, defaults=[\'1\', \'valid\', \'channels_last\', \'1\', \'1\', \'None\', \'True\', \'None\', \'None\', \'\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'True\', \'None\', \'None\'], " + } + member_method { + name: "separable_conv2d" + argspec: "args=[\'inputs\', \'filters\', \'kernel_size\', \'strides\', \'padding\', \'data_format\', \'dilation_rate\', \'depth_multiplier\', \'activation\', \'use_bias\', \'depthwise_initializer\', \'pointwise_initializer\', \'bias_initializer\', \'depthwise_regularizer\', \'pointwise_regularizer\', \'bias_regularizer\', \'activity_regularizer\', \'depthwise_constraint\', \'pointwise_constraint\', \'bias_constraint\', \'trainable\', \'name\', \'reuse\'], varargs=None, keywords=None, defaults=[\'(1, 1)\', \'valid\', \'channels_last\', \'(1, 1)\', \'1\', \'None\', \'True\', \'None\', \'None\', \'\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'True\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-block-diag.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-block-diag.__metaclass__.pbtxt new file mode 100644 index 0000000000..b6dee63176 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-block-diag.__metaclass__.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.linalg.LinearOperatorBlockDiag.__metaclass__" +tf_class { + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "mro" + } + member_method { + name: "register" + argspec: "args=[\'cls\', \'subclass\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-block-diag.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-block-diag.pbtxt new file mode 100644 index 0000000000..973705dae2 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-block-diag.pbtxt @@ -0,0 +1,134 @@ +path: "tensorflow.linalg.LinearOperatorBlockDiag" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "batch_shape" + mtype: "" + } + member { + name: "domain_dimension" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph_parents" + mtype: "" + } + member { + name: "is_non_singular" + mtype: "" + } + member { + name: "is_positive_definite" + mtype: "" + } + member { + name: "is_self_adjoint" + mtype: "" + } + member { + name: "is_square" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "operators" + mtype: "" + } + member { + name: "range_dimension" + mtype: "" + } + member { + name: "shape" + mtype: "" + } + member { + name: "tensor_rank" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'operators\', \'is_non_singular\', \'is_self_adjoint\', \'is_positive_definite\', \'is_square\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\', \'None\'], " + } + member_method { + name: "add_to_tensor" + argspec: "args=[\'self\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'add_to_tensor\'], " + } + member_method { + name: "assert_non_singular" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_non_singular\'], " + } + member_method { + name: "assert_positive_definite" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_positive_definite\'], " + } + member_method { + name: "assert_self_adjoint" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_self_adjoint\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'det\'], " + } + member_method { + name: "diag_part" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'diag_part\'], " + } + member_method { + name: "domain_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'domain_dimension_tensor\'], " + } + member_method { + name: "log_abs_determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'log_abs_det\'], " + } + member_method { + name: "matmul" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'matmul\'], " + } + member_method { + name: "matvec" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'matvec\'], " + } + member_method { + name: "range_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'range_dimension_tensor\'], " + } + member_method { + name: "shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'shape_tensor\'], " + } + member_method { + name: "solve" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'solve\'], " + } + member_method { + name: "solvevec" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'solve\'], " + } + member_method { + name: "tensor_rank_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'tensor_rank_tensor\'], " + } + member_method { + name: "to_dense" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'to_dense\'], " + } + member_method { + name: "trace" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'trace\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant.__metaclass__.pbtxt new file mode 100644 index 0000000000..3b33f3da97 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant.__metaclass__.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.linalg.LinearOperatorCirculant.__metaclass__" +tf_class { + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "mro" + } + member_method { + name: "register" + argspec: "args=[\'cls\', \'subclass\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant.pbtxt new file mode 100644 index 0000000000..de917706d5 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant.pbtxt @@ -0,0 +1,155 @@ +path: "tensorflow.linalg.LinearOperatorCirculant" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "batch_shape" + mtype: "" + } + member { + name: "block_depth" + mtype: "" + } + member { + name: "block_shape" + mtype: "" + } + member { + name: "domain_dimension" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph_parents" + mtype: "" + } + member { + name: "is_non_singular" + mtype: "" + } + member { + name: "is_positive_definite" + mtype: "" + } + member { + name: "is_self_adjoint" + mtype: "" + } + member { + name: "is_square" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "range_dimension" + mtype: "" + } + member { + name: "shape" + mtype: "" + } + member { + name: "spectrum" + mtype: "" + } + member { + name: "tensor_rank" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'spectrum\', \'input_output_dtype\', \'is_non_singular\', \'is_self_adjoint\', \'is_positive_definite\', \'is_square\', \'name\'], varargs=None, keywords=None, defaults=[\"\", \'None\', \'None\', \'None\', \'True\', \'LinearOperatorCirculant\'], " + } + member_method { + name: "add_to_tensor" + argspec: "args=[\'self\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'add_to_tensor\'], " + } + member_method { + name: "assert_hermitian_spectrum" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_hermitian_spectrum\'], " + } + member_method { + name: "assert_non_singular" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_non_singular\'], " + } + member_method { + name: "assert_positive_definite" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_positive_definite\'], " + } + member_method { + name: "assert_self_adjoint" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_self_adjoint\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "block_shape_tensor" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "convolution_kernel" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'convolution_kernel\'], " + } + member_method { + name: "determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'det\'], " + } + member_method { + name: "diag_part" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'diag_part\'], " + } + member_method { + name: "domain_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'domain_dimension_tensor\'], " + } + member_method { + name: "log_abs_determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'log_abs_det\'], " + } + member_method { + name: "matmul" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'matmul\'], " + } + member_method { + name: "matvec" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'matvec\'], " + } + member_method { + name: "range_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'range_dimension_tensor\'], " + } + member_method { + name: "shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'shape_tensor\'], " + } + member_method { + name: "solve" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'solve\'], " + } + member_method { + name: "solvevec" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'solve\'], " + } + member_method { + name: "tensor_rank_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'tensor_rank_tensor\'], " + } + member_method { + name: "to_dense" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'to_dense\'], " + } + member_method { + name: "trace" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'trace\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant2-d.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant2-d.__metaclass__.pbtxt new file mode 100644 index 0000000000..591bc9631a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant2-d.__metaclass__.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.linalg.LinearOperatorCirculant2D.__metaclass__" +tf_class { + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "mro" + } + member_method { + name: "register" + argspec: "args=[\'cls\', \'subclass\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant2-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant2-d.pbtxt new file mode 100644 index 0000000000..c4e6a21c3a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant2-d.pbtxt @@ -0,0 +1,155 @@ +path: "tensorflow.linalg.LinearOperatorCirculant2D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "batch_shape" + mtype: "" + } + member { + name: "block_depth" + mtype: "" + } + member { + name: "block_shape" + mtype: "" + } + member { + name: "domain_dimension" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph_parents" + mtype: "" + } + member { + name: "is_non_singular" + mtype: "" + } + member { + name: "is_positive_definite" + mtype: "" + } + member { + name: "is_self_adjoint" + mtype: "" + } + member { + name: "is_square" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "range_dimension" + mtype: "" + } + member { + name: "shape" + mtype: "" + } + member { + name: "spectrum" + mtype: "" + } + member { + name: "tensor_rank" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'spectrum\', \'input_output_dtype\', \'is_non_singular\', \'is_self_adjoint\', \'is_positive_definite\', \'is_square\', \'name\'], varargs=None, keywords=None, defaults=[\"\", \'None\', \'None\', \'None\', \'True\', \'LinearOperatorCirculant2D\'], " + } + member_method { + name: "add_to_tensor" + argspec: "args=[\'self\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'add_to_tensor\'], " + } + member_method { + name: "assert_hermitian_spectrum" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_hermitian_spectrum\'], " + } + member_method { + name: "assert_non_singular" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_non_singular\'], " + } + member_method { + name: "assert_positive_definite" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_positive_definite\'], " + } + member_method { + name: "assert_self_adjoint" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_self_adjoint\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "block_shape_tensor" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "convolution_kernel" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'convolution_kernel\'], " + } + member_method { + name: "determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'det\'], " + } + member_method { + name: "diag_part" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'diag_part\'], " + } + member_method { + name: "domain_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'domain_dimension_tensor\'], " + } + member_method { + name: "log_abs_determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'log_abs_det\'], " + } + member_method { + name: "matmul" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'matmul\'], " + } + member_method { + name: "matvec" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'matvec\'], " + } + member_method { + name: "range_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'range_dimension_tensor\'], " + } + member_method { + name: "shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'shape_tensor\'], " + } + member_method { + name: "solve" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'solve\'], " + } + member_method { + name: "solvevec" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'solve\'], " + } + member_method { + name: "tensor_rank_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'tensor_rank_tensor\'], " + } + member_method { + name: "to_dense" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'to_dense\'], " + } + member_method { + name: "trace" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'trace\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant3-d.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant3-d.__metaclass__.pbtxt new file mode 100644 index 0000000000..d643139a53 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant3-d.__metaclass__.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.linalg.LinearOperatorCirculant3D.__metaclass__" +tf_class { + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "mro" + } + member_method { + name: "register" + argspec: "args=[\'cls\', \'subclass\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant3-d.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant3-d.pbtxt new file mode 100644 index 0000000000..2e085a8e28 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-circulant3-d.pbtxt @@ -0,0 +1,155 @@ +path: "tensorflow.linalg.LinearOperatorCirculant3D" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "batch_shape" + mtype: "" + } + member { + name: "block_depth" + mtype: "" + } + member { + name: "block_shape" + mtype: "" + } + member { + name: "domain_dimension" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph_parents" + mtype: "" + } + member { + name: "is_non_singular" + mtype: "" + } + member { + name: "is_positive_definite" + mtype: "" + } + member { + name: "is_self_adjoint" + mtype: "" + } + member { + name: "is_square" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "range_dimension" + mtype: "" + } + member { + name: "shape" + mtype: "" + } + member { + name: "spectrum" + mtype: "" + } + member { + name: "tensor_rank" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'spectrum\', \'input_output_dtype\', \'is_non_singular\', \'is_self_adjoint\', \'is_positive_definite\', \'is_square\', \'name\'], varargs=None, keywords=None, defaults=[\"\", \'None\', \'None\', \'None\', \'True\', \'LinearOperatorCirculant3D\'], " + } + member_method { + name: "add_to_tensor" + argspec: "args=[\'self\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'add_to_tensor\'], " + } + member_method { + name: "assert_hermitian_spectrum" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_hermitian_spectrum\'], " + } + member_method { + name: "assert_non_singular" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_non_singular\'], " + } + member_method { + name: "assert_positive_definite" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_positive_definite\'], " + } + member_method { + name: "assert_self_adjoint" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_self_adjoint\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "block_shape_tensor" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "convolution_kernel" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'convolution_kernel\'], " + } + member_method { + name: "determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'det\'], " + } + member_method { + name: "diag_part" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'diag_part\'], " + } + member_method { + name: "domain_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'domain_dimension_tensor\'], " + } + member_method { + name: "log_abs_determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'log_abs_det\'], " + } + member_method { + name: "matmul" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'matmul\'], " + } + member_method { + name: "matvec" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'matvec\'], " + } + member_method { + name: "range_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'range_dimension_tensor\'], " + } + member_method { + name: "shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'shape_tensor\'], " + } + member_method { + name: "solve" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'solve\'], " + } + member_method { + name: "solvevec" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'solve\'], " + } + member_method { + name: "tensor_rank_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'tensor_rank_tensor\'], " + } + member_method { + name: "to_dense" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'to_dense\'], " + } + member_method { + name: "trace" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'trace\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-composition.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-composition.__metaclass__.pbtxt new file mode 100644 index 0000000000..1adbcb41ad --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-composition.__metaclass__.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.linalg.LinearOperatorComposition.__metaclass__" +tf_class { + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "mro" + } + member_method { + name: "register" + argspec: "args=[\'cls\', \'subclass\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-composition.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-composition.pbtxt new file mode 100644 index 0000000000..42d22bce42 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-composition.pbtxt @@ -0,0 +1,134 @@ +path: "tensorflow.linalg.LinearOperatorComposition" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "batch_shape" + mtype: "" + } + member { + name: "domain_dimension" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph_parents" + mtype: "" + } + member { + name: "is_non_singular" + mtype: "" + } + member { + name: "is_positive_definite" + mtype: "" + } + member { + name: "is_self_adjoint" + mtype: "" + } + member { + name: "is_square" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "operators" + mtype: "" + } + member { + name: "range_dimension" + mtype: "" + } + member { + name: "shape" + mtype: "" + } + member { + name: "tensor_rank" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'operators\', \'is_non_singular\', \'is_self_adjoint\', \'is_positive_definite\', \'is_square\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_to_tensor" + argspec: "args=[\'self\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'add_to_tensor\'], " + } + member_method { + name: "assert_non_singular" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_non_singular\'], " + } + member_method { + name: "assert_positive_definite" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_positive_definite\'], " + } + member_method { + name: "assert_self_adjoint" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_self_adjoint\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'det\'], " + } + member_method { + name: "diag_part" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'diag_part\'], " + } + member_method { + name: "domain_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'domain_dimension_tensor\'], " + } + member_method { + name: "log_abs_determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'log_abs_det\'], " + } + member_method { + name: "matmul" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'matmul\'], " + } + member_method { + name: "matvec" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'matvec\'], " + } + member_method { + name: "range_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'range_dimension_tensor\'], " + } + member_method { + name: "shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'shape_tensor\'], " + } + member_method { + name: "solve" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'solve\'], " + } + member_method { + name: "solvevec" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'solve\'], " + } + member_method { + name: "tensor_rank_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'tensor_rank_tensor\'], " + } + member_method { + name: "to_dense" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'to_dense\'], " + } + member_method { + name: "trace" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'trace\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-diag.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-diag.__metaclass__.pbtxt new file mode 100644 index 0000000000..023d90ccdb --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-diag.__metaclass__.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.linalg.LinearOperatorDiag.__metaclass__" +tf_class { + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "mro" + } + member_method { + name: "register" + argspec: "args=[\'cls\', \'subclass\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-diag.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-diag.pbtxt new file mode 100644 index 0000000000..d6749fdcec --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-diag.pbtxt @@ -0,0 +1,134 @@ +path: "tensorflow.linalg.LinearOperatorDiag" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "batch_shape" + mtype: "" + } + member { + name: "diag" + mtype: "" + } + member { + name: "domain_dimension" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph_parents" + mtype: "" + } + member { + name: "is_non_singular" + mtype: "" + } + member { + name: "is_positive_definite" + mtype: "" + } + member { + name: "is_self_adjoint" + mtype: "" + } + member { + name: "is_square" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "range_dimension" + mtype: "" + } + member { + name: "shape" + mtype: "" + } + member { + name: "tensor_rank" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'diag\', \'is_non_singular\', \'is_self_adjoint\', \'is_positive_definite\', \'is_square\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'LinearOperatorDiag\'], " + } + member_method { + name: "add_to_tensor" + argspec: "args=[\'self\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'add_to_tensor\'], " + } + member_method { + name: "assert_non_singular" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_non_singular\'], " + } + member_method { + name: "assert_positive_definite" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_positive_definite\'], " + } + member_method { + name: "assert_self_adjoint" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_self_adjoint\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'det\'], " + } + member_method { + name: "diag_part" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'diag_part\'], " + } + member_method { + name: "domain_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'domain_dimension_tensor\'], " + } + member_method { + name: "log_abs_determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'log_abs_det\'], " + } + member_method { + name: "matmul" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'matmul\'], " + } + member_method { + name: "matvec" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'matvec\'], " + } + member_method { + name: "range_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'range_dimension_tensor\'], " + } + member_method { + name: "shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'shape_tensor\'], " + } + member_method { + name: "solve" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'solve\'], " + } + member_method { + name: "solvevec" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'solve\'], " + } + member_method { + name: "tensor_rank_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'tensor_rank_tensor\'], " + } + member_method { + name: "to_dense" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'to_dense\'], " + } + member_method { + name: "trace" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'trace\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-full-matrix.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-full-matrix.__metaclass__.pbtxt new file mode 100644 index 0000000000..381072e76c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-full-matrix.__metaclass__.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.linalg.LinearOperatorFullMatrix.__metaclass__" +tf_class { + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "mro" + } + member_method { + name: "register" + argspec: "args=[\'cls\', \'subclass\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-full-matrix.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-full-matrix.pbtxt new file mode 100644 index 0000000000..d9f363d133 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-full-matrix.pbtxt @@ -0,0 +1,130 @@ +path: "tensorflow.linalg.LinearOperatorFullMatrix" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "batch_shape" + mtype: "" + } + member { + name: "domain_dimension" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph_parents" + mtype: "" + } + member { + name: "is_non_singular" + mtype: "" + } + member { + name: "is_positive_definite" + mtype: "" + } + member { + name: "is_self_adjoint" + mtype: "" + } + member { + name: "is_square" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "range_dimension" + mtype: "" + } + member { + name: "shape" + mtype: "" + } + member { + name: "tensor_rank" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'matrix\', \'is_non_singular\', \'is_self_adjoint\', \'is_positive_definite\', \'is_square\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'LinearOperatorFullMatrix\'], " + } + member_method { + name: "add_to_tensor" + argspec: "args=[\'self\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'add_to_tensor\'], " + } + member_method { + name: "assert_non_singular" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_non_singular\'], " + } + member_method { + name: "assert_positive_definite" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_positive_definite\'], " + } + member_method { + name: "assert_self_adjoint" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_self_adjoint\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'det\'], " + } + member_method { + name: "diag_part" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'diag_part\'], " + } + member_method { + name: "domain_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'domain_dimension_tensor\'], " + } + member_method { + name: "log_abs_determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'log_abs_det\'], " + } + member_method { + name: "matmul" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'matmul\'], " + } + member_method { + name: "matvec" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'matvec\'], " + } + member_method { + name: "range_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'range_dimension_tensor\'], " + } + member_method { + name: "shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'shape_tensor\'], " + } + member_method { + name: "solve" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'solve\'], " + } + member_method { + name: "solvevec" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'solve\'], " + } + member_method { + name: "tensor_rank_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'tensor_rank_tensor\'], " + } + member_method { + name: "to_dense" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'to_dense\'], " + } + member_method { + name: "trace" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'trace\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-identity.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-identity.__metaclass__.pbtxt new file mode 100644 index 0000000000..5d115b35fb --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-identity.__metaclass__.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.linalg.LinearOperatorIdentity.__metaclass__" +tf_class { + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "mro" + } + member_method { + name: "register" + argspec: "args=[\'cls\', \'subclass\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-identity.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-identity.pbtxt new file mode 100644 index 0000000000..aac7ee31ed --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-identity.pbtxt @@ -0,0 +1,131 @@ +path: "tensorflow.linalg.LinearOperatorIdentity" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "batch_shape" + mtype: "" + } + member { + name: "domain_dimension" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph_parents" + mtype: "" + } + member { + name: "is_non_singular" + mtype: "" + } + member { + name: "is_positive_definite" + mtype: "" + } + member { + name: "is_self_adjoint" + mtype: "" + } + member { + name: "is_square" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "range_dimension" + mtype: "" + } + member { + name: "shape" + mtype: "" + } + member { + name: "tensor_rank" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'num_rows\', \'batch_shape\', \'dtype\', \'is_non_singular\', \'is_self_adjoint\', \'is_positive_definite\', \'is_square\', \'assert_proper_shapes\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'True\', \'True\', \'True\', \'True\', \'False\', \'LinearOperatorIdentity\'], " + } + member_method { + name: "add_to_tensor" + argspec: "args=[\'self\', \'mat\', \'name\'], varargs=None, keywords=None, defaults=[\'add_to_tensor\'], " + } + member_method { + name: "assert_non_singular" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_non_singular\'], " + } + member_method { + name: "assert_positive_definite" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_positive_definite\'], " + } + member_method { + name: "assert_self_adjoint" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_self_adjoint\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'det\'], " + } + member_method { + name: "diag_part" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'diag_part\'], " + } + member_method { + name: "domain_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'domain_dimension_tensor\'], " + } + member_method { + name: "log_abs_determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'log_abs_det\'], " + } + member_method { + name: "matmul" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'matmul\'], " + } + member_method { + name: "matvec" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'matvec\'], " + } + member_method { + name: "range_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'range_dimension_tensor\'], " + } + member_method { + name: "shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'shape_tensor\'], " + } + member_method { + name: "solve" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'solve\'], " + } + member_method { + name: "solvevec" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'solve\'], " + } + member_method { + name: "tensor_rank_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'tensor_rank_tensor\'], " + } + member_method { + name: "to_dense" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'to_dense\'], " + } + member_method { + name: "trace" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'trace\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-kronecker.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-kronecker.__metaclass__.pbtxt new file mode 100644 index 0000000000..5c6784dd02 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-kronecker.__metaclass__.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.linalg.LinearOperatorKronecker.__metaclass__" +tf_class { + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "mro" + } + member_method { + name: "register" + argspec: "args=[\'cls\', \'subclass\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-kronecker.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-kronecker.pbtxt new file mode 100644 index 0000000000..c11d390829 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-kronecker.pbtxt @@ -0,0 +1,134 @@ +path: "tensorflow.linalg.LinearOperatorKronecker" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "batch_shape" + mtype: "" + } + member { + name: "domain_dimension" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph_parents" + mtype: "" + } + member { + name: "is_non_singular" + mtype: "" + } + member { + name: "is_positive_definite" + mtype: "" + } + member { + name: "is_self_adjoint" + mtype: "" + } + member { + name: "is_square" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "operators" + mtype: "" + } + member { + name: "range_dimension" + mtype: "" + } + member { + name: "shape" + mtype: "" + } + member { + name: "tensor_rank" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'operators\', \'is_non_singular\', \'is_self_adjoint\', \'is_positive_definite\', \'is_square\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_to_tensor" + argspec: "args=[\'self\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'add_to_tensor\'], " + } + member_method { + name: "assert_non_singular" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_non_singular\'], " + } + member_method { + name: "assert_positive_definite" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_positive_definite\'], " + } + member_method { + name: "assert_self_adjoint" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_self_adjoint\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'det\'], " + } + member_method { + name: "diag_part" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'diag_part\'], " + } + member_method { + name: "domain_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'domain_dimension_tensor\'], " + } + member_method { + name: "log_abs_determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'log_abs_det\'], " + } + member_method { + name: "matmul" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'matmul\'], " + } + member_method { + name: "matvec" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'matvec\'], " + } + member_method { + name: "range_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'range_dimension_tensor\'], " + } + member_method { + name: "shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'shape_tensor\'], " + } + member_method { + name: "solve" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'solve\'], " + } + member_method { + name: "solvevec" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'solve\'], " + } + member_method { + name: "tensor_rank_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'tensor_rank_tensor\'], " + } + member_method { + name: "to_dense" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'to_dense\'], " + } + member_method { + name: "trace" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'trace\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-low-rank-update.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-low-rank-update.__metaclass__.pbtxt new file mode 100644 index 0000000000..1f0d33298a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-low-rank-update.__metaclass__.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.linalg.LinearOperatorLowRankUpdate.__metaclass__" +tf_class { + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "mro" + } + member_method { + name: "register" + argspec: "args=[\'cls\', \'subclass\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-low-rank-update.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-low-rank-update.pbtxt new file mode 100644 index 0000000000..3ee800269e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-low-rank-update.pbtxt @@ -0,0 +1,154 @@ +path: "tensorflow.linalg.LinearOperatorLowRankUpdate" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "base_operator" + mtype: "" + } + member { + name: "batch_shape" + mtype: "" + } + member { + name: "diag_operator" + mtype: "" + } + member { + name: "diag_update" + mtype: "" + } + member { + name: "domain_dimension" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph_parents" + mtype: "" + } + member { + name: "is_diag_update_positive" + mtype: "" + } + member { + name: "is_non_singular" + mtype: "" + } + member { + name: "is_positive_definite" + mtype: "" + } + member { + name: "is_self_adjoint" + mtype: "" + } + member { + name: "is_square" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "range_dimension" + mtype: "" + } + member { + name: "shape" + mtype: "" + } + member { + name: "tensor_rank" + mtype: "" + } + member { + name: "u" + mtype: "" + } + member { + name: "v" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'base_operator\', \'u\', \'diag_update\', \'v\', \'is_diag_update_positive\', \'is_non_singular\', \'is_self_adjoint\', \'is_positive_definite\', \'is_square\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'LinearOperatorLowRankUpdate\'], " + } + member_method { + name: "add_to_tensor" + argspec: "args=[\'self\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'add_to_tensor\'], " + } + member_method { + name: "assert_non_singular" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_non_singular\'], " + } + member_method { + name: "assert_positive_definite" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_positive_definite\'], " + } + member_method { + name: "assert_self_adjoint" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_self_adjoint\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'det\'], " + } + member_method { + name: "diag_part" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'diag_part\'], " + } + member_method { + name: "domain_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'domain_dimension_tensor\'], " + } + member_method { + name: "log_abs_determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'log_abs_det\'], " + } + member_method { + name: "matmul" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'matmul\'], " + } + member_method { + name: "matvec" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'matvec\'], " + } + member_method { + name: "range_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'range_dimension_tensor\'], " + } + member_method { + name: "shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'shape_tensor\'], " + } + member_method { + name: "solve" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'solve\'], " + } + member_method { + name: "solvevec" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'solve\'], " + } + member_method { + name: "tensor_rank_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'tensor_rank_tensor\'], " + } + member_method { + name: "to_dense" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'to_dense\'], " + } + member_method { + name: "trace" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'trace\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-lower-triangular.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-lower-triangular.__metaclass__.pbtxt new file mode 100644 index 0000000000..2683430f4f --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-lower-triangular.__metaclass__.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.linalg.LinearOperatorLowerTriangular.__metaclass__" +tf_class { + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "mro" + } + member_method { + name: "register" + argspec: "args=[\'cls\', \'subclass\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-lower-triangular.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-lower-triangular.pbtxt new file mode 100644 index 0000000000..63a1bc2321 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-lower-triangular.pbtxt @@ -0,0 +1,130 @@ +path: "tensorflow.linalg.LinearOperatorLowerTriangular" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "batch_shape" + mtype: "" + } + member { + name: "domain_dimension" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph_parents" + mtype: "" + } + member { + name: "is_non_singular" + mtype: "" + } + member { + name: "is_positive_definite" + mtype: "" + } + member { + name: "is_self_adjoint" + mtype: "" + } + member { + name: "is_square" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "range_dimension" + mtype: "" + } + member { + name: "shape" + mtype: "" + } + member { + name: "tensor_rank" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'tril\', \'is_non_singular\', \'is_self_adjoint\', \'is_positive_definite\', \'is_square\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'LinearOperatorLowerTriangular\'], " + } + member_method { + name: "add_to_tensor" + argspec: "args=[\'self\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'add_to_tensor\'], " + } + member_method { + name: "assert_non_singular" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_non_singular\'], " + } + member_method { + name: "assert_positive_definite" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_positive_definite\'], " + } + member_method { + name: "assert_self_adjoint" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_self_adjoint\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'det\'], " + } + member_method { + name: "diag_part" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'diag_part\'], " + } + member_method { + name: "domain_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'domain_dimension_tensor\'], " + } + member_method { + name: "log_abs_determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'log_abs_det\'], " + } + member_method { + name: "matmul" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'matmul\'], " + } + member_method { + name: "matvec" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'matvec\'], " + } + member_method { + name: "range_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'range_dimension_tensor\'], " + } + member_method { + name: "shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'shape_tensor\'], " + } + member_method { + name: "solve" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'solve\'], " + } + member_method { + name: "solvevec" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'solve\'], " + } + member_method { + name: "tensor_rank_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'tensor_rank_tensor\'], " + } + member_method { + name: "to_dense" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'to_dense\'], " + } + member_method { + name: "trace" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'trace\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-scaled-identity.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-scaled-identity.__metaclass__.pbtxt new file mode 100644 index 0000000000..38bf7ad586 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-scaled-identity.__metaclass__.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.linalg.LinearOperatorScaledIdentity.__metaclass__" +tf_class { + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "mro" + } + member_method { + name: "register" + argspec: "args=[\'cls\', \'subclass\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-scaled-identity.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-scaled-identity.pbtxt new file mode 100644 index 0000000000..e2c5a505a7 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-scaled-identity.pbtxt @@ -0,0 +1,135 @@ +path: "tensorflow.linalg.LinearOperatorScaledIdentity" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "batch_shape" + mtype: "" + } + member { + name: "domain_dimension" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph_parents" + mtype: "" + } + member { + name: "is_non_singular" + mtype: "" + } + member { + name: "is_positive_definite" + mtype: "" + } + member { + name: "is_self_adjoint" + mtype: "" + } + member { + name: "is_square" + mtype: "" + } + member { + name: "multiplier" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "range_dimension" + mtype: "" + } + member { + name: "shape" + mtype: "" + } + member { + name: "tensor_rank" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'num_rows\', \'multiplier\', \'is_non_singular\', \'is_self_adjoint\', \'is_positive_definite\', \'is_square\', \'assert_proper_shapes\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'True\', \'False\', \'LinearOperatorScaledIdentity\'], " + } + member_method { + name: "add_to_tensor" + argspec: "args=[\'self\', \'mat\', \'name\'], varargs=None, keywords=None, defaults=[\'add_to_tensor\'], " + } + member_method { + name: "assert_non_singular" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_non_singular\'], " + } + member_method { + name: "assert_positive_definite" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_positive_definite\'], " + } + member_method { + name: "assert_self_adjoint" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_self_adjoint\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'det\'], " + } + member_method { + name: "diag_part" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'diag_part\'], " + } + member_method { + name: "domain_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'domain_dimension_tensor\'], " + } + member_method { + name: "log_abs_determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'log_abs_det\'], " + } + member_method { + name: "matmul" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'matmul\'], " + } + member_method { + name: "matvec" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'matvec\'], " + } + member_method { + name: "range_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'range_dimension_tensor\'], " + } + member_method { + name: "shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'shape_tensor\'], " + } + member_method { + name: "solve" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'solve\'], " + } + member_method { + name: "solvevec" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'solve\'], " + } + member_method { + name: "tensor_rank_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'tensor_rank_tensor\'], " + } + member_method { + name: "to_dense" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'to_dense\'], " + } + member_method { + name: "trace" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'trace\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-zeros.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-zeros.__metaclass__.pbtxt new file mode 100644 index 0000000000..49ff85728f --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-zeros.__metaclass__.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.linalg.LinearOperatorZeros.__metaclass__" +tf_class { + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "mro" + } + member_method { + name: "register" + argspec: "args=[\'cls\', \'subclass\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-zeros.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-zeros.pbtxt new file mode 100644 index 0000000000..a1b0e06b47 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator-zeros.pbtxt @@ -0,0 +1,130 @@ +path: "tensorflow.linalg.LinearOperatorZeros" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "batch_shape" + mtype: "" + } + member { + name: "domain_dimension" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph_parents" + mtype: "" + } + member { + name: "is_non_singular" + mtype: "" + } + member { + name: "is_positive_definite" + mtype: "" + } + member { + name: "is_self_adjoint" + mtype: "" + } + member { + name: "is_square" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "range_dimension" + mtype: "" + } + member { + name: "shape" + mtype: "" + } + member { + name: "tensor_rank" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'num_rows\', \'num_columns\', \'batch_shape\', \'dtype\', \'is_non_singular\', \'is_self_adjoint\', \'is_positive_definite\', \'is_square\', \'assert_proper_shapes\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'False\', \'True\', \'False\', \'True\', \'False\', \'LinearOperatorZeros\'], " + } + member_method { + name: "add_to_tensor" + argspec: "args=[\'self\', \'mat\', \'name\'], varargs=None, keywords=None, defaults=[\'add_to_tensor\'], " + } + member_method { + name: "assert_non_singular" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_non_singular\'], " + } + member_method { + name: "assert_positive_definite" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_positive_definite\'], " + } + member_method { + name: "assert_self_adjoint" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_self_adjoint\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'det\'], " + } + member_method { + name: "diag_part" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'diag_part\'], " + } + member_method { + name: "domain_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'domain_dimension_tensor\'], " + } + member_method { + name: "log_abs_determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'log_abs_det\'], " + } + member_method { + name: "matmul" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'matmul\'], " + } + member_method { + name: "matvec" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'matvec\'], " + } + member_method { + name: "range_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'range_dimension_tensor\'], " + } + member_method { + name: "shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'shape_tensor\'], " + } + member_method { + name: "solve" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'solve\'], " + } + member_method { + name: "solvevec" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'solve\'], " + } + member_method { + name: "tensor_rank_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'tensor_rank_tensor\'], " + } + member_method { + name: "to_dense" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'to_dense\'], " + } + member_method { + name: "trace" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'trace\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator.__metaclass__.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator.__metaclass__.pbtxt new file mode 100644 index 0000000000..38da809b36 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator.__metaclass__.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.linalg.LinearOperator.__metaclass__" +tf_class { + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "mro" + } + member_method { + name: "register" + argspec: "args=[\'cls\', \'subclass\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator.pbtxt new file mode 100644 index 0000000000..6d849dc040 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.-linear-operator.pbtxt @@ -0,0 +1,129 @@ +path: "tensorflow.linalg.LinearOperator" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "batch_shape" + mtype: "" + } + member { + name: "domain_dimension" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph_parents" + mtype: "" + } + member { + name: "is_non_singular" + mtype: "" + } + member { + name: "is_positive_definite" + mtype: "" + } + member { + name: "is_self_adjoint" + mtype: "" + } + member { + name: "is_square" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "range_dimension" + mtype: "" + } + member { + name: "shape" + mtype: "" + } + member { + name: "tensor_rank" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'dtype\', \'graph_parents\', \'is_non_singular\', \'is_self_adjoint\', \'is_positive_definite\', \'is_square\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_to_tensor" + argspec: "args=[\'self\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'add_to_tensor\'], " + } + member_method { + name: "assert_non_singular" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_non_singular\'], " + } + member_method { + name: "assert_positive_definite" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_positive_definite\'], " + } + member_method { + name: "assert_self_adjoint" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'assert_self_adjoint\'], " + } + member_method { + name: "batch_shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'batch_shape_tensor\'], " + } + member_method { + name: "determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'det\'], " + } + member_method { + name: "diag_part" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'diag_part\'], " + } + member_method { + name: "domain_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'domain_dimension_tensor\'], " + } + member_method { + name: "log_abs_determinant" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'log_abs_det\'], " + } + member_method { + name: "matmul" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'matmul\'], " + } + member_method { + name: "matvec" + argspec: "args=[\'self\', \'x\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'matvec\'], " + } + member_method { + name: "range_dimension_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'range_dimension_tensor\'], " + } + member_method { + name: "shape_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'shape_tensor\'], " + } + member_method { + name: "solve" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'adjoint_arg\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'solve\'], " + } + member_method { + name: "solvevec" + argspec: "args=[\'self\', \'rhs\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'solve\'], " + } + member_method { + name: "tensor_rank_tensor" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'tensor_rank_tensor\'], " + } + member_method { + name: "to_dense" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'to_dense\'], " + } + member_method { + name: "trace" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'trace\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.linalg.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.linalg.pbtxt new file mode 100644 index 0000000000..d979116887 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.linalg.pbtxt @@ -0,0 +1,175 @@ +path: "tensorflow.linalg" +tf_module { + member { + name: "LinearOperator" + mtype: "" + } + member { + name: "LinearOperatorBlockDiag" + mtype: "" + } + member { + name: "LinearOperatorCirculant" + mtype: "" + } + member { + name: "LinearOperatorCirculant2D" + mtype: "" + } + member { + name: "LinearOperatorCirculant3D" + mtype: "" + } + member { + name: "LinearOperatorComposition" + mtype: "" + } + member { + name: "LinearOperatorDiag" + mtype: "" + } + member { + name: "LinearOperatorFullMatrix" + mtype: "" + } + member { + name: "LinearOperatorIdentity" + mtype: "" + } + member { + name: "LinearOperatorKronecker" + mtype: "" + } + member { + name: "LinearOperatorLowRankUpdate" + mtype: "" + } + member { + name: "LinearOperatorLowerTriangular" + mtype: "" + } + member { + name: "LinearOperatorScaledIdentity" + mtype: "" + } + member { + name: "LinearOperatorZeros" + mtype: "" + } + member_method { + name: "adjoint" + argspec: "args=[\'matrix\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "band_part" + argspec: "args=[\'input\', \'num_lower\', \'num_upper\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "cholesky" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "cholesky_solve" + argspec: "args=[\'chol\', \'rhs\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "cross" + argspec: "args=[\'a\', \'b\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "det" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "diag" + argspec: "args=[\'diagonal\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "diag_part" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "eigh" + argspec: "args=[\'tensor\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "eigvalsh" + argspec: "args=[\'tensor\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "einsum" + argspec: "args=[\'equation\'], varargs=inputs, keywords=kwargs, defaults=None" + } + member_method { + name: "expm" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "eye" + argspec: "args=[\'num_rows\', \'num_columns\', \'batch_shape\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \"\", \'None\'], " + } + member_method { + name: "inv" + argspec: "args=[\'input\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "logdet" + argspec: "args=[\'matrix\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "logm" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "lstsq" + argspec: "args=[\'matrix\', \'rhs\', \'l2_regularizer\', \'fast\', \'name\'], varargs=None, keywords=None, defaults=[\'0.0\', \'True\', \'None\'], " + } + member_method { + name: "norm" + argspec: "args=[\'tensor\', \'ord\', \'axis\', \'keepdims\', \'name\', \'keep_dims\'], varargs=None, keywords=None, defaults=[\'euclidean\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "qr" + argspec: "args=[\'input\', \'full_matrices\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "set_diag" + argspec: "args=[\'input\', \'diagonal\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "slogdet" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "solve" + argspec: "args=[\'matrix\', \'rhs\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "svd" + argspec: "args=[\'tensor\', \'full_matrices\', \'compute_uv\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'True\', \'None\'], " + } + member_method { + name: "tensor_diag" + argspec: "args=[\'diagonal\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "tensor_diag_part" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "tensordot" + argspec: "args=[\'a\', \'b\', \'axes\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "trace" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "transpose" + argspec: "args=[\'a\', \'name\', \'conjugate\'], varargs=None, keywords=None, defaults=[\'matrix_transpose\', \'False\'], " + } + member_method { + name: "triangular_solve" + argspec: "args=[\'matrix\', \'rhs\', \'lower\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'True\', \'False\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.logging.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.logging.pbtxt new file mode 100644 index 0000000000..85bb15455d --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.logging.pbtxt @@ -0,0 +1,83 @@ +path: "tensorflow.logging" +tf_module { + member { + name: "DEBUG" + mtype: "" + } + member { + name: "ERROR" + mtype: "" + } + member { + name: "FATAL" + mtype: "" + } + member { + name: "INFO" + mtype: "" + } + member { + name: "WARN" + mtype: "" + } + member_method { + name: "TaskLevelStatusMessage" + argspec: "args=[\'msg\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "debug" + argspec: "args=[\'msg\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "error" + argspec: "args=[\'msg\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "fatal" + argspec: "args=[\'msg\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "flush" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_verbosity" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "info" + argspec: "args=[\'msg\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "log" + argspec: "args=[\'level\', \'msg\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "log_every_n" + argspec: "args=[\'level\', \'msg\', \'n\'], varargs=args, keywords=None, defaults=None" + } + member_method { + name: "log_first_n" + argspec: "args=[\'level\', \'msg\', \'n\'], varargs=args, keywords=None, defaults=None" + } + member_method { + name: "log_if" + argspec: "args=[\'level\', \'msg\', \'condition\'], varargs=args, keywords=None, defaults=None" + } + member_method { + name: "set_verbosity" + argspec: "args=[\'v\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "vlog" + argspec: "args=[\'level\', \'msg\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "warn" + argspec: "args=[\'msg\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "warning" + argspec: "args=[\'msg\'], varargs=args, keywords=kwargs, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.losses.-reduction.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.losses.-reduction.pbtxt new file mode 100644 index 0000000000..258ad5047e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.losses.-reduction.pbtxt @@ -0,0 +1,40 @@ +path: "tensorflow.losses.Reduction" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "MEAN" + mtype: "" + } + member { + name: "NONE" + mtype: "" + } + member { + name: "SUM" + mtype: "" + } + member { + name: "SUM_BY_NONZERO_WEIGHTS" + mtype: "" + } + member { + name: "SUM_OVER_BATCH_SIZE" + mtype: "" + } + member { + name: "SUM_OVER_NONZERO_WEIGHTS" + mtype: "" + } + member_method { + name: "__init__" + } + member_method { + name: "all" + argspec: "args=[\'cls\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "validate" + argspec: "args=[\'cls\', \'key\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.losses.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.losses.pbtxt new file mode 100644 index 0000000000..c1d190ae11 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.losses.pbtxt @@ -0,0 +1,71 @@ +path: "tensorflow.losses" +tf_module { + member { + name: "Reduction" + mtype: "" + } + member_method { + name: "absolute_difference" + argspec: "args=[\'labels\', \'predictions\', \'weights\', \'scope\', \'loss_collection\', \'reduction\'], varargs=None, keywords=None, defaults=[\'1.0\', \'None\', \'losses\', \'weighted_sum_by_nonzero_weights\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'loss\', \'loss_collection\'], varargs=None, keywords=None, defaults=[\'losses\'], " + } + member_method { + name: "compute_weighted_loss" + argspec: "args=[\'losses\', \'weights\', \'scope\', \'loss_collection\', \'reduction\'], varargs=None, keywords=None, defaults=[\'1.0\', \'None\', \'losses\', \'weighted_sum_by_nonzero_weights\'], " + } + member_method { + name: "cosine_distance" + argspec: "args=[\'labels\', \'predictions\', \'axis\', \'weights\', \'scope\', \'loss_collection\', \'reduction\', \'dim\'], varargs=None, keywords=None, defaults=[\'None\', \'1.0\', \'None\', \'losses\', \'weighted_sum_by_nonzero_weights\', \'None\'], " + } + member_method { + name: "get_losses" + argspec: "args=[\'scope\', \'loss_collection\'], varargs=None, keywords=None, defaults=[\'None\', \'losses\'], " + } + member_method { + name: "get_regularization_loss" + argspec: "args=[\'scope\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'total_regularization_loss\'], " + } + member_method { + name: "get_regularization_losses" + argspec: "args=[\'scope\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_total_loss" + argspec: "args=[\'add_regularization_losses\', \'name\'], varargs=None, keywords=None, defaults=[\'True\', \'total_loss\'], " + } + member_method { + name: "hinge_loss" + argspec: "args=[\'labels\', \'logits\', \'weights\', \'scope\', \'loss_collection\', \'reduction\'], varargs=None, keywords=None, defaults=[\'1.0\', \'None\', \'losses\', \'weighted_sum_by_nonzero_weights\'], " + } + member_method { + name: "huber_loss" + argspec: "args=[\'labels\', \'predictions\', \'weights\', \'delta\', \'scope\', \'loss_collection\', \'reduction\'], varargs=None, keywords=None, defaults=[\'1.0\', \'1.0\', \'None\', \'losses\', \'weighted_sum_by_nonzero_weights\'], " + } + member_method { + name: "log_loss" + argspec: "args=[\'labels\', \'predictions\', \'weights\', \'epsilon\', \'scope\', \'loss_collection\', \'reduction\'], varargs=None, keywords=None, defaults=[\'1.0\', \'1e-07\', \'None\', \'losses\', \'weighted_sum_by_nonzero_weights\'], " + } + member_method { + name: "mean_pairwise_squared_error" + argspec: "args=[\'labels\', \'predictions\', \'weights\', \'scope\', \'loss_collection\'], varargs=None, keywords=None, defaults=[\'1.0\', \'None\', \'losses\'], " + } + member_method { + name: "mean_squared_error" + argspec: "args=[\'labels\', \'predictions\', \'weights\', \'scope\', \'loss_collection\', \'reduction\'], varargs=None, keywords=None, defaults=[\'1.0\', \'None\', \'losses\', \'weighted_sum_by_nonzero_weights\'], " + } + member_method { + name: "sigmoid_cross_entropy" + argspec: "args=[\'multi_class_labels\', \'logits\', \'weights\', \'label_smoothing\', \'scope\', \'loss_collection\', \'reduction\'], varargs=None, keywords=None, defaults=[\'1.0\', \'0\', \'None\', \'losses\', \'weighted_sum_by_nonzero_weights\'], " + } + member_method { + name: "softmax_cross_entropy" + argspec: "args=[\'onehot_labels\', \'logits\', \'weights\', \'label_smoothing\', \'scope\', \'loss_collection\', \'reduction\'], varargs=None, keywords=None, defaults=[\'1.0\', \'0\', \'None\', \'losses\', \'weighted_sum_by_nonzero_weights\'], " + } + member_method { + name: "sparse_softmax_cross_entropy" + argspec: "args=[\'labels\', \'logits\', \'weights\', \'scope\', \'loss_collection\', \'reduction\'], varargs=None, keywords=None, defaults=[\'1.0\', \'None\', \'losses\', \'weighted_sum_by_nonzero_weights\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.manip.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.manip.pbtxt new file mode 100644 index 0000000000..9add462396 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.manip.pbtxt @@ -0,0 +1,35 @@ +path: "tensorflow.manip" +tf_module { + member_method { + name: "batch_to_space_nd" + argspec: "args=[\'input\', \'block_shape\', \'crops\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "gather_nd" + argspec: "args=[\'params\', \'indices\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "reshape" + argspec: "args=[\'tensor\', \'shape\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "reverse" + argspec: "args=[\'tensor\', \'axis\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "roll" + argspec: "args=[\'input\', \'shift\', \'axis\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "scatter_nd" + argspec: "args=[\'indices\', \'updates\', \'shape\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "space_to_batch_nd" + argspec: "args=[\'input\', \'block_shape\', \'paddings\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "tile" + argspec: "args=[\'input\', \'multiples\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.math.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.math.pbtxt new file mode 100644 index 0000000000..a308c76ebc --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.math.pbtxt @@ -0,0 +1,239 @@ +path: "tensorflow.math" +tf_module { + member_method { + name: "acos" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "acosh" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "asin" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "asinh" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "atan" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "atan2" + argspec: "args=[\'y\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "atanh" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "bessel_i0" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "bessel_i0e" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "bessel_i1" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "bessel_i1e" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "betainc" + argspec: "args=[\'a\', \'b\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "ceil" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "cos" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "cosh" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "digamma" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "equal" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "erfc" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "exp" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "expm1" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "floor" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "greater" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "greater_equal" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "igamma" + argspec: "args=[\'a\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "igammac" + argspec: "args=[\'a\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "invert_permutation" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "less" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "less_equal" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "lgamma" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "log" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "log1p" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "logical_and" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "logical_not" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "logical_or" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "maximum" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "minimum" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "not_equal" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "polygamma" + argspec: "args=[\'a\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "polyval" + argspec: "args=[\'coeffs\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "reciprocal" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "rint" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "rsqrt" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "segment_max" + argspec: "args=[\'data\', \'segment_ids\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "segment_mean" + argspec: "args=[\'data\', \'segment_ids\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "segment_min" + argspec: "args=[\'data\', \'segment_ids\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "segment_prod" + argspec: "args=[\'data\', \'segment_ids\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "segment_sum" + argspec: "args=[\'data\', \'segment_ids\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "sin" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "sinh" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "softplus" + argspec: "args=[\'features\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "softsign" + argspec: "args=[\'features\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "squared_difference" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "tan" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "unsorted_segment_max" + argspec: "args=[\'data\', \'segment_ids\', \'num_segments\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "unsorted_segment_min" + argspec: "args=[\'data\', \'segment_ids\', \'num_segments\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "unsorted_segment_prod" + argspec: "args=[\'data\', \'segment_ids\', \'num_segments\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "unsorted_segment_sum" + argspec: "args=[\'data\', \'segment_ids\', \'num_segments\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "zeta" + argspec: "args=[\'x\', \'q\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.metrics.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.metrics.pbtxt new file mode 100644 index 0000000000..e9b996c9f5 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.metrics.pbtxt @@ -0,0 +1,135 @@ +path: "tensorflow.metrics" +tf_module { + member_method { + name: "accuracy" + argspec: "args=[\'labels\', \'predictions\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "auc" + argspec: "args=[\'labels\', \'predictions\', \'weights\', \'num_thresholds\', \'metrics_collections\', \'updates_collections\', \'curve\', \'name\', \'summation_method\'], varargs=None, keywords=None, defaults=[\'None\', \'200\', \'None\', \'None\', \'ROC\', \'None\', \'trapezoidal\'], " + } + member_method { + name: "average_precision_at_k" + argspec: "args=[\'labels\', \'predictions\', \'k\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "false_negatives" + argspec: "args=[\'labels\', \'predictions\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "false_negatives_at_thresholds" + argspec: "args=[\'labels\', \'predictions\', \'thresholds\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "false_positives" + argspec: "args=[\'labels\', \'predictions\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "false_positives_at_thresholds" + argspec: "args=[\'labels\', \'predictions\', \'thresholds\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "mean" + argspec: "args=[\'values\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "mean_absolute_error" + argspec: "args=[\'labels\', \'predictions\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "mean_cosine_distance" + argspec: "args=[\'labels\', \'predictions\', \'dim\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "mean_iou" + argspec: "args=[\'labels\', \'predictions\', \'num_classes\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "mean_per_class_accuracy" + argspec: "args=[\'labels\', \'predictions\', \'num_classes\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "mean_relative_error" + argspec: "args=[\'labels\', \'predictions\', \'normalizer\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "mean_squared_error" + argspec: "args=[\'labels\', \'predictions\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "mean_tensor" + argspec: "args=[\'values\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "percentage_below" + argspec: "args=[\'values\', \'threshold\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "precision" + argspec: "args=[\'labels\', \'predictions\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "precision_at_k" + argspec: "args=[\'labels\', \'predictions\', \'k\', \'class_id\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "precision_at_thresholds" + argspec: "args=[\'labels\', \'predictions\', \'thresholds\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "precision_at_top_k" + argspec: "args=[\'labels\', \'predictions_idx\', \'k\', \'class_id\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "recall" + argspec: "args=[\'labels\', \'predictions\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "recall_at_k" + argspec: "args=[\'labels\', \'predictions\', \'k\', \'class_id\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "recall_at_thresholds" + argspec: "args=[\'labels\', \'predictions\', \'thresholds\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "recall_at_top_k" + argspec: "args=[\'labels\', \'predictions_idx\', \'k\', \'class_id\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "root_mean_squared_error" + argspec: "args=[\'labels\', \'predictions\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "sensitivity_at_specificity" + argspec: "args=[\'labels\', \'predictions\', \'specificity\', \'weights\', \'num_thresholds\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'200\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "sparse_average_precision_at_k" + argspec: "args=[\'labels\', \'predictions\', \'k\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "sparse_precision_at_k" + argspec: "args=[\'labels\', \'predictions\', \'k\', \'class_id\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "specificity_at_sensitivity" + argspec: "args=[\'labels\', \'predictions\', \'sensitivity\', \'weights\', \'num_thresholds\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'200\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "true_negatives" + argspec: "args=[\'labels\', \'predictions\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "true_negatives_at_thresholds" + argspec: "args=[\'labels\', \'predictions\', \'thresholds\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "true_positives" + argspec: "args=[\'labels\', \'predictions\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "true_positives_at_thresholds" + argspec: "args=[\'labels\', \'predictions\', \'thresholds\', \'weights\', \'metrics_collections\', \'updates_collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.name_scope.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.name_scope.pbtxt new file mode 100644 index 0000000000..8041897013 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.name_scope.pbtxt @@ -0,0 +1,13 @@ +path: "tensorflow.name_scope" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "name" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'name\', \'default_name\', \'values\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.nn.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.nn.pbtxt new file mode 100644 index 0000000000..d9e5b0d0fc --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.nn.pbtxt @@ -0,0 +1,359 @@ +path: "tensorflow.nn" +tf_module { + member { + name: "rnn_cell" + mtype: "" + } + member { + name: "swish" + mtype: "" + } + member_method { + name: "all_candidate_sampler" + argspec: "args=[\'true_classes\', \'num_true\', \'num_sampled\', \'unique\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "atrous_conv2d" + argspec: "args=[\'value\', \'filters\', \'rate\', \'padding\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "atrous_conv2d_transpose" + argspec: "args=[\'value\', \'filters\', \'output_shape\', \'rate\', \'padding\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "avg_pool" + argspec: "args=[\'value\', \'ksize\', \'strides\', \'padding\', \'data_format\', \'name\'], varargs=None, keywords=None, defaults=[\'NHWC\', \'None\'], " + } + member_method { + name: "avg_pool3d" + argspec: "args=[\'input\', \'ksize\', \'strides\', \'padding\', \'data_format\', \'name\'], varargs=None, keywords=None, defaults=[\'NDHWC\', \'None\'], " + } + member_method { + name: "batch_norm_with_global_normalization" + argspec: "args=[\'t\', \'m\', \'v\', \'beta\', \'gamma\', \'variance_epsilon\', \'scale_after_normalization\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "batch_normalization" + argspec: "args=[\'x\', \'mean\', \'variance\', \'offset\', \'scale\', \'variance_epsilon\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "bias_add" + argspec: "args=[\'value\', \'bias\', \'data_format\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "bidirectional_dynamic_rnn" + argspec: "args=[\'cell_fw\', \'cell_bw\', \'inputs\', \'sequence_length\', \'initial_state_fw\', \'initial_state_bw\', \'dtype\', \'parallel_iterations\', \'swap_memory\', \'time_major\', \'scope\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'False\', \'False\', \'None\'], " + } + member_method { + name: "compute_accidental_hits" + argspec: "args=[\'true_classes\', \'sampled_candidates\', \'num_true\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "conv1d" + argspec: "args=[\'value\', \'filters\', \'stride\', \'padding\', \'use_cudnn_on_gpu\', \'data_format\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "conv2d" + argspec: "args=[\'input\', \'filter\', \'strides\', \'padding\', \'use_cudnn_on_gpu\', \'data_format\', \'dilations\', \'name\'], varargs=None, keywords=None, defaults=[\'True\', \'NHWC\', \'[1, 1, 1, 1]\', \'None\'], " + } + member_method { + name: "conv2d_backprop_filter" + argspec: "args=[\'input\', \'filter_sizes\', \'out_backprop\', \'strides\', \'padding\', \'use_cudnn_on_gpu\', \'data_format\', \'dilations\', \'name\'], varargs=None, keywords=None, defaults=[\'True\', \'NHWC\', \'[1, 1, 1, 1]\', \'None\'], " + } + member_method { + name: "conv2d_backprop_input" + argspec: "args=[\'input_sizes\', \'filter\', \'out_backprop\', \'strides\', \'padding\', \'use_cudnn_on_gpu\', \'data_format\', \'dilations\', \'name\'], varargs=None, keywords=None, defaults=[\'True\', \'NHWC\', \'[1, 1, 1, 1]\', \'None\'], " + } + member_method { + name: "conv2d_transpose" + argspec: "args=[\'value\', \'filter\', \'output_shape\', \'strides\', \'padding\', \'data_format\', \'name\'], varargs=None, keywords=None, defaults=[\'SAME\', \'NHWC\', \'None\'], " + } + member_method { + name: "conv3d" + argspec: "args=[\'input\', \'filter\', \'strides\', \'padding\', \'data_format\', \'dilations\', \'name\'], varargs=None, keywords=None, defaults=[\'NDHWC\', \'[1, 1, 1, 1, 1]\', \'None\'], " + } + member_method { + name: "conv3d_backprop_filter_v2" + argspec: "args=[\'input\', \'filter_sizes\', \'out_backprop\', \'strides\', \'padding\', \'data_format\', \'dilations\', \'name\'], varargs=None, keywords=None, defaults=[\'NDHWC\', \'[1, 1, 1, 1, 1]\', \'None\'], " + } + member_method { + name: "conv3d_transpose" + argspec: "args=[\'value\', \'filter\', \'output_shape\', \'strides\', \'padding\', \'data_format\', \'name\'], varargs=None, keywords=None, defaults=[\'SAME\', \'NDHWC\', \'None\'], " + } + member_method { + name: "convolution" + argspec: "args=[\'input\', \'filter\', \'padding\', \'strides\', \'dilation_rate\', \'name\', \'data_format\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "crelu" + argspec: "args=[\'features\', \'name\', \'axis\'], varargs=None, keywords=None, defaults=[\'None\', \'-1\'], " + } + member_method { + name: "ctc_beam_search_decoder" + argspec: "args=[\'inputs\', \'sequence_length\', \'beam_width\', \'top_paths\', \'merge_repeated\'], varargs=None, keywords=None, defaults=[\'100\', \'1\', \'True\'], " + } + member_method { + name: "ctc_greedy_decoder" + argspec: "args=[\'inputs\', \'sequence_length\', \'merge_repeated\'], varargs=None, keywords=None, defaults=[\'True\'], " + } + member_method { + name: "ctc_loss" + argspec: "args=[\'labels\', \'inputs\', \'sequence_length\', \'preprocess_collapse_repeated\', \'ctc_merge_repeated\', \'ignore_longer_outputs_than_inputs\', \'time_major\'], varargs=None, keywords=None, defaults=[\'False\', \'True\', \'False\', \'True\'], " + } + member_method { + name: "depthwise_conv2d" + argspec: "args=[\'input\', \'filter\', \'strides\', \'padding\', \'rate\', \'name\', \'data_format\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "depthwise_conv2d_native" + argspec: "args=[\'input\', \'filter\', \'strides\', \'padding\', \'data_format\', \'dilations\', \'name\'], varargs=None, keywords=None, defaults=[\'NHWC\', \'[1, 1, 1, 1]\', \'None\'], " + } + member_method { + name: "depthwise_conv2d_native_backprop_filter" + argspec: "args=[\'input\', \'filter_sizes\', \'out_backprop\', \'strides\', \'padding\', \'data_format\', \'dilations\', \'name\'], varargs=None, keywords=None, defaults=[\'NHWC\', \'[1, 1, 1, 1]\', \'None\'], " + } + member_method { + name: "depthwise_conv2d_native_backprop_input" + argspec: "args=[\'input_sizes\', \'filter\', \'out_backprop\', \'strides\', \'padding\', \'data_format\', \'dilations\', \'name\'], varargs=None, keywords=None, defaults=[\'NHWC\', \'[1, 1, 1, 1]\', \'None\'], " + } + member_method { + name: "dilation2d" + argspec: "args=[\'input\', \'filter\', \'strides\', \'rates\', \'padding\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "dropout" + argspec: "args=[\'x\', \'keep_prob\', \'noise_shape\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "dynamic_rnn" + argspec: "args=[\'cell\', \'inputs\', \'sequence_length\', \'initial_state\', \'dtype\', \'parallel_iterations\', \'swap_memory\', \'time_major\', \'scope\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'False\', \'False\', \'None\'], " + } + member_method { + name: "elu" + argspec: "args=[\'features\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "embedding_lookup" + argspec: "args=[\'params\', \'ids\', \'partition_strategy\', \'name\', \'validate_indices\', \'max_norm\'], varargs=None, keywords=None, defaults=[\'mod\', \'None\', \'True\', \'None\'], " + } + member_method { + name: "embedding_lookup_sparse" + argspec: "args=[\'params\', \'sp_ids\', \'sp_weights\', \'partition_strategy\', \'name\', \'combiner\', \'max_norm\'], varargs=None, keywords=None, defaults=[\'mod\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "erosion2d" + argspec: "args=[\'value\', \'kernel\', \'strides\', \'rates\', \'padding\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "fixed_unigram_candidate_sampler" + argspec: "args=[\'true_classes\', \'num_true\', \'num_sampled\', \'unique\', \'range_max\', \'vocab_file\', \'distortion\', \'num_reserved_ids\', \'num_shards\', \'shard\', \'unigrams\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'\', \'1.0\', \'0\', \'1\', \'0\', \'()\', \'None\', \'None\'], " + } + member_method { + name: "fractional_avg_pool" + argspec: "args=[\'value\', \'pooling_ratio\', \'pseudo_random\', \'overlapping\', \'deterministic\', \'seed\', \'seed2\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'False\', \'0\', \'0\', \'None\'], " + } + member_method { + name: "fractional_max_pool" + argspec: "args=[\'value\', \'pooling_ratio\', \'pseudo_random\', \'overlapping\', \'deterministic\', \'seed\', \'seed2\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'False\', \'0\', \'0\', \'None\'], " + } + member_method { + name: "fused_batch_norm" + argspec: "args=[\'x\', \'scale\', \'offset\', \'mean\', \'variance\', \'epsilon\', \'data_format\', \'is_training\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'0.001\', \'NHWC\', \'True\', \'None\'], " + } + member_method { + name: "in_top_k" + argspec: "args=[\'predictions\', \'targets\', \'k\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "l2_loss" + argspec: "args=[\'t\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "l2_normalize" + argspec: "args=[\'x\', \'axis\', \'epsilon\', \'name\', \'dim\'], varargs=None, keywords=None, defaults=[\'None\', \'1e-12\', \'None\', \'None\'], " + } + member_method { + name: "leaky_relu" + argspec: "args=[\'features\', \'alpha\', \'name\'], varargs=None, keywords=None, defaults=[\'0.2\', \'None\'], " + } + member_method { + name: "learned_unigram_candidate_sampler" + argspec: "args=[\'true_classes\', \'num_true\', \'num_sampled\', \'unique\', \'range_max\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "local_response_normalization" + argspec: "args=[\'input\', \'depth_radius\', \'bias\', \'alpha\', \'beta\', \'name\'], varargs=None, keywords=None, defaults=[\'5\', \'1\', \'1\', \'0.5\', \'None\'], " + } + member_method { + name: "log_poisson_loss" + argspec: "args=[\'targets\', \'log_input\', \'compute_full_loss\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "log_softmax" + argspec: "args=[\'logits\', \'axis\', \'name\', \'dim\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "log_uniform_candidate_sampler" + argspec: "args=[\'true_classes\', \'num_true\', \'num_sampled\', \'unique\', \'range_max\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "lrn" + argspec: "args=[\'input\', \'depth_radius\', \'bias\', \'alpha\', \'beta\', \'name\'], varargs=None, keywords=None, defaults=[\'5\', \'1\', \'1\', \'0.5\', \'None\'], " + } + member_method { + name: "max_pool" + argspec: "args=[\'value\', \'ksize\', \'strides\', \'padding\', \'data_format\', \'name\'], varargs=None, keywords=None, defaults=[\'NHWC\', \'None\'], " + } + member_method { + name: "max_pool3d" + argspec: "args=[\'input\', \'ksize\', \'strides\', \'padding\', \'data_format\', \'name\'], varargs=None, keywords=None, defaults=[\'NDHWC\', \'None\'], " + } + member_method { + name: "max_pool_with_argmax" + argspec: "args=[\'input\', \'ksize\', \'strides\', \'padding\', \'Targmax\', \'name\'], varargs=None, keywords=None, defaults=[\"\", \'None\'], " + } + member_method { + name: "moments" + argspec: "args=[\'x\', \'axes\', \'shift\', \'name\', \'keep_dims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'False\'], " + } + member_method { + name: "nce_loss" + argspec: "args=[\'weights\', \'biases\', \'labels\', \'inputs\', \'num_sampled\', \'num_classes\', \'num_true\', \'sampled_values\', \'remove_accidental_hits\', \'partition_strategy\', \'name\'], varargs=None, keywords=None, defaults=[\'1\', \'None\', \'False\', \'mod\', \'nce_loss\'], " + } + member_method { + name: "normalize_moments" + argspec: "args=[\'counts\', \'mean_ss\', \'variance_ss\', \'shift\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "pool" + argspec: "args=[\'input\', \'window_shape\', \'pooling_type\', \'padding\', \'dilation_rate\', \'strides\', \'name\', \'data_format\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "quantized_avg_pool" + argspec: "args=[\'input\', \'min_input\', \'max_input\', \'ksize\', \'strides\', \'padding\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "quantized_conv2d" + argspec: "args=[\'input\', \'filter\', \'min_input\', \'max_input\', \'min_filter\', \'max_filter\', \'strides\', \'padding\', \'out_type\', \'dilations\', \'name\'], varargs=None, keywords=None, defaults=[\"\", \'[1, 1, 1, 1]\', \'None\'], " + } + member_method { + name: "quantized_max_pool" + argspec: "args=[\'input\', \'min_input\', \'max_input\', \'ksize\', \'strides\', \'padding\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "quantized_relu_x" + argspec: "args=[\'features\', \'max_value\', \'min_features\', \'max_features\', \'out_type\', \'name\'], varargs=None, keywords=None, defaults=[\"\", \'None\'], " + } + member_method { + name: "raw_rnn" + argspec: "args=[\'cell\', \'loop_fn\', \'parallel_iterations\', \'swap_memory\', \'scope\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\'], " + } + member_method { + name: "relu" + argspec: "args=[\'features\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "relu6" + argspec: "args=[\'features\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "relu_layer" + argspec: "args=[\'x\', \'weights\', \'biases\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "safe_embedding_lookup_sparse" + argspec: "args=[\'embedding_weights\', \'sparse_ids\', \'sparse_weights\', \'combiner\', \'default_id\', \'name\', \'partition_strategy\', \'max_norm\'], varargs=None, keywords=None, defaults=[\'None\', \'mean\', \'None\', \'None\', \'div\', \'None\'], " + } + member_method { + name: "sampled_softmax_loss" + argspec: "args=[\'weights\', \'biases\', \'labels\', \'inputs\', \'num_sampled\', \'num_classes\', \'num_true\', \'sampled_values\', \'remove_accidental_hits\', \'partition_strategy\', \'name\', \'seed\'], varargs=None, keywords=None, defaults=[\'1\', \'None\', \'True\', \'mod\', \'sampled_softmax_loss\', \'None\'], " + } + member_method { + name: "selu" + argspec: "args=[\'features\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "separable_conv2d" + argspec: "args=[\'input\', \'depthwise_filter\', \'pointwise_filter\', \'strides\', \'padding\', \'rate\', \'name\', \'data_format\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "sigmoid" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "sigmoid_cross_entropy_with_logits" + argspec: "args=[\'_sentinel\', \'labels\', \'logits\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "softmax" + argspec: "args=[\'logits\', \'axis\', \'name\', \'dim\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "softmax_cross_entropy_with_logits" + argspec: "args=[\'_sentinel\', \'labels\', \'logits\', \'dim\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'-1\', \'None\'], " + } + member_method { + name: "softmax_cross_entropy_with_logits_v2" + argspec: "args=[\'_sentinel\', \'labels\', \'logits\', \'dim\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'-1\', \'None\'], " + } + member_method { + name: "softplus" + argspec: "args=[\'features\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "softsign" + argspec: "args=[\'features\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "sparse_softmax_cross_entropy_with_logits" + argspec: "args=[\'_sentinel\', \'labels\', \'logits\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "static_bidirectional_rnn" + argspec: "args=[\'cell_fw\', \'cell_bw\', \'inputs\', \'initial_state_fw\', \'initial_state_bw\', \'dtype\', \'sequence_length\', \'scope\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "static_rnn" + argspec: "args=[\'cell\', \'inputs\', \'initial_state\', \'dtype\', \'sequence_length\', \'scope\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "static_state_saving_rnn" + argspec: "args=[\'cell\', \'inputs\', \'state_saver\', \'state_name\', \'sequence_length\', \'scope\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "sufficient_statistics" + argspec: "args=[\'x\', \'axes\', \'shift\', \'keep_dims\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\'], " + } + member_method { + name: "tanh" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "top_k" + argspec: "args=[\'input\', \'k\', \'sorted\', \'name\'], varargs=None, keywords=None, defaults=[\'1\', \'True\', \'None\'], " + } + member_method { + name: "uniform_candidate_sampler" + argspec: "args=[\'true_classes\', \'num_true\', \'num_sampled\', \'unique\', \'range_max\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "weighted_cross_entropy_with_logits" + argspec: "args=[\'targets\', \'logits\', \'pos_weight\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "weighted_moments" + argspec: "args=[\'x\', \'axes\', \'frequency_weights\', \'name\', \'keep_dims\'], varargs=None, keywords=None, defaults=[\'None\', \'False\'], " + } + member_method { + name: "with_space_to_batch" + argspec: "args=[\'input\', \'dilation_rate\', \'padding\', \'op\', \'filter_shape\', \'spatial_dims\', \'data_format\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "xw_plus_b" + argspec: "args=[\'x\', \'weights\', \'biases\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "zero_fraction" + argspec: "args=[\'value\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-basic-l-s-t-m-cell.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-basic-l-s-t-m-cell.pbtxt new file mode 100644 index 0000000000..c74773000a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-basic-l-s-t-m-cell.pbtxt @@ -0,0 +1,198 @@ +path: "tensorflow.nn.rnn_cell.BasicLSTMCell" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "output_size" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "state_size" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'num_units\', \'forget_bias\', \'state_is_tuple\', \'activation\', \'reuse\', \'name\', \'dtype\'], varargs=None, keywords=None, defaults=[\'1.0\', \'True\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'inputs_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'state\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "zero_state" + argspec: "args=[\'self\', \'batch_size\', \'dtype\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-basic-r-n-n-cell.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-basic-r-n-n-cell.pbtxt new file mode 100644 index 0000000000..d251f54806 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-basic-r-n-n-cell.pbtxt @@ -0,0 +1,198 @@ +path: "tensorflow.nn.rnn_cell.BasicRNNCell" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "output_size" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "state_size" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'num_units\', \'activation\', \'reuse\', \'name\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'inputs_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'state\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "zero_state" + argspec: "args=[\'self\', \'batch_size\', \'dtype\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-device-wrapper.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-device-wrapper.pbtxt new file mode 100644 index 0000000000..8a63b49180 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-device-wrapper.pbtxt @@ -0,0 +1,197 @@ +path: "tensorflow.nn.rnn_cell.DeviceWrapper" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "output_size" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "state_size" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'cell\', \'device\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'_\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "zero_state" + argspec: "args=[\'self\', \'batch_size\', \'dtype\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-dropout-wrapper.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-dropout-wrapper.pbtxt new file mode 100644 index 0000000000..db1aae2757 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-dropout-wrapper.pbtxt @@ -0,0 +1,201 @@ +path: "tensorflow.nn.rnn_cell.DropoutWrapper" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "output_size" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "state_size" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member { + name: "wrapped_cell" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'cell\', \'input_keep_prob\', \'output_keep_prob\', \'state_keep_prob\', \'variational_recurrent\', \'input_size\', \'dtype\', \'seed\', \'dropout_state_filter_visitor\'], varargs=None, keywords=None, defaults=[\'1.0\', \'1.0\', \'1.0\', \'False\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'_\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "zero_state" + argspec: "args=[\'self\', \'batch_size\', \'dtype\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-g-r-u-cell.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-g-r-u-cell.pbtxt new file mode 100644 index 0000000000..d76eab7eb8 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-g-r-u-cell.pbtxt @@ -0,0 +1,198 @@ +path: "tensorflow.nn.rnn_cell.GRUCell" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "output_size" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "state_size" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'num_units\', \'activation\', \'reuse\', \'kernel_initializer\', \'bias_initializer\', \'name\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'inputs_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'state\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "zero_state" + argspec: "args=[\'self\', \'batch_size\', \'dtype\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-l-s-t-m-cell.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-l-s-t-m-cell.pbtxt new file mode 100644 index 0000000000..944db6ac93 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-l-s-t-m-cell.pbtxt @@ -0,0 +1,198 @@ +path: "tensorflow.nn.rnn_cell.LSTMCell" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "output_size" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "state_size" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'num_units\', \'use_peepholes\', \'cell_clip\', \'initializer\', \'num_proj\', \'proj_clip\', \'num_unit_shards\', \'num_proj_shards\', \'forget_bias\', \'state_is_tuple\', \'activation\', \'reuse\', \'name\', \'dtype\'], varargs=None, keywords=None, defaults=[\'False\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'1.0\', \'True\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'inputs_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'state\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "zero_state" + argspec: "args=[\'self\', \'batch_size\', \'dtype\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-l-s-t-m-state-tuple.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-l-s-t-m-state-tuple.pbtxt new file mode 100644 index 0000000000..1de8a55dcc --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-l-s-t-m-state-tuple.pbtxt @@ -0,0 +1,27 @@ +path: "tensorflow.nn.rnn_cell.LSTMStateTuple" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "c" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "h" + mtype: "" + } + member_method { + name: "__init__" + } + member_method { + name: "count" + } + member_method { + name: "index" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-multi-r-n-n-cell.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-multi-r-n-n-cell.pbtxt new file mode 100644 index 0000000000..72b40cc9f7 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-multi-r-n-n-cell.pbtxt @@ -0,0 +1,197 @@ +path: "tensorflow.nn.rnn_cell.MultiRNNCell" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "output_size" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "state_size" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'cells\', \'state_is_tuple\'], varargs=None, keywords=None, defaults=[\'True\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'_\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\', \'state\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "zero_state" + argspec: "args=[\'self\', \'batch_size\', \'dtype\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-r-n-n-cell.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-r-n-n-cell.pbtxt new file mode 100644 index 0000000000..a5c2b4aefd --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-r-n-n-cell.pbtxt @@ -0,0 +1,196 @@ +path: "tensorflow.nn.rnn_cell.RNNCell" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "output_size" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "state_size" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'trainable\', \'name\', \'dtype\'], varargs=None, keywords=kwargs, defaults=[\'True\', \'None\', \'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'_\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "zero_state" + argspec: "args=[\'self\', \'batch_size\', \'dtype\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-residual-wrapper.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-residual-wrapper.pbtxt new file mode 100644 index 0000000000..61d5f04b22 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.-residual-wrapper.pbtxt @@ -0,0 +1,197 @@ +path: "tensorflow.nn.rnn_cell.ResidualWrapper" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "activity_regularizer" + mtype: "" + } + member { + name: "dtype" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member { + name: "inbound_nodes" + mtype: "" + } + member { + name: "input" + mtype: "" + } + member { + name: "input_mask" + mtype: "" + } + member { + name: "input_shape" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "non_trainable_variables" + mtype: "" + } + member { + name: "non_trainable_weights" + mtype: "" + } + member { + name: "outbound_nodes" + mtype: "" + } + member { + name: "output" + mtype: "" + } + member { + name: "output_mask" + mtype: "" + } + member { + name: "output_shape" + mtype: "" + } + member { + name: "output_size" + mtype: "" + } + member { + name: "scope_name" + mtype: "" + } + member { + name: "state_size" + mtype: "" + } + member { + name: "trainable_variables" + mtype: "" + } + member { + name: "trainable_weights" + mtype: "" + } + member { + name: "updates" + mtype: "" + } + member { + name: "variables" + mtype: "" + } + member { + name: "weights" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'cell\', \'residual_fn\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_loss" + argspec: "args=[\'self\', \'losses\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_update" + argspec: "args=[\'self\', \'updates\', \'inputs\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_variable" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "add_weight" + argspec: "args=[\'self\', \'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'constraint\', \'use_resource\', \'synchronization\', \'aggregation\', \'partitioner\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'inputs\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\', \'_\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "call" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "compute_mask" + argspec: "args=[\'self\', \'inputs\', \'mask\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "compute_output_shape" + argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "count_params" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_input_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_losses_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_mask_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_output_shape_at" + argspec: "args=[\'self\', \'node_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_updates_for" + argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_weights" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_weights" + argspec: "args=[\'self\', \'weights\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "zero_state" + argspec: "args=[\'self\', \'batch_size\', \'dtype\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.pbtxt new file mode 100644 index 0000000000..64697e8a02 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.nn.rnn_cell.pbtxt @@ -0,0 +1,43 @@ +path: "tensorflow.nn.rnn_cell" +tf_module { + member { + name: "BasicLSTMCell" + mtype: "" + } + member { + name: "BasicRNNCell" + mtype: "" + } + member { + name: "DeviceWrapper" + mtype: "" + } + member { + name: "DropoutWrapper" + mtype: "" + } + member { + name: "GRUCell" + mtype: "" + } + member { + name: "LSTMCell" + mtype: "" + } + member { + name: "LSTMStateTuple" + mtype: "" + } + member { + name: "MultiRNNCell" + mtype: "" + } + member { + name: "RNNCell" + mtype: "" + } + member { + name: "ResidualWrapper" + mtype: "" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.ones_initializer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.ones_initializer.pbtxt new file mode 100644 index 0000000000..210b56242b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.ones_initializer.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.ones_initializer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'dtype\'], varargs=None, keywords=None, defaults=[\"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.orthogonal_initializer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.orthogonal_initializer.pbtxt new file mode 100644 index 0000000000..13ec7454f4 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.orthogonal_initializer.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.orthogonal_initializer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'gain\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'1.0\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.pbtxt new file mode 100644 index 0000000000..5eb42b4db3 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.pbtxt @@ -0,0 +1,2215 @@ +path: "tensorflow" +tf_module { + member { + name: "AUTO_REUSE" + mtype: "" + } + member { + name: "AggregationMethod" + mtype: "" + } + member { + name: "AttrValue" + mtype: "" + } + member { + name: "COMPILER_VERSION" + mtype: "" + } + member { + name: "CXX11_ABI_FLAG" + mtype: "" + } + member { + name: "ConditionalAccumulator" + mtype: "" + } + member { + name: "ConditionalAccumulatorBase" + mtype: "" + } + member { + name: "ConfigProto" + mtype: "" + } + member { + name: "DType" + mtype: "" + } + member { + name: "DeviceSpec" + mtype: "" + } + member { + name: "Dimension" + mtype: "" + } + member { + name: "Event" + mtype: "" + } + member { + name: "FIFOQueue" + mtype: "" + } + member { + name: "FixedLenFeature" + mtype: "" + } + member { + name: "FixedLenSequenceFeature" + mtype: "" + } + member { + name: "FixedLengthRecordReader" + mtype: "" + } + member { + name: "GIT_VERSION" + mtype: "" + } + member { + name: "GPUOptions" + mtype: "" + } + member { + name: "GRAPH_DEF_VERSION" + mtype: "" + } + member { + name: "GRAPH_DEF_VERSION_MIN_CONSUMER" + mtype: "" + } + member { + name: "GRAPH_DEF_VERSION_MIN_PRODUCER" + mtype: "" + } + member { + name: "GradientTape" + mtype: "" + } + member { + name: "Graph" + mtype: "" + } + member { + name: "GraphDef" + mtype: "" + } + member { + name: "GraphKeys" + mtype: "" + } + member { + name: "GraphOptions" + mtype: "" + } + member { + name: "HistogramProto" + mtype: "" + } + member { + name: "IdentityReader" + mtype: "" + } + member { + name: "IndexedSlices" + mtype: "" + } + member { + name: "InteractiveSession" + mtype: "" + } + member { + name: "LMDBReader" + mtype: "" + } + member { + name: "LogMessage" + mtype: "" + } + member { + name: "MONOLITHIC_BUILD" + mtype: "" + } + member { + name: "MetaGraphDef" + mtype: "" + } + member { + name: "NameAttrList" + mtype: "" + } + member { + name: "NodeDef" + mtype: "" + } + member { + name: "OpError" + mtype: "" + } + member { + name: "Operation" + mtype: "" + } + member { + name: "OptimizerOptions" + mtype: "" + } + member { + name: "PaddingFIFOQueue" + mtype: "" + } + member { + name: "PriorityQueue" + mtype: "" + } + member { + name: "QUANTIZED_DTYPES" + mtype: "" + } + member { + name: "QueueBase" + mtype: "" + } + member { + name: "RandomShuffleQueue" + mtype: "" + } + member { + name: "ReaderBase" + mtype: "" + } + member { + name: "RegisterGradient" + mtype: "" + } + member { + name: "RunMetadata" + mtype: "" + } + member { + name: "RunOptions" + mtype: "" + } + member { + name: "Session" + mtype: "" + } + member { + name: "SessionLog" + mtype: "" + } + member { + name: "SparseConditionalAccumulator" + mtype: "" + } + member { + name: "SparseFeature" + mtype: "" + } + member { + name: "SparseTensor" + mtype: "" + } + member { + name: "SparseTensorValue" + mtype: "" + } + member { + name: "Summary" + mtype: "" + } + member { + name: "SummaryMetadata" + mtype: "" + } + member { + name: "TFRecordReader" + mtype: "" + } + member { + name: "Tensor" + mtype: "" + } + member { + name: "TensorArray" + mtype: "" + } + member { + name: "TensorInfo" + mtype: "" + } + member { + name: "TensorShape" + mtype: "" + } + member { + name: "TextLineReader" + mtype: "" + } + member { + name: "VERSION" + mtype: "" + } + member { + name: "VarLenFeature" + mtype: "" + } + member { + name: "Variable" + mtype: "" + } + member { + name: "VariableAggregation" + mtype: "" + } + member { + name: "VariableScope" + mtype: "" + } + member { + name: "VariableSynchronization" + mtype: "" + } + member { + name: "WholeFileReader" + mtype: "" + } + member { + name: "app" + mtype: "" + } + member { + name: "bfloat16" + mtype: "" + } + member { + name: "bitwise" + mtype: "" + } + member { + name: "bool" + mtype: "" + } + member { + name: "compat" + mtype: "" + } + member { + name: "complex128" + mtype: "" + } + member { + name: "complex64" + mtype: "" + } + member { + name: "constant_initializer" + mtype: "" + } + member { + name: "contrib" + mtype: "" + } + member { + name: "data" + mtype: "" + } + member { + name: "debugging" + mtype: "" + } + member { + name: "distributions" + mtype: "" + } + member { + name: "double" + mtype: "" + } + member { + name: "dtypes" + mtype: "" + } + member { + name: "errors" + mtype: "" + } + member { + name: "estimator" + mtype: "" + } + member { + name: "feature_column" + mtype: "" + } + member { + name: "flags" + mtype: "" + } + member { + name: "float16" + mtype: "" + } + member { + name: "float32" + mtype: "" + } + member { + name: "float64" + mtype: "" + } + member { + name: "gfile" + mtype: "" + } + member { + name: "graph_util" + mtype: "" + } + member { + name: "half" + mtype: "" + } + member { + name: "image" + mtype: "" + } + member { + name: "initializers" + mtype: "" + } + member { + name: "int16" + mtype: "" + } + member { + name: "int32" + mtype: "" + } + member { + name: "int64" + mtype: "" + } + member { + name: "int8" + mtype: "" + } + member { + name: "io" + mtype: "" + } + member { + name: "keras" + mtype: "" + } + member { + name: "layers" + mtype: "" + } + member { + name: "linalg" + mtype: "" + } + member { + name: "logging" + mtype: "" + } + member { + name: "losses" + mtype: "" + } + member { + name: "manip" + mtype: "" + } + member { + name: "math" + mtype: "" + } + member { + name: "metrics" + mtype: "" + } + member { + name: "name_scope" + mtype: "" + } + member { + name: "newaxis" + mtype: "" + } + member { + name: "nn" + mtype: "" + } + member { + name: "ones_initializer" + mtype: "" + } + member { + name: "orthogonal_initializer" + mtype: "" + } + member { + name: "profiler" + mtype: "" + } + member { + name: "python_io" + mtype: "" + } + member { + name: "pywrap_tensorflow" + mtype: "" + } + member { + name: "qint16" + mtype: "" + } + member { + name: "qint32" + mtype: "" + } + member { + name: "qint8" + mtype: "" + } + member { + name: "quantization" + mtype: "" + } + member { + name: "quint16" + mtype: "" + } + member { + name: "quint8" + mtype: "" + } + member { + name: "random_normal_initializer" + mtype: "" + } + member { + name: "random_uniform_initializer" + mtype: "" + } + member { + name: "resource" + mtype: "" + } + member { + name: "resource_loader" + mtype: "" + } + member { + name: "saved_model" + mtype: "" + } + member { + name: "sets" + mtype: "" + } + member { + name: "sparse" + mtype: "" + } + member { + name: "spectral" + mtype: "" + } + member { + name: "string" + mtype: "" + } + member { + name: "strings" + mtype: "" + } + member { + name: "summary" + mtype: "" + } + member { + name: "sysconfig" + mtype: "" + } + member { + name: "test" + mtype: "" + } + member { + name: "train" + mtype: "" + } + member { + name: "truncated_normal_initializer" + mtype: "" + } + member { + name: "uint16" + mtype: "" + } + member { + name: "uint32" + mtype: "" + } + member { + name: "uint64" + mtype: "" + } + member { + name: "uint8" + mtype: "" + } + member { + name: "uniform_unit_scaling_initializer" + mtype: "" + } + member { + name: "user_ops" + mtype: "" + } + member { + name: "variable_scope" + mtype: "" + } + member { + name: "variance_scaling_initializer" + mtype: "" + } + member { + name: "variant" + mtype: "" + } + member { + name: "zeros_initializer" + mtype: "" + } + member_method { + name: "Assert" + argspec: "args=[\'condition\', \'data\', \'summarize\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "NoGradient" + argspec: "args=[\'op_type\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "NotDifferentiable" + argspec: "args=[\'op_type\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "Print" + argspec: "args=[\'input_\', \'data\', \'message\', \'first_n\', \'summarize\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "abs" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "accumulate_n" + argspec: "args=[\'inputs\', \'shape\', \'tensor_dtype\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "acos" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "acosh" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_check_numerics_ops" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "add_n" + argspec: "args=[\'inputs\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_to_collection" + argspec: "args=[\'name\', \'value\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "add_to_collections" + argspec: "args=[\'names\', \'value\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "all_variables" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "angle" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "arg_max" + argspec: "args=[\'input\', \'dimension\', \'output_type\', \'name\'], varargs=None, keywords=None, defaults=[\"\", \'None\'], " + } + member_method { + name: "arg_min" + argspec: "args=[\'input\', \'dimension\', \'output_type\', \'name\'], varargs=None, keywords=None, defaults=[\"\", \'None\'], " + } + member_method { + name: "argmax" + argspec: "args=[\'input\', \'axis\', \'name\', \'dimension\', \'output_type\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \"\"], " + } + member_method { + name: "argmin" + argspec: "args=[\'input\', \'axis\', \'name\', \'dimension\', \'output_type\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \"\"], " + } + member_method { + name: "as_dtype" + argspec: "args=[\'type_value\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "as_string" + argspec: "args=[\'input\', \'precision\', \'scientific\', \'shortest\', \'width\', \'fill\', \'name\'], varargs=None, keywords=None, defaults=[\'-1\', \'False\', \'False\', \'-1\', \'\', \'None\'], " + } + member_method { + name: "asin" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "asinh" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "assert_equal" + argspec: "args=[\'x\', \'y\', \'data\', \'summarize\', \'message\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "assert_greater" + argspec: "args=[\'x\', \'y\', \'data\', \'summarize\', \'message\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "assert_greater_equal" + argspec: "args=[\'x\', \'y\', \'data\', \'summarize\', \'message\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "assert_integer" + argspec: "args=[\'x\', \'message\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "assert_less" + argspec: "args=[\'x\', \'y\', \'data\', \'summarize\', \'message\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "assert_less_equal" + argspec: "args=[\'x\', \'y\', \'data\', \'summarize\', \'message\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "assert_near" + argspec: "args=[\'x\', \'y\', \'rtol\', \'atol\', \'data\', \'summarize\', \'message\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "assert_negative" + argspec: "args=[\'x\', \'data\', \'summarize\', \'message\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "assert_non_negative" + argspec: "args=[\'x\', \'data\', \'summarize\', \'message\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "assert_non_positive" + argspec: "args=[\'x\', \'data\', \'summarize\', \'message\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "assert_none_equal" + argspec: "args=[\'x\', \'y\', \'data\', \'summarize\', \'message\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "assert_positive" + argspec: "args=[\'x\', \'data\', \'summarize\', \'message\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "assert_proper_iterable" + argspec: "args=[\'values\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "assert_rank" + argspec: "args=[\'x\', \'rank\', \'data\', \'summarize\', \'message\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "assert_rank_at_least" + argspec: "args=[\'x\', \'rank\', \'data\', \'summarize\', \'message\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "assert_rank_in" + argspec: "args=[\'x\', \'ranks\', \'data\', \'summarize\', \'message\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "assert_same_float_dtype" + argspec: "args=[\'tensors\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "assert_scalar" + argspec: "args=[\'tensor\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "assert_type" + argspec: "args=[\'tensor\', \'tf_type\', \'message\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "assert_variables_initialized" + argspec: "args=[\'var_list\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "assign" + argspec: "args=[\'ref\', \'value\', \'validate_shape\', \'use_locking\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "assign_add" + argspec: "args=[\'ref\', \'value\', \'use_locking\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "assign_sub" + argspec: "args=[\'ref\', \'value\', \'use_locking\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "atan" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "atan2" + argspec: "args=[\'y\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "atanh" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "batch_to_space" + argspec: "args=[\'input\', \'crops\', \'block_size\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "batch_to_space_nd" + argspec: "args=[\'input\', \'block_shape\', \'crops\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "betainc" + argspec: "args=[\'a\', \'b\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "bincount" + argspec: "args=[\'arr\', \'weights\', \'minlength\', \'maxlength\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \"\"], " + } + member_method { + name: "bitcast" + argspec: "args=[\'input\', \'type\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "boolean_mask" + argspec: "args=[\'tensor\', \'mask\', \'name\', \'axis\'], varargs=None, keywords=None, defaults=[\'boolean_mask\', \'None\'], " + } + member_method { + name: "broadcast_dynamic_shape" + argspec: "args=[\'shape_x\', \'shape_y\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "broadcast_static_shape" + argspec: "args=[\'shape_x\', \'shape_y\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "broadcast_to" + argspec: "args=[\'input\', \'shape\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "case" + argspec: "args=[\'pred_fn_pairs\', \'default\', \'exclusive\', \'strict\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'False\', \'case\'], " + } + member_method { + name: "cast" + argspec: "args=[\'x\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "ceil" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "check_numerics" + argspec: "args=[\'tensor\', \'message\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "cholesky" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "cholesky_solve" + argspec: "args=[\'chol\', \'rhs\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "clip_by_average_norm" + argspec: "args=[\'t\', \'clip_norm\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "clip_by_global_norm" + argspec: "args=[\'t_list\', \'clip_norm\', \'use_norm\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "clip_by_norm" + argspec: "args=[\'t\', \'clip_norm\', \'axes\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "clip_by_value" + argspec: "args=[\'t\', \'clip_value_min\', \'clip_value_max\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "colocate_with" + argspec: "args=[\'op\', \'ignore_existing\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "complex" + argspec: "args=[\'real\', \'imag\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "concat" + argspec: "args=[\'values\', \'axis\', \'name\'], varargs=None, keywords=None, defaults=[\'concat\'], " + } + member_method { + name: "cond" + argspec: "args=[\'pred\', \'true_fn\', \'false_fn\', \'strict\', \'name\', \'fn1\', \'fn2\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'False\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "confusion_matrix" + argspec: "args=[\'labels\', \'predictions\', \'num_classes\', \'dtype\', \'name\', \'weights\'], varargs=None, keywords=None, defaults=[\'None\', \"\", \'None\', \'None\'], " + } + member_method { + name: "conj" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "constant" + argspec: "args=[\'value\', \'dtype\', \'shape\', \'name\', \'verify_shape\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'Const\', \'False\'], " + } + member_method { + name: "container" + argspec: "args=[\'container_name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "control_dependencies" + argspec: "args=[\'control_inputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "convert_to_tensor" + argspec: "args=[\'value\', \'dtype\', \'name\', \'preferred_dtype\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "convert_to_tensor_or_indexed_slices" + argspec: "args=[\'value\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "convert_to_tensor_or_sparse_tensor" + argspec: "args=[\'value\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "cos" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "cosh" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "count_nonzero" + argspec: "args=[\'input_tensor\', \'axis\', \'keepdims\', \'dtype\', \'name\', \'reduction_indices\', \'keep_dims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \"\", \'None\', \'None\', \'None\'], " + } + member_method { + name: "count_up_to" + argspec: "args=[\'ref\', \'limit\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "create_partitioned_variables" + argspec: "args=[\'shape\', \'slicing\', \'initializer\', \'dtype\', \'trainable\', \'collections\', \'name\', \'reuse\'], varargs=None, keywords=None, defaults=[\"\", \'True\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "cross" + argspec: "args=[\'a\', \'b\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "cumprod" + argspec: "args=[\'x\', \'axis\', \'exclusive\', \'reverse\', \'name\'], varargs=None, keywords=None, defaults=[\'0\', \'False\', \'False\', \'None\'], " + } + member_method { + name: "cumsum" + argspec: "args=[\'x\', \'axis\', \'exclusive\', \'reverse\', \'name\'], varargs=None, keywords=None, defaults=[\'0\', \'False\', \'False\', \'None\'], " + } + member_method { + name: "custom_gradient" + argspec: "args=[\'f\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "decode_base64" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "decode_compressed" + argspec: "args=[\'bytes\', \'compression_type\', \'name\'], varargs=None, keywords=None, defaults=[\'\', \'None\'], " + } + member_method { + name: "decode_csv" + argspec: "args=[\'records\', \'record_defaults\', \'field_delim\', \'use_quote_delim\', \'name\', \'na_value\', \'select_cols\'], varargs=None, keywords=None, defaults=[\',\', \'True\', \'None\', \'\', \'None\'], " + } + member_method { + name: "decode_json_example" + argspec: "args=[\'json_examples\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "decode_raw" + argspec: "args=[\'bytes\', \'out_type\', \'little_endian\', \'name\'], varargs=None, keywords=None, defaults=[\'True\', \'None\'], " + } + member_method { + name: "delete_session_tensor" + argspec: "args=[\'handle\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "depth_to_space" + argspec: "args=[\'input\', \'block_size\', \'name\', \'data_format\'], varargs=None, keywords=None, defaults=[\'None\', \'NHWC\'], " + } + member_method { + name: "dequantize" + argspec: "args=[\'input\', \'min_range\', \'max_range\', \'mode\', \'name\'], varargs=None, keywords=None, defaults=[\'MIN_COMBINED\', \'None\'], " + } + member_method { + name: "deserialize_many_sparse" + argspec: "args=[\'serialized_sparse\', \'dtype\', \'rank\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "device" + argspec: "args=[\'device_name_or_function\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "diag" + argspec: "args=[\'diagonal\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "diag_part" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "digamma" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "div" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "divide" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "dynamic_partition" + argspec: "args=[\'data\', \'partitions\', \'num_partitions\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "dynamic_stitch" + argspec: "args=[\'indices\', \'data\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "edit_distance" + argspec: "args=[\'hypothesis\', \'truth\', \'normalize\', \'name\'], varargs=None, keywords=None, defaults=[\'True\', \'edit_distance\'], " + } + member_method { + name: "einsum" + argspec: "args=[\'equation\'], varargs=inputs, keywords=kwargs, defaults=None" + } + member_method { + name: "enable_eager_execution" + argspec: "args=[\'config\', \'device_policy\', \'execution_mode\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "encode_base64" + argspec: "args=[\'input\', \'pad\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "equal" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "erf" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "erfc" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "executing_eagerly" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "exp" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "expand_dims" + argspec: "args=[\'input\', \'axis\', \'name\', \'dim\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "expm1" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "extract_image_patches" + argspec: "args=[\'images\', \'ksizes\', \'strides\', \'rates\', \'padding\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "eye" + argspec: "args=[\'num_rows\', \'num_columns\', \'batch_shape\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \"\", \'None\'], " + } + member_method { + name: "fake_quant_with_min_max_args" + argspec: "args=[\'inputs\', \'min\', \'max\', \'num_bits\', \'narrow_range\', \'name\'], varargs=None, keywords=None, defaults=[\'-6\', \'6\', \'8\', \'False\', \'None\'], " + } + member_method { + name: "fake_quant_with_min_max_args_gradient" + argspec: "args=[\'gradients\', \'inputs\', \'min\', \'max\', \'num_bits\', \'narrow_range\', \'name\'], varargs=None, keywords=None, defaults=[\'-6\', \'6\', \'8\', \'False\', \'None\'], " + } + member_method { + name: "fake_quant_with_min_max_vars" + argspec: "args=[\'inputs\', \'min\', \'max\', \'num_bits\', \'narrow_range\', \'name\'], varargs=None, keywords=None, defaults=[\'8\', \'False\', \'None\'], " + } + member_method { + name: "fake_quant_with_min_max_vars_gradient" + argspec: "args=[\'gradients\', \'inputs\', \'min\', \'max\', \'num_bits\', \'narrow_range\', \'name\'], varargs=None, keywords=None, defaults=[\'8\', \'False\', \'None\'], " + } + member_method { + name: "fake_quant_with_min_max_vars_per_channel" + argspec: "args=[\'inputs\', \'min\', \'max\', \'num_bits\', \'narrow_range\', \'name\'], varargs=None, keywords=None, defaults=[\'8\', \'False\', \'None\'], " + } + member_method { + name: "fake_quant_with_min_max_vars_per_channel_gradient" + argspec: "args=[\'gradients\', \'inputs\', \'min\', \'max\', \'num_bits\', \'narrow_range\', \'name\'], varargs=None, keywords=None, defaults=[\'8\', \'False\', \'None\'], " + } + member_method { + name: "fft" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "fft2d" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "fft3d" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "fill" + argspec: "args=[\'dims\', \'value\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "fixed_size_partitioner" + argspec: "args=[\'num_shards\', \'axis\'], varargs=None, keywords=None, defaults=[\'0\'], " + } + member_method { + name: "floor" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "floor_div" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "floordiv" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "floormod" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "foldl" + argspec: "args=[\'fn\', \'elems\', \'initializer\', \'parallel_iterations\', \'back_prop\', \'swap_memory\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'10\', \'True\', \'False\', \'None\'], " + } + member_method { + name: "foldr" + argspec: "args=[\'fn\', \'elems\', \'initializer\', \'parallel_iterations\', \'back_prop\', \'swap_memory\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'10\', \'True\', \'False\', \'None\'], " + } + member_method { + name: "gather" + argspec: "args=[\'params\', \'indices\', \'validate_indices\', \'name\', \'axis\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'0\'], " + } + member_method { + name: "gather_nd" + argspec: "args=[\'params\', \'indices\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_collection" + argspec: "args=[\'key\', \'scope\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_collection_ref" + argspec: "args=[\'key\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_default_graph" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_default_session" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_local_variable" + argspec: "args=[\'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'collections\', \'caching_device\', \'partitioner\', \'validate_shape\', \'use_resource\', \'synchronization\', \'aggregation\', \'custom_getter\', \'constraint\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'False\', \'None\', \'None\', \'None\', \'True\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\', \'None\', \'None\'], " + } + member_method { + name: "get_seed" + argspec: "args=[\'op_seed\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_session_handle" + argspec: "args=[\'data\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_session_tensor" + argspec: "args=[\'handle\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_variable" + argspec: "args=[\'name\', \'shape\', \'dtype\', \'initializer\', \'regularizer\', \'trainable\', \'collections\', \'caching_device\', \'partitioner\', \'validate_shape\', \'use_resource\', \'custom_getter\', \'constraint\', \'synchronization\', \'aggregation\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'True\', \'None\', \'None\', \'None\', \'VariableSynchronization.AUTO\', \'VariableAggregation.NONE\'], " + } + member_method { + name: "get_variable_scope" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "global_norm" + argspec: "args=[\'t_list\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "global_variables" + argspec: "args=[\'scope\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "global_variables_initializer" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "glorot_normal_initializer" + argspec: "args=[\'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\', \"\"], " + } + member_method { + name: "glorot_uniform_initializer" + argspec: "args=[\'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'None\', \"\"], " + } + member_method { + name: "gradients" + argspec: "args=[\'ys\', \'xs\', \'grad_ys\', \'name\', \'colocate_gradients_with_ops\', \'gate_gradients\', \'aggregation_method\', \'stop_gradients\'], varargs=None, keywords=None, defaults=[\'None\', \'gradients\', \'False\', \'False\', \'None\', \'None\'], " + } + member_method { + name: "greater" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "greater_equal" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "group" + argspec: "args=[], varargs=inputs, keywords=kwargs, defaults=None" + } + member_method { + name: "guarantee_const" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "hessians" + argspec: "args=[\'ys\', \'xs\', \'name\', \'colocate_gradients_with_ops\', \'gate_gradients\', \'aggregation_method\'], varargs=None, keywords=None, defaults=[\'hessians\', \'False\', \'False\', \'None\'], " + } + member_method { + name: "histogram_fixed_width" + argspec: "args=[\'values\', \'value_range\', \'nbins\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\'100\', \"\", \'None\'], " + } + member_method { + name: "histogram_fixed_width_bins" + argspec: "args=[\'values\', \'value_range\', \'nbins\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\'100\', \"\", \'None\'], " + } + member_method { + name: "identity" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "identity_n" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "ifft" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "ifft2d" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "ifft3d" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "igamma" + argspec: "args=[\'a\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "igammac" + argspec: "args=[\'a\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "imag" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "import_graph_def" + argspec: "args=[\'graph_def\', \'input_map\', \'return_elements\', \'name\', \'op_dict\', \'producer_op_list\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "initialize_all_tables" + argspec: "args=[\'name\'], varargs=None, keywords=None, defaults=[\'init_all_tables\'], " + } + member_method { + name: "initialize_all_variables" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "initialize_local_variables" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "initialize_variables" + argspec: "args=[\'var_list\', \'name\'], varargs=None, keywords=None, defaults=[\'init\'], " + } + member_method { + name: "invert_permutation" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "is_finite" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "is_inf" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "is_nan" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "is_non_decreasing" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "is_numeric_tensor" + argspec: "args=[\'tensor\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "is_strictly_increasing" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "is_variable_initialized" + argspec: "args=[\'variable\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "lbeta" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "less" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "less_equal" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "lgamma" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "lin_space" + argspec: "args=[\'start\', \'stop\', \'num\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "linspace" + argspec: "args=[\'start\', \'stop\', \'num\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "load_file_system_library" + argspec: "args=[\'library_filename\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "load_op_library" + argspec: "args=[\'library_filename\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "local_variables" + argspec: "args=[\'scope\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "local_variables_initializer" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "log" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "log1p" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "log_sigmoid" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "logical_and" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "logical_not" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "logical_or" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "logical_xor" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'LogicalXor\'], " + } + member_method { + name: "make_ndarray" + argspec: "args=[\'tensor\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "make_template" + argspec: "args=[\'name_\', \'func_\', \'create_scope_now_\', \'unique_name_\', \'custom_getter_\'], varargs=None, keywords=kwargs, defaults=[\'False\', \'None\', \'None\'], " + } + member_method { + name: "make_tensor_proto" + argspec: "args=[\'values\', \'dtype\', \'shape\', \'verify_shape\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'False\'], " + } + member_method { + name: "map_fn" + argspec: "args=[\'fn\', \'elems\', \'dtype\', \'parallel_iterations\', \'back_prop\', \'swap_memory\', \'infer_shape\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'10\', \'True\', \'False\', \'True\', \'None\'], " + } + member_method { + name: "matching_files" + argspec: "args=[\'pattern\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "matmul" + argspec: "args=[\'a\', \'b\', \'transpose_a\', \'transpose_b\', \'adjoint_a\', \'adjoint_b\', \'a_is_sparse\', \'b_is_sparse\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'False\', \'False\', \'False\', \'False\', \'None\'], " + } + member_method { + name: "matrix_band_part" + argspec: "args=[\'input\', \'num_lower\', \'num_upper\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "matrix_determinant" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "matrix_diag" + argspec: "args=[\'diagonal\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "matrix_diag_part" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "matrix_inverse" + argspec: "args=[\'input\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "matrix_set_diag" + argspec: "args=[\'input\', \'diagonal\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "matrix_solve" + argspec: "args=[\'matrix\', \'rhs\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "matrix_solve_ls" + argspec: "args=[\'matrix\', \'rhs\', \'l2_regularizer\', \'fast\', \'name\'], varargs=None, keywords=None, defaults=[\'0.0\', \'True\', \'None\'], " + } + member_method { + name: "matrix_transpose" + argspec: "args=[\'a\', \'name\', \'conjugate\'], varargs=None, keywords=None, defaults=[\'matrix_transpose\', \'False\'], " + } + member_method { + name: "matrix_triangular_solve" + argspec: "args=[\'matrix\', \'rhs\', \'lower\', \'adjoint\', \'name\'], varargs=None, keywords=None, defaults=[\'True\', \'False\', \'None\'], " + } + member_method { + name: "maximum" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "meshgrid" + argspec: "args=[], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "min_max_variable_partitioner" + argspec: "args=[\'max_partitions\', \'axis\', \'min_slice_size\', \'bytes_per_string_element\'], varargs=None, keywords=None, defaults=[\'1\', \'0\', \'262144\', \'16\'], " + } + member_method { + name: "minimum" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "mod" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "model_variables" + argspec: "args=[\'scope\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "moving_average_variables" + argspec: "args=[\'scope\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "multinomial" + argspec: "args=[\'logits\', \'num_samples\', \'seed\', \'name\', \'output_dtype\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "multiply" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "negative" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "no_op" + argspec: "args=[\'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "no_regularizer" + argspec: "args=[\'_\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "norm" + argspec: "args=[\'tensor\', \'ord\', \'axis\', \'keepdims\', \'name\', \'keep_dims\'], varargs=None, keywords=None, defaults=[\'euclidean\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "not_equal" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "one_hot" + argspec: "args=[\'indices\', \'depth\', \'on_value\', \'off_value\', \'axis\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "ones" + argspec: "args=[\'shape\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\"\", \'None\'], " + } + member_method { + name: "ones_like" + argspec: "args=[\'tensor\', \'dtype\', \'name\', \'optimize\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'True\'], " + } + member_method { + name: "op_scope" + argspec: "args=[\'values\', \'name\', \'default_name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "pad" + argspec: "args=[\'tensor\', \'paddings\', \'mode\', \'name\', \'constant_values\'], varargs=None, keywords=None, defaults=[\'CONSTANT\', \'None\', \'0\'], " + } + member_method { + name: "parallel_stack" + argspec: "args=[\'values\', \'name\'], varargs=None, keywords=None, defaults=[\'parallel_stack\'], " + } + member_method { + name: "parse_example" + argspec: "args=[\'serialized\', \'features\', \'name\', \'example_names\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "parse_single_example" + argspec: "args=[\'serialized\', \'features\', \'name\', \'example_names\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "parse_single_sequence_example" + argspec: "args=[\'serialized\', \'context_features\', \'sequence_features\', \'example_name\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "parse_tensor" + argspec: "args=[\'serialized\', \'out_type\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "placeholder" + argspec: "args=[\'dtype\', \'shape\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "placeholder_with_default" + argspec: "args=[\'input\', \'shape\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "polygamma" + argspec: "args=[\'a\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "pow" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "py_func" + argspec: "args=[\'func\', \'inp\', \'Tout\', \'stateful\', \'name\'], varargs=None, keywords=None, defaults=[\'True\', \'None\'], " + } + member_method { + name: "qr" + argspec: "args=[\'input\', \'full_matrices\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "quantize" + argspec: "args=[\'input\', \'min_range\', \'max_range\', \'T\', \'mode\', \'round_mode\', \'name\'], varargs=None, keywords=None, defaults=[\'MIN_COMBINED\', \'HALF_AWAY_FROM_ZERO\', \'None\'], " + } + member_method { + name: "quantize_v2" + argspec: "args=[\'input\', \'min_range\', \'max_range\', \'T\', \'mode\', \'name\', \'round_mode\'], varargs=None, keywords=None, defaults=[\'MIN_COMBINED\', \'None\', \'HALF_AWAY_FROM_ZERO\'], " + } + member_method { + name: "quantized_concat" + argspec: "args=[\'concat_dim\', \'values\', \'input_mins\', \'input_maxes\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "random_crop" + argspec: "args=[\'value\', \'size\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "random_gamma" + argspec: "args=[\'shape\', \'alpha\', \'beta\', \'dtype\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \"\", \'None\', \'None\'], " + } + member_method { + name: "random_normal" + argspec: "args=[\'shape\', \'mean\', \'stddev\', \'dtype\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'0.0\', \'1.0\', \"\", \'None\', \'None\'], " + } + member_method { + name: "random_poisson" + argspec: "args=[\'lam\', \'shape\', \'dtype\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\"\", \'None\', \'None\'], " + } + member_method { + name: "random_shuffle" + argspec: "args=[\'value\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "random_uniform" + argspec: "args=[\'shape\', \'minval\', \'maxval\', \'dtype\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'0\', \'None\', \"\", \'None\', \'None\'], " + } + member_method { + name: "range" + argspec: "args=[\'start\', \'limit\', \'delta\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'None\', \'range\'], " + } + member_method { + name: "rank" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "read_file" + argspec: "args=[\'filename\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "real" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "realdiv" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "reciprocal" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "reduce_all" + argspec: "args=[\'input_tensor\', \'axis\', \'keepdims\', \'name\', \'reduction_indices\', \'keep_dims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "reduce_any" + argspec: "args=[\'input_tensor\', \'axis\', \'keepdims\', \'name\', \'reduction_indices\', \'keep_dims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "reduce_join" + argspec: "args=[\'inputs\', \'axis\', \'keep_dims\', \'separator\', \'name\', \'reduction_indices\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'\', \'None\', \'None\'], " + } + member_method { + name: "reduce_logsumexp" + argspec: "args=[\'input_tensor\', \'axis\', \'keepdims\', \'name\', \'reduction_indices\', \'keep_dims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "reduce_max" + argspec: "args=[\'input_tensor\', \'axis\', \'keepdims\', \'name\', \'reduction_indices\', \'keep_dims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "reduce_mean" + argspec: "args=[\'input_tensor\', \'axis\', \'keepdims\', \'name\', \'reduction_indices\', \'keep_dims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "reduce_min" + argspec: "args=[\'input_tensor\', \'axis\', \'keepdims\', \'name\', \'reduction_indices\', \'keep_dims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "reduce_prod" + argspec: "args=[\'input_tensor\', \'axis\', \'keepdims\', \'name\', \'reduction_indices\', \'keep_dims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "reduce_sum" + argspec: "args=[\'input_tensor\', \'axis\', \'keepdims\', \'name\', \'reduction_indices\', \'keep_dims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "regex_replace" + argspec: "args=[\'input\', \'pattern\', \'rewrite\', \'replace_global\', \'name\'], varargs=None, keywords=None, defaults=[\'True\', \'None\'], " + } + member_method { + name: "register_tensor_conversion_function" + argspec: "args=[\'base_type\', \'conversion_func\', \'priority\'], varargs=None, keywords=None, defaults=[\'100\'], " + } + member_method { + name: "report_uninitialized_variables" + argspec: "args=[\'var_list\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'report_uninitialized_variables\'], " + } + member_method { + name: "required_space_to_batch_paddings" + argspec: "args=[\'input_shape\', \'block_shape\', \'base_paddings\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "reset_default_graph" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "reshape" + argspec: "args=[\'tensor\', \'shape\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "reverse" + argspec: "args=[\'tensor\', \'axis\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "reverse_sequence" + argspec: "args=[\'input\', \'seq_lengths\', \'seq_axis\', \'batch_axis\', \'name\', \'seq_dim\', \'batch_dim\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "reverse_v2" + argspec: "args=[\'tensor\', \'axis\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "rint" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "round" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "rsqrt" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "saturate_cast" + argspec: "args=[\'value\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "scalar_mul" + argspec: "args=[\'scalar\', \'x\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "scan" + argspec: "args=[\'fn\', \'elems\', \'initializer\', \'parallel_iterations\', \'back_prop\', \'swap_memory\', \'infer_shape\', \'reverse\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'10\', \'True\', \'False\', \'True\', \'False\', \'None\'], " + } + member_method { + name: "scatter_add" + argspec: "args=[\'ref\', \'indices\', \'updates\', \'use_locking\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "scatter_div" + argspec: "args=[\'ref\', \'indices\', \'updates\', \'use_locking\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "scatter_max" + argspec: "args=[\'ref\', \'indices\', \'updates\', \'use_locking\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "scatter_min" + argspec: "args=[\'ref\', \'indices\', \'updates\', \'use_locking\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "scatter_mul" + argspec: "args=[\'ref\', \'indices\', \'updates\', \'use_locking\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "scatter_nd" + argspec: "args=[\'indices\', \'updates\', \'shape\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "scatter_nd_add" + argspec: "args=[\'ref\', \'indices\', \'updates\', \'use_locking\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "scatter_nd_sub" + argspec: "args=[\'ref\', \'indices\', \'updates\', \'use_locking\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "scatter_nd_update" + argspec: "args=[\'ref\', \'indices\', \'updates\', \'use_locking\', \'name\'], varargs=None, keywords=None, defaults=[\'True\', \'None\'], " + } + member_method { + name: "scatter_sub" + argspec: "args=[\'ref\', \'indices\', \'updates\', \'use_locking\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "scatter_update" + argspec: "args=[\'ref\', \'indices\', \'updates\', \'use_locking\', \'name\'], varargs=None, keywords=None, defaults=[\'True\', \'None\'], " + } + member_method { + name: "segment_max" + argspec: "args=[\'data\', \'segment_ids\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "segment_mean" + argspec: "args=[\'data\', \'segment_ids\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "segment_min" + argspec: "args=[\'data\', \'segment_ids\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "segment_prod" + argspec: "args=[\'data\', \'segment_ids\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "segment_sum" + argspec: "args=[\'data\', \'segment_ids\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "self_adjoint_eig" + argspec: "args=[\'tensor\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "self_adjoint_eigvals" + argspec: "args=[\'tensor\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "sequence_mask" + argspec: "args=[\'lengths\', \'maxlen\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \"\", \'None\'], " + } + member_method { + name: "serialize_many_sparse" + argspec: "args=[\'sp_input\', \'name\', \'out_type\'], varargs=None, keywords=None, defaults=[\'None\', \"\"], " + } + member_method { + name: "serialize_sparse" + argspec: "args=[\'sp_input\', \'name\', \'out_type\'], varargs=None, keywords=None, defaults=[\'None\', \"\"], " + } + member_method { + name: "serialize_tensor" + argspec: "args=[\'tensor\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "set_random_seed" + argspec: "args=[\'seed\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "setdiff1d" + argspec: "args=[\'x\', \'y\', \'index_dtype\', \'name\'], varargs=None, keywords=None, defaults=[\"\", \'None\'], " + } + member_method { + name: "shape" + argspec: "args=[\'input\', \'name\', \'out_type\'], varargs=None, keywords=None, defaults=[\'None\', \"\"], " + } + member_method { + name: "shape_n" + argspec: "args=[\'input\', \'out_type\', \'name\'], varargs=None, keywords=None, defaults=[\"\", \'None\'], " + } + member_method { + name: "sigmoid" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "sign" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "sin" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "sinh" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "size" + argspec: "args=[\'input\', \'name\', \'out_type\'], varargs=None, keywords=None, defaults=[\'None\', \"\"], " + } + member_method { + name: "slice" + argspec: "args=[\'input_\', \'begin\', \'size\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "space_to_batch" + argspec: "args=[\'input\', \'paddings\', \'block_size\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "space_to_batch_nd" + argspec: "args=[\'input\', \'block_shape\', \'paddings\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "space_to_depth" + argspec: "args=[\'input\', \'block_size\', \'name\', \'data_format\'], varargs=None, keywords=None, defaults=[\'None\', \'NHWC\'], " + } + member_method { + name: "sparse_add" + argspec: "args=[\'a\', \'b\', \'thresh\'], varargs=None, keywords=None, defaults=[\'0\'], " + } + member_method { + name: "sparse_concat" + argspec: "args=[\'axis\', \'sp_inputs\', \'name\', \'expand_nonconcat_dim\', \'concat_dim\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\'], " + } + member_method { + name: "sparse_fill_empty_rows" + argspec: "args=[\'sp_input\', \'default_value\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "sparse_mask" + argspec: "args=[\'a\', \'mask_indices\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "sparse_matmul" + argspec: "args=[\'a\', \'b\', \'transpose_a\', \'transpose_b\', \'a_is_sparse\', \'b_is_sparse\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'False\', \'False\', \'None\'], " + } + member_method { + name: "sparse_maximum" + argspec: "args=[\'sp_a\', \'sp_b\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "sparse_merge" + argspec: "args=[\'sp_ids\', \'sp_values\', \'vocab_size\', \'name\', \'already_sorted\'], varargs=None, keywords=None, defaults=[\'None\', \'False\'], " + } + member_method { + name: "sparse_minimum" + argspec: "args=[\'sp_a\', \'sp_b\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "sparse_placeholder" + argspec: "args=[\'dtype\', \'shape\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "sparse_reduce_max" + argspec: "args=[\'sp_input\', \'axis\', \'keep_dims\', \'reduction_axes\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\'], " + } + member_method { + name: "sparse_reduce_max_sparse" + argspec: "args=[\'sp_input\', \'axis\', \'keep_dims\', \'reduction_axes\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\'], " + } + member_method { + name: "sparse_reduce_sum" + argspec: "args=[\'sp_input\', \'axis\', \'keep_dims\', \'reduction_axes\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\'], " + } + member_method { + name: "sparse_reduce_sum_sparse" + argspec: "args=[\'sp_input\', \'axis\', \'keep_dims\', \'reduction_axes\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\'], " + } + member_method { + name: "sparse_reorder" + argspec: "args=[\'sp_input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "sparse_reset_shape" + argspec: "args=[\'sp_input\', \'new_shape\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "sparse_reshape" + argspec: "args=[\'sp_input\', \'shape\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "sparse_retain" + argspec: "args=[\'sp_input\', \'to_retain\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "sparse_segment_mean" + argspec: "args=[\'data\', \'indices\', \'segment_ids\', \'name\', \'num_segments\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "sparse_segment_sqrt_n" + argspec: "args=[\'data\', \'indices\', \'segment_ids\', \'name\', \'num_segments\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "sparse_segment_sum" + argspec: "args=[\'data\', \'indices\', \'segment_ids\', \'name\', \'num_segments\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "sparse_slice" + argspec: "args=[\'sp_input\', \'start\', \'size\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "sparse_softmax" + argspec: "args=[\'sp_input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "sparse_split" + argspec: "args=[\'keyword_required\', \'sp_input\', \'num_split\', \'axis\', \'name\', \'split_dim\'], varargs=None, keywords=None, defaults=[\'KeywordRequired()\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "sparse_tensor_dense_matmul" + argspec: "args=[\'sp_a\', \'b\', \'adjoint_a\', \'adjoint_b\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'None\'], " + } + member_method { + name: "sparse_tensor_to_dense" + argspec: "args=[\'sp_input\', \'default_value\', \'validate_indices\', \'name\'], varargs=None, keywords=None, defaults=[\'0\', \'True\', \'None\'], " + } + member_method { + name: "sparse_to_dense" + argspec: "args=[\'sparse_indices\', \'output_shape\', \'sparse_values\', \'default_value\', \'validate_indices\', \'name\'], varargs=None, keywords=None, defaults=[\'0\', \'True\', \'None\'], " + } + member_method { + name: "sparse_to_indicator" + argspec: "args=[\'sp_input\', \'vocab_size\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "sparse_transpose" + argspec: "args=[\'sp_input\', \'perm\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "split" + argspec: "args=[\'value\', \'num_or_size_splits\', \'axis\', \'num\', \'name\'], varargs=None, keywords=None, defaults=[\'0\', \'None\', \'split\'], " + } + member_method { + name: "sqrt" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "square" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "squared_difference" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "squeeze" + argspec: "args=[\'input\', \'axis\', \'name\', \'squeeze_dims\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "stack" + argspec: "args=[\'values\', \'axis\', \'name\'], varargs=None, keywords=None, defaults=[\'0\', \'stack\'], " + } + member_method { + name: "stop_gradient" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "strided_slice" + argspec: "args=[\'input_\', \'begin\', \'end\', \'strides\', \'begin_mask\', \'end_mask\', \'ellipsis_mask\', \'new_axis_mask\', \'shrink_axis_mask\', \'var\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'0\', \'0\', \'0\', \'0\', \'0\', \'None\', \'None\'], " + } + member_method { + name: "string_join" + argspec: "args=[\'inputs\', \'separator\', \'name\'], varargs=None, keywords=None, defaults=[\'\', \'None\'], " + } + member_method { + name: "string_split" + argspec: "args=[\'source\', \'delimiter\', \'skip_empty\'], varargs=None, keywords=None, defaults=[\' \', \'True\'], " + } + member_method { + name: "string_strip" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "string_to_hash_bucket" + argspec: "args=[\'string_tensor\', \'num_buckets\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "string_to_hash_bucket_fast" + argspec: "args=[\'input\', \'num_buckets\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "string_to_hash_bucket_strong" + argspec: "args=[\'input\', \'num_buckets\', \'key\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "string_to_number" + argspec: "args=[\'string_tensor\', \'out_type\', \'name\'], varargs=None, keywords=None, defaults=[\"\", \'None\'], " + } + member_method { + name: "substr" + argspec: "args=[\'input\', \'pos\', \'len\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "subtract" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "svd" + argspec: "args=[\'tensor\', \'full_matrices\', \'compute_uv\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'True\', \'None\'], " + } + member_method { + name: "tables_initializer" + argspec: "args=[\'name\'], varargs=None, keywords=None, defaults=[\'init_all_tables\'], " + } + member_method { + name: "tan" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "tanh" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "tensordot" + argspec: "args=[\'a\', \'b\', \'axes\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "tile" + argspec: "args=[\'input\', \'multiples\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "timestamp" + argspec: "args=[\'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "to_bfloat16" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'ToBFloat16\'], " + } + member_method { + name: "to_complex128" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'ToComplex128\'], " + } + member_method { + name: "to_complex64" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'ToComplex64\'], " + } + member_method { + name: "to_double" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'ToDouble\'], " + } + member_method { + name: "to_float" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'ToFloat\'], " + } + member_method { + name: "to_int32" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'ToInt32\'], " + } + member_method { + name: "to_int64" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'ToInt64\'], " + } + member_method { + name: "trace" + argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "trainable_variables" + argspec: "args=[\'scope\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "transpose" + argspec: "args=[\'a\', \'perm\', \'name\', \'conjugate\'], varargs=None, keywords=None, defaults=[\'None\', \'transpose\', \'False\'], " + } + member_method { + name: "truediv" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "truncated_normal" + argspec: "args=[\'shape\', \'mean\', \'stddev\', \'dtype\', \'seed\', \'name\'], varargs=None, keywords=None, defaults=[\'0.0\', \'1.0\', \"\", \'None\', \'None\'], " + } + member_method { + name: "truncatediv" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "truncatemod" + argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "tuple" + argspec: "args=[\'tensors\', \'name\', \'control_inputs\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "unique" + argspec: "args=[\'x\', \'out_idx\', \'name\'], varargs=None, keywords=None, defaults=[\"\", \'None\'], " + } + member_method { + name: "unique_with_counts" + argspec: "args=[\'x\', \'out_idx\', \'name\'], varargs=None, keywords=None, defaults=[\"\", \'None\'], " + } + member_method { + name: "unravel_index" + argspec: "args=[\'indices\', \'dims\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "unsorted_segment_max" + argspec: "args=[\'data\', \'segment_ids\', \'num_segments\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "unsorted_segment_mean" + argspec: "args=[\'data\', \'segment_ids\', \'num_segments\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "unsorted_segment_min" + argspec: "args=[\'data\', \'segment_ids\', \'num_segments\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "unsorted_segment_prod" + argspec: "args=[\'data\', \'segment_ids\', \'num_segments\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "unsorted_segment_sqrt_n" + argspec: "args=[\'data\', \'segment_ids\', \'num_segments\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "unsorted_segment_sum" + argspec: "args=[\'data\', \'segment_ids\', \'num_segments\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "unstack" + argspec: "args=[\'value\', \'num\', \'axis\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'0\', \'unstack\'], " + } + member_method { + name: "variable_axis_size_partitioner" + argspec: "args=[\'max_shard_bytes\', \'axis\', \'bytes_per_string_element\', \'max_shards\'], varargs=None, keywords=None, defaults=[\'0\', \'16\', \'None\'], " + } + member_method { + name: "variable_op_scope" + argspec: "args=[\'values\', \'name_or_scope\', \'default_name\', \'initializer\', \'regularizer\', \'caching_device\', \'partitioner\', \'custom_getter\', \'reuse\', \'dtype\', \'use_resource\', \'constraint\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "variables_initializer" + argspec: "args=[\'var_list\', \'name\'], varargs=None, keywords=None, defaults=[\'init\'], " + } + member_method { + name: "verify_tensor_all_finite" + argspec: "args=[\'t\', \'msg\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "where" + argspec: "args=[\'condition\', \'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "while_loop" + argspec: "args=[\'cond\', \'body\', \'loop_vars\', \'shape_invariants\', \'parallel_iterations\', \'back_prop\', \'swap_memory\', \'name\', \'maximum_iterations\', \'return_same_structure\'], varargs=None, keywords=None, defaults=[\'None\', \'10\', \'True\', \'False\', \'None\', \'None\', \'False\'], " + } + member_method { + name: "write_file" + argspec: "args=[\'filename\', \'contents\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "zeros" + argspec: "args=[\'shape\', \'dtype\', \'name\'], varargs=None, keywords=None, defaults=[\"\", \'None\'], " + } + member_method { + name: "zeros_like" + argspec: "args=[\'tensor\', \'dtype\', \'name\', \'optimize\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'True\'], " + } + member_method { + name: "zeta" + argspec: "args=[\'x\', \'q\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.profiler.-advice-proto.-checker.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.profiler.-advice-proto.-checker.pbtxt new file mode 100644 index 0000000000..e09c44cc9c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.profiler.-advice-proto.-checker.pbtxt @@ -0,0 +1,12 @@ +path: "tensorflow.profiler.AdviceProto.Checker" +tf_proto { + descriptor { + name: "Checker" + field { + name: "reports" + number: 2 + label: LABEL_REPEATED + type: TYPE_STRING + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.profiler.-advice-proto.-checkers-entry.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.profiler.-advice-proto.-checkers-entry.pbtxt new file mode 100644 index 0000000000..8746243549 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.profiler.-advice-proto.-checkers-entry.pbtxt @@ -0,0 +1,22 @@ +path: "tensorflow.profiler.AdviceProto.CheckersEntry" +tf_proto { + descriptor { + name: "CheckersEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.tfprof.AdviceProto.Checker" + } + options { + map_entry: true + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.profiler.-advice-proto.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.profiler.-advice-proto.pbtxt new file mode 100644 index 0000000000..a8a8858ccd --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.profiler.-advice-proto.pbtxt @@ -0,0 +1,41 @@ +path: "tensorflow.profiler.AdviceProto" +tf_proto { + descriptor { + name: "AdviceProto" + field { + name: "checkers" + number: 1 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.tfprof.AdviceProto.CheckersEntry" + } + nested_type { + name: "CheckersEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.tfprof.AdviceProto.Checker" + } + options { + map_entry: true + } + } + nested_type { + name: "Checker" + field { + name: "reports" + number: 2 + label: LABEL_REPEATED + type: TYPE_STRING + } + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.profiler.-graph-node-proto.-input-shapes-entry.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.profiler.-graph-node-proto.-input-shapes-entry.pbtxt new file mode 100644 index 0000000000..afec73f537 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.profiler.-graph-node-proto.-input-shapes-entry.pbtxt @@ -0,0 +1,22 @@ +path: "tensorflow.profiler.GraphNodeProto.InputShapesEntry" +tf_proto { + descriptor { + name: "InputShapesEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.TensorShapeProto" + } + options { + map_entry: true + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.profiler.-graph-node-proto.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.profiler.-graph-node-proto.pbtxt new file mode 100644 index 0000000000..3c83177005 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.profiler.-graph-node-proto.pbtxt @@ -0,0 +1,191 @@ +path: "tensorflow.profiler.GraphNodeProto" +tf_proto { + descriptor { + name: "GraphNodeProto" + field { + name: "name" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "tensor_value" + number: 15 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.tfprof.TFProfTensorProto" + } + field { + name: "run_count" + number: 21 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "exec_micros" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "accelerator_exec_micros" + number: 17 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "cpu_exec_micros" + number: 18 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "requested_bytes" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "peak_bytes" + number: 24 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "residual_bytes" + number: 25 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "output_bytes" + number: 26 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "parameters" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "float_ops" + number: 13 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "devices" + number: 10 + label: LABEL_REPEATED + type: TYPE_STRING + } + field { + name: "total_definition_count" + number: 23 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "total_run_count" + number: 22 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "total_exec_micros" + number: 6 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "total_accelerator_exec_micros" + number: 19 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "total_cpu_exec_micros" + number: 20 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "total_requested_bytes" + number: 7 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "total_peak_bytes" + number: 27 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "total_residual_bytes" + number: 28 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "total_output_bytes" + number: 29 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "total_parameters" + number: 8 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "total_float_ops" + number: 14 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "shapes" + number: 11 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.TensorShapeProto" + } + field { + name: "input_shapes" + number: 16 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.tfprof.GraphNodeProto.InputShapesEntry" + } + field { + name: "children" + number: 12 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.tfprof.GraphNodeProto" + } + nested_type { + name: "InputShapesEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.TensorShapeProto" + } + options { + map_entry: true + } + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.profiler.-multi-graph-node-proto.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.profiler.-multi-graph-node-proto.pbtxt new file mode 100644 index 0000000000..2b08a05437 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.profiler.-multi-graph-node-proto.pbtxt @@ -0,0 +1,134 @@ +path: "tensorflow.profiler.MultiGraphNodeProto" +tf_proto { + descriptor { + name: "MultiGraphNodeProto" + field { + name: "name" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "exec_micros" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "accelerator_exec_micros" + number: 12 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "cpu_exec_micros" + number: 13 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "requested_bytes" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "peak_bytes" + number: 16 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "residual_bytes" + number: 17 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "output_bytes" + number: 18 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "parameters" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "float_ops" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "total_exec_micros" + number: 6 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "total_accelerator_exec_micros" + number: 14 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "total_cpu_exec_micros" + number: 15 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "total_requested_bytes" + number: 7 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "total_peak_bytes" + number: 19 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "total_residual_bytes" + number: 20 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "total_output_bytes" + number: 21 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "total_parameters" + number: 8 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "total_float_ops" + number: 9 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "graph_nodes" + number: 10 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.tfprof.GraphNodeProto" + } + field { + name: "children" + number: 11 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.tfprof.MultiGraphNodeProto" + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.profiler.-op-log-proto.-id-to-string-entry.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.profiler.-op-log-proto.-id-to-string-entry.pbtxt new file mode 100644 index 0000000000..b3adc50c7e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.profiler.-op-log-proto.-id-to-string-entry.pbtxt @@ -0,0 +1,21 @@ +path: "tensorflow.profiler.OpLogProto.IdToStringEntry" +tf_proto { + descriptor { + name: "IdToStringEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + options { + map_entry: true + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.profiler.-op-log-proto.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.profiler.-op-log-proto.pbtxt new file mode 100644 index 0000000000..7510c566ba --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.profiler.-op-log-proto.pbtxt @@ -0,0 +1,38 @@ +path: "tensorflow.profiler.OpLogProto" +tf_proto { + descriptor { + name: "OpLogProto" + field { + name: "log_entries" + number: 1 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.tfprof.OpLogEntry" + } + field { + name: "id_to_string" + number: 2 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.tfprof.OpLogProto.IdToStringEntry" + } + nested_type { + name: "IdToStringEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + options { + map_entry: true + } + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.profiler.-profile-option-builder.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.profiler.-profile-option-builder.pbtxt new file mode 100644 index 0000000000..19ff38a390 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.profiler.-profile-option-builder.pbtxt @@ -0,0 +1,93 @@ +path: "tensorflow.profiler.ProfileOptionBuilder" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'options\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "account_displayed_op_only" + argspec: "args=[\'self\', \'is_true\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "float_operation" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "order_by" + argspec: "args=[\'self\', \'attribute\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "select" + argspec: "args=[\'self\', \'attributes\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "time_and_memory" + argspec: "args=[\'min_micros\', \'min_bytes\', \'min_accelerator_micros\', \'min_cpu_micros\', \'min_peak_bytes\', \'min_residual_bytes\', \'min_output_bytes\'], varargs=None, keywords=None, defaults=[\'1\', \'1\', \'0\', \'0\', \'0\', \'0\', \'0\'], " + } + member_method { + name: "trainable_variables_parameter" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "with_accounted_types" + argspec: "args=[\'self\', \'account_type_regexes\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "with_empty_output" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "with_file_output" + argspec: "args=[\'self\', \'outfile\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "with_max_depth" + argspec: "args=[\'self\', \'max_depth\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "with_min_execution_time" + argspec: "args=[\'self\', \'min_micros\', \'min_accelerator_micros\', \'min_cpu_micros\'], varargs=None, keywords=None, defaults=[\'0\', \'0\', \'0\'], " + } + member_method { + name: "with_min_float_operations" + argspec: "args=[\'self\', \'min_float_ops\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "with_min_memory" + argspec: "args=[\'self\', \'min_bytes\', \'min_peak_bytes\', \'min_residual_bytes\', \'min_output_bytes\'], varargs=None, keywords=None, defaults=[\'0\', \'0\', \'0\', \'0\'], " + } + member_method { + name: "with_min_occurrence" + argspec: "args=[\'self\', \'min_occurrence\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "with_min_parameters" + argspec: "args=[\'self\', \'min_params\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "with_node_names" + argspec: "args=[\'self\', \'start_name_regexes\', \'show_name_regexes\', \'hide_name_regexes\', \'trim_name_regexes\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "with_pprof_output" + argspec: "args=[\'self\', \'pprof_file\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "with_stdout_output" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "with_step" + argspec: "args=[\'self\', \'step\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "with_timeline_output" + argspec: "args=[\'self\', \'timeline_file\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.profiler.-profiler.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.profiler.-profiler.pbtxt new file mode 100644 index 0000000000..acb61dae9f --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.profiler.-profiler.pbtxt @@ -0,0 +1,37 @@ +path: "tensorflow.profiler.Profiler" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'graph\', \'op_log\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "add_step" + argspec: "args=[\'self\', \'step\', \'run_meta\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "advise" + argspec: "args=[\'self\', \'options\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "profile_graph" + argspec: "args=[\'self\', \'options\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "profile_name_scope" + argspec: "args=[\'self\', \'options\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "profile_operations" + argspec: "args=[\'self\', \'options\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "profile_python" + argspec: "args=[\'self\', \'options\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "serialize_to_string" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.profiler.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.profiler.pbtxt new file mode 100644 index 0000000000..7b4d3ac522 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.profiler.pbtxt @@ -0,0 +1,39 @@ +path: "tensorflow.profiler" +tf_module { + member { + name: "AdviceProto" + mtype: "" + } + member { + name: "GraphNodeProto" + mtype: "" + } + member { + name: "MultiGraphNodeProto" + mtype: "" + } + member { + name: "OpLogProto" + mtype: "" + } + member { + name: "ProfileOptionBuilder" + mtype: "" + } + member { + name: "Profiler" + mtype: "" + } + member_method { + name: "advise" + argspec: "args=[\'graph\', \'run_meta\', \'options\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'0\'], " + } + member_method { + name: "profile" + argspec: "args=[\'graph\', \'run_meta\', \'op_log\', \'cmd\', \'options\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'scope\', \'0\'], " + } + member_method { + name: "write_op_log" + argspec: "args=[\'graph\', \'log_dir\', \'op_log\', \'run_meta\', \'add_trace\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'True\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.python_io.-t-f-record-compression-type.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.python_io.-t-f-record-compression-type.pbtxt new file mode 100644 index 0000000000..4941dda50e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.python_io.-t-f-record-compression-type.pbtxt @@ -0,0 +1,20 @@ +path: "tensorflow.python_io.TFRecordCompressionType" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "GZIP" + mtype: "" + } + member { + name: "NONE" + mtype: "" + } + member { + name: "ZLIB" + mtype: "" + } + member_method { + name: "__init__" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.python_io.-t-f-record-options.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.python_io.-t-f-record-options.pbtxt new file mode 100644 index 0000000000..0853716023 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.python_io.-t-f-record-options.pbtxt @@ -0,0 +1,17 @@ +path: "tensorflow.python_io.TFRecordOptions" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "compression_type_map" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'compression_type\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_compression_type_string" + argspec: "args=[\'cls\', \'options\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.python_io.-t-f-record-writer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.python_io.-t-f-record-writer.pbtxt new file mode 100644 index 0000000000..31775de2d1 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.python_io.-t-f-record-writer.pbtxt @@ -0,0 +1,21 @@ +path: "tensorflow.python_io.TFRecordWriter" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'path\', \'options\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "close" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "flush" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "write" + argspec: "args=[\'self\', \'record\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.python_io.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.python_io.pbtxt new file mode 100644 index 0000000000..7c9953e5fe --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.python_io.pbtxt @@ -0,0 +1,19 @@ +path: "tensorflow.python_io" +tf_module { + member { + name: "TFRecordCompressionType" + mtype: "" + } + member { + name: "TFRecordOptions" + mtype: "" + } + member { + name: "TFRecordWriter" + mtype: "" + } + member_method { + name: "tf_record_iterator" + argspec: "args=[\'path\', \'options\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.quantization.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.quantization.pbtxt new file mode 100644 index 0000000000..6d865efed0 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.quantization.pbtxt @@ -0,0 +1,35 @@ +path: "tensorflow.quantization" +tf_module { + member_method { + name: "dequantize" + argspec: "args=[\'input\', \'min_range\', \'max_range\', \'mode\', \'name\'], varargs=None, keywords=None, defaults=[\'MIN_COMBINED\', \'None\'], " + } + member_method { + name: "fake_quant_with_min_max_args" + argspec: "args=[\'inputs\', \'min\', \'max\', \'num_bits\', \'narrow_range\', \'name\'], varargs=None, keywords=None, defaults=[\'-6\', \'6\', \'8\', \'False\', \'None\'], " + } + member_method { + name: "fake_quant_with_min_max_args_gradient" + argspec: "args=[\'gradients\', \'inputs\', \'min\', \'max\', \'num_bits\', \'narrow_range\', \'name\'], varargs=None, keywords=None, defaults=[\'-6\', \'6\', \'8\', \'False\', \'None\'], " + } + member_method { + name: "fake_quant_with_min_max_vars" + argspec: "args=[\'inputs\', \'min\', \'max\', \'num_bits\', \'narrow_range\', \'name\'], varargs=None, keywords=None, defaults=[\'8\', \'False\', \'None\'], " + } + member_method { + name: "fake_quant_with_min_max_vars_gradient" + argspec: "args=[\'gradients\', \'inputs\', \'min\', \'max\', \'num_bits\', \'narrow_range\', \'name\'], varargs=None, keywords=None, defaults=[\'8\', \'False\', \'None\'], " + } + member_method { + name: "fake_quant_with_min_max_vars_per_channel" + argspec: "args=[\'inputs\', \'min\', \'max\', \'num_bits\', \'narrow_range\', \'name\'], varargs=None, keywords=None, defaults=[\'8\', \'False\', \'None\'], " + } + member_method { + name: "fake_quant_with_min_max_vars_per_channel_gradient" + argspec: "args=[\'gradients\', \'inputs\', \'min\', \'max\', \'num_bits\', \'narrow_range\', \'name\'], varargs=None, keywords=None, defaults=[\'8\', \'False\', \'None\'], " + } + member_method { + name: "quantized_concat" + argspec: "args=[\'concat_dim\', \'values\', \'input_mins\', \'input_maxes\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.random_normal_initializer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.random_normal_initializer.pbtxt new file mode 100644 index 0000000000..5993fdeb9c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.random_normal_initializer.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.random_normal_initializer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'mean\', \'stddev\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'0.0\', \'1.0\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.random_uniform_initializer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.random_uniform_initializer.pbtxt new file mode 100644 index 0000000000..a434ed1599 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.random_uniform_initializer.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.random_uniform_initializer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'minval\', \'maxval\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'0\', \'None\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.resource_loader.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.resource_loader.pbtxt new file mode 100644 index 0000000000..288b78b4cd --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.resource_loader.pbtxt @@ -0,0 +1,23 @@ +path: "tensorflow.resource_loader" +tf_module { + member_method { + name: "get_data_files_path" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_path_to_datafile" + argspec: "args=[\'path\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_root_dir_with_all_resources" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "load_resource" + argspec: "args=[\'path\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "readahead_file_path" + argspec: "args=[\'path\', \'readahead\'], varargs=None, keywords=None, defaults=[\'128M\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.saved_model.builder.-saved-model-builder.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.saved_model.builder.-saved-model-builder.pbtxt new file mode 100644 index 0000000000..83bd703540 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.saved_model.builder.-saved-model-builder.pbtxt @@ -0,0 +1,21 @@ +path: "tensorflow.saved_model.builder.SavedModelBuilder" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'export_dir\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "add_meta_graph" + argspec: "args=[\'self\', \'tags\', \'signature_def_map\', \'assets_collection\', \'legacy_init_op\', \'clear_devices\', \'main_op\', \'strip_default_attrs\', \'saver\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'False\', \'None\', \'False\', \'None\'], " + } + member_method { + name: "add_meta_graph_and_variables" + argspec: "args=[\'self\', \'sess\', \'tags\', \'signature_def_map\', \'assets_collection\', \'legacy_init_op\', \'clear_devices\', \'main_op\', \'strip_default_attrs\', \'saver\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'False\', \'None\', \'False\', \'None\'], " + } + member_method { + name: "save" + argspec: "args=[\'self\', \'as_text\'], varargs=None, keywords=None, defaults=[\'False\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.saved_model.builder.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.saved_model.builder.pbtxt new file mode 100644 index 0000000000..adc697ad1c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.saved_model.builder.pbtxt @@ -0,0 +1,7 @@ +path: "tensorflow.saved_model.builder" +tf_module { + member { + name: "SavedModelBuilder" + mtype: "" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.saved_model.constants.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.saved_model.constants.pbtxt new file mode 100644 index 0000000000..20e10aa094 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.saved_model.constants.pbtxt @@ -0,0 +1,39 @@ +path: "tensorflow.saved_model.constants" +tf_module { + member { + name: "ASSETS_DIRECTORY" + mtype: "" + } + member { + name: "ASSETS_KEY" + mtype: "" + } + member { + name: "LEGACY_INIT_OP_KEY" + mtype: "" + } + member { + name: "MAIN_OP_KEY" + mtype: "" + } + member { + name: "SAVED_MODEL_FILENAME_PB" + mtype: "" + } + member { + name: "SAVED_MODEL_FILENAME_PBTXT" + mtype: "" + } + member { + name: "SAVED_MODEL_SCHEMA_VERSION" + mtype: "" + } + member { + name: "VARIABLES_DIRECTORY" + mtype: "" + } + member { + name: "VARIABLES_FILENAME" + mtype: "" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.saved_model.loader.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.saved_model.loader.pbtxt new file mode 100644 index 0000000000..511e6b4712 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.saved_model.loader.pbtxt @@ -0,0 +1,11 @@ +path: "tensorflow.saved_model.loader" +tf_module { + member_method { + name: "load" + argspec: "args=[\'sess\', \'tags\', \'export_dir\', \'import_scope\'], varargs=None, keywords=saver_kwargs, defaults=[\'None\'], " + } + member_method { + name: "maybe_saved_model_directory" + argspec: "args=[\'export_dir\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.saved_model.main_op.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.saved_model.main_op.pbtxt new file mode 100644 index 0000000000..176cb788c2 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.saved_model.main_op.pbtxt @@ -0,0 +1,11 @@ +path: "tensorflow.saved_model.main_op" +tf_module { + member_method { + name: "main_op" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "main_op_with_restore" + argspec: "args=[\'restore_op_name\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.saved_model.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.saved_model.pbtxt new file mode 100644 index 0000000000..e1a0385092 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.saved_model.pbtxt @@ -0,0 +1,39 @@ +path: "tensorflow.saved_model" +tf_module { + member { + name: "builder" + mtype: "" + } + member { + name: "constants" + mtype: "" + } + member { + name: "loader" + mtype: "" + } + member { + name: "main_op" + mtype: "" + } + member { + name: "signature_constants" + mtype: "" + } + member { + name: "signature_def_utils" + mtype: "" + } + member { + name: "tag_constants" + mtype: "" + } + member { + name: "utils" + mtype: "" + } + member_method { + name: "simple_save" + argspec: "args=[\'session\', \'export_dir\', \'inputs\', \'outputs\', \'legacy_init_op\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.saved_model.signature_constants.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.saved_model.signature_constants.pbtxt new file mode 100644 index 0000000000..478d410e06 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.saved_model.signature_constants.pbtxt @@ -0,0 +1,47 @@ +path: "tensorflow.saved_model.signature_constants" +tf_module { + member { + name: "CLASSIFY_INPUTS" + mtype: "" + } + member { + name: "CLASSIFY_METHOD_NAME" + mtype: "" + } + member { + name: "CLASSIFY_OUTPUT_CLASSES" + mtype: "" + } + member { + name: "CLASSIFY_OUTPUT_SCORES" + mtype: "" + } + member { + name: "DEFAULT_SERVING_SIGNATURE_DEF_KEY" + mtype: "" + } + member { + name: "PREDICT_INPUTS" + mtype: "" + } + member { + name: "PREDICT_METHOD_NAME" + mtype: "" + } + member { + name: "PREDICT_OUTPUTS" + mtype: "" + } + member { + name: "REGRESS_INPUTS" + mtype: "" + } + member { + name: "REGRESS_METHOD_NAME" + mtype: "" + } + member { + name: "REGRESS_OUTPUTS" + mtype: "" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.saved_model.signature_def_utils.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.saved_model.signature_def_utils.pbtxt new file mode 100644 index 0000000000..a5602464ee --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.saved_model.signature_def_utils.pbtxt @@ -0,0 +1,23 @@ +path: "tensorflow.saved_model.signature_def_utils" +tf_module { + member_method { + name: "build_signature_def" + argspec: "args=[\'inputs\', \'outputs\', \'method_name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "classification_signature_def" + argspec: "args=[\'examples\', \'classes\', \'scores\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "is_valid_signature" + argspec: "args=[\'signature_def\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "predict_signature_def" + argspec: "args=[\'inputs\', \'outputs\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "regression_signature_def" + argspec: "args=[\'examples\', \'predictions\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.saved_model.tag_constants.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.saved_model.tag_constants.pbtxt new file mode 100644 index 0000000000..6af72498d7 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.saved_model.tag_constants.pbtxt @@ -0,0 +1,19 @@ +path: "tensorflow.saved_model.tag_constants" +tf_module { + member { + name: "GPU" + mtype: "" + } + member { + name: "SERVING" + mtype: "" + } + member { + name: "TPU" + mtype: "" + } + member { + name: "TRAINING" + mtype: "" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.saved_model.utils.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.saved_model.utils.pbtxt new file mode 100644 index 0000000000..d95c946682 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.saved_model.utils.pbtxt @@ -0,0 +1,11 @@ +path: "tensorflow.saved_model.utils" +tf_module { + member_method { + name: "build_tensor_info" + argspec: "args=[\'tensor\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_tensor_from_tensor_info" + argspec: "args=[\'tensor_info\', \'graph\', \'import_scope\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.sets.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.sets.pbtxt new file mode 100644 index 0000000000..8a196b1a55 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.sets.pbtxt @@ -0,0 +1,19 @@ +path: "tensorflow.sets" +tf_module { + member_method { + name: "set_difference" + argspec: "args=[\'a\', \'b\', \'aminusb\', \'validate_indices\'], varargs=None, keywords=None, defaults=[\'True\', \'True\'], " + } + member_method { + name: "set_intersection" + argspec: "args=[\'a\', \'b\', \'validate_indices\'], varargs=None, keywords=None, defaults=[\'True\'], " + } + member_method { + name: "set_size" + argspec: "args=[\'a\', \'validate_indices\'], varargs=None, keywords=None, defaults=[\'True\'], " + } + member_method { + name: "set_union" + argspec: "args=[\'a\', \'b\', \'validate_indices\'], varargs=None, keywords=None, defaults=[\'True\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.sparse.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.sparse.pbtxt new file mode 100644 index 0000000000..bbfe395031 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.sparse.pbtxt @@ -0,0 +1,11 @@ +path: "tensorflow.sparse" +tf_module { + member_method { + name: "cross" + argspec: "args=[\'inputs\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "cross_hashed" + argspec: "args=[\'inputs\', \'num_buckets\', \'hash_key\', \'name\'], varargs=None, keywords=None, defaults=[\'0\', \'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.spectral.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.spectral.pbtxt new file mode 100644 index 0000000000..6a421ef12d --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.spectral.pbtxt @@ -0,0 +1,59 @@ +path: "tensorflow.spectral" +tf_module { + member_method { + name: "dct" + argspec: "args=[\'input\', \'type\', \'n\', \'axis\', \'norm\', \'name\'], varargs=None, keywords=None, defaults=[\'2\', \'None\', \'-1\', \'None\', \'None\'], " + } + member_method { + name: "fft" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "fft2d" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "fft3d" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "idct" + argspec: "args=[\'input\', \'type\', \'n\', \'axis\', \'norm\', \'name\'], varargs=None, keywords=None, defaults=[\'2\', \'None\', \'-1\', \'None\', \'None\'], " + } + member_method { + name: "ifft" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "ifft2d" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "ifft3d" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "irfft" + argspec: "args=[\'input_tensor\', \'fft_length\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "irfft2d" + argspec: "args=[\'input_tensor\', \'fft_length\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "irfft3d" + argspec: "args=[\'input_tensor\', \'fft_length\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "rfft" + argspec: "args=[\'input_tensor\', \'fft_length\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "rfft2d" + argspec: "args=[\'input_tensor\', \'fft_length\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "rfft3d" + argspec: "args=[\'input_tensor\', \'fft_length\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.strings.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.strings.pbtxt new file mode 100644 index 0000000000..9a831fed26 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.strings.pbtxt @@ -0,0 +1,43 @@ +path: "tensorflow.strings" +tf_module { + member_method { + name: "join" + argspec: "args=[\'inputs\', \'separator\', \'name\'], varargs=None, keywords=None, defaults=[\'\', \'None\'], " + } + member_method { + name: "regex_full_match" + argspec: "args=[\'input\', \'pattern\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "regex_replace" + argspec: "args=[\'input\', \'pattern\', \'rewrite\', \'replace_global\', \'name\'], varargs=None, keywords=None, defaults=[\'True\', \'None\'], " + } + member_method { + name: "split" + argspec: "args=[\'source\', \'sep\', \'maxsplit\'], varargs=None, keywords=None, defaults=[\'None\', \'-1\'], " + } + member_method { + name: "strip" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "substr" + argspec: "args=[\'input\', \'pos\', \'len\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "to_hash_bucket" + argspec: "args=[\'string_tensor\', \'num_buckets\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "to_hash_bucket_fast" + argspec: "args=[\'input\', \'num_buckets\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "to_hash_bucket_strong" + argspec: "args=[\'input\', \'num_buckets\', \'key\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "to_number" + argspec: "args=[\'string_tensor\', \'out_type\', \'name\'], varargs=None, keywords=None, defaults=[\"\", \'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.summary.-event.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.summary.-event.pbtxt new file mode 100644 index 0000000000..eb99d0f533 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.summary.-event.pbtxt @@ -0,0 +1,74 @@ +path: "tensorflow.summary.Event" +tf_proto { + descriptor { + name: "Event" + field { + name: "wall_time" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_DOUBLE + } + field { + name: "step" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "file_version" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_STRING + oneof_index: 0 + } + field { + name: "graph_def" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_BYTES + oneof_index: 0 + } + field { + name: "summary" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.Summary" + oneof_index: 0 + } + field { + name: "log_message" + number: 6 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.LogMessage" + oneof_index: 0 + } + field { + name: "session_log" + number: 7 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.SessionLog" + oneof_index: 0 + } + field { + name: "tagged_run_metadata" + number: 8 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.TaggedRunMetadata" + oneof_index: 0 + } + field { + name: "meta_graph_def" + number: 9 + label: LABEL_OPTIONAL + type: TYPE_BYTES + oneof_index: 0 + } + oneof_decl { + name: "what" + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.summary.-file-writer-cache.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.summary.-file-writer-cache.pbtxt new file mode 100644 index 0000000000..2a5b63dcea --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.summary.-file-writer-cache.pbtxt @@ -0,0 +1,16 @@ +path: "tensorflow.summary.FileWriterCache" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "clear" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get" + argspec: "args=[\'logdir\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.summary.-file-writer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.summary.-file-writer.pbtxt new file mode 100644 index 0000000000..6b65b0ace3 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.summary.-file-writer.pbtxt @@ -0,0 +1,50 @@ +path: "tensorflow.summary.FileWriter" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'logdir\', \'graph\', \'max_queue\', \'flush_secs\', \'graph_def\', \'filename_suffix\', \'session\'], varargs=None, keywords=None, defaults=[\'None\', \'10\', \'120\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "add_event" + argspec: "args=[\'self\', \'event\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "add_graph" + argspec: "args=[\'self\', \'graph\', \'global_step\', \'graph_def\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "add_meta_graph" + argspec: "args=[\'self\', \'meta_graph_def\', \'global_step\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_run_metadata" + argspec: "args=[\'self\', \'run_metadata\', \'tag\', \'global_step\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_session_log" + argspec: "args=[\'self\', \'session_log\', \'global_step\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "add_summary" + argspec: "args=[\'self\', \'summary\', \'global_step\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "close" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "flush" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_logdir" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "reopen" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.summary.-session-log.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.summary.-session-log.pbtxt new file mode 100644 index 0000000000..73de73869c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.summary.-session-log.pbtxt @@ -0,0 +1,44 @@ +path: "tensorflow.summary.SessionLog" +tf_proto { + descriptor { + name: "SessionLog" + field { + name: "status" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_ENUM + type_name: ".tensorflow.SessionLog.SessionStatus" + } + field { + name: "checkpoint_path" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "msg" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + enum_type { + name: "SessionStatus" + value { + name: "STATUS_UNSPECIFIED" + number: 0 + } + value { + name: "START" + number: 1 + } + value { + name: "STOP" + number: 2 + } + value { + name: "CHECKPOINT" + number: 3 + } + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.summary.-summary-description.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.summary.-summary-description.pbtxt new file mode 100644 index 0000000000..4a8b59cf02 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.summary.-summary-description.pbtxt @@ -0,0 +1,12 @@ +path: "tensorflow.summary.SummaryDescription" +tf_proto { + descriptor { + name: "SummaryDescription" + field { + name: "type_hint" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.summary.-summary.-audio.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.summary.-summary.-audio.pbtxt new file mode 100644 index 0000000000..8b271cf58f --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.summary.-summary.-audio.pbtxt @@ -0,0 +1,36 @@ +path: "tensorflow.summary.Summary.Audio" +tf_proto { + descriptor { + name: "Audio" + field { + name: "sample_rate" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_FLOAT + } + field { + name: "num_channels" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "length_frames" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "encoded_audio_string" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_BYTES + } + field { + name: "content_type" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.summary.-summary.-image.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.summary.-summary.-image.pbtxt new file mode 100644 index 0000000000..dbbc02dd05 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.summary.-summary.-image.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.summary.Summary.Image" +tf_proto { + descriptor { + name: "Image" + field { + name: "height" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "width" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "colorspace" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "encoded_image_string" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_BYTES + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.summary.-summary.-value.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.summary.-summary.-value.pbtxt new file mode 100644 index 0000000000..4176171cd9 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.summary.-summary.-value.pbtxt @@ -0,0 +1,74 @@ +path: "tensorflow.summary.Summary.Value" +tf_proto { + descriptor { + name: "Value" + field { + name: "node_name" + number: 7 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "tag" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "metadata" + number: 9 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.SummaryMetadata" + } + field { + name: "simple_value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_FLOAT + oneof_index: 0 + } + field { + name: "obsolete_old_style_histogram" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_BYTES + oneof_index: 0 + } + field { + name: "image" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.Summary.Image" + oneof_index: 0 + } + field { + name: "histo" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.HistogramProto" + oneof_index: 0 + } + field { + name: "audio" + number: 6 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.Summary.Audio" + oneof_index: 0 + } + field { + name: "tensor" + number: 8 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.TensorProto" + oneof_index: 0 + } + oneof_decl { + name: "value" + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.summary.-summary.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.summary.-summary.pbtxt new file mode 100644 index 0000000000..d6c5e3a87a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.summary.-summary.pbtxt @@ -0,0 +1,144 @@ +path: "tensorflow.summary.Summary" +tf_proto { + descriptor { + name: "Summary" + field { + name: "value" + number: 1 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.Summary.Value" + } + nested_type { + name: "Image" + field { + name: "height" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "width" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "colorspace" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "encoded_image_string" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_BYTES + } + } + nested_type { + name: "Audio" + field { + name: "sample_rate" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_FLOAT + } + field { + name: "num_channels" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "length_frames" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_INT64 + } + field { + name: "encoded_audio_string" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_BYTES + } + field { + name: "content_type" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + } + nested_type { + name: "Value" + field { + name: "node_name" + number: 7 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "tag" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "metadata" + number: 9 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.SummaryMetadata" + } + field { + name: "simple_value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_FLOAT + oneof_index: 0 + } + field { + name: "obsolete_old_style_histogram" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_BYTES + oneof_index: 0 + } + field { + name: "image" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.Summary.Image" + oneof_index: 0 + } + field { + name: "histo" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.HistogramProto" + oneof_index: 0 + } + field { + name: "audio" + number: 6 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.Summary.Audio" + oneof_index: 0 + } + field { + name: "tensor" + number: 8 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.TensorProto" + oneof_index: 0 + } + oneof_decl { + name: "value" + } + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.summary.-tagged-run-metadata.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.summary.-tagged-run-metadata.pbtxt new file mode 100644 index 0000000000..27c8873320 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.summary.-tagged-run-metadata.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.summary.TaggedRunMetadata" +tf_proto { + descriptor { + name: "TaggedRunMetadata" + field { + name: "tag" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "run_metadata" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_BYTES + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.summary.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.summary.pbtxt new file mode 100644 index 0000000000..871ebb5247 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.summary.pbtxt @@ -0,0 +1,67 @@ +path: "tensorflow.summary" +tf_module { + member { + name: "Event" + mtype: "" + } + member { + name: "FileWriter" + mtype: "" + } + member { + name: "FileWriterCache" + mtype: "" + } + member { + name: "SessionLog" + mtype: "" + } + member { + name: "Summary" + mtype: "" + } + member { + name: "SummaryDescription" + mtype: "" + } + member { + name: "TaggedRunMetadata" + mtype: "" + } + member_method { + name: "audio" + argspec: "args=[\'name\', \'tensor\', \'sample_rate\', \'max_outputs\', \'collections\', \'family\'], varargs=None, keywords=None, defaults=[\'3\', \'None\', \'None\'], " + } + member_method { + name: "get_summary_description" + argspec: "args=[\'node_def\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "histogram" + argspec: "args=[\'name\', \'values\', \'collections\', \'family\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "image" + argspec: "args=[\'name\', \'tensor\', \'max_outputs\', \'collections\', \'family\'], varargs=None, keywords=None, defaults=[\'3\', \'None\', \'None\'], " + } + member_method { + name: "merge" + argspec: "args=[\'inputs\', \'collections\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "merge_all" + argspec: "args=[\'key\', \'scope\'], varargs=None, keywords=None, defaults=[\'summaries\', \'None\'], " + } + member_method { + name: "scalar" + argspec: "args=[\'name\', \'tensor\', \'collections\', \'family\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "tensor_summary" + argspec: "args=[\'name\', \'tensor\', \'summary_description\', \'collections\', \'summary_metadata\', \'family\', \'display_name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "text" + argspec: "args=[\'name\', \'tensor\', \'collections\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.sysconfig.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.sysconfig.pbtxt new file mode 100644 index 0000000000..2f00aeac25 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.sysconfig.pbtxt @@ -0,0 +1,19 @@ +path: "tensorflow.sysconfig" +tf_module { + member_method { + name: "get_compile_flags" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_include" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_lib" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_link_flags" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.test.-benchmark.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.test.-benchmark.pbtxt new file mode 100644 index 0000000000..df528e26b6 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.test.-benchmark.pbtxt @@ -0,0 +1,21 @@ +path: "tensorflow.test.Benchmark" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "is_abstract" + argspec: "args=[\'cls\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "report_benchmark" + argspec: "args=[\'self\', \'iters\', \'cpu_time\', \'wall_time\', \'throughput\', \'extras\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "run_op_benchmark" + argspec: "args=[\'self\', \'sess\', \'op_or_tensor\', \'feed_dict\', \'burn_iters\', \'min_iters\', \'store_trace\', \'store_memory_usage\', \'name\', \'extras\', \'mbs\'], varargs=None, keywords=None, defaults=[\'None\', \'2\', \'10\', \'False\', \'True\', \'None\', \'None\', \'0\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.test.-stub-out-for-testing.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.test.-stub-out-for-testing.pbtxt new file mode 100644 index 0000000000..e02a0c6097 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.test.-stub-out-for-testing.pbtxt @@ -0,0 +1,28 @@ +path: "tensorflow.test.StubOutForTesting" +tf_class { + is_instance: "" + member_method { + name: "CleanUp" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "Set" + argspec: "args=[\'self\', \'parent\', \'child_name\', \'new_child\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "SmartSet" + argspec: "args=[\'self\', \'obj\', \'attr_name\', \'new_attr\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "SmartUnsetAll" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "UnsetAll" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.test.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.test.pbtxt new file mode 100644 index 0000000000..abe9b068ae --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.test.pbtxt @@ -0,0 +1,59 @@ +path: "tensorflow.test" +tf_module { + member { + name: "Benchmark" + mtype: "" + } + member { + name: "StubOutForTesting" + mtype: "" + } + member { + name: "TestCase" + mtype: "" + } + member { + name: "mock" + mtype: "" + } + member_method { + name: "assert_equal_graph_def" + argspec: "args=[\'actual\', \'expected\', \'checkpoint_v2\'], varargs=None, keywords=None, defaults=[\'False\'], " + } + member_method { + name: "compute_gradient" + argspec: "args=[\'x\', \'x_shape\', \'y\', \'y_shape\', \'x_init_value\', \'delta\', \'init_targets\', \'extra_feed_dict\'], varargs=None, keywords=None, defaults=[\'None\', \'0.001\', \'None\', \'None\'], " + } + member_method { + name: "compute_gradient_error" + argspec: "args=[\'x\', \'x_shape\', \'y\', \'y_shape\', \'x_init_value\', \'delta\', \'init_targets\', \'extra_feed_dict\'], varargs=None, keywords=None, defaults=[\'None\', \'0.001\', \'None\', \'None\'], " + } + member_method { + name: "create_local_cluster" + argspec: "args=[\'num_workers\', \'num_ps\', \'protocol\', \'worker_config\', \'ps_config\'], varargs=None, keywords=None, defaults=[\'grpc\', \'None\', \'None\'], " + } + member_method { + name: "get_temp_dir" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "gpu_device_name" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "is_built_with_cuda" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "is_gpu_available" + argspec: "args=[\'cuda_only\', \'min_cuda_compute_capability\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "main" + argspec: "args=[\'argv\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "test_src_dir_path" + argspec: "args=[\'relative_path\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-adadelta-optimizer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-adadelta-optimizer.pbtxt new file mode 100644 index 0000000000..1f1d8b6f9e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-adadelta-optimizer.pbtxt @@ -0,0 +1,51 @@ +path: "tensorflow.train.AdadeltaOptimizer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "GATE_GRAPH" + mtype: "" + } + member { + name: "GATE_NONE" + mtype: "" + } + member { + name: "GATE_OP" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'learning_rate\', \'rho\', \'epsilon\', \'use_locking\', \'name\'], varargs=None, keywords=None, defaults=[\'0.001\', \'0.95\', \'1e-08\', \'False\', \'Adadelta\'], " + } + member_method { + name: "apply_gradients" + argspec: "args=[\'self\', \'grads_and_vars\', \'global_step\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "compute_gradients" + argspec: "args=[\'self\', \'loss\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'None\', \'False\', \'None\'], " + } + member_method { + name: "get_name" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot" + argspec: "args=[\'self\', \'var\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "minimize" + argspec: "args=[\'self\', \'loss\', \'global_step\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'name\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'1\', \'None\', \'False\', \'None\', \'None\'], " + } + member_method { + name: "variables" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-adagrad-d-a-optimizer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-adagrad-d-a-optimizer.pbtxt new file mode 100644 index 0000000000..a7c05d4849 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-adagrad-d-a-optimizer.pbtxt @@ -0,0 +1,51 @@ +path: "tensorflow.train.AdagradDAOptimizer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "GATE_GRAPH" + mtype: "" + } + member { + name: "GATE_NONE" + mtype: "" + } + member { + name: "GATE_OP" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'learning_rate\', \'global_step\', \'initial_gradient_squared_accumulator_value\', \'l1_regularization_strength\', \'l2_regularization_strength\', \'use_locking\', \'name\'], varargs=None, keywords=None, defaults=[\'0.1\', \'0.0\', \'0.0\', \'False\', \'AdagradDA\'], " + } + member_method { + name: "apply_gradients" + argspec: "args=[\'self\', \'grads_and_vars\', \'global_step\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "compute_gradients" + argspec: "args=[\'self\', \'loss\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'None\', \'False\', \'None\'], " + } + member_method { + name: "get_name" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot" + argspec: "args=[\'self\', \'var\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "minimize" + argspec: "args=[\'self\', \'loss\', \'global_step\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'name\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'1\', \'None\', \'False\', \'None\', \'None\'], " + } + member_method { + name: "variables" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-adagrad-optimizer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-adagrad-optimizer.pbtxt new file mode 100644 index 0000000000..bc8b92389c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-adagrad-optimizer.pbtxt @@ -0,0 +1,51 @@ +path: "tensorflow.train.AdagradOptimizer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "GATE_GRAPH" + mtype: "" + } + member { + name: "GATE_NONE" + mtype: "" + } + member { + name: "GATE_OP" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'learning_rate\', \'initial_accumulator_value\', \'use_locking\', \'name\'], varargs=None, keywords=None, defaults=[\'0.1\', \'False\', \'Adagrad\'], " + } + member_method { + name: "apply_gradients" + argspec: "args=[\'self\', \'grads_and_vars\', \'global_step\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "compute_gradients" + argspec: "args=[\'self\', \'loss\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'None\', \'False\', \'None\'], " + } + member_method { + name: "get_name" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot" + argspec: "args=[\'self\', \'var\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "minimize" + argspec: "args=[\'self\', \'loss\', \'global_step\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'name\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'1\', \'None\', \'False\', \'None\', \'None\'], " + } + member_method { + name: "variables" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-adam-optimizer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-adam-optimizer.pbtxt new file mode 100644 index 0000000000..5d17be9378 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-adam-optimizer.pbtxt @@ -0,0 +1,51 @@ +path: "tensorflow.train.AdamOptimizer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "GATE_GRAPH" + mtype: "" + } + member { + name: "GATE_NONE" + mtype: "" + } + member { + name: "GATE_OP" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'learning_rate\', \'beta1\', \'beta2\', \'epsilon\', \'use_locking\', \'name\'], varargs=None, keywords=None, defaults=[\'0.001\', \'0.9\', \'0.999\', \'1e-08\', \'False\', \'Adam\'], " + } + member_method { + name: "apply_gradients" + argspec: "args=[\'self\', \'grads_and_vars\', \'global_step\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "compute_gradients" + argspec: "args=[\'self\', \'loss\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'None\', \'False\', \'None\'], " + } + member_method { + name: "get_name" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot" + argspec: "args=[\'self\', \'var\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "minimize" + argspec: "args=[\'self\', \'loss\', \'global_step\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'name\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'1\', \'None\', \'False\', \'None\', \'None\'], " + } + member_method { + name: "variables" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-bytes-list.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-bytes-list.pbtxt new file mode 100644 index 0000000000..87e4f160e5 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-bytes-list.pbtxt @@ -0,0 +1,12 @@ +path: "tensorflow.train.BytesList" +tf_proto { + descriptor { + name: "BytesList" + field { + name: "value" + number: 1 + label: LABEL_REPEATED + type: TYPE_BYTES + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-checkpoint-saver-hook.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-checkpoint-saver-hook.pbtxt new file mode 100644 index 0000000000..c3037baa8c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-checkpoint-saver-hook.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.train.CheckpointSaverHook" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'checkpoint_dir\', \'save_secs\', \'save_steps\', \'saver\', \'checkpoint_basename\', \'scaffold\', \'listeners\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'model.ckpt\', \'None\', \'None\'], " + } + member_method { + name: "after_create_session" + argspec: "args=[\'self\', \'session\', \'coord\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "after_run" + argspec: "args=[\'self\', \'run_context\', \'run_values\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "before_run" + argspec: "args=[\'self\', \'run_context\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "begin" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "end" + argspec: "args=[\'self\', \'session\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-checkpoint-saver-listener.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-checkpoint-saver-listener.pbtxt new file mode 100644 index 0000000000..9d3688e565 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-checkpoint-saver-listener.pbtxt @@ -0,0 +1,24 @@ +path: "tensorflow.train.CheckpointSaverListener" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "after_save" + argspec: "args=[\'self\', \'session\', \'global_step_value\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "before_save" + argspec: "args=[\'self\', \'session\', \'global_step_value\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "begin" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "end" + argspec: "args=[\'self\', \'session\', \'global_step_value\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-checkpoint.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-checkpoint.pbtxt new file mode 100644 index 0000000000..2d067e4eff --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-checkpoint.pbtxt @@ -0,0 +1,23 @@ +path: "tensorflow.train.Checkpoint" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "save_counter" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\'], varargs=None, keywords=kwargs, defaults=None" + } + member_method { + name: "restore" + argspec: "args=[\'self\', \'save_path\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "save" + argspec: "args=[\'self\', \'file_prefix\', \'session\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-chief-session-creator.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-chief-session-creator.pbtxt new file mode 100644 index 0000000000..abbe273be3 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-chief-session-creator.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.train.ChiefSessionCreator" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'scaffold\', \'master\', \'config\', \'checkpoint_dir\', \'checkpoint_filename_with_path\'], varargs=None, keywords=None, defaults=[\'None\', \'\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "create_session" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-cluster-def.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-cluster-def.pbtxt new file mode 100644 index 0000000000..f9de26839f --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-cluster-def.pbtxt @@ -0,0 +1,13 @@ +path: "tensorflow.train.ClusterDef" +tf_proto { + descriptor { + name: "ClusterDef" + field { + name: "job" + number: 1 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.JobDef" + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-cluster-spec.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-cluster-spec.pbtxt new file mode 100644 index 0000000000..1658b15a5f --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-cluster-spec.pbtxt @@ -0,0 +1,37 @@ +path: "tensorflow.train.ClusterSpec" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "jobs" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'cluster\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "as_cluster_def" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "as_dict" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "job_tasks" + argspec: "args=[\'self\', \'job_name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "num_tasks" + argspec: "args=[\'self\', \'job_name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "task_address" + argspec: "args=[\'self\', \'job_name\', \'task_index\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "task_indices" + argspec: "args=[\'self\', \'job_name\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-coordinator.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-coordinator.pbtxt new file mode 100644 index 0000000000..11277f077e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-coordinator.pbtxt @@ -0,0 +1,45 @@ +path: "tensorflow.train.Coordinator" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "joined" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'clean_stop_exception_types\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "clear_stop" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "join" + argspec: "args=[\'self\', \'threads\', \'stop_grace_period_secs\', \'ignore_live_threads\'], varargs=None, keywords=None, defaults=[\'None\', \'120\', \'False\'], " + } + member_method { + name: "raise_requested_exception" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "register_thread" + argspec: "args=[\'self\', \'thread\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "request_stop" + argspec: "args=[\'self\', \'ex\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "should_stop" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "stop_on_exception" + argspec: "args=[], varargs=args, keywords=kwds, defaults=None" + } + member_method { + name: "wait_for_stop" + argspec: "args=[\'self\', \'timeout\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-example.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-example.pbtxt new file mode 100644 index 0000000000..23c30f1ef4 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-example.pbtxt @@ -0,0 +1,13 @@ +path: "tensorflow.train.Example" +tf_proto { + descriptor { + name: "Example" + field { + name: "features" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.Features" + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-exponential-moving-average.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-exponential-moving-average.pbtxt new file mode 100644 index 0000000000..c9fe136e68 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-exponential-moving-average.pbtxt @@ -0,0 +1,29 @@ +path: "tensorflow.train.ExponentialMovingAverage" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "name" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'decay\', \'num_updates\', \'zero_debias\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'ExponentialMovingAverage\'], " + } + member_method { + name: "apply" + argspec: "args=[\'self\', \'var_list\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "average" + argspec: "args=[\'self\', \'var\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "average_name" + argspec: "args=[\'self\', \'var\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "variables_to_restore" + argspec: "args=[\'self\', \'moving_avg_variables\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-feature-list.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-feature-list.pbtxt new file mode 100644 index 0000000000..2a8b3714fc --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-feature-list.pbtxt @@ -0,0 +1,13 @@ +path: "tensorflow.train.FeatureList" +tf_proto { + descriptor { + name: "FeatureList" + field { + name: "feature" + number: 1 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.Feature" + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-feature-lists.-feature-list-entry.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-feature-lists.-feature-list-entry.pbtxt new file mode 100644 index 0000000000..cd1d56e606 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-feature-lists.-feature-list-entry.pbtxt @@ -0,0 +1,22 @@ +path: "tensorflow.train.FeatureLists.FeatureListEntry" +tf_proto { + descriptor { + name: "FeatureListEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.FeatureList" + } + options { + map_entry: true + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-feature-lists.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-feature-lists.pbtxt new file mode 100644 index 0000000000..3c183a6476 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-feature-lists.pbtxt @@ -0,0 +1,32 @@ +path: "tensorflow.train.FeatureLists" +tf_proto { + descriptor { + name: "FeatureLists" + field { + name: "feature_list" + number: 1 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.FeatureLists.FeatureListEntry" + } + nested_type { + name: "FeatureListEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.FeatureList" + } + options { + map_entry: true + } + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-feature.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-feature.pbtxt new file mode 100644 index 0000000000..5d0eb871c2 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-feature.pbtxt @@ -0,0 +1,33 @@ +path: "tensorflow.train.Feature" +tf_proto { + descriptor { + name: "Feature" + field { + name: "bytes_list" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.BytesList" + oneof_index: 0 + } + field { + name: "float_list" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.FloatList" + oneof_index: 0 + } + field { + name: "int64_list" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.Int64List" + oneof_index: 0 + } + oneof_decl { + name: "kind" + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-features.-feature-entry.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-features.-feature-entry.pbtxt new file mode 100644 index 0000000000..f912005f1c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-features.-feature-entry.pbtxt @@ -0,0 +1,22 @@ +path: "tensorflow.train.Features.FeatureEntry" +tf_proto { + descriptor { + name: "FeatureEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.Feature" + } + options { + map_entry: true + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-features.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-features.pbtxt new file mode 100644 index 0000000000..b788ca1d57 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-features.pbtxt @@ -0,0 +1,32 @@ +path: "tensorflow.train.Features" +tf_proto { + descriptor { + name: "Features" + field { + name: "feature" + number: 1 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.Features.FeatureEntry" + } + nested_type { + name: "FeatureEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.Feature" + } + options { + map_entry: true + } + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-feed-fn-hook.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-feed-fn-hook.pbtxt new file mode 100644 index 0000000000..7bec4d032c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-feed-fn-hook.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.train.FeedFnHook" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'feed_fn\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "after_create_session" + argspec: "args=[\'self\', \'session\', \'coord\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "after_run" + argspec: "args=[\'self\', \'run_context\', \'run_values\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "before_run" + argspec: "args=[\'self\', \'run_context\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "begin" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "end" + argspec: "args=[\'self\', \'session\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-final-ops-hook.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-final-ops-hook.pbtxt new file mode 100644 index 0000000000..31cf9aaeb2 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-final-ops-hook.pbtxt @@ -0,0 +1,34 @@ +path: "tensorflow.train.FinalOpsHook" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "final_ops_values" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'final_ops\', \'final_ops_feed_dict\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "after_create_session" + argspec: "args=[\'self\', \'session\', \'coord\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "after_run" + argspec: "args=[\'self\', \'run_context\', \'run_values\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "before_run" + argspec: "args=[\'self\', \'run_context\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "begin" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "end" + argspec: "args=[\'self\', \'session\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-float-list.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-float-list.pbtxt new file mode 100644 index 0000000000..55d3b46f20 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-float-list.pbtxt @@ -0,0 +1,15 @@ +path: "tensorflow.train.FloatList" +tf_proto { + descriptor { + name: "FloatList" + field { + name: "value" + number: 1 + label: LABEL_REPEATED + type: TYPE_FLOAT + options { + packed: true + } + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-ftrl-optimizer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-ftrl-optimizer.pbtxt new file mode 100644 index 0000000000..d265fdeb01 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-ftrl-optimizer.pbtxt @@ -0,0 +1,51 @@ +path: "tensorflow.train.FtrlOptimizer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "GATE_GRAPH" + mtype: "" + } + member { + name: "GATE_NONE" + mtype: "" + } + member { + name: "GATE_OP" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'learning_rate\', \'learning_rate_power\', \'initial_accumulator_value\', \'l1_regularization_strength\', \'l2_regularization_strength\', \'use_locking\', \'name\', \'accum_name\', \'linear_name\', \'l2_shrinkage_regularization_strength\'], varargs=None, keywords=None, defaults=[\'-0.5\', \'0.1\', \'0.0\', \'0.0\', \'False\', \'Ftrl\', \'None\', \'None\', \'0.0\'], " + } + member_method { + name: "apply_gradients" + argspec: "args=[\'self\', \'grads_and_vars\', \'global_step\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "compute_gradients" + argspec: "args=[\'self\', \'loss\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'None\', \'False\', \'None\'], " + } + member_method { + name: "get_name" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot" + argspec: "args=[\'self\', \'var\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "minimize" + argspec: "args=[\'self\', \'loss\', \'global_step\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'name\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'1\', \'None\', \'False\', \'None\', \'None\'], " + } + member_method { + name: "variables" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-global-step-waiter-hook.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-global-step-waiter-hook.pbtxt new file mode 100644 index 0000000000..147448618e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-global-step-waiter-hook.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.train.GlobalStepWaiterHook" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'wait_until_step\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "after_create_session" + argspec: "args=[\'self\', \'session\', \'coord\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "after_run" + argspec: "args=[\'self\', \'run_context\', \'run_values\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "before_run" + argspec: "args=[\'self\', \'run_context\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "begin" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "end" + argspec: "args=[\'self\', \'session\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-gradient-descent-optimizer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-gradient-descent-optimizer.pbtxt new file mode 100644 index 0000000000..c673e29cd4 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-gradient-descent-optimizer.pbtxt @@ -0,0 +1,51 @@ +path: "tensorflow.train.GradientDescentOptimizer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "GATE_GRAPH" + mtype: "" + } + member { + name: "GATE_NONE" + mtype: "" + } + member { + name: "GATE_OP" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'learning_rate\', \'use_locking\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'GradientDescent\'], " + } + member_method { + name: "apply_gradients" + argspec: "args=[\'self\', \'grads_and_vars\', \'global_step\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "compute_gradients" + argspec: "args=[\'self\', \'loss\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'None\', \'False\', \'None\'], " + } + member_method { + name: "get_name" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot" + argspec: "args=[\'self\', \'var\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "minimize" + argspec: "args=[\'self\', \'loss\', \'global_step\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'name\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'1\', \'None\', \'False\', \'None\', \'None\'], " + } + member_method { + name: "variables" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-int64-list.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-int64-list.pbtxt new file mode 100644 index 0000000000..1de92b3ab7 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-int64-list.pbtxt @@ -0,0 +1,15 @@ +path: "tensorflow.train.Int64List" +tf_proto { + descriptor { + name: "Int64List" + field { + name: "value" + number: 1 + label: LABEL_REPEATED + type: TYPE_INT64 + options { + packed: true + } + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-job-def.-tasks-entry.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-job-def.-tasks-entry.pbtxt new file mode 100644 index 0000000000..58115590a5 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-job-def.-tasks-entry.pbtxt @@ -0,0 +1,21 @@ +path: "tensorflow.train.JobDef.TasksEntry" +tf_proto { + descriptor { + name: "TasksEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + options { + map_entry: true + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-job-def.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-job-def.pbtxt new file mode 100644 index 0000000000..d7eb505e27 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-job-def.pbtxt @@ -0,0 +1,37 @@ +path: "tensorflow.train.JobDef" +tf_proto { + descriptor { + name: "JobDef" + field { + name: "name" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "tasks" + number: 2 + label: LABEL_REPEATED + type: TYPE_MESSAGE + type_name: ".tensorflow.JobDef.TasksEntry" + } + nested_type { + name: "TasksEntry" + field { + name: "key" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "value" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + options { + map_entry: true + } + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-logging-tensor-hook.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-logging-tensor-hook.pbtxt new file mode 100644 index 0000000000..9801c05df1 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-logging-tensor-hook.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.train.LoggingTensorHook" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'tensors\', \'every_n_iter\', \'every_n_secs\', \'at_end\', \'formatter\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'False\', \'None\'], " + } + member_method { + name: "after_create_session" + argspec: "args=[\'self\', \'session\', \'coord\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "after_run" + argspec: "args=[\'self\', \'run_context\', \'run_values\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "before_run" + argspec: "args=[\'self\', \'run_context\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "begin" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "end" + argspec: "args=[\'self\', \'session\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-looper-thread.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-looper-thread.pbtxt new file mode 100644 index 0000000000..c61859004e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-looper-thread.pbtxt @@ -0,0 +1,73 @@ +path: "tensorflow.train.LooperThread" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "daemon" + mtype: "" + } + member { + name: "ident" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'coord\', \'timer_interval_secs\', \'target\', \'args\', \'kwargs\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "getName" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "isAlive" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "isDaemon" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "is_alive" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "join" + argspec: "args=[\'self\', \'timeout\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "loop" + argspec: "args=[\'coord\', \'timer_interval_secs\', \'target\', \'args\', \'kwargs\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "run" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "run_loop" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "setDaemon" + argspec: "args=[\'self\', \'daemonic\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "setName" + argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "start" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "start_loop" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "stop_loop" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-momentum-optimizer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-momentum-optimizer.pbtxt new file mode 100644 index 0000000000..8199f63b9b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-momentum-optimizer.pbtxt @@ -0,0 +1,51 @@ +path: "tensorflow.train.MomentumOptimizer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "GATE_GRAPH" + mtype: "" + } + member { + name: "GATE_NONE" + mtype: "" + } + member { + name: "GATE_OP" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'learning_rate\', \'momentum\', \'use_locking\', \'name\', \'use_nesterov\'], varargs=None, keywords=None, defaults=[\'False\', \'Momentum\', \'False\'], " + } + member_method { + name: "apply_gradients" + argspec: "args=[\'self\', \'grads_and_vars\', \'global_step\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "compute_gradients" + argspec: "args=[\'self\', \'loss\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'None\', \'False\', \'None\'], " + } + member_method { + name: "get_name" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot" + argspec: "args=[\'self\', \'var\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "minimize" + argspec: "args=[\'self\', \'loss\', \'global_step\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'name\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'1\', \'None\', \'False\', \'None\', \'None\'], " + } + member_method { + name: "variables" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-monitored-session.-step-context.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-monitored-session.-step-context.pbtxt new file mode 100644 index 0000000000..03efe6639e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-monitored-session.-step-context.pbtxt @@ -0,0 +1,21 @@ +path: "tensorflow.train.MonitoredSession.StepContext" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "session" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'session\', \'run_with_hooks_fn\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "request_stop" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "run_with_hooks" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-monitored-session.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-monitored-session.pbtxt new file mode 100644 index 0000000000..09b7b3fb53 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-monitored-session.pbtxt @@ -0,0 +1,34 @@ +path: "tensorflow.train.MonitoredSession" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "StepContext" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'session_creator\', \'hooks\', \'stop_grace_period_secs\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'120\'], " + } + member_method { + name: "close" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "run" + argspec: "args=[\'self\', \'fetches\', \'feed_dict\', \'options\', \'run_metadata\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "run_step_fn" + argspec: "args=[\'self\', \'step_fn\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "should_stop" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-nan-loss-during-training-error.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-nan-loss-during-training-error.pbtxt new file mode 100644 index 0000000000..25fd5e75a7 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-nan-loss-during-training-error.pbtxt @@ -0,0 +1,16 @@ +path: "tensorflow.train.NanLossDuringTrainingError" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "args" + mtype: "" + } + member { + name: "message" + mtype: "" + } + member_method { + name: "__init__" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-nan-tensor-hook.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-nan-tensor-hook.pbtxt new file mode 100644 index 0000000000..7d1c89f9b3 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-nan-tensor-hook.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.train.NanTensorHook" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'loss_tensor\', \'fail_on_nan_loss\'], varargs=None, keywords=None, defaults=[\'True\'], " + } + member_method { + name: "after_create_session" + argspec: "args=[\'self\', \'session\', \'coord\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "after_run" + argspec: "args=[\'self\', \'run_context\', \'run_values\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "before_run" + argspec: "args=[\'self\', \'run_context\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "begin" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "end" + argspec: "args=[\'self\', \'session\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-optimizer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-optimizer.pbtxt new file mode 100644 index 0000000000..876bb35e39 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-optimizer.pbtxt @@ -0,0 +1,50 @@ +path: "tensorflow.train.Optimizer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "GATE_GRAPH" + mtype: "" + } + member { + name: "GATE_NONE" + mtype: "" + } + member { + name: "GATE_OP" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'use_locking\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "apply_gradients" + argspec: "args=[\'self\', \'grads_and_vars\', \'global_step\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "compute_gradients" + argspec: "args=[\'self\', \'loss\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'None\', \'False\', \'None\'], " + } + member_method { + name: "get_name" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot" + argspec: "args=[\'self\', \'var\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "minimize" + argspec: "args=[\'self\', \'loss\', \'global_step\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'name\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'1\', \'None\', \'False\', \'None\', \'None\'], " + } + member_method { + name: "variables" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-profiler-hook.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-profiler-hook.pbtxt new file mode 100644 index 0000000000..4df6c4156a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-profiler-hook.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.train.ProfilerHook" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'save_steps\', \'save_secs\', \'output_dir\', \'show_dataflow\', \'show_memory\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'\', \'True\', \'False\'], " + } + member_method { + name: "after_create_session" + argspec: "args=[\'self\', \'session\', \'coord\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "after_run" + argspec: "args=[\'self\', \'run_context\', \'run_values\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "before_run" + argspec: "args=[\'self\', \'run_context\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "begin" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "end" + argspec: "args=[\'self\', \'session\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-proximal-adagrad-optimizer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-proximal-adagrad-optimizer.pbtxt new file mode 100644 index 0000000000..14349a74ef --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-proximal-adagrad-optimizer.pbtxt @@ -0,0 +1,51 @@ +path: "tensorflow.train.ProximalAdagradOptimizer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "GATE_GRAPH" + mtype: "" + } + member { + name: "GATE_NONE" + mtype: "" + } + member { + name: "GATE_OP" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'learning_rate\', \'initial_accumulator_value\', \'l1_regularization_strength\', \'l2_regularization_strength\', \'use_locking\', \'name\'], varargs=None, keywords=None, defaults=[\'0.1\', \'0.0\', \'0.0\', \'False\', \'ProximalAdagrad\'], " + } + member_method { + name: "apply_gradients" + argspec: "args=[\'self\', \'grads_and_vars\', \'global_step\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "compute_gradients" + argspec: "args=[\'self\', \'loss\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'None\', \'False\', \'None\'], " + } + member_method { + name: "get_name" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot" + argspec: "args=[\'self\', \'var\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "minimize" + argspec: "args=[\'self\', \'loss\', \'global_step\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'name\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'1\', \'None\', \'False\', \'None\', \'None\'], " + } + member_method { + name: "variables" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-proximal-gradient-descent-optimizer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-proximal-gradient-descent-optimizer.pbtxt new file mode 100644 index 0000000000..7d982dc51f --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-proximal-gradient-descent-optimizer.pbtxt @@ -0,0 +1,51 @@ +path: "tensorflow.train.ProximalGradientDescentOptimizer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "GATE_GRAPH" + mtype: "" + } + member { + name: "GATE_NONE" + mtype: "" + } + member { + name: "GATE_OP" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'learning_rate\', \'l1_regularization_strength\', \'l2_regularization_strength\', \'use_locking\', \'name\'], varargs=None, keywords=None, defaults=[\'0.0\', \'0.0\', \'False\', \'ProximalGradientDescent\'], " + } + member_method { + name: "apply_gradients" + argspec: "args=[\'self\', \'grads_and_vars\', \'global_step\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "compute_gradients" + argspec: "args=[\'self\', \'loss\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'None\', \'False\', \'None\'], " + } + member_method { + name: "get_name" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot" + argspec: "args=[\'self\', \'var\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "minimize" + argspec: "args=[\'self\', \'loss\', \'global_step\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'name\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'1\', \'None\', \'False\', \'None\', \'None\'], " + } + member_method { + name: "variables" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-queue-runner.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-queue-runner.pbtxt new file mode 100644 index 0000000000..d84d0058ee --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-queue-runner.pbtxt @@ -0,0 +1,49 @@ +path: "tensorflow.train.QueueRunner" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "cancel_op" + mtype: "" + } + member { + name: "close_op" + mtype: "" + } + member { + name: "enqueue_ops" + mtype: "" + } + member { + name: "exceptions_raised" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "queue" + mtype: "" + } + member { + name: "queue_closed_exception_types" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'queue\', \'enqueue_ops\', \'close_op\', \'cancel_op\', \'queue_closed_exception_types\', \'queue_runner_def\', \'import_scope\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "create_threads" + argspec: "args=[\'self\', \'sess\', \'coord\', \'daemon\', \'start\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'False\'], " + } + member_method { + name: "from_proto" + argspec: "args=[\'queue_runner_def\', \'import_scope\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "to_proto" + argspec: "args=[\'self\', \'export_scope\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-r-m-s-prop-optimizer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-r-m-s-prop-optimizer.pbtxt new file mode 100644 index 0000000000..906384a287 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-r-m-s-prop-optimizer.pbtxt @@ -0,0 +1,51 @@ +path: "tensorflow.train.RMSPropOptimizer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "GATE_GRAPH" + mtype: "" + } + member { + name: "GATE_NONE" + mtype: "" + } + member { + name: "GATE_OP" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'learning_rate\', \'decay\', \'momentum\', \'epsilon\', \'use_locking\', \'centered\', \'name\'], varargs=None, keywords=None, defaults=[\'0.9\', \'0.0\', \'1e-10\', \'False\', \'False\', \'RMSProp\'], " + } + member_method { + name: "apply_gradients" + argspec: "args=[\'self\', \'grads_and_vars\', \'global_step\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "compute_gradients" + argspec: "args=[\'self\', \'loss\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'1\', \'None\', \'False\', \'None\'], " + } + member_method { + name: "get_name" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot" + argspec: "args=[\'self\', \'var\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot_names" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "minimize" + argspec: "args=[\'self\', \'loss\', \'global_step\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'name\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'1\', \'None\', \'False\', \'None\', \'None\'], " + } + member_method { + name: "variables" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-saver-def.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-saver-def.pbtxt new file mode 100644 index 0000000000..4ec99469e4 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-saver-def.pbtxt @@ -0,0 +1,64 @@ +path: "tensorflow.train.SaverDef" +tf_proto { + descriptor { + name: "SaverDef" + field { + name: "filename_tensor_name" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "save_tensor_name" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "restore_op_name" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "max_to_keep" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "sharded" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_BOOL + } + field { + name: "keep_checkpoint_every_n_hours" + number: 6 + label: LABEL_OPTIONAL + type: TYPE_FLOAT + } + field { + name: "version" + number: 7 + label: LABEL_OPTIONAL + type: TYPE_ENUM + type_name: ".tensorflow.SaverDef.CheckpointFormatVersion" + } + enum_type { + name: "CheckpointFormatVersion" + value { + name: "LEGACY" + number: 0 + } + value { + name: "V1" + number: 1 + } + value { + name: "V2" + number: 2 + } + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-saver.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-saver.pbtxt new file mode 100644 index 0000000000..2cda458f46 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-saver.pbtxt @@ -0,0 +1,53 @@ +path: "tensorflow.train.Saver" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "last_checkpoints" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'var_list\', \'reshape\', \'sharded\', \'max_to_keep\', \'keep_checkpoint_every_n_hours\', \'name\', \'restore_sequentially\', \'saver_def\', \'builder\', \'defer_build\', \'allow_empty\', \'write_version\', \'pad_step_number\', \'save_relative_paths\', \'filename\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'False\', \'5\', \'10000.0\', \'None\', \'False\', \'None\', \'None\', \'False\', \'False\', \'2\', \'False\', \'False\', \'None\'], " + } + member_method { + name: "as_saver_def" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "build" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "export_meta_graph" + argspec: "args=[\'self\', \'filename\', \'collection_list\', \'as_text\', \'export_scope\', \'clear_devices\', \'clear_extraneous_savers\', \'strip_default_attrs\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'False\', \'None\', \'False\', \'False\', \'False\'], " + } + member_method { + name: "from_proto" + argspec: "args=[\'saver_def\', \'import_scope\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "recover_last_checkpoints" + argspec: "args=[\'self\', \'checkpoint_paths\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "restore" + argspec: "args=[\'self\', \'sess\', \'save_path\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "save" + argspec: "args=[\'self\', \'sess\', \'save_path\', \'global_step\', \'latest_filename\', \'meta_graph_suffix\', \'write_meta_graph\', \'write_state\', \'strip_default_attrs\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'meta\', \'True\', \'True\', \'False\'], " + } + member_method { + name: "set_last_checkpoints" + argspec: "args=[\'self\', \'last_checkpoints\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "set_last_checkpoints_with_time" + argspec: "args=[\'self\', \'last_checkpoints_with_time\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "to_proto" + argspec: "args=[\'self\', \'export_scope\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-scaffold.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-scaffold.pbtxt new file mode 100644 index 0000000000..38cc98b48e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-scaffold.pbtxt @@ -0,0 +1,53 @@ +path: "tensorflow.train.Scaffold" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "init_feed_dict" + mtype: "" + } + member { + name: "init_fn" + mtype: "" + } + member { + name: "init_op" + mtype: "" + } + member { + name: "local_init_op" + mtype: "" + } + member { + name: "ready_for_local_init_op" + mtype: "" + } + member { + name: "ready_op" + mtype: "" + } + member { + name: "saver" + mtype: "" + } + member { + name: "summary_op" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'init_op\', \'init_feed_dict\', \'init_fn\', \'ready_op\', \'ready_for_local_init_op\', \'local_init_op\', \'summary_op\', \'saver\', \'copy_from_scaffold\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "default_local_init_op" + argspec: "args=[], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "finalize" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_or_default" + argspec: "args=[\'arg_name\', \'collection_key\', \'default_constructor\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-second-or-step-timer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-second-or-step-timer.pbtxt new file mode 100644 index 0000000000..3c5a6ac13c --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-second-or-step-timer.pbtxt @@ -0,0 +1,26 @@ +path: "tensorflow.train.SecondOrStepTimer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'every_secs\', \'every_steps\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "last_triggered_step" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "reset" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "should_trigger_for_step" + argspec: "args=[\'self\', \'step\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "update_last_triggered_step" + argspec: "args=[\'self\', \'step\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-sequence-example.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-sequence-example.pbtxt new file mode 100644 index 0000000000..6a4553bbc1 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-sequence-example.pbtxt @@ -0,0 +1,20 @@ +path: "tensorflow.train.SequenceExample" +tf_proto { + descriptor { + name: "SequenceExample" + field { + name: "context" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.Features" + } + field { + name: "feature_lists" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.FeatureLists" + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-server-def.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-server-def.pbtxt new file mode 100644 index 0000000000..83ee7b3eb9 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-server-def.pbtxt @@ -0,0 +1,38 @@ +path: "tensorflow.train.ServerDef" +tf_proto { + descriptor { + name: "ServerDef" + field { + name: "cluster" + number: 1 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.ClusterDef" + } + field { + name: "job_name" + number: 2 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + field { + name: "task_index" + number: 3 + label: LABEL_OPTIONAL + type: TYPE_INT32 + } + field { + name: "default_session_config" + number: 4 + label: LABEL_OPTIONAL + type: TYPE_MESSAGE + type_name: ".tensorflow.ConfigProto" + } + field { + name: "protocol" + number: 5 + label: LABEL_OPTIONAL + type: TYPE_STRING + } + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-server.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-server.pbtxt new file mode 100644 index 0000000000..9b8f185f5b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-server.pbtxt @@ -0,0 +1,29 @@ +path: "tensorflow.train.Server" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "server_def" + mtype: "" + } + member { + name: "target" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'server_or_cluster_def\', \'job_name\', \'task_index\', \'protocol\', \'config\', \'start\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'True\'], " + } + member_method { + name: "create_local_server" + argspec: "args=[\'config\', \'start\'], varargs=None, keywords=None, defaults=[\'None\', \'True\'], " + } + member_method { + name: "join" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "start" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-session-creator.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-session-creator.pbtxt new file mode 100644 index 0000000000..beb232715f --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-session-creator.pbtxt @@ -0,0 +1,12 @@ +path: "tensorflow.train.SessionCreator" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "create_session" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-session-manager.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-session-manager.pbtxt new file mode 100644 index 0000000000..448764fe08 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-session-manager.pbtxt @@ -0,0 +1,21 @@ +path: "tensorflow.train.SessionManager" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'local_init_op\', \'ready_op\', \'ready_for_local_init_op\', \'graph\', \'recovery_wait_secs\', \'local_init_run_options\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'30\', \'None\'], " + } + member_method { + name: "prepare_session" + argspec: "args=[\'self\', \'master\', \'init_op\', \'saver\', \'checkpoint_dir\', \'checkpoint_filename_with_path\', \'wait_for_checkpoint\', \'max_wait_secs\', \'config\', \'init_feed_dict\', \'init_fn\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'False\', \'7200\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "recover_session" + argspec: "args=[\'self\', \'master\', \'saver\', \'checkpoint_dir\', \'checkpoint_filename_with_path\', \'wait_for_checkpoint\', \'max_wait_secs\', \'config\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'False\', \'7200\', \'None\'], " + } + member_method { + name: "wait_for_session" + argspec: "args=[\'self\', \'master\', \'config\', \'max_wait_secs\'], varargs=None, keywords=None, defaults=[\'None\', \'inf\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-session-run-args.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-session-run-args.pbtxt new file mode 100644 index 0000000000..442990893e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-session-run-args.pbtxt @@ -0,0 +1,27 @@ +path: "tensorflow.train.SessionRunArgs" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "feed_dict" + mtype: "" + } + member { + name: "fetches" + mtype: "" + } + member { + name: "options" + mtype: "" + } + member_method { + name: "__init__" + } + member_method { + name: "count" + } + member_method { + name: "index" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-session-run-context.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-session-run-context.pbtxt new file mode 100644 index 0000000000..d5adb15c95 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-session-run-context.pbtxt @@ -0,0 +1,25 @@ +path: "tensorflow.train.SessionRunContext" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "original_args" + mtype: "" + } + member { + name: "session" + mtype: "" + } + member { + name: "stop_requested" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'original_args\', \'session\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "request_stop" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-session-run-hook.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-session-run-hook.pbtxt new file mode 100644 index 0000000000..db1aa24acf --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-session-run-hook.pbtxt @@ -0,0 +1,28 @@ +path: "tensorflow.train.SessionRunHook" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + } + member_method { + name: "after_create_session" + argspec: "args=[\'self\', \'session\', \'coord\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "after_run" + argspec: "args=[\'self\', \'run_context\', \'run_values\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "before_run" + argspec: "args=[\'self\', \'run_context\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "begin" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "end" + argspec: "args=[\'self\', \'session\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-session-run-values.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-session-run-values.pbtxt new file mode 100644 index 0000000000..0b401d59c4 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-session-run-values.pbtxt @@ -0,0 +1,27 @@ +path: "tensorflow.train.SessionRunValues" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "options" + mtype: "" + } + member { + name: "results" + mtype: "" + } + member { + name: "run_metadata" + mtype: "" + } + member_method { + name: "__init__" + } + member_method { + name: "count" + } + member_method { + name: "index" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-singular-monitored-session.-step-context.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-singular-monitored-session.-step-context.pbtxt new file mode 100644 index 0000000000..36d8ce7ff8 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-singular-monitored-session.-step-context.pbtxt @@ -0,0 +1,21 @@ +path: "tensorflow.train.SingularMonitoredSession.StepContext" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "session" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'session\', \'run_with_hooks_fn\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "request_stop" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "run_with_hooks" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-singular-monitored-session.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-singular-monitored-session.pbtxt new file mode 100644 index 0000000000..de0f2c1c1a --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-singular-monitored-session.pbtxt @@ -0,0 +1,38 @@ +path: "tensorflow.train.SingularMonitoredSession" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "StepContext" + mtype: "" + } + member { + name: "graph" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'hooks\', \'scaffold\', \'master\', \'config\', \'checkpoint_dir\', \'stop_grace_period_secs\', \'checkpoint_filename_with_path\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'\', \'None\', \'None\', \'120\', \'None\'], " + } + member_method { + name: "close" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "raw_session" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "run" + argspec: "args=[\'self\', \'fetches\', \'feed_dict\', \'options\', \'run_metadata\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " + } + member_method { + name: "run_step_fn" + argspec: "args=[\'self\', \'step_fn\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "should_stop" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-step-counter-hook.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-step-counter-hook.pbtxt new file mode 100644 index 0000000000..13261f6dde --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-step-counter-hook.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.train.StepCounterHook" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'every_n_steps\', \'every_n_secs\', \'output_dir\', \'summary_writer\'], varargs=None, keywords=None, defaults=[\'100\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "after_create_session" + argspec: "args=[\'self\', \'session\', \'coord\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "after_run" + argspec: "args=[\'self\', \'run_context\', \'run_values\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "before_run" + argspec: "args=[\'self\', \'run_context\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "begin" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "end" + argspec: "args=[\'self\', \'session\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-stop-at-step-hook.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-stop-at-step-hook.pbtxt new file mode 100644 index 0000000000..e388599b0b --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-stop-at-step-hook.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.train.StopAtStepHook" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'num_steps\', \'last_step\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "after_create_session" + argspec: "args=[\'self\', \'session\', \'coord\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "after_run" + argspec: "args=[\'self\', \'run_context\', \'run_values\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "before_run" + argspec: "args=[\'self\', \'run_context\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "begin" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "end" + argspec: "args=[\'self\', \'session\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-summary-saver-hook.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-summary-saver-hook.pbtxt new file mode 100644 index 0000000000..697c3667b0 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-summary-saver-hook.pbtxt @@ -0,0 +1,30 @@ +path: "tensorflow.train.SummarySaverHook" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'save_steps\', \'save_secs\', \'output_dir\', \'summary_writer\', \'scaffold\', \'summary_op\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "after_create_session" + argspec: "args=[\'self\', \'session\', \'coord\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "after_run" + argspec: "args=[\'self\', \'run_context\', \'run_values\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "before_run" + argspec: "args=[\'self\', \'run_context\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "begin" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "end" + argspec: "args=[\'self\', \'session\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-supervisor.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-supervisor.pbtxt new file mode 100644 index 0000000000..9677e5a98e --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-supervisor.pbtxt @@ -0,0 +1,153 @@ +path: "tensorflow.train.Supervisor" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "USE_DEFAULT" + mtype: "" + } + member { + name: "coord" + mtype: "" + } + member { + name: "global_step" + mtype: "" + } + member { + name: "init_feed_dict" + mtype: "" + } + member { + name: "init_op" + mtype: "" + } + member { + name: "is_chief" + mtype: "" + } + member { + name: "ready_for_local_init_op" + mtype: "" + } + member { + name: "ready_op" + mtype: "" + } + member { + name: "save_model_secs" + mtype: "" + } + member { + name: "save_path" + mtype: "" + } + member { + name: "save_summaries_secs" + mtype: "" + } + member { + name: "saver" + mtype: "" + } + member { + name: "session_manager" + mtype: "" + } + member { + name: "summary_op" + mtype: "" + } + member { + name: "summary_writer" + mtype: "" + } + member_method { + name: "Loop" + argspec: "args=[\'self\', \'timer_interval_secs\', \'target\', \'args\', \'kwargs\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "PrepareSession" + argspec: "args=[\'self\', \'master\', \'config\', \'wait_for_checkpoint\', \'max_wait_secs\', \'start_standard_services\'], varargs=None, keywords=None, defaults=[\'\', \'None\', \'False\', \'7200\', \'True\'], " + } + member_method { + name: "RequestStop" + argspec: "args=[\'self\', \'ex\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "ShouldStop" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "StartQueueRunners" + argspec: "args=[\'self\', \'sess\', \'queue_runners\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "StartStandardServices" + argspec: "args=[\'self\', \'sess\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "Stop" + argspec: "args=[\'self\', \'threads\', \'close_summary_writer\', \'ignore_live_threads\'], varargs=None, keywords=None, defaults=[\'None\', \'True\', \'False\'], " + } + member_method { + name: "StopOnException" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "SummaryComputed" + argspec: "args=[\'self\', \'sess\', \'summary\', \'global_step\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "WaitForStop" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'graph\', \'ready_op\', \'ready_for_local_init_op\', \'is_chief\', \'init_op\', \'init_feed_dict\', \'local_init_op\', \'logdir\', \'summary_op\', \'saver\', \'global_step\', \'save_summaries_secs\', \'save_model_secs\', \'recovery_wait_secs\', \'stop_grace_secs\', \'checkpoint_basename\', \'session_manager\', \'summary_writer\', \'init_fn\', \'local_init_run_options\'], varargs=None, keywords=None, defaults=[\'None\', \'0\', \'0\', \'True\', \'0\', \'None\', \'0\', \'None\', \'0\', \'0\', \'0\', \'120\', \'600\', \'30\', \'120\', \'model.ckpt\', \'None\', \'0\', \'None\', \'None\'], " + } + member_method { + name: "loop" + argspec: "args=[\'self\', \'timer_interval_secs\', \'target\', \'args\', \'kwargs\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "managed_session" + argspec: "args=[], varargs=args, keywords=kwds, defaults=None" + } + member_method { + name: "prepare_or_wait_for_session" + argspec: "args=[\'self\', \'master\', \'config\', \'wait_for_checkpoint\', \'max_wait_secs\', \'start_standard_services\'], varargs=None, keywords=None, defaults=[\'\', \'None\', \'False\', \'7200\', \'True\'], " + } + member_method { + name: "request_stop" + argspec: "args=[\'self\', \'ex\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "should_stop" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "start_queue_runners" + argspec: "args=[\'self\', \'sess\', \'queue_runners\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "start_standard_services" + argspec: "args=[\'self\', \'sess\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "stop" + argspec: "args=[\'self\', \'threads\', \'close_summary_writer\', \'ignore_live_threads\'], varargs=None, keywords=None, defaults=[\'None\', \'True\', \'False\'], " + } + member_method { + name: "stop_on_exception" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "summary_computed" + argspec: "args=[\'self\', \'sess\', \'summary\', \'global_step\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "wait_for_stop" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-sync-replicas-optimizer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-sync-replicas-optimizer.pbtxt new file mode 100644 index 0000000000..2c0fda3c72 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-sync-replicas-optimizer.pbtxt @@ -0,0 +1,63 @@ +path: "tensorflow.train.SyncReplicasOptimizer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "GATE_GRAPH" + mtype: "" + } + member { + name: "GATE_NONE" + mtype: "" + } + member { + name: "GATE_OP" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'opt\', \'replicas_to_aggregate\', \'total_num_replicas\', \'variable_averages\', \'variables_to_average\', \'use_locking\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'False\', \'sync_replicas\'], " + } + member_method { + name: "apply_gradients" + argspec: "args=[\'self\', \'grads_and_vars\', \'global_step\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "compute_gradients" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "get_chief_queue_runner" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_init_tokens_op" + argspec: "args=[\'self\', \'num_tokens\'], varargs=None, keywords=None, defaults=[\'-1\'], " + } + member_method { + name: "get_name" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_slot" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "get_slot_names" + argspec: "args=[\'self\'], varargs=args, keywords=kwargs, defaults=None" + } + member_method { + name: "make_session_run_hook" + argspec: "args=[\'self\', \'is_chief\', \'num_tokens\'], varargs=None, keywords=None, defaults=[\'-1\'], " + } + member_method { + name: "minimize" + argspec: "args=[\'self\', \'loss\', \'global_step\', \'var_list\', \'gate_gradients\', \'aggregation_method\', \'colocate_gradients_with_ops\', \'name\', \'grad_loss\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'1\', \'None\', \'False\', \'None\', \'None\'], " + } + member_method { + name: "variables" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-vocab-info.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-vocab-info.pbtxt new file mode 100644 index 0000000000..4ce7cb1111 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-vocab-info.pbtxt @@ -0,0 +1,39 @@ +path: "tensorflow.train.VocabInfo" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member { + name: "backup_initializer" + mtype: "" + } + member { + name: "new_vocab" + mtype: "" + } + member { + name: "new_vocab_size" + mtype: "" + } + member { + name: "num_oov_buckets" + mtype: "" + } + member { + name: "old_vocab" + mtype: "" + } + member { + name: "old_vocab_size" + mtype: "" + } + member_method { + name: "__init__" + } + member_method { + name: "count" + } + member_method { + name: "index" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.-worker-session-creator.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.-worker-session-creator.pbtxt new file mode 100644 index 0000000000..ac26358068 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.-worker-session-creator.pbtxt @@ -0,0 +1,14 @@ +path: "tensorflow.train.WorkerSessionCreator" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'scaffold\', \'master\', \'config\', \'max_wait_secs\'], varargs=None, keywords=None, defaults=[\'None\', \'\', \'None\', \'1800\'], " + } + member_method { + name: "create_session" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.pbtxt new file mode 100644 index 0000000000..b0fb04d7d4 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.pbtxt @@ -0,0 +1,459 @@ +path: "tensorflow.train" +tf_module { + member { + name: "AdadeltaOptimizer" + mtype: "" + } + member { + name: "AdagradDAOptimizer" + mtype: "" + } + member { + name: "AdagradOptimizer" + mtype: "" + } + member { + name: "AdamOptimizer" + mtype: "" + } + member { + name: "BytesList" + mtype: "" + } + member { + name: "Checkpoint" + mtype: "" + } + member { + name: "CheckpointSaverHook" + mtype: "" + } + member { + name: "CheckpointSaverListener" + mtype: "" + } + member { + name: "ChiefSessionCreator" + mtype: "" + } + member { + name: "ClusterDef" + mtype: "" + } + member { + name: "ClusterSpec" + mtype: "" + } + member { + name: "Coordinator" + mtype: "" + } + member { + name: "Example" + mtype: "" + } + member { + name: "ExponentialMovingAverage" + mtype: "" + } + member { + name: "Feature" + mtype: "" + } + member { + name: "FeatureList" + mtype: "" + } + member { + name: "FeatureLists" + mtype: "" + } + member { + name: "Features" + mtype: "" + } + member { + name: "FeedFnHook" + mtype: "" + } + member { + name: "FinalOpsHook" + mtype: "" + } + member { + name: "FloatList" + mtype: "" + } + member { + name: "FtrlOptimizer" + mtype: "" + } + member { + name: "GlobalStepWaiterHook" + mtype: "" + } + member { + name: "GradientDescentOptimizer" + mtype: "" + } + member { + name: "Int64List" + mtype: "" + } + member { + name: "JobDef" + mtype: "" + } + member { + name: "LoggingTensorHook" + mtype: "" + } + member { + name: "LooperThread" + mtype: "" + } + member { + name: "MomentumOptimizer" + mtype: "" + } + member { + name: "MonitoredSession" + mtype: "" + } + member { + name: "NanLossDuringTrainingError" + mtype: "" + } + member { + name: "NanTensorHook" + mtype: "" + } + member { + name: "Optimizer" + mtype: "" + } + member { + name: "ProfilerHook" + mtype: "" + } + member { + name: "ProximalAdagradOptimizer" + mtype: "" + } + member { + name: "ProximalGradientDescentOptimizer" + mtype: "" + } + member { + name: "QueueRunner" + mtype: "" + } + member { + name: "RMSPropOptimizer" + mtype: "" + } + member { + name: "Saver" + mtype: "" + } + member { + name: "SaverDef" + mtype: "" + } + member { + name: "Scaffold" + mtype: "" + } + member { + name: "SecondOrStepTimer" + mtype: "" + } + member { + name: "SequenceExample" + mtype: "" + } + member { + name: "Server" + mtype: "" + } + member { + name: "ServerDef" + mtype: "" + } + member { + name: "SessionCreator" + mtype: "" + } + member { + name: "SessionManager" + mtype: "" + } + member { + name: "SessionRunArgs" + mtype: "" + } + member { + name: "SessionRunContext" + mtype: "" + } + member { + name: "SessionRunHook" + mtype: "" + } + member { + name: "SessionRunValues" + mtype: "" + } + member { + name: "SingularMonitoredSession" + mtype: "" + } + member { + name: "StepCounterHook" + mtype: "" + } + member { + name: "StopAtStepHook" + mtype: "" + } + member { + name: "SummarySaverHook" + mtype: "" + } + member { + name: "Supervisor" + mtype: "" + } + member { + name: "SyncReplicasOptimizer" + mtype: "" + } + member { + name: "VocabInfo" + mtype: "" + } + member { + name: "WorkerSessionCreator" + mtype: "" + } + member { + name: "queue_runner" + mtype: "" + } + member_method { + name: "MonitoredTrainingSession" + argspec: "args=[\'master\', \'is_chief\', \'checkpoint_dir\', \'scaffold\', \'hooks\', \'chief_only_hooks\', \'save_checkpoint_secs\', \'save_summaries_steps\', \'save_summaries_secs\', \'config\', \'stop_grace_period_secs\', \'log_step_count_steps\', \'max_wait_secs\', \'save_checkpoint_steps\', \'summary_dir\'], varargs=None, keywords=None, defaults=[\'\', \'True\', \'None\', \'None\', \'None\', \'None\', \'\', \'\', \'\', \'None\', \'120\', \'100\', \'7200\', \'\', \'None\'], " + } + member_method { + name: "NewCheckpointReader" + argspec: "args=[\'filepattern\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "add_queue_runner" + argspec: "args=[\'qr\', \'collection\'], varargs=None, keywords=None, defaults=[\'queue_runners\'], " + } + member_method { + name: "assert_global_step" + argspec: "args=[\'global_step_tensor\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "basic_train_loop" + argspec: "args=[\'supervisor\', \'train_step_fn\', \'args\', \'kwargs\', \'master\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'\'], " + } + member_method { + name: "batch" + argspec: "args=[\'tensors\', \'batch_size\', \'num_threads\', \'capacity\', \'enqueue_many\', \'shapes\', \'dynamic_pad\', \'allow_smaller_final_batch\', \'shared_name\', \'name\'], varargs=None, keywords=None, defaults=[\'1\', \'32\', \'False\', \'None\', \'False\', \'False\', \'None\', \'None\'], " + } + member_method { + name: "batch_join" + argspec: "args=[\'tensors_list\', \'batch_size\', \'capacity\', \'enqueue_many\', \'shapes\', \'dynamic_pad\', \'allow_smaller_final_batch\', \'shared_name\', \'name\'], varargs=None, keywords=None, defaults=[\'32\', \'False\', \'None\', \'False\', \'False\', \'None\', \'None\'], " + } + member_method { + name: "checkpoint_exists" + argspec: "args=[\'checkpoint_prefix\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "cosine_decay" + argspec: "args=[\'learning_rate\', \'global_step\', \'decay_steps\', \'alpha\', \'name\'], varargs=None, keywords=None, defaults=[\'0.0\', \'None\'], " + } + member_method { + name: "cosine_decay_restarts" + argspec: "args=[\'learning_rate\', \'global_step\', \'first_decay_steps\', \'t_mul\', \'m_mul\', \'alpha\', \'name\'], varargs=None, keywords=None, defaults=[\'2.0\', \'1.0\', \'0.0\', \'None\'], " + } + member_method { + name: "create_global_step" + argspec: "args=[\'graph\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "do_quantize_training_on_graphdef" + argspec: "args=[\'input_graph\', \'num_bits\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "exponential_decay" + argspec: "args=[\'learning_rate\', \'global_step\', \'decay_steps\', \'decay_rate\', \'staircase\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "export_meta_graph" + argspec: "args=[\'filename\', \'meta_info_def\', \'graph_def\', \'saver_def\', \'collection_list\', \'as_text\', \'graph\', \'export_scope\', \'clear_devices\', \'clear_extraneous_savers\', \'strip_default_attrs\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'False\', \'None\', \'None\', \'False\', \'False\', \'False\'], " + } + member_method { + name: "generate_checkpoint_state_proto" + argspec: "args=[\'save_dir\', \'model_checkpoint_path\', \'all_model_checkpoint_paths\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_checkpoint_mtimes" + argspec: "args=[\'checkpoint_prefixes\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_checkpoint_state" + argspec: "args=[\'checkpoint_dir\', \'latest_filename\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_global_step" + argspec: "args=[\'graph\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "get_or_create_global_step" + argspec: "args=[\'graph\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "global_step" + argspec: "args=[\'sess\', \'global_step_tensor\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "import_meta_graph" + argspec: "args=[\'meta_graph_or_file\', \'clear_devices\', \'import_scope\'], varargs=None, keywords=kwargs, defaults=[\'False\', \'None\'], " + } + member_method { + name: "init_from_checkpoint" + argspec: "args=[\'ckpt_dir_or_file\', \'assignment_map\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "input_producer" + argspec: "args=[\'input_tensor\', \'element_shape\', \'num_epochs\', \'shuffle\', \'seed\', \'capacity\', \'shared_name\', \'summary_name\', \'name\', \'cancel_op\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'True\', \'None\', \'32\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "inverse_time_decay" + argspec: "args=[\'learning_rate\', \'global_step\', \'decay_steps\', \'decay_rate\', \'staircase\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "latest_checkpoint" + argspec: "args=[\'checkpoint_dir\', \'latest_filename\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "limit_epochs" + argspec: "args=[\'tensor\', \'num_epochs\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "linear_cosine_decay" + argspec: "args=[\'learning_rate\', \'global_step\', \'decay_steps\', \'num_periods\', \'alpha\', \'beta\', \'name\'], varargs=None, keywords=None, defaults=[\'0.5\', \'0.0\', \'0.001\', \'None\'], " + } + member_method { + name: "list_variables" + argspec: "args=[\'ckpt_dir_or_file\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "load_checkpoint" + argspec: "args=[\'ckpt_dir_or_file\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "load_variable" + argspec: "args=[\'ckpt_dir_or_file\', \'name\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "match_filenames_once" + argspec: "args=[\'pattern\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "maybe_batch" + argspec: "args=[\'tensors\', \'keep_input\', \'batch_size\', \'num_threads\', \'capacity\', \'enqueue_many\', \'shapes\', \'dynamic_pad\', \'allow_smaller_final_batch\', \'shared_name\', \'name\'], varargs=None, keywords=None, defaults=[\'1\', \'32\', \'False\', \'None\', \'False\', \'False\', \'None\', \'None\'], " + } + member_method { + name: "maybe_batch_join" + argspec: "args=[\'tensors_list\', \'keep_input\', \'batch_size\', \'capacity\', \'enqueue_many\', \'shapes\', \'dynamic_pad\', \'allow_smaller_final_batch\', \'shared_name\', \'name\'], varargs=None, keywords=None, defaults=[\'32\', \'False\', \'None\', \'False\', \'False\', \'None\', \'None\'], " + } + member_method { + name: "maybe_shuffle_batch" + argspec: "args=[\'tensors\', \'batch_size\', \'capacity\', \'min_after_dequeue\', \'keep_input\', \'num_threads\', \'seed\', \'enqueue_many\', \'shapes\', \'allow_smaller_final_batch\', \'shared_name\', \'name\'], varargs=None, keywords=None, defaults=[\'1\', \'None\', \'False\', \'None\', \'False\', \'None\', \'None\'], " + } + member_method { + name: "maybe_shuffle_batch_join" + argspec: "args=[\'tensors_list\', \'batch_size\', \'capacity\', \'min_after_dequeue\', \'keep_input\', \'seed\', \'enqueue_many\', \'shapes\', \'allow_smaller_final_batch\', \'shared_name\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\', \'False\', \'None\', \'None\'], " + } + member_method { + name: "natural_exp_decay" + argspec: "args=[\'learning_rate\', \'global_step\', \'decay_steps\', \'decay_rate\', \'staircase\', \'name\'], varargs=None, keywords=None, defaults=[\'False\', \'None\'], " + } + member_method { + name: "noisy_linear_cosine_decay" + argspec: "args=[\'learning_rate\', \'global_step\', \'decay_steps\', \'initial_variance\', \'variance_decay\', \'num_periods\', \'alpha\', \'beta\', \'name\'], varargs=None, keywords=None, defaults=[\'1.0\', \'0.55\', \'0.5\', \'0.0\', \'0.001\', \'None\'], " + } + member_method { + name: "piecewise_constant" + argspec: "args=[\'x\', \'boundaries\', \'values\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "polynomial_decay" + argspec: "args=[\'learning_rate\', \'global_step\', \'decay_steps\', \'end_learning_rate\', \'power\', \'cycle\', \'name\'], varargs=None, keywords=None, defaults=[\'0.0001\', \'1.0\', \'False\', \'None\'], " + } + member_method { + name: "range_input_producer" + argspec: "args=[\'limit\', \'num_epochs\', \'shuffle\', \'seed\', \'capacity\', \'shared_name\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'True\', \'None\', \'32\', \'None\', \'None\'], " + } + member_method { + name: "remove_checkpoint" + argspec: "args=[\'checkpoint_prefix\', \'checkpoint_format_version\', \'meta_graph_suffix\'], varargs=None, keywords=None, defaults=[\'2\', \'meta\'], " + } + member_method { + name: "replica_device_setter" + argspec: "args=[\'ps_tasks\', \'ps_device\', \'worker_device\', \'merge_devices\', \'cluster\', \'ps_ops\', \'ps_strategy\'], varargs=None, keywords=None, defaults=[\'0\', \'/job:ps\', \'/job:worker\', \'True\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "sdca_fprint" + argspec: "args=[\'input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "sdca_optimizer" + argspec: "args=[\'sparse_example_indices\', \'sparse_feature_indices\', \'sparse_feature_values\', \'dense_features\', \'example_weights\', \'example_labels\', \'sparse_indices\', \'sparse_weights\', \'dense_weights\', \'example_state_data\', \'loss_type\', \'l1\', \'l2\', \'num_loss_partitions\', \'num_inner_iterations\', \'adaptative\', \'name\'], varargs=None, keywords=None, defaults=[\'True\', \'None\'], " + } + member_method { + name: "sdca_shrink_l1" + argspec: "args=[\'weights\', \'l1\', \'l2\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "shuffle_batch" + argspec: "args=[\'tensors\', \'batch_size\', \'capacity\', \'min_after_dequeue\', \'num_threads\', \'seed\', \'enqueue_many\', \'shapes\', \'allow_smaller_final_batch\', \'shared_name\', \'name\'], varargs=None, keywords=None, defaults=[\'1\', \'None\', \'False\', \'None\', \'False\', \'None\', \'None\'], " + } + member_method { + name: "shuffle_batch_join" + argspec: "args=[\'tensors_list\', \'batch_size\', \'capacity\', \'min_after_dequeue\', \'seed\', \'enqueue_many\', \'shapes\', \'allow_smaller_final_batch\', \'shared_name\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'None\', \'False\', \'None\', \'None\'], " + } + member_method { + name: "slice_input_producer" + argspec: "args=[\'tensor_list\', \'num_epochs\', \'shuffle\', \'seed\', \'capacity\', \'shared_name\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'True\', \'None\', \'32\', \'None\', \'None\'], " + } + member_method { + name: "start_queue_runners" + argspec: "args=[\'sess\', \'coord\', \'daemon\', \'start\', \'collection\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'True\', \'True\', \'queue_runners\'], " + } + member_method { + name: "string_input_producer" + argspec: "args=[\'string_tensor\', \'num_epochs\', \'shuffle\', \'seed\', \'capacity\', \'shared_name\', \'name\', \'cancel_op\'], varargs=None, keywords=None, defaults=[\'None\', \'True\', \'None\', \'32\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "summary_iterator" + argspec: "args=[\'path\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "update_checkpoint_state" + argspec: "args=[\'save_dir\', \'model_checkpoint_path\', \'all_model_checkpoint_paths\', \'latest_filename\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + } + member_method { + name: "warm_start" + argspec: "args=[\'ckpt_to_initialize_from\', \'vars_to_warm_start\', \'var_name_to_vocab_info\', \'var_name_to_prev_var_name\'], varargs=None, keywords=None, defaults=[\'.*\', \'None\', \'None\'], " + } + member_method { + name: "write_graph" + argspec: "args=[\'graph_or_graph_def\', \'logdir\', \'name\', \'as_text\'], varargs=None, keywords=None, defaults=[\'True\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.queue_runner.-queue-runner.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.queue_runner.-queue-runner.pbtxt new file mode 100644 index 0000000000..23d402de30 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.queue_runner.-queue-runner.pbtxt @@ -0,0 +1,49 @@ +path: "tensorflow.train.queue_runner.QueueRunner" +tf_class { + is_instance: "" + is_instance: "" + member { + name: "cancel_op" + mtype: "" + } + member { + name: "close_op" + mtype: "" + } + member { + name: "enqueue_ops" + mtype: "" + } + member { + name: "exceptions_raised" + mtype: "" + } + member { + name: "name" + mtype: "" + } + member { + name: "queue" + mtype: "" + } + member { + name: "queue_closed_exception_types" + mtype: "" + } + member_method { + name: "__init__" + argspec: "args=[\'self\', \'queue\', \'enqueue_ops\', \'close_op\', \'cancel_op\', \'queue_closed_exception_types\', \'queue_runner_def\', \'import_scope\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], " + } + member_method { + name: "create_threads" + argspec: "args=[\'self\', \'sess\', \'coord\', \'daemon\', \'start\'], varargs=None, keywords=None, defaults=[\'None\', \'False\', \'False\'], " + } + member_method { + name: "from_proto" + argspec: "args=[\'queue_runner_def\', \'import_scope\'], varargs=None, keywords=None, defaults=[\'None\'], " + } + member_method { + name: "to_proto" + argspec: "args=[\'self\', \'export_scope\'], varargs=None, keywords=None, defaults=[\'None\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.train.queue_runner.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.train.queue_runner.pbtxt new file mode 100644 index 0000000000..6e2d043049 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.train.queue_runner.pbtxt @@ -0,0 +1,15 @@ +path: "tensorflow.train.queue_runner" +tf_module { + member { + name: "QueueRunner" + mtype: "" + } + member_method { + name: "add_queue_runner" + argspec: "args=[\'qr\', \'collection\'], varargs=None, keywords=None, defaults=[\'queue_runners\'], " + } + member_method { + name: "start_queue_runners" + argspec: "args=[\'sess\', \'coord\', \'daemon\', \'start\', \'collection\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'True\', \'True\', \'queue_runners\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.truncated_normal_initializer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.truncated_normal_initializer.pbtxt new file mode 100644 index 0000000000..c1e1c230a9 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.truncated_normal_initializer.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.truncated_normal_initializer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'mean\', \'stddev\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'0.0\', \'1.0\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.uniform_unit_scaling_initializer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.uniform_unit_scaling_initializer.pbtxt new file mode 100644 index 0000000000..e1b18dc92f --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.uniform_unit_scaling_initializer.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.uniform_unit_scaling_initializer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'factor\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'1.0\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.variable_scope.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.variable_scope.pbtxt new file mode 100644 index 0000000000..e62dec93e6 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.variable_scope.pbtxt @@ -0,0 +1,9 @@ +path: "tensorflow.variable_scope" +tf_class { + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'name_or_scope\', \'default_name\', \'values\', \'initializer\', \'regularizer\', \'caching_device\', \'partitioner\', \'custom_getter\', \'reuse\', \'dtype\', \'use_resource\', \'constraint\', \'auxiliary_name_scope\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'True\'], " + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.variance_scaling_initializer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.variance_scaling_initializer.pbtxt new file mode 100644 index 0000000000..09d7bc03b4 --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.variance_scaling_initializer.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.variance_scaling_initializer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'scale\', \'mode\', \'distribution\', \'seed\', \'dtype\'], varargs=None, keywords=None, defaults=[\'1.0\', \'fan_in\', \'truncated_normal\', \'None\', \"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/golden/v2/tensorflow.zeros_initializer.pbtxt b/tensorflow/tools/api/golden/v2/tensorflow.zeros_initializer.pbtxt new file mode 100644 index 0000000000..e229b02cee --- /dev/null +++ b/tensorflow/tools/api/golden/v2/tensorflow.zeros_initializer.pbtxt @@ -0,0 +1,18 @@ +path: "tensorflow.zeros_initializer" +tf_class { + is_instance: "" + is_instance: "" + is_instance: "" + member_method { + name: "__init__" + argspec: "args=[\'self\', \'dtype\'], varargs=None, keywords=None, defaults=[\"\"], " + } + member_method { + name: "from_config" + argspec: "args=[\'cls\', \'config\'], varargs=None, keywords=None, defaults=None" + } + member_method { + name: "get_config" + argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" + } +} diff --git a/tensorflow/tools/api/tests/BUILD b/tensorflow/tools/api/tests/BUILD index 724b12cd47..8764409e4d 100644 --- a/tensorflow/tools/api/tests/BUILD +++ b/tensorflow/tools/api/tests/BUILD @@ -17,7 +17,8 @@ py_test( name = "api_compatibility_test", srcs = ["api_compatibility_test.py"], data = [ - "//tensorflow/tools/api/golden:api_golden", + "//tensorflow/tools/api/golden:api_golden_v1", + "//tensorflow/tools/api/golden:api_golden_v2", "//tensorflow/tools/api/tests:API_UPDATE_WARNING.txt", "//tensorflow/tools/api/tests:README.txt", ], diff --git a/tensorflow/tools/api/tests/api_compatibility_test.py b/tensorflow/tools/api/tests/api_compatibility_test.py index d1b34fb242..d680b96673 100644 --- a/tensorflow/tools/api/tests/api_compatibility_test.py +++ b/tensorflow/tools/api/tests/api_compatibility_test.py @@ -70,19 +70,25 @@ _VERBOSE_DIFFS_HELP = """ false, only print which libraries have differences. """ -_API_GOLDEN_FOLDER = 'tensorflow/tools/api/golden' +_API_GOLDEN_FOLDER_V1 = 'tensorflow/tools/api/golden/v1' +_API_GOLDEN_FOLDER_V2 = 'tensorflow/tools/api/golden/v2' _TEST_README_FILE = 'tensorflow/tools/api/tests/README.txt' _UPDATE_WARNING_FILE = 'tensorflow/tools/api/tests/API_UPDATE_WARNING.txt' -def _KeyToFilePath(key): - """From a given key, construct a filepath.""" +def _KeyToFilePath(key, api_version): + """From a given key, construct a filepath. + + Filepath will be inside golden folder for api_version. + """ def _ReplaceCapsWithDash(matchobj): match = matchobj.group(0) return '-%s' % (match.lower()) case_insensitive_key = re.sub('([A-Z]{1})', _ReplaceCapsWithDash, key) - return os.path.join(_API_GOLDEN_FOLDER, '%s.pbtxt' % case_insensitive_key) + api_folder = ( + _API_GOLDEN_FOLDER_V2 if api_version == 2 else _API_GOLDEN_FOLDER_V1) + return os.path.join(_API_GOLDEN_FOLDER_V1, '%s.pbtxt' % case_insensitive_key) def _FileNameToKey(filename): @@ -120,7 +126,8 @@ class ApiCompatibilityTest(test.TestCase): actual_dict, verbose=False, update_goldens=False, - additional_missing_object_message=''): + additional_missing_object_message='', + api_version=2): """Diff given dicts of protobufs and report differences a readable way. Args: @@ -133,6 +140,7 @@ class ApiCompatibilityTest(test.TestCase): update_goldens: Whether to update goldens when there are diffs found. additional_missing_object_message: Message to print when a symbol is missing. + api_version: TensorFlow API version to test. """ diffs = [] verbose_diffs = [] @@ -188,13 +196,13 @@ class ApiCompatibilityTest(test.TestCase): # If the keys are only in expected, some objects are deleted. # Remove files. for key in only_in_expected: - filepath = _KeyToFilePath(key) + filepath = _KeyToFilePath(key, api_version) file_io.delete_file(filepath) # If the files are only in actual (current library), these are new # modules. Write them to files. Also record all updates in files. for key in only_in_actual | set(updated_keys): - filepath = _KeyToFilePath(key) + filepath = _KeyToFilePath(key, api_version) file_io.write_string_to_file( filepath, text_format.MessageToString(actual_dict[key])) else: @@ -223,8 +231,8 @@ class ApiCompatibilityTest(test.TestCase): visitor.do_not_descend_map['tf'].append('contrib') traverse.traverse(tf, visitor) - def checkBackwardsCompatibility(self, root, golden_file_pattern): - # Extract all API stuff. + def checkBackwardsCompatibility(self, root, golden_file_pattern, api_version): + # Extract all API stuff. visitor = python_object_to_proto_visitor.PythonObjectToProtoVisitor() public_api_visitor = public_api.PublicAPIVisitor(visitor) @@ -254,16 +262,18 @@ class ApiCompatibilityTest(test.TestCase): golden_proto_dict, proto_dict, verbose=FLAGS.verbose_diffs, - update_goldens=FLAGS.update_goldens) + update_goldens=FLAGS.update_goldens, + api_version=api_version) @unittest.skipUnless( sys.version_info.major == 2, 'API compabitility test goldens are generated using python2.') def testAPIBackwardsCompatibility(self): + api_version = 2 golden_file_pattern = os.path.join( resource_loader.get_root_dir_with_all_resources(), - _KeyToFilePath('*')) - self.checkBackwardsCompatibility(tf, golden_file_pattern) + _KeyToFilePath('*', api_version)) + self.checkBackwardsCompatibility(tf, golden_file_pattern, api_version) @unittest.skipUnless( sys.version_info.major == 2, @@ -271,10 +281,11 @@ class ApiCompatibilityTest(test.TestCase): def testAPIBackwardsCompatibilityV1(self): if not tf_v1: return + api_version = 1 golden_file_pattern = os.path.join( resource_loader.get_root_dir_with_all_resources(), - _KeyToFilePath('*')) - self.checkBackwardsCompatibility(tf_v1, golden_file_pattern) + _KeyToFilePath('*', api_version)) + self.checkBackwardsCompatibility(tf_v1, golden_file_pattern, api_version) if __name__ == '__main__': -- GitLab From 0cae77919613b15ec5ba4db167966ba21e969fd8 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 7 Aug 2018 15:38:31 -0700 Subject: [PATCH 178/437] [XLA] Delete the xla_builder in xla_client. PiperOrigin-RevId: 207792582 --- tensorflow/compiler/xla/client/lib/BUILD | 6 ++-- tensorflow/compiler/xla/client/lib/pooling.h | 2 +- tensorflow/compiler/xla/client/lib/sorting.h | 2 +- .../compiler/xla/client/lib/sorting_test.cc | 2 +- .../compiler/xla/client/xla_client/BUILD | 33 ------------------- .../xla/client/xla_client/xla_builder.h | 21 ------------ .../performance/xla/operation_semantics.md | 2 +- 7 files changed, 7 insertions(+), 61 deletions(-) delete mode 100644 tensorflow/compiler/xla/client/xla_client/BUILD delete mode 100644 tensorflow/compiler/xla/client/xla_client/xla_builder.h diff --git a/tensorflow/compiler/xla/client/lib/BUILD b/tensorflow/compiler/xla/client/lib/BUILD index 8bf0773928..a2f32ab97e 100644 --- a/tensorflow/compiler/xla/client/lib/BUILD +++ b/tensorflow/compiler/xla/client/lib/BUILD @@ -129,7 +129,7 @@ cc_library( ":arithmetic", ":constants", "//tensorflow/compiler/tf2xla/lib:util", - "//tensorflow/compiler/xla/client/xla_client:xla_builder", + "//tensorflow/compiler/xla/client:xla_builder", "//tensorflow/core:lib", ], ) @@ -168,7 +168,7 @@ cc_library( ":numeric", "//tensorflow/compiler/xla:types", "//tensorflow/compiler/xla:xla_data_proto", - "//tensorflow/compiler/xla/client/xla_client:xla_builder", + "//tensorflow/compiler/xla/client:xla_builder", ], ) @@ -185,7 +185,7 @@ xla_test( "//tensorflow/compiler/xla:test", "//tensorflow/compiler/xla:types", "//tensorflow/compiler/xla:xla_data_proto", - "//tensorflow/compiler/xla/client/xla_client:xla_builder", + "//tensorflow/compiler/xla/client:xla_builder", "//tensorflow/compiler/xla/tests:client_library_test_base", "//tensorflow/compiler/xla/tests:xla_internal_test_main", ], diff --git a/tensorflow/compiler/xla/client/lib/pooling.h b/tensorflow/compiler/xla/client/lib/pooling.h index 66d8006aae..1699c585d3 100644 --- a/tensorflow/compiler/xla/client/lib/pooling.h +++ b/tensorflow/compiler/xla/client/lib/pooling.h @@ -16,7 +16,7 @@ limitations under the License. #ifndef TENSORFLOW_COMPILER_XLA_CLIENT_LIB_POOLING_H_ #define TENSORFLOW_COMPILER_XLA_CLIENT_LIB_POOLING_H_ -#include "tensorflow/compiler/xla/client/xla_client/xla_builder.h" +#include "tensorflow/compiler/xla/client/xla_builder.h" #include "tensorflow/core/lib/gtl/inlined_vector.h" namespace xla { diff --git a/tensorflow/compiler/xla/client/lib/sorting.h b/tensorflow/compiler/xla/client/lib/sorting.h index 404b4783c3..b9dfafdd6f 100644 --- a/tensorflow/compiler/xla/client/lib/sorting.h +++ b/tensorflow/compiler/xla/client/lib/sorting.h @@ -16,7 +16,7 @@ limitations under the License. #ifndef TENSORFLOW_COMPILER_XLA_CLIENT_LIB_SORTING_H_ #define TENSORFLOW_COMPILER_XLA_CLIENT_LIB_SORTING_H_ -#include "tensorflow/compiler/xla/client/xla_client/xla_builder.h" +#include "tensorflow/compiler/xla/client/xla_builder.h" #include "tensorflow/compiler/xla/types.h" #include "tensorflow/compiler/xla/xla_data.pb.h" diff --git a/tensorflow/compiler/xla/client/lib/sorting_test.cc b/tensorflow/compiler/xla/client/lib/sorting_test.cc index b6eee762a5..fef98c9923 100644 --- a/tensorflow/compiler/xla/client/lib/sorting_test.cc +++ b/tensorflow/compiler/xla/client/lib/sorting_test.cc @@ -14,7 +14,7 @@ limitations under the License. ==============================================================================*/ #include "tensorflow/compiler/xla/client/lib/sorting.h" -#include "tensorflow/compiler/xla/client/xla_client/xla_builder.h" +#include "tensorflow/compiler/xla/client/xla_builder.h" #include "tensorflow/compiler/xla/test.h" #include "tensorflow/compiler/xla/tests/client_library_test_base.h" #include "tensorflow/compiler/xla/tests/test_macros.h" diff --git a/tensorflow/compiler/xla/client/xla_client/BUILD b/tensorflow/compiler/xla/client/xla_client/BUILD deleted file mode 100644 index 2e131dbad2..0000000000 --- a/tensorflow/compiler/xla/client/xla_client/BUILD +++ /dev/null @@ -1,33 +0,0 @@ -# Description: -# The new XLA client libraries. - -licenses(["notice"]) # Apache 2.0 - -package(default_visibility = [":friends"]) - -package_group( - name = "friends", - includes = [ - "//tensorflow/compiler/xla:friends", - ], -) - -# Filegroup used to collect source files for dependency checking. -filegroup( - name = "c_srcs", - data = glob([ - "**/*.cc", - "**/*.h", - ]), -) - -load("//tensorflow:tensorflow.bzl", "tf_cc_test") - -cc_library( - name = "xla_builder", - hdrs = ["xla_builder.h"], - visibility = ["//visibility:public"], - deps = [ - "//tensorflow/compiler/xla/client:xla_builder", - ], -) diff --git a/tensorflow/compiler/xla/client/xla_client/xla_builder.h b/tensorflow/compiler/xla/client/xla_client/xla_builder.h deleted file mode 100644 index ce2a8afd4c..0000000000 --- a/tensorflow/compiler/xla/client/xla_client/xla_builder.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -==============================================================================*/ - -#ifndef TENSORFLOW_COMPILER_XLA_CLIENT_XLA_CLIENT_XLA_BUILDER_H_ -#define TENSORFLOW_COMPILER_XLA_CLIENT_XLA_CLIENT_XLA_BUILDER_H_ - -#include "tensorflow/compiler/xla/client/xla_builder.h" - -#endif // TENSORFLOW_COMPILER_XLA_CLIENT_XLA_CLIENT_XLA_BUILDER_H_ diff --git a/tensorflow/docs_src/performance/xla/operation_semantics.md b/tensorflow/docs_src/performance/xla/operation_semantics.md index 8726fdb67a..165f6f5914 100644 --- a/tensorflow/docs_src/performance/xla/operation_semantics.md +++ b/tensorflow/docs_src/performance/xla/operation_semantics.md @@ -1847,7 +1847,7 @@ tensor `operand`, with several slices (at indices specified by `update_computation`. See also -[`XlaBuilder::Scatter`](https://www.tensorflow.org/code/tensorflow/compiler/xla/client/xla_client/xla_builder.h). +[`XlaBuilder::Scatter`](https://www.tensorflow.org/code/tensorflow/compiler/xla/client/xla_builder.h). `scatter(operand, scatter_indices, updates, update_computation, index_vector_dim, update_window_dims, inserted_window_dims, scatter_dims_to_operand_dims)` -- GitLab From ef2bd57e75d829a921e9045851c53bcecf441d08 Mon Sep 17 00:00:00 2001 From: Frank Chen Date: Tue, 7 Aug 2018 16:36:40 -0700 Subject: [PATCH 179/437] Preliminary work for auto-detecting cores and hosts for TPU Distribution Strategy PiperOrigin-RevId: 207802033 --- tensorflow/contrib/distribute/python/BUILD | 1 + .../contrib/distribute/python/combinations.py | 5 ++- .../contrib/distribute/python/tpu_strategy.py | 38 ++++++++++++++++--- tensorflow/contrib/tpu/BUILD | 2 +- .../contrib/tpu/python/tpu/tpu_context.py | 7 +++- .../tpu/python/tpu/tpu_system_metadata.py | 19 +++++----- 6 files changed, 53 insertions(+), 19 deletions(-) diff --git a/tensorflow/contrib/distribute/python/BUILD b/tensorflow/contrib/distribute/python/BUILD index d9e66ddac0..3159dd154a 100644 --- a/tensorflow/contrib/distribute/python/BUILD +++ b/tensorflow/contrib/distribute/python/BUILD @@ -187,6 +187,7 @@ py_library( ":multi_worker_strategy", ":one_device_strategy", ":tpu_strategy", + "//tensorflow/contrib/cluster_resolver:cluster_resolver_pip", "//tensorflow/contrib/optimizer_v2:training", "//tensorflow/python:distribute", "//tensorflow/python:framework_ops", diff --git a/tensorflow/contrib/distribute/python/combinations.py b/tensorflow/contrib/distribute/python/combinations.py index 52f73ddb03..120349481f 100644 --- a/tensorflow/contrib/distribute/python/combinations.py +++ b/tensorflow/contrib/distribute/python/combinations.py @@ -46,6 +46,7 @@ import unittest from absl.testing import parameterized import six +from tensorflow.contrib.cluster_resolver import TPUClusterResolver from tensorflow.contrib.distribute.python import mirrored_strategy as mirrored_lib from tensorflow.contrib.distribute.python import multi_worker_strategy from tensorflow.contrib.distribute.python import one_device_strategy as one_device_lib @@ -324,7 +325,9 @@ default_strategy = NamedDistribution( one_device_strategy = NamedDistribution( "OneDeviceCPU", lambda: one_device_lib.OneDeviceStrategy("/cpu:0"), required_gpus=None) -tpu_strategy = NamedDistribution("TPU", tpu_lib.TPUStrategy, required_tpu=True) +tpu_strategy = NamedDistribution( + "TPU", lambda: tpu_lib.TPUStrategy(TPUClusterResolver("")), + required_tpu=True) # Note that we disable prefetching for testing since prefetching makes # the input non-deterministic. mirrored_strategy_with_gpu_and_cpu = NamedDistribution( diff --git a/tensorflow/contrib/distribute/python/tpu_strategy.py b/tensorflow/contrib/distribute/python/tpu_strategy.py index f5497e0b21..d34258703c 100644 --- a/tensorflow/contrib/distribute/python/tpu_strategy.py +++ b/tensorflow/contrib/distribute/python/tpu_strategy.py @@ -26,6 +26,7 @@ from tensorflow.contrib.distribute.python import one_device_strategy from tensorflow.contrib.distribute.python import values from tensorflow.contrib.tpu.python.ops import tpu_ops from tensorflow.contrib.tpu.python.tpu import tpu +from tensorflow.contrib.tpu.python.tpu import tpu_system_metadata as tpu_system_metadata_lib from tensorflow.contrib.tpu.python.tpu import training_loop from tensorflow.python.framework import constant_op from tensorflow.python.framework import ops @@ -34,18 +35,43 @@ from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import variable_scope as vs from tensorflow.python.training import device_util +from tensorflow.python.training import server_lib from tensorflow.python.util import nest +def get_tpu_system_metadata(tpu_cluster_resolver): + """Retrieves TPU system metadata given a TPUClusterResolver.""" + master = tpu_cluster_resolver.master() + + # pylint: disable=protected-access + cluster_def = (tpu_cluster_resolver.cluster_spec() + or server_lib.ClusterSpec({})).as_cluster_def() + tpu_system_metadata = ( + tpu_system_metadata_lib._query_tpu_system_metadata( + master, + cluster_def=cluster_def, + query_topology=True)) + + return tpu_system_metadata + + class TPUStrategy(one_device_strategy.OneDeviceStrategy): """Experimental TPU distribution strategy implementation.""" - def __init__(self, num_cores_per_host=2): + def __init__(self, tpu_cluster_resolver): + """Initializes the TPUStrategy object. + + Args: + tpu_cluster_resolver: A tf.contrib.cluster_resolver.TPUClusterResolver, + which provides information about the TPU cluster. + """ # TODO(isaprykin): Generalize the defaults. They are currently tailored for # the unit test. super(TPUStrategy, self).__init__('/device:CPU:0') - # TODO(isaprykin): Auto-detect number of cores and hosts. - self._num_cores_per_host = num_cores_per_host + + self._tpu_cluster_resolver = tpu_cluster_resolver + self._tpu_metadata = get_tpu_system_metadata(self._tpu_cluster_resolver) + # TODO(priyag): This should not be hardcoded here. self._host = '/device:CPU:0' @@ -72,7 +98,7 @@ class TPUStrategy(one_device_strategy.OneDeviceStrategy): control_deps = [] sharded_inputs = [] with ops.device(self._host): - for _ in range(self._num_cores_per_host): + for _ in range(self.num_towers): # Use control dependencies to ensure a deterministic ordering. with ops.control_dependencies(control_deps): inputs = nest.flatten(iterator.get_next()) @@ -118,7 +144,7 @@ class TPUStrategy(one_device_strategy.OneDeviceStrategy): def iterate_on_tpu(): return training_loop.repeat(iterations, run_fn, [initial_loop_values]) - replicate_inputs = [[]] * self._num_cores_per_host + replicate_inputs = [[]] * self.num_towers outputs = tpu.replicate(iterate_on_tpu, replicate_inputs) last_step_tensor_outputs = [list(x) for x in zip(*outputs)] @@ -168,4 +194,4 @@ class TPUStrategy(one_device_strategy.OneDeviceStrategy): @property def num_towers(self): - return self._num_cores_per_host + return self._tpu_metadata.num_of_cores_per_host diff --git a/tensorflow/contrib/tpu/BUILD b/tensorflow/contrib/tpu/BUILD index f5d852908a..1669f6050e 100644 --- a/tensorflow/contrib/tpu/BUILD +++ b/tensorflow/contrib/tpu/BUILD @@ -41,7 +41,6 @@ py_library( "python/tpu/tpu_config.py", "python/tpu/tpu_context.py", "python/tpu/tpu_estimator.py", - "python/tpu/tpu_system_metadata.py", "python/tpu/util.py", ], srcs_version = "PY2AND3", @@ -217,6 +216,7 @@ py_library( "python/tpu/tpu_function.py", "python/tpu/tpu_optimizer.py", "python/tpu/tpu_sharding.py", + "python/tpu/tpu_system_metadata.py", "python/tpu/training_loop.py", ], srcs_version = "PY2AND3", diff --git a/tensorflow/contrib/tpu/python/tpu/tpu_context.py b/tensorflow/contrib/tpu/python/tpu/tpu_context.py index 2c054360a4..806ae1c4c9 100644 --- a/tensorflow/contrib/tpu/python/tpu/tpu_context.py +++ b/tensorflow/contrib/tpu/python/tpu/tpu_context.py @@ -232,11 +232,16 @@ class _InternalTPUContext(object): if tpu_system_metadata is not None: return tpu_system_metadata + cluster_def = None + if (self._config.session_config and + self._config.session_config.cluster_def.job): + cluster_def = self._config.session_config.cluster_def + # pylint: disable=protected-access tpu_system_metadata = ( tpu_system_metadata_lib._query_tpu_system_metadata( master, - run_config=self._config, + cluster_def=cluster_def, query_topology=self.model_parallelism_enabled)) self._lazy_tpu_system_metadata_dict[master] = tpu_system_metadata diff --git a/tensorflow/contrib/tpu/python/tpu/tpu_system_metadata.py b/tensorflow/contrib/tpu/python/tpu/tpu_system_metadata.py index 894f21d063..ec682e5829 100644 --- a/tensorflow/contrib/tpu/python/tpu/tpu_system_metadata.py +++ b/tensorflow/contrib/tpu/python/tpu/tpu_system_metadata.py @@ -45,7 +45,7 @@ _TPUSystemMetadata = collections.namedtuple('_TPUSystemMetadata', [ ]) -def _query_tpu_system_metadata(master_address, run_config, +def _query_tpu_system_metadata(master_address, cluster_def=None, query_topology=False): """Automatically detects the TPU system metadata in the system.""" tpu_core_count = 0 @@ -61,7 +61,8 @@ def _query_tpu_system_metadata(master_address, run_config, with session_lib.Session( master_address, config=get_session_config_with_timeout( - _PINGING_MASTER_TIMEOUT_IN_MS, run_config)) as sess: + _PINGING_MASTER_TIMEOUT_IN_MS, + cluster_def)) as sess: devices = sess.list_devices() for device in devices: match = _TPU_DEVICE_REG.match(device.name) @@ -105,7 +106,7 @@ def _query_tpu_system_metadata(master_address, run_config, 'TPU worker has some problems. Available devices: {}'.format( master_address, devices)) - topology = _obtain_topology(master_address, run_config) + topology = _obtain_topology(master_address, cluster_def) metadata = _TPUSystemMetadata( num_cores=tpu_core_count, @@ -127,14 +128,15 @@ def _query_tpu_system_metadata(master_address, run_config, return metadata -def _obtain_topology(master_address, run_config): +def _obtain_topology(master_address, cluster_def): + """Obtains TPU fabric topology.""" try: logging.info('Initializing TPU system (master: %s) to fetch topology ' 'for model parallelism. This might take a while.', master_address) with ops.Graph().as_default(): session_config = get_session_config_with_timeout( - _INITIAL_TPU_SYSTEM_TIMEOUT_IN_MS, run_config) + _INITIAL_TPU_SYSTEM_TIMEOUT_IN_MS, cluster_def) with session_lib.Session( master_address, config=session_config) as sess: topology = sess.run(tpu.initialize_system()) @@ -146,11 +148,8 @@ def _obtain_topology(master_address, run_config): master_address)) -def get_session_config_with_timeout(timeout_in_secs, run_config): - cluster_def = None - if run_config.session_config and run_config.session_config.cluster_def.job: - cluster_def = run_config.session_config.cluster_def - +def get_session_config_with_timeout(timeout_in_secs, cluster_def): + """Returns a session given a timeout and a cluster configuration.""" config = config_pb2.ConfigProto( operation_timeout_in_ms=timeout_in_secs, cluster_def=cluster_def) return config -- GitLab From 6f07c3f37425ca0f893cd7f2f457830662ffed02 Mon Sep 17 00:00:00 2001 From: Mark Daoust Date: Tue, 7 Aug 2018 16:41:12 -0700 Subject: [PATCH 180/437] "All_files" is no longer necessary (ref: cl/190878279) `layers` subclassing instructions are out of date. PiperOrigin-RevId: 207802618 --- tensorflow/docs_src/community/style_guide.md | 58 ++------------------ 1 file changed, 5 insertions(+), 53 deletions(-) diff --git a/tensorflow/docs_src/community/style_guide.md b/tensorflow/docs_src/community/style_guide.md index c9268790a7..daf0d2fdc0 100644 --- a/tensorflow/docs_src/community/style_guide.md +++ b/tensorflow/docs_src/community/style_guide.md @@ -47,27 +47,7 @@ licenses(["notice"]) # Apache 2.0 exports_files(["LICENSE"]) ``` -* At the end of every BUILD file, should contain: -``` -filegroup( - name = "all_files", - srcs = glob( - ["**/*"], - exclude = [ - "**/METADATA", - "**/OWNERS", - ], - ), - visibility = ["//tensorflow:__subpackages__"], -) -``` - -* When adding new BUILD file, add this line to `tensorflow/BUILD` file into `all_opensource_files` target. - -``` -"//tensorflow/:all_files", -``` * For all Python BUILD targets (libraries and tests) add next line: @@ -80,6 +60,9 @@ srcs_version = "PY2AND3", * Operations that deal with batches may assume that the first dimension of a Tensor is the batch dimension. +* In most models the *last dimension* is the number of channels. + +* Dimensions excluding the first and last usually make up the "space" dimensions: Sequence-length or Image-size. ## Python operations @@ -148,37 +131,6 @@ Usage: ## Layers -A *Layer* is a Python operation that combines variable creation and/or one or many -other graph operations. Follow the same requirements as for regular Python -operation. - -* If a layer creates one or more variables, the layer function - should take next arguments also following order: - - `initializers`: Optionally allow to specify initializers for the variables. - - `regularizers`: Optionally allow to specify regularizers for the variables. - - `trainable`: which control if their variables are trainable or not. - - `scope`: `VariableScope` object that variable will be put under. - - `reuse`: `bool` indicator if the variable should be reused if - it's present in the scope. - -* Layers that behave differently during training should take: - - `is_training`: `bool` indicator to conditionally choose different - computation paths (e.g. using `tf.cond`) during execution. - -Example: - - def conv2d(inputs, - num_filters_out, - kernel_size, - stride=1, - padding='SAME', - activation_fn=tf.nn.relu, - normalization_fn=add_bias, - normalization_params=None, - initializers=None, - regularizers=None, - trainable=True, - scope=None, - reuse=None): - ... see implementation at tensorflow/contrib/layers/python/layers/layers.py ... +Use `tf.keras.layers`, not `tf.layers`. +See `tf.keras.layers` and [the Keras guide](../guide/keras.md#custom_layers) for details on how to sub-class layers. -- GitLab From 75ee9f5e9bc04c312363d9c0836dd9c3851ead64 Mon Sep 17 00:00:00 2001 From: Rohan Jain Date: Tue, 7 Aug 2018 16:42:16 -0700 Subject: [PATCH 181/437] Making PrefetchToDevice work on XLA Compile on Demand mode. Also adds a bunch of dataset / iterator kernel registrations for XLA. PiperOrigin-RevId: 207802858 --- tensorflow/compiler/jit/BUILD | 4 + tensorflow/compiler/jit/xla_device_ops.h | 68 +- tensorflow/compiler/tf2xla/kernels/arg_op.cc | 2 +- .../compiler/tf2xla/kernels/retval_op.cc | 2 +- .../process_function_library_runtime.cc | 5 +- tensorflow/core/framework/dataset.cc | 47 ++ tensorflow/core/framework/dataset.h | 32 + tensorflow/core/kernels/BUILD | 1 + tensorflow/core/kernels/data/BUILD | 3 + .../core/kernels/data/generator_dataset_op.cc | 292 ++++---- .../core/kernels/data/generator_dataset_op.h | 41 ++ tensorflow/core/kernels/data/iterator_ops.cc | 652 +++++++----------- tensorflow/core/kernels/data/iterator_ops.h | 140 ++++ .../core/kernels/data/prefetch_dataset_op.cc | 550 +++++++-------- .../core/kernels/data/prefetch_dataset_op.h | 39 ++ tensorflow/core/kernels/function_ops.cc | 296 ++++---- tensorflow/core/kernels/function_ops.h | 79 +++ 17 files changed, 1241 insertions(+), 1012 deletions(-) create mode 100644 tensorflow/core/kernels/data/generator_dataset_op.h create mode 100644 tensorflow/core/kernels/data/iterator_ops.h create mode 100644 tensorflow/core/kernels/data/prefetch_dataset_op.h create mode 100644 tensorflow/core/kernels/function_ops.h diff --git a/tensorflow/compiler/jit/BUILD b/tensorflow/compiler/jit/BUILD index d3238c6a5e..15f9ba217f 100644 --- a/tensorflow/compiler/jit/BUILD +++ b/tensorflow/compiler/jit/BUILD @@ -178,6 +178,7 @@ cc_library( "//tensorflow/core/kernels:constant_op", "//tensorflow/core/kernels:control_flow_ops", "//tensorflow/core/kernels:fifo_queue", + "//tensorflow/core/kernels:function_ops", "//tensorflow/core/kernels:identity_n_op", "//tensorflow/core/kernels:identity_op", "//tensorflow/core/kernels:no_op", @@ -186,6 +187,9 @@ cc_library( "//tensorflow/core/kernels:sendrecv_ops", "//tensorflow/core/kernels:shape_ops", "//tensorflow/core/kernels:variable_ops", + "//tensorflow/core/kernels/data:generator_dataset_op", + "//tensorflow/core/kernels/data:iterator_ops", + "//tensorflow/core/kernels/data:prefetch_dataset_op", ], ) diff --git a/tensorflow/compiler/jit/xla_device_ops.h b/tensorflow/compiler/jit/xla_device_ops.h index 6adda327f1..da3e329247 100644 --- a/tensorflow/compiler/jit/xla_device_ops.h +++ b/tensorflow/compiler/jit/xla_device_ops.h @@ -23,7 +23,11 @@ limitations under the License. #include "tensorflow/core/kernels/cast_op.h" #include "tensorflow/core/kernels/constant_op.h" #include "tensorflow/core/kernels/control_flow_ops.h" +#include "tensorflow/core/kernels/data/generator_dataset_op.h" +#include "tensorflow/core/kernels/data/iterator_ops.h" +#include "tensorflow/core/kernels/data/prefetch_dataset_op.h" #include "tensorflow/core/kernels/fifo_queue.h" +#include "tensorflow/core/kernels/function_ops.h" #include "tensorflow/core/kernels/identity_n_op.h" #include "tensorflow/core/kernels/identity_op.h" #include "tensorflow/core/kernels/no_op.h" @@ -166,7 +170,69 @@ class XlaAssignVariableOp : public AsyncOpKernel { QueueIsClosedOp); \ \ REGISTER_KERNEL_BUILDER( \ - Name("FIFOQueueV2").Device(DEVICE).HostMemory("handle"), FIFOQueueOp); + Name("FIFOQueueV2").Device(DEVICE).HostMemory("handle"), FIFOQueueOp); \ + \ + REGISTER_KERNEL_BUILDER( \ + Name(kArgOp).Device(DEVICE).HostMemory("output").TypeConstraint("T", \ + TYPES), \ + ArgOp); \ + REGISTER_KERNEL_BUILDER(Name(kArgOp) \ + .Device(DEVICE) \ + .HostMemory("output") \ + .TypeConstraint("T"), \ + ArgOp); \ + \ + REGISTER_KERNEL_BUILDER(Name(kRetOp) \ + .Device(DEVICE) \ + .TypeConstraint("T", TYPES) \ + .HostMemory("input"), \ + RetvalOp); \ + REGISTER_KERNEL_BUILDER(Name(kRetOp) \ + .Device(DEVICE) \ + .TypeConstraint("T") \ + .HostMemory("input"), \ + RetvalOp); \ + \ + REGISTER_KERNEL_BUILDER( \ + Name("RemoteCall").Device(DEVICE).HostMemory("target"), RemoteCallOp); \ + \ + REGISTER_KERNEL_BUILDER( \ + Name("GeneratorDataset").Device(DEVICE).HostMemory("handle"), \ + GeneratorDatasetOp); \ + REGISTER_KERNEL_BUILDER(Name("PrefetchDataset") \ + .Device(DEVICE) \ + .HostMemory("buffer_size") \ + .HostMemory("input_dataset") \ + .HostMemory("handle"), \ + PrefetchDatasetOp); \ + \ + REGISTER_KERNEL_BUILDER(Name("IteratorV2").Device(DEVICE), \ + IteratorHandleOp); \ + REGISTER_KERNEL_BUILDER( \ + Name("MakeIterator").Device(DEVICE).HostMemory("dataset"), \ + MakeIteratorOp); \ + REGISTER_KERNEL_BUILDER(Name("AnonymousIterator").Device(DEVICE), \ + AnonymousIteratorHandleOp); \ + REGISTER_KERNEL_BUILDER(Name("IteratorGetNext").Device(DEVICE), \ + IteratorGetNextOp); \ + REGISTER_KERNEL_BUILDER(Name("IteratorToStringHandle") \ + .Device(DEVICE) \ + .HostMemory("string_handle"), \ + IteratorToStringHandleOp); \ + REGISTER_KERNEL_BUILDER(Name("IteratorFromStringHandleV2") \ + .Device(DEVICE) \ + .HostMemory("string_handle"), \ + IteratorFromStringHandleOp); \ + REGISTER_KERNEL_BUILDER(Name(FunctionLibraryDefinition::kArgOp) \ + .Device(DEVICE) \ + .HostMemory("output") \ + .TypeConstraint("T"), \ + ArgOp); \ + REGISTER_KERNEL_BUILDER(Name(FunctionLibraryDefinition::kRetOp) \ + .Device(DEVICE) \ + .TypeConstraint("T") \ + .HostMemory("input"), \ + RetvalOp); // TODO(phawkins): currently we do not register the QueueEnqueueMany, // QueueDequeueMany, or QueueDequeueUpTo kernels because they attempt to read diff --git a/tensorflow/compiler/tf2xla/kernels/arg_op.cc b/tensorflow/compiler/tf2xla/kernels/arg_op.cc index 26fc1620a4..276d744c09 100644 --- a/tensorflow/compiler/tf2xla/kernels/arg_op.cc +++ b/tensorflow/compiler/tf2xla/kernels/arg_op.cc @@ -65,6 +65,6 @@ class XlaArgOp : public XlaOpKernel { TF_DISALLOW_COPY_AND_ASSIGN(XlaArgOp); }; -REGISTER_XLA_OP(Name("_Arg").AllowResourceTypes(), XlaArgOp); +REGISTER_XLA_OP(Name("_Arg").AllowResourceTypes().CompilationOnly(), XlaArgOp); } // namespace tensorflow diff --git a/tensorflow/compiler/tf2xla/kernels/retval_op.cc b/tensorflow/compiler/tf2xla/kernels/retval_op.cc index 1911e6ea36..64900e4709 100644 --- a/tensorflow/compiler/tf2xla/kernels/retval_op.cc +++ b/tensorflow/compiler/tf2xla/kernels/retval_op.cc @@ -104,7 +104,7 @@ class RetvalOp : public XlaOpKernel { TF_DISALLOW_COPY_AND_ASSIGN(RetvalOp); }; -REGISTER_XLA_OP(Name("_Retval"), RetvalOp); +REGISTER_XLA_OP(Name("_Retval").CompilationOnly(), RetvalOp); } // anonymous namespace } // namespace tensorflow diff --git a/tensorflow/core/common_runtime/process_function_library_runtime.cc b/tensorflow/core/common_runtime/process_function_library_runtime.cc index 729312a310..6dac4c3acf 100644 --- a/tensorflow/core/common_runtime/process_function_library_runtime.cc +++ b/tensorflow/core/common_runtime/process_function_library_runtime.cc @@ -145,12 +145,11 @@ Status ProcessFunctionLibraryRuntime::GetDeviceContext( } Device* device = flr->device(); string device_type = device->parsed_name().type; - if (device_type == "CPU" || device_type == "TPU_SYSTEM" || - device_type == "TPU") { + if (device_type == "CPU" || device_type == "TPU_SYSTEM") { // "TPU_SYSTEM" indicates that `device` is a CPU. return Status::OK(); } - if (device_type == "GPU") { + if (device_type == "GPU" || device_type == "TPU") { auto* dev_info = flr->device()->tensorflow_gpu_device_info(); if (dev_info) { *device_context = dev_info->default_context; diff --git a/tensorflow/core/framework/dataset.cc b/tensorflow/core/framework/dataset.cc index 62a9d5751d..6510f81ab7 100644 --- a/tensorflow/core/framework/dataset.cc +++ b/tensorflow/core/framework/dataset.cc @@ -270,6 +270,53 @@ const char GraphDatasetBase::kDatasetGraphKey[] = "_DATASET_GRAPH"; const char GraphDatasetBase::kDatasetGraphOutputNodeKey[] = "_DATASET_GRAPH_OUTPUT_NODE"; +BackgroundWorker::BackgroundWorker(Env* env, const string& name) { + thread_.reset(env->StartThread({} /* thread_options */, name, + [this]() { WorkerLoop(); })); +} + +BackgroundWorker::~BackgroundWorker() { + { + mutex_lock l(mu_); + cancelled_ = true; + } + cond_var_.notify_one(); + // Block until the background thread has terminated. + // + // NOTE(mrry): We explicitly free and join the thread here because + // `WorkerLoop()` uses other members of this object, and so we must join + // the thread before destroying them. + thread_.reset(); +} + +void BackgroundWorker::Schedule(std::function work_item) { + { + mutex_lock l(mu_); + work_queue_.push_back(std::move(work_item)); + } + cond_var_.notify_one(); +} + +void BackgroundWorker::WorkerLoop() { + while (true) { + std::function work_item = nullptr; + { + mutex_lock l(mu_); + while (!cancelled_ && work_queue_.empty()) { + cond_var_.wait(l); + } + if (cancelled_) { + return; + } + DCHECK(!work_queue_.empty()); + work_item = std::move(work_queue_.front()); + work_queue_.pop_front(); + } + DCHECK(work_item != nullptr); + work_item(); + } +} + namespace dataset { IteratorContext MakeIteratorContext(OpKernelContext* ctx) { diff --git a/tensorflow/core/framework/dataset.h b/tensorflow/core/framework/dataset.h index 8cf84afedb..ad73a3d0c7 100644 --- a/tensorflow/core/framework/dataset.h +++ b/tensorflow/core/framework/dataset.h @@ -15,6 +15,7 @@ limitations under the License. #ifndef TENSORFLOW_CORE_FRAMEWORK_DATASET_H_ #define TENSORFLOW_CORE_FRAMEWORK_DATASET_H_ +#include #include #include "tensorflow/core/framework/attr_value.pb.h" @@ -671,6 +672,37 @@ Status GetDatasetFromVariantTensor(const Tensor& tensor, // The ownership of `dataset` is transferred to `tensor`. Status StoreDatasetInVariantTensor(DatasetBase* dataset, Tensor* tensor); +// A simple background worker that executes closures asynchronously and without +// blocking. +// +// A `BackgroundWorker` is used to offload blocking work from an `AsyncOpKernel` +// to avoid blocking an executor thread that may be required by the blocking +// work. +// +// NOTE(mrry): We do not use a regular `tensorflow::thread::ThreadPool` for this +// purpose because its current implementation (in Eigen) uses a finite-length +// queue and will block the caller when full. This can lead to deadlock under +// heavy load. Since the number of concurrent work items in each user of a +// `BackgroundWorker` is at most one per op invocation, the dynamic allocation +// overhead is tolerable. +class BackgroundWorker { + public: + BackgroundWorker(Env* env, const string& name); + + ~BackgroundWorker(); + + void Schedule(std::function work_item); + + private: + void WorkerLoop(); + + std::unique_ptr thread_; + mutex mu_; + condition_variable cond_var_; + bool cancelled_ GUARDED_BY(mu_) = false; + std::deque> work_queue_ GUARDED_BY(mu_); +}; + namespace dataset { IteratorContext MakeIteratorContext(OpKernelContext* ctx); diff --git a/tensorflow/core/kernels/BUILD b/tensorflow/core/kernels/BUILD index ed690fbb53..e66e9a10e7 100644 --- a/tensorflow/core/kernels/BUILD +++ b/tensorflow/core/kernels/BUILD @@ -4887,6 +4887,7 @@ filegroup( "fill_functor.cc", "fill_functor.h", "function_ops.cc", + "function_ops.h", "gather_functor.h", "gather_nd_op.cc", "gather_nd_op.h", diff --git a/tensorflow/core/kernels/data/BUILD b/tensorflow/core/kernels/data/BUILD index d2b3c15760..599ec60270 100644 --- a/tensorflow/core/kernels/data/BUILD +++ b/tensorflow/core/kernels/data/BUILD @@ -251,6 +251,7 @@ tf_kernel_library( tf_kernel_library( name = "generator_dataset_op", srcs = ["generator_dataset_op.cc"], + hdrs = ["generator_dataset_op.h"], deps = [ ":captured_function", "//tensorflow/core:core_cpu_internal", @@ -343,6 +344,7 @@ tf_cc_test( tf_kernel_library( name = "prefetch_dataset_op", srcs = ["prefetch_dataset_op.cc"], + hdrs = ["prefetch_dataset_op.h"], deps = [ ":dataset", ":prefetch_autotuner", @@ -564,6 +566,7 @@ tf_kernel_library( tf_kernel_library( name = "iterator_ops", srcs = ["iterator_ops.cc"], + hdrs = ["iterator_ops.h"], deps = [ ":dataset", ":dataset_utils", diff --git a/tensorflow/core/kernels/data/generator_dataset_op.cc b/tensorflow/core/kernels/data/generator_dataset_op.cc index 0981e42ba1..c4dd849b8b 100644 --- a/tensorflow/core/kernels/data/generator_dataset_op.cc +++ b/tensorflow/core/kernels/data/generator_dataset_op.cc @@ -15,192 +15,174 @@ limitations under the License. #include #include -#include "tensorflow/core/framework/dataset.h" +#include "tensorflow/core/kernels/data/generator_dataset_op.h" + #include "tensorflow/core/framework/partial_tensor_shape.h" #include "tensorflow/core/framework/tensor.h" -#include "tensorflow/core/kernels/data/captured_function.h" #include "tensorflow/core/lib/random/random.h" namespace tensorflow { -namespace { - // See documentation in ../ops/dataset_ops.cc for a high-level // description of the following op. -class GeneratorDatasetOp : public DatasetOpKernel { +class GeneratorDatasetOp::Dataset : public GraphDatasetBase { public: - explicit GeneratorDatasetOp(OpKernelConstruction* ctx) - : DatasetOpKernel(ctx) { - OP_REQUIRES_OK(ctx, ctx->GetAttr("init_func", &init_func_)); - OP_REQUIRES_OK(ctx, ctx->GetAttr("next_func", &next_func_)); - OP_REQUIRES_OK(ctx, ctx->GetAttr("finalize_func", &finalize_func_)); - OP_REQUIRES_OK(ctx, ctx->GetAttr("output_types", &output_types_)); - OP_REQUIRES_OK(ctx, ctx->GetAttr("output_shapes", &output_shapes_)); + Dataset(OpKernelContext* ctx, std::unique_ptr init_func, + std::unique_ptr next_func, + std::unique_ptr finalize_func, + const DataTypeVector& output_types, + const std::vector& output_shapes) + : GraphDatasetBase(ctx), + init_func_(std::move(init_func)), + next_func_(std::move(next_func)), + finalize_func_(std::move(finalize_func)), + output_types_(output_types), + output_shapes_(output_shapes) {} + + std::unique_ptr MakeIteratorInternal( + const string& prefix) const override { + return std::unique_ptr( + new Iterator({this, strings::StrCat(prefix, "::Generator")})); } - void MakeDataset(OpKernelContext* ctx, DatasetBase** output) override { - OpInputList init_func_other_args_input; - OP_REQUIRES_OK(ctx, ctx->input_list("init_func_other_args", - &init_func_other_args_input)); - std::vector init_func_other_args; - init_func_other_args.reserve(init_func_other_args_input.size()); - for (const Tensor& t : init_func_other_args_input) { - init_func_other_args.push_back(t); - } - std::unique_ptr init_func; - OP_REQUIRES_OK( - ctx, CapturedFunction::Create( - init_func_, std::move(init_func_other_args), &init_func)); - - OpInputList next_func_other_args_input; - OP_REQUIRES_OK(ctx, ctx->input_list("next_func_other_args", - &next_func_other_args_input)); - std::vector next_func_other_args; - next_func_other_args.reserve(next_func_other_args_input.size()); - for (const Tensor& t : next_func_other_args_input) { - next_func_other_args.push_back(t); - } - std::unique_ptr next_func; - OP_REQUIRES_OK( - ctx, CapturedFunction::Create( - next_func_, std::move(next_func_other_args), &next_func)); - - OpInputList finalize_func_other_args_input; - OP_REQUIRES_OK(ctx, ctx->input_list("finalize_func_other_args", - &finalize_func_other_args_input)); - std::vector finalize_func_other_args; - finalize_func_other_args.reserve(finalize_func_other_args_input.size()); - for (const Tensor& t : finalize_func_other_args_input) { - finalize_func_other_args.push_back(t); - } - std::unique_ptr finalize_func; - OP_REQUIRES_OK(ctx, CapturedFunction::Create( - finalize_func_, std::move(finalize_func_other_args), - &finalize_func)); - - *output = - new Dataset(ctx, std::move(init_func), std::move(next_func), - std::move(finalize_func), output_types_, output_shapes_); + const DataTypeVector& output_dtypes() const override { return output_types_; } + const std::vector& output_shapes() const override { + return output_shapes_; } + string DebugString() const override { return "GeneratorDatasetOp::Dataset"; } + private: - class Dataset : public GraphDatasetBase { + class Iterator : public DatasetIterator { public: - Dataset(OpKernelContext* ctx, std::unique_ptr init_func, - std::unique_ptr next_func, - std::unique_ptr finalize_func, - const DataTypeVector& output_types, - const std::vector& output_shapes) - : GraphDatasetBase(ctx), - init_func_(std::move(init_func)), - next_func_(std::move(next_func)), - finalize_func_(std::move(finalize_func)), - output_types_(output_types), - output_shapes_(output_shapes) {} - - std::unique_ptr MakeIteratorInternal( - const string& prefix) const override { - return std::unique_ptr( - new Iterator({this, strings::StrCat(prefix, "::Generator")})); - } - - const DataTypeVector& output_dtypes() const override { - return output_types_; - } - const std::vector& output_shapes() const override { - return output_shapes_; - } - - string DebugString() const override { - return "GeneratorDatasetOp::Dataset"; - } - - private: - class Iterator : public DatasetIterator { - public: - explicit Iterator(const Params& params) - : DatasetIterator(params) {} - - ~Iterator() override { - if (!finalized_) { - std::vector ignored; - Status s = - dataset()->finalize_func_->RunInstantiated(state_, &ignored); - if (!s.ok()) { - LOG(WARNING) - << "Error occurred when finalizing GeneratorDataset iterator: " - << s; - } + explicit Iterator(const Params& params) + : DatasetIterator(params) {} + + ~Iterator() override { + if (!finalized_) { + std::vector ignored; + Status s = dataset()->finalize_func_->RunInstantiated(state_, &ignored); + if (!s.ok()) { + LOG(WARNING) + << "Error occurred when finalizing GeneratorDataset iterator: " + << s; } } + } - Status GetNextInternal(IteratorContext* ctx, - std::vector* out_tensors, - bool* end_of_sequence) override { - mutex_lock l(mu_); - - if (!initialized_) { - TF_RETURN_IF_ERROR( - dataset()->init_func_->RunWithBorrowedArgs(ctx, {}, &state_)); - // Explicitly instantiate the finalize function here so that - // we can invoke it in the destructor. - TF_RETURN_IF_ERROR(dataset()->finalize_func_->Instantiate(ctx)); - initialized_ = true; - } + Status GetNextInternal(IteratorContext* ctx, + std::vector* out_tensors, + bool* end_of_sequence) override { + mutex_lock l(mu_); + + if (!initialized_) { + TF_RETURN_IF_ERROR( + dataset()->init_func_->RunWithBorrowedArgs(ctx, {}, &state_)); + // Explicitly instantiate the finalize function here so that + // we can invoke it in the destructor. + TF_RETURN_IF_ERROR(dataset()->finalize_func_->Instantiate(ctx)); + initialized_ = true; + } - if (finalized_) { - *end_of_sequence = true; - return Status::OK(); - } + if (finalized_) { + *end_of_sequence = true; + return Status::OK(); + } - Status s = dataset()->next_func_->RunWithBorrowedArgs(ctx, state_, - out_tensors); - if (s.ok()) { - *end_of_sequence = false; - } else if (errors::IsOutOfRange(s)) { - // `next_func` may deliberately raise `errors::OutOfRange` - // to indicate that we should terminate the iteration. - s = Status::OK(); - *end_of_sequence = true; - - // NOTE(mrry): We ignore any tensors returned by the - // finalize function. - std::vector ignored; - TF_RETURN_IF_ERROR( - dataset()->finalize_func_->RunInstantiated(state_, &ignored)); - finalized_ = true; - } - return s; + Status s = + dataset()->next_func_->RunWithBorrowedArgs(ctx, state_, out_tensors); + if (s.ok()) { + *end_of_sequence = false; + } else if (errors::IsOutOfRange(s)) { + // `next_func` may deliberately raise `errors::OutOfRange` + // to indicate that we should terminate the iteration. + s = Status::OK(); + *end_of_sequence = true; + + // NOTE(mrry): We ignore any tensors returned by the + // finalize function. + std::vector ignored; + TF_RETURN_IF_ERROR( + dataset()->finalize_func_->RunInstantiated(state_, &ignored)); + finalized_ = true; } + return s; + } - private: - mutex mu_; - bool initialized_ GUARDED_BY(mu_) = false; - bool finalized_ GUARDED_BY(mu_) = false; - std::vector state_ GUARDED_BY(mu_); - }; - - const std::unique_ptr init_func_; - const std::unique_ptr next_func_; - const std::unique_ptr finalize_func_; - const DataTypeVector output_types_; - const std::vector output_shapes_; + private: + mutex mu_; + bool initialized_ GUARDED_BY(mu_) = false; + bool finalized_ GUARDED_BY(mu_) = false; + std::vector state_ GUARDED_BY(mu_); }; - DataTypeVector output_types_; - std::vector output_shapes_; - NameAttrList init_func_; - NameAttrList next_func_; - NameAttrList finalize_func_; + const std::unique_ptr init_func_; + const std::unique_ptr next_func_; + const std::unique_ptr finalize_func_; + const DataTypeVector output_types_; + const std::vector output_shapes_; }; +GeneratorDatasetOp::GeneratorDatasetOp(OpKernelConstruction* ctx) + : DatasetOpKernel(ctx) { + OP_REQUIRES_OK(ctx, ctx->GetAttr("init_func", &init_func_)); + OP_REQUIRES_OK(ctx, ctx->GetAttr("next_func", &next_func_)); + OP_REQUIRES_OK(ctx, ctx->GetAttr("finalize_func", &finalize_func_)); + OP_REQUIRES_OK(ctx, ctx->GetAttr("output_types", &output_types_)); + OP_REQUIRES_OK(ctx, ctx->GetAttr("output_shapes", &output_shapes_)); +} + +void GeneratorDatasetOp::MakeDataset(OpKernelContext* ctx, + DatasetBase** output) { + OpInputList init_func_other_args_input; + OP_REQUIRES_OK(ctx, ctx->input_list("init_func_other_args", + &init_func_other_args_input)); + std::vector init_func_other_args; + init_func_other_args.reserve(init_func_other_args_input.size()); + for (const Tensor& t : init_func_other_args_input) { + init_func_other_args.push_back(t); + } + std::unique_ptr init_func; + OP_REQUIRES_OK( + ctx, CapturedFunction::Create(init_func_, std::move(init_func_other_args), + &init_func)); + + OpInputList next_func_other_args_input; + OP_REQUIRES_OK(ctx, ctx->input_list("next_func_other_args", + &next_func_other_args_input)); + std::vector next_func_other_args; + next_func_other_args.reserve(next_func_other_args_input.size()); + for (const Tensor& t : next_func_other_args_input) { + next_func_other_args.push_back(t); + } + std::unique_ptr next_func; + OP_REQUIRES_OK( + ctx, CapturedFunction::Create(next_func_, std::move(next_func_other_args), + &next_func)); + + OpInputList finalize_func_other_args_input; + OP_REQUIRES_OK(ctx, ctx->input_list("finalize_func_other_args", + &finalize_func_other_args_input)); + std::vector finalize_func_other_args; + finalize_func_other_args.reserve(finalize_func_other_args_input.size()); + for (const Tensor& t : finalize_func_other_args_input) { + finalize_func_other_args.push_back(t); + } + std::unique_ptr finalize_func; + OP_REQUIRES_OK(ctx, CapturedFunction::Create( + finalize_func_, std::move(finalize_func_other_args), + &finalize_func)); + + *output = + new Dataset(ctx, std::move(init_func), std::move(next_func), + std::move(finalize_func), output_types_, output_shapes_); +} + REGISTER_KERNEL_BUILDER(Name("GeneratorDataset").Device(DEVICE_CPU), GeneratorDatasetOp); REGISTER_KERNEL_BUILDER( Name("GeneratorDataset").Device(DEVICE_GPU).HostMemory("handle"), GeneratorDatasetOp); -} // namespace - } // namespace tensorflow diff --git a/tensorflow/core/kernels/data/generator_dataset_op.h b/tensorflow/core/kernels/data/generator_dataset_op.h new file mode 100644 index 0000000000..3f84fa9c2e --- /dev/null +++ b/tensorflow/core/kernels/data/generator_dataset_op.h @@ -0,0 +1,41 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_CORE_KERNELS_DATA_GENERATOR_DATASET_OP_H_ +#define TENSORFLOW_CORE_KERNELS_DATA_GENERATOR_DATASET_OP_H_ + +#include "tensorflow/core/framework/dataset.h" +#include "tensorflow/core/kernels/data/captured_function.h" + +namespace tensorflow { + +class GeneratorDatasetOp : public DatasetOpKernel { + public: + explicit GeneratorDatasetOp(OpKernelConstruction* ctx); + + void MakeDataset(OpKernelContext* ctx, DatasetBase** output) override; + + private: + class Dataset; + + DataTypeVector output_types_; + std::vector output_shapes_; + NameAttrList init_func_; + NameAttrList next_func_; + NameAttrList finalize_func_; +}; + +} // namespace tensorflow +#endif // TENSORFLOW_CORE_KERNELS_DATA_GENERATOR_DATASET_OP_H_ diff --git a/tensorflow/core/kernels/data/iterator_ops.cc b/tensorflow/core/kernels/data/iterator_ops.cc index 86adbc4f47..e2df14337c 100644 --- a/tensorflow/core/kernels/data/iterator_ops.cc +++ b/tensorflow/core/kernels/data/iterator_ops.cc @@ -12,7 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -#include "tensorflow/core/common_runtime/function.h" +#include "tensorflow/core/kernels/data/iterator_ops.h" + #include "tensorflow/core/common_runtime/graph_runner.h" #include "tensorflow/core/common_runtime/renamed_device.h" #include "tensorflow/core/common_runtime/threadpool_device.h" @@ -23,7 +24,6 @@ limitations under the License. #include "tensorflow/core/framework/tensor.h" #include "tensorflow/core/framework/variant_op_registry.h" #include "tensorflow/core/graph/graph_constructor.h" -#include "tensorflow/core/kernels/data/dataset.h" #include "tensorflow/core/kernels/data/dataset_utils.h" #include "tensorflow/core/kernels/data/optional_ops.h" #include "tensorflow/core/kernels/ops_util.h" @@ -81,6 +81,8 @@ Status VerifyShapesCompatible(const std::vector& expected, return Status::OK(); } +} // namespace + class IteratorResource : public ResourceBase { public: IteratorResource(const DataTypeVector& output_dtypes, @@ -438,300 +440,179 @@ REGISTER_UNARY_VARIANT_DECODE_FUNCTION(IteratorStateVariant, // Note that IteratorHandleOp holds a reference to the resource it creates. If // cleaning up resources with DestroyResourceOp is important, consider creating // resource containers with AnonymousIteratorHandleOp instead. -class IteratorHandleOp : public OpKernel { - public: - explicit IteratorHandleOp(OpKernelConstruction* ctx) - : OpKernel(ctx), graph_def_version_(ctx->graph_def_version()) { - OP_REQUIRES_OK(ctx, ctx->GetAttr("output_types", &output_dtypes_)); - OP_REQUIRES_OK(ctx, ctx->GetAttr("output_shapes", &output_shapes_)); - OP_REQUIRES_OK(ctx, ctx->GetAttr("shared_name", &name_)); - } +IteratorHandleOp::IteratorHandleOp(OpKernelConstruction* ctx) + : OpKernel(ctx), graph_def_version_(ctx->graph_def_version()) { + OP_REQUIRES_OK(ctx, ctx->GetAttr("output_types", &output_dtypes_)); + OP_REQUIRES_OK(ctx, ctx->GetAttr("output_shapes", &output_shapes_)); + OP_REQUIRES_OK(ctx, ctx->GetAttr("shared_name", &name_)); +} - // The resource is deleted from the resource manager only when it is private - // to kernel. Ideally the resource should be deleted when it is no longer held - // by anyone, but it would break backward compatibility. - ~IteratorHandleOp() override { - if (resource_ != nullptr) { - resource_->Unref(); - if (cinfo_.resource_is_private_to_kernel()) { - if (!cinfo_.resource_manager() - ->template Delete(cinfo_.container(), - cinfo_.name()) - .ok()) { - // Do nothing; the resource can have been deleted by session resets. - } +// The resource is deleted from the resource manager only when it is private +// to kernel. Ideally the resource should be deleted when it is no longer held +// by anyone, but it would break backward compatibility. +IteratorHandleOp::~IteratorHandleOp() { + if (resource_ != nullptr) { + resource_->Unref(); + if (cinfo_.resource_is_private_to_kernel()) { + if (!cinfo_.resource_manager() + ->template Delete(cinfo_.container(), + cinfo_.name()) + .ok()) { + // Do nothing; the resource can have been deleted by session resets. } } } +} - void Compute(OpKernelContext* context) override LOCKS_EXCLUDED(mu_) { - { - mutex_lock l(mu_); - if (resource_ == nullptr) { - FunctionLibraryRuntime* lib; - std::unique_ptr device_mgr(nullptr); - std::unique_ptr flib_def(nullptr); - std::unique_ptr pflr(nullptr); - // If the iterator is shared then we construct a new FLR, and pass that - // in. NOTE(mrry,rohanj): In this case it is not possible to call remote - // functions from the iterator. We may add this functionality if there - // is sufficient demand, but it will require a significant refactoring. - if (!name_.empty()) { - lib = CreatePrivateFLR(context, &device_mgr, &flib_def, &pflr); - } else { - OP_REQUIRES_OK(context, context->function_library()->Clone( - &flib_def, &pflr, &lib)); - } - - ResourceMgr* mgr = context->resource_manager(); - OP_REQUIRES_OK(context, cinfo_.Init(mgr, def())); - - IteratorResource* resource; - OP_REQUIRES_OK( - context, - mgr->LookupOrCreate( - cinfo_.container(), cinfo_.name(), &resource, - [lib, &device_mgr, &flib_def, &pflr, - this](IteratorResource** ret) EXCLUSIVE_LOCKS_REQUIRED(mu_) { - *ret = new IteratorResource( - output_dtypes_, output_shapes_, graph_def_version_, - std::move(device_mgr), std::move(flib_def), - std::move(pflr), lib); - return Status::OK(); - })); +void IteratorHandleOp::Compute(OpKernelContext* context) LOCKS_EXCLUDED(mu_) { + { + mutex_lock l(mu_); + if (resource_ == nullptr) { + FunctionLibraryRuntime* lib; + std::unique_ptr device_mgr(nullptr); + std::unique_ptr flib_def(nullptr); + std::unique_ptr pflr(nullptr); + // If the iterator is shared then we construct a new FLR, and pass that + // in. NOTE(mrry,rohanj): In this case it is not possible to call remote + // functions from the iterator. We may add this functionality if there + // is sufficient demand, but it will require a significant refactoring. + if (!name_.empty()) { + lib = CreatePrivateFLR(context, &device_mgr, &flib_def, &pflr); + } else { + OP_REQUIRES_OK(context, context->function_library()->Clone( + &flib_def, &pflr, &lib)); + } - Status s = VerifyResource(resource); - if (TF_PREDICT_FALSE(!s.ok())) { - resource->Unref(); - context->SetStatus(s); - return; - } + ResourceMgr* mgr = context->resource_manager(); + OP_REQUIRES_OK(context, cinfo_.Init(mgr, def())); - resource_ = resource; + IteratorResource* resource; + OP_REQUIRES_OK( + context, + mgr->LookupOrCreate( + cinfo_.container(), cinfo_.name(), &resource, + [lib, &device_mgr, &flib_def, &pflr, this](IteratorResource** ret) + EXCLUSIVE_LOCKS_REQUIRED(mu_) { + *ret = new IteratorResource( + output_dtypes_, output_shapes_, graph_def_version_, + std::move(device_mgr), std::move(flib_def), + std::move(pflr), lib); + return Status::OK(); + })); + + Status s = VerifyResource(resource); + if (TF_PREDICT_FALSE(!s.ok())) { + resource->Unref(); + context->SetStatus(s); + return; } - } - OP_REQUIRES_OK(context, MakeResourceHandleToOutput( - context, 0, cinfo_.container(), cinfo_.name(), - MakeTypeIndex())); - } - - private: - // During the first Compute(), resource is either created or looked up using - // shared_name. In the latter case, the resource found should be verified if - // it is compatible with this op's configuration. The verification may fail in - // cases such as two graphs asking queues of the same shared name to have - // inconsistent capacities. - Status VerifyResource(IteratorResource* resource) { - TF_RETURN_IF_ERROR( - VerifyTypesMatch(output_dtypes_, resource->output_dtypes())); - TF_RETURN_IF_ERROR( - VerifyShapesCompatible(output_shapes_, resource->output_shapes())); - return Status::OK(); - } - template // use like this: down_cast(foo); - static inline To down_cast(From* f) { // so we only accept pointers - static_assert( - (std::is_base_of::type>::value), - "target type not derived from source type"); - - // We skip the assert and hence the dynamic_cast if RTTI is disabled. -#if !defined(__GNUC__) || defined(__GXX_RTTI) - // Uses RTTI in dbg and fastbuild. asserts are disabled in opt builds. - assert(f == nullptr || dynamic_cast(f) != nullptr); -#endif // !defined(__GNUC__) || defined(__GXX_RTTI) - return static_cast(f); + resource_ = resource; + } } + OP_REQUIRES_OK(context, MakeResourceHandleToOutput( + context, 0, cinfo_.container(), cinfo_.name(), + MakeTypeIndex())); +} - FunctionLibraryRuntime* CreatePrivateFLR( - OpKernelContext* ctx, std::unique_ptr* device_mgr, - std::unique_ptr* flib_def, - std::unique_ptr* pflr) { - // Wrap the existing device in order to see any captured resources - // in its resource manager. The existing device will outlive the - // IteratorResource, because we are storing the IteratorResource - // in that device's resource manager. - Device* wrapped_device = RenamedDevice::NewRenamedDevice( - ctx->device()->name(), down_cast(ctx->device()), - false /* owns_underlying */, false /* isolate_session_state */); - device_mgr->reset(new DeviceMgr({wrapped_device})); - flib_def->reset(new FunctionLibraryDefinition( - *ctx->function_library()->GetFunctionLibraryDefinition())); - pflr->reset(new ProcessFunctionLibraryRuntime( - device_mgr->get(), ctx->env(), graph_def_version_, flib_def->get(), - {} /* TODO(mrry): OptimizerOptions? */, - nullptr /* TODO(mrry): ClusterFLR */)); - - return (*pflr)->GetFLR(ctx->device()->name()); - } +Status IteratorHandleOp::VerifyResource(IteratorResource* resource) { + TF_RETURN_IF_ERROR( + VerifyTypesMatch(output_dtypes_, resource->output_dtypes())); + TF_RETURN_IF_ERROR( + VerifyShapesCompatible(output_shapes_, resource->output_shapes())); + return Status::OK(); +} - mutex mu_; - ContainerInfo cinfo_; // Written once under mu_ then constant afterwards. - IteratorResource* resource_ GUARDED_BY(mu_) = nullptr; - DataTypeVector output_dtypes_; - std::vector output_shapes_; - const int graph_def_version_; - string name_; -}; +FunctionLibraryRuntime* IteratorHandleOp::CreatePrivateFLR( + OpKernelContext* ctx, std::unique_ptr* device_mgr, + std::unique_ptr* flib_def, + std::unique_ptr* pflr) { + // Wrap the existing device in order to see any captured resources + // in its resource manager. The existing device will outlive the + // IteratorResource, because we are storing the IteratorResource + // in that device's resource manager. + Device* wrapped_device = RenamedDevice::NewRenamedDevice( + ctx->device()->name(), down_cast(ctx->device()), + false /* owns_underlying */, false /* isolate_session_state */); + device_mgr->reset(new DeviceMgr({wrapped_device})); + flib_def->reset(new FunctionLibraryDefinition( + *ctx->function_library()->GetFunctionLibraryDefinition())); + pflr->reset(new ProcessFunctionLibraryRuntime( + device_mgr->get(), ctx->env(), graph_def_version_, flib_def->get(), + {} /* TODO(mrry): OptimizerOptions? */, + nullptr /* TODO(mrry): ClusterFLR */)); + + return (*pflr)->GetFLR(ctx->device()->name()); +} // Like IteratorHandleOp, but creates handles which are never shared, and does // not hold a reference to these handles. The latter is important for eager // execution, since OpKernel instances generally live as long as the program // running them. -class AnonymousIteratorHandleOp : public OpKernel { - public: - explicit AnonymousIteratorHandleOp(OpKernelConstruction* context) - : OpKernel(context), graph_def_version_(context->graph_def_version()) { - OP_REQUIRES_OK(context, context->GetAttr("output_types", &output_dtypes_)); - OP_REQUIRES_OK(context, context->GetAttr("output_shapes", &output_shapes_)); - } +AnonymousIteratorHandleOp::AnonymousIteratorHandleOp( + OpKernelConstruction* context) + : OpKernel(context), graph_def_version_(context->graph_def_version()) { + OP_REQUIRES_OK(context, context->GetAttr("output_types", &output_dtypes_)); + OP_REQUIRES_OK(context, context->GetAttr("output_shapes", &output_shapes_)); +} - void Compute(OpKernelContext* context) override { - FunctionLibraryRuntime* lib; - std::unique_ptr device_mgr(nullptr); - std::unique_ptr flib_def(nullptr); - std::unique_ptr pflr(nullptr); - OP_REQUIRES_OK(context, - context->function_library()->Clone(&flib_def, &pflr, &lib)); +void AnonymousIteratorHandleOp::Compute(OpKernelContext* context) { + FunctionLibraryRuntime* lib; + std::unique_ptr device_mgr(nullptr); + std::unique_ptr flib_def(nullptr); + std::unique_ptr pflr(nullptr); + OP_REQUIRES_OK(context, + context->function_library()->Clone(&flib_def, &pflr, &lib)); - ResourceMgr* mgr = context->resource_manager(); + ResourceMgr* mgr = context->resource_manager(); - const string container_name = "AnonymousIterator"; - string unique_name; - { - mutex_lock l(static_resource_lookup_mutex_); - while (true) { // Find an unused name - IteratorResource* existing_resource = nullptr; - unique_name = strings::StrCat("AnonymousIterator", current_id_++); - Status status = mgr->Lookup( - container_name, unique_name, &existing_resource); - if (status.code() == error::NOT_FOUND) { - break; - } - OP_REQUIRES_OK(context, status); - existing_resource->Unref(); + const string container_name = "AnonymousIterator"; + string unique_name; + { + mutex_lock l(static_resource_lookup_mutex_); + while (true) { // Find an unused name + IteratorResource* existing_resource = nullptr; + unique_name = strings::StrCat("AnonymousIterator", current_id_++); + Status status = mgr->Lookup(container_name, unique_name, + &existing_resource); + if (status.code() == error::NOT_FOUND) { + break; } - IteratorResource* new_resource = new IteratorResource( - output_dtypes_, output_shapes_, graph_def_version_, - std::move(device_mgr), std::move(flib_def), std::move(pflr), lib); - // Create the resource with our chosen name under the resource lookup - // mutex to avoid another kernel racily creating a resource with this - // name. - OP_REQUIRES_OK(context, mgr->Create( - container_name, unique_name, new_resource)); + OP_REQUIRES_OK(context, status); + existing_resource->Unref(); } - OP_REQUIRES_OK(context, MakeResourceHandleToOutput( - context, 0, container_name, unique_name, - MakeTypeIndex())); + IteratorResource* new_resource = new IteratorResource( + output_dtypes_, output_shapes_, graph_def_version_, + std::move(device_mgr), std::move(flib_def), std::move(pflr), lib); + // Create the resource with our chosen name under the resource lookup + // mutex to avoid another kernel racily creating a resource with this + // name. + OP_REQUIRES_OK(context, mgr->Create( + container_name, unique_name, new_resource)); } - - private: - // Coordinates Iterator unique name creation across AnonymousIteratorHandleOp - // instances. - static mutex static_resource_lookup_mutex_; - // current_id_ is just a hint for creating unique names. If it turns out - // there's a collision (e.g. because another AnonymousIteratorHandleOp - // instance is generating handles) we'll just skip that id. - static int64 current_id_ GUARDED_BY(static_resource_lookup_mutex_); - DataTypeVector output_dtypes_; - std::vector output_shapes_; - const int graph_def_version_; -}; + OP_REQUIRES_OK(context, MakeResourceHandleToOutput( + context, 0, container_name, unique_name, + MakeTypeIndex())); +} // Static initializers for AnonymousIteratorHandleOp id counting. mutex AnonymousIteratorHandleOp::static_resource_lookup_mutex_{ LINKER_INITIALIZED}; int64 AnonymousIteratorHandleOp::current_id_(0); -class MakeIteratorOp : public OpKernel { - public: - explicit MakeIteratorOp(OpKernelConstruction* ctx) : OpKernel(ctx) {} - - void Compute(OpKernelContext* ctx) override { - DatasetBase* dataset; - OP_REQUIRES_OK(ctx, GetDatasetFromVariantTensor(ctx->input(0), &dataset)); - IteratorResource* iterator_resource; - OP_REQUIRES_OK( - ctx, LookupResource(ctx, HandleFromInput(ctx, 1), &iterator_resource)); - core::ScopedUnref unref(iterator_resource); - - IteratorContext iter_ctx = dataset::MakeIteratorContext(ctx); - std::unique_ptr iterator; - OP_REQUIRES_OK(ctx, - dataset->MakeIterator(&iter_ctx, "Iterator", &iterator)); - OP_REQUIRES_OK(ctx, iterator_resource->set_iterator(std::move(iterator))); - } -}; - -// A simple background worker that executes closures asynchronously and without -// blocking. -// -// A `BackgroundWorker` is used to offload blocking work from an `AsyncOpKernel` -// to avoid blocking an executor thread that may be required by the blocking -// work. -// -// NOTE(mrry): We do not use a regular `tensorflow::thread::ThreadPool` for this -// purpose because its current implementation (in Eigen) uses a finite-length -// queue and will block the caller when full. This can lead to deadlock under -// heavy load. Since the number of concurrent work items in each user of a -// `BackgroundWorker` is at most one per op invocation, the dynamic allocation -// overhead is tolerable. -class BackgroundWorker { - public: - BackgroundWorker(Env* env, const string& name) { - thread_.reset(env->StartThread({} /* thread_options */, name, - [this]() { WorkerLoop(); })); - } - - ~BackgroundWorker() { - { - mutex_lock l(mu_); - cancelled_ = true; - } - cond_var_.notify_one(); - // Block until the background thread has terminated. - // - // NOTE(mrry): We explicitly free and join the thread here because - // `WorkerLoop()` uses other members of this object, and so we must join - // the thread before destroying them. - thread_.reset(); - } - - void Schedule(std::function work_item) { - { - mutex_lock l(mu_); - work_queue_.push_back(std::move(work_item)); - } - cond_var_.notify_one(); - } - - private: - void WorkerLoop() { - while (true) { - std::function work_item = nullptr; - { - mutex_lock l(mu_); - while (!cancelled_ && work_queue_.empty()) { - cond_var_.wait(l); - } - if (cancelled_) { - return; - } - DCHECK(!work_queue_.empty()); - work_item = std::move(work_queue_.front()); - work_queue_.pop_front(); - } - DCHECK(work_item != nullptr); - work_item(); - } - } - - std::unique_ptr thread_; - mutex mu_; - condition_variable cond_var_; - bool cancelled_ GUARDED_BY(mu_) = false; - std::deque> work_queue_ GUARDED_BY(mu_); -}; +void MakeIteratorOp::Compute(OpKernelContext* ctx) { + DatasetBase* dataset; + OP_REQUIRES_OK(ctx, GetDatasetFromVariantTensor(ctx->input(0), &dataset)); + IteratorResource* iterator_resource; + OP_REQUIRES_OK( + ctx, LookupResource(ctx, HandleFromInput(ctx, 1), &iterator_resource)); + core::ScopedUnref unref(iterator_resource); + + IteratorContext iter_ctx = dataset::MakeIteratorContext(ctx); + std::unique_ptr iterator; + OP_REQUIRES_OK(ctx, dataset->MakeIterator(&iter_ctx, "Iterator", &iterator)); + OP_REQUIRES_OK(ctx, iterator_resource->set_iterator(std::move(iterator))); +} class ToSingleElementOp : public AsyncOpKernel { public: @@ -996,60 +877,47 @@ class OneShotIteratorOp : public AsyncOpKernel { const int graph_def_version_; }; -class IteratorGetNextOp : public AsyncOpKernel { - public: - explicit IteratorGetNextOp(OpKernelConstruction* ctx) - : AsyncOpKernel(ctx), - background_worker_(ctx->env(), - strings::StrCat("iterator_get_next_thread_", - SanitizeThreadSuffix(name()))) {} - - void ComputeAsync(OpKernelContext* ctx, DoneCallback done) override { - IteratorResource* iterator; - OP_REQUIRES_OK_ASYNC( - ctx, LookupResource(ctx, HandleFromInput(ctx, 0), &iterator), done); - // The call to `iterator->GetNext()` may block and depend on an - // inter-op thread pool thread, so we issue the call from the - // owned thread pool. - background_worker_.Schedule(std::bind( - [ctx, iterator](DoneCallback done) { - std::vector components; - bool end_of_sequence = false; - - IteratorContext::Params params; - params.env = ctx->env(); - params.runner = *(ctx->runner()); - params.function_library = iterator->function_library(); - DeviceBase* device = ctx->function_library()->device(); - params.allocator_getter = [device](AllocatorAttributes attrs) { - return device->GetAllocator(attrs); - }; - IteratorContext iter_ctx(std::move(params)); - - Status s = - iterator->GetNext(&iter_ctx, &components, &end_of_sequence); - // NOTE(mrry): We must unref the iterator before calling `done()`, to - // avoid destruction races. - iterator->Unref(); - - if (!s.ok()) { - ctx->SetStatus(s); - } else if (end_of_sequence) { - ctx->SetStatus(errors::OutOfRange("End of sequence")); - } else { - for (int i = 0; i < components.size(); ++i) { - // TODO(mrry): Check that the shapes match the shape attrs. - ctx->set_output(i, components[i]); - } +void IteratorGetNextOp::ComputeAsync(OpKernelContext* ctx, DoneCallback done) { + IteratorResource* iterator; + OP_REQUIRES_OK_ASYNC( + ctx, LookupResource(ctx, HandleFromInput(ctx, 0), &iterator), done); + // The call to `iterator->GetNext()` may block and depend on an + // inter-op thread pool thread, so we issue the call from the + // owned thread pool. + background_worker_.Schedule(std::bind( + [ctx, iterator](DoneCallback done) { + std::vector components; + bool end_of_sequence = false; + + IteratorContext::Params params; + params.env = ctx->env(); + params.runner = *(ctx->runner()); + params.function_library = iterator->function_library(); + DeviceBase* device = ctx->function_library()->device(); + params.allocator_getter = [device](AllocatorAttributes attrs) { + return device->GetAllocator(attrs); + }; + IteratorContext iter_ctx(std::move(params)); + + Status s = iterator->GetNext(&iter_ctx, &components, &end_of_sequence); + // NOTE(mrry): We must unref the iterator before calling `done()`, to + // avoid destruction races. + iterator->Unref(); + + if (!s.ok()) { + ctx->SetStatus(s); + } else if (end_of_sequence) { + ctx->SetStatus(errors::OutOfRange("End of sequence")); + } else { + for (int i = 0; i < components.size(); ++i) { + // TODO(mrry): Check that the shapes match the shape attrs. + ctx->set_output(i, components[i]); } - done(); - }, - std::move(done))); - } - - private: - BackgroundWorker background_worker_; -}; + } + done(); + }, + std::move(done))); +} class IteratorGetNextSyncOp : public OpKernel { public: @@ -1165,90 +1033,76 @@ class IteratorGetNextAsOptionalOp : public AsyncOpKernel { std::vector output_shapes_; }; -class IteratorToStringHandleOp : public OpKernel { - public: - explicit IteratorToStringHandleOp(OpKernelConstruction* ctx) - : OpKernel(ctx) {} - - void Compute(OpKernelContext* ctx) override { - const Tensor& resource_handle_t = ctx->input(0); - OP_REQUIRES(ctx, TensorShapeUtils::IsScalar(resource_handle_t.shape()), - errors::InvalidArgument("resource_handle must be a scalar")); - - // Validate that the handle corresponds to a real resource, and - // that it is an IteratorResource. - IteratorResource* iterator_resource; - OP_REQUIRES_OK( - ctx, LookupResource(ctx, HandleFromInput(ctx, 0), &iterator_resource)); - iterator_resource->Unref(); +void IteratorToStringHandleOp::Compute(OpKernelContext* ctx) { + const Tensor& resource_handle_t = ctx->input(0); + OP_REQUIRES(ctx, TensorShapeUtils::IsScalar(resource_handle_t.shape()), + errors::InvalidArgument("resource_handle must be a scalar")); + + // Validate that the handle corresponds to a real resource, and + // that it is an IteratorResource. + IteratorResource* iterator_resource; + OP_REQUIRES_OK( + ctx, LookupResource(ctx, HandleFromInput(ctx, 0), &iterator_resource)); + iterator_resource->Unref(); + + Tensor* string_handle_t; + OP_REQUIRES_OK(ctx, + ctx->allocate_output(0, TensorShape({}), &string_handle_t)); + string_handle_t->scalar()() = + resource_handle_t.scalar()().SerializeAsString(); +} - Tensor* string_handle_t; - OP_REQUIRES_OK(ctx, - ctx->allocate_output(0, TensorShape({}), &string_handle_t)); - string_handle_t->scalar()() = - resource_handle_t.scalar()().SerializeAsString(); - } -}; +IteratorFromStringHandleOp::IteratorFromStringHandleOp( + OpKernelConstruction* ctx) + : OpKernel(ctx) { + OP_REQUIRES_OK(ctx, ctx->GetAttr("output_types", &output_dtypes_)); + OP_REQUIRES_OK(ctx, ctx->GetAttr("output_shapes", &output_shapes_)); + OP_REQUIRES( + ctx, + output_dtypes_.empty() || output_shapes_.empty() || + output_dtypes_.size() == output_shapes_.size(), + errors::InvalidArgument("If both 'output_types' and 'output_shapes' " + "are set, they must have the same length.")); +} -class IteratorFromStringHandleOp : public OpKernel { - public: - explicit IteratorFromStringHandleOp(OpKernelConstruction* ctx) - : OpKernel(ctx) { - OP_REQUIRES_OK(ctx, ctx->GetAttr("output_types", &output_dtypes_)); - OP_REQUIRES_OK(ctx, ctx->GetAttr("output_shapes", &output_shapes_)); - OP_REQUIRES( - ctx, - output_dtypes_.empty() || output_shapes_.empty() || - output_dtypes_.size() == output_shapes_.size(), - errors::InvalidArgument("If both 'output_types' and 'output_shapes' " - "are set, they must have the same length.")); +void IteratorFromStringHandleOp::Compute(OpKernelContext* ctx) { + const Tensor& string_handle_t = ctx->input(0); + OP_REQUIRES(ctx, TensorShapeUtils::IsScalar(string_handle_t.shape()), + errors::InvalidArgument("string_handle must be a scalar")); + + ResourceHandle resource_handle; + OP_REQUIRES( + ctx, resource_handle.ParseFromString(string_handle_t.scalar()()), + errors::InvalidArgument( + "Could not parse string_handle as a valid ResourceHandle")); + + OP_REQUIRES( + ctx, resource_handle.device() == ctx->device()->attributes().name(), + errors::InvalidArgument("Attempted create an iterator on device \"", + ctx->device()->attributes().name(), + "\" from handle defined on device \"", + resource_handle.device(), "\"")); + + // Validate that the handle corresponds to a real resource, and + // that it is an IteratorResource. + IteratorResource* iterator_resource; + OP_REQUIRES_OK(ctx, LookupResource(ctx, resource_handle, &iterator_resource)); + core::ScopedUnref unref_iterator(iterator_resource); + if (!output_dtypes_.empty()) { + OP_REQUIRES_OK(ctx, VerifyTypesMatch(output_dtypes_, + iterator_resource->output_dtypes())); } - - void Compute(OpKernelContext* ctx) override { - const Tensor& string_handle_t = ctx->input(0); - OP_REQUIRES(ctx, TensorShapeUtils::IsScalar(string_handle_t.shape()), - errors::InvalidArgument("string_handle must be a scalar")); - - ResourceHandle resource_handle; - OP_REQUIRES( - ctx, - resource_handle.ParseFromString(string_handle_t.scalar()()), - errors::InvalidArgument( - "Could not parse string_handle as a valid ResourceHandle")); - - OP_REQUIRES( - ctx, resource_handle.device() == ctx->device()->attributes().name(), - errors::InvalidArgument("Attempted create an iterator on device \"", - ctx->device()->attributes().name(), - "\" from handle defined on device \"", - resource_handle.device(), "\"")); - - // Validate that the handle corresponds to a real resource, and - // that it is an IteratorResource. - IteratorResource* iterator_resource; + if (!output_shapes_.empty()) { OP_REQUIRES_OK(ctx, - LookupResource(ctx, resource_handle, &iterator_resource)); - core::ScopedUnref unref_iterator(iterator_resource); - if (!output_dtypes_.empty()) { - OP_REQUIRES_OK(ctx, VerifyTypesMatch(output_dtypes_, - iterator_resource->output_dtypes())); - } - if (!output_shapes_.empty()) { - OP_REQUIRES_OK( - ctx, VerifyShapesCompatible(output_shapes_, - iterator_resource->output_shapes())); - } - - Tensor* resource_handle_t; - OP_REQUIRES_OK( - ctx, ctx->allocate_output(0, TensorShape({}), &resource_handle_t)); - resource_handle_t->scalar()() = resource_handle; + VerifyShapesCompatible(output_shapes_, + iterator_resource->output_shapes())); } - private: - DataTypeVector output_dtypes_; - std::vector output_shapes_; -}; + Tensor* resource_handle_t; + OP_REQUIRES_OK(ctx, + ctx->allocate_output(0, TensorShape({}), &resource_handle_t)); + resource_handle_t->scalar()() = resource_handle; +} class SerializeIteratorOp : public OpKernel { public: @@ -1344,6 +1198,4 @@ REGISTER_KERNEL_BUILDER(Name("SerializeIterator").Device(DEVICE_CPU), REGISTER_KERNEL_BUILDER(Name("DeserializeIterator").Device(DEVICE_CPU), DeserializeIteratorOp); -} // namespace - } // namespace tensorflow diff --git a/tensorflow/core/kernels/data/iterator_ops.h b/tensorflow/core/kernels/data/iterator_ops.h new file mode 100644 index 0000000000..e426febcce --- /dev/null +++ b/tensorflow/core/kernels/data/iterator_ops.h @@ -0,0 +1,140 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_CORE_KERNELS_DATA_ITERATOR_OPS_H_ +#define TENSORFLOW_CORE_KERNELS_DATA_ITERATOR_OPS_H_ + +#include "tensorflow/core/common_runtime/function.h" +#include "tensorflow/core/framework/dataset.h" +#include "tensorflow/core/framework/op_kernel.h" +#include "tensorflow/core/kernels/ops_util.h" + +namespace tensorflow { + +class IteratorResource; + +class IteratorHandleOp : public OpKernel { + public: + explicit IteratorHandleOp(OpKernelConstruction* ctx); + + // The resource is deleted from the resource manager only when it is private + // to kernel. Ideally the resource should be deleted when it is no longer held + // by anyone, but it would break backward compatibility. + ~IteratorHandleOp() override; + + void Compute(OpKernelContext* context) override LOCKS_EXCLUDED(mu_); + + private: + // During the first Compute(), resource is either created or looked up using + // shared_name. In the latter case, the resource found should be verified if + // it is compatible with this op's configuration. The verification may fail in + // cases such as two graphs asking queues of the same shared name to have + // inconsistent capacities. + Status VerifyResource(IteratorResource* resource); + + template // use like this: down_cast(foo); + static inline To down_cast(From* f) { // so we only accept pointers + static_assert( + (std::is_base_of::type>::value), + "target type not derived from source type"); + + // We skip the assert and hence the dynamic_cast if RTTI is disabled. +#if !defined(__GNUC__) || defined(__GXX_RTTI) + // Uses RTTI in dbg and fastbuild. asserts are disabled in opt builds. + assert(f == nullptr || dynamic_cast(f) != nullptr); +#endif // !defined(__GNUC__) || defined(__GXX_RTTI) + return static_cast(f); + } + + FunctionLibraryRuntime* CreatePrivateFLR( + OpKernelContext* ctx, std::unique_ptr* device_mgr, + std::unique_ptr* flib_def, + std::unique_ptr* pflr); + + mutex mu_; + ContainerInfo cinfo_; // Written once under mu_ then constant afterwards. + IteratorResource* resource_ GUARDED_BY(mu_) = nullptr; + DataTypeVector output_dtypes_; + std::vector output_shapes_; + const int graph_def_version_; + string name_; +}; + +// Like IteratorHandleOp, but creates handles which are never shared, and does +// not hold a reference to these handles. The latter is important for eager +// execution, since OpKernel instances generally live as long as the program +// running them. +class AnonymousIteratorHandleOp : public OpKernel { + public: + explicit AnonymousIteratorHandleOp(OpKernelConstruction* context); + + void Compute(OpKernelContext* context) override; + + private: + // Coordinates Iterator unique name creation across AnonymousIteratorHandleOp + // instances. + static mutex static_resource_lookup_mutex_; + // current_id_ is just a hint for creating unique names. If it turns out + // there's a collision (e.g. because another AnonymousIteratorHandleOp + // instance is generating handles) we'll just skip that id. + static int64 current_id_ GUARDED_BY(static_resource_lookup_mutex_); + DataTypeVector output_dtypes_; + std::vector output_shapes_; + const int graph_def_version_; +}; + +class MakeIteratorOp : public OpKernel { + public: + explicit MakeIteratorOp(OpKernelConstruction* ctx) : OpKernel(ctx) {} + + void Compute(OpKernelContext* ctx) override; +}; + +class IteratorGetNextOp : public AsyncOpKernel { + public: + explicit IteratorGetNextOp(OpKernelConstruction* ctx) + : AsyncOpKernel(ctx), + background_worker_(ctx->env(), + strings::StrCat("iterator_get_next_thread_", + SanitizeThreadSuffix(name()))) {} + + void ComputeAsync(OpKernelContext* ctx, DoneCallback done) override; + + private: + BackgroundWorker background_worker_; +}; + +class IteratorToStringHandleOp : public OpKernel { + public: + explicit IteratorToStringHandleOp(OpKernelConstruction* ctx) + : OpKernel(ctx) {} + + void Compute(OpKernelContext* ctx) override; +}; + +class IteratorFromStringHandleOp : public OpKernel { + public: + explicit IteratorFromStringHandleOp(OpKernelConstruction* ctx); + + void Compute(OpKernelContext* ctx) override; + + private: + DataTypeVector output_dtypes_; + std::vector output_shapes_; +}; + +} // namespace tensorflow + +#endif // TENSORFLOW_CORE_KERNELS_DATA_ITERATOR_OPS_H_ diff --git a/tensorflow/core/kernels/data/prefetch_dataset_op.cc b/tensorflow/core/kernels/data/prefetch_dataset_op.cc index cc16108dce..9000842840 100644 --- a/tensorflow/core/kernels/data/prefetch_dataset_op.cc +++ b/tensorflow/core/kernels/data/prefetch_dataset_op.cc @@ -14,347 +14,335 @@ limitations under the License. ==============================================================================*/ #include +#include "tensorflow/core/kernels/data/prefetch_dataset_op.h" + #include "tensorflow/core/framework/partial_tensor_shape.h" #include "tensorflow/core/framework/tensor.h" -#include "tensorflow/core/kernels/data/dataset.h" -#include "tensorflow/core/kernels/data/prefetch_autotuner.h" #include "tensorflow/core/lib/core/error_codes.pb.h" namespace tensorflow { -namespace { - // See documentation in ../ops/dataset_ops.cc for a high-level // description of the following op. -class PrefetchDatasetOp : public UnaryDatasetOpKernel { +class PrefetchDatasetOp::Dataset : public GraphDatasetBase { public: - explicit PrefetchDatasetOp(OpKernelConstruction* ctx) - : UnaryDatasetOpKernel(ctx) {} - - protected: - void MakeDataset(OpKernelContext* ctx, DatasetBase* input, - DatasetBase** output) override { - int64 buffer_size; - OP_REQUIRES_OK( - ctx, ParseScalarArgument(ctx, "buffer_size", &buffer_size)); - OP_REQUIRES(ctx, - buffer_size >= 0 || buffer_size == PrefetchAutotuner::kAutoTune, - errors::InvalidArgument("buffer_size must be >= 0")); - - *output = new Dataset(ctx, input, buffer_size); + Dataset(OpKernelContext* ctx, const DatasetBase* input, int64 buffer_size) + : GraphDatasetBase(ctx), input_(input), buffer_size_(buffer_size) { + input_->Ref(); } - private: - class Dataset : public GraphDatasetBase { - public: - Dataset(OpKernelContext* ctx, const DatasetBase* input, int64 buffer_size) - : GraphDatasetBase(ctx), input_(input), buffer_size_(buffer_size) { - input_->Ref(); - } + ~Dataset() override { input_->Unref(); } - ~Dataset() override { input_->Unref(); } + std::unique_ptr MakeIteratorInternal( + const string& prefix) const override { + return std::unique_ptr( + new Iterator({this, strings::StrCat(prefix, "::Prefetch")})); + } - std::unique_ptr MakeIteratorInternal( - const string& prefix) const override { - return std::unique_ptr( - new Iterator({this, strings::StrCat(prefix, "::Prefetch")})); - } + const DataTypeVector& output_dtypes() const override { + return input_->output_dtypes(); + } - const DataTypeVector& output_dtypes() const override { - return input_->output_dtypes(); - } - const std::vector& output_shapes() const override { - return input_->output_shapes(); - } + const std::vector& output_shapes() const override { + return input_->output_shapes(); + } - string DebugString() const override { return "PrefetchDatasetOp::Dataset"; } + string DebugString() const override { return "PrefetchDatasetOp::Dataset"; } - protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, - Node** output) const override { - Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); - Node* buffer_size = nullptr; - TF_RETURN_IF_ERROR(b->AddScalar(buffer_size_, &buffer_size)); - TF_RETURN_IF_ERROR( - b->AddDataset(this, {input_graph_node, buffer_size}, output)); - return Status::OK(); - } + protected: + Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Node** output) const override { + Node* input_graph_node = nullptr; + TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + Node* buffer_size = nullptr; + TF_RETURN_IF_ERROR(b->AddScalar(buffer_size_, &buffer_size)); + TF_RETURN_IF_ERROR( + b->AddDataset(this, {input_graph_node, buffer_size}, output)); + return Status::OK(); + } - private: - class Iterator : public DatasetIterator { - public: - explicit Iterator(const Params& params) - : DatasetIterator(params), - auto_tuner_(params.dataset->buffer_size_) {} - - ~Iterator() override { - // Signal the prefetch thread to terminate it. We will then - // join that thread when we delete `this->prefetch_thread_`. - // - // TODO(mrry): Replace this cancellation logic with a - // CancellationManager. The syntax would be more heavyweight, - // but it would be possible to thread a cancellation manager - // through the IteratorContext to upstream, - // potentially-blocking iterators, when we add these. - { - mutex_lock l(mu_); - cancelled_ = true; - cond_var_.notify_all(); - } - } + private: + class Iterator : public DatasetIterator { + public: + explicit Iterator(const Params& params) + : DatasetIterator(params), + auto_tuner_(params.dataset->buffer_size_) {} - Status Initialize(IteratorContext* ctx) override { - return dataset()->input_->MakeIterator(ctx, prefix(), &input_impl_); + ~Iterator() override { + // Signal the prefetch thread to terminate it. We will then + // join that thread when we delete `this->prefetch_thread_`. + // + // TODO(mrry): Replace this cancellation logic with a + // CancellationManager. The syntax would be more heavyweight, + // but it would be possible to thread a cancellation manager + // through the IteratorContext to upstream, + // potentially-blocking iterators, when we add these. + { + mutex_lock l(mu_); + cancelled_ = true; + cond_var_.notify_all(); } + } - Status GetNextInternal(IteratorContext* ctx, - std::vector* out_tensors, - bool* end_of_sequence) override { - { - mutex_lock l(mu_); - TF_RETURN_IF_ERROR(EnsurePrefetchThreadStarted(ctx)); - // Wait until the next element in the buffer has been - // produced, or we are shutting down. - while (!cancelled_ && buffer_.empty() && !prefetch_thread_finished_ && - auto_tuner_.buffer_limit() != 0) { - auto_tuner_.RecordEmpty(); - cond_var_.wait(l); - } + Status Initialize(IteratorContext* ctx) override { + return dataset()->input_->MakeIterator(ctx, prefix(), &input_impl_); + } - if (cancelled_) { - return errors::Cancelled( - "PrefetchDatasetOp::Dataset::Iterator::GetNext"); - } + Status GetNextInternal(IteratorContext* ctx, + std::vector* out_tensors, + bool* end_of_sequence) override { + { + mutex_lock l(mu_); + TF_RETURN_IF_ERROR(EnsurePrefetchThreadStarted(ctx)); + // Wait until the next element in the buffer has been + // produced, or we are shutting down. + while (!cancelled_ && buffer_.empty() && !prefetch_thread_finished_ && + auto_tuner_.buffer_limit() != 0) { + auto_tuner_.RecordEmpty(); + cond_var_.wait(l); + } - if (!buffer_.empty()) { - return Consume(out_tensors, end_of_sequence); - } + if (cancelled_) { + return errors::Cancelled( + "PrefetchDatasetOp::Dataset::Iterator::GetNext"); + } - if (prefetch_thread_finished_) { - *end_of_sequence = true; - return Status::OK(); - } + if (!buffer_.empty()) { + return Consume(out_tensors, end_of_sequence); + } - DCHECK_EQ(auto_tuner_.buffer_limit(), 0); + if (prefetch_thread_finished_) { + *end_of_sequence = true; + return Status::OK(); } - mutex_lock parent_l(parent_mu_); - mutex_lock l(mu_); - return input_impl_->GetNext(ctx, out_tensors, end_of_sequence); + DCHECK_EQ(auto_tuner_.buffer_limit(), 0); } - protected: - Status SaveInternal(IteratorStateWriter* writer) override { - // Acquire both locks to ensure that the prefetch thread and - // all GetNext threads are blocked. - mutex_lock parent_l(parent_mu_); - mutex_lock l(mu_); - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); - TF_RETURN_IF_ERROR( - writer->WriteScalar(full_name("buffer_size"), buffer_.size())); - for (size_t i = 0; i < buffer_.size(); i++) { - auto& buffer_element = buffer_[i]; - TF_RETURN_IF_ERROR(WriteStatus(writer, i, buffer_element.status)); - if (buffer_element.status.ok()) { - TF_RETURN_IF_ERROR(writer->WriteScalar( - full_name(strings::StrCat("buffer[", i, "].size")), - buffer_element.value.size())); - for (size_t j = 0; j < buffer_element.value.size(); j++) { - TF_RETURN_IF_ERROR(writer->WriteTensor( - full_name(strings::StrCat("buffer[", i, "][", j, "]")), - buffer_element.value[j])); - } + mutex_lock parent_l(parent_mu_); + mutex_lock l(mu_); + return input_impl_->GetNext(ctx, out_tensors, end_of_sequence); + } + + protected: + Status SaveInternal(IteratorStateWriter* writer) override { + // Acquire both locks to ensure that the prefetch thread and + // all GetNext threads are blocked. + mutex_lock parent_l(parent_mu_); + mutex_lock l(mu_); + TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR( + writer->WriteScalar(full_name("buffer_size"), buffer_.size())); + for (size_t i = 0; i < buffer_.size(); i++) { + auto& buffer_element = buffer_[i]; + TF_RETURN_IF_ERROR(WriteStatus(writer, i, buffer_element.status)); + if (buffer_element.status.ok()) { + TF_RETURN_IF_ERROR(writer->WriteScalar( + full_name(strings::StrCat("buffer[", i, "].size")), + buffer_element.value.size())); + for (size_t j = 0; j < buffer_element.value.size(); j++) { + TF_RETURN_IF_ERROR(writer->WriteTensor( + full_name(strings::StrCat("buffer[", i, "][", j, "]")), + buffer_element.value[j])); } } - return Status::OK(); } + return Status::OK(); + } - Status RestoreInternal(IteratorContext* ctx, - IteratorStateReader* reader) override { - mutex_lock parent_l(parent_mu_); - mutex_lock l(mu_); - buffer_.clear(); - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); - size_t buffer_size; - { - int64 temp; - TF_RETURN_IF_ERROR( - reader->ReadScalar(full_name("buffer_size"), &temp)); - buffer_size = static_cast(temp); - } - for (size_t i = 0; i < buffer_size; i++) { - buffer_.emplace_back(); - auto& buffer_element = buffer_.back(); - TF_RETURN_IF_ERROR(ReadStatus(reader, i, &buffer_element.status)); - if (buffer_element.status.ok()) { - size_t value_size; - { - int64 temp; - TF_RETURN_IF_ERROR(reader->ReadScalar( - full_name(strings::StrCat("buffer[", i, "].size")), &temp)); - value_size = static_cast(temp); - } - buffer_element.value.reserve(value_size); - for (size_t j = 0; j < value_size; j++) { - buffer_element.value.emplace_back(); - TF_RETURN_IF_ERROR(reader->ReadTensor( - full_name(strings::StrCat("buffer[", i, "][", j, "]")), - &buffer_element.value.back())); - } + Status RestoreInternal(IteratorContext* ctx, + IteratorStateReader* reader) override { + mutex_lock parent_l(parent_mu_); + mutex_lock l(mu_); + buffer_.clear(); + TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + size_t buffer_size; + { + int64 temp; + TF_RETURN_IF_ERROR(reader->ReadScalar(full_name("buffer_size"), &temp)); + buffer_size = static_cast(temp); + } + for (size_t i = 0; i < buffer_size; i++) { + buffer_.emplace_back(); + auto& buffer_element = buffer_.back(); + TF_RETURN_IF_ERROR(ReadStatus(reader, i, &buffer_element.status)); + if (buffer_element.status.ok()) { + size_t value_size; + { + int64 temp; + TF_RETURN_IF_ERROR(reader->ReadScalar( + full_name(strings::StrCat("buffer[", i, "].size")), &temp)); + value_size = static_cast(temp); + } + buffer_element.value.reserve(value_size); + for (size_t j = 0; j < value_size; j++) { + buffer_element.value.emplace_back(); + TF_RETURN_IF_ERROR(reader->ReadTensor( + full_name(strings::StrCat("buffer[", i, "][", j, "]")), + &buffer_element.value.back())); } } - return Status::OK(); } + return Status::OK(); + } - private: - // A buffer element comprises a status and (if that status is - // OK) a vector of tensors, representing an element of the input dataset. - struct BufferElement { - // The producer sets `status` if getting the input element fails. - Status status; - // The buffered data element. - std::vector value; - }; - - Status Consume(std::vector* out_tensors, bool* end_of_sequence) - EXCLUSIVE_LOCKS_REQUIRED(mu_) { - // A new element is available. Forward the status from computing it, and - // (if we successfully got an element) the output values. - Status s = buffer_.front().status; - if (s.ok()) { - *out_tensors = std::move(buffer_.front().value); - } - buffer_.pop_front(); - *end_of_sequence = false; - - // Wake the prefetch thread, in case it has been waiting for space - // in the buffer. Also wake up threads from other calls to GetNext. - // - // TODO(mrry): Consider using different condition variables for - // GetNext and Prefetch. - cond_var_.notify_all(); - return s; - } + private: + // A buffer element comprises a status and (if that status is + // OK) a vector of tensors, representing an element of the input dataset. + struct BufferElement { + // The producer sets `status` if getting the input element fails. + Status status; + // The buffered data element. + std::vector value; + }; - Status EnsurePrefetchThreadStarted(IteratorContext* ctx) - EXCLUSIVE_LOCKS_REQUIRED(mu_) { - if (!prefetch_thread_) { - prefetch_thread_.reset( - ctx->env()->StartThread({}, "prefetch_thread", - std::bind(&Iterator::PrefetchThread, this, - new IteratorContext(*ctx)))); - } - return Status::OK(); + Status Consume(std::vector* out_tensors, bool* end_of_sequence) + EXCLUSIVE_LOCKS_REQUIRED(mu_) { + // A new element is available. Forward the status from computing it, and + // (if we successfully got an element) the output values. + Status s = buffer_.front().status; + if (s.ok()) { + *out_tensors = std::move(buffer_.front().value); } + buffer_.pop_front(); + *end_of_sequence = false; - // Prefetches elements of the input, storing results in an internal - // buffer. + // Wake the prefetch thread, in case it has been waiting for space + // in the buffer. Also wake up threads from other calls to GetNext. // - // It owns the iterator context passed to it. - void PrefetchThread(IteratorContext* ctx) { - std::unique_ptr cleanup(ctx); - while (true) { - std::vector value; + // TODO(mrry): Consider using different condition variables for + // GetNext and Prefetch. + cond_var_.notify_all(); + return s; + } - // 1. Wait for a slot in the buffer. - { - mutex_lock l(mu_); - while (!cancelled_ && - buffer_.size() >= auto_tuner_.buffer_limit()) { - cond_var_.wait(l); - } - - if (cancelled_) { - return; - } - } + Status EnsurePrefetchThreadStarted(IteratorContext* ctx) + EXCLUSIVE_LOCKS_REQUIRED(mu_) { + if (!prefetch_thread_) { + prefetch_thread_.reset( + ctx->env()->StartThread({}, "prefetch_thread", + std::bind(&Iterator::PrefetchThread, this, + new IteratorContext(*ctx)))); + } + return Status::OK(); + } - // 2. Read the next element. - // Acquire the parent lock since we will be reading an element - // from the input iterator. Note that we do not wish to release - // this lock till we have added the fetched element to the - // `buffer_` else there will be local state that may be missed - // by SaveInternal. - mutex_lock parent_l(parent_mu_); - bool end_of_sequence; - BufferElement buffer_element; - buffer_element.status = input_impl_->GetNext( - ctx, &buffer_element.value, &end_of_sequence); - if (buffer_element.status.ok() && end_of_sequence) { - mutex_lock l(mu_); - prefetch_thread_finished_ = true; - cond_var_.notify_all(); - return; + // Prefetches elements of the input, storing results in an internal + // buffer. + // + // It owns the iterator context passed to it. + void PrefetchThread(IteratorContext* ctx) { + std::unique_ptr cleanup(ctx); + while (true) { + std::vector value; + + // 1. Wait for a slot in the buffer. + { + mutex_lock l(mu_); + while (!cancelled_ && buffer_.size() >= auto_tuner_.buffer_limit()) { + cond_var_.wait(l); } - // 3. Signal that the element has been produced. - { - mutex_lock l(mu_); - buffer_.push_back(std::move(buffer_element)); - cond_var_.notify_all(); + if (cancelled_) { + return; } } - } - Status WriteStatus(IteratorStateWriter* writer, size_t index, - const Status& status) EXCLUSIVE_LOCKS_REQUIRED(mu_) { - TF_RETURN_IF_ERROR(writer->WriteScalar( - CodeKey(index), static_cast(status.code()))); - if (!status.ok()) { - TF_RETURN_IF_ERROR(writer->WriteScalar(ErrorMessageKey(index), - status.error_message())); + // 2. Read the next element. + // Acquire the parent lock since we will be reading an element + // from the input iterator. Note that we do not wish to release + // this lock till we have added the fetched element to the + // `buffer_` else there will be local state that may be missed + // by SaveInternal. + mutex_lock parent_l(parent_mu_); + bool end_of_sequence; + BufferElement buffer_element; + buffer_element.status = + input_impl_->GetNext(ctx, &buffer_element.value, &end_of_sequence); + if (buffer_element.status.ok() && end_of_sequence) { + mutex_lock l(mu_); + prefetch_thread_finished_ = true; + cond_var_.notify_all(); + return; } - return Status::OK(); - } - Status ReadStatus(IteratorStateReader* reader, size_t index, - Status* status) EXCLUSIVE_LOCKS_REQUIRED(mu_) { - int64 code_int; - TF_RETURN_IF_ERROR(reader->ReadScalar(CodeKey(index), &code_int)); - error::Code code = static_cast(code_int); - - if (code != error::Code::OK) { - string error_message; - TF_RETURN_IF_ERROR( - reader->ReadScalar(ErrorMessageKey(index), &error_message)); - *status = Status(code, error_message); - } else { - *status = Status::OK(); + // 3. Signal that the element has been produced. + { + mutex_lock l(mu_); + buffer_.push_back(std::move(buffer_element)); + cond_var_.notify_all(); } - return Status::OK(); } + } - string CodeKey(size_t index) { - return full_name(strings::StrCat("status[", index, "].code")); + Status WriteStatus(IteratorStateWriter* writer, size_t index, + const Status& status) EXCLUSIVE_LOCKS_REQUIRED(mu_) { + TF_RETURN_IF_ERROR(writer->WriteScalar( + CodeKey(index), static_cast(status.code()))); + if (!status.ok()) { + TF_RETURN_IF_ERROR(writer->WriteScalar(ErrorMessageKey(index), + status.error_message())); } + return Status::OK(); + } - string ErrorMessageKey(size_t index) { - return full_name(strings::StrCat("status[", index, "].error_message")); + Status ReadStatus(IteratorStateReader* reader, size_t index, Status* status) + EXCLUSIVE_LOCKS_REQUIRED(mu_) { + int64 code_int; + TF_RETURN_IF_ERROR(reader->ReadScalar(CodeKey(index), &code_int)); + error::Code code = static_cast(code_int); + + if (code != error::Code::OK) { + string error_message; + TF_RETURN_IF_ERROR( + reader->ReadScalar(ErrorMessageKey(index), &error_message)); + *status = Status(code, error_message); + } else { + *status = Status::OK(); } + return Status::OK(); + } - // This mutex is used to ensure exclusivity between multiple threads - // reading/writing this iterator's local state. - mutex mu_; - // This mutex is used to ensure exclusivity between multiple threads - // accessing the parent iterator. We keep this separate from `mu_` to - // allow prefetching to run in parallel with GetNext calls. - mutex parent_mu_ ACQUIRED_BEFORE(mu_); - std::unique_ptr input_impl_ GUARDED_BY(parent_mu_); - condition_variable cond_var_; - PrefetchAutotuner auto_tuner_ GUARDED_BY(mu_); - std::deque buffer_ GUARDED_BY(mu_); - std::unique_ptr prefetch_thread_ GUARDED_BY(mu_); - bool cancelled_ GUARDED_BY(mu_) = false; - bool prefetch_thread_finished_ GUARDED_BY(mu_) = false; - }; + string CodeKey(size_t index) { + return full_name(strings::StrCat("status[", index, "].code")); + } + + string ErrorMessageKey(size_t index) { + return full_name(strings::StrCat("status[", index, "].error_message")); + } - const DatasetBase* const input_; - const int64 buffer_size_; + // This mutex is used to ensure exclusivity between multiple threads + // reading/writing this iterator's local state. + mutex mu_; + // This mutex is used to ensure exclusivity between multiple threads + // accessing the parent iterator. We keep this separate from `mu_` to + // allow prefetching to run in parallel with GetNext calls. + mutex parent_mu_ ACQUIRED_BEFORE(mu_); + std::unique_ptr input_impl_ GUARDED_BY(parent_mu_); + condition_variable cond_var_; + PrefetchAutotuner auto_tuner_ GUARDED_BY(mu_); + std::deque buffer_ GUARDED_BY(mu_); + std::unique_ptr prefetch_thread_ GUARDED_BY(mu_); + bool cancelled_ GUARDED_BY(mu_) = false; + bool prefetch_thread_finished_ GUARDED_BY(mu_) = false; }; + const DatasetBase* const input_; + const int64 buffer_size_; }; +void PrefetchDatasetOp::MakeDataset(OpKernelContext* ctx, DatasetBase* input, + DatasetBase** output) { + int64 buffer_size; + OP_REQUIRES_OK(ctx, + ParseScalarArgument(ctx, "buffer_size", &buffer_size)); + OP_REQUIRES(ctx, + buffer_size >= 0 || buffer_size == PrefetchAutotuner::kAutoTune, + errors::InvalidArgument("buffer_size must be >= 0")); + + *output = new Dataset(ctx, input, buffer_size); +} + REGISTER_KERNEL_BUILDER(Name("PrefetchDataset").Device(DEVICE_CPU), PrefetchDatasetOp); REGISTER_KERNEL_BUILDER(Name("PrefetchDataset") @@ -363,6 +351,4 @@ REGISTER_KERNEL_BUILDER(Name("PrefetchDataset") .HostMemory("input_dataset") .HostMemory("handle"), PrefetchDatasetOp); -} // namespace - } // namespace tensorflow diff --git a/tensorflow/core/kernels/data/prefetch_dataset_op.h b/tensorflow/core/kernels/data/prefetch_dataset_op.h new file mode 100644 index 0000000000..c40c4b00da --- /dev/null +++ b/tensorflow/core/kernels/data/prefetch_dataset_op.h @@ -0,0 +1,39 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_CORE_KERNELS_DATA_PREFETCH_DATASET_OP_H_ +#define TENSORFLOW_CORE_KERNELS_DATA_PREFETCH_DATASET_OP_H_ + +#include "tensorflow/core/kernels/data/dataset.h" +#include "tensorflow/core/kernels/data/prefetch_autotuner.h" + +namespace tensorflow { + +class PrefetchDatasetOp : public UnaryDatasetOpKernel { + public: + explicit PrefetchDatasetOp(OpKernelConstruction* ctx) + : UnaryDatasetOpKernel(ctx) {} + + protected: + void MakeDataset(OpKernelContext* ctx, DatasetBase* input, + DatasetBase** output) override; + + private: + class Dataset; +}; + +} // namespace tensorflow + +#endif // TENSORFLOW_CORE_KERNELS_DATA_PREFETCH_DATASET_OP_H_ diff --git a/tensorflow/core/kernels/function_ops.cc b/tensorflow/core/kernels/function_ops.cc index d5c33c0188..bfdabc3a9f 100644 --- a/tensorflow/core/kernels/function_ops.cc +++ b/tensorflow/core/kernels/function_ops.cc @@ -16,13 +16,13 @@ limitations under the License. #include #include +#include "tensorflow/core/kernels/function_ops.h" + #include "tensorflow/core/common_runtime/device.h" #include "tensorflow/core/common_runtime/executor.h" #include "tensorflow/core/common_runtime/function.h" #include "tensorflow/core/common_runtime/memory_types.h" -#include "tensorflow/core/framework/function.h" #include "tensorflow/core/framework/op.h" -#include "tensorflow/core/framework/op_kernel.h" #include "tensorflow/core/framework/register_types.h" #include "tensorflow/core/graph/algorithm.h" #include "tensorflow/core/graph/gradients.h" @@ -33,64 +33,40 @@ limitations under the License. namespace tensorflow { -static const char* const kArgOp = FunctionLibraryDefinition::kArgOp; -static const char* const kRetOp = FunctionLibraryDefinition::kRetOp; static const char* const kGradientOp = FunctionLibraryDefinition::kGradientOp; -class ArgOp : public OpKernel { - public: - explicit ArgOp(OpKernelConstruction* ctx) : OpKernel(ctx) { - OP_REQUIRES_OK(ctx, ctx->GetAttr("T", &dtype_)); - OP_REQUIRES_OK(ctx, ctx->GetAttr("index", &index_)); - } - - void Compute(OpKernelContext* ctx) override { - auto frame = ctx->call_frame(); - OP_REQUIRES(ctx, frame != nullptr, errors::Internal("no call frame")); - Tensor val; - OP_REQUIRES_OK(ctx, frame->GetArg(index_, &val)); - OP_REQUIRES(ctx, val.dtype() == dtype_, - errors::InvalidArgument( - "Type mismatch: actual ", DataTypeString(val.dtype()), - " vs. expect ", DataTypeString(dtype_))); - ctx->set_output(0, val); - } - - bool IsExpensive() override { return false; } - - private: - int index_; - DataType dtype_; - - TF_DISALLOW_COPY_AND_ASSIGN(ArgOp); -}; - -class RetvalOp : public OpKernel { - public: - explicit RetvalOp(OpKernelConstruction* ctx) : OpKernel(ctx) { - OP_REQUIRES_OK(ctx, ctx->GetAttr("T", &dtype_)); - OP_REQUIRES_OK(ctx, ctx->GetAttr("index", &index_)); - } - - void Compute(OpKernelContext* ctx) override { - const Tensor& val = ctx->input(0); - OP_REQUIRES(ctx, val.dtype() == dtype_, - errors::InvalidArgument( - "Type mismatch: actual ", DataTypeString(val.dtype()), - " vs. expect ", DataTypeString(dtype_))); - auto frame = ctx->call_frame(); - OP_REQUIRES(ctx, frame != nullptr, errors::Internal("no call frame")); - OP_REQUIRES_OK(ctx, frame->SetRetval(index_, val)); - } - - bool IsExpensive() override { return false; } - - private: - int index_; - DataType dtype_; - - TF_DISALLOW_COPY_AND_ASSIGN(RetvalOp); -}; +ArgOp::ArgOp(OpKernelConstruction* ctx) : OpKernel(ctx) { + OP_REQUIRES_OK(ctx, ctx->GetAttr("T", &dtype_)); + OP_REQUIRES_OK(ctx, ctx->GetAttr("index", &index_)); +} + +void ArgOp::Compute(OpKernelContext* ctx) { + auto frame = ctx->call_frame(); + OP_REQUIRES(ctx, frame != nullptr, errors::Internal("no call frame")); + Tensor val; + OP_REQUIRES_OK(ctx, frame->GetArg(index_, &val)); + OP_REQUIRES(ctx, val.dtype() == dtype_, + errors::InvalidArgument("Type mismatch: actual ", + DataTypeString(val.dtype()), + " vs. expect ", DataTypeString(dtype_))); + ctx->set_output(0, val); +} + +RetvalOp::RetvalOp(OpKernelConstruction* ctx) : OpKernel(ctx) { + OP_REQUIRES_OK(ctx, ctx->GetAttr("T", &dtype_)); + OP_REQUIRES_OK(ctx, ctx->GetAttr("index", &index_)); +} + +void RetvalOp::Compute(OpKernelContext* ctx) { + const Tensor& val = ctx->input(0); + OP_REQUIRES(ctx, val.dtype() == dtype_, + errors::InvalidArgument("Type mismatch: actual ", + DataTypeString(val.dtype()), + " vs. expect ", DataTypeString(dtype_))); + auto frame = ctx->call_frame(); + OP_REQUIRES(ctx, frame != nullptr, errors::Internal("no call frame")); + OP_REQUIRES_OK(ctx, frame->SetRetval(index_, val)); +} REGISTER_SYSTEM_KERNEL_BUILDER(Name(kArgOp).Device(DEVICE_CPU), ArgOp); REGISTER_SYSTEM_KERNEL_BUILDER(Name(kRetOp).Device(DEVICE_CPU), RetvalOp); @@ -304,123 +280,105 @@ REGISTER_KERNEL_BUILDER(Name(kGradientOp).Device(DEVICE_SYCL), #endif // TENSORFLOW_USE_SYCL -class RemoteCallOp : public AsyncOpKernel { - public: - explicit RemoteCallOp(OpKernelConstruction* ctx) : AsyncOpKernel(ctx) { - OP_REQUIRES_OK(ctx, - ctx->GetAttr(FunctionLibraryDefinition::kFuncAttr, &func_)); - OP_REQUIRES_OK(ctx, ctx->GetAttr("Tin", &input_dtypes_)); - OP_REQUIRES_OK(ctx, ctx->GetAttr("Tout", &output_dtypes_)); - } - - ~RemoteCallOp() override {} - - void ComputeAsync(OpKernelContext* ctx, DoneCallback done) override { - FunctionLibraryRuntime* lib = ctx->function_library(); - OP_REQUIRES_ASYNC(ctx, lib != nullptr, - errors::Internal("No function library is provided."), - done); - - const string& source_device = lib->device()->name(); - const Tensor* target; - OP_REQUIRES_OK_ASYNC(ctx, ctx->input("target", &target), done); - string target_device; - OP_REQUIRES_OK_ASYNC( - ctx, - DeviceNameUtils::CanonicalizeDeviceName(target->scalar()(), - source_device, &target_device), - done); - - AttrValueMap attr_values = func_.attr(); - FunctionLibraryRuntime::InstantiateOptions instantiate_opts; - instantiate_opts.target = target_device; - - FunctionTarget function_target = {target_device, lib}; - - FunctionLibraryRuntime::Handle handle; - { - mutex_lock l(mu_); - auto cached_entry = handle_cache_.find(function_target); - if (cached_entry != handle_cache_.end()) { - handle = cached_entry->second; - } else { - VLOG(1) << "Instantiating " << func_.name() << " on " << target_device; - tracing::ScopedActivity activity(strings::StrCat( - "RemoteCall: Instantiate: ", func_.name(), " on ", target_device)); - OP_REQUIRES_OK_ASYNC( - ctx, - lib->Instantiate(func_.name(), AttrSlice(&attr_values), - instantiate_opts, &handle), - done); - auto insert_result = handle_cache_.insert({function_target, handle}); - CHECK(insert_result.second) << "Insert unsuccessful."; - VLOG(1) << "Instantiated " << func_.name() << " on " << target_device - << ", resulting in handle: " << handle << " flr: " << lib; - } +RemoteCallOp::RemoteCallOp(OpKernelConstruction* ctx) : AsyncOpKernel(ctx) { + OP_REQUIRES_OK(ctx, + ctx->GetAttr(FunctionLibraryDefinition::kFuncAttr, &func_)); + OP_REQUIRES_OK(ctx, ctx->GetAttr("Tin", &input_dtypes_)); + OP_REQUIRES_OK(ctx, ctx->GetAttr("Tout", &output_dtypes_)); +} + +void RemoteCallOp::ComputeAsync(OpKernelContext* ctx, DoneCallback done) { + FunctionLibraryRuntime* lib = ctx->function_library(); + OP_REQUIRES_ASYNC(ctx, lib != nullptr, + errors::Internal("No function library is provided."), done); + + const string& source_device = lib->device()->name(); + const Tensor* target; + OP_REQUIRES_OK_ASYNC(ctx, ctx->input("target", &target), done); + string target_device; + OP_REQUIRES_OK_ASYNC( + ctx, + DeviceNameUtils::CanonicalizeDeviceName(target->scalar()(), + source_device, &target_device), + done); + + AttrValueMap attr_values = func_.attr(); + FunctionLibraryRuntime::InstantiateOptions instantiate_opts; + instantiate_opts.target = target_device; + + FunctionTarget function_target = {target_device, lib}; + + FunctionLibraryRuntime::Handle handle; + { + mutex_lock l(mu_); + auto cached_entry = handle_cache_.find(function_target); + if (cached_entry != handle_cache_.end()) { + handle = cached_entry->second; + } else { + VLOG(1) << "Instantiating " << func_.name() << " on " << target_device; + tracing::ScopedActivity activity(strings::StrCat( + "RemoteCall: Instantiate: ", func_.name(), " on ", target_device)); + OP_REQUIRES_OK_ASYNC( + ctx, + lib->Instantiate(func_.name(), AttrSlice(&attr_values), + instantiate_opts, &handle), + done); + auto insert_result = handle_cache_.insert({function_target, handle}); + CHECK(insert_result.second) << "Insert unsuccessful."; + VLOG(1) << "Instantiated " << func_.name() << " on " << target_device + << ", resulting in handle: " << handle << " flr: " << lib; } + } - OpInputList arguments; - OP_REQUIRES_OK_ASYNC(ctx, ctx->input_list("args", &arguments), done); + OpInputList arguments; + OP_REQUIRES_OK_ASYNC(ctx, ctx->input_list("args", &arguments), done); - FunctionLibraryRuntime::Options opts; - opts.step_id = ctx->step_id(); - opts.runner = ctx->runner(); - opts.source_device = source_device; - if (opts.source_device != target_device) { - opts.remote_execution = true; - } - opts.create_rendezvous = true; - std::vector args; - args.reserve(arguments.size()); - for (const Tensor& argument : arguments) { - args.push_back(argument); - } - for (const auto& dtype : input_dtypes_) { - AllocatorAttributes arg_alloc_attrs; - if (DataTypeAlwaysOnHost(dtype)) { - arg_alloc_attrs.set_on_host(true); - } - opts.args_alloc_attrs.push_back(arg_alloc_attrs); + FunctionLibraryRuntime::Options opts; + opts.step_id = ctx->step_id(); + opts.runner = ctx->runner(); + opts.source_device = source_device; + if (opts.source_device != target_device) { + opts.remote_execution = true; + } + opts.create_rendezvous = true; + std::vector args; + args.reserve(arguments.size()); + for (const Tensor& argument : arguments) { + args.push_back(argument); + } + for (const auto& dtype : input_dtypes_) { + AllocatorAttributes arg_alloc_attrs; + if (DataTypeAlwaysOnHost(dtype)) { + arg_alloc_attrs.set_on_host(true); } - for (const auto& dtype : output_dtypes_) { - AllocatorAttributes ret_alloc_attrs; - if (DataTypeAlwaysOnHost(dtype)) { - ret_alloc_attrs.set_on_host(true); - } - opts.rets_alloc_attrs.push_back(ret_alloc_attrs); + opts.args_alloc_attrs.push_back(arg_alloc_attrs); + } + for (const auto& dtype : output_dtypes_) { + AllocatorAttributes ret_alloc_attrs; + if (DataTypeAlwaysOnHost(dtype)) { + ret_alloc_attrs.set_on_host(true); } - auto* rets = new std::vector; - auto* activity = new tracing::ScopedActivity(strings::StrCat( - "RemoteCall: Run: ", func_.name(), " on ", target_device)); - VLOG(1) << "Running " << func_.name() << " on " << target_device - << " with handle: " << handle; - lib->Run(opts, handle, args, rets, - [rets, activity, done, ctx](const Status& status) { - if (!status.ok()) { - ctx->SetStatus(status); - } else { - for (size_t i = 0; i < rets->size(); ++i) { - ctx->set_output(i, (*rets)[i]); - } - } - delete rets; - delete activity; - done(); - }); + opts.rets_alloc_attrs.push_back(ret_alloc_attrs); } - - private: - NameAttrList func_; - DataTypeVector input_dtypes_; - DataTypeVector output_dtypes_; - - mutex mu_; - typedef std::pair FunctionTarget; - std::map handle_cache_ - GUARDED_BY(mu_); - - TF_DISALLOW_COPY_AND_ASSIGN(RemoteCallOp); -}; + auto* rets = new std::vector; + auto* activity = new tracing::ScopedActivity(strings::StrCat( + "RemoteCall: Run: ", func_.name(), " on ", target_device)); + VLOG(1) << "Running " << func_.name() << " on " << target_device + << " with handle: " << handle; + lib->Run(opts, handle, args, rets, + [rets, activity, done, ctx](const Status& status) { + if (!status.ok()) { + ctx->SetStatus(status); + } else { + for (size_t i = 0; i < rets->size(); ++i) { + ctx->set_output(i, (*rets)[i]); + } + } + delete rets; + delete activity; + done(); + }); +} REGISTER_KERNEL_BUILDER( Name("RemoteCall").Device(DEVICE_CPU).HostMemory("target"), RemoteCallOp); diff --git a/tensorflow/core/kernels/function_ops.h b/tensorflow/core/kernels/function_ops.h new file mode 100644 index 0000000000..9e88cc6d8c --- /dev/null +++ b/tensorflow/core/kernels/function_ops.h @@ -0,0 +1,79 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_CORE_KERNELS_FUNCTION_OPS_H_ +#define TENSORFLOW_CORE_KERNELS_FUNCTION_OPS_H_ + +#include "tensorflow/core/framework/function.h" +#include "tensorflow/core/framework/op_kernel.h" + +namespace tensorflow { + +static const char* const kArgOp = FunctionLibraryDefinition::kArgOp; +static const char* const kRetOp = FunctionLibraryDefinition::kRetOp; + +class ArgOp : public OpKernel { + public: + explicit ArgOp(OpKernelConstruction* ctx); + + void Compute(OpKernelContext* ctx) override; + + bool IsExpensive() override { return false; } + + private: + int index_; + DataType dtype_; + + TF_DISALLOW_COPY_AND_ASSIGN(ArgOp); +}; + +class RetvalOp : public OpKernel { + public: + explicit RetvalOp(OpKernelConstruction* ctx); + + void Compute(OpKernelContext* ctx) override; + + bool IsExpensive() override { return false; } + + private: + int index_; + DataType dtype_; + + TF_DISALLOW_COPY_AND_ASSIGN(RetvalOp); +}; + +class RemoteCallOp : public AsyncOpKernel { + public: + explicit RemoteCallOp(OpKernelConstruction* ctx); + + ~RemoteCallOp() override {} + + void ComputeAsync(OpKernelContext* ctx, DoneCallback done) override; + + private: + NameAttrList func_; + DataTypeVector input_dtypes_; + DataTypeVector output_dtypes_; + + mutex mu_; + typedef std::pair FunctionTarget; + std::map handle_cache_ + GUARDED_BY(mu_); + + TF_DISALLOW_COPY_AND_ASSIGN(RemoteCallOp); +}; + +} // namespace tensorflow +#endif // TENSORFLOW_CORE_KERNELS_FUNCTION_OPS_H_ -- GitLab From 376e44eb0ab67db4fcb61e0303eda67862c6c6de Mon Sep 17 00:00:00 2001 From: Anna R Date: Tue, 7 Aug 2018 17:10:47 -0700 Subject: [PATCH 182/437] Internal change. PiperOrigin-RevId: 207807275 --- tensorflow/contrib/autograph/converters/BUILD | 1 + 1 file changed, 1 insertion(+) diff --git a/tensorflow/contrib/autograph/converters/BUILD b/tensorflow/contrib/autograph/converters/BUILD index 7cbba71683..2d2ab7040a 100644 --- a/tensorflow/contrib/autograph/converters/BUILD +++ b/tensorflow/contrib/autograph/converters/BUILD @@ -204,6 +204,7 @@ py_test( name = "side_effect_guards_test", srcs = ["side_effect_guards_test.py"], srcs_version = "PY2AND3", + tags = ["notsan"], deps = [ ":converters", "//tensorflow/contrib/autograph/core:test_lib", -- GitLab From 69a6c91a3937a01375a88b328a1637084c1cc257 Mon Sep 17 00:00:00 2001 From: Anna R Date: Tue, 7 Aug 2018 17:45:50 -0700 Subject: [PATCH 183/437] Internal change. PiperOrigin-RevId: 207811817 --- tensorflow/tools/api/tests/api_compatibility_test.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tensorflow/tools/api/tests/api_compatibility_test.py b/tensorflow/tools/api/tests/api_compatibility_test.py index d680b96673..12fe029ede 100644 --- a/tensorflow/tools/api/tests/api_compatibility_test.py +++ b/tensorflow/tools/api/tests/api_compatibility_test.py @@ -166,6 +166,8 @@ class ApiCompatibilityTest(test.TestCase): diff_message = 'New object %s found (added).' % key verbose_diff_message = diff_message else: + # Do not truncate diff + self.maxDiffs = None # pylint: disable=invalid-name # Now we can run an actual proto diff. try: self.assertProtoEquals(expected_dict[key], actual_dict[key]) -- GitLab From 6cbc142ac44dd7c70c98ec4a43db6fe65658574a Mon Sep 17 00:00:00 2001 From: Akshay Agrawal Date: Tue, 7 Aug 2018 17:46:32 -0700 Subject: [PATCH 184/437] Output a helpful error message when defun-ing a Python function that returns something other than a Tensor. PiperOrigin-RevId: 207811913 --- tensorflow/python/eager/function.py | 17 ++++++++++++++--- tensorflow/python/eager/function_test.py | 12 ++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/tensorflow/python/eager/function.py b/tensorflow/python/eager/function.py index f315fa296c..e640cc9f66 100644 --- a/tensorflow/python/eager/function.py +++ b/tensorflow/python/eager/function.py @@ -744,6 +744,10 @@ def _trace_and_define_function(name, python_func, compiled, args, kwds, Returns: A GraphModeFunction. + + Raises: + TypeError: If any of `python_func`'s return values is neither `None` nor a + `Tensor`. """ graph_key = ops.get_default_graph()._graph_key # pylint: disable=protected-access func_graph = CapturingGraph() @@ -775,9 +779,17 @@ def _trace_and_define_function(name, python_func, compiled, args, kwds, func_kwds_before = nest.pack_sequence_as(func_kwds, nest.flatten(func_kwds)) def convert(x): + """Converts an argument to a Tensor.""" if x is None: return None - x = ops.convert_to_tensor_or_indexed_slices(x) + try: + x = ops.convert_to_tensor_or_indexed_slices(x) + except (ValueError, TypeError): + raise TypeError( + "To be compatible with tf.contrib.eager.defun, Python functions " + "must return zero or more Tensors; in compilation of %s, found " + "return value of type %s, which is not a Tensor." % + (str(python_func), type(x))) x = a.mark_as_return(x) return x @@ -820,9 +832,8 @@ def _trace_and_define_function(name, python_func, compiled, args, kwds, # Returning a closed-over tensor as an output does not trigger a # call to convert_to_tensor, so we manually capture all such tensors. - outputs_list = _flatten(func_outputs) func_def_outputs = [ - func_graph.capture(x) for x in outputs_list + func_graph.capture(x) for x in _flatten(func_outputs) if x is not None ] diff --git a/tensorflow/python/eager/function_test.py b/tensorflow/python/eager/function_test.py index b7c9334c33..8084df4e8e 100644 --- a/tensorflow/python/eager/function_test.py +++ b/tensorflow/python/eager/function_test.py @@ -1464,6 +1464,18 @@ class AutomaticControlDependenciesTest(test.TestCase): value = train() self.assertEqual(value.numpy(), -1.0) + def testReturningNonTensorRaisesError(self): + optimizer = momentum.MomentumOptimizer(learning_rate=1.0, momentum=1.0) + optimizer.apply_gradients = function.defun(optimizer.apply_gradients) + v = resource_variable_ops.ResourceVariable(1.0) + grad = backprop.implicit_grad(lambda v: v**2)(v) + + with self.assertRaisesRegexp(TypeError, + '.*must return zero or more Tensors.*'): + # TODO(akshayka): We might want to allow defun-ing Python functions + # that return operations (and just execute the op instead of running it). + optimizer.apply_gradients(grad) + # TODO(b/111663004): This should work when the outer context is graph # building. def testOptimizerNonSlotVarsInDefunNoError(self): -- GitLab From 554519acc4e684689d4f930ad3c627497e177b1a Mon Sep 17 00:00:00 2001 From: Michael Kuperstein Date: Tue, 7 Aug 2018 17:53:21 -0700 Subject: [PATCH 185/437] [XLA] Add inputs and init values accessors to HloReduceInstruction PiperOrigin-RevId: 207812671 --- tensorflow/compiler/xla/service/hlo_instructions.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tensorflow/compiler/xla/service/hlo_instructions.h b/tensorflow/compiler/xla/service/hlo_instructions.h index b038822337..9250b2b846 100644 --- a/tensorflow/compiler/xla/service/hlo_instructions.h +++ b/tensorflow/compiler/xla/service/hlo_instructions.h @@ -340,6 +340,18 @@ class HloReduceInstruction : public HloInstruction { // Returns a serialized representation of this instruction. HloInstructionProto ToProto() const override; + // Returns the input tensors to be reduced. + tensorflow::gtl::ArraySlice inputs() const { + return tensorflow::gtl::ArraySlice(operands(), 0, + operand_count() / 2); + } + + // Returns the init values of the reduction. + tensorflow::gtl::ArraySlice init_values() const { + return tensorflow::gtl::ArraySlice( + operands(), operand_count() / 2, operand_count()); + } + private: std::vector ExtraAttributesToStringImpl( const HloPrintOptions& options) const override; -- GitLab From ade3c79d45075bb3e7266fa44f380f29fccc1b68 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 7 Aug 2018 18:34:36 -0700 Subject: [PATCH 186/437] Fix the dtype of last_idx_for_bcast inside _PickFinalStateFromHistory to be consistent with state_var, since 'Mul' op requires it's inputs must have the same dtype. PiperOrigin-RevId: 207817076 --- tensorflow/contrib/recurrent/python/ops/functional_rnn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/contrib/recurrent/python/ops/functional_rnn.py b/tensorflow/contrib/recurrent/python/ops/functional_rnn.py index 96cc3e997f..67a8f59c3c 100644 --- a/tensorflow/contrib/recurrent/python/ops/functional_rnn.py +++ b/tensorflow/contrib/recurrent/python/ops/functional_rnn.py @@ -206,7 +206,7 @@ def _PickFinalStateFromHistory(acc_state, sequence_length): lengths = array_ops.tile(array_ops.reshape(sequence_length, [-1, 1]), [1, max_time]) last_idx = math_ops.cast(math_ops.equal(output_time, lengths - 1), - dtype=dtypes.float32) + dtype=state_var.dtype) last_idx = array_ops.transpose(last_idx) last_idx_for_bcast = array_ops.expand_dims(last_idx, -1) sliced = math_ops.multiply(last_idx_for_bcast, state_var) -- GitLab From be9e098112284611a68b2d4b332f8029d9cbffac Mon Sep 17 00:00:00 2001 From: Allen Lavoie Date: Tue, 7 Aug 2018 19:14:17 -0700 Subject: [PATCH 187/437] TFTS: Don't return model state from OneShotPredictionHead evaluate() It doesn't need to be fed (OneShot), and returning it as a tuple causes some issues for evaluation infrastructure. PiperOrigin-RevId: 207820650 --- tensorflow/contrib/timeseries/python/timeseries/head.py | 8 ++++++++ .../contrib/timeseries/python/timeseries/head_test.py | 2 ++ 2 files changed, 10 insertions(+) diff --git a/tensorflow/contrib/timeseries/python/timeseries/head.py b/tensorflow/contrib/timeseries/python/timeseries/head.py index d2484d0ef5..32194e400e 100644 --- a/tensorflow/contrib/timeseries/python/timeseries/head.py +++ b/tensorflow/contrib/timeseries/python/timeseries/head.py @@ -321,6 +321,14 @@ class OneShotPredictionHead(TimeSeriesRegressionHead): feature_keys.TrainEvalFeatures.VALUES, ])) + def _evaluate_ops(self, features): + """Add ops for evaluation (aka filtering) to the graph.""" + spec = super(OneShotPredictionHead, self)._evaluate_ops(features) + # No state is fed to OneShotPredictionHead, so we don't return it; it being + # a tuple can cause issues for downstream infrastructure. + del spec.eval_metric_ops[feature_keys.State.STATE_TUPLE] + return spec + def _serving_ops(self, features): """Add ops for serving to the graph.""" with variable_scope.variable_scope("model", use_resource=True): diff --git a/tensorflow/contrib/timeseries/python/timeseries/head_test.py b/tensorflow/contrib/timeseries/python/timeseries/head_test.py index 857e7c5635..bda3b53aca 100644 --- a/tensorflow/contrib/timeseries/python/timeseries/head_test.py +++ b/tensorflow/contrib/timeseries/python/timeseries/head_test.py @@ -397,6 +397,8 @@ class OneShotTests(parameterized.TestCase): input_pipeline.NumpyReader(train_features), shuffle_seed=2, num_threads=1, batch_size=16, window_size=16) estimator.train(input_fn=train_input_fn, steps=5) + result = estimator.evaluate(input_fn=train_input_fn, steps=1) + self.assertNotIn(feature_keys.State.STATE_TUPLE, result) input_receiver_fn = estimator.build_raw_serving_input_receiver_fn() export_location = estimator.export_savedmodel(_new_temp_dir(), input_receiver_fn) -- GitLab From 38e507f7666f6be34e6eb58bac3fb9140544f925 Mon Sep 17 00:00:00 2001 From: Tiezhen WANG Date: Tue, 7 Aug 2018 19:58:35 -0700 Subject: [PATCH 188/437] update documentation Calling the parent constructor is needed, otherwise it will fail with the following error: RuntimeError: It looks like you are subclassing `Model` and you forgot to call `super(YourClass, self).__init__()`. Always start with this line. PiperOrigin-RevId: 207823589 --- tensorflow/python/keras/engine/training.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tensorflow/python/keras/engine/training.py b/tensorflow/python/keras/engine/training.py index 2cdd00a48d..ec900dd90e 100644 --- a/tensorflow/python/keras/engine/training.py +++ b/tensorflow/python/keras/engine/training.py @@ -74,6 +74,7 @@ class Model(Network): class MyModel(tf.keras.Model): def __init__(self): + super(MyModel, self).__init__() self.dense1 = tf.keras.layers.Dense(4, activation=tf.nn.relu) self.dense2 = tf.keras.layers.Dense(5, activation=tf.nn.softmax) @@ -94,6 +95,7 @@ class Model(Network): class MyModel(tf.keras.Model): def __init__(self): + super(MyModel, self).__init__() self.dense1 = tf.keras.layers.Dense(4, activation=tf.nn.relu) self.dense2 = tf.keras.layers.Dense(5, activation=tf.nn.softmax) self.dropout = tf.keras.layers.Dropout(0.5) -- GitLab From 35847b960fe59c0e2e5371db55041a62b65dbb37 Mon Sep 17 00:00:00 2001 From: Tiezhen WANG Date: Tue, 7 Aug 2018 20:06:30 -0700 Subject: [PATCH 189/437] Add missing python dependency. PiperOrigin-RevId: 207824286 --- tensorflow/docs_src/install/install_sources.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tensorflow/docs_src/install/install_sources.md b/tensorflow/docs_src/install/install_sources.md index a7c0b6970a..8bb09f4021 100644 --- a/tensorflow/docs_src/install/install_sources.md +++ b/tensorflow/docs_src/install/install_sources.md @@ -168,6 +168,7 @@ If bazel is not installed on your system, install it now by following To build TensorFlow, you must install the following packages: * six +* mock * numpy, which is a numerical processing package that TensorFlow requires. * wheel, which enables you to manage Python compressed packages in the wheel (.whl) format. @@ -179,7 +180,7 @@ If you follow these instructions, you will not need to disable SIP. After installing pip, invoke the following commands: -
 $ sudo pip install six numpy wheel 
+
 $ sudo pip install six numpy wheel mock 
Note: These are just the minimum requirements to _build_ tensorflow. Installing the pip package will download additional packages required to _run_ it. If you -- GitLab From 9c161fa8e869dd8e982a0b38ee540f251f52c3ab Mon Sep 17 00:00:00 2001 From: Yuefeng Zhou Date: Tue, 7 Aug 2018 22:41:11 -0700 Subject: [PATCH 190/437] Support independet-worker mode in distribute coordinator. PiperOrigin-RevId: 207835757 --- tensorflow/python/distribute/BUILD | 2 +- .../distribute/distribute_coordinator.py | 269 ++++++++++---- .../distribute/distribute_coordinator_test.py | 336 ++++++++++++++++-- 3 files changed, 501 insertions(+), 106 deletions(-) diff --git a/tensorflow/python/distribute/BUILD b/tensorflow/python/distribute/BUILD index 2bd0b4320a..68d8b8d13b 100644 --- a/tensorflow/python/distribute/BUILD +++ b/tensorflow/python/distribute/BUILD @@ -22,7 +22,7 @@ py_library( py_test( name = "distribute_coordinator_test", - size = "small", + size = "large", srcs = ["distribute_coordinator_test.py"], srcs_version = "PY2AND3", tags = ["no_pip"], diff --git a/tensorflow/python/distribute/distribute_coordinator.py b/tensorflow/python/distribute/distribute_coordinator.py index dab1ed43ca..fc9ca4ac4a 100644 --- a/tensorflow/python/distribute/distribute_coordinator.py +++ b/tensorflow/python/distribute/distribute_coordinator.py @@ -32,6 +32,23 @@ class _TaskType(object): WORKER = "worker" CHIEF = "chief" EVALUATOR = "evaluator" + CLIENT = "client" + + +# TODO(yuefengz): support another mode where the client colocates with one +# worker. +class CoordinatorMode(object): + """Specify how distribute coordinator runs.""" + # The default mode where distribute coordinator will run as a standalone + # client and connects to remote servers for training. Each remote server can + # use the distribute coordinator binary with task_type set correctly which + # will then turn into standard servers. + SPLIT_CLIENT = 0 + + # The distribute coordinator runs on each worker. It will run a standard + # server on each worker and optionally run the `worker_fn` that is configured + # to talk to its standard server. + INDEPENDENT_WORKER = 1 _worker_context = threading.local() @@ -99,7 +116,6 @@ class _WorkerContext(object): cluster_spec, task_type, task_id, - between_graph=False, rpc_layer="grpc", worker_barrier=None): """Initialize the worker context object. @@ -108,27 +124,15 @@ class _WorkerContext(object): cluster_spec: a ClusterSpec object. It can be empty or None in the local training case. task_type: a string indicating the role of the corresponding task, such as - "worker" or "ps". It can be None if it is local training or - `between_graph` is False. + "worker" or "ps". It can be None if it is local training or in-graph + replicated training. task_id: an integer indicating id of the corresponding task. It can be - None if it is local training or `between_graph` is False. - between_graph: whether it is between-graph replication or not. + None if it is local training or in-graph replicated training. rpc_layer: optional string specifying the RPC protocol for communication with worker masters. If None or empty, hosts in the `cluster_spec` will be used directly. worker_barrier: optional, the barrier object for worker synchronization. - - Raises: - ValueError: if task_type or task_id is Node or empty and it is distributed - between-graph replicated training. """ - if cluster_spec and between_graph: - if not task_type or task_id is None: - raise ValueError("`task_type` and `task_id` must be set in the " - "distributed between-graph replicated training.") - if task_type not in cluster_spec.jobs: - raise ValueError("`task_type` %r not found in the `cluster_spec` %r" % - (task_type, cluster_spec)) self._cluster_spec = cluster_spec self._task_type = task_type self._task_id = task_id @@ -138,11 +142,16 @@ class _WorkerContext(object): self._num_workers = _get_num_workers(cluster_spec) self._is_chief_node = self._is_chief() + def _debug_message(self): + return "[cluster_spec: %r, task_type: %r, task_id: %r]" % ( + self._cluster_spec, self.task_type, self.task_id) + def __enter__(self): old_context = get_current_worker_context() if old_context: raise ValueError( - "You cannot run distribute coordinator in a `worker_fn`.") + "You cannot run distribute coordinator in a `worker_fn`.\t" + + self._debug_message()) _worker_context.current = self def __exit__(self, unused_exception_type, unused_exception_value, @@ -159,7 +168,6 @@ class _WorkerContext(object): # case we use the chief or first worker's master target. if not self._task_type: if _TaskType.CHIEF in self._cluster_spec.jobs: - assert not self.between_graph task_type = _TaskType.CHIEF task_id = 0 else: @@ -177,7 +185,8 @@ class _WorkerContext(object): def _is_chief(self): """Return whether the task is the chief worker.""" - if (not self._cluster_spec or self._task_type in [_TaskType.CHIEF, None]): + if (not self._cluster_spec or + self._task_type in [_TaskType.CHIEF, _TaskType.EVALUATOR, None]): return True # If not local and chief not in the cluster_spec, use the first worker as @@ -194,14 +203,19 @@ class _WorkerContext(object): ValueError: if `worker_barrier` is not passed to the __init__ method. """ if not self._worker_barrier: - raise ValueError( - "`worker_barrier is not set in the worker context.`") + raise ValueError("`worker_barrier is not set in the worker context.` \t" + + self._debug_message()) self._worker_barrier.wait() + @property + def has_barrier(self): + """Whether the barrier is set or not.""" + return self._worker_barrier is not None + @property def distributed_mode(self): """Whether it is distributed training or not.""" - return bool(self._cluster_spec) + return bool(self._cluster_spec) and self._task_type != _TaskType.EVALUATOR @property def cluster_spec(self): @@ -234,24 +248,110 @@ class _WorkerContext(object): return self._num_workers -def _run(worker_fn, cluster_spec, task_type, task_id, between_graph, rpc_layer, - worker_barrier): - with _WorkerContext(cluster_spec, task_type, task_id, between_graph, - rpc_layer, worker_barrier): +def _run_single_worker(worker_fn, + cluster_spec, + task_type, + task_id, + rpc_layer, + worker_barrier=None): + """Runs a single worker by calling `worker_fn` under context.""" + with _WorkerContext( + cluster_spec, + task_type, + task_id, + rpc_layer=rpc_layer, + worker_barrier=worker_barrier): worker_fn() +def _run_std_server(cluster_spec=None, + task_type=None, + task_id=None, + session_config=None, + rpc_layer=None): + """Runs a standard server.""" + server = server_lib.Server( + cluster_spec, + job_name=task_type, + task_index=task_id, + config=session_config, + protocol=rpc_layer) + server.start() + return server + + +def _run_between_graph_client(worker_fn, cluster_spec, rpc_layer): + """Runs a standalone client for between-graph replication.""" + eval_thread = None + if _TaskType.EVALUATOR in cluster_spec.jobs: + eval_thread = threading.Thread( + target=_run_single_worker, + args=(worker_fn, cluster_spec, _TaskType.EVALUATOR, 0), + kwargs={ + "rpc_layer": rpc_layer, + }) + eval_thread.start() + + threads = [] + worker_barrier = _Barrier(_get_num_workers(cluster_spec)) + for task_type in [_TaskType.CHIEF, _TaskType.WORKER]: + for task_id in range(len(cluster_spec.as_dict().get(task_type, []))): + t = threading.Thread( + target=_run_single_worker, + args=(worker_fn, cluster_spec, task_type, task_id), + kwargs={ + "rpc_layer": rpc_layer, + "worker_barrier": worker_barrier + }) + t.start() + threads.append(t) + + # TODO(yuefengz): wrap threads into thread coordinator? + for t in threads: + t.join() + + # TODO(yuefengz): is it necessary to join eval thread? + if eval_thread: + eval_thread.join() + + +def _run_in_graph_client(worker_fn, cluster_spec, rpc_layer): + """Runs a standalone client for in-graph replication.""" + eval_thread = None + if _TaskType.EVALUATOR in cluster_spec.jobs: + eval_thread = threading.Thread( + target=_run_single_worker, + args=(worker_fn, cluster_spec, _TaskType.EVALUATOR, 0), + kwargs={ + "rpc_layer": rpc_layer, + }) + eval_thread.start() + + _run_single_worker(worker_fn, cluster_spec, None, None, rpc_layer) + if eval_thread: + eval_thread.join() + + +# TODO(yuefengz): propagate cluster_spec in the SPLIT_CLIENT mode. +# TODO(yuefengz): we may need a smart way to figure out whether the current task +# is the special task when we support cluster_spec propagation. def run_distribute_coordinator(worker_fn, + mode=CoordinatorMode.SPLIT_CLIENT, cluster_spec=None, + task_type=None, + task_id=None, between_graph=False, - rpc_layer=None): - """Run the coordinator for distributed TensorFlow. - - This function runs a unified and split coordinator for distributed TensorFlow. - Given a `cluster_spec` specifying server addresses and their roles in a - cluster, this coordinator will figure out how to set them up, give the - underlying function the right targets for master sessions and coordinate their - training. + rpc_layer="grpc"): + """Runs the coordinator for distributed TensorFlow. + + This function runs a split coordinator for distributed TensorFlow in its + default mode, i.e the SPLIT_CLIENT mode. Given a `cluster_spec` specifying + server addresses and their roles in a cluster, this coordinator will figure + out how to set them up, give the underlying function the right targets for + master sessions via a scope object and coordinate their training. The cluster + consisting of standard servers needs to be brought up either with the standard + server binary or with a binary running distribute coordinator with `task_type` + set to non-client type which will then turn into standard servers. In addition to be the distribute coordinator, this is also the source of configurations for each job in the distributed training. As there are multiple @@ -261,9 +361,14 @@ def run_distribute_coordinator(worker_fn, In the between-graph replicated training, this coordinator will create multiple threads and each calls the `worker_fn` which is supposed to create - its own graph and connect to one worker master given by its coordinator - context. In the in-graph replicated training, it has only one thread calling - this `worker_fn`. + its own graph and connect to one worker master given by its context object. In + the in-graph replicated training, it has only one thread calling this + `worker_fn`. + + Another mode is the INDEPENDENT_WORKER mode where each server runs a + distribute coordinator which will start a standard server and optionally runs + `worker_fn` depending whether it is between-graph training or in-graph + replicated training. The `worker_fn` defines the training logic and is called under a its own worker context which can be accessed to via `get_current_worker_context`. A @@ -274,13 +379,14 @@ def run_distribute_coordinator(worker_fn, `worker_fn` or to define different environment variables for different `worker_fn`s. - The `worker_fn` for the between-graph replication is defined as if there are - only one worker corresponding to the `worker_fn` and possibly ps jobs. It - assigns variables to parameter servers and all other operations to that - worker. In the in-graph replication case, the `worker_fn` has to define - operations for all worker jobs. Using a distribution strategy can simplify the - `worker_fn` by not having to worry about the replication and device assignment - of variables and operations. + The `worker_fn` for the between-graph replication is defined as if there is + only one worker corresponding to the `worker_fn` and possibly ps jobs. For + example, when training with parameter servers, it assigns variables to + parameter servers and all other operations to that worker. In the in-graph + replication case, the `worker_fn` has to define operations for all worker + jobs. Using a distribution strategy can simplify the `worker_fn` by not having + to worry about the replication and device assignment of variables and + operations. This method is intended to be invoked by high-level APIs so that users don't have to explictly call it to run this coordinator. For those who don't use @@ -309,8 +415,11 @@ def run_distribute_coordinator(worker_fn, Args: worker_fn: the function to be called and given the access to a coordinator context object. + mode: in which mode this distribute coordinator runs. cluster_spec: a dict, ClusterDef or ClusterSpec specifying servers and roles in a cluster. If not set or empty, fall back to local training. + task_type: the current task type, optional if this is a client. + task_id: the current task id, optional if this is a client. between_graph: a boolean. It is only useful when `cluster_spec` is set and not empty. If true, it will use between-graph replicated training; otherwise it will use in-graph replicated training. @@ -320,9 +429,13 @@ def run_distribute_coordinator(worker_fn, ValueError: if `cluster_spec` is supplied but not a dict or a ClusterDef or a ClusterSpec. """ + tf_config = json.loads(os.environ.get("TF_CONFIG", "{}")) if not cluster_spec: - tf_config = json.loads(os.environ.get("TF_CONFIG", "{}")) cluster_spec = tf_config.get("cluster", {}) + task_env = tf_config.get("task", {}) + if task_env: + task_type = task_env.get("type", task_type) + task_id = int(task_env.get("index", task_id)) if cluster_spec: if isinstance(cluster_spec, (dict, cluster_pb2.ClusterDef)): @@ -333,29 +446,45 @@ def run_distribute_coordinator(worker_fn, "`tf.train.ClusterDef` object") # TODO(yuefengz): validate cluster_spec. - threads = [] - if cluster_spec and _TaskType.EVALUATOR in cluster_spec.jobs: - t = threading.Thread( - target=_run, - args=(worker_fn, cluster_spec, _TaskType.EVALUATOR, 0, between_graph, - rpc_layer, None)) - t.start() - threads.append(t) - - if cluster_spec and between_graph: - worker_barrier = _Barrier(_get_num_workers(cluster_spec)) - for task_type in [_TaskType.CHIEF, _TaskType.WORKER]: - for task_id in range(len(cluster_spec.as_dict().get(task_type, []))): - t = threading.Thread( - target=_run, - args=(worker_fn, cluster_spec, task_type, task_id, between_graph, - rpc_layer, worker_barrier)) - t.start() - threads.append(t) + if not cluster_spec: + # `mode` is ignored in the local case. + _run_single_worker(worker_fn, None, None, None, rpc_layer) + elif mode == CoordinatorMode.SPLIT_CLIENT: + # The client must know the cluster but servers in the cluster don't have to + # know the client. + if task_type in [_TaskType.CLIENT, None]: + if between_graph: + _run_between_graph_client(worker_fn, cluster_spec, rpc_layer) + else: + _run_in_graph_client(worker_fn, cluster_spec, rpc_layer) + else: + # If not a client job, run the standard server. + server = _run_std_server( + cluster_spec=cluster_spec, task_type=task_type, task_id=task_id) + server.join() else: - # Local or in-graph replicated training. - _run(worker_fn, cluster_spec, None, None, between_graph, rpc_layer, None) - - # TODO(yuefengz): wrapper threads into thread coordinator? - for t in threads: - t.join() + if mode != CoordinatorMode.INDEPENDENT_WORKER: + raise ValueError("Unexpected coordinator mode: %r" % mode) + + # Every one starts a standard server. + server = _run_std_server( + cluster_spec=cluster_spec, task_type=task_type, task_id=task_id) + + if task_type in [_TaskType.CHIEF, _TaskType.WORKER]: + if between_graph: + # All jobs run `worker_fn` if between-graph. + _run_single_worker(worker_fn, cluster_spec, task_type, task_id, + rpc_layer) + else: + # Only one node runs `worker_fn` if in-graph. + context = _WorkerContext(cluster_spec, task_type, task_id, rpc_layer) + if context.is_chief: + _run_single_worker(worker_fn, cluster_spec, None, None, rpc_layer) + else: + server.join() + elif task_type == _TaskType.EVALUATOR: + _run_single_worker(worker_fn, cluster_spec, task_type, task_id, rpc_layer) + else: + if task_type != _TaskType.PS: + raise ValueError("Unexpected task_type: %r" % task_type) + server.join() diff --git a/tensorflow/python/distribute/distribute_coordinator_test.py b/tensorflow/python/distribute/distribute_coordinator_test.py index d7ffeb56a5..319c29ba2f 100644 --- a/tensorflow/python/distribute/distribute_coordinator_test.py +++ b/tensorflow/python/distribute/distribute_coordinator_test.py @@ -20,9 +20,20 @@ from __future__ import print_function import contextlib import copy +import os +import sys import threading import six +# pylint: disable=invalid-name +_portpicker_import_error = None +try: + import portpicker # pylint: disable=g-import-not-at-top +except ImportError as _error: + _portpicker_import_error = _error + portpicker = None +# pylint: enable=invalid-name + from tensorflow.core.protobuf import config_pb2 from tensorflow.python.client import session from tensorflow.python.distribute import distribute_coordinator @@ -39,6 +50,11 @@ WORKER = distribute_coordinator._TaskType.WORKER PS = distribute_coordinator._TaskType.PS EVALUATOR = distribute_coordinator._TaskType.EVALUATOR +SPLIT_CLIENT = distribute_coordinator.CoordinatorMode.SPLIT_CLIENT +INDEPENDENT_WORKER = distribute_coordinator.CoordinatorMode.INDEPENDENT_WORKER + +RUN_STD_SERVER_METHOD = "tensorflow.python.distribute.distribute_coordinator._run_std_server" + NUM_WORKERS = 3 NUM_PS = 2 @@ -50,7 +66,29 @@ def _bytes_to_str(maybe_bytes): return str(maybe_bytes, "utf-8") -class DistributeCoordinatorTest(test.TestCase): +def _strip_protocol(target): + # cluster_spec expects "host:port" strings. + if "//" in target: + return target.split("//")[1] + else: + return target + + +class MockServer(object): + + def __init__(self): + self._joined = False + + def join(self): + assert not self._joined + self._joined = True + + @property + def joined(self): + return self._joined + + +class DistributeCoordinatorTestBase(test.TestCase): @classmethod def setUpClass(cls): @@ -60,14 +98,18 @@ class DistributeCoordinatorTest(test.TestCase): cls._workers, cls._ps = test_util.create_local_cluster( NUM_WORKERS, num_ps=NUM_PS) cls._cluster_spec = { - WORKER: [_bytes_to_str(w.target) for w in cls._workers], - PS: [_bytes_to_str(ps.target) for ps in cls._ps] + WORKER: [ + _strip_protocol(_bytes_to_str(w.target)) for w in cls._workers + ], + PS: [_strip_protocol(_bytes_to_str(ps.target)) for ps in cls._ps] } def setUp(self): self._result_correct = 0 self._lock = threading.Lock() self._worker_context = {} + self._std_servers = {} + self._barrier = distribute_coordinator._Barrier(NUM_WORKERS) @contextlib.contextmanager def _test_session(self, target): @@ -76,6 +118,30 @@ class DistributeCoordinatorTest(test.TestCase): with session.Session(graph=None, config=config, target=target) as sess: yield sess + def _create_cluster_spec(self, + has_chief=False, + num_workers=1, + num_ps=0, + has_eval=False): + if _portpicker_import_error: + raise _portpicker_import_error # pylint: disable=raising-bad-type + + cluster_spec = {} + if has_chief: + cluster_spec[CHIEF] = ["localhost:%s" % portpicker.pick_unused_port()] + if num_workers: + cluster_spec[WORKER] = [ + "localhost:%s" % portpicker.pick_unused_port() + for _ in range(num_workers) + ] + if num_ps: + cluster_spec[PS] = [ + "localhost:%s" % portpicker.pick_unused_port() for _ in range(num_ps) + ] + if has_eval: + cluster_spec[EVALUATOR] = ["localhost:%s" % portpicker.pick_unused_port()] + return cluster_spec + def _in_graph_worker_fn(self): context = distribute_coordinator.get_current_worker_context() self.assertTrue(context is not None) @@ -98,13 +164,28 @@ class DistributeCoordinatorTest(test.TestCase): if result_value == expected: self._result_correct += 1 - def testInGraph(self): - """Test it runs in-graph replicated training correctly.""" - distribute_coordinator.run_distribute_coordinator( - self._in_graph_worker_fn, - cluster_spec=self._cluster_spec, - between_graph=False) - self.assertEqual(self._result_correct, 1) + def _run_coordinator_in_thread(self, worker_fn, **kwargs): + t = threading.Thread( + target=distribute_coordinator.run_distribute_coordinator, + args=(worker_fn,), + kwargs=kwargs) + t.start() + return t + + def _run_multiple_coordinator_in_threads(self, worker_fn, cluster_spec, + **kwargs): + threads = {} + for task_type in cluster_spec.keys(): + threads[task_type] = [] + for task_id in range(len(cluster_spec[task_type])): + t = self._run_coordinator_in_thread( + worker_fn, + cluster_spec=cluster_spec, + task_type=task_type, + task_id=task_id, + **kwargs) + threads[task_type].append(t) + return threads def _between_graph_worker_fn(self): context = distribute_coordinator.get_current_worker_context() @@ -127,13 +208,23 @@ class DistributeCoordinatorTest(test.TestCase): variables.global_variables_initializer().run() # Synchronize workers after initializaton. - context.wait_for_other_workers() + if context.has_barrier: + context.wait_for_other_workers() + else: + while True: + uninit_vars = sess.run(variables.report_uninitialized_variables()) + # pylint: disable=g-explicit-length-test + if len(uninit_vars) == 0: + break sess.run(train_op) # Synchronize workers after one step to make sure they all have finished # training. - context.wait_for_other_workers() + if context.has_barrier: + context.wait_for_other_workers() + else: + self._barrier.wait() x_val, y_val = sess.run([x, y]) @@ -143,16 +234,6 @@ class DistributeCoordinatorTest(test.TestCase): with self._lock: self._result_correct += 1 - def testBetweenGraph(self): - """Test it runs between-graph replicated training correctly.""" - distribute_coordinator.run_distribute_coordinator( - self._between_graph_worker_fn, - cluster_spec=self._cluster_spec, - between_graph=True) - - # Each finished worker will increment self._result_correct. - self.assertEqual(self._result_correct, NUM_WORKERS) - def _dump_worker_context(self): """Dumps the propoerties of each worker context. @@ -174,6 +255,45 @@ class DistributeCoordinatorTest(test.TestCase): context.is_chief, context.distributed_mode) + def _run_mock_std_server(self, + session_config=None, + cluster_spec=None, + task_type=None, + task_id=None, + rpc_layer=None): + task_type = str(task_type) + task_id = task_id or 0 + with self._lock: + if task_type not in self._std_servers: + self._std_servers[task_type] = [] + while len(self._std_servers[task_type]) <= task_id: + self._std_servers[task_type].append(None) + + server = MockServer() + self._std_servers[task_type][task_id] = server + return server + + +class DistributeCoordinatorTestSplitMode(DistributeCoordinatorTestBase): + + def testInGraphSplitMode(self): + """Test it runs in-graph replication in split client mode.""" + distribute_coordinator.run_distribute_coordinator( + self._in_graph_worker_fn, + cluster_spec=self._cluster_spec, + between_graph=False) + self.assertEqual(self._result_correct, 1) + + def testBetweenGraph(self): + """Test it runs between-graph replication in split client mode.""" + distribute_coordinator.run_distribute_coordinator( + self._between_graph_worker_fn, + cluster_spec=self._cluster_spec, + between_graph=True) + + # Each finished worker will increment self._result_correct. + self.assertEqual(self._result_correct, NUM_WORKERS) + def testBetweenGraphContext(self): # Dumps the task contexts to the self._worker_context dict. distribute_coordinator.run_distribute_coordinator( @@ -253,15 +373,15 @@ class DistributeCoordinatorTest(test.TestCase): # and distributed_mode. self.assertEqual(self._worker_context[CHIEF][0], ("grpc://fake_chief", 4, True, True)) - self.assertEqual(self._worker_context[WORKER][0], - ("grpc://" + _bytes_to_str(self._workers[0].target), - NUM_WORKERS + 1, False, True)) - self.assertEqual(self._worker_context[WORKER][1], - ("grpc://" + _bytes_to_str(self._workers[1].target), - NUM_WORKERS + 1, False, True)) - self.assertEqual(self._worker_context[WORKER][2], - ("grpc://" + _bytes_to_str(self._workers[2].target), - NUM_WORKERS + 1, False, True)) + self.assertEqual( + self._worker_context[WORKER][0], + (_bytes_to_str(self._workers[0].target), NUM_WORKERS + 1, False, True)) + self.assertEqual( + self._worker_context[WORKER][1], + (_bytes_to_str(self._workers[1].target), NUM_WORKERS + 1, False, True)) + self.assertEqual( + self._worker_context[WORKER][2], + (_bytes_to_str(self._workers[2].target), NUM_WORKERS + 1, False, True)) def testInGraphContextWithEval(self): # Adds a EVALUATOR job. @@ -272,7 +392,140 @@ class DistributeCoordinatorTest(test.TestCase): distribute_coordinator.run_distribute_coordinator( self._dump_worker_context, cluster_spec=cluster_spec, - between_graph=False) + between_graph=False, + rpc_layer=None) + + # There are one "None" task and one EVALUATOR task. + self.assertEqual(len(self._worker_context), 2) + self.assertTrue("None" in self._worker_context) + self.assertTrue(EVALUATOR in self._worker_context) + self.assertEqual(len(self._worker_context["None"]), 1) + self.assertEqual(len(self._worker_context[EVALUATOR]), 1) + + # Check whether each task has the right master_target, num_workers, is_chief + # and distributed_mode. + self.assertEqual(self._worker_context["None"][0], (_strip_protocol( + _bytes_to_str(self._workers[0].target)), 3, True, True)) + self.assertEqual(self._worker_context[EVALUATOR][0], + ("fake_evaluator", 3, True, False)) + + +class DistributeCoordinatorTestInpendentWorkerMode( + DistributeCoordinatorTestBase): + + def testInGraph(self): + cluster_spec = self._create_cluster_spec(num_workers=NUM_WORKERS) + threads = self._run_multiple_coordinator_in_threads( + self._in_graph_worker_fn, + cluster_spec, + between_graph=False, + mode=INDEPENDENT_WORKER) + threads[WORKER][0].join() + self.assertEqual(self._result_correct, 1) + + def testBetweenGraph(self): + cluster_spec = self._create_cluster_spec( + num_workers=NUM_WORKERS, num_ps=NUM_PS) + threads = self._run_multiple_coordinator_in_threads( + self._between_graph_worker_fn, + cluster_spec, + between_graph=True, + mode=INDEPENDENT_WORKER) + for task_id in range(NUM_WORKERS): + threads[WORKER][task_id].join() + + # Each finished worker will increment self._result_correct. + self.assertEqual(self._result_correct, NUM_WORKERS) + + def testBetweenGraphContext(self): + cluster_spec = self._create_cluster_spec(num_workers=NUM_WORKERS) + # Dumps the task contexts and std server arguments. + with test.mock.patch.object(distribute_coordinator, "_run_std_server", + self._run_mock_std_server): + threads = self._run_multiple_coordinator_in_threads( + self._dump_worker_context, + cluster_spec, + mode=INDEPENDENT_WORKER, + between_graph=True, + rpc_layer=None) + for task_id in range(NUM_WORKERS): + threads[WORKER][task_id].join() + + # There is only one type of task and three such tasks. + self.assertEqual(len(self._worker_context), 1) + self.assertTrue(WORKER in self._worker_context) + self.assertEqual(len(self._worker_context[WORKER]), NUM_WORKERS) + + # Check whether each task has the right master_target, num_workers, is_chief + # and distributed_mode. + self.assertEqual( + self._worker_context[WORKER][0], + (_bytes_to_str(cluster_spec[WORKER][0]), NUM_WORKERS, True, True)) + self.assertEqual( + self._worker_context[WORKER][1], + (_bytes_to_str(cluster_spec[WORKER][1]), NUM_WORKERS, False, True)) + self.assertEqual( + self._worker_context[WORKER][2], + (_bytes_to_str(cluster_spec[WORKER][2]), NUM_WORKERS, False, True)) + + # Make sure each worker runs a std server. + self.assertEqual(len(self._std_servers), 1) + self.assertTrue(WORKER in self._std_servers) + self.assertEqual(len(self._std_servers[WORKER]), 3) + self.assertFalse(self._std_servers[WORKER][0].joined) + self.assertFalse(self._std_servers[WORKER][1].joined) + self.assertFalse(self._std_servers[WORKER][2].joined) + + def testInGraphContext(self): + cluster_spec = self._create_cluster_spec(num_workers=NUM_WORKERS) + # Dumps the task contexts and std server arguments. + with test.mock.patch.object(distribute_coordinator, "_run_std_server", + self._run_mock_std_server): + threads = self._run_multiple_coordinator_in_threads( + self._dump_worker_context, + cluster_spec, + mode=INDEPENDENT_WORKER, + between_graph=False, + rpc_layer=None) + for task_id in range(NUM_WORKERS): + threads[WORKER][task_id].join() + + # There is only a "None" task in the dumped task context. + self.assertEqual(len(self._worker_context), 1) + self.assertTrue("None" in self._worker_context) + self.assertEqual(len(self._worker_context["None"]), 1) + + # Check whether each task has the right master_target, num_workers, is_chief + # and distributed_mode. + self.assertEqual( + self._worker_context["None"][0], + (_bytes_to_str(cluster_spec[WORKER][0]), NUM_WORKERS, True, True)) + + # Make sure each worker runs a std server. + self.assertEqual(len(self._std_servers), 1) + self.assertTrue(WORKER in self._std_servers) + self.assertEqual(len(self._std_servers[WORKER]), 3) + self.assertFalse(self._std_servers[WORKER][0].joined) + self.assertTrue(self._std_servers[WORKER][1].joined) + self.assertTrue(self._std_servers[WORKER][2].joined) + + def testInGraphContextWithEval(self): + # Adds a EVALUATOR job. + cluster_spec = self._create_cluster_spec( + num_workers=NUM_WORKERS, has_eval=True) + + # Dumps the task contexts and std server arguments. + with test.mock.patch.object(distribute_coordinator, "_run_std_server", + self._run_mock_std_server): + threads = self._run_multiple_coordinator_in_threads( + self._dump_worker_context, + cluster_spec, + mode=INDEPENDENT_WORKER, + between_graph=False, + rpc_layer=None) + for task_id in range(NUM_WORKERS): + threads[WORKER][task_id].join() + threads[EVALUATOR][0].join() # There are one "None" task and one EVALUATOR task. self.assertEqual(len(self._worker_context), 2) @@ -284,10 +537,23 @@ class DistributeCoordinatorTest(test.TestCase): # Check whether each task has the right master_target, num_workers, is_chief # and distributed_mode. self.assertEqual(self._worker_context["None"][0], - (_bytes_to_str(self._workers[0].target), 3, True, True)) + (_bytes_to_str(cluster_spec[WORKER][0]), 3, True, True)) self.assertEqual(self._worker_context[EVALUATOR][0], - ("fake_evaluator", 3, False, True)) + (cluster_spec[EVALUATOR][0], 3, True, False)) + + # Make sure each worker runs a std server. + self.assertEqual(len(self._std_servers), 2) + self.assertTrue(WORKER in self._std_servers) + self.assertTrue(EVALUATOR in self._std_servers) + self.assertEqual(len(self._std_servers[WORKER]), 3) + self.assertEqual(len(self._std_servers[EVALUATOR]), 1) + self.assertFalse(self._std_servers[WORKER][0].joined) + self.assertTrue(self._std_servers[WORKER][1].joined) + self.assertTrue(self._std_servers[WORKER][2].joined) + self.assertFalse(self._std_servers[EVALUATOR][0].joined) if __name__ == "__main__": - test.main() + # TODO(yuefengz): find a smart way to terminite std server threads. + with test.mock.patch.object(sys, "exit", os._exit): + test.main() -- GitLab From 2abc4f0fb7fa464a6aa97df91ec5cd1097197376 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Tue, 7 Aug 2018 23:40:52 -0700 Subject: [PATCH 191/437] FIX reduce_prod generate_examples_test. PiperOrigin-RevId: 207839564 --- tensorflow/contrib/lite/build_def.bzl | 2 +- .../contrib/lite/testing/generate_examples.py | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tensorflow/contrib/lite/build_def.bzl b/tensorflow/contrib/lite/build_def.bzl index 3f158850d9..81844756bc 100644 --- a/tensorflow/contrib/lite/build_def.bzl +++ b/tensorflow/contrib/lite/build_def.bzl @@ -265,7 +265,7 @@ def generated_test_models(): "prelu", "pow", "reduce_max", - #"reduce_prod", # disabled due to b/111823366 + "reduce_prod", "relu", "relu1", "relu6", diff --git a/tensorflow/contrib/lite/testing/generate_examples.py b/tensorflow/contrib/lite/testing/generate_examples.py index 3d1f8c07d2..a58924693e 100644 --- a/tensorflow/contrib/lite/testing/generate_examples.py +++ b/tensorflow/contrib/lite/testing/generate_examples.py @@ -824,11 +824,13 @@ def make_binary_op_tests(zip_path, binary_operator): make_zip_of_tests(zip_path, test_parameters, build_graph, build_inputs) -def make_reduce_tests(reduce_op): +def make_reduce_tests(reduce_op, min_value=-10, max_value=10): """Make a set of tests to do reduce operation. Args: reduce_op: TensorFlow reduce operation to test, i.e. `tf.reduce_mean`. + min_value: min value for created tensor data. + max_value: max value for created tensor data. Returns: a function representing the true generator with `reduce_op_in` curried. @@ -891,10 +893,12 @@ def make_reduce_tests(reduce_op): def build_inputs(parameters, sess, inputs, outputs): values = [ - create_tensor_data(parameters["input_dtype"], - parameters["input_shape"], - min_value=-10, - max_value=10)] + create_tensor_data( + parameters["input_dtype"], + parameters["input_shape"], + min_value=min_value, + max_value=max_value) + ] if not parameters["const_axis"]: values.append(np.array(parameters["axis"])) return values, sess.run(outputs, feed_dict=dict(zip(inputs, values))) @@ -916,7 +920,8 @@ def make_sum_tests(zip_path): def make_reduce_prod_tests(zip_path): """Make a set of tests to do prod.""" - return make_reduce_tests(tf.reduce_prod)(zip_path) + # set min max value to be -2, 2 to avoid overflow. + return make_reduce_tests(tf.reduce_prod, -2, 2)(zip_path) def make_reduce_max_tests(zip_path): -- GitLab From cf9d596881ea4ce2c95a5fe6bbac34e322a2b0ea Mon Sep 17 00:00:00 2001 From: Blake Hechtman Date: Wed, 8 Aug 2018 00:55:27 -0700 Subject: [PATCH 192/437] Add a run-only mode to hlo-test-base. PiperOrigin-RevId: 207845382 --- .../compiler/xla/tests/hlo_test_base.cc | 23 +++++++++++++++++++ tensorflow/compiler/xla/tests/hlo_test_base.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/tensorflow/compiler/xla/tests/hlo_test_base.cc b/tensorflow/compiler/xla/tests/hlo_test_base.cc index b662e83716..0dce1b22a3 100644 --- a/tensorflow/compiler/xla/tests/hlo_test_base.cc +++ b/tensorflow/compiler/xla/tests/hlo_test_base.cc @@ -233,6 +233,29 @@ StatusOr<::testing::AssertionResult> HloTestBase::RunAndCompareInternal( reference_preprocessor); } +::testing::AssertionResult HloTestBase::Run(const StringPiece hlo_string) { + auto module_or_status = + HloRunner::CreateModuleFromString(hlo_string, GetDebugOptionsForTest()); + if (!module_or_status.ok()) { + return ::testing::AssertionFailure() + << "Error while parsing HLO text format: " + << module_or_status.status().ToString(); + } + const auto& fake_arguments = + MakeFakeArguments(module_or_status.ValueOrDie().get()) + .ConsumeValueOrDie(); + std::vector fake_argument_ptrs; + c_transform( + fake_arguments, std::back_inserter(fake_argument_ptrs), + [](const std::unique_ptr& literal) { return literal.get(); }); + return test_runner_ + .Execute(std::move(module_or_status.ValueOrDie()), + fake_argument_ptrs, /*run_hlo_passes=*/true) + .ok() + ? ::testing::AssertionSuccess() + : ::testing::AssertionFailure(); +} + ::testing::AssertionResult HloTestBase::RunAndCompareFromFile( const string& filename, const tensorflow::gtl::optional& error, const std::function& reference_preprocessor) { diff --git a/tensorflow/compiler/xla/tests/hlo_test_base.h b/tensorflow/compiler/xla/tests/hlo_test_base.h index 66719b1460..bb55e562ad 100644 --- a/tensorflow/compiler/xla/tests/hlo_test_base.h +++ b/tensorflow/compiler/xla/tests/hlo_test_base.h @@ -166,6 +166,8 @@ class HloTestBase : public ::testing::Test { const tensorflow::gtl::optional& error, const std::function& reference_preprocessor = nullptr) TF_MUST_USE_RESULT; + ::testing::AssertionResult Run(const tensorflow::StringPiece hlo_string) + TF_MUST_USE_RESULT; ::testing::AssertionResult RunAndCompareFromFile( const string& filename, const tensorflow::gtl::optional& error, const std::function& reference_preprocessor = nullptr) -- GitLab From cedefe895e53bd38a624feb55f950cb4a3679de6 Mon Sep 17 00:00:00 2001 From: Tom Hennigan Date: Wed, 8 Aug 2018 01:19:28 -0700 Subject: [PATCH 193/437] Avoid copying collections 4x when calling templates. PiperOrigin-RevId: 207847764 --- tensorflow/python/ops/template.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tensorflow/python/ops/template.py b/tensorflow/python/ops/template.py index 161d9687d6..da9b64fe34 100644 --- a/tensorflow/python/ops/template.py +++ b/tensorflow/python/ops/template.py @@ -298,9 +298,10 @@ class Template(checkpointable.CheckpointableBase): def _call_func(self, args, kwargs): try: - vars_at_start = len(ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES)) + vars_at_start = len( + ops.get_collection_ref(ops.GraphKeys.GLOBAL_VARIABLES)) trainable_at_start = len( - ops.get_collection(ops.GraphKeys.TRAINABLE_VARIABLES)) + ops.get_collection_ref(ops.GraphKeys.TRAINABLE_VARIABLES)) if self._variables_created: result = self._func(*args, **kwargs) else: @@ -313,7 +314,7 @@ class Template(checkpointable.CheckpointableBase): # Variables were previously created, implying this is not the first # time the template has been called. Check to make sure that no new # trainable variables were created this time around. - trainable_variables = ops.get_collection( + trainable_variables = ops.get_collection_ref( ops.GraphKeys.TRAINABLE_VARIABLES) # If a variable that we intend to train is created as a side effect # of creating a template, then that is almost certainly an error. @@ -326,7 +327,7 @@ class Template(checkpointable.CheckpointableBase): # Non-trainable tracking variables are a legitimate reason why a new # variable would be created, but it is a relatively advanced use-case, # so log it. - variables = ops.get_collection(ops.GraphKeys.GLOBAL_VARIABLES) + variables = ops.get_collection_ref(ops.GraphKeys.GLOBAL_VARIABLES) if vars_at_start != len(variables): logging.info("New variables created when calling a template after " "the first time, perhaps you used tf.Variable when you " -- GitLab From de537122fbd1a49a44bd71e3a24c7b4d4d23c24c Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Wed, 8 Aug 2018 02:10:38 -0700 Subject: [PATCH 194/437] compat: Update forward compatibility horizon to 2018-08-08 PiperOrigin-RevId: 207852278 --- tensorflow/python/compat/compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/python/compat/compat.py b/tensorflow/python/compat/compat.py index b8ead6b778..4921f8b8b2 100644 --- a/tensorflow/python/compat/compat.py +++ b/tensorflow/python/compat/compat.py @@ -26,7 +26,7 @@ import datetime from tensorflow.python.util import tf_contextlib from tensorflow.python.util.tf_export import tf_export -_FORWARD_COMPATIBILITY_HORIZON = datetime.date(2018, 8, 7) +_FORWARD_COMPATIBILITY_HORIZON = datetime.date(2018, 8, 8) @tf_export("compat.forward_compatible") -- GitLab From 15f1fa14a3fd4b63e18539836f6036fef024fce7 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Wed, 8 Aug 2018 03:28:34 -0700 Subject: [PATCH 195/437] Remove tile shape from HloSharding The tile shape can be deduced based on the tile assignment and then HLO shape and by not storing it in the sharding we can give more flexibility to the compiler to decide the data layout. PiperOrigin-RevId: 207860794 --- .../compiler/xla/service/hlo_matchers_test.cc | 8 +- tensorflow/compiler/xla/service/hlo_parser.cc | 15 +-- .../compiler/xla/service/hlo_sharding.cc | 97 +++++++---------- .../compiler/xla/service/hlo_sharding.h | 56 +++------- .../compiler/xla/service/hlo_sharding_test.cc | 102 +++++------------- 5 files changed, 79 insertions(+), 199 deletions(-) diff --git a/tensorflow/compiler/xla/service/hlo_matchers_test.cc b/tensorflow/compiler/xla/service/hlo_matchers_test.cc index 7de59acc1e..7961aece54 100644 --- a/tensorflow/compiler/xla/service/hlo_matchers_test.cc +++ b/tensorflow/compiler/xla/service/hlo_matchers_test.cc @@ -157,9 +157,8 @@ TEST(HloMatchersTest, ShardingMatcher) { Array assignment({2}); assignment.SetValues({0, 1}); auto sharding = HloSharding::Tuple( - tuple_shape, - {HloSharding::Tile(ShapeUtil::MakeShape(F32, {5}), assignment), - HloSharding::AssignDevice(1), HloSharding::Replicate()}); + tuple_shape, {HloSharding::Tile(assignment), HloSharding::AssignDevice(1), + HloSharding::Replicate()}); p2->set_sharding(sharding); EXPECT_THAT(p0.get(), op::NoSharding()); @@ -172,8 +171,7 @@ TEST(HloMatchersTest, ShardingMatcher) { EXPECT_THAT( p2.get(), - op::Sharding( - "{{f32[5] devices=[2]0,1}, {maximal device=1}, {replicated}}")); + op::Sharding("{{devices=[2]0,1}, {maximal device=1}, {replicated}}")); EXPECT_THAT(Explain(p0.get(), op::Sharding(HloSharding::AssignDevice(1))), "%param.0 = f32[5]{0} parameter(0) has no sharding (expected: " diff --git a/tensorflow/compiler/xla/service/hlo_parser.cc b/tensorflow/compiler/xla/service/hlo_parser.cc index 93cc884e3a..de73b38dec 100644 --- a/tensorflow/compiler/xla/service/hlo_parser.cc +++ b/tensorflow/compiler/xla/service/hlo_parser.cc @@ -1383,7 +1383,6 @@ bool HloParser::ParseSingleSharding(OpSharding* sharding, bool replicated = false; std::vector devices; std::vector tile_assignment_dimensions; - Shape tile_shape; while (lexer_.GetKind() != TokKind::kRbrace) { switch (lexer_.GetKind()) { case TokKind::kw_maximal: @@ -1434,7 +1433,8 @@ bool HloParser::ParseSingleSharding(OpSharding* sharding, break; } case TokKind::kShape: - tile_shape = lexer_.GetShapeVal(); + // TODO(b/112302613): Left here for backward compatibility to ignore the + // removed tile shape data. lexer_.Lex(); break; case TokKind::kRbrace: @@ -1449,19 +1449,12 @@ bool HloParser::ParseSingleSharding(OpSharding* sharding, return Error(loc, "replicated shardings should not have any devices assigned"); } - if (!ShapeUtil::Equal(tile_shape, Shape())) { - return Error(loc, - "replicated shardings should not have any tile shape set"); - } sharding->set_type(OpSharding::Type::OpSharding_Type_REPLICATED); } else if (maximal) { if (devices.size() != 1) { return Error(loc, "maximal shardings should have exactly one device assigned"); } - if (!ShapeUtil::Equal(tile_shape, Shape())) { - return Error(loc, "maximal shardings should not have any tile shape set"); - } sharding->set_type(OpSharding::Type::OpSharding_Type_MAXIMAL); sharding->add_tile_assignment_devices(devices[0]); } else { @@ -1469,9 +1462,6 @@ bool HloParser::ParseSingleSharding(OpSharding* sharding, return Error( loc, "non-maximal shardings must have more than one device assigned"); } - if (ShapeUtil::Equal(tile_shape, Shape())) { - return Error(loc, "non-maximal shardings should have a tile shape set"); - } if (tile_assignment_dimensions.empty()) { return Error( loc, @@ -1479,7 +1469,6 @@ bool HloParser::ParseSingleSharding(OpSharding* sharding, "dimensions"); } sharding->set_type(OpSharding::Type::OpSharding_Type_OTHER); - *sharding->mutable_tile_shape() = tile_shape; for (tensorflow::int64 dim : tile_assignment_dimensions) { sharding->add_tile_assignment_dimensions(dim); } diff --git a/tensorflow/compiler/xla/service/hlo_sharding.cc b/tensorflow/compiler/xla/service/hlo_sharding.cc index 6399f6ef3c..879fb3bbab 100644 --- a/tensorflow/compiler/xla/service/hlo_sharding.cc +++ b/tensorflow/compiler/xla/service/hlo_sharding.cc @@ -31,12 +31,9 @@ HloSharding HloSharding::Tile1D(const Shape& input_shape, int64 num_tiles) { CHECK_EQ(1, ShapeUtil::Rank(input_shape)); CHECK_GT(num_tiles, 1); std::vector dimensions(1, num_tiles); - Shape tile_shape = input_shape; - auto& tile_dimension = (*tile_shape.mutable_dimensions())[0]; - tile_dimension = CeilOfRatio(static_cast(tile_dimension), num_tiles); Array assignment(dimensions); std::iota(assignment.begin(), assignment.end(), 0); - return HloSharding(tile_shape, assignment); + return HloSharding(assignment); } HloSharding HloSharding::Tuple(const ShapeTree& sub_shardings) { @@ -104,8 +101,7 @@ string HloSharding::ToString() const { return StrCat( "{maximal device=", static_cast(*tile_assignment_.begin()), "}"); } else { - return StrCat("{", ShapeUtil::HumanString(tile_shape_), " ", "devices=[", - Join(tile_assignment_.dimensions(), ","), "]", + return StrCat("{devices=[", Join(tile_assignment_.dimensions(), ","), "]", Join(tile_assignment_, ","), "}"); } } @@ -145,7 +141,6 @@ std::map HloSharding::UsedDevices(int64* count) const { } std::vector HloSharding::TileIndexForDevice(int64 device) const { - CHECK(!ShapeUtil::IsTuple(tile_shape_)); CHECK(!maximal_); CHECK(!IsTuple()); std::vector ret_index; @@ -165,32 +160,43 @@ int64 HloSharding::DeviceForTileIndex( if (maximal_) { return *tile_assignment_.begin(); } - CHECK_EQ(ShapeUtil::Rank(tile_shape_), tile_assignment_.dimensions().size()); return tile_assignment_(index); } -std::vector HloSharding::TileOffsetForDevice(int64 device) const { +std::vector HloSharding::TileOffsetForDevice(const Shape& shape, + int64 device) const { CHECK(!IsTuple()); - std::vector index = TileIndexForDevice(device); if (maximal_) { - // Index will always be all zeroes if we're maximal, and tile_shape_ is not - // valid. - return index; + return std::vector(shape.dimensions_size(), 0); } + + CHECK_EQ(shape.dimensions_size(), tile_assignment_.num_dimensions()); + std::vector index = TileIndexForDevice(device); for (int64 i = 0; i < index.size(); ++i) { - index[i] *= tile_shape_.dimensions(i); + const int64 shape_dim = shape.dimensions(i); + index[i] = std::min( + index[i] * CeilOfRatio(shape_dim, tile_assignment_.dim(i)), shape_dim); } return index; } -std::vector HloSharding::TileLimitForDevice(int64 device) const { +std::vector HloSharding::TileLimitForDevice(const Shape& shape, + int64 device) const { CHECK(!IsTuple()); - CHECK(!maximal_); // Maximal shardings do not have a valid tile shape. + if (maximal_) { + return std::vector(shape.dimensions().begin(), + shape.dimensions().end()); + } + + CHECK_EQ(shape.dimensions_size(), tile_assignment_.num_dimensions()); std::vector index = TileIndexForDevice(device); for (int64 i = 0; i < index.size(); ++i) { - index[i] = (index[i] + 1) * tile_shape_.dimensions(i); + const int64 shape_dim = shape.dimensions(i); + index[i] = std::min( + (index[i] + 1) * CeilOfRatio(shape_dim, tile_assignment_.dim(i)), + shape_dim); } return index; } @@ -336,11 +342,12 @@ Status HloSharding::ValidateNonTuple(const Shape& shape, return Status::OK(); } - // The tile rank must be the same as the input rank. - if (ShapeUtil::Rank(shape) != ShapeUtil::Rank(tile_shape_)) { + // The tile assignment tensor must have the same rank as the input. + if (ShapeUtil::Rank(shape) != tile_assignment_.num_dimensions()) { return tensorflow::errors::InvalidArgument( - "Tile rank is different to the input rank. sharding=", ToString(), - ", input_shape=", ShapeUtil::HumanString(shape)); + "Number of tile assignment dimensions is different to the input rank. " + "sharding=", + ToString(), ", input_shape=", ShapeUtil::HumanString(shape)); } // The correct constructor have to be used to create tile maximal shardings. @@ -350,20 +357,6 @@ Status HloSharding::ValidateNonTuple(const Shape& shape, "sharding was intended, use HloSharding::Replicated(). If a device " "placement was intended, use HloSharding::AssignDevice()"); } - - // The tile assignment tensor must contain enough element to cover the full - // shape with tiles of the specified size. - for (int64 i = 0, e = tile_assignment_.dimensions().size(); i != e; ++i) { - int64 total_tile_size = tile_assignment_.dim(i) * tile_shape_.dimensions(i); - if (shape.dimensions(i) > total_tile_size) { - return tensorflow::errors::InvalidArgument( - StrCat("Tile assignment tensor has too few element to cover the full " - "shape. Dimension ", - i, ", shape ", shape.dimensions(i), ", total size ", - total_tile_size)); - } - } - return Status::OK(); } @@ -393,7 +386,7 @@ Status HloSharding::ValidateNonTuple(const Shape& shape, proto.tile_assignment_dimensions().end())); std::copy(proto.tile_assignment_devices().begin(), proto.tile_assignment_devices().end(), tile_assignment.begin()); - return HloSharding(proto.tile_shape(), tile_assignment); + return HloSharding(tile_assignment); } OpSharding HloSharding::ToProto() const { @@ -407,7 +400,6 @@ OpSharding HloSharding::ToProto() const { return result; } - *result.mutable_tile_shape() = tile_shape_; for (int64 dim : tile_assignment_.dimensions()) { result.add_tile_assignment_dimensions(dim); } @@ -424,30 +416,16 @@ OpSharding HloSharding::ToProto() const { return result; } -HloSharding HloSharding::TransformShardedTileShape( - const Shape& new_shape, - const std::function& transform) const { - CHECK(!IsTuple()); +Shape HloSharding::TileShape(const Shape& shape) const { if (IsTileMaximal()) { - return *this; + return shape; } - CHECK_EQ(ShapeUtil::Rank(new_shape), ShapeUtil::Rank(tile_shape())); - Shape new_tile_shape; - new_tile_shape.set_element_type(tile_shape().element_type()); - for (int64 i = 0; i < ShapeUtil::Rank(new_shape); ++i) { - int64 dim; - if (tile_assignment().dim(i) == 1) { - dim = new_shape.dimensions(i); - } else if (transform) { - dim = transform(i, tile_shape().dimensions(i)); - } else { - dim = tile_shape().dimensions(i); - } - new_tile_shape.add_dimensions(dim); + Shape result_shape = shape; + for (int64 i = 0; i < shape.dimensions_size(); ++i) { + (*result_shape.mutable_dimensions())[i] = + CeilOfRatio(shape.dimensions(i), tile_assignment_.dim(i)); } - TF_CHECK_OK( - LayoutUtil::CopyLayoutBetweenShapes(tile_shape_, &new_tile_shape)); - return HloSharding::Tile(new_tile_shape, tile_assignment()); + return result_shape; } HloSharding HloSharding::GetSubSharding(const Shape& shape, @@ -489,9 +467,6 @@ size_t HloSharding::Hash() const { for (uint32 v : tile_assignment_) { h = tensorflow::Hash64Combine(h, std::hash{}(v)); } - for (uint32 v : tile_shape_.dimensions()) { - h = tensorflow::Hash64Combine(h, std::hash{}(v)); - } return h; } diff --git a/tensorflow/compiler/xla/service/hlo_sharding.h b/tensorflow/compiler/xla/service/hlo_sharding.h index 28575c0e75..894783e5d1 100644 --- a/tensorflow/compiler/xla/service/hlo_sharding.h +++ b/tensorflow/compiler/xla/service/hlo_sharding.h @@ -48,22 +48,10 @@ class HloSharding { // the input shape (one tile) assigned to a single device. static HloSharding AssignDevice(int64 device_id); - // Creates a new sharding which splits a shape into tiles each with shape - // `tile_shape`. Each tile is assigned to one device, which is specified by - // `tile_assignment`. Any tensor not a multiple of the tile size in any - // dimension is implicitly padded to the tile size. - // - // e.g. Tile({2, 2}, {0, 1}) on a tensor of shape {3, 2} would look like: - // 2 1 padding - // <------><-> - // +----+----+ - // | 0 | 1 | - // +----+----+ - // - // Split into two tiles, one of which is implicitly padded by one. - static HloSharding Tile(const Shape& tile_shape, - const Array& tile_assignment) { - return HloSharding(tile_shape, tile_assignment); + // Creates a new sharding which splits a shape into tiles amongst the devices + // specified by `tile_assignment`. + static HloSharding Tile(const Array& tile_assignment) { + return HloSharding(tile_assignment); } // Creates a new sharding which splits a one-dimensional input shape into @@ -146,17 +134,18 @@ class HloSharding { // REQUIRES: !IsTuple() int64 DeviceForTileIndex(tensorflow::gtl::ArraySlice index) const; - // Given a device ID, returns the offset within the input space of the + // Given a device ID, returns the offset within the specified shape of the // tile that should be executed on the given core. This returns the lower // extent of the tile in the input space. // REQUIRES: !IsTuple() - std::vector TileOffsetForDevice(int64 device) const; + std::vector TileOffsetForDevice(const Shape& shape, + int64 device) const; - // Given a device ID, returns the limit within the input space of the + // Given a device ID, returns the limit within the specified shape of the // tile that should be executed on the given core. This returns the upper // extent of the tile in the input space. // REQUIRES: !IsTuple() - std::vector TileLimitForDevice(int64 device) const; + std::vector TileLimitForDevice(const Shape& shape, int64 device) const; // Returns the single device this op operates on. If the sharding does not // span a single device, the return value will be empty. @@ -197,7 +186,6 @@ class HloSharding { bool operator==(const HloSharding& other) const { return replicated_ == other.replicated_ && maximal_ == other.maximal_ && - ShapeUtil::Compatible(tile_shape_, other.tile_shape_) && tile_assignment_ == other.tile_assignment_ && tuple_elements_ == other.tuple_elements_; } @@ -211,9 +199,6 @@ class HloSharding { } }; - // Gets the tile shape. - // REQUIRES: !IsTileMaximal() && !IsTuple() - const Shape& tile_shape() const { return tile_shape_; } // Gets the tile assignment tensor. // REQUIRES: !IsReplicated() && !IsTuple() const Array& tile_assignment() const { return tile_assignment_; } @@ -225,25 +210,15 @@ class HloSharding { return tuple_elements_; } - // Return a new sharding that can apply to the given new shape. - // If this sharding is tile-maximal, the returned sharding will be the same as - // this sharding. If this sharding is not tile-maximal, the returned - // sharding's tile size will differ: - // - Non-sharded dimensions will be adapted to be the same as `new_shape`; - // tile_dimension(i) = new_shape.dimensions(i); - // - Sharded dimensions will be kept the same unless `transform` is supplied - // in which case tile_dimension(i) = transform(i, tile_dimension(i)); - // REQUIRES: !IsTuple(). - HloSharding TransformShardedTileShape( - const Shape& new_shape, - const std::function& transform = nullptr) const; + // Gets the tile shape. + // REQUIRES: !IsTuple() + Shape TileShape(const Shape& shape) const; private: HloSharding() : replicated_(true), maximal_(true), tuple_(false), - tile_shape_(), tile_assignment_({0}) {} // device_id values: // -2: magic number to mean unassigned device, used by spatial partitioning @@ -255,15 +230,13 @@ class HloSharding { : replicated_(false), maximal_(true), tuple_(false), - tile_shape_(), tile_assignment_({1}, device_id) {} - HloSharding(const Shape& tile_shape, const Array& tile_assignment) + explicit HloSharding(const Array& tile_assignment) : replicated_(false), maximal_(false), tuple_(false), - tile_shape_(tile_shape), tile_assignment_(tile_assignment) {} - HloSharding(const std::vector& tuple_shardings) + explicit HloSharding(const std::vector& tuple_shardings) : replicated_(false), maximal_(false), tuple_(true), @@ -286,7 +259,6 @@ class HloSharding { bool replicated_; bool maximal_; bool tuple_; - Shape tile_shape_; Array tile_assignment_; // Only non-empty when tuple_ is true, but because empty tuples are allowed // may also be empty even then. This is a flattened list of all the leaf diff --git a/tensorflow/compiler/xla/service/hlo_sharding_test.cc b/tensorflow/compiler/xla/service/hlo_sharding_test.cc index aebda562d3..45fc300fca 100644 --- a/tensorflow/compiler/xla/service/hlo_sharding_test.cc +++ b/tensorflow/compiler/xla/service/hlo_sharding_test.cc @@ -39,7 +39,6 @@ Array MakeArray(tensorflow::gtl::ArraySlice dimensions, class HloShardingTest : public HloTestBase {}; TEST_F(HloShardingTest, Replicate) { - Shape tile_shape = ShapeUtil::MakeShape(U32, {4}); HloSharding sharding = HloSharding::Replicate(); EXPECT_TRUE(sharding.IsReplicated()); EXPECT_TRUE(sharding.IsTileMaximal()); @@ -79,37 +78,22 @@ TEST_F(HloShardingTest, DevicePlacement) { TEST_F(HloShardingTest, Tile) { { // Test should fail because of a duplicate tile assignment. - Shape tile_shape = ShapeUtil::MakeShape(U32, {2, 3}); - HloSharding sharding = - HloSharding::Tile(tile_shape, MakeArray({2, 2}, {0, 0, 2, 3})); + HloSharding sharding = HloSharding::Tile(MakeArray({2, 2}, {0, 0, 2, 3})); EXPECT_IS_NOT_OK(sharding.Validate(ShapeUtil::MakeShape(F32, {4, 6}), /*num_devices=*/4)); } { // Test should fail because of more devices used then `num_device`. - Shape tile_shape = ShapeUtil::MakeShape(U32, {2, 3}); - HloSharding sharding = - HloSharding::Tile(tile_shape, MakeArray({2, 2}, {0, 1, 2, 3})); + HloSharding sharding = HloSharding::Tile(MakeArray({2, 2}, {0, 1, 2, 3})); EXPECT_IS_NOT_OK(sharding.Validate(ShapeUtil::MakeShape(U32, {4, 6}), /*num_devices=*/2)); } - { - // Test should fail because the total tiled size in dimension 0 is 4 but we - // have 6 elements along that dimensions. - Shape tile_shape = ShapeUtil::MakeShape(U32, {2, 3}); - HloSharding sharding = - HloSharding::Tile(tile_shape, MakeArray({2, 2}, {0, 1, 2, 3})); - EXPECT_IS_NOT_OK(sharding.Validate(ShapeUtil::MakeShape(F32, {6, 3}), - /*num_devices=*/4)); - } - { // Test should pass. - Shape tile_shape = ShapeUtil::MakeShape(U32, {2, 3}); - HloSharding sharding = - HloSharding::Tile(tile_shape, MakeArray({2, 2}, {0, 3, 2, 1})); + Shape shape = ShapeUtil::MakeShape(U32, {4, 5}); + HloSharding sharding = HloSharding::Tile(MakeArray({2, 2}, {0, 3, 2, 1})); EXPECT_IS_OK(sharding.Validate(ShapeUtil::MakeShape(F32, {3, 5}), /*num_devices=*/5)); @@ -118,10 +102,14 @@ TEST_F(HloShardingTest, Tile) { EXPECT_EQ(2, sharding.DeviceForTileIndex({1, 0})); EXPECT_EQ(1, sharding.DeviceForTileIndex({1, 1})); - EXPECT_EQ(sharding.TileOffsetForDevice(0), (std::vector{0, 0})); - EXPECT_EQ(sharding.TileOffsetForDevice(3), (std::vector{0, 3})); - EXPECT_EQ(sharding.TileOffsetForDevice(2), (std::vector{2, 0})); - EXPECT_EQ(sharding.TileOffsetForDevice(1), (std::vector{2, 3})); + EXPECT_EQ(sharding.TileOffsetForDevice(shape, 0), + (std::vector{0, 0})); + EXPECT_EQ(sharding.TileOffsetForDevice(shape, 3), + (std::vector{0, 3})); + EXPECT_EQ(sharding.TileOffsetForDevice(shape, 2), + (std::vector{2, 0})); + EXPECT_EQ(sharding.TileOffsetForDevice(shape, 1), + (std::vector{2, 3})); EXPECT_FALSE(sharding.HasUniqueDevice()); } @@ -135,8 +123,7 @@ TEST_F(HloShardingTest, NestedTuple) { ShapeUtil::MakeShape(F32, {4, 6}), }); - HloSharding tiled_sharding = HloSharding::Tile( - ShapeUtil::MakeShape(F32, {4, 3}), Array({{0, 1}})); + HloSharding tiled_sharding = HloSharding::Tile(Array({{0, 1}})); OpSharding proto; proto.set_type(OpSharding::Type::OpSharding_Type_TUPLE); *proto.add_tuple_shardings() = HloSharding::Replicate().ToProto(); @@ -187,32 +174,11 @@ TEST_F(HloShardingTest, Hash) { } { - Shape tile_shape = ShapeUtil::MakeShape(U32, {2, 3}); - HloSharding sharding1 = - HloSharding::Tile(tile_shape, MakeArray({2, 2}, {0, 3, 2, 1})); - HloSharding sharding2 = HloSharding::Tile(ShapeUtil::MakeShape(U32, {2, 3}), - MakeArray({2, 2}, {0, 3, 2, 1})); - EXPECT_TRUE(hash_compare_equal(sharding1, sharding2)); - } - - { - Shape tile_shape = ShapeUtil::MakeShape(U32, {2, 3}); - HloSharding sharding1 = - HloSharding::Tile(tile_shape, MakeArray({2, 2}, {0, 3, 2, 1})); - HloSharding sharding2 = HloSharding::Tile(ShapeUtil::MakeShape(U32, {2, 3}), - MakeArray({2, 2}, {0, 3, 2, 1})); + HloSharding sharding1 = HloSharding::Tile(MakeArray({2, 2}, {0, 3, 2, 1})); + HloSharding sharding2 = HloSharding::Tile(MakeArray({2, 2}, {0, 3, 2, 1})); EXPECT_TRUE(hash_compare_equal(sharding1, sharding2)); } - { - Shape tile_shape = ShapeUtil::MakeShape(U32, {2, 3}); - HloSharding sharding1 = - HloSharding::Tile(tile_shape, MakeArray({2, 2}, {0, 3, 2, 1})); - HloSharding sharding2 = HloSharding::Tile(ShapeUtil::MakeShape(U32, {2, 3}), - MakeArray({2, 2}, {0, 3, 1, 2})); - EXPECT_FALSE(hash_compare_equal(sharding1, sharding2)); - } - HloSharding default_sharding = HloSharding::Replicate(); { ShapeTree shape_tree(ShapeUtil::MakeTupleShape({}), @@ -259,19 +225,6 @@ TEST_F(HloShardingTest, Hash) { } } -TEST_F(HloShardingTest, TransformShardedTileShapeTest) { - HloSharding sharding = - HloSharding::Tile(ShapeUtil::MakeShape(F32, {3, 5, 7, 11}), - Array4D({{{{0, 1}, {2, 3}}}})); - HloSharding result = sharding.TransformShardedTileShape( - ShapeUtil::MakeShape(F32, {13, 15, 17, 19}), - [](int dim, int value) { return dim * 111; }); - HloSharding expected = - HloSharding::Tile(ShapeUtil::MakeShape(F32, {13, 15, 222, 333}), - Array4D({{{{0, 1}, {2, 3}}}})); - EXPECT_EQ(result, expected); -} - TEST_F(HloShardingTest, ToStringReplicatedTest) { HloSharding sharding = HloSharding::Replicate(); EXPECT_EQ(sharding.ToString(), "{replicated}"); @@ -284,9 +237,8 @@ TEST_F(HloShardingTest, ToStringAssignDeviceTest) { TEST_F(HloShardingTest, ToStringTiledTest) { HloSharding sharding = - HloSharding::Tile(ShapeUtil::MakeShape(S32, {7, 11, 13}), - Array3D({{{2, 3}}, {{5, 7}}})); - EXPECT_EQ(sharding.ToString(), "{s32[7,11,13] devices=[2,1,2]2,3,5,7}"); + HloSharding::Tile(Array3D({{{2, 3}}, {{5, 7}}})); + EXPECT_EQ(sharding.ToString(), "{devices=[2,1,2]2,3,5,7}"); } TEST_F(HloShardingTest, ToStringTupleTest) { @@ -294,21 +246,18 @@ TEST_F(HloShardingTest, ToStringTupleTest) { ShapeUtil::MakeTupleShape({ShapeUtil::MakeShape(F32, {3, 5}), ShapeUtil::MakeShape(U32, {7, 25}), ShapeUtil::MakeShape(S32, {9, 11})}), - {HloSharding::Replicate(), - HloSharding::Tile(ShapeUtil::MakeShape(U32, {7, 13}), - Array2D({{3, 5}})), + {HloSharding::Replicate(), HloSharding::Tile(Array2D({{3, 5}})), HloSharding::AssignDevice(3)}); EXPECT_EQ(sharding.ToString(), - "{{replicated}, {u32[7,13] devices=[1,2]3,5}, {maximal device=3}}"); + "{{replicated}, {devices=[1,2]3,5}, {maximal device=3}}"); } TEST_F(HloShardingTest, OstreamTest) { HloSharding sharding = - HloSharding::Tile(ShapeUtil::MakeShape(F32, {3, 5, 7, 11}), - Array4D({{{{0, 1}, {2, 3}}}})); + HloSharding::Tile(Array4D({{{{0, 1}, {2, 3}}}})); std::ostringstream oss; oss << sharding; - EXPECT_EQ(oss.str(), "{f32[3,5,7,11] devices=[1,1,2,2]0,1,2,3}"); + EXPECT_EQ(oss.str(), "{devices=[1,1,2,2]0,1,2,3}"); } TEST_F(HloShardingTest, ParseHloString) { @@ -319,8 +268,7 @@ TEST_F(HloShardingTest, ParseHloString) { }; check(HloSharding::Replicate()); check(HloSharding::AssignDevice(2)); - check(HloSharding::Tile(ShapeUtil::MakeShape(F32, {3, 1, 3, 7}), - Array4D({{{{0}, {1}}}}))); + check(HloSharding::Tile(Array4D({{{{0}, {1}}}}))); // Empty tuple. One sharding is required for empty tuples, as we need to be // able to assign sharding to them, even though they have no leaves. check(HloSharding::Tuple(ShapeUtil::MakeTupleShape({}), @@ -332,8 +280,7 @@ TEST_F(HloShardingTest, ParseHloString) { ShapeUtil::MakeShape(F32, {3, 5, 7}), ShapeUtil::MakeShape(F32, {3, 7})}); check(HloSharding::Tuple( - tuple_shape, {HloSharding::Tile(ShapeUtil::MakeShape(F32, {3, 1, 3, 7}), - Array4D({{{{0}, {1}}}})), + tuple_shape, {HloSharding::Tile(Array4D({{{{0}, {1}}}})), HloSharding::Replicate(), HloSharding::AssignDevice(1)})); } { @@ -343,8 +290,7 @@ TEST_F(HloShardingTest, ParseHloString) { ShapeUtil::MakeTupleShape({ShapeUtil::MakeShape(F32, {3, 5, 7}), ShapeUtil::MakeShape(F32, {3, 7})})}); std::vector leaf_shardings = { - HloSharding::Tile(ShapeUtil::MakeShape(F32, {3, 1, 3, 7}), - Array4D({{{{0}, {1}}}})), + HloSharding::Tile(Array4D({{{{0}, {1}}}})), HloSharding::Replicate(), HloSharding::AssignDevice(1)}; ShapeTree sharding_tree(tuple_shape, HloSharding::Replicate()); // Assign leaf_shardings to sharding_tree leaves. -- GitLab From a26e1ef08db82be225837b6323fb45062c56caf2 Mon Sep 17 00:00:00 2001 From: Mark Daoust Date: Wed, 8 Aug 2018 07:37:48 -0700 Subject: [PATCH 196/437] Make autograph visible in contrib. PiperOrigin-RevId: 207882047 --- tensorflow/contrib/__init__.py | 1 + tensorflow/tools/docs/generate_lib.py | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tensorflow/contrib/__init__.py b/tensorflow/contrib/__init__.py index ded05da718..e18ea8df4d 100644 --- a/tensorflow/contrib/__init__.py +++ b/tensorflow/contrib/__init__.py @@ -22,6 +22,7 @@ from __future__ import print_function import os # Add projects here, they will show up under tf.contrib. +from tensorflow.contrib import autograph from tensorflow.contrib import batching from tensorflow.contrib import bayesflow from tensorflow.contrib import checkpoint diff --git a/tensorflow/tools/docs/generate_lib.py b/tensorflow/tools/docs/generate_lib.py index 7c8dbd5dc2..3a93bdcf4a 100644 --- a/tensorflow/tools/docs/generate_lib.py +++ b/tensorflow/tools/docs/generate_lib.py @@ -235,12 +235,14 @@ def add_dict_to_dict(add_from, add_to): # Exclude some libraries in contrib from the documentation altogether. def _get_default_private_map(): - return {'tf.test': ['mock']} + return { + 'tf.contrib.autograph': ['utils', 'operators'], + 'tf.test': ['mock']} # Exclude members of some libraries. def _get_default_do_not_descend_map(): - # TODO(wicke): Shrink this list once the modules get sealed. + # TODO(markdaoust): Use docs_controls decorators, locally, instead. return { 'tf': ['cli', 'lib', 'wrappers'], 'tf.contrib': [ -- GitLab From 7b0760feae2b0a291b28d7304952b4cf32e8f5a1 Mon Sep 17 00:00:00 2001 From: Mark Heffernan Date: Wed, 8 Aug 2018 08:24:22 -0700 Subject: [PATCH 197/437] Make root determination of XLA computations in XlaBuilder less magical. Previously (before this CL), in the XLA builder certain XLA ops could never be the root of a computation. These restricted ops include Send, Outfeed, and several others. The root of the built computation was then the last added op which was not in this restricted set. However, this is undesirable because now Send and Outfeed produce token values and it may be desirable to return these tokens from a computation, something which is impossible now. This CL addresses this problem by allowing any op to be the root of a computation. This means now the root of the computation will be the last operation added before calling Build(). Furthermore, to enable previous functionality and improve expressiveness in general a new XlaComputation::Build method is added which takes an XlaOp which specifies the root. PiperOrigin-RevId: 207887842 --- tensorflow/compiler/xla/client/xla_builder.cc | 84 ++++++++----------- tensorflow/compiler/xla/client/xla_builder.h | 22 +++-- .../compiler/xla/client/xla_builder_test.cc | 52 ++++++++++++ 3 files changed, 103 insertions(+), 55 deletions(-) diff --git a/tensorflow/compiler/xla/client/xla_builder.cc b/tensorflow/compiler/xla/client/xla_builder.cc index 1cb61f77fb..073d66bcd2 100644 --- a/tensorflow/compiler/xla/client/xla_builder.cc +++ b/tensorflow/compiler/xla/client/xla_builder.cc @@ -45,21 +45,6 @@ int64 GetUniqueId() { return id; } -// Returns true if an instruction with the given opcode can be the root of the -// computation. -bool CanBeRoot(HloOpcode opcode) { - switch (opcode) { - case HloOpcode::kAfterAll: - case HloOpcode::kSend: - case HloOpcode::kSendDone: - case HloOpcode::kOutfeed: - case HloOpcode::kTrace: - return false; - default: - return true; - } -} - } // namespace XlaOp operator-(const XlaOp& x) { return Neg(x); } @@ -142,28 +127,13 @@ XlaOp XlaBuilder::ReportErrorOrReturn( return ReportErrorOrReturn(op_creator()); } -StatusOr XlaBuilder::GetProgramShape(int64* root_id) const { +StatusOr XlaBuilder::GetProgramShape(int64 root_id) const { TF_RETURN_IF_ERROR(first_error_); - - TF_RET_CHECK(root_id != nullptr); + TF_RET_CHECK((root_id >= 0) && (root_id < instructions_.size())); ProgramShape program_shape; - // Not all instructions can be roots. Walk backwards from the last added - // instruction until a valid root is found. - int64 index = instructions_.size() - 1; - for (; index >= 0; index--) { - TF_ASSIGN_OR_RETURN(HloOpcode opcode, - StringToHloOpcode(instructions_[index].opcode())); - if (CanBeRoot(opcode)) { - break; - } - } - if (index < 0) { - return FailedPrecondition("no root instruction was found"); - } - *root_id = instructions_[index].id(); - *program_shape.mutable_result() = instructions_[index].shape(); + *program_shape.mutable_result() = instructions_[root_id].shape(); // Check that the parameter numbers are continuous from 0, and add parameter // shapes and names to the program shape. @@ -188,8 +158,15 @@ StatusOr XlaBuilder::GetProgramShape(int64* root_id) const { } StatusOr XlaBuilder::GetProgramShape() const { - int64 root; - return GetProgramShape(&root); + TF_RET_CHECK(!instructions_.empty()); + return GetProgramShape(instructions_.back().id()); +} + +StatusOr XlaBuilder::GetProgramShape(XlaOp root) const { + if (root.builder_ != this) { + return InvalidArgument("Given root operation is not in this computation."); + } + return GetProgramShape(root.handle()); } void XlaBuilder::IsConstantVisitor(const int64 op_handle, @@ -257,17 +234,29 @@ StatusOr XlaBuilder::Build() { first_error_backtrace_.Dump(tensorflow::DebugWriteToString, &backtrace); return AppendStatus(first_error_, backtrace); } + return Build(instructions_.back().id()); +} + +StatusOr XlaBuilder::Build(XlaOp root) { + if (root.builder_ != this) { + return InvalidArgument("Given root operation is not in this computation."); + } + return Build(root.handle()); +} + +StatusOr XlaBuilder::Build(int64 root_id) { + if (!first_error_.ok()) { + string backtrace; + first_error_backtrace_.Dump(tensorflow::DebugWriteToString, &backtrace); + return AppendStatus(first_error_, backtrace); + } HloComputationProto entry; entry.set_id(GetUniqueId()); // Give the computation a global unique id. entry.set_name(StrCat(name_, entry.id())); // Ensure that the name is unique. - { - int64 root_id; - TF_ASSIGN_OR_RETURN(*entry.mutable_program_shape(), - GetProgramShape(&root_id)); - entry.set_root_id(root_id); - } + TF_ASSIGN_OR_RETURN(*entry.mutable_program_shape(), GetProgramShape(root_id)); + entry.set_root_id(root_id); for (auto& instruction : instructions_) { // Ensures that the instruction names are unique among the whole graph. @@ -1099,11 +1088,11 @@ XlaOp XlaBuilder::Infeed(const Shape& shape, const string& config) { sharding_builder::AssignDevice(0); XlaScopedShardingAssignment scoped_sharding(this, infeed_instruction_sharding); - TF_ASSIGN_OR_RETURN(infeed, - AddInstruction(std::move(instr), HloOpcode::kInfeed)); + TF_ASSIGN_OR_RETURN( + infeed, AddInstruction(std::move(instr), HloOpcode::kInfeed, {})); } else { - TF_ASSIGN_OR_RETURN(infeed, - AddInstruction(std::move(instr), HloOpcode::kInfeed)); + TF_ASSIGN_OR_RETURN( + infeed, AddInstruction(std::move(instr), HloOpcode::kInfeed, {})); } // The infeed instruction produces a tuple of the infed data and a token @@ -2163,11 +2152,6 @@ StatusOr XlaBuilder::BuildConstantSubGraph( TF_ASSIGN_OR_RETURN(const HloInstructionProto* root, LookUpInstruction(root_op)); - TF_ASSIGN_OR_RETURN(HloOpcode opcode, StringToHloOpcode(root->opcode())); - if (!CanBeRoot(opcode)) { - return InvalidArgument("the operand with opcode %s cannot be root", - root->opcode().c_str()); - } HloComputationProto entry; entry.set_id(GetUniqueId()); // Give the computation a global unique id. diff --git a/tensorflow/compiler/xla/client/xla_builder.h b/tensorflow/compiler/xla/client/xla_builder.h index 8726cc6f93..3c5f8c8d53 100644 --- a/tensorflow/compiler/xla/client/xla_builder.h +++ b/tensorflow/compiler/xla/client/xla_builder.h @@ -195,9 +195,14 @@ class XlaBuilder { // Builds the computation with the requested operations, or returns a non-ok // status. Note that all ops that have been enqueued will be moved to the - // computation being returned. + // computation being returned. The root of the computation will be the last + // added operation. StatusOr Build(); + // Overload of Build which specifies a particular root instruction for the + // computation. + StatusOr Build(XlaOp root); + // Builds the computation with the requested operations, or notes an error in // the parent XlaBuilder and returns an empty computation if building failed. // This function is intended to be used where the returned XlaComputation is @@ -225,9 +230,14 @@ class XlaBuilder { // Returns the shape of the given op. StatusOr GetShape(const XlaOp& op) const; - // Returns the (inferred) result for the current computation's shape. + // Returns the (inferred) result for the current computation's shape. This + // assumes the root instruction is the last added instruction. StatusOr GetProgramShape() const; + // Returns the (inferred) result for the current computation's shape using the + // given operation as the root. + StatusOr GetProgramShape(XlaOp root) const; + // Reports an error to the builder, by // * storing it internally and capturing a backtrace if it's the first error // (this deferred value will be produced on the call to @@ -255,6 +265,9 @@ class XlaBuilder { StatusOr IsConstant(const XlaOp& operand) const; private: + // Build helper which takes the id of the root operation.. + StatusOr Build(int64 root_id); + // Enqueues a "retrieve parameter value" instruction for a parameter that was // passed to the computation. XlaOp Parameter(int64 parameter_number, const Shape& shape, @@ -969,9 +982,8 @@ class XlaBuilder { // shape. StatusOr Reshape(const Shape& shape, const XlaOp& operand); - // Returns the (inferred) result for the program shape for the current - // computation and fills the root_id in the pointer. - StatusOr GetProgramShape(int64* root_id) const; + // Returns the (inferred) result for the program shape using the given root. + StatusOr GetProgramShape(int64 root_id) const; // Returns shapes for the operands. StatusOr> GetOperandShapes( diff --git a/tensorflow/compiler/xla/client/xla_builder_test.cc b/tensorflow/compiler/xla/client/xla_builder_test.cc index 28a207b137..afe5be29f0 100644 --- a/tensorflow/compiler/xla/client/xla_builder_test.cc +++ b/tensorflow/compiler/xla/client/xla_builder_test.cc @@ -24,6 +24,7 @@ limitations under the License. #include "tensorflow/compiler/xla/shape_util.h" #include "tensorflow/compiler/xla/status_macros.h" #include "tensorflow/compiler/xla/test.h" +#include "tensorflow/compiler/xla/test_helpers.h" #include "tensorflow/compiler/xla/xla_data.pb.h" namespace xla { @@ -46,6 +47,17 @@ class XlaBuilderTest : public ::testing::Test { return HloModule::CreateFromProto(proto, config); } + // Overload which explicitly specifies the root instruction. + StatusOr> BuildHloModule(XlaBuilder* b, + XlaOp root) { + TF_ASSIGN_OR_RETURN(XlaComputation computation, b->Build(root)); + const HloModuleProto& proto = computation.proto(); + TF_ASSIGN_OR_RETURN(const auto& config, + HloModule::CreateModuleConfigFromProto( + proto, legacy_flags::GetDebugOptionsFromFlags())); + return HloModule::CreateFromProto(proto, config); + } + // Returns the name of the test currently being run. string TestName() const { return ::testing::UnitTest::GetInstance()->current_test_info()->name(); @@ -320,5 +332,45 @@ TEST_F(XlaBuilderTest, ReportErrorOrReturnHandlesErrors) { EXPECT_THAT(statusor.status().error_message(), HasSubstr("a test error")); } +TEST_F(XlaBuilderTest, BuildWithSpecificRoot) { + XlaBuilder b(TestName()); + XlaOp constant = ConstantR0(&b, 1.0); + Add(constant, ConstantR0(&b, 2.0)); + TF_ASSERT_OK_AND_ASSIGN(auto module, BuildHloModule(&b, /*root=*/constant)); + auto root = module->entry_computation()->root_instruction(); + EXPECT_THAT(root, op::Constant()); +} + +TEST_F(XlaBuilderTest, BuildWithSpecificRootAndMultipleParameters) { + // Specifying a particular root in Build should still include all entry + // parameters. + XlaBuilder b(TestName()); + const Shape shape = ShapeUtil::MakeShape(F32, {42, 123}); + XlaOp x = Parameter(&b, 0, shape, "x"); + XlaOp y = Parameter(&b, 1, shape, "y"); + XlaOp z = Parameter(&b, 2, shape, "z"); + Add(x, Sub(y, z)); + TF_ASSERT_OK_AND_ASSIGN(auto module, BuildHloModule(&b, /*root=*/x)); + auto root = module->entry_computation()->root_instruction(); + EXPECT_THAT(root, op::Parameter()); + EXPECT_EQ(module->entry_computation()->num_parameters(), 3); + EXPECT_EQ(module->entry_computation()->instruction_count(), 5); +} + +TEST_F(XlaBuilderTest, BuildWithSpecificRootWithWrongBuilder) { + XlaBuilder b(TestName()); + XlaBuilder other_b(TestName()); + const Shape shape = ShapeUtil::MakeShape(F32, {42, 123}); + + Parameter(&b, 0, shape, "param"); + XlaOp other_param = Parameter(&other_b, 0, shape, "other_param"); + + Status status = b.Build(other_param).status(); + ASSERT_IS_NOT_OK(status); + EXPECT_THAT( + status.error_message(), + ::testing::HasSubstr("root operation is not in this computation")); +} + } // namespace } // namespace xla -- GitLab From c61eeb03ec18bd9fc2f4fb77272f78b8d1efb6de Mon Sep 17 00:00:00 2001 From: "William D. Irons" Date: Wed, 8 Aug 2018 10:50:40 -0500 Subject: [PATCH 198/437] Update Copyright year for new files --- tensorflow/tools/ci_build/linux/ppc64le/cpu/run_cc_core.sh | 2 +- tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py2_core.sh | 2 +- tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_contrib.sh | 2 +- tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_core.sh | 2 +- tensorflow/tools/ci_build/linux/ppc64le/gpu/run_cc_core.sh | 2 +- tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2_core.sh | 2 +- tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_cc_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_cc_core.sh index d026d00d47..945f072a51 100755 --- a/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_cc_core.sh +++ b/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_cc_core.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright 2016 The TensorFlow Authors. All Rights Reserved. +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py2_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py2_core.sh index 22a8ddf388..aeb8c2ba99 100755 --- a/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py2_core.sh +++ b/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py2_core.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright 2016 The TensorFlow Authors. All Rights Reserved. +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_contrib.sh b/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_contrib.sh index 658410a1a5..9983f6a7c7 100755 --- a/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_contrib.sh +++ b/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_contrib.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright 2017 The TensorFlow Authors. All Rights Reserved. +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_core.sh index 8557b70037..c2916bc2b8 100755 --- a/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_core.sh +++ b/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_core.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright 2017 The TensorFlow Authors. All Rights Reserved. +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_cc_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_cc_core.sh index 8efa580dbd..68a9d0068b 100755 --- a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_cc_core.sh +++ b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_cc_core.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright 2017 The TensorFlow Authors. All Rights Reserved. +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2_core.sh index caa9f188f0..cc213a86bf 100755 --- a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2_core.sh +++ b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2_core.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright 2017 The TensorFlow Authors. All Rights Reserved. +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh index 05815e0a58..1b8d38f3cb 100755 --- a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh +++ b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright 2017 The TensorFlow Authors. All Rights Reserved. +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. -- GitLab From c3d102c47a8c4cacdb7a4e055224ac2aabf2b578 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Wed, 8 Aug 2018 09:55:05 -0700 Subject: [PATCH 199/437] [XLA:GPU] Add a generic trip count analysis based on HloEvaluator This simply brute-forces the trip count by evaluating the trip count repeatedly. This is a simple extension of the code in while_loop_simplifier. Make while_loop_simplifier use it. The GPU backend has a WhileTransformer, which tries to pattern match loops with a constant trip count. This has stopped working a long time ago. Just replace it with the common trip count finder. The longer-term goal is to move the transformation before fusion and copy insertion so it's less fragile. The tests that cover this are while_transformer's tests at the moment. PiperOrigin-RevId: 207901341 --- tensorflow/compiler/xla/service/BUILD | 14 +- tensorflow/compiler/xla/service/gpu/BUILD | 19 +- .../xla/service/gpu/ir_emitter_unnested.cc | 16 +- .../xla/service/gpu/while_transformer.cc | 521 ------------------ .../xla/service/gpu/while_transformer.h | 43 -- .../xla/service/gpu/while_transformer_test.cc | 74 +-- .../xla/service/while_loop_analysis.cc | 238 ++++++++ .../xla/service/while_loop_analysis.h | 33 ++ .../xla/service/while_loop_simplifier.cc | 228 +------- 9 files changed, 322 insertions(+), 864 deletions(-) delete mode 100644 tensorflow/compiler/xla/service/gpu/while_transformer.cc delete mode 100644 tensorflow/compiler/xla/service/gpu/while_transformer.h create mode 100644 tensorflow/compiler/xla/service/while_loop_analysis.cc create mode 100644 tensorflow/compiler/xla/service/while_loop_analysis.h diff --git a/tensorflow/compiler/xla/service/BUILD b/tensorflow/compiler/xla/service/BUILD index 528b7fdfd3..1b93d72a3e 100644 --- a/tensorflow/compiler/xla/service/BUILD +++ b/tensorflow/compiler/xla/service/BUILD @@ -1384,6 +1384,18 @@ tf_cc_test( ], ) +cc_library( + name = "while_loop_analysis", + srcs = ["while_loop_analysis.cc"], + hdrs = ["while_loop_analysis.h"], + deps = [ + ":hlo", + ":hlo_evaluator", + "//tensorflow/compiler/xla:literal", + "//tensorflow/core:lib", + ], +) + cc_library( name = "while_loop_simplifier", srcs = ["while_loop_simplifier.cc"], @@ -1391,8 +1403,8 @@ cc_library( deps = [ ":call_inliner", ":hlo", - ":hlo_evaluator", ":hlo_pass", + ":while_loop_analysis", "//tensorflow/compiler/xla:statusor", "//tensorflow/core:lib", ], diff --git a/tensorflow/compiler/xla/service/gpu/BUILD b/tensorflow/compiler/xla/service/gpu/BUILD index 6a0aedc949..a3f6e8d989 100644 --- a/tensorflow/compiler/xla/service/gpu/BUILD +++ b/tensorflow/compiler/xla/service/gpu/BUILD @@ -153,7 +153,6 @@ cc_library( ":ir_emission_utils", ":parallel_loop_emitter", ":partition_assignment", - ":while_transformer", "//tensorflow/compiler/xla:literal", "//tensorflow/compiler/xla:shape_util", "//tensorflow/compiler/xla:status_macros", @@ -166,6 +165,7 @@ cc_library( "//tensorflow/compiler/xla/service:elemental_ir_emitter", "//tensorflow/compiler/xla/service:hlo", "//tensorflow/compiler/xla/service:name_uniquer", + "//tensorflow/compiler/xla/service:while_loop_analysis", "//tensorflow/compiler/xla/service/llvm_ir:buffer_assignment_util", "//tensorflow/compiler/xla/service/llvm_ir:dynamic_update_slice_util", "//tensorflow/compiler/xla/service/llvm_ir:fused_ir_emitter", @@ -787,32 +787,17 @@ tf_cc_test( ], ) -cc_library( - name = "while_transformer", - srcs = ["while_transformer.cc"], - hdrs = ["while_transformer.h"], - deps = [ - "//tensorflow/compiler/xla:literal", - "//tensorflow/compiler/xla:shape_util", - "//tensorflow/compiler/xla:status_macros", - "//tensorflow/compiler/xla:statusor", - "//tensorflow/compiler/xla:util", - "//tensorflow/compiler/xla/service:hlo", - "//tensorflow/core:lib", - ], -) - tf_cc_test( name = "while_transformer_test", srcs = ["while_transformer_test.cc"], deps = [ ":instruction_fusion", - ":while_transformer", "//tensorflow/compiler/xla:shape_util", "//tensorflow/compiler/xla:test", "//tensorflow/compiler/xla:test_helpers", "//tensorflow/compiler/xla/service:copy_insertion", "//tensorflow/compiler/xla/service:hlo_verifier", + "//tensorflow/compiler/xla/service:while_loop_analysis", "//tensorflow/compiler/xla/tests:hlo_test_base", "//tensorflow/compiler/xla/tests:xla_internal_test_main", "//tensorflow/core:test", diff --git a/tensorflow/compiler/xla/service/gpu/ir_emitter_unnested.cc b/tensorflow/compiler/xla/service/gpu/ir_emitter_unnested.cc index d5ecae88ed..a093ffc7c1 100644 --- a/tensorflow/compiler/xla/service/gpu/ir_emitter_unnested.cc +++ b/tensorflow/compiler/xla/service/gpu/ir_emitter_unnested.cc @@ -56,7 +56,6 @@ limitations under the License. #include "tensorflow/compiler/xla/service/gpu/thunk.h" #include "tensorflow/compiler/xla/service/gpu/tuple_thunk.h" #include "tensorflow/compiler/xla/service/gpu/while_thunk.h" -#include "tensorflow/compiler/xla/service/gpu/while_transformer.h" #include "tensorflow/compiler/xla/service/hlo_computation.h" #include "tensorflow/compiler/xla/service/hlo_instruction.h" #include "tensorflow/compiler/xla/service/hlo_opcode.h" @@ -68,6 +67,7 @@ limitations under the License. #include "tensorflow/compiler/xla/service/llvm_ir/sort_util.h" #include "tensorflow/compiler/xla/service/llvm_ir/tuple_ops.h" #include "tensorflow/compiler/xla/service/name_uniquer.h" +#include "tensorflow/compiler/xla/service/while_loop_analysis.h" #include "tensorflow/compiler/xla/shape_util.h" #include "tensorflow/compiler/xla/status_macros.h" #include "tensorflow/compiler/xla/types.h" @@ -1963,19 +1963,13 @@ Status IrEmitterUnnested::HandleWhile(HloInstruction* xla_while) { condition->root_instruction()->shape().element_type() == PRED) << "While condition computation must return bool"; // Build ForThunk for conformant while loops, otherwise build WhileThunk. - auto result = CanTransformWhileToFor(xla_while); - if (result.ok()) { - auto tuple = result.ConsumeValueOrDie(); - // loop_trip_count = (limit - start + increment - 1) / increment - const int64 loop_trip_count = - (std::get<1>(tuple) - std::get<0>(tuple) + std::get<2>(tuple) - 1) / - std::get<2>(tuple); - thunk_sequence_->emplace_back(BuildForThunk(xla_while, loop_trip_count)); + // TODO(b/112163966): Move trip count computation earlier in the pipeline. + if (auto loop_trip_count = ComputeWhileLoopTripCount(xla_while)) { + thunk_sequence_->emplace_back(BuildForThunk(xla_while, *loop_trip_count)); VLOG(3) << "Built ForThunk for while: " << xla_while->name(); } else { thunk_sequence_->emplace_back(BuildWhileThunk(xla_while)); - VLOG(3) << "Built WhileThunk for while: " << xla_while->name() - << " while-to-for transform status: " << result.status(); + VLOG(3) << "Built WhileThunk for while: " << xla_while->name(); } return Status::OK(); } diff --git a/tensorflow/compiler/xla/service/gpu/while_transformer.cc b/tensorflow/compiler/xla/service/gpu/while_transformer.cc deleted file mode 100644 index c5321df6c4..0000000000 --- a/tensorflow/compiler/xla/service/gpu/while_transformer.cc +++ /dev/null @@ -1,521 +0,0 @@ -/* Copyright 2017 The TensorFlow Authors. All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -==============================================================================*/ - -#include "tensorflow/compiler/xla/service/gpu/while_transformer.h" - -#include -#include - -#include "tensorflow/compiler/xla/literal.h" -#include "tensorflow/compiler/xla/service/hlo_computation.h" -#include "tensorflow/compiler/xla/shape_util.h" -#include "tensorflow/compiler/xla/status_macros.h" -#include "tensorflow/compiler/xla/util.h" -#include "tensorflow/core/lib/core/errors.h" - -namespace xla { -namespace gpu { - -namespace { - -// TODO(b/33483676) Use an expression tree to specify computations to pattern -// match for while transformations. - -// ExprTree is a simple recursive data structure used to express computation -// patterns to match. -// -// Each ExprTree node is comprised of an HloOpcode, and a set of operands (each -// of type ExprTree). Operands can be added by specifying the index and -// HloOpcode of the operand. -// -// For example, the following computation: -// -// Parameter -// | -// Const GetTupleElement -// \ / -// Add (root) -// -// Can be matched with the following expression tree: -// -// ExprTree add(HloOpcode::kAdd, -// ExprTree(HloOpcode::kConstant), -// ExprTree(HloOpcode::kGetTupleElement, -// tuple_index, ExprTree(HloOpcode::kParameter))); -// -// Match the ExprTree root against an Hlo graph: -// -// ExprTree::TaggedInstructionMap tagged_instructions; -// TF_RETURN_IF_ERROR(add.Match(computation_->root_instruction(), -// &tagged_instructions)); -// -// Instructions that are "tagged" with a context-specific string will -// be returned in 'tagged_instructions' for further processing (i.e. parsing -// constants or recording the tuple_index). -// -class ExprTree { - public: - explicit ExprTree(HloOpcode opcode) : opcode_(opcode) {} - ExprTree(HloOpcode opcode, const string& tag) : opcode_(opcode), tag_(tag) {} - ExprTree(HloOpcode opcode, const ExprTree& operand0) : opcode_(opcode) { - SetOperand(0, operand0); - } - ExprTree(HloOpcode opcode, int64 index0, const ExprTree& operand0) - : opcode_(opcode) { - SetOperand(index0, operand0); - } - ExprTree(HloOpcode opcode, int64 index0, const ExprTree& operand0, - int64 index1, const ExprTree& operand1) - : opcode_(opcode) { - SetOperand(index0, operand0); - SetOperand(index1, operand1); - } - ExprTree(HloOpcode opcode, const string& tag, const ExprTree& operand0) - : opcode_(opcode), tag_(tag) { - SetOperand(0, operand0); - } - ExprTree(HloOpcode opcode, const ExprTree& operand0, const ExprTree& operand1) - : opcode_(opcode) { - SetOperand(0, operand0); - SetOperand(1, operand1); - } - - ExprTree(const ExprTree& to_copy) { - opcode_ = to_copy.opcode_; - tag_ = to_copy.tag_; - if (to_copy.fused_root_tree_ != nullptr) { - fused_root_tree_.reset(new ExprTree(*to_copy.fused_root_tree_)); - } - for (auto& pair : to_copy.operands_) { - CHECK(operands_.find(pair.first) == operands_.end()); - operands_.insert(std::make_pair( - pair.first, std::unique_ptr(new ExprTree(*pair.second)))); - } - } - - void SetFusedRoot(const ExprTree& fused_root) { - fused_root_tree_.reset(new ExprTree(fused_root)); - } - - typedef std::unordered_map - TaggedInstructionMap; - - // Matches 'instruction' HloOpcode against 'opcode_'. - // Recursively matches each operand in 'operands_'. - // Recursively matches fused instructions starting at 'fused_root_tree_' - // if 'opcode_ == kFusion'. - // Returns OK status, and instructions in 'tagged_instructions' for each - // matched ExprTree node with a non-empty 'tag_'. - // Returns error message on failure. - Status Match(const HloInstruction* instruction, - TaggedInstructionMap* tagged_instructions) const { - if (opcode_ != instruction->opcode()) { - return InvalidArgument("got opcode %s, want %s", - HloOpcodeString(instruction->opcode()).c_str(), - HloOpcodeString(opcode_).c_str()); - } - - VLOG(2) << "Matched " << HloOpcodeString(opcode_) << ": " << tag_; - if (!tag_.empty()) { - tagged_instructions->insert({tag_, instruction}); - } - - if (instruction->opcode() == HloOpcode::kFusion) { - CHECK(fused_root_tree_ != nullptr); - // Match fused instructions for this node starting a 'fused_root_tree'. - TF_RETURN_IF_ERROR(fused_root_tree_->Match( - instruction->fused_expression_root(), tagged_instructions)); - } - - // Match each operand in 'operands_'. - for (auto& pair : operands_) { - TF_RETURN_IF_ERROR(pair.second->Match(instruction->operand(pair.first), - tagged_instructions)); - } - return Status::OK(); - } - - private: - void SetOperand(int64 index, const ExprTree& operand) { - CHECK_EQ(0, operands_.count(index)); - operands_.insert(std::make_pair(index, MakeUnique(operand))); - } - - HloOpcode opcode_; - std::unordered_map> operands_; - std::unique_ptr fused_root_tree_; - string tag_; -}; - -// MatcherBase is a base class that provides common functionality for -// sub-classes which match specific target sub-computations (i.e. loop -// induction variable initialization, comparison and update). -class MatcherBase { - public: - MatcherBase() {} - virtual ~MatcherBase() {} - - // Attempts to match each ExprTree in 'expr_trees_'. - // Returns OK on the first successful match, error status otherwise. - virtual Status Run() { - Status status; - for (const ExprTree& expr_tree : expr_trees_) { - status = MatchExprTree(expr_tree); - if (status.ok()) { - return status; - } - } - return status; - } - - virtual Status MatchExprTree(const ExprTree& expr_tree) = 0; - - // Returns the constant value parsed form kConstant 'instruction'. - // Returns error status otherwise. - Status ParseConstInteger(const HloInstruction* instruction, - int64* const_value) const { - CHECK_EQ(HloOpcode::kConstant, instruction->opcode()); - PrimitiveType element_type = instruction->shape().element_type(); - if (element_type != S32 && element_type != S64) { - return InvalidArgument("Expected constant of integral type."); - } - const Literal& literal = instruction->literal(); - PrimitiveType type = literal.shape().element_type(); - if (type != S32 && type != S64) { - return InvalidArgument("Must use S32 or S64 integral types."); - } - if (type == S32) { - *const_value = static_cast(literal.GetFirstElement()); - } else if (type == S64) { - *const_value = literal.GetFirstElement(); - } - return Status::OK(); - } - - StatusOr GetTaggedInstruction( - const string& tag, - const ExprTree::TaggedInstructionMap& tagged_instructions) { - auto it = tagged_instructions.find(tag); - if (it == tagged_instructions.end()) { - return InvalidArgument("Cound not find instruction for tag: %s", - tag.c_str()); - } - return it->second; - } - - protected: - std::vector expr_trees_; - - private: - TF_DISALLOW_COPY_AND_ASSIGN(MatcherBase); -}; - -// WhileConditionComputationMatcher attempts to match a target computation -// pattern in the while condition sub-computation. -// If the target pattern is matched, two pieces of information are extracted -// from 'tagged' instructions returned by the matcher: -// -// *) 'tuple_index': -// *) The loop induction variable tuple_index from the GetTupleElement -// instruction of the matched computation. -// *) Used in subsequent matching passes of while init operand and body -// computations to select loop induction variable tuple element. -// -// *) 'loop_limit': -// *) The integral value from Constant root operand in matched computation. -// *) Used as the constant for the loop limit. -// -class WhileConditionComputationMatcher : public MatcherBase { - public: - explicit WhileConditionComputationMatcher(const HloComputation* computation) - : computation_(computation) { - expr_trees_.emplace_back(BuildCondExprTree()); - } - - int64 loop_limit() const { return loop_limit_; } - int64 tuple_index() const { return tuple_index_; } - - private: - // Builds expression tree for the following condition computation: - // - // Const Parameter - // \ / - // Fusion ------------> FusionParam FusionParam - // \ / - // GTE / - // \ / - // LessThan (fused root) - // - ExprTree BuildCondExprTree() { - // Build ExprTree for fused instructions. - ExprTree fused_root( - HloOpcode::kLt, - ExprTree(HloOpcode::kGetTupleElement, "gte", - ExprTree(HloOpcode::kParameter, "gte.fusion_param.param0")), - ExprTree(HloOpcode::kParameter)); - - // Build top-level computation. - ExprTree root(HloOpcode::kFusion, - ExprTree(HloOpcode::kConstant, "loop_limit"), - ExprTree(HloOpcode::kParameter, "param0")); - - root.SetFusedRoot(fused_root); - return root; - } - - Status MatchExprTree(const ExprTree& expr_tree) override { - VLOG(2) << "MATCHING while condition"; - ExprTree::TaggedInstructionMap tagged_instructions; - TF_RETURN_IF_ERROR(expr_tree.Match(computation_->root_instruction(), - &tagged_instructions)); - - // Get tagged GTE instruction and set 'tuple_index_'. - TF_ASSIGN_OR_RETURN(const HloInstruction* gte, - GetTaggedInstruction("gte", tagged_instructions)); - tuple_index_ = gte->tuple_index(); - - // Get tagged Constant instruction and parse 'loop_limit_'. - TF_ASSIGN_OR_RETURN( - const HloInstruction* const_hlo, - GetTaggedInstruction("loop_limit", tagged_instructions)); - TF_RETURN_IF_ERROR(ParseConstInteger(const_hlo, &loop_limit_)); - - // Get tagged "param0" instruction, and check that it matches - // 'computation_' parameter 0. - TF_ASSIGN_OR_RETURN(const HloInstruction* param0, - GetTaggedInstruction("param0", tagged_instructions)); - if (param0 != computation_->parameter_instruction(0)) { - return InvalidArgument("Unexpected Parameter0 instruction : %s", - param0->name().c_str()); - } - - // Get tagged 'gte.fusion_param.param0', find its associated fusion operand, - // and compare it to 'computation_' parameter0. - TF_ASSIGN_OR_RETURN( - const HloInstruction* gte_fusion_param0, - GetTaggedInstruction("gte.fusion_param.param0", tagged_instructions)); - CHECK_EQ(HloOpcode::kParameter, gte_fusion_param0->opcode()); - CHECK(gte_fusion_param0->IsFused()); - if (gte_fusion_param0->parent()->FusionInstruction()->operand( - gte_fusion_param0->parameter_number()) != - computation_->parameter_instruction(0)) { - return InvalidArgument("Could not match fusion param: %s", - gte_fusion_param0->name().c_str()); - } - - return Status::OK(); - } - - const HloComputation* computation_; - - int64 loop_limit_ = -1; - int64 tuple_index_ = -1; - - TF_DISALLOW_COPY_AND_ASSIGN(WhileConditionComputationMatcher); -}; - -// WhileInitOperandMatcher matches a target computation pattern of the -// while instructions 'init' operand, indexing the tuple at 'tuple_index'. -// On success, parses constant 'loop_start' which represents the loop induction -// variable start values, then returns OK. -// Returns error status otherwise. -class WhileInitOperandMatcher : public MatcherBase { - public: - WhileInitOperandMatcher(const HloInstruction* while_hlo, - const int64 tuple_index) - : while_hlo_(while_hlo), tuple_index_(tuple_index) { - expr_trees_.emplace_back(BuildInitExprTree()); - } - - int64 loop_start() const { return loop_start_; } - - private: - // Builds expression tree for the following while init operand subcomputation: - // - // Const - // | - // Copy - // | - // Tuple0 - // | - // While - // - ExprTree BuildInitExprTree() { - return ExprTree( - HloOpcode::kWhile, "while", - ExprTree(HloOpcode::kTuple, tuple_index_, - ExprTree(HloOpcode::kCopy, - ExprTree(HloOpcode::kConstant, "loop_start")))); - } - - Status MatchExprTree(const ExprTree& expr_tree) override { - VLOG(2) << "MATCHING while init"; - ExprTree::TaggedInstructionMap tagged_instructions; - TF_RETURN_IF_ERROR(expr_tree.Match(while_hlo_, &tagged_instructions)); - - // Get tagged while instruction check against 'while_hlo_'. - TF_ASSIGN_OR_RETURN(const HloInstruction* while_hlo, - GetTaggedInstruction("while", tagged_instructions)); - if (while_hlo != while_hlo_) { - return InvalidArgument("Expected While for instruction : %s", - while_hlo->name().c_str()); - } - - // Get tagged Constant instruction and parse 'loop_start_'. - TF_ASSIGN_OR_RETURN( - const HloInstruction* const_hlo, - GetTaggedInstruction("loop_start", tagged_instructions)); - TF_RETURN_IF_ERROR(ParseConstInteger(const_hlo, &loop_start_)); - - return Status::OK(); - } - - const HloInstruction* while_hlo_; - const int64 tuple_index_; - - int64 loop_start_ = -1; - - TF_DISALLOW_COPY_AND_ASSIGN(WhileInitOperandMatcher); -}; - -// WhileBodyComputationMatcher matches a target computation pattern for -// the loop induction variable update. Matching proceeds from the while body -// computation root[tuple_index] to param[tuple_index], where 'tuple_index' -// If the target pattern is matched, parses a constant which represents the -// loop induction variable increment value, then returns status OK. -// Returns error status otherwise. -class WhileBodyComputationMatcher : public MatcherBase { - public: - WhileBodyComputationMatcher(const HloComputation* computation, - const int64 tuple_index) - : computation_(computation), tuple_index_(tuple_index) { - expr_trees_.emplace_back(BuildBodyExprTree(0, 1)); - expr_trees_.emplace_back(BuildBodyExprTree(1, 0)); - } - - int64 loop_increment() const { return loop_increment_; } - - private: - // Builds expression tree for the following while body computation: - // - // - // FusionParam FusionParam - // \ / - // Const Param \ GTE1 - // \ / \ / - // Fusion -----------> Add - // | - // Copy - // | - // Tuple0 - // - ExprTree BuildBodyExprTree(const int64 const_index, const int64 gte_index) { - // Build ExprTree for fused instructions. - ExprTree gte1 = - ExprTree(HloOpcode::kGetTupleElement, "gte", - ExprTree(HloOpcode::kParameter, "gte.fusion_param.param0")); - ExprTree fused_root(HloOpcode::kAdd, const_index, - ExprTree(HloOpcode::kParameter), gte_index, gte1); - - // Build fusion instruction (and set fused root). - ExprTree fusion(HloOpcode::kFusion, 0, - ExprTree(HloOpcode::kConstant, "loop_increment"), 1, - ExprTree(HloOpcode::kParameter, "param0")); - fusion.SetFusedRoot(fused_root); - - // Build top-level computation. - ExprTree tuple0(HloOpcode::kTuple, tuple_index_, - ExprTree(HloOpcode::kCopy, fusion)); - return tuple0; - } - - Status MatchExprTree(const ExprTree& expr_tree) override { - VLOG(2) << "MATCHING while body"; - ExprTree::TaggedInstructionMap tagged_instructions; - TF_RETURN_IF_ERROR(expr_tree.Match(computation_->root_instruction(), - &tagged_instructions)); - - for (const auto& pair : tagged_instructions) { - const auto& tag = pair.first; - const auto& inst = pair.second; - - if (tag == "gte" && inst->tuple_index() != tuple_index_) { - // Check that the matched GTE instruction is at the 'tuple_index' we - // matched in the while condition computation. - return InvalidArgument("Unexpected tuple index instruction : %s", - inst->name().c_str()); - } else if (tag == "loop_increment") { - // ParseHloString the constant which represents the loop induction - // variable increment value. - TF_RETURN_IF_ERROR(ParseConstInteger(inst, &loop_increment_)); - } else if (tag == "param0" && - inst != computation_->parameter_instruction(0)) { - // Check that the matched parameter == parameter 0 from 'computation_'. - return InvalidArgument("Unexpected Parameter0 instruction : %s", - inst->name().c_str()); - } else if (tag == "gte.fusion_param.param0") { - // Fusion parameter: lookup and compare with associated fusion operand. - CHECK_EQ(HloOpcode::kParameter, inst->opcode()); - CHECK(inst->IsFused()); - if (inst->parent()->FusionInstruction()->operand( - inst->parameter_number()) != - computation_->parameter_instruction(0)) { - return InvalidArgument("Could not match fusion param: %s", - inst->name().c_str()); - } - } - } - return Status::OK(); - } - - const HloComputation* computation_; - const int64 tuple_index_; - - int64 loop_increment_ = -1; - - TF_DISALLOW_COPY_AND_ASSIGN(WhileBodyComputationMatcher); -}; - -} // namespace - -StatusOr> CanTransformWhileToFor( - const HloInstruction* while_hlo) { - if (while_hlo->opcode() != HloOpcode::kWhile) { - return InvalidArgument("Expected While instruction."); - } - - WhileConditionComputationMatcher cond_matcher(while_hlo->while_condition()); - TF_RETURN_IF_ERROR(cond_matcher.Run()); - - WhileInitOperandMatcher init_matcher(while_hlo, cond_matcher.tuple_index()); - TF_RETURN_IF_ERROR(init_matcher.Run()); - - WhileBodyComputationMatcher body_matcher(while_hlo->while_body(), - cond_matcher.tuple_index()); - TF_RETURN_IF_ERROR(body_matcher.Run()); - - // Check for valid For loop parameters. - if (init_matcher.loop_start() >= cond_matcher.loop_limit()) { - return InvalidArgument("Loop start must be less than loop limit."); - } - if (body_matcher.loop_increment() <= 0) { - return InvalidArgument("Loop increment must greater than zero."); - } - return std::make_tuple(init_matcher.loop_start(), cond_matcher.loop_limit(), - body_matcher.loop_increment()); -} - -} // namespace gpu -} // namespace xla diff --git a/tensorflow/compiler/xla/service/gpu/while_transformer.h b/tensorflow/compiler/xla/service/gpu/while_transformer.h deleted file mode 100644 index fe3a954e18..0000000000 --- a/tensorflow/compiler/xla/service/gpu/while_transformer.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright 2017 The TensorFlow Authors. All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -==============================================================================*/ - -#ifndef TENSORFLOW_COMPILER_XLA_SERVICE_GPU_WHILE_TRANSFORMER_H_ -#define TENSORFLOW_COMPILER_XLA_SERVICE_GPU_WHILE_TRANSFORMER_H_ - -#include "tensorflow/compiler/xla/service/hlo_instruction.h" -#include "tensorflow/compiler/xla/statusor.h" - -namespace xla { -namespace gpu { - -// Runs an analysis of the while loop instruction 'while_hlo' (and its -// associated sub-computations) to determine if it can be transformed into an -// equivalent "for" loop with the following "for" loop parameters: -// -// *) 'loop_start': loop induction variable starting value. -// *) 'loop_limit': loop induction variable limit value. -// *) 'loop_increment': loop induction variable per-iteration increment value. -// -// Returns an std::tuple = (loop_start, loop_limit, loop_increment) on success. -// The values in the returned tuple are values extracted from the 'while_hlo' -// operand (and its sub-computations) during analysis. -// Returns an error status on failure. -StatusOr> CanTransformWhileToFor( - const HloInstruction* while_hlo); - -} // namespace gpu -} // namespace xla - -#endif // TENSORFLOW_COMPILER_XLA_SERVICE_GPU_WHILE_TRANSFORMER_H_ diff --git a/tensorflow/compiler/xla/service/gpu/while_transformer_test.cc b/tensorflow/compiler/xla/service/gpu/while_transformer_test.cc index dbc8442ed2..c5f3906356 100644 --- a/tensorflow/compiler/xla/service/gpu/while_transformer_test.cc +++ b/tensorflow/compiler/xla/service/gpu/while_transformer_test.cc @@ -13,11 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -#include "tensorflow/compiler/xla/service/gpu/while_transformer.h" - #include "tensorflow/compiler/xla/service/copy_insertion.h" #include "tensorflow/compiler/xla/service/gpu/instruction_fusion.h" #include "tensorflow/compiler/xla/service/hlo_verifier.h" +#include "tensorflow/compiler/xla/service/while_loop_analysis.h" #include "tensorflow/compiler/xla/shape_util.h" #include "tensorflow/compiler/xla/test.h" #include "tensorflow/compiler/xla/test_helpers.h" @@ -110,12 +109,12 @@ class WhileTransformerTest : public HloTestBase { void RunFusionPasses() { // Run standard fusion passes. - EXPECT_TRUE(gpu::GpuInstructionFusion(/*may_duplicate=*/false) - .Run(module_.get()) - .ValueOrDie()); - EXPECT_TRUE(gpu::GpuInstructionFusion(/*may_duplicate=*/true) - .Run(module_.get()) - .ValueOrDie()); + TF_ASSERT_OK(gpu::GpuInstructionFusion(/*may_duplicate=*/false) + .Run(module_.get()) + .status()); + TF_ASSERT_OK(gpu::GpuInstructionFusion(/*may_duplicate=*/true) + .Run(module_.get()) + .status()); } void RunCopyInsertionPass() { @@ -141,10 +140,7 @@ class WhileTransformerTest : public HloTestBase { Shape condition_result_shape_; }; -// TODO(b/68830972): The while transformer is far too fragile. It patterns -// matches the exact expressions of opcodes. Re-enable when transformation is -// more general -TEST_F(WhileTransformerTest, DISABLED_InductionVariableAtTupleElement0) { +TEST_F(WhileTransformerTest, InductionVariableAtTupleElement0) { // Build computation with induction variable at tuple element 0. auto condition = module_->AddEmbeddedComputation(BuildConditionComputation(0, 10)); @@ -153,18 +149,13 @@ TEST_F(WhileTransformerTest, DISABLED_InductionVariableAtTupleElement0) { // Run HLO Optimization passes. RunFusionPasses(); RunCopyInsertionPass(); - // Run WhileTransformer. - auto result = gpu::CanTransformWhileToFor(while_hlo); - TF_ASSERT_OK(result.status()); - // Check results. - EXPECT_THAT(result.ConsumeValueOrDie(), - Eq(std::tuple(0, 10, 1))); + + auto result = ComputeWhileLoopTripCount(while_hlo); + ASSERT_TRUE(result); + EXPECT_EQ(10, *result); } -// TODO(b/68830972): The while transformer is far too fragile. It patterns -// matches the exact expressions of opcodes. Re-enable when transformation is -// more general -TEST_F(WhileTransformerTest, DISABLED_InductionVariableAtTupleElement1) { +TEST_F(WhileTransformerTest, InductionVariableAtTupleElement1) { // Build computation with induction variable at tuple element 1. auto condition = module_->AddEmbeddedComputation(BuildConditionComputation(1, 10)); @@ -173,19 +164,14 @@ TEST_F(WhileTransformerTest, DISABLED_InductionVariableAtTupleElement1) { // Run HLO Optimization passes. RunFusionPasses(); RunCopyInsertionPass(); - // Run WhileTransformer. - auto result = gpu::CanTransformWhileToFor(while_hlo); - TF_ASSERT_OK(result.status()); - // Check results. - EXPECT_THAT(result.ConsumeValueOrDie(), - Eq(std::tuple(0, 10, 1))); + + auto result = ComputeWhileLoopTripCount(while_hlo); + ASSERT_TRUE(result); + EXPECT_EQ(10, *result); } -// TODO(b/68830972): The while transformer is far too fragile. It patterns -// matches the exact expressions of opcodes. Re-enable when transformation is -// more general -TEST_F(WhileTransformerTest, DISABLED_InvalidLoopLimit) { - // Build computation with invalid loop limit. +TEST_F(WhileTransformerTest, ImpossibleLoopLimit) { + // Build computation with an impossible loop limit. auto condition = module_->AddEmbeddedComputation(BuildConditionComputation(0, 5)); auto body = module_->AddEmbeddedComputation(BuildBodyComputation(0, 1, 1)); @@ -193,17 +179,13 @@ TEST_F(WhileTransformerTest, DISABLED_InvalidLoopLimit) { // Run HLO Optimization passes. RunFusionPasses(); RunCopyInsertionPass(); - // Run WhileTransformer. - auto result = gpu::CanTransformWhileToFor(while_hlo); - ASSERT_FALSE(result.ok()); - EXPECT_THAT(result.status().error_message(), - HasSubstr("Loop start must be less than loop limit.")); + + auto result = ComputeWhileLoopTripCount(while_hlo); + ASSERT_TRUE(result); + EXPECT_EQ(0, *result); } -// TODO(b/68830972): The while transformer is far too fragile. It patterns -// matches the exact expressions of opcodes. Re-enable when transformation is -// more general -TEST_F(WhileTransformerTest, DISABLED_InvalidLoopIncrement) { +TEST_F(WhileTransformerTest, InvalidLoopIncrement) { // Build computation with invalid loop increment. auto condition = module_->AddEmbeddedComputation(BuildConditionComputation(0, 10)); @@ -212,11 +194,9 @@ TEST_F(WhileTransformerTest, DISABLED_InvalidLoopIncrement) { // Run HLO Optimization passes. RunFusionPasses(); RunCopyInsertionPass(); - // Run WhileTransformer. - auto result = gpu::CanTransformWhileToFor(while_hlo); - ASSERT_FALSE(result.ok()); - EXPECT_THAT(result.status().error_message(), - HasSubstr("Loop increment must greater than zero.")); + + auto result = ComputeWhileLoopTripCount(while_hlo); + ASSERT_FALSE(result); } } // namespace diff --git a/tensorflow/compiler/xla/service/while_loop_analysis.cc b/tensorflow/compiler/xla/service/while_loop_analysis.cc new file mode 100644 index 0000000000..af2cb6dc2a --- /dev/null +++ b/tensorflow/compiler/xla/service/while_loop_analysis.cc @@ -0,0 +1,238 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#include "tensorflow/compiler/xla/service/while_loop_analysis.h" +#include "tensorflow/compiler/xla/service/hlo_evaluator.h" + +namespace xla { + +using tensorflow::gtl::nullopt; +using tensorflow::gtl::optional; + +// Finds and returns the non-constant operand in instr. +// +// CHECK-fails if instr doesn't have exactly one unique non-constant operand. +static const HloInstruction* NonConstantOperand(const HloInstruction* instr) { + const HloInstruction* result = nullptr; + for (const HloInstruction* operand : instr->operands()) { + if (!operand->IsConstant()) { + if (result != nullptr) { + CHECK_EQ(result, operand); + } + result = operand; + } + } + CHECK_NE(result, nullptr); + return result; +} + +// If all of instr's operands are either constants or have the form +// get-tuple-element(gte_operand, N) +// for the same value N, returns N. Otherwise, returns nullopt. +static optional GetGTEOperandIndex(const HloInstruction* instr, + const HloInstruction* gte_operand) { + VLOG(2) << "GetGTEOperandIndex(" << instr->ToString() << ", " + << gte_operand->ToString() << ")"; + optional tuple_idx; + for (const HloInstruction* operand : instr->operands()) { + if (operand->IsConstant()) { + continue; + } + // Look through copies. + // TODO(b/68830972): We wouldn't need this if for loop matching on the GPU + // would run before copy insertion. + if (operand->opcode() == HloOpcode::kCopy) { + operand = operand->operand(0); + } + if (operand->opcode() != HloOpcode::kGetTupleElement) { + VLOG(2) << "instr uses something other than gte(gte_operand): " + << operand->ToString(); + return nullopt; + } + if (operand->operand(0) != gte_operand) { + VLOG(2) << "instr has gte whose operand is not gte_operand: " + << operand->ToString(); + return nullopt; + } + if (tuple_idx && tuple_idx != operand->tuple_index()) { + VLOG(2) << "instr has operands with conflicting gte indices, " + << *tuple_idx << " vs " << operand->tuple_index(); + return nullopt; + } + + tuple_idx = operand->tuple_index(); + } + return tuple_idx; +} + +// Tries to get the tuple index of the induction variable of a while loop. +// +// Checks that the loop condition and root both plumb the induction variable +// through the same tuple index, and that they both apply exactly one op to the +// induction variable before deciding whether to do another loop iteration (in +// the loop condition's case) or packing the induction variable into the result +// tuple (in the loop body's case). +// +// Specifically, checks that the loop condition has structure +// +// root = op(constants, get-tuple-elem(param0, N), constants) +// +// and the loop body has the structure +// +// inc = op(constants, get-tuple-elem(param0, N), constants) +// root = tuple(..., inc, ...) // inc is N'th operand of tuple(). +// +// If so, returns N. Otherwise, returns nullopt. +static optional GetLoopInductionVarTupleIdx( + const HloInstruction* while_op) { + CHECK_EQ(while_op->opcode(), HloOpcode::kWhile); + VLOG(2) << "Finding induction variable for loop " + << while_op->ToShortString(); + + // The while_cond computation should have the form + // + // while_cond_root = + // op(constants, get-tuple-elem(while_cond_param, N), constants). + // + // If it does, set indvar_tuple_idx to N. + auto* while_cond = while_op->while_condition(); + auto* while_cond_root = while_cond->root_instruction(); + auto* while_cond_param = while_cond->parameter_instruction(0); + optional indvar_tuple_idx = + GetGTEOperandIndex(while_cond_root, while_cond_param); + if (!indvar_tuple_idx) { + VLOG(2) << "Induction variable not found in loop condition: " + << while_cond->root_instruction()->ToString(); + return nullopt; + } + + // The while_body computation should have the form + // + // while_body_inc = + // op(constants, get-tuple-elem(while_body_param, N), constants) + // while_body_root = tuple(..., while_body_inc, ...) + // + // where while_body_inc is operand N of while_body_root. + auto* while_body = while_op->while_body(); + auto* while_body_root = while_body->root_instruction(); + if (while_body_root->opcode() != HloOpcode::kTuple) { + VLOG(2) << "While body's root is not a tuple instruction: " + << while_body_root->ToString(); + return nullopt; + } + + auto* while_body_inc = while_body_root->operand(*indvar_tuple_idx); + auto* while_body_param = while_body->parameter_instruction(0); + optional while_body_indvar_tuple_idx = + GetGTEOperandIndex(while_body_inc, while_body_param); + if (!while_body_indvar_tuple_idx) { + VLOG(2) + << "Induction variable not found in while body increment instruction: " + << while_body_inc->ToString(); + return nullopt; + } + if (while_body_indvar_tuple_idx != indvar_tuple_idx) { + VLOG(2) << "Tuple index of induction variable does not match between loop " + "condition (" + << *indvar_tuple_idx << ") and while body (" + << *while_body_indvar_tuple_idx << ")"; + return nullopt; + } + + // Finally, check that the while loop's initial value is a tuple with enough + // elements. + auto* while_init = while_op->operand(0); + if (while_init->opcode() != HloOpcode::kTuple) { + VLOG(2) << "While init expected to be a tuple: " << while_init->ToString(); + return nullopt; + } + + VLOG(2) << "Induction variable's tuple index: " << *indvar_tuple_idx; + return indvar_tuple_idx; +} + +optional ComputeWhileLoopTripCount(HloInstruction* while_op, + int64 max_value_returned) { + VLOG(2) << "Getting trip count for loop " << while_op->ToString(); + + // The loop's induction variable is found at + // + // get-tuple-elem(comp->parameter_instruction(0), *indvar_tuple_idx), + // + // where comp is while_op->while_body() or while_op->while_condition(). + optional indvar_tuple_idx = GetLoopInductionVarTupleIdx(while_op); + if (!indvar_tuple_idx) { + return nullopt; + } + + // Now that we know the index of the induction variable, we can we can try to + // compute how many times the loop executes. Start by computing the induction + // variable's initial value. + HloEvaluator evaluator(/*max_loop_iterations=*/0); + auto* while_init = while_op->mutable_operand(0); + auto* indvar_init = while_init->mutable_operand(*indvar_tuple_idx); + StatusOr> indvar_init_result = + evaluator.Evaluate(indvar_init); + if (!indvar_init_result.ok()) { + VLOG(2) << "Couldn't evaluate induction variable init: " + << indvar_init_result.status(); + return nullopt; + } + + auto* while_body = while_op->while_body(); + auto* while_body_indvar_update = + while_body->root_instruction()->operand(*indvar_tuple_idx); + auto* while_body_indvar = NonConstantOperand(while_body_indvar_update); + + // The initial value of the induction variable. + std::unique_ptr indvar_iter_val = + std::move(indvar_init_result).ValueOrDie(); + for (int64 trip_count = 0; trip_count != max_value_returned + 1; + ++trip_count) { + auto* while_cond = while_op->while_condition(); + auto* while_cond_root = while_cond->root_instruction(); + auto* while_cond_indvar = NonConstantOperand(while_cond_root); + StatusOr> result = + evaluator.EvaluateWithSubstitutions( + while_cond_root, {{while_cond_indvar, indvar_iter_val.get()}}); + if (!result.ok()) { + VLOG(2) << "Couldn't evaluate while cond: " << result.status(); + return nullopt; + } + if (result.ValueOrDie()->data() == + tensorflow::gtl::ArraySlice{false}) { + VLOG(2) << "Loop has static trip count of " << trip_count; + return trip_count; + } + + // Calculate the value of the induction variable after one iteration of the + // loop, and check whether the while condition is true with this new value. + StatusOr> indvar_next_result = + evaluator.EvaluateWithSubstitutions( + while_body_indvar_update, + {{while_body_indvar, indvar_iter_val.get()}}); + if (!indvar_next_result.ok()) { + VLOG(2) << "Couldn't evaluate induction variable update: " + << indvar_next_result.status(); + return nullopt; + } + indvar_iter_val = std::move(indvar_next_result).ValueOrDie(); + } + + VLOG(2) << "Loop has unknown trip count."; + return nullopt; +} + +} // namespace xla diff --git a/tensorflow/compiler/xla/service/while_loop_analysis.h b/tensorflow/compiler/xla/service/while_loop_analysis.h new file mode 100644 index 0000000000..bf59813e8c --- /dev/null +++ b/tensorflow/compiler/xla/service/while_loop_analysis.h @@ -0,0 +1,33 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_COMPILER_XLA_SERVICE_WHILE_LOOP_ANALYSIS_H_ +#define TENSORFLOW_COMPILER_XLA_SERVICE_WHILE_LOOP_ANALYSIS_H_ + +#include "tensorflow/compiler/xla/service/hlo_instruction.h" +#include "tensorflow/core/lib/gtl/optional.h" + +namespace xla { + +// Returns the precise trip count of the loop if it's statically known, +// nullopt otherwise. max_value_returned limits the number of steps that are +// evaluated while trying to brute force a loop trip count, trip counts larger +// than max_value_returned result in nullopt. +tensorflow::gtl::optional ComputeWhileLoopTripCount( + HloInstruction *while_op, int64 max_value_returned = 128); + +} // namespace xla + +#endif // TENSORFLOW_COMPILER_XLA_SERVICE_WHILE_LOOP_ANALYSIS_H_ diff --git a/tensorflow/compiler/xla/service/while_loop_simplifier.cc b/tensorflow/compiler/xla/service/while_loop_simplifier.cc index ec05a74e28..dd8697e680 100644 --- a/tensorflow/compiler/xla/service/while_loop_simplifier.cc +++ b/tensorflow/compiler/xla/service/while_loop_simplifier.cc @@ -15,7 +15,7 @@ limitations under the License. #include "tensorflow/compiler/xla/service/while_loop_simplifier.h" #include "tensorflow/compiler/xla/service/call_inliner.h" -#include "tensorflow/compiler/xla/service/hlo_evaluator.h" +#include "tensorflow/compiler/xla/service/while_loop_analysis.h" #include "tensorflow/core/lib/gtl/flatmap.h" #include "tensorflow/core/lib/gtl/optional.h" #include "tensorflow/core/lib/strings/str_util.h" @@ -26,23 +26,6 @@ namespace xla { using tensorflow::gtl::nullopt; using tensorflow::gtl::optional; -// Finds and returns the non-constant operand in instr. -// -// CHECK-fails if instr doesn't have exactly one unique non-constant operand. -static const HloInstruction* NonConstantOperand(const HloInstruction* instr) { - const HloInstruction* result = nullptr; - for (const HloInstruction* operand : instr->operands()) { - if (!operand->IsConstant()) { - if (result != nullptr) { - CHECK_EQ(result, operand); - } - result = operand; - } - } - CHECK_NE(result, nullptr); - return result; -} - // Determines whether the given instruction is a send/recv node, or has a // subcomputation which contains a send/recv node. static bool IsOrContainsSendOrRecv(const HloInstruction* instr); @@ -72,211 +55,6 @@ static bool IsOrContainsSendOrRecv(const HloInstruction* instr) { return false; } -// If all of instr's operands are either constants or have the form -// get-tuple-element(gte_operand, N) -// for the same value N, returns N. Otherwise, returns nullopt. -static optional GetGTEOperandIndex(const HloInstruction* instr, - const HloInstruction* gte_operand) { - VLOG(2) << "GetGTEOperandIndex(" << instr->ToString() << ", " - << gte_operand->ToString() << ")"; - optional tuple_idx; - for (const HloInstruction* operand : instr->operands()) { - if (operand->IsConstant()) { - continue; - } - if (operand->opcode() != HloOpcode::kGetTupleElement) { - VLOG(2) << "instr uses something other than gte(gte_operand): " - << operand->ToString(); - return nullopt; - } - if (operand->operand(0) != gte_operand) { - VLOG(2) << "instr has gte whose operand is not gte_operand: " - << operand->ToString(); - return nullopt; - } - if (tuple_idx && tuple_idx != operand->tuple_index()) { - VLOG(2) << "instr has operands with conflicting gte indices, " - << *tuple_idx << " vs " << operand->tuple_index(); - return nullopt; - } - - tuple_idx = operand->tuple_index(); - } - return tuple_idx; -} - -// Tries to get the tuple index of the induction variable of a while loop. -// -// Checks that the loop condition and root both plumb the induction variable -// through the same tuple index, and that they both apply exactly one op to the -// induction variable before deciding whether to do another loop iteration (in -// the loop condition's case) or packing the induction variable into the result -// tuple (in the loop body's case). -// -// Specifically, checks that the loop condition has structure -// -// root = op(constants, get-tuple-elem(param0, N), constants) -// -// and the loop body has the structure -// -// inc = op(constants, get-tuple-elem(param0, N), constants) -// root = tuple(..., inc, ...) // inc is N'th operand of tuple(). -// -// If so, returns N. Otherwise, returns nullopt. -static optional GetLoopInductionVarTupleIdx( - const HloInstruction* while_op) { - CHECK_EQ(while_op->opcode(), HloOpcode::kWhile); - VLOG(2) << "Finding induction variable for loop " - << while_op->ToShortString(); - - // The while_cond computation should have the form - // - // while_cond_root = - // op(constants, get-tuple-elem(while_cond_param, N), constants). - // - // If it does, set indvar_tuple_idx to N. - auto* while_cond = while_op->while_condition(); - auto* while_cond_root = while_cond->root_instruction(); - auto* while_cond_param = while_cond->parameter_instruction(0); - optional indvar_tuple_idx = - GetGTEOperandIndex(while_cond_root, while_cond_param); - if (!indvar_tuple_idx) { - VLOG(2) << "Induction variable not found in loop condition: " - << while_cond->root_instruction()->ToString(); - return nullopt; - } - - // The while_body computation should have the form - // - // while_body_inc = - // op(constants, get-tuple-elem(while_body_param, N), constants) - // while_body_root = tuple(..., while_body_inc, ...) - // - // where while_body_inc is operand N of while_body_root. - auto* while_body = while_op->while_body(); - auto* while_body_root = while_body->root_instruction(); - if (while_body_root->opcode() != HloOpcode::kTuple) { - VLOG(2) << "While body's root is not a tuple instruction: " - << while_body_root->ToString(); - return nullopt; - } - - auto* while_body_inc = while_body_root->operand(*indvar_tuple_idx); - auto* while_body_param = while_body->parameter_instruction(0); - optional while_body_indvar_tuple_idx = - GetGTEOperandIndex(while_body_inc, while_body_param); - if (!while_body_indvar_tuple_idx) { - VLOG(2) - << "Induction variable not found in while body increment instruction: " - << while_body_inc->ToString(); - return nullopt; - } - if (while_body_indvar_tuple_idx != indvar_tuple_idx) { - VLOG(2) << "Tuple index of induction variable does not match between loop " - "condition (" - << *indvar_tuple_idx << ") and while body (" - << *while_body_indvar_tuple_idx << ")"; - return nullopt; - } - - // Finally, check that the while loop's initial value is a tuple with enough - // elements. - auto* while_init = while_op->operand(0); - if (while_init->opcode() != HloOpcode::kTuple) { - VLOG(2) << "While init expected to be a tuple: " << while_init->ToString(); - return nullopt; - } - - VLOG(2) << "Induction variable's tuple index: " << *indvar_tuple_idx; - return indvar_tuple_idx; -} - -// Tries to determine the number of times the given loop executes. Currently -// simply returns 0, 1, or "can't tell" (nullopt). -static optional GetLoopTripCount(HloInstruction* while_op) { - CHECK_EQ(while_op->opcode(), HloOpcode::kWhile); - VLOG(2) << "Getting trip count for loop " << while_op->ToString(); - - // The loop's induction variable is found at - // - // get-tuple-elem(comp->parameter_instruction(0), *indvar_tuple_idx), - // - // where comp is while_op->while_body() or while_op->while_condition(). - optional indvar_tuple_idx = GetLoopInductionVarTupleIdx(while_op); - if (!indvar_tuple_idx) { - return nullopt; - } - - VLOG(2) << "Induction variable is at index " << *indvar_tuple_idx - << " in input tuple."; - - // Now that we know the index of the induction variable, we can we can try to - // compute how many times the loop executes. Start by computing the induction - // variable's initial value. - HloEvaluator evaluator(/*max_loop_iterations=*/0); - auto* while_init = while_op->mutable_operand(0); - auto* indvar_init = while_init->mutable_operand(*indvar_tuple_idx); - StatusOr> indvar_init_result = - evaluator.Evaluate(indvar_init); - if (!indvar_init_result.ok()) { - VLOG(2) << "Couldn't evaluate induction variable init: " - << indvar_init_result.status(); - return nullopt; - } - - // Evaluates the while loop's condition, returning either "true" (continue - // looping), "false" (stop looping), or nullopt (can't evaluate). - auto evaluate_while_cond = [&](const Literal& indvar) -> optional { - auto* while_cond = while_op->while_condition(); - auto* while_cond_root = while_cond->root_instruction(); - auto* while_cond_indvar = NonConstantOperand(while_cond_root); - StatusOr> result = - evaluator.EvaluateWithSubstitutions(while_cond_root, - {{while_cond_indvar, &indvar}}); - if (!result.ok()) { - VLOG(2) << "Couldn't evaluate while cond: " << result.status(); - return nullopt; - } - return result.ValueOrDie()->data() == - tensorflow::gtl::ArraySlice{true}; - }; - - // The initial value of the induction variable. - const Literal& indvar_iter0_val = *indvar_init_result.ValueOrDie(); - - // Evaluate whether the while condition is true when seeded with - // indvar_iter0_val. - optional while_cond_iter0_val = evaluate_while_cond(indvar_iter0_val); - if (while_cond_iter0_val == false) { - VLOG(2) << "Loop has static trip count of 0."; - return 0; - } - - // Calculate the value of the induction variable after one iteration of the - // loop, and check whether the while condition is true with this new value. - auto* while_body = while_op->while_body(); - auto* while_body_indvar_update = - while_body->root_instruction()->operand(*indvar_tuple_idx); - auto* while_body_indvar = NonConstantOperand(while_body_indvar_update); - StatusOr> indvar_iter1_result = - evaluator.EvaluateWithSubstitutions( - while_body_indvar_update, {{while_body_indvar, &indvar_iter0_val}}); - if (!indvar_iter1_result.ok()) { - VLOG(2) << "Couldn't evaluate induction variable update: " - << indvar_iter1_result.status(); - return nullopt; - } - const Literal& indvar_iter1_val = *indvar_iter1_result.ValueOrDie(); - optional while_cond_iter1_val = evaluate_while_cond(indvar_iter1_val); - if (while_cond_iter1_val == false) { - VLOG(2) << "Determined that loop has static trip count of 1."; - return 1; - } - - VLOG(2) << "Loop has unknown trip count >= 1."; - return nullopt; -} - // Tries to remove elements in a while loop's tuple that aren't used within the // loop. // @@ -577,7 +355,9 @@ static StatusOr TryRemoveWhileLoop(HloInstruction* while_op) { } // Remove while loops with static trip count of 0. - optional trip_count = GetLoopTripCount(while_op); + optional trip_count = + ComputeWhileLoopTripCount(while_op, + /*max_value_returned=*/1); if (trip_count && *trip_count == 0) { // The loop never executes, so the value of the loop is the value of its // "init" operand. -- GitLab From 152c5563ca2474ec9394442086e53b26b41e0773 Mon Sep 17 00:00:00 2001 From: Suyog Gupta Date: Wed, 8 Aug 2018 10:00:54 -0700 Subject: [PATCH 200/437] Add utility function to pruning library to strip a trained graph of pruning-related variables PiperOrigin-RevId: 207902316 --- tensorflow/contrib/model_pruning/BUILD | 42 ++++ tensorflow/contrib/model_pruning/README.md | 46 +++- tensorflow/contrib/model_pruning/__init__.py | 6 +- .../model_pruning/python/pruning_test.py | 1 - .../python/strip_pruning_vars.py | 103 ++++++++ .../python/strip_pruning_vars_lib.py | 142 +++++++++++ .../python/strip_pruning_vars_test.py | 232 ++++++++++++++++++ 7 files changed, 562 insertions(+), 10 deletions(-) create mode 100644 tensorflow/contrib/model_pruning/python/strip_pruning_vars.py create mode 100644 tensorflow/contrib/model_pruning/python/strip_pruning_vars_lib.py create mode 100644 tensorflow/contrib/model_pruning/python/strip_pruning_vars_test.py diff --git a/tensorflow/contrib/model_pruning/BUILD b/tensorflow/contrib/model_pruning/BUILD index 54bd39afac..16ddc38f5a 100644 --- a/tensorflow/contrib/model_pruning/BUILD +++ b/tensorflow/contrib/model_pruning/BUILD @@ -95,6 +95,22 @@ py_library( ], ) +py_library( + name = "strip_pruning_vars_lib", + srcs = ["python/strip_pruning_vars_lib.py"], + srcs_version = "PY2AND3", + visibility = ["//visibility:public"], + deps = [ + ":pruning", + "//tensorflow/python:client", + "//tensorflow/python:framework", + "//tensorflow/python:platform", + "//tensorflow/python:training", + "//third_party/py/numpy", + "@six_archive//:six", + ], +) + py_test( name = "pruning_utils_test", size = "small", @@ -129,6 +145,31 @@ py_test( ], ) +py_test( + name = "strip_pruning_vars_test", + size = "small", + srcs = ["python/strip_pruning_vars_test.py"], + srcs_version = "PY2AND3", + deps = [ + ":layers", + ":pruning", + ":rnn_cells", + ":strip_pruning_vars_lib", + "//tensorflow/python:client_testlib", + ], +) + +py_binary( + name = "strip_pruning_vars", + srcs = ["python/strip_pruning_vars.py"], + srcs_version = "PY2AND3", + visibility = ["//visibility:public"], + deps = [ + ":strip_pruning_vars_lib", + "//tensorflow/python:platform", + ], +) + py_library( name = "init_py", srcs = ["__init__.py"], @@ -145,5 +186,6 @@ py_library( ":learning", ":pruning", ":rnn_cells", + ":strip_pruning_vars_lib", ], ) diff --git a/tensorflow/contrib/model_pruning/README.md b/tensorflow/contrib/model_pruning/README.md index dbe4e124fd..0761dea900 100644 --- a/tensorflow/contrib/model_pruning/README.md +++ b/tensorflow/contrib/model_pruning/README.md @@ -4,7 +4,15 @@ This document describes the API that facilitates magnitude-based pruning of neural network's weight tensors. The API helps inject necessary tensorflow op into the training graph so the model can be pruned while it is being trained. -### Model creation +## Table of contents +1. [Model creation](# model-creation) +2. [Hyperparameters for pruning](#hyperparameters) + - [Block sparsity](#block-sparsity) +3. [Adding pruning ops to the training graph](#adding-pruning-ops) +4. [Removing pruning ops from trained model](#remove) +5. [Example](#example) + +### Model creation The first step involves adding mask and threshold variables to the layers that need to undergo pruning. The variable mask is the same shape as the layer's @@ -33,7 +41,7 @@ auxiliary variables built-in (see * [rnn_cells.MaskedLSTMCell](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/model_pruning/python/layers/rnn_cells.py?l=154) -### Adding pruning ops to the training graph +### Pruning-related hyperparameters The pruning library allows for specification of the following hyper parameters: @@ -64,7 +72,13 @@ is divided into $$n$$ intervals of size equal to the pruning_frequency ($$\Delta t$$). $$s_f$$ is the target_sparsity, $$s_i$$ is the initial_sparsity, $$t_0$$ is the sparsity_function_begin_step. In this equation, the sparsity_function_exponent is set to 3. -### Adding pruning ops to the training graph + +#### Block Sparsity + +For some hardware architectures, it may be beneficial to induce spatially correlated sparsity. To train models in which the weight tensors have block sparse structure, set *block_height* and *block_width* hyperparameters to the desired block configuration (2x2, 4x4, 4x1, 1x8, etc). Currently, block sparsity is only supported for weight tensors which can be squeezed to rank 2. The matrix is partitioned into non-overlapping blocks of size *[block_height, block_dim]* and the either the average or max absolute value in this block is taken as a proxy for the entire block (set by *block_pooling_function* hyperparameter). +The convolution layer tensors are always pruned used block dimensions of [1,1]. + +### Adding pruning ops to the training graph The final step involves adding ops to the training graph that monitor the distribution of the layer's weight magnitudes and determine the layer threshold, @@ -105,7 +119,19 @@ with tf.graph.as_default(): ``` Ensure that `global_step` is being [incremented](https://www.tensorflow.org/api_docs/python/tf/train/Optimizer#minimize), otherwise pruning will not work! -## Example: Pruning and training deep CNNs on the cifar10 dataset +### Removing pruning ops from the trained graph +Once the model is trained, it is necessary to remove the auxiliary variables (mask, threshold) and pruning ops added to the graph in the steps above. This can be accomplished using the `strip_pruning_vars` utility. + +This utility generates a binary GraphDef in which the variables have been converted to constants. In particular, the threshold variables are removed from the graph and the mask variable is fused with the corresponding weight tensor to produce a `masked_weight` tensor. This tensor is sparse, has the same size as the weight tensor, and the sparsity is as set by the `target_sparsity` or the `weight_sparsity_map` hyperparameters above. + +```shell +$ bazel build -c opt contrib/model_pruning:strip_pruning_vars +$ bazel-bin/contrib/model_pruning/strip_pruning_vars --checkpoint_dir=/path/to/checkpoints/ --output_node_names=graph_node1,graph_node2 --output_dir=/tmp --filename=pruning_stripped.pb +``` + +For now, it is assumed that the underlying hardware platform will provide mechanisms for compressing the sparse tensors and/or accelerating the sparse tensor computations. + +## Example: Pruning and training deep CNNs on the cifar10 dataset Please see https://www.tensorflow.org/tutorials/deep_cnn for details on neural network architecture, setting up inputs etc. The additional changes needed to @@ -121,7 +147,7 @@ incorporate pruning are captured in the following: To train the pruned version of cifar10: -```bash +```shell $ examples_dir=contrib/model_pruning/examples $ bazel build -c opt $examples_dir/cifar10:cifar10_{train,eval} $ bazel-bin/$examples_dir/cifar10/cifar10_train --pruning_hparams=name=cifar10_pruning,begin_pruning_step=10000,end_pruning_step=100000,target_sparsity=0.9,sparsity_function_begin_step=10000,sparsity_function_end_step=100000 @@ -133,10 +159,14 @@ Eval: $ bazel-bin/$examples_dir/cifar10/cifar10_eval --run_once ``` -### Block Sparsity +Removing pruning nodes from the trained graph: -For some hardware architectures, it may be beneficial to induce spatially correlated sparsity. To train models in which the weight tensors have block sparse structure, set *block_height* and *block_width* hyperparameters to the desired block configuration (2x2, 4x4, 4x1, 1x8, etc). Currently, block sparsity is only supported for weight tensors which can be squeezed to rank 2. The matrix is partitioned into non-overlapping blocks of size *[block_height, block_dim]* and the either the average or max absolute value in this block is taken as a proxy for the entire block (set by *block_pooling_function* hyperparameter). -The convolution layer tensors are always pruned used block dimensions of [1,1]. +```shell +$ bazel build -c opt contrib/model_pruning:strip_pruning_vars +$ bazel-bin/contrib/model_pruning/strip_pruning_vars --checkpoint_path=/tmp/cifar10_train --output_node_names=softmax_linear/softmax_linear_2 --filename=cifar_pruned.pb +``` + +The generated GraphDef (cifar_pruned.pb) may be visualized using the [`import_pb_to_tensorboard`](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/python/tools/import_pb_to_tensorboard.py) utility ## References diff --git a/tensorflow/contrib/model_pruning/__init__.py b/tensorflow/contrib/model_pruning/__init__.py index d32bedbcd6..6eca54aaee 100644 --- a/tensorflow/contrib/model_pruning/__init__.py +++ b/tensorflow/contrib/model_pruning/__init__.py @@ -33,6 +33,9 @@ from tensorflow.contrib.model_pruning.python.pruning import get_thresholds from tensorflow.contrib.model_pruning.python.pruning import get_weight_sparsity from tensorflow.contrib.model_pruning.python.pruning import get_weights from tensorflow.contrib.model_pruning.python.pruning import Pruning +from tensorflow.contrib.model_pruning.python.strip_pruning_vars_lib import graph_def_from_checkpoint +from tensorflow.contrib.model_pruning.python.strip_pruning_vars_lib import strip_pruning_vars_fn + # pylint: enable=unused-import from tensorflow.python.util.all_util import remove_undocumented @@ -41,7 +44,8 @@ _allowed_symbols = [ 'masked_convolution', 'masked_conv2d', 'masked_fully_connected', 'MaskedBasicLSTMCell', 'MaskedLSTMCell', 'train', 'apply_mask', 'get_masked_weights', 'get_masks', 'get_pruning_hparams', 'get_thresholds', - 'get_weights', 'get_weight_sparsity', 'Pruning' + 'get_weights', 'get_weight_sparsity', 'Pruning', 'strip_pruning_vars_fn', + 'graph_def_from_checkpoint' ] remove_undocumented(__name__, _allowed_symbols) diff --git a/tensorflow/contrib/model_pruning/python/pruning_test.py b/tensorflow/contrib/model_pruning/python/pruning_test.py index 5b67656e9f..33c4ad58bd 100644 --- a/tensorflow/contrib/model_pruning/python/pruning_test.py +++ b/tensorflow/contrib/model_pruning/python/pruning_test.py @@ -60,7 +60,6 @@ class PruningHParamsTest(test.TestCase): self.assertEqual(p._weight_sparsity_map["conv1"], 0.8) self.assertEqual(p._weight_sparsity_map["conv2/kernel"], 0.8) - def testInitWithExternalSparsity(self): with self.test_session(): p = pruning.Pruning(spec=self.pruning_hparams, sparsity=self.sparsity) diff --git a/tensorflow/contrib/model_pruning/python/strip_pruning_vars.py b/tensorflow/contrib/model_pruning/python/strip_pruning_vars.py new file mode 100644 index 0000000000..3385103807 --- /dev/null +++ b/tensorflow/contrib/model_pruning/python/strip_pruning_vars.py @@ -0,0 +1,103 @@ +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== +r"""Removes the auxiliary variables and ops added by the pruning library. + +Usage: + +bazel build tensorflow/contrib/model_pruning:strip_pruning_vars && \ +bazel-bin/tensorflow/contrib/model_pruning/strip_pruning_vars \ +--checkpoint_dir=/tmp/model_ckpts \ +--output_node_names=softmax \ +--output_dir=/tmp \ +--filename=pruning_stripped.pb +""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import argparse +import os +import sys + +from tensorflow.contrib.model_pruning.python import strip_pruning_vars_lib +from tensorflow.python.framework import graph_io +from tensorflow.python.platform import app +from tensorflow.python.platform import tf_logging as logging + +FLAGS = None + + +def strip_pruning_vars(checkpoint_dir, output_node_names, output_dir, filename): + """Remove pruning-related auxiliary variables and ops from the graph. + + Accepts training checkpoints and produces a GraphDef in which the pruning vars + and ops have been removed. + + Args: + checkpoint_dir: Path to the checkpoints. + output_node_names: The name of the output nodes, comma separated. + output_dir: Directory where to write the graph. + filename: Output GraphDef file name. + + Returns: + None + + Raises: + ValueError: if output_nodes_names are not provided. + """ + if not output_node_names: + raise ValueError( + 'Need to specify atleast 1 output node through output_node_names flag') + output_node_names = output_node_names.replace(' ', '').split(',') + + initial_graph_def = strip_pruning_vars_lib.graph_def_from_checkpoint( + checkpoint_dir, output_node_names) + + final_graph_def = strip_pruning_vars_lib.strip_pruning_vars_fn( + initial_graph_def, output_node_names) + graph_io.write_graph(final_graph_def, output_dir, filename, as_text=False) + logging.info('\nFinal graph written to %s', os.path.join( + output_dir, filename)) + + +def main(unused_args): + return strip_pruning_vars(FLAGS.checkpoint_dir, FLAGS.output_node_names, + FLAGS.output_dir, FLAGS.filename) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.register('type', 'bool', lambda v: v.lower() == 'true') + parser.add_argument( + '--checkpoint_dir', type=str, default='', help='Path to the checkpoints.') + parser.add_argument( + '--output_node_names', + type=str, + default='', + help='The name of the output nodes, comma separated.') + parser.add_argument( + '--output_dir', + type=str, + default='/tmp', + help='Directory where to write the graph.') + parser.add_argument( + '--filename', + type=str, + default='pruning_stripped.pb', + help='Output \'GraphDef\' file name.') + + FLAGS, unparsed = parser.parse_known_args() + app.run(main=main, argv=[sys.argv[0]] + unparsed) diff --git a/tensorflow/contrib/model_pruning/python/strip_pruning_vars_lib.py b/tensorflow/contrib/model_pruning/python/strip_pruning_vars_lib.py new file mode 100644 index 0000000000..fc4b10863f --- /dev/null +++ b/tensorflow/contrib/model_pruning/python/strip_pruning_vars_lib.py @@ -0,0 +1,142 @@ +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== +"""Utilities to remove pruning-related ops and variables from a GraphDef. +""" + +# pylint: disable=missing-docstring +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import numpy as np + +from tensorflow.core.framework import attr_value_pb2 +from tensorflow.core.framework import graph_pb2 +from tensorflow.core.framework import node_def_pb2 +from tensorflow.python.client import session +from tensorflow.python.framework import graph_util +from tensorflow.python.framework import importer +from tensorflow.python.framework import ops +from tensorflow.python.framework import tensor_util +from tensorflow.python.platform import tf_logging as logging +from tensorflow.python.training import saver as saver_lib + + +def _node_name(tensor_name): + """Remove the trailing ':0' from the variable name.""" + if ':' not in tensor_name: + return tensor_name + + return tensor_name.split(':')[0] + + +def _tensor_name(node_name): + """Appends the :0 in the op name to get the canonical tensor name.""" + if ':' in node_name: + return node_name + + return node_name + ':0' + + +def _get_masked_weights(input_graph_def): + """Extracts masked_weights from the graph as a dict of {var_name:ndarray}.""" + input_graph = ops.Graph() + with input_graph.as_default(): + importer.import_graph_def(input_graph_def, name='') + + with session.Session(graph=input_graph) as sess: + masked_weights_dict = {} + for node in input_graph_def.node: + if 'masked_weight' in node.name: + masked_weight_val = sess.run( + sess.graph.get_tensor_by_name(_tensor_name(node.name))) + logging.info( + '%s has %d values, %1.2f%% zeros \n', node.name, + np.size(masked_weight_val), + 100 - float(100 * np.count_nonzero(masked_weight_val)) / + np.size(masked_weight_val)) + masked_weights_dict.update({node.name: masked_weight_val}) + return masked_weights_dict + + +def strip_pruning_vars_fn(input_graph_def, output_node_names): + """Removes mask variable from the graph. + + Replaces the masked_weight tensor with element-wise multiplication of mask + and the corresponding weight variable. + + Args: + input_graph_def: A GraphDef in which the variables have been converted to + constants. This is typically the output of + tf.graph_util.convert_variables_to_constant() + output_node_names: List of name strings for the result nodes of the graph + + Returns: + A GraphDef in which pruning-related variables have been removed + """ + masked_weights_dict = _get_masked_weights(input_graph_def) + pruned_graph_def = graph_pb2.GraphDef() + + # Replace masked_weight with a const op containing the + # result of tf.multiply(mask,weight) + for node in input_graph_def.node: + output_node = node_def_pb2.NodeDef() + if 'masked_weight' in node.name: + output_node.op = 'Const' + output_node.name = node.name + dtype = node.attr['T'] + data = masked_weights_dict[node.name] + output_node.attr['dtype'].CopyFrom(dtype) + output_node.attr['value'].CopyFrom( + attr_value_pb2.AttrValue(tensor=tensor_util.make_tensor_proto(data))) + + else: + output_node.CopyFrom(node) + pruned_graph_def.node.extend([output_node]) + + # Remove stranded nodes: mask and weights + return graph_util.extract_sub_graph(pruned_graph_def, output_node_names) + + +def graph_def_from_checkpoint(checkpoint_dir, output_node_names): + """Converts checkpoint data to GraphDef. + + Reads the latest checkpoint data and produces a GraphDef in which the + variables have been converted to constants. + + Args: + checkpoint_dir: Path to the checkpoints. + output_node_names: List of name strings for the result nodes of the graph. + + Returns: + A GraphDef from the latest checkpoint + + Raises: + ValueError: if no checkpoint is found + """ + checkpoint_path = saver_lib.latest_checkpoint(checkpoint_dir) + if checkpoint_path is None: + raise ValueError('Could not find a checkpoint at: {0}.' + .format(checkpoint_dir)) + + saver_for_restore = saver_lib.import_meta_graph( + checkpoint_path + '.meta', clear_devices=True) + with session.Session() as sess: + saver_for_restore.restore(sess, checkpoint_path) + graph_def = ops.get_default_graph().as_graph_def() + output_graph_def = graph_util.convert_variables_to_constants( + sess, graph_def, output_node_names) + + return output_graph_def diff --git a/tensorflow/contrib/model_pruning/python/strip_pruning_vars_test.py b/tensorflow/contrib/model_pruning/python/strip_pruning_vars_test.py new file mode 100644 index 0000000000..255daa0360 --- /dev/null +++ b/tensorflow/contrib/model_pruning/python/strip_pruning_vars_test.py @@ -0,0 +1,232 @@ +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== +"""Tests for strip_pruning_vars.""" +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import re + +from tensorflow.contrib.model_pruning.python import pruning +from tensorflow.contrib.model_pruning.python import strip_pruning_vars_lib +from tensorflow.contrib.model_pruning.python.layers import layers +from tensorflow.contrib.model_pruning.python.layers import rnn_cells +from tensorflow.python.framework import dtypes +from tensorflow.python.framework import graph_util +from tensorflow.python.framework import importer +from tensorflow.python.framework import ops +from tensorflow.python.ops import array_ops +from tensorflow.python.ops import random_ops +from tensorflow.python.ops import rnn +from tensorflow.python.ops import rnn_cell as tf_rnn_cells +from tensorflow.python.ops import state_ops +from tensorflow.python.ops import variable_scope +from tensorflow.python.ops import variables +from tensorflow.python.platform import test +from tensorflow.python.training import training_util + + +def _get_number_pruning_vars(graph_def): + number_vars = 0 + for node in graph_def.node: + if re.match(r"^.*(mask$)|(threshold$)", node.name): + number_vars += 1 + return number_vars + + +def _get_node_names(tensor_names): + return [ + strip_pruning_vars_lib._node_name(tensor_name) + for tensor_name in tensor_names + ] + + +class StripPruningVarsTest(test.TestCase): + + def setUp(self): + param_list = [ + "pruning_frequency=1", "begin_pruning_step=1", "end_pruning_step=10", + "nbins=2048", "threshold_decay=0.0" + ] + self.initial_graph = ops.Graph() + self.initial_graph_def = None + self.final_graph = ops.Graph() + self.final_graph_def = None + self.pruning_spec = ",".join(param_list) + with self.initial_graph.as_default(): + self.sparsity = variables.Variable(0.5, name="sparsity") + self.global_step = training_util.get_or_create_global_step() + self.increment_global_step = state_ops.assign_add(self.global_step, 1) + self.mask_update_op = None + + def _build_convolutional_model(self, number_of_layers): + # Create a graph with several conv2d layers + kernel_size = 3 + base_depth = 4 + depth_step = 7 + height, width = 7, 9 + with variable_scope.variable_scope("conv_model"): + input_tensor = array_ops.ones((8, height, width, base_depth)) + top_layer = input_tensor + for ix in range(number_of_layers): + top_layer = layers.masked_conv2d( + top_layer, + base_depth + (ix + 1) * depth_step, + kernel_size, + scope="Conv_" + str(ix)) + + return top_layer + + def _build_fully_connected_model(self, number_of_layers): + base_depth = 4 + depth_step = 7 + + input_tensor = array_ops.ones((8, base_depth)) + + top_layer = input_tensor + + with variable_scope.variable_scope("fc_model"): + for ix in range(number_of_layers): + top_layer = layers.masked_fully_connected( + top_layer, base_depth + (ix + 1) * depth_step) + + return top_layer + + def _build_lstm_model(self, number_of_layers): + batch_size = 8 + dim = 10 + inputs = variables.Variable(random_ops.random_normal([batch_size, dim])) + + def lstm_cell(): + return rnn_cells.MaskedBasicLSTMCell( + dim, forget_bias=0.0, state_is_tuple=True, reuse=False) + + cell = tf_rnn_cells.MultiRNNCell( + [lstm_cell() for _ in range(number_of_layers)], state_is_tuple=True) + + outputs = rnn.static_rnn( + cell, [inputs], + initial_state=cell.zero_state(batch_size, dtypes.float32)) + + return outputs + + def _prune_model(self, session): + pruning_hparams = pruning.get_pruning_hparams().parse(self.pruning_spec) + p = pruning.Pruning(pruning_hparams, sparsity=self.sparsity) + self.mask_update_op = p.conditional_mask_update_op() + + variables.global_variables_initializer().run() + for _ in range(20): + session.run(self.mask_update_op) + session.run(self.increment_global_step) + + def _get_outputs(self, session, input_graph, tensors_list, graph_prefix=None): + outputs = [] + + for output_tensor in tensors_list: + if graph_prefix: + output_tensor = graph_prefix + "/" + output_tensor + outputs.append( + session.run(session.graph.get_tensor_by_name(output_tensor))) + + return outputs + + def _get_initial_outputs(self, output_tensor_names_list): + with self.test_session(graph=self.initial_graph) as sess1: + self._prune_model(sess1) + reference_outputs = self._get_outputs(sess1, self.initial_graph, + output_tensor_names_list) + + self.initial_graph_def = graph_util.convert_variables_to_constants( + sess1, sess1.graph.as_graph_def(), + _get_node_names(output_tensor_names_list)) + return reference_outputs + + def _get_final_outputs(self, output_tensor_names_list): + self.final_graph_def = strip_pruning_vars_lib.strip_pruning_vars_fn( + self.initial_graph_def, _get_node_names(output_tensor_names_list)) + _ = importer.import_graph_def(self.final_graph_def, name="final") + + with self.test_session(self.final_graph) as sess2: + final_outputs = self._get_outputs( + sess2, + self.final_graph, + output_tensor_names_list, + graph_prefix="final") + return final_outputs + + def _check_removal_of_pruning_vars(self, number_masked_layers): + self.assertEqual( + _get_number_pruning_vars(self.initial_graph_def), number_masked_layers) + self.assertEqual(_get_number_pruning_vars(self.final_graph_def), 0) + + def _check_output_equivalence(self, initial_outputs, final_outputs): + for initial_output, final_output in zip(initial_outputs, final_outputs): + self.assertAllEqual(initial_output, final_output) + + def testConvolutionalModel(self): + with self.initial_graph.as_default(): + number_masked_conv_layers = 5 + top_layer = self._build_convolutional_model(number_masked_conv_layers) + output_tensor_names = [top_layer.name] + initial_outputs = self._get_initial_outputs(output_tensor_names) + + # Remove pruning-related nodes. + with self.final_graph.as_default(): + final_outputs = self._get_final_outputs(output_tensor_names) + + # Check that the final graph has no pruning-related vars + self._check_removal_of_pruning_vars(number_masked_conv_layers) + + # Check that outputs remain the same after removal of pruning-related nodes + self._check_output_equivalence(initial_outputs, final_outputs) + + def testFullyConnectedModel(self): + with self.initial_graph.as_default(): + number_masked_fc_layers = 3 + top_layer = self._build_fully_connected_model(number_masked_fc_layers) + output_tensor_names = [top_layer.name] + initial_outputs = self._get_initial_outputs(output_tensor_names) + + # Remove pruning-related nodes. + with self.final_graph.as_default(): + final_outputs = self._get_final_outputs(output_tensor_names) + + # Check that the final graph has no pruning-related vars + self._check_removal_of_pruning_vars(number_masked_fc_layers) + + # Check that outputs remain the same after removal of pruning-related nodes + self._check_output_equivalence(initial_outputs, final_outputs) + + def testLSTMModel(self): + with self.initial_graph.as_default(): + number_masked_lstm_layers = 2 + outputs = self._build_lstm_model(number_masked_lstm_layers) + output_tensor_names = [outputs[0][0].name] + initial_outputs = self._get_initial_outputs(output_tensor_names) + + # Remove pruning-related nodes. + with self.final_graph.as_default(): + final_outputs = self._get_final_outputs(output_tensor_names) + + # Check that the final graph has no pruning-related vars + self._check_removal_of_pruning_vars(number_masked_lstm_layers) + + # Check that outputs remain the same after removal of pruning-related nodes + self._check_output_equivalence(initial_outputs, final_outputs) + + +if __name__ == "__main__": + test.main() -- GitLab From 215b91dd541cd22a6dda3ce3fe2a7ee630cb8253 Mon Sep 17 00:00:00 2001 From: Akshay Agrawal Date: Wed, 8 Aug 2018 10:01:22 -0700 Subject: [PATCH 201/437] Fix use-after-free in (Stateful)PartitionedCallOp. Before the introduction of StatefulPartitionedCallOp, it was guaranteed that the function would only be partitioned once. That this invariant is no longer true was not reflected in the code prior to this change --- `overlay_lib_` was reset every time the function was re-partitioned. The FunctionLibraryRuntime keeps pointers to overlay libraries, so we need to keep the objects around. PiperOrigin-RevId: 207902409 --- .../core/kernels/partitioned_function_ops.cc | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/tensorflow/core/kernels/partitioned_function_ops.cc b/tensorflow/core/kernels/partitioned_function_ops.cc index a7a9609c21..33ed044dae 100644 --- a/tensorflow/core/kernels/partitioned_function_ops.cc +++ b/tensorflow/core/kernels/partitioned_function_ops.cc @@ -114,8 +114,16 @@ class PartitionedCallOp : public AsyncOpKernel { // The FunctionLibraryRuntime's library cannot be mutated from within // an OpKernel, so functions are instantiated in an overlay library. - overlay_lib_.reset(new FunctionLibraryDefinition( - *lib->GetFunctionLibraryDefinition())); + OP_REQUIRES_ASYNC( + ctx, overlay_libs_.find(lib) == overlay_libs_.end(), + errors::Internal("Found an overlay library but did not " + "find cached function partitions; " + "this indicates a bug."), + done); + FunctionLibraryDefinition* overlay_lib = + new FunctionLibraryDefinition(*lib->GetFunctionLibraryDefinition()); + overlay_libs_.emplace(lib, overlay_lib); + auto handles = tensorflow::MakeUnique>(); for (const auto& pair : subgraphs) { // TODO(akshayka): Fail gracefully if the set of devices corresponds @@ -125,13 +133,13 @@ class PartitionedCallOp : public AsyncOpKernel { OP_REQUIRES_OK_ASYNC( ctx, UpdateArgAndRetMetadata(target, subgraph.get()), done); FunctionDef shard; - string unique_name = UniquifyFunctionName(func_.name()); + string unique_name = UniquifyFunctionName(overlay_lib, func_.name()); OP_REQUIRES_OK_ASYNC( ctx, GraphToFunctionDef(*subgraph, unique_name, &shard), done); - OP_REQUIRES_OK_ASYNC(ctx, overlay_lib_->AddFunctionDef(shard), done); + OP_REQUIRES_OK_ASYNC(ctx, overlay_lib->AddFunctionDef(shard), done); FunctionLibraryRuntime::InstantiateOptions opts; opts.target = target; - opts.overlay_lib = overlay_lib_.get(); + opts.overlay_lib = overlay_lib; FHandle handle; OP_REQUIRES_OK_ASYNC( ctx, @@ -399,10 +407,11 @@ class PartitionedCallOp : public AsyncOpKernel { } } - string UniquifyFunctionName(const string& name) { + string UniquifyFunctionName(const FunctionLibraryDefinition* function_library, + const string& name) { for (;; ++suffix_) { const string candidate = strings::StrCat(name, "_", suffix_); - if (overlay_lib_->Find(candidate) == nullptr) { + if (function_library->Find(candidate) == nullptr) { return candidate; } } @@ -410,14 +419,16 @@ class PartitionedCallOp : public AsyncOpKernel { NameAttrList func_; string local_device_name_; - // Function shards are added to `overlay_lib_`. - std::unique_ptr overlay_lib_; - // Contains maps from device names to handles of function shards, keyed by + // Contains maps from device names to handles of function partitions, keyed by // FunctionLibraryRuntime pointers. (Because this kernel may be instantiated // for a stateful op, different invocations of it may use different FLRs.) gtl::FlatMap>> function_handles_ GUARDED_BY(mu_); + // Function partitions are added to overlay libraries. + gtl::FlatMap> + overlay_libs_ GUARDED_BY(mu_); // Map from device name to the indices of the arguments and return values // placed on that device. Read-only after the first invocation. gtl::FlatMap arg_and_ret_indices_; @@ -427,7 +438,7 @@ class PartitionedCallOp : public AsyncOpKernel { mutex mu_; - // Used to uniquify function names in `overlay_lib_`. + // Used to uniquify function names in `overlay_libs_`. uint32 suffix_ = 0; }; REGISTER_KERNEL_BUILDER(Name("PartitionedCall").Device(DEVICE_CPU), -- GitLab From 4d084996b88f405da2ff8b7ad6d62ed962e8741e Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Wed, 8 Aug 2018 10:08:25 -0700 Subject: [PATCH 202/437] Clarify that min <= max is actually a requirement. PiperOrigin-RevId: 207903789 --- tensorflow/python/ops/clip_ops.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tensorflow/python/ops/clip_ops.py b/tensorflow/python/ops/clip_ops.py index 75c459a9cf..e2580e8a2e 100644 --- a/tensorflow/python/ops/clip_ops.py +++ b/tensorflow/python/ops/clip_ops.py @@ -42,6 +42,9 @@ def clip_by_value(t, clip_value_min, clip_value_max, Any values less than `clip_value_min` are set to `clip_value_min`. Any values greater than `clip_value_max` are set to `clip_value_max`. + Note: `clip_value_min` needs to be smaller or equal to `clip_value_max` for + correct results. + Args: t: A `Tensor`. clip_value_min: A 0-D (scalar) `Tensor`, or a `Tensor` with the same shape -- GitLab From 4a4ae62c75f1de3455c3adea96802d22c7e986e3 Mon Sep 17 00:00:00 2001 From: Alexandre Passos Date: Wed, 8 Aug 2018 10:48:23 -0700 Subject: [PATCH 203/437] Allows differentiating tfe.defun functions with loops in eager mode. Adopts a minimal sensible policy for step containers: starting a graident tape creates a step container; inner tapes do nothing; popping out of the outermost tape will reset that step container. This should allow us to have reasonable behavior in the presence of step-container-scoped things for a while. Ideally we'll move away from them in favor of lists but the infrastructure isn't ready yet. PiperOrigin-RevId: 207911091 --- tensorflow/c/eager/c_api.cc | 4 +++ tensorflow/c/eager/c_api.h | 10 ++++++ .../core/common_runtime/eager/context.cc | 31 +++++++++++++++++++ .../core/common_runtime/eager/context.h | 8 +++++ .../core/common_runtime/eager/execute.cc | 7 ++++- .../common_runtime/eager/kernel_and_device.cc | 31 ++++++++++++------- .../common_runtime/eager/kernel_and_device.h | 3 ++ tensorflow/python/eager/backprop.py | 4 +++ tensorflow/python/eager/context.py | 6 ++++ tensorflow/python/eager/function_test.py | 2 -- tensorflow/python/pywrap_tfe.i | 2 ++ 11 files changed, 93 insertions(+), 15 deletions(-) diff --git a/tensorflow/c/eager/c_api.cc b/tensorflow/c/eager/c_api.cc index a0a44440c8..d7073d8e05 100644 --- a/tensorflow/c/eager/c_api.cc +++ b/tensorflow/c/eager/c_api.cc @@ -719,6 +719,10 @@ TFE_Op* GetFunc(TFE_Context* ctx, const tensorflow::NameAttrList& func, } } // namespace +void TFE_ContextStartStep(TFE_Context* ctx) { ctx->context.StartStep(); } + +void TFE_ContextEndStep(TFE_Context* ctx) { ctx->context.EndStep(); } + namespace tensorflow { void SetOpAttrValueScalar(TFE_Context* ctx, TFE_Op* op, const tensorflow::AttrValue& default_value, diff --git a/tensorflow/c/eager/c_api.h b/tensorflow/c/eager/c_api.h index 25cf7adbc7..092af45731 100644 --- a/tensorflow/c/eager/c_api.h +++ b/tensorflow/c/eager/c_api.h @@ -380,6 +380,16 @@ TF_CAPI_EXPORT extern void TFE_ContextExportRunMetadata(TFE_Context* ctx, TF_Buffer* buf, TF_Status* status); +// Some TF ops need a step container to be set to limit the lifetime of some +// resources (mostly TensorArray and Stack, used in while loop gradients in +// graph mode). Calling this on a context tells it to start a step. +TF_CAPI_EXPORT extern void TFE_ContextStartStep(TFE_Context* ctx); + +// Ends a step. When there is no active step (that is, every started step has +// been ended) step containers will be cleared. Note: it is not safe to call +// TFE_ContextEndStep while ops which rely on the step container may be running. +TF_CAPI_EXPORT extern void TFE_ContextEndStep(TFE_Context* ctx); + #ifdef __cplusplus } /* end extern "C" */ #endif diff --git a/tensorflow/core/common_runtime/eager/context.cc b/tensorflow/core/common_runtime/eager/context.cc index 6ab2d1ebf1..e5fe87fc37 100644 --- a/tensorflow/core/common_runtime/eager/context.cc +++ b/tensorflow/core/common_runtime/eager/context.cc @@ -16,6 +16,7 @@ limitations under the License. #include "tensorflow/core/common_runtime/eager/context.h" #include "tensorflow/core/common_runtime/process_util.h" +#include "tensorflow/core/framework/resource_mgr.h" #include "tensorflow/core/lib/core/blocking_counter.h" #include "tensorflow/core/util/env_var.h" @@ -46,6 +47,7 @@ EagerContext::EagerContext(const SessionOptions& opts, local_device_manager_.get(), opts.env, TF_GRAPH_DEF_VERSION, &func_lib_def_, {}, thread_pool_.get())), log_device_placement_(opts.config.log_device_placement()), + num_active_steps_(0), async_default_(async), env_(opts.env), use_send_tensor_rpc_(false) { @@ -194,6 +196,35 @@ Status EagerContext::FindDeviceByName(const string& name, Device** result) { return Status::OK(); } +void EagerContext::StartStep() { + mutex_lock ml(metadata_mu_); + num_active_steps_++; + if (step_container_ == nullptr) { + step_container_.reset( + new ScopedStepContainer(0, [this](const string& name) { + for (Device* device : devices_) { + device->resource_manager()->Cleanup(name).IgnoreError(); + } + })); + } +} + +void EagerContext::EndStep() { + mutex_lock ml(metadata_mu_); + num_active_steps_--; + if (num_active_steps_ == 0) { + step_container_.reset(); + } +} + +ScopedStepContainer* EagerContext::StepContainer() { + if (num_active_steps_.load() == 0) { + return nullptr; + } + mutex_lock ml(metadata_mu_); + return step_container_.get(); +} + Status EagerContext::MaybeRegisterFunctionRemotely(const FunctionDef& fdef) { if (remote_device_manager_ == nullptr) return Status::OK(); #ifndef __ANDROID__ diff --git a/tensorflow/core/common_runtime/eager/context.h b/tensorflow/core/common_runtime/eager/context.h index a0b612e6e5..3eea56b5e3 100644 --- a/tensorflow/core/common_runtime/eager/context.h +++ b/tensorflow/core/common_runtime/eager/context.h @@ -153,6 +153,10 @@ class EagerContext { void SetShouldStoreMetadata(bool value); RunMetadata* RunMetadataProto() { return &run_metadata_; } + void StartStep(); + void EndStep(); + ScopedStepContainer* StepContainer(); + FunctionLibraryDefinition* FuncLibDef() { return &func_lib_def_; } #ifndef __ANDROID__ @@ -236,6 +240,10 @@ class EagerContext { // EagerExecutor for async execution. EagerExecutor executor_; + // Information related to step containers. + std::atomic num_active_steps_; + std::unique_ptr step_container_ GUARDED_BY(metadata_mu_); + // True if the default value for execution mode is async. Note that this value // can be overridden per thread based on `thread_local_async` overrides. const bool async_default_; diff --git a/tensorflow/core/common_runtime/eager/execute.cc b/tensorflow/core/common_runtime/eager/execute.cc index 3837405e7f..51b770d035 100644 --- a/tensorflow/core/common_runtime/eager/execute.cc +++ b/tensorflow/core/common_runtime/eager/execute.cc @@ -653,7 +653,12 @@ Status EagerExecute(EagerContext* ctx, Device* device, // FunctionLibraryDefinition?). TODO(apassos) figure out how to record stats // for ops which are a part of functions. // TODO(agarwal): change Run to take vector of handles ? - TF_RETURN_IF_ERROR(kernel->Run(&inputs, &outputs, maybe_stats)); + ScopedStepContainer* container = ctx->StepContainer(); + if (container == nullptr) { + TF_RETURN_IF_ERROR(kernel->Run(&inputs, &outputs, maybe_stats)); + } else { + TF_RETURN_IF_ERROR(kernel->Run(container, &inputs, &outputs, maybe_stats)); + } if (maybe_stats != nullptr) { int64 nanos = Env::Default()->NowNanos(); maybe_stats->set_op_end_rel_micros(nanos / EnvTime::kMicrosToNanos - diff --git a/tensorflow/core/common_runtime/eager/kernel_and_device.cc b/tensorflow/core/common_runtime/eager/kernel_and_device.cc index dae5d1983f..3d61ff4dc2 100644 --- a/tensorflow/core/common_runtime/eager/kernel_and_device.cc +++ b/tensorflow/core/common_runtime/eager/kernel_and_device.cc @@ -60,12 +60,22 @@ Status KernelAndDevice::Init(const NodeDef& ndef, FunctionLibraryRuntime* flib, return s; } -Status KernelAndDevice::Run(std::vector* input_tensors, - std::vector* output_tensors, +Status KernelAndDevice::Run(std::vector* inputs, + std::vector* outputs, NodeExecStats* stats) { - gtl::InlinedVector inputs; - for (Tensor& t : *input_tensors) { - inputs.push_back(TensorValue(&t)); + ScopedStepContainer step_container(0, [this](const string& name) { + device_->resource_manager()->Cleanup(name).IgnoreError(); + }); + return this->Run(&step_container, inputs, outputs, stats); +} + +Status KernelAndDevice::Run(ScopedStepContainer* step_container, + std::vector* inputs, + std::vector* outputs, + NodeExecStats* stats) { + gtl::InlinedVector input_vector; + for (Tensor& t : *inputs) { + input_vector.push_back(TensorValue(&t)); } std::vector out_attrs(kernel_->num_outputs()); @@ -77,7 +87,7 @@ Status KernelAndDevice::Run(std::vector* input_tensors, OpKernelContext::Params params; params.device = device_; params.frame_iter = FrameAndIter(0, 0); - params.inputs = &inputs; + params.inputs = &input_vector; params.op_kernel = kernel_.get(); params.resource_manager = device_->resource_manager(); params.output_attr_array = gtl::vector_as_array(&out_attrs); @@ -94,10 +104,7 @@ Status KernelAndDevice::Run(std::vector* input_tensors, params.runner = runner_; } - ScopedStepContainer step_container(0, [this](const string& name) { - device_->resource_manager()->Cleanup(name).IgnoreError(); - }); - params.step_container = &step_container; + params.step_container = step_container; OpKernelContext context(¶ms); @@ -114,9 +121,9 @@ Status KernelAndDevice::Run(std::vector* input_tensors, } if (!context.status().ok()) return context.status(); - output_tensors->clear(); + outputs->clear(); for (int i = 0; i < context.num_outputs(); ++i) { - output_tensors->push_back(Tensor(*context.mutable_output(i))); + outputs->push_back(Tensor(*context.mutable_output(i))); } if (stats != nullptr) { for (const auto& allocator_pair : context.wrapped_allocators()) { diff --git a/tensorflow/core/common_runtime/eager/kernel_and_device.h b/tensorflow/core/common_runtime/eager/kernel_and_device.h index c0b676b285..751cf687b2 100644 --- a/tensorflow/core/common_runtime/eager/kernel_and_device.h +++ b/tensorflow/core/common_runtime/eager/kernel_and_device.h @@ -70,6 +70,9 @@ class KernelAndDevice { Status Run(std::vector* inputs, std::vector* outputs, NodeExecStats* stats); + Status Run(ScopedStepContainer* step_container, std::vector* inputs, + std::vector* outputs, NodeExecStats* stats); + const OpKernel* kernel() const { return kernel_.get(); } Device* device() const { return device_; } diff --git a/tensorflow/python/eager/backprop.py b/tensorflow/python/eager/backprop.py index 5f60f62874..728b283695 100644 --- a/tensorflow/python/eager/backprop.py +++ b/tensorflow/python/eager/backprop.py @@ -705,6 +705,7 @@ class GradientTape(object): self._tape = None self._persistent = persistent self._recording = False + context.context().start_step() def __enter__(self): """Enters a context inside which operations are recorded on this tape.""" @@ -733,6 +734,9 @@ class GradientTape(object): tape.pop_tape(self._tape) self._recording = False + def __del__(self): + context.context().end_step() + def watch(self, tensor): """Ensures that `tensor` is being traced by this tape. diff --git a/tensorflow/python/eager/context.py b/tensorflow/python/eager/context.py index c79294895b..09223c86d4 100644 --- a/tensorflow/python/eager/context.py +++ b/tensorflow/python/eager/context.py @@ -603,6 +603,12 @@ class Context(object): """Returns a stack of context switches.""" return self._context_switches + def start_step(self): + pywrap_tensorflow.TFE_ContextStartStep(self._handle) + + def end_step(self): + pywrap_tensorflow.TFE_ContextEndStep(self._handle) + _context = None _context_lock = threading.Lock() diff --git a/tensorflow/python/eager/function_test.py b/tensorflow/python/eager/function_test.py index 8084df4e8e..06b4e732a1 100644 --- a/tensorflow/python/eager/function_test.py +++ b/tensorflow/python/eager/function_test.py @@ -232,8 +232,6 @@ class FunctionTest(test.TestCase): @test_util.run_in_graph_and_eager_modes() def testGraphLoopGradient(self): - if context.executing_eagerly(): - self.skipTest('TODO(apassos): support loops in defuns in eager') @function.defun def f(x): diff --git a/tensorflow/python/pywrap_tfe.i b/tensorflow/python/pywrap_tfe.i index 1b69e0d06c..157f2341e0 100644 --- a/tensorflow/python/pywrap_tfe.i +++ b/tensorflow/python/pywrap_tfe.i @@ -63,6 +63,8 @@ limitations under the License. %rename("%s") TFE_DeleteContextOptions; %rename("%s") TFE_Py_TensorShapeSlice; %rename("%s") TFE_Py_TensorShapeOnDevice; +%rename("%s") TFE_ContextStartStep; +%rename("%s") TFE_ContextEndStep; %{ #include "tensorflow/python/eager/pywrap_tfe.h" -- GitLab From b93ba55c00df027fcd3b00f025eed4c9c487de6e Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Wed, 8 Aug 2018 11:03:20 -0700 Subject: [PATCH 204/437] Allow empty shapes in certain cases within toco PiperOrigin-RevId: 207913842 --- .../contrib/lite/testing/generate_examples.py | 4 -- tensorflow/contrib/lite/toco/dump_graphviz.cc | 2 +- tensorflow/contrib/lite/toco/tooling_util.cc | 43 ++++++++++++------- tensorflow/contrib/lite/toco/tooling_util.h | 7 ++- 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/tensorflow/contrib/lite/testing/generate_examples.py b/tensorflow/contrib/lite/testing/generate_examples.py index a58924693e..73c05e21b6 100644 --- a/tensorflow/contrib/lite/testing/generate_examples.py +++ b/tensorflow/contrib/lite/testing/generate_examples.py @@ -90,8 +90,6 @@ TEST_INPUT_DEPTH = 3 # matching the expression will be considered due to the corresponding bug. KNOWN_BUGS = { # TOCO doesn't support scalars as input. - r"relu.*input_shape=\[\]": "67587484", - r"sigmoid.*input_shape=\[\]": "67645668", # Concat doesn't work with a single input tensor r"concat.*num_tensors=1": "67378344", # Transposition in MatMul is not fully supported. @@ -104,8 +102,6 @@ KNOWN_BUGS = { r"div.*int32": "72051395", # No support for SplitV r"split.*num_or_size_splits=\[2,2\]": "73377559", - # Scalar constants don't work. - r"constant.*shape=\[\]": "109811500", } diff --git a/tensorflow/contrib/lite/toco/dump_graphviz.cc b/tensorflow/contrib/lite/toco/dump_graphviz.cc index 6877fb237c..30525efd23 100644 --- a/tensorflow/contrib/lite/toco/dump_graphviz.cc +++ b/tensorflow/contrib/lite/toco/dump_graphviz.cc @@ -167,7 +167,7 @@ NodeProperties GetPropertiesForArray(const Model& model, node_properties.label += "]"; int buffer_size = 0; - if (IsValid(array.shape())) { + if (IsNonEmpty(array.shape())) { buffer_size = RequiredBufferSizeForShape(array.shape()); node_properties.log2_buffer_size = std::log2(static_cast(buffer_size)); diff --git a/tensorflow/contrib/lite/toco/tooling_util.cc b/tensorflow/contrib/lite/toco/tooling_util.cc index 80df09eb08..2ad2719811 100644 --- a/tensorflow/contrib/lite/toco/tooling_util.cc +++ b/tensorflow/contrib/lite/toco/tooling_util.cc @@ -602,14 +602,33 @@ void UnextendShape(Shape* shape, int new_shape_size) { shape_dims.erase(shape_dims.begin(), shape_dims.begin() + size_reduction); } -bool IsValid(const Shape& shape) { +// In general, zero-sized dimensions are disallowed, but there are exceptions, +// e.g., if the tensor data itself represents a scalar (rank 0) shape, its +// shape will have dimensions [0]. CheckNonEmptyShapeDimensions is more +// strict, and is appropriate for ops and comparisons where an empty shape +// doesn't make sense. +template +void CheckValidShapeDimensions(const Dims& dims) { + if (dims.size() == 1 && dims[0] == 0) { + return; + } + for (const auto& dim : dims) { + CHECK_GE(dim, 1); + } +} + +void CheckValidShape(const Shape& shape) { + CheckValidShapeDimensions(shape.dims()); +} + +bool IsNonEmpty(const Shape& shape) { for (int i = 0; i < shape.dimensions_count(); ++i) { if (shape.dims(i) < 1) return false; } return true; } -void CheckShapeDimensions(const Shape& shape) { +void CheckNonEmptyShapeDimensions(const Shape& shape) { for (int i = 0; i < shape.dimensions_count(); ++i) { CHECK_GE(shape.dims()[i], 1) << "shape has dimension 0 at index << " << i << ". shape = " << ShapeToString(shape); @@ -617,8 +636,8 @@ void CheckShapeDimensions(const Shape& shape) { } bool ShapesAgreeUpToBroadcasting(const Shape& shape0, const Shape& shape1) { - CheckShapeDimensions(shape0); - CheckShapeDimensions(shape1); + CheckNonEmptyShapeDimensions(shape0); + CheckNonEmptyShapeDimensions(shape1); const Shape* longer = &shape0; const Shape* shorter = &shape1; @@ -645,8 +664,8 @@ bool ShapesAgreeUpToBroadcasting(const Shape& shape0, const Shape& shape1) { } bool ShapesAgreeUpToExtending(const Shape& shape0, const Shape& shape1) { - CheckShapeDimensions(shape0); - CheckShapeDimensions(shape1); + CheckNonEmptyShapeDimensions(shape0); + CheckNonEmptyShapeDimensions(shape1); const Shape* longer = &shape0; const Shape* shorter = &shape1; @@ -683,9 +702,9 @@ bool ShapesAgreeUpToExtending(const Shape& shape0, const Shape& shape1) { } int RequiredBufferSizeForShape(const Shape& shape) { + CheckValidShape(shape); int max_offset = 1; for (const auto& dim : shape.dims()) { - CHECK_GE(dim, 1); max_offset *= dim; } return max_offset; @@ -946,13 +965,7 @@ void CheckEachArray(const Model& model) { // shape. CHECK(array->has_shape()); // Constant buffer should has a valid shape. - bool is_scalar = - array->shape().dimensions_count() == 1 && array->shape().dims(0) == 0; - if (!is_scalar) { - for (int d : array->shape().dims()) { - CHECK_GE(d, 1); - } - } + CheckValidShape(array->shape()); // The shape flat-size should agree with the buffer length. CHECK_EQ(array->buffer->Length(), RequiredBufferSizeForShape(array->shape())); @@ -1544,8 +1557,8 @@ void ResolveModelFlags(const ModelFlags& model_flags, Model* model) { if (!input_array.has_shape()) { if (input_array_proto.has_shape()) { auto& input_array_dims = *input_array.mutable_shape()->mutable_dims(); + CheckValidShapeDimensions(input_array_proto.shape().dims()); for (auto dim : input_array_proto.shape().dims()) { - CHECK_GE(dim, 1); input_array_dims.push_back(dim); } } diff --git a/tensorflow/contrib/lite/toco/tooling_util.h b/tensorflow/contrib/lite/toco/tooling_util.h index 5dbfa54fa0..b99e6111fe 100644 --- a/tensorflow/contrib/lite/toco/tooling_util.h +++ b/tensorflow/contrib/lite/toco/tooling_util.h @@ -115,10 +115,9 @@ void ExtendShape(Shape* shape, int new_shape_size); // TODO(b/36075966): Clean up when dims superseded by array shape. void UnextendShape(Shape* shape, int new_shape_size); -// Checks that all dimensions of 'shape' are at least 1. -bool IsValid(const Shape& shape); -// Same as above, but reports error using CHECK. -void CheckShapeDimensions(const Shape& shape); +// Checks that all dimensions of 'shape' are at least 1. Note that scalars, +// lacking dimensions, satisfy this condition and are considered non-empty. +bool IsNonEmpty(const Shape& shape); // Given two shapes with potentially different dimensionality and dimension // arrays d0 and d1. Without loss of generality, assume that shape0 may have -- GitLab From e041ae7dcc8916a4f5b358c45a68a6ec731e86e2 Mon Sep 17 00:00:00 2001 From: Scott Zhu Date: Wed, 8 Aug 2018 11:16:14 -0700 Subject: [PATCH 205/437] Update Keras RNN to support high dimensional inputs and states. PiperOrigin-RevId: 207916231 --- tensorflow/python/keras/layers/recurrent.py | 171 ++++++++++++------ .../python/keras/layers/recurrent_test.py | 118 ++++++++++++ 2 files changed, 230 insertions(+), 59 deletions(-) diff --git a/tensorflow/python/keras/layers/recurrent.py b/tensorflow/python/keras/layers/recurrent.py index a8bfdf25f2..acc4ba37c0 100644 --- a/tensorflow/python/keras/layers/recurrent.py +++ b/tensorflow/python/keras/layers/recurrent.py @@ -19,10 +19,10 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import numbers import numpy as np from tensorflow.python.eager import context +from tensorflow.python.framework import tensor_shape from tensorflow.python.keras import activations from tensorflow.python.keras import backend as K from tensorflow.python.keras import constraints @@ -37,6 +37,7 @@ from tensorflow.python.ops import math_ops from tensorflow.python.ops import state_ops from tensorflow.python.platform import tf_logging as logging from tensorflow.python.training.checkpointable import base as checkpointable +from tensorflow.python.util import nest from tensorflow.python.util.tf_export import tf_export @@ -86,7 +87,7 @@ class StackedRNNCells(Layer): # (assuming one LSTM has states [h, c]) state_size = [] for cell in self.cells[::-1]: - if hasattr(cell.state_size, '__len__'): + if _is_multiple_state(cell.state_size): state_size += list(cell.state_size) else: state_size.append(cell.state_size) @@ -96,7 +97,7 @@ class StackedRNNCells(Layer): # Recover per-cell states. nested_states = [] for cell in self.cells[::-1]: - if hasattr(cell.state_size, '__len__'): + if _is_multiple_state(cell.state_size): nested_states.append(states[:len(cell.state_size)]) states = states[len(cell.state_size):] else: @@ -133,11 +134,12 @@ class StackedRNNCells(Layer): cell.build([input_shape] + constants_shape) else: cell.build(input_shape) - if hasattr(cell.state_size, '__len__'): + if _is_multiple_state(cell.state_size): output_dim = cell.state_size[0] else: output_dim = cell.state_size - input_shape = (input_shape[0], output_dim) + input_shape = tuple([input_shape[0]] + + tensor_shape.as_shape(output_dim).as_list()) self.built = True def get_config(self): @@ -242,13 +244,13 @@ class RNN(Layer): cell can also take the optional argument `constants`, see section "Note on passing external constants" below. - a `state_size` attribute. This can be a single integer - (single state) in which case it is - the size of the recurrent state + (single state) in which case it is the size of the recurrent state (which should be the same as the size of the cell output). - This can also be a list/tuple of integers - (one size per state). In this case, the first entry - (`state_size[0]`) should be the same as - the size of the cell output. + This can also be a list/tuple of integers (one size per state). + In this case, the first entry (`state_size[0]`) should be the same + as the size of the cell output. + The `state_size` can also be TensorShape or tuple/list of + TensorShape, to represent high dimension state. In the case that `cell` is a list of RNN cell instances, the cells will be stacked on after the other in the RNN, implementing an efficient stacked RNN. @@ -268,9 +270,8 @@ class RNN(Layer): Unrolling can speed-up a RNN, although it tends to be more memory-intensive. Unrolling is only suitable for short sequences. - input_dim: dimensionality of the input (integer). - This argument (or alternatively, - the keyword argument `input_shape`) + input_dim: dimensionality of the input (integer or tuple of integers). + This argument (or alternatively, the keyword argument `input_shape`) is required when using this layer as the first layer in a model. input_length: Length of input sequences, to be specified when it is constant. @@ -283,15 +284,18 @@ class RNN(Layer): (e.g. via the `input_shape` argument) Input shape: - 3D tensor with shape `(batch_size, timesteps, input_dim)`. + N-D tensor with shape `(batch_size, timesteps, ...)`. Output shape: - if `return_state`: a list of tensors. The first tensor is the output. The remaining tensors are the last states, - each with shape `(batch_size, units)`. - - if `return_sequences`: 3D tensor with shape - `(batch_size, timesteps, units)`. - - else, 2D tensor with shape `(batch_size, units)`. + each with shape `(batch_size, ...)`, where `...` is in the shape of + `state_size`. + - if `return_sequences`: N-D tensor with shape + `(batch_size, timesteps, ...)`, where `...` is in the shape of output + size. + - else, N-D tensor with shape `(batch_size, ...)`, where `...` is in the + shape of output size. # Masking This layer supports masking for input data with a variable number @@ -412,7 +416,7 @@ class RNN(Layer): self.unroll = unroll self.supports_masking = True - self.input_spec = [InputSpec(ndim=3)] + self.input_spec = [None] # The input shape is unknown yet, at least rank 3. self.state_spec = None self._states = None self.constants_spec = None @@ -421,11 +425,8 @@ class RNN(Layer): @property def states(self): if self._states is None: - if isinstance(self.cell.state_size, numbers.Integral): - num_states = 1 - else: - num_states = len(self.cell.state_size) - return [None for _ in range(num_states)] + state = nest.map_structure(lambda _: None, self.cell.state_size) + return state if nest.is_sequence(self.cell.state_size) else [state] return self._states @states.setter @@ -437,19 +438,23 @@ class RNN(Layer): if isinstance(input_shape, list): input_shape = input_shape[0] - if hasattr(self.cell.state_size, '__len__'): + if _is_multiple_state(self.cell.state_size): state_size = self.cell.state_size else: state_size = [self.cell.state_size] - output_dim = state_size[0] + # Note that state_size[0] could be a tensor_shape or int. + output_dim = tensor_shape.as_shape(state_size[0]).as_list() if self.return_sequences: - output_shape = (input_shape[0], input_shape[1], output_dim) + output_shape = tuple([input_shape[0], input_shape[1]] + output_dim) else: - output_shape = (input_shape[0], output_dim) + output_shape = tuple([input_shape[0]] + output_dim) if self.return_state: - state_shape = [(input_shape[0], dim) for dim in state_size] + state_shape = [ + tuple([input_shape[0]] + tensor_shape.as_shape(dim).as_list()) + for dim in state_size + ] return [output_shape] + state_shape else: return output_shape @@ -477,49 +482,83 @@ class RNN(Layer): input_shape = input_shape[0] batch_size = input_shape[0] if self.stateful else None - input_dim = input_shape[-1] - self.input_spec[0] = InputSpec(shape=(batch_size, None, input_dim)) + input_dim = input_shape[2:] + self.input_spec[0] = InputSpec(shape=(batch_size, None) + input_dim) # allow cell (if layer) to build before we set or validate state_spec if isinstance(self.cell, Layer): - step_input_shape = (input_shape[0],) + input_shape[2:] + step_input_shape = (input_shape[0],) + input_dim if constants_shape is not None: self.cell.build([step_input_shape] + constants_shape) else: self.cell.build(step_input_shape) # set or validate state_spec - if hasattr(self.cell.state_size, '__len__'): + if _is_multiple_state(self.cell.state_size): state_size = list(self.cell.state_size) else: state_size = [self.cell.state_size] if self.state_spec is not None: # initial_state was passed in call, check compatibility - if [spec.shape[-1] for spec in self.state_spec] != state_size: - raise ValueError( - 'An `initial_state` was passed that is not compatible with ' - '`cell.state_size`. Received `state_spec`={}; ' - 'however `cell.state_size` is ' - '{}'.format(self.state_spec, self.cell.state_size)) + self._validate_state_spec(state_size, self.state_spec) else: - self.state_spec = [InputSpec(shape=(None, dim)) for dim in state_size] + self.state_spec = [ + InputSpec(shape=[None] + tensor_shape.as_shape(dim).as_list()) + for dim in state_size + ] if self.stateful: self.reset_states() self.built = True + @staticmethod + def _validate_state_spec(cell_state_sizes, init_state_specs): + """Validate the state spec between the initial_state and the state_size. + + Args: + cell_state_sizes: list, the `state_size` attribute from the cell. + init_state_specs: list, the `state_spec` from the initial_state that is + passed in call() + + Raises: + ValueError: When initial state spec is not compatible with the state size. + """ + validation_error = ValueError( + 'An `initial_state` was passed that is not compatible with ' + '`cell.state_size`. Received `state_spec`={}; ' + 'however `cell.state_size` is ' + '{}'.format(init_state_specs, cell_state_sizes)) + if len(cell_state_sizes) == len(init_state_specs): + for i in range(len(cell_state_sizes)): + if not tensor_shape.TensorShape( + # Ignore the first axis for init_state which is for batch + init_state_specs[i].shape[1:]).is_compatible_with( + tensor_shape.TensorShape(cell_state_sizes[i])): + raise validation_error + else: + raise validation_error + def get_initial_state(self, inputs): - # build an all-zero tensor of shape (samples, output_dim) + # build an all-zero tensor of shape (batch, cell.state_size) initial_state = array_ops.zeros_like(inputs) - # shape of initial_state = (samples, timesteps, input_dim) - initial_state = math_ops.reduce_sum(initial_state, axis=(1, 2)) - # shape of initial_state = (samples,) - initial_state = array_ops.expand_dims(initial_state, axis=-1) - # shape of initial_state = (samples, 1) - if hasattr(self.cell.state_size, '__len__'): - return [K.tile(initial_state, [1, dim]) for dim in self.cell.state_size] + # shape of initial_state = (batch, timesteps, ...) + initial_state = math_ops.reduce_sum( + initial_state, axis=list(range(1, len(inputs.shape)))) + # shape of initial_state = (batch,) + if _is_multiple_state(self.cell.state_size): + states = [] + for dims in self.cell.state_size: + state = initial_state + flat_dims = tensor_shape.as_shape(dims).as_list() + # reshape the state to (batch, 1, 1, ....) and then expand each state. + state = array_ops.reshape(state, [-1,] + [1] * len(flat_dims)) + states.append(K.tile(state, [1] + flat_dims)) + return states else: - return [K.tile(initial_state, [1, self.cell.state_size])] + flat_dims = tensor_shape.as_shape(self.cell.state_size).as_list() + initial_state = array_ops.reshape( + initial_state, [-1] + [1] * len(flat_dims)) + return [K.tile(initial_state, [1] + flat_dims)] def __call__(self, inputs, initial_state=None, constants=None, **kwargs): inputs, initial_state, constants = _standardize_args(inputs, @@ -682,19 +721,26 @@ class RNN(Layer): '`batch_shape` argument to your Input layer.') # initialize state if None if self.states[0] is None: - if hasattr(self.cell.state_size, '__len__'): + if _is_multiple_state(self.cell.state_size): self.states = [ - K.zeros((batch_size, dim)) for dim in self.cell.state_size + K.zeros([batch_size] + tensor_shape.as_shape(dim).as_list()) + for dim in self.cell.state_size ] else: - self.states = [K.zeros((batch_size, self.cell.state_size))] + self.states = [ + K.zeros([batch_size] + + tensor_shape.as_shape(self.cell.state_size).as_list()) + ] elif states is None: - if hasattr(self.cell.state_size, '__len__'): + if _is_multiple_state(self.cell.state_size): for state, dim in zip(self.states, self.cell.state_size): - K.set_value(state, np.zeros((batch_size, dim))) + K.set_value(state, + np.zeros([batch_size] + + tensor_shape.as_shape(dim).as_list())) else: - K.set_value(self.states[0], np.zeros((batch_size, - self.cell.state_size))) + K.set_value(self.states[0], np.zeros( + [batch_size] + + tensor_shape.as_shape(self.cell.state_size).as_list())) else: if not isinstance(states, (list, tuple)): states = [states] @@ -704,11 +750,12 @@ class RNN(Layer): 'but it received ' + str(len(states)) + ' state values. Input received: ' + str(states)) for index, (value, state) in enumerate(zip(states, self.states)): - if hasattr(self.cell.state_size, '__len__'): + if _is_multiple_state(self.cell.state_size): dim = self.cell.state_size[index] else: dim = self.cell.state_size - if value.shape != (batch_size, dim): + if value.shape != tuple([batch_size] + + tensor_shape.as_shape(dim).as_list()): raise ValueError( 'State ' + str(index) + ' is incompatible with layer ' + self.name + ': expected shape=' + str( @@ -2272,3 +2319,9 @@ def _standardize_args(inputs, initial_state, constants, num_constants): constants = to_list_or_none(constants) return inputs, initial_state, constants + + +def _is_multiple_state(state_size): + """Check whether the state_size contains multiple states.""" + return (hasattr(state_size, '__len__') and + not isinstance(state_size, tensor_shape.TensorShape)) diff --git a/tensorflow/python/keras/layers/recurrent_test.py b/tensorflow/python/keras/layers/recurrent_test.py index fefb92826b..9be439ea14 100644 --- a/tensorflow/python/keras/layers/recurrent_test.py +++ b/tensorflow/python/keras/layers/recurrent_test.py @@ -24,8 +24,10 @@ from __future__ import print_function import numpy as np from tensorflow.python import keras +from tensorflow.python.framework import tensor_shape from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops +from tensorflow.python.ops import special_math_ops from tensorflow.python.ops import state_ops from tensorflow.python.platform import test from tensorflow.python.training.checkpointable import util as checkpointable_util @@ -573,6 +575,122 @@ class RNNTest(test.TestCase): for v in model.variables: self.assertIn(v, checkpointed_objects) + def test_high_dimension_RNN(self): + with self.test_session(): + # Basic test case. + unit_a = 10 + unit_b = 20 + input_a = 5 + input_b = 10 + batch = 32 + time_step = 4 + + cell = Minimal2DRNNCell(unit_a, unit_b) + x = keras.Input((None, input_a, input_b)) + layer = keras.layers.RNN(cell) + y = layer(x) + + self.assertEqual(cell.state_size.as_list(), [unit_a, unit_b]) + init_state = layer.get_initial_state(x) + self.assertEqual(len(init_state), 1) + self.assertEqual(init_state[0].get_shape().as_list(), + [None, unit_a, unit_b]) + + model = keras.models.Model(x, y) + model.compile(optimizer='rmsprop', loss='mse') + model.train_on_batch( + np.zeros((batch, time_step, input_a, input_b)), + np.zeros((batch, unit_a, unit_b))) + self.assertEqual(model.output_shape, (None, unit_a, unit_b)) + + # Test stacking. + cells = [ + Minimal2DRNNCell(unit_a, unit_b), + Minimal2DRNNCell(unit_a * 2, unit_b * 2), + Minimal2DRNNCell(unit_a * 4, unit_b * 4) + ] + layer = keras.layers.RNN(cells) + y = layer(x) + model = keras.models.Model(x, y) + model.compile(optimizer='rmsprop', loss='mse') + model.train_on_batch( + np.zeros((batch, time_step, input_a, input_b)), + np.zeros((batch, unit_a * 4, unit_b * 4))) + self.assertEqual(model.output_shape, (None, unit_a * 4, unit_b * 4)) + + def test_high_dimension_RNN_with_init_state(self): + unit_a = 10 + unit_b = 20 + input_a = 5 + input_b = 10 + batch = 32 + time_step = 4 + + with self.test_session(): + # Basic test case. + cell = Minimal2DRNNCell(unit_a, unit_b) + x = keras.Input((None, input_a, input_b)) + s = keras.Input((unit_a, unit_b)) + layer = keras.layers.RNN(cell) + y = layer(x, initial_state=s) + + model = keras.models.Model([x, s], y) + model.compile(optimizer='rmsprop', loss='mse') + model.train_on_batch([ + np.zeros((batch, time_step, input_a, input_b)), + np.zeros((batch, unit_a, unit_b)) + ], np.zeros((batch, unit_a, unit_b))) + self.assertEqual(model.output_shape, (None, unit_a, unit_b)) + + with self.test_session(): + # Bad init state shape. + bad_shape_a = unit_a * 2 + bad_shape_b = unit_b * 2 + cell = Minimal2DRNNCell(unit_a, unit_b) + x = keras.Input((None, input_a, input_b)) + s = keras.Input((bad_shape_a, bad_shape_b)) + layer = keras.layers.RNN(cell) + with self.assertRaisesWithPredicateMatch(ValueError, + 'however `cell.state_size` is'): + layer(x, initial_state=s) + + +class Minimal2DRNNCell(keras.layers.Layer): + """The minimal 2D RNN cell is a simple combination of 2 1-D RNN cell. + + Both internal state and output have 2 dimensions and are orthogonal + between each other. + """ + + def __init__(self, unit_a, unit_b, **kwargs): + self.unit_a = unit_a + self.unit_b = unit_b + self.state_size = tensor_shape.as_shape([unit_a, unit_b]) + super(Minimal2DRNNCell, self).__init__(**kwargs) + + def build(self, input_shape): + input_a = input_shape[-2] + input_b = input_shape[-1] + self.kernel = self.add_weight( + shape=(input_a, input_b, self.unit_a, self.unit_b), + initializer='uniform', + name='kernel') + self.recurring_kernel = self.add_weight( + shape=(self.unit_a, self.unit_b, self.unit_a, self.unit_b), + initializer='uniform', + name='recurring_kernel') + self.bias = self.add_weight( + shape=(self.unit_a, self.unit_b), initializer='uniform', name='bias') + self.built = True + + def call(self, inputs, states): + prev_output = states[0] + h = special_math_ops.einsum('bij,ijkl->bkl', inputs, self.kernel) + h += array_ops.expand_dims(self.bias, axis=0) + output = h + special_math_ops.einsum('bij,ijkl->bkl', prev_output, + self.recurring_kernel) + return output, [output] + if __name__ == '__main__': test.main() -- GitLab From a1d3ebbe6f40768ea5ccf6beef9e905bce207b42 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Wed, 8 Aug 2018 11:22:41 -0700 Subject: [PATCH 206/437] Fixing for TopKV2 shape propagation in Toco. PiperOrigin-RevId: 207917321 --- .../contrib/lite/testing/generate_examples.py | 19 +++++++++++++----- .../propagate_fixed_sizes.cc | 20 ++++++++----------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/tensorflow/contrib/lite/testing/generate_examples.py b/tensorflow/contrib/lite/testing/generate_examples.py index 73c05e21b6..1dfd086f5a 100644 --- a/tensorflow/contrib/lite/testing/generate_examples.py +++ b/tensorflow/contrib/lite/testing/generate_examples.py @@ -1670,7 +1670,7 @@ def make_shape_tests(zip_path): }] def build_graph(parameters): - """Build the topk op testing graph.""" + """Build the shape op testing graph.""" # Note that we intentionally leave out the shape from the input placeholder # to prevent the Shape operation from being optimized out during conversion. input_value = tf.placeholder(dtype=parameters["input_dtype"], name="input") @@ -2318,6 +2318,7 @@ def make_topk_tests(zip_path): test_parameters = [{ "input_dtype": [tf.float32, tf.int32], "input_shape": [[10], [5, 20]], + "input_k": [None, 1, 3], }] def build_graph(parameters): @@ -2326,15 +2327,23 @@ def make_topk_tests(zip_path): dtype=parameters["input_dtype"], name="input", shape=parameters["input_shape"]) - k = tf.constant(3, name="k") + if parameters["input_k"] is not None: + k = tf.placeholder(dtype=tf.int32, name="input_k", shape=[]) + else: + k = tf.constant(3, name="k") out = tf.nn.top_k(input_value, k) - return [input_value], [out[1]] + return [input_value, k], [out[1]] def build_inputs(parameters, sess, inputs, outputs): input_value = create_tensor_data(parameters["input_dtype"], parameters["input_shape"]) - return [input_value], sess.run( - outputs, feed_dict=dict(zip(inputs, [input_value]))) + if parameters["input_k"] is not None: + k = np.array(parameters["input_k"], dtype=np.int32) + return [input_value, k], sess.run( + outputs, feed_dict=dict(zip(inputs, [input_value, k]))) + else: + return [input_value], sess.run( + outputs, feed_dict=dict(zip(inputs, [input_value]))) make_zip_of_tests(zip_path, test_parameters, build_graph, build_inputs) diff --git a/tensorflow/contrib/lite/toco/graph_transformations/propagate_fixed_sizes.cc b/tensorflow/contrib/lite/toco/graph_transformations/propagate_fixed_sizes.cc index 3c9379fd87..91e290439a 100644 --- a/tensorflow/contrib/lite/toco/graph_transformations/propagate_fixed_sizes.cc +++ b/tensorflow/contrib/lite/toco/graph_transformations/propagate_fixed_sizes.cc @@ -1082,27 +1082,23 @@ void ProcessTopkV2Operator(Model* model, TopKV2Operator* op) { } // Yield until input dims have been resolved. - if (!input_values.has_shape()) { + if (!input_values.has_shape() || !input_k.has_shape()) { return; } - const auto& input_values_shape = input_values.shape(); - auto output_indexes_dims = output_indexes.mutable_shape()->mutable_dims(); - auto output_values_dims = output_values.mutable_shape()->mutable_dims(); - for (int dim = 0; dim < input_values_shape.dimensions_count() - 1; dim++) { - output_indexes_dims->push_back(input_values_shape.dims(dim)); - output_values_dims->push_back(input_values_shape.dims(dim)); - } // If the value is initialized, we can specify the last dimension, otherwise // unknown. if (input_k.buffer) { + const auto& input_values_shape = input_values.shape(); + auto output_indexes_dims = output_indexes.mutable_shape()->mutable_dims(); + auto output_values_dims = output_values.mutable_shape()->mutable_dims(); + for (int dim = 0; dim < input_values_shape.dimensions_count() - 1; dim++) { + output_indexes_dims->push_back(input_values_shape.dims(dim)); + output_values_dims->push_back(input_values_shape.dims(dim)); + } const int32_t k_value = input_k.GetBuffer().data[0]; output_indexes_dims->push_back(k_value); output_values_dims->push_back(k_value); - - } else { - output_indexes_dims->push_back(0); - output_values_dims->push_back(0); } } -- GitLab From 2345997d328ef992d24c0182cc1b1f21bcc51f0d Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Wed, 8 Aug 2018 11:39:17 -0700 Subject: [PATCH 207/437] Do not bucketize when buckets are empty. This is for situations when for a rare feature, no buckets were found. PiperOrigin-RevId: 207920196 --- .../boosted_trees/kernels/quantile_ops.cc | 2 + .../lib/learner/batch/base_split_handler.py | 4 + .../batch/categorical_split_handler.py | 4 + .../learner/batch/ordinal_split_handler.py | 19 +++- .../batch/ordinal_split_handler_test.py | 102 +++++++++++++++++- .../python/training/functions/gbdt_batch.py | 3 +- 6 files changed, 125 insertions(+), 9 deletions(-) diff --git a/tensorflow/contrib/boosted_trees/kernels/quantile_ops.cc b/tensorflow/contrib/boosted_trees/kernels/quantile_ops.cc index 5b4be2f258..1375fddf2b 100644 --- a/tensorflow/contrib/boosted_trees/kernels/quantile_ops.cc +++ b/tensorflow/contrib/boosted_trees/kernels/quantile_ops.cc @@ -125,6 +125,8 @@ void QuantizeFeatures( auto flat_values = values_tensor.flat(); for (int64 instance = 0; instance < num_values; ++instance) { const float value = flat_values(instance); + CHECK(!buckets_vector.empty()) + << "Got empty buckets for feature " << feature_index; auto bucket_iter = std::lower_bound(buckets_vector.begin(), buckets_vector.end(), value); if (bucket_iter == buckets_vector.end()) { diff --git a/tensorflow/contrib/boosted_trees/lib/learner/batch/base_split_handler.py b/tensorflow/contrib/boosted_trees/lib/learner/batch/base_split_handler.py index 1b7f59ea42..5d4819b0f1 100644 --- a/tensorflow/contrib/boosted_trees/lib/learner/batch/base_split_handler.py +++ b/tensorflow/contrib/boosted_trees/lib/learner/batch/base_split_handler.py @@ -131,6 +131,10 @@ class BaseSplitHandler(object): }, stamp_token, None) return control_flow_ops.group(update_1, *update_2[self]) + @abc.abstractmethod + def reset(self, stamp_token, next_stamp_token): + """Resets the state maintained by the handler.""" + @abc.abstractmethod def make_splits(self, stamp_token, next_stamp_token, class_id): """Create the best split using the accumulated stats and flush the state. diff --git a/tensorflow/contrib/boosted_trees/lib/learner/batch/categorical_split_handler.py b/tensorflow/contrib/boosted_trees/lib/learner/batch/categorical_split_handler.py index bf686237ff..efe29216c2 100644 --- a/tensorflow/contrib/boosted_trees/lib/learner/batch/categorical_split_handler.py +++ b/tensorflow/contrib/boosted_trees/lib/learner/batch/categorical_split_handler.py @@ -202,3 +202,7 @@ class EqualitySplitHandler(base_split_handler.BaseSplitHandler): # always return ready. are_splits_ready = constant_op.constant(True) return (are_splits_ready, partition_ids, gains, split_infos) + + def reset(self, stamp_token, next_stamp_token): + reset = self._stats_accumulator.flush(stamp_token, next_stamp_token) + return reset diff --git a/tensorflow/contrib/boosted_trees/lib/learner/batch/ordinal_split_handler.py b/tensorflow/contrib/boosted_trees/lib/learner/batch/ordinal_split_handler.py index df0bec1fe3..2559fe9913 100644 --- a/tensorflow/contrib/boosted_trees/lib/learner/batch/ordinal_split_handler.py +++ b/tensorflow/contrib/boosted_trees/lib/learner/batch/ordinal_split_handler.py @@ -79,6 +79,7 @@ from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import math_ops + _BIAS_FEATURE_ID = -1 # Pattern to remove all non alpha numeric from a string. _PATTERN = re.compile(r"[\W_]+") @@ -147,6 +148,11 @@ class InequalitySplitHandler(base_split_handler.BaseSplitHandler): num_quantiles=num_quantiles, name="QuantileAccumulator/{}".format(self._name)) + def reset(self, stamp_token, next_stamp_token): + reset_1 = self._stats_accumulator.flush(stamp_token, next_stamp_token) + reset_2 = self._quantile_accumulator.flush(stamp_token, next_stamp_token) + return control_flow_ops.group([reset_1, reset_2]) + class DenseSplitHandler(InequalitySplitHandler): """Computes stats and finds the best inequality splits on dense columns.""" @@ -264,6 +270,7 @@ class DenseSplitHandler(InequalitySplitHandler): self._feature_column_group_id, self._l1_regularization, self._l2_regularization, self._tree_complexity_regularization, self._min_node_weight, self._loss_uses_sum_reduction)) + return are_splits_ready, partition_ids, gains, split_infos @@ -579,8 +586,10 @@ def dense_make_stats_update(is_active, are_buckets_ready, float_column, example_partition_ids, feature_ids, gradients, hessians = ( control_flow_ops.cond( - math_ops.logical_and(are_buckets_ready, is_active[0]), - ready_inputs_fn, not_ready_inputs_fn)) + math_ops.logical_and( + math_ops.logical_and(are_buckets_ready, + array_ops.size(quantile_buckets) > 0), + is_active[0]), ready_inputs_fn, not_ready_inputs_fn)) return (quantile_values, quantile_weights, example_partition_ids, feature_ids, gradients, hessians) @@ -674,8 +683,10 @@ def sparse_make_stats_update( lambda: handler_not_active)) example_partition_ids, feature_ids, gradients, hessians = ( - control_flow_ops.cond(are_buckets_ready, quantiles_ready, - quantiles_not_ready)) + control_flow_ops.cond( + math_ops.logical_and(are_buckets_ready, + array_ops.size(quantile_buckets) > 0), + quantiles_ready, quantiles_not_ready)) return (quantile_indices, quantile_values, quantile_shape, quantile_weights, example_partition_ids, feature_ids, gradients, hessians) diff --git a/tensorflow/contrib/boosted_trees/lib/learner/batch/ordinal_split_handler_test.py b/tensorflow/contrib/boosted_trees/lib/learner/batch/ordinal_split_handler_test.py index d59732cf92..5d82c4cae5 100644 --- a/tensorflow/contrib/boosted_trees/lib/learner/batch/ordinal_split_handler_test.py +++ b/tensorflow/contrib/boosted_trees/lib/learner/batch/ordinal_split_handler_test.py @@ -1072,8 +1072,8 @@ class SparseSplitHandlerTest(test_util.TensorFlowTestCase): def testGenerateFeatureSplitCandidatesMulticlassFullHessian(self): with self.test_session() as sess: # Batch is 4, 2 classes - gradients = array_ops.constant( - [[0.2, 1.4], [-0.5, 0.1], [1.2, 3], [4.0, -3]]) + gradients = array_ops.constant([[0.2, 1.4], [-0.5, 0.1], [1.2, 3], + [4.0, -3]]) # 2x2 matrix for each instance hessian_0 = [[0.12, 0.02], [0.3, 0.11]] hessian_1 = [[0.07, -0.2], [-0.5, 0.2]] @@ -1167,8 +1167,8 @@ class SparseSplitHandlerTest(test_util.TensorFlowTestCase): def testGenerateFeatureSplitCandidatesMulticlassDiagonalHessian(self): with self.test_session() as sess: # Batch is 4, 2 classes - gradients = array_ops.constant( - [[0.2, 1.4], [-0.5, 0.1], [1.2, 3], [4.0, -3]]) + gradients = array_ops.constant([[0.2, 1.4], [-0.5, 0.1], [1.2, 3], + [4.0, -3]]) # Each hessian is a diagonal from a full hessian matrix. hessian_0 = [0.12, 0.11] hessian_1 = [0.07, 0.2] @@ -1406,6 +1406,100 @@ class SparseSplitHandlerTest(test_util.TensorFlowTestCase): self.assertEqual(len(gains), 0) self.assertEqual(len(splits), 0) + def testEmptyBuckets(self): + """Test that reproduces the case when quantile buckets were empty.""" + with self.test_session() as sess: + sparse_column = array_ops.sparse_placeholder(dtypes.float32) + + # We have two batches - at first, a sparse feature is empty. + empty_indices = array_ops.constant([], dtype=dtypes.int64, shape=[0, 2]) + empty_values = array_ops.constant([], dtype=dtypes.float32) + empty_sparse_column = sparse_tensor.SparseTensor(empty_indices, + empty_values, [4, 2]) + empty_sparse_column = empty_sparse_column.eval(session=sess) + + # For the second batch, the sparse feature is not empty. + non_empty_indices = array_ops.constant( + [[0, 0], [2, 1], [3, 2]], dtype=dtypes.int64, shape=[3, 2]) + non_empty_values = array_ops.constant( + [0.52, 0.3, 0.52], dtype=dtypes.float32) + non_empty_sparse_column = sparse_tensor.SparseTensor( + non_empty_indices, non_empty_values, [4, 2]) + non_empty_sparse_column = non_empty_sparse_column.eval(session=sess) + + gradient_shape = tensor_shape.scalar() + hessian_shape = tensor_shape.scalar() + class_id = -1 + + split_handler = ordinal_split_handler.SparseSplitHandler( + l1_regularization=0.0, + l2_regularization=2.0, + tree_complexity_regularization=0.0, + min_node_weight=0.0, + epsilon=0.01, + num_quantiles=2, + feature_column_group_id=0, + sparse_float_column=sparse_column, + init_stamp_token=0, + gradient_shape=gradient_shape, + hessian_shape=hessian_shape, + multiclass_strategy=learner_pb2.LearnerConfig.TREE_PER_CLASS) + resources.initialize_resources(resources.shared_resources()).run() + gradients = array_ops.constant([0.2, -0.5, 1.2, 4.0]) + hessians = array_ops.constant([0.12, 0.07, 0.2, 0.13]) + partition_ids = array_ops.constant([0, 0, 0, 1], dtype=dtypes.int32) + + empty_gradients, empty_hessians = get_empty_tensors( + gradient_shape, hessian_shape) + example_weights = array_ops.ones([4, 1], dtypes.float32) + + update_1 = split_handler.update_stats_sync( + 0, + partition_ids, + gradients, + hessians, + empty_gradients, + empty_hessians, + example_weights, + is_active=array_ops.constant([True, True])) + with ops.control_dependencies([update_1]): + are_splits_ready = split_handler.make_splits( + np.int64(0), np.int64(1), class_id)[0] + + # First, calculate quantiles and try to update on an empty data for a + # feature. + are_splits_ready = ( + sess.run( + are_splits_ready, + feed_dict={sparse_column: empty_sparse_column})) + self.assertFalse(are_splits_ready) + + update_2 = split_handler.update_stats_sync( + 1, + partition_ids, + gradients, + hessians, + empty_gradients, + empty_hessians, + example_weights, + is_active=array_ops.constant([True, True])) + with ops.control_dependencies([update_2]): + are_splits_ready2, partitions, gains, splits = ( + split_handler.make_splits(np.int64(1), np.int64(2), class_id)) + + # Now the feature in the second batch is not empty, but buckets + # calculated on the first batch are empty. + are_splits_ready2, partitions, gains, splits = ( + sess.run( + [are_splits_ready2, partitions, gains, splits], + feed_dict={sparse_column: non_empty_sparse_column})) + self.assertFalse(are_splits_ready) + self.assertTrue(are_splits_ready2) + # Since the buckets were empty, we can't calculate the splits. + self.assertEqual(len(partitions), 0) + self.assertEqual(len(gains), 0) + self.assertEqual(len(splits), 0) + def testDegenerativeCase(self): with self.test_session() as sess: # One data example only, one leaf and thus one quantile bucket.The same diff --git a/tensorflow/contrib/boosted_trees/python/training/functions/gbdt_batch.py b/tensorflow/contrib/boosted_trees/python/training/functions/gbdt_batch.py index ba5ef700c5..d0d1249bd6 100644 --- a/tensorflow/contrib/boosted_trees/python/training/functions/gbdt_batch.py +++ b/tensorflow/contrib/boosted_trees/python/training/functions/gbdt_batch.py @@ -51,6 +51,7 @@ from tensorflow.python.platform import tf_logging as logging from tensorflow.python.summary import summary from tensorflow.python.training import device_setter + # Key names for prediction dict. ENSEMBLE_STAMP = "ensemble_stamp" PREDICTIONS = "predictions" @@ -898,7 +899,7 @@ class GradientBoostedDecisionTreeModel(object): reset_ops = [] for handler in handlers: - reset_ops.append(handler.make_splits(stamp_token, next_stamp_token, 0)) + reset_ops.append(handler.reset(stamp_token, next_stamp_token)) if self._center_bias: reset_ops.append( bias_stats_accumulator.flush(stamp_token, next_stamp_token)) -- GitLab From 42b61fbd380a7b6c3912e5a91ff09738ace7073c Mon Sep 17 00:00:00 2001 From: Francois Chollet Date: Wed, 8 Aug 2018 11:48:37 -0700 Subject: [PATCH 208/437] Refactor Sequential model to make it behave exactly like a subclassed network unless it receives an input_shape argument with its first layer. In particular in graph mode no placeholder gets created by a Sequential model (unless an input shape is provided). PiperOrigin-RevId: 207921752 --- tensorflow/python/keras/BUILD | 3 +- tensorflow/python/keras/engine/network.py | 21 +- tensorflow/python/keras/engine/sequential.py | 225 +++++++++++------- .../python/keras/engine/sequential_test.py | 104 +++++--- tensorflow/python/keras/engine/training.py | 15 +- .../python/keras/engine/training_eager.py | 2 +- .../python/keras/engine/training_test.py | 30 ++- tensorflow/python/keras/layers/wrappers.py | 2 +- tensorflow/python/util/serialization_test.py | 7 +- .../v1/tensorflow.keras.-sequential.pbtxt | 4 - .../tensorflow.keras.models.-sequential.pbtxt | 4 - 11 files changed, 269 insertions(+), 148 deletions(-) diff --git a/tensorflow/python/keras/BUILD b/tensorflow/python/keras/BUILD index 1706158c65..446cf6355a 100755 --- a/tensorflow/python/keras/BUILD +++ b/tensorflow/python/keras/BUILD @@ -860,13 +860,14 @@ py_test( py_test( name = "sequential_test", - size = "small", + size = "medium", srcs = ["engine/sequential_test.py"], srcs_version = "PY2AND3", deps = [ ":keras", "//tensorflow/python:client_testlib", "//third_party/py/numpy", + "@absl_py//absl/testing:parameterized", ], ) diff --git a/tensorflow/python/keras/engine/network.py b/tensorflow/python/keras/engine/network.py index 8f35794456..bdff4497e2 100644 --- a/tensorflow/python/keras/engine/network.py +++ b/tensorflow/python/keras/engine/network.py @@ -116,6 +116,16 @@ class Network(base_layer.Layer): # included in base_init to avoid excessive special casing when retrieving # the value). self._extra_variables = [] + # In many internal cases one needs to compute both the model's output + # and its output mask without relying on `__call__` (which would do both and + # set mask metadata), but for models, computing the mask requires to + # recompute the output. + # Hence the pattern `output = model.call(); mask = model.compute_mask()` + # would be redundant, and internal logic + # (susceptible to use `call` directly) should prefer using the + # internal method `output, mask = _call_and_compute_mask()`. + # This is True for Sequential networks and graph networks. + self._compute_output_and_mask_jointly = False self.supports_masking = False if not hasattr(self, 'optimizer'): @@ -219,6 +229,7 @@ class Network(base_layer.Layer): # A Network does not create weights of its own, thus it is already # built. self.built = True + self._compute_output_and_mask_jointly = True self._is_graph_network = True self._input_layers = [] @@ -819,6 +830,10 @@ class Network(base_layer.Layer): A tensor if there is a single output, or a list of tensors if there are more than one outputs. """ + if not self._is_graph_network: + raise NotImplementedError('When subclassing the `Model` class, you should' + ' implement a `call` method.') + inputs = generic_utils.to_list(inputs) if mask is None: masks = [None for _ in range(len(inputs))] @@ -1007,7 +1022,8 @@ class Network(base_layer.Layer): kwargs.setdefault('mask', computed_mask) # Compute outputs and masks. - if isinstance(layer, Network) and layer._is_graph_network: + if (isinstance(layer, Network) and + layer._compute_output_and_mask_jointly): output_tensors, output_masks = layer._call_and_compute_mask( computed_tensor, **kwargs) else: @@ -1027,7 +1043,8 @@ class Network(base_layer.Layer): kwargs.setdefault('mask', computed_masks) # Compute outputs and masks. - if isinstance(layer, Network) and layer._is_graph_network: + if (isinstance(layer, Network) and + layer._compute_output_and_mask_jointly): output_tensors, output_masks = layer._call_and_compute_mask( computed_tensors, **kwargs) else: diff --git a/tensorflow/python/keras/engine/sequential.py b/tensorflow/python/keras/engine/sequential.py index 41cdfda660..b3a2ad8b0c 100644 --- a/tensorflow/python/keras/engine/sequential.py +++ b/tensorflow/python/keras/engine/sequential.py @@ -21,15 +21,17 @@ from __future__ import print_function import copy -from tensorflow.python.keras import backend as K +from tensorflow.python.eager import context from tensorflow.python.keras import layers as layer_module from tensorflow.python.keras.engine import base_layer from tensorflow.python.keras.engine.input_layer import Input from tensorflow.python.keras.engine.input_layer import InputLayer +from tensorflow.python.keras.engine.network import Network from tensorflow.python.keras.engine.training import Model from tensorflow.python.keras.utils import layer_utils from tensorflow.python.platform import tf_logging as logging from tensorflow.python.training.checkpointable import base as checkpointable +from tensorflow.python.util import tf_inspect from tensorflow.python.util.tf_export import tf_export @@ -92,8 +94,12 @@ class Sequential(Model): ``` """ + @checkpointable.no_automatic_dependency_tracking def __init__(self, layers=None, name=None): super(Sequential, self).__init__(name=name) + self.supports_masking = True + self._build_input_shape = None + self._compute_output_and_mask_jointly = True # Add to the model any layers passed to the constructor. if layers: @@ -105,9 +111,12 @@ class Sequential(Model): # Historically, `sequential.layers` only returns layers that were added # via `add`, and omits the auto-generated `InputLayer` that comes at the # bottom of the stack. - if self._layers and isinstance(self._layers[0], InputLayer): - return self._layers[1:] - return self._layers + # `CheckpointableBase` manages the `_layers` attributes and does filtering + # over it. + layers = super(Sequential, self).layers + if layers and isinstance(layers[0], InputLayer): + return layers[1:] + return layers[:] @checkpointable.no_automatic_dependency_tracking def add(self, layer): @@ -129,30 +138,16 @@ class Sequential(Model): 'an instance of class Layer. ' 'Found: ' + str(layer)) self.built = False + set_inputs = False if not self._layers: - set_inputs = False - # First layer in model: check that it is an input layer. - if not isinstance(layer, InputLayer): - # Create an input tensor and call `layer` on the input tensor. - # First, we need to infer the expected input shape and dtype. - first_layer = layer - if isinstance(layer, (Model, Sequential)): - # We were passed a model as first layer. - # This requires a specific way to figure out the - # input shape and dtype. - if not layer.layers: - raise ValueError('Cannot add an empty model ' - 'to a `Sequential` model.') - # In case of nested models: recover the first layer - # of the deepest model to infer input shape and dtype. - first_layer = layer.layers[0] - while isinstance(first_layer, (Model, Sequential)): - first_layer = first_layer.layers[0] - - if hasattr(first_layer, '_batch_input_shape'): - batch_shape = first_layer._batch_input_shape - dtype = first_layer.dtype - # Instantiate the input layer. + if isinstance(layer, InputLayer): + # Corner case where the user passes an InputLayer layer via `add`. + assert len(layer._inbound_nodes[-1].output_tensors) == 1 + set_inputs = True + else: + batch_shape, dtype = get_input_shape_and_dtype(layer) + if batch_shape: + # Instantiate an input layer. x = Input( batch_shape=batch_shape, dtype=dtype, @@ -162,25 +157,20 @@ class Sequential(Model): # to the input layer we just created. layer(x) set_inputs = True - else: - # The layer doesn't know about its expected shape. We will have to - # build the model lazily on `fit`/etc. - batch_shape = None - else: - # Corner case where the user passes an InputLayer layer via `add`. - assert len(layer._inbound_nodes[-1].output_tensors) == 1 - set_inputs = True if set_inputs: + # If an input layer (placeholder) is available. if len(layer._inbound_nodes[-1].output_tensors) != 1: raise ValueError('All layers in a Sequential model ' 'should have a single output tensor. ' 'For multi-output layers, ' 'use the functional API.') - self.outputs = [layer._inbound_nodes[-1].output_tensors[0]] self.inputs = layer_utils.get_source_inputs(self.outputs[0]) + elif self.outputs: + # If the model is being built continuously on top of an input layer: + # refresh its output. output_tensor = layer(self.outputs[0]) if isinstance(output_tensor, list): raise TypeError('All layers in a Sequential model ' @@ -188,10 +178,13 @@ class Sequential(Model): 'For multi-output layers, ' 'use the functional API.') self.outputs = [output_tensor] - if self.inputs: - self.build() + if set_inputs or self._is_graph_network: + self._init_graph_network(self.inputs, self.outputs, name=self.name) + self.built = True else: self._layers.append(layer) + if self._layers: + self._track_layers(self._layers) @checkpointable.no_automatic_dependency_tracking def pop(self): @@ -204,54 +197,69 @@ class Sequential(Model): raise TypeError('There are no layers in the model.') self._layers.pop() - self.built = False if not self.layers: self.outputs = None self.inputs = None - elif self.outputs: + self.built = False + elif self._is_graph_network: self.layers[-1]._outbound_nodes = [] self.outputs = [self.layers[-1].output] - self.build() + self._init_graph_network(self.inputs, self.outputs, name=self.name) + self.built = True def build(self, input_shape=None): - self._set_inputs_and_outputs(input_shape=input_shape) - - def symbolic_set_inputs(self, inputs): - self._set_inputs_and_outputs(tensor=inputs) - - @checkpointable.no_automatic_dependency_tracking - def _set_inputs_and_outputs(self, input_shape=None, tensor=None): - """Set model's input and output specs based on the input received. + if self._is_graph_network: + self._init_graph_network(self.inputs, self.outputs, name=self.name) + else: + if input_shape is None: + raise ValueError('You must provide an `input_shape` argument.') + self._build_input_shape = input_shape + shape = input_shape + for layer in self.layers: + if not layer.built: + layer.build(shape) + layer.built = True + shape = layer.compute_output_shape(shape) + self.built = True + + def call(self, inputs, training=None, mask=None): + if self._is_graph_network: + return super(Sequential, self).call(inputs, training=training, mask=mask) + + outputs, _ = self._call_and_compute_mask( + inputs, training=training, mask=mask) + return outputs + + def _call_and_compute_mask(self, inputs, training=None, mask=None): + x = inputs + for layer in self.layers: + kwargs = {} + if 'mask' in tf_inspect.getargspec(layer.call).args: + kwargs['mask'] = mask + if 'training' in tf_inspect.getargspec(layer.call).args: + kwargs['training'] = training + + if isinstance(layer, Network) and layer._compute_output_and_mask_jointly: + x, mask = layer._call_and_compute_mask(x, **kwargs) + else: + x = layer.call(x, **kwargs) + if layer.supports_masking: + mask = layer.compute_mask(x, mask) + else: + mask = None + if not context.executing_eagerly(): + x._keras_mask = mask + return x, mask - If `tensor` is provided, `input_shape` is not required. + def compute_output_shape(self, input_shape): + shape = input_shape + for layer in self.layers: + shape = layer.compute_output_shape(shape) + return shape - Args: - input_shape: Optional shape of input. - tensor: Optional existing tensor to wrap into the `Input` layer. - """ - if not self.inputs: - dtype = K.floatx() - if tensor is not None: - batch_shape = (None,) + tuple(tensor.get_shape().as_list()[1:]) - x = Input(dtype=dtype, name=self.name + '_input', tensor=tensor) - elif input_shape is not None: - batch_shape = tuple(input_shape) - x = Input( - batch_shape=batch_shape, dtype=dtype, name=self.name + '_input') - self.inputs = [x] - for layer in self._layers: - x = layer(x) - self.outputs = [x] - # Make sure that the model's input shape will be preserved during - # serialization. - if self._layers: - self._layers[0]._batch_input_shape = batch_shape - - if self.inputs: - self._init_graph_network(self.inputs, self.outputs, name=self.name) - self.built = True - if self._layers: - self._track_layers(self._layers) + def compute_mask(self, inputs, mask): + _, mask = self._call_and_compute_mask(inputs, mask=mask) + return mask def predict_proba(self, x, batch_size=32, verbose=0): """Generates class probability predictions for the input samples. @@ -296,18 +304,69 @@ class Sequential(Model): return (proba > 0.5).astype('int32') def get_config(self): - config = [] + layer_configs = [] for layer in self.layers: - config.append({ + layer_configs.append({ 'class_name': layer.__class__.__name__, 'config': layer.get_config() }) - return copy.deepcopy(config) + config = { + 'name': self.name, + 'layers': copy.deepcopy(layer_configs) + } + if self._build_input_shape: + config['build_input_shape'] = self._build_input_shape + return config @classmethod def from_config(cls, config, custom_objects=None): - model = cls() - for conf in config: - layer = layer_module.deserialize(conf, custom_objects=custom_objects) + if 'name' in config: + name = config['name'] + build_input_shape = config.get('build_input_shape') + layer_configs = config['layers'] + else: + name = None + build_input_shape = None + model = cls(name=name) + for layer_config in layer_configs: + layer = layer_module.deserialize(layer_config, + custom_objects=custom_objects) model.add(layer) + if not model.inputs and build_input_shape: + model.build(build_input_shape) return model + + +def get_input_shape_and_dtype(layer): + """Retrieve input shape and input dtype of layer if applicable. + + Args: + layer: Layer (or model) instance. + + Returns: + Tuple (input_shape, input_dtype). Both could be None if the layer + does not have a defined input shape. + + Raises: + ValueError: in case an empty Sequential or Graph Network is passed. + """ + if ((isinstance(layer, Model) and layer._is_graph_network) + or isinstance(layer, Sequential)): + # We were passed a model as first layer. + # This requires a specific way to figure out the + # input shape and dtype. + if not layer.layers: + raise ValueError('Cannot add an empty model ' + 'to a `Sequential` model.') + # In case of nested models: recover the first layer + # of the deepest model to infer input shape and dtype. + layer = layer.layers[0] + while ((isinstance(layer, Model) and layer._is_graph_network) + or isinstance(layer, Sequential)): + layer = layer.layers[0] + + if hasattr(layer, '_batch_input_shape'): + batch_shape = layer._batch_input_shape + dtype = layer.dtype + return batch_shape, dtype + return None, None diff --git a/tensorflow/python/keras/engine/sequential_test.py b/tensorflow/python/keras/engine/sequential_test.py index 4f4adca333..9d3f65e0c6 100644 --- a/tensorflow/python/keras/engine/sequential_test.py +++ b/tensorflow/python/keras/engine/sequential_test.py @@ -18,6 +18,7 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +from absl.testing import parameterized import numpy as np from tensorflow.python import keras @@ -28,7 +29,18 @@ from tensorflow.python.platform import test from tensorflow.python.training import rmsprop -class TestSequential(test.TestCase): +def _get_small_mlp(num_hidden, num_classes, input_dim=None): + model = keras.models.Sequential() + if input_dim: + model.add(keras.layers.Dense(num_hidden, activation='relu', + input_dim=input_dim)) + else: + model.add(keras.layers.Dense(num_hidden, activation='relu')) + model.add(keras.layers.Dense(num_classes, activation='softmax')) + return model + + +class TestSequential(test.TestCase, parameterized.TestCase): """Most Sequential model API tests are covered in `training_test.py`. """ @@ -50,9 +62,7 @@ class TestSequential(test.TestCase): batch_size = 5 num_classes = 2 - model = keras.models.Sequential() - model.add(keras.layers.Dense(num_hidden, input_dim=input_dim)) - model.add(keras.layers.Dense(num_classes)) + model = _get_small_mlp(num_hidden, num_classes, input_dim) model.compile(loss='mse', optimizer=rmsprop.RMSPropOptimizer(1e-3)) x = np.random.random((batch_size, input_dim)) y = np.random.random((batch_size, num_classes)) @@ -83,10 +93,7 @@ class TestSequential(test.TestCase): batch_size = 5 num_classes = 2 - model = keras.models.Sequential() - # We don't specify the input shape. - model.add(keras.layers.Dense(num_hidden)) - model.add(keras.layers.Dense(num_classes)) + model = _get_small_mlp(num_hidden, num_classes) model.compile(loss='mse', optimizer=rmsprop.RMSPropOptimizer(1e-3)) self.assertEqual(len(model.layers), 2) self.assertEqual(len(model.weights), 0) @@ -96,9 +103,7 @@ class TestSequential(test.TestCase): y = np.random.random((batch_size, num_classes)) model.fit(x, y, epochs=1) self.assertTrue(model.built) - self.assertEqual(model.inputs[0].get_shape().as_list(), [None, input_dim]) - self.assertEqual(model.outputs[0].get_shape().as_list(), - [None, num_classes]) + self.assertFalse(model._is_graph_network) self.assertEqual(len(model.weights), 2 * 2) @tf_test_util.run_in_graph_and_eager_modes @@ -109,10 +114,7 @@ class TestSequential(test.TestCase): num_samples = 50 steps_per_epoch = 10 - model = keras.models.Sequential() - # We don't specify the input shape. - model.add(keras.layers.Dense(num_hidden)) - model.add(keras.layers.Dense(num_classes)) + model = _get_small_mlp(num_hidden, num_classes) model.compile(loss='mse', optimizer=rmsprop.RMSPropOptimizer(1e-3)) self.assertEqual(len(model.layers), 2) self.assertEqual(len(model.weights), 0) @@ -127,19 +129,18 @@ class TestSequential(test.TestCase): model.fit(iterator, epochs=1, steps_per_epoch=steps_per_epoch) self.assertTrue(model.built) - self.assertEqual(model.inputs[0].get_shape().as_list(), [None, input_dim]) - self.assertEqual(model.outputs[0].get_shape().as_list(), - [None, num_classes]) self.assertEqual(len(model.weights), 2 * 2) + self.assertFalse(model._is_graph_network) - def test_training_and_eval_methods_on_symbolic_tensors(self): + @parameterized.parameters((True,), (False,)) + def test_training_and_eval_methods_on_symbolic_tensors(self, deferred): with self.test_session(): - def create_model(): - model = keras.Sequential() - model.add(keras.layers.Dense(10, activation='relu')) - model.add(keras.layers.Dense(4, activation='softmax')) - + def get_model(): + if deferred: + model = _get_small_mlp(10, 4) + else: + model = _get_small_mlp(10, 4, input_dim=3) model.compile( optimizer=rmsprop.RMSPropOptimizer(1e-3), loss='categorical_crossentropy', @@ -149,22 +150,22 @@ class TestSequential(test.TestCase): inputs = keras.backend.zeros(shape=(10, 3)) targets = keras.backend.zeros(shape=(10, 4)) - model = create_model() + model = get_model() model.fit(inputs, targets, epochs=10, steps_per_epoch=30) - model = create_model() + model = get_model() model.evaluate(inputs, targets, steps=2, verbose=0) - model = create_model() + model = get_model() model.predict(inputs, steps=2) - model = create_model() + model = get_model() model.train_on_batch(inputs, targets) - model = create_model() + model = get_model() model.test_on_batch(inputs, targets) - model = create_model() + model = get_model() model.fit( inputs, targets, @@ -247,16 +248,14 @@ class TestSequential(test.TestCase): x2 = model.predict(val_a) assert np.abs(np.sum(x1 - x2)) > 1e-5 + @tf_test_util.run_in_graph_and_eager_modes def test_sequential_deferred_build_serialization(self): num_hidden = 5 input_dim = 3 batch_size = 5 num_classes = 2 - model = keras.models.Sequential() - # We don't specify the input shape. - model.add(keras.layers.Dense(num_hidden)) - model.add(keras.layers.Dense(num_classes)) + model = _get_small_mlp(num_hidden, num_classes) model.compile(loss='mse', optimizer=rmsprop.RMSPropOptimizer(1e-3)) self.assertFalse(model.built) @@ -266,11 +265,48 @@ class TestSequential(test.TestCase): self.assertTrue(model.built) config = model.get_config() + self.assertIn('build_input_shape', config) + new_model = keras.models.Sequential.from_config(config) self.assertTrue(new_model.built) self.assertEqual(len(model.layers), 2) self.assertEqual(len(model.weights), 4) + @tf_test_util.run_in_graph_and_eager_modes + def test_sequential_shape_inference_deferred(self): + model = _get_small_mlp(4, 5) + output_shape = model.compute_output_shape((None, 7)) + self.assertEqual(tuple(output_shape.as_list()), (None, 5)) + + @tf_test_util.run_in_graph_and_eager_modes + def test_sequential_build_deferred(self): + model = _get_small_mlp(4, 5) + + model.build((None, 10)) + self.assertTrue(model.built) + self.assertEqual(len(model.weights), 4) + + # Test with nested model + model = _get_small_mlp(4, 3) + inner_model = _get_small_mlp(4, 5) + model.add(inner_model) + + model.build((None, 10)) + self.assertTrue(model.built) + self.assertTrue(model.layers[-1].built) + self.assertEqual(len(model.weights), 8) + + @tf_test_util.run_in_graph_and_eager_modes + def test_sequential_nesting(self): + model = _get_small_mlp(4, 3) + inner_model = _get_small_mlp(4, 5) + model.add(inner_model) + + model.compile(loss='mse', optimizer=rmsprop.RMSPropOptimizer(1e-3)) + x = np.random.random((2, 6)) + y = np.random.random((2, 5)) + model.fit(x, y, epochs=1) + if __name__ == '__main__': test.main() diff --git a/tensorflow/python/keras/engine/training.py b/tensorflow/python/keras/engine/training.py index ec900dd90e..254de27ceb 100644 --- a/tensorflow/python/keras/engine/training.py +++ b/tensorflow/python/keras/engine/training.py @@ -1069,22 +1069,13 @@ class Model(Network): 'in their call() signatures do not yet support shape inference. File ' 'a feature request if this limitation bothers you.') if self.__class__.__name__ == 'Sequential': - # Note: we can't test whether the model is `Sequential` via `isinstance` - # since `Sequential` depends on `Model`. - if isinstance(inputs, list): - assert len(inputs) == 1 - inputs = inputs[0] - if tensor_util.is_tensor(inputs): - if context.executing_eagerly(): - input_shape = (None,) + tuple(inputs.get_shape().as_list()[1:]) - self.build(input_shape=input_shape) - else: - self.symbolic_set_inputs(inputs) + input_shape = (None,) + tuple(inputs.get_shape().as_list()[1:]) + self.build(input_shape=input_shape) else: input_shape = (None,) + inputs.shape[1:] self.build(input_shape=input_shape) - elif context.executing_eagerly(): + if context.executing_eagerly(): self._eager_set_inputs(inputs) else: self._symbolic_set_inputs(inputs, training=training) diff --git a/tensorflow/python/keras/engine/training_eager.py b/tensorflow/python/keras/engine/training_eager.py index 774d2e44f3..d5a47efb98 100644 --- a/tensorflow/python/keras/engine/training_eager.py +++ b/tensorflow/python/keras/engine/training_eager.py @@ -98,7 +98,7 @@ def _model_loss(model, inputs, targets, sample_weights=None, training=False): if len(inputs) == 1: inputs = inputs[0] - if model._is_graph_network: + if model._compute_output_and_mask_jointly: outs, masks = model._call_and_compute_mask(inputs, **kwargs) masks = generic_utils.to_list(masks) else: diff --git a/tensorflow/python/keras/engine/training_test.py b/tensorflow/python/keras/engine/training_test.py index 753519fbac..0e10eba4c6 100644 --- a/tensorflow/python/keras/engine/training_test.py +++ b/tensorflow/python/keras/engine/training_test.py @@ -794,7 +794,7 @@ class LossWeightingTest(test.TestCase): class LossMaskingTest(test.TestCase): @tf_test_util.run_in_graph_and_eager_modes - def test_masking(self): + def test_masking_graph_sequential(self): with self.test_session(): x = np.array([[[1], [1]], [[0], [0]]]) model = keras.models.Sequential() @@ -807,6 +807,34 @@ class LossMaskingTest(test.TestCase): loss = model.train_on_batch(x, y) self.assertEqual(float(loss), 0.) + @tf_test_util.run_in_graph_and_eager_modes + def test_masking_deferred_sequential(self): + with self.test_session(): + x = np.array([[[1], [1]], [[0], [0]]]) + model = keras.models.Sequential() + model.add(keras.layers.Masking(mask_value=0)) + model.add( + keras.layers.TimeDistributed( + keras.layers.Dense(1, kernel_initializer='one'))) + model.compile(loss='mse', optimizer=RMSPropOptimizer(learning_rate=0.001)) + y = np.array([[[1], [1]], [[1], [1]]]) + loss = model.train_on_batch(x, y) + self.assertEqual(float(loss), 0.) + + @tf_test_util.run_in_graph_and_eager_modes + def test_masking_functional(self): + with self.test_session(): + x = np.array([[[1], [1]], [[0], [0]]]) + inputs = keras.layers.Input((2, 1)) + outputs = keras.layers.Masking(mask_value=0)(inputs) + outputs = keras.layers.TimeDistributed( + keras.layers.Dense(1, kernel_initializer='one'))(outputs) + model = keras.Model(inputs, outputs) + model.compile(loss='mse', optimizer=RMSPropOptimizer(learning_rate=0.001)) + y = np.array([[[1], [1]], [[1], [1]]]) + loss = model.train_on_batch(x, y) + self.assertEqual(float(loss), 0.) + @tf_test_util.run_in_graph_and_eager_modes def test_mask_argument_in_layer(self): # Test that the mask argument gets correctly passed to a layer in the diff --git a/tensorflow/python/keras/layers/wrappers.py b/tensorflow/python/keras/layers/wrappers.py index f0c1e76156..9b8d5fc5cc 100644 --- a/tensorflow/python/keras/layers/wrappers.py +++ b/tensorflow/python/keras/layers/wrappers.py @@ -331,7 +331,7 @@ class TimeDistributed(Wrapper): inner_mask_shape = self._get_shape_tuple((-1,), mask, 2) inner_mask = K.reshape(inner_mask, inner_mask_shape) input_uid = generic_utils.object_list_uid(inputs) - inner_inputs = self._input_map[input_uid] + inner_inputs = self._input_map.get(input_uid, inputs) output_mask = self.layer.compute_mask(inner_inputs, inner_mask) if output_mask is None: if mask is None: diff --git a/tensorflow/python/util/serialization_test.py b/tensorflow/python/util/serialization_test.py index 9d9cac2725..6df7533831 100644 --- a/tensorflow/python/util/serialization_test.py +++ b/tensorflow/python/util/serialization_test.py @@ -55,11 +55,8 @@ class SerializationTests(test.TestCase): model(constant_op.constant([[1.]])) sequential_round_trip = json.loads( json.dumps(model, default=serialization.get_json_type)) - self.assertEqual(5, sequential_round_trip["config"][1]["config"]["units"]) - input_round_trip = json.loads( - json.dumps(model._input_layers, default=serialization.get_json_type)) - self.assertAllEqual([1, 1], - input_round_trip[0]["config"]["batch_input_shape"]) + self.assertEqual( + 5, sequential_round_trip["config"]["layers"][1]["config"]["units"]) @test_util.run_in_graph_and_eager_modes def test_serialize_model(self): diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.-sequential.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.-sequential.pbtxt index 6f05cdd093..97688fcb0f 100644 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.-sequential.pbtxt +++ b/tensorflow/tools/api/golden/v1/tensorflow.keras.-sequential.pbtxt @@ -266,10 +266,6 @@ tf_class { name: "summary" argspec: "args=[\'self\', \'line_length\', \'positions\', \'print_fn\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " } - member_method { - name: "symbolic_set_inputs" - argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" - } member_method { name: "test_on_batch" argspec: "args=[\'self\', \'x\', \'y\', \'sample_weight\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.models.-sequential.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.models.-sequential.pbtxt index 4c1c54001d..acfb3521c0 100644 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.models.-sequential.pbtxt +++ b/tensorflow/tools/api/golden/v1/tensorflow.keras.models.-sequential.pbtxt @@ -266,10 +266,6 @@ tf_class { name: "summary" argspec: "args=[\'self\', \'line_length\', \'positions\', \'print_fn\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " } - member_method { - name: "symbolic_set_inputs" - argspec: "args=[\'self\', \'inputs\'], varargs=None, keywords=None, defaults=None" - } member_method { name: "test_on_batch" argspec: "args=[\'self\', \'x\', \'y\', \'sample_weight\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " -- GitLab From 85fb2bf56873638bb65d9cad75d59a0a16087fe3 Mon Sep 17 00:00:00 2001 From: Skye Wanderman-Milne Date: Wed, 8 Aug 2018 12:17:38 -0700 Subject: [PATCH 209/437] Introduce eager.function.FuncGraph class. FuncGraph is a subclass of CapturingGraph, and represents a function body. This is similar to _FuncGraph in framework/function.py. The eventual goal is to completely replicate the functionality, both for use in tfe.defun and cond_v2. As a PoC, FuncGraph is used instead of CapturingGraph in _trace_and_define_function. The existing unit tests provide coverage for it. As part of this change, CapturingGraph.captures is also changed from a dict to an OrderedDict. The order determines in what order the captured inputs should be passed to the final function (as well as simplifies some of the logic, since we no longer have to key by tensor ID and manually sort to get deterministic results). PiperOrigin-RevId: 207926299 --- tensorflow/python/eager/function.py | 166 +++++++++++++++------- tensorflow/python/eager/graph_callable.py | 10 +- 2 files changed, 117 insertions(+), 59 deletions(-) diff --git a/tensorflow/python/eager/function.py b/tensorflow/python/eager/function.py index e640cc9f66..adbf5605ed 100644 --- a/tensorflow/python/eager/function.py +++ b/tensorflow/python/eager/function.py @@ -83,26 +83,30 @@ def create_substitute_placeholder(value, name, dtype=None): def capture_value(tensor_map, value, dtype, name): """Capture a value from outside the function, to pass in as an extra arg.""" - captured_tuple = tensor_map.get(ops.tensor_id(value), None) - if captured_tuple is None: + captured_value = tensor_map.get(value, None) + if captured_value is None: captured_value = create_substitute_placeholder(value, name=name, dtype=dtype) - tensor_map[ops.tensor_id(value)] = (value, captured_value) - else: - captured_value = captured_tuple[1] + tensor_map[value] = captured_value tape.record_operation("captured_value", [captured_value], [value], lambda x: [x]) return captured_value class CapturingGraph(ops.Graph): - """Graph used when constructing eager functions.""" + """Graph that can capture tensors from other graphs. + + Attributes: + captures: Maps external tensor -> internal tensor (e.g. input placeholder). + The entries are in the order they were captured. + """ def __init__(self): super(CapturingGraph, self).__init__() + + self.captures = collections.OrderedDict() self._building_function = True - # Maps external tensor id -> internal tensor (e.g. input placeholder). - self.captures = {} + # Map from resource tensor name to last op (in program order) which uses # this tensor. Used to enforce that execution order matches program order # for resource tensors. @@ -115,7 +119,22 @@ class CapturingGraph(ops.Graph): def clear_resource_control_flow_state(self): self._last_op_using_resource_tensor = {} + # TODO(skyewm): get rid of name and use the name of `tensor`. def capture(self, tensor, name=None): + """Capture `tensor` if it's external to this graph. + + If `tensor` is from a different graph, returns a placeholder for it. + `tensor` and the placeholder will also appears in self.captures. Multiple + calls to this method with the same `tensor` argument will return the same + placeholder. If `tensor` is from this graph, returns `tensor`. + + Args: + tensor: Tensor. May be from this FuncGraph or a different graph. + name: Optional name if a placeholder is created. + + Returns: + Tensor from this FuncGraph. + """ if isinstance(tensor, ops.EagerTensor): if name is None: name = str(ops.uid()) @@ -137,6 +156,7 @@ class CapturingGraph(ops.Graph): op_def=None, compute_shapes=True, compute_device=True): + """Captures an external inputs before calling Graph.capture_op.""" # This capturing logic interacts poorly with control flow contexts which # want to replace inputs of ops far too late in the process. This can lead # the context to get confused and try to create an Enter for an Enter. We @@ -159,6 +179,70 @@ class CapturingGraph(ops.Graph): compute_device=compute_device) +class FuncGraph(CapturingGraph): + """Graph representing a function body. + + Attributes: + name: The name of the function. + + inputs: Placeholder tensors representing the inputs to this function. The + tensors are in this FuncGraph. This represents "regular" inputs as well as + captured inputs (i.e. the values of self.captures), with the regular + inputs coming first. + outputs: Tensors that will be returned by this function. The tensors are in + this FuncGraph. + structured_outputs: A possibly-nested python object which will be returned + by this function. The Tensors in this structure are the same as those of + self.outputs. Note that this structure might contain Python `None`s. + variables: Variables that should be watched during function execution. + seed: The graph-level random seed. + """ + + def __init__(self, name, graph=None): + """Construct a new FuncGraph. + + Args: + name: the name of the function. + graph: if specified, this FuncGraph will inherit its graph key, + collections, and seed from `graph`. + """ + super(FuncGraph, self).__init__() + + self.name = name + self.inputs = [] + self.outputs = [] + self.structured_outputs = None + self.variables = [] + + if graph is not None: + # Inherit the graph key, since this is used for matching variables in + # optimizers. + self._graph_key = graph._graph_key # pylint: disable=protected-access + + # Copy the graph collections to ensure summaries and other things work. + # This lets the function access (but not mutate) collections of the + # containing graph, such as the global step and the summary writer + # collections. + for collection in graph.collections: + self.get_collection_ref(collection)[:] = graph.get_collection( + collection) + + if context.executing_eagerly(): + self.seed = context.global_seed() + else: + self.seed = graph.seed + + def capture(self, tensor, name=None): + """Calls CapturingGraph.capture and updates self.inputs if necessary.""" + new_capture = tensor not in self.captures + internal_tensor = super(FuncGraph, self).capture(tensor, name) + + if new_capture and tensor is not internal_tensor: + self.inputs.append(internal_tensor) + + return internal_tensor + + # pylint: disable=invalid-name class HelperContext(object): """ControlFlowContext with a customizable AddOp method.""" @@ -502,6 +586,7 @@ class GraphModeFunction(object): def _construct_backprop_function(self): """Constructs the backprop function object for this function.""" filtered_outputs = [x for x in self._python_returns if x is not None] + # TODO(skyewm): use FuncGraph backwards_graph = CapturingGraph() backwards_graph._graph_key = self._graph._graph_key # pylint: disable=protected-access for collection in self._graph.collections: @@ -521,13 +606,8 @@ class GraphModeFunction(object): grad for grad in _flatten(in_gradients) if grad is not None) output_shapes = tuple(grad.shape for grad in backward_outputs) - captures = backwards_graph.captures - ids = list(sorted(captures.keys())) - if ids: - extra_inputs, extra_placeholders = zip(*[captures[x] for x in ids]) - else: - extra_inputs = [] - extra_placeholders = [] + extra_inputs = backwards_graph.captures.keys() + extra_placeholders = backwards_graph.captures.values() forward_name = _forward_name(self._func_name) # Note: we cannot have placeholder ops in the graph or the TPU compilation @@ -749,22 +829,8 @@ def _trace_and_define_function(name, python_func, compiled, args, kwds, TypeError: If any of `python_func`'s return values is neither `None` nor a `Tensor`. """ - graph_key = ops.get_default_graph()._graph_key # pylint: disable=protected-access - func_graph = CapturingGraph() - # Inherit the graph key, since this is used for matching variables in - # optimizers. - func_graph._graph_key = graph_key # pylint: disable=protected-access - # Copy the graph collections to ensure summaries and other things work. This - # lets the function access (but not mutate) collections of the containing - # graph, such as the global step and the summary writer collections. - curr_graph = ops.get_default_graph() - for collection in curr_graph.collections: - func_graph.get_collection_ref(collection)[:] = curr_graph.get_collection( - collection) - if context.executing_eagerly(): - func_graph.seed = context.global_seed() - else: - func_graph.seed = curr_graph.seed + func_graph = FuncGraph(_inference_name(name), graph=ops.get_default_graph()) + with func_graph.as_default(), AutomaticControlDependencies() as a: if signature is None: func_args = _get_defun_inputs_from_args(args) @@ -773,6 +839,12 @@ def _trace_and_define_function(name, python_func, compiled, args, kwds, func_args = _get_defun_inputs_from_signature(signature) func_kwds = {} + # Note: `nest.flatten` sorts by keys, as does `_deterministic_dict_values`. + func_graph.inputs.extend( + x for x in nest.flatten(func_args) + nest.flatten(func_kwds) + if isinstance(x, ops.Tensor) + ) + # Variables to help check whether mutation happens in calling the function # Copy the recursive list, tuple and map structure, but not base objects func_args_before = nest.pack_sequence_as(func_args, nest.flatten(func_args)) @@ -818,6 +890,7 @@ def _trace_and_define_function(name, python_func, compiled, args, kwds, finally: tape.pop_tape(this_tape) + func_graph.structured_outputs = func_outputs variables = list(this_tape.watched_variables()) # Some variables captured by the tape can come from a DistributedValue. @@ -830,32 +903,20 @@ def _trace_and_define_function(name, python_func, compiled, args, kwds, # If variable is not distributed value_container returns itself. variables[i] = strategy.value_container(variable) + func_graph.variables = variables + # Returning a closed-over tensor as an output does not trigger a # call to convert_to_tensor, so we manually capture all such tensors. - func_def_outputs = [ - func_graph.capture(x) for x in _flatten(func_outputs) + func_graph.outputs.extend( + func_graph.capture(x) for x in _flatten(func_graph.structured_outputs) if x is not None - ] + ) - captures = func_graph.captures - ids = list(sorted(captures.keys())) - if ids: - extra_inputs, extra_placeholders = zip(* [captures[x] for x in ids]) - else: - extra_inputs = [] - extra_placeholders = [] output_shapes = tuple( x.shape if isinstance(x, ops.Tensor) else None - for x in func_def_outputs) + for x in func_graph.outputs) - # Note: `nest.flatten` sorts by keys, as does `_deterministic_dict_values`. - flat_inputs = [ - x for x in nest.flatten(func_args) + nest.flatten(func_kwds) - if isinstance(x, ops.Tensor) - ] - all_inputs = flat_inputs + list(extra_placeholders) - all_ignored_ops = frozenset(x.op for x in all_inputs) - fname = _inference_name(name) + all_ignored_ops = frozenset(x.op for x in func_graph.inputs) operations = tuple(x for x in func_graph.get_operations() if x not in all_ignored_ops) # Register any other functions defined in the graph @@ -870,8 +931,9 @@ def _trace_and_define_function(name, python_func, compiled, args, kwds, attrs[_xla_compile_attr] = attr_value_pb2.AttrValue(b=True) return GraphModeFunction( - fname, all_inputs, extra_inputs, func_graph, operations, func_def_outputs, - func_outputs, output_shapes, variables, attrs) + func_graph.name, func_graph.inputs, func_graph.captures.keys(), + func_graph, operations, func_graph.outputs, func_graph.structured_outputs, + output_shapes, func_graph.variables, attrs) _TensorType = collections.namedtuple("_TensorType", ["dtype", "shape"]) diff --git a/tensorflow/python/eager/graph_callable.py b/tensorflow/python/eager/graph_callable.py index 9200396c8a..7105d2e399 100644 --- a/tensorflow/python/eager/graph_callable.py +++ b/tensorflow/python/eager/graph_callable.py @@ -330,13 +330,9 @@ def _graph_callable_internal(func, shape_and_dtypes): sorted_variables = sorted(variable_captures.variables.values(), key=lambda x: x.name) - captures = tmp_graph.captures - ids = list(sorted(captures.keys())) - if ids: - extra_inputs, extra_placeholders = zip(*[captures[x] for x in ids]) - else: - extra_inputs = [] - extra_placeholders = [] + + extra_inputs = tmp_graph.captures.keys() + extra_placeholders = tmp_graph.captures.values() flat_inputs = [x for x in nest.flatten(func_inputs) if isinstance(x, tf_ops.Tensor)] -- GitLab From 30a7ef5b689acc97685d8a32d99f4d59bebc8d5f Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Sat, 30 Jun 2018 19:03:26 -0700 Subject: [PATCH 210/437] Fix build issue on mac with python-2.7.10 and clang 9.1.0 In PR 19993 the build issues on macOS with python2.7.10 and clang-9.1.0 were fixed. However, later on it looks like the order of `` and `` has been changed in https://github.com/tensorflow/tensorflow/commit/1e7b0e4ad6d0f57f3241fe0b80a65f2c2a7f11b0 possibly caused by `clang-format -i --style=`. This caused the build break of macOS with python-2.7.10 and clang 9.1.0 again. This fix updates the impacted files, and, adds an empty line in between so that future `clang-format -i --style` will not cuase build breaks. Signed-off-by: Yong Tang --- tensorflow/python/lib/core/py_util.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tensorflow/python/lib/core/py_util.cc b/tensorflow/python/lib/core/py_util.cc index 2ee898ea1d..739cab46b1 100644 --- a/tensorflow/python/lib/core/py_util.cc +++ b/tensorflow/python/lib/core/py_util.cc @@ -18,6 +18,8 @@ limitations under the License. // Place `` before to avoid build failure in macOS. #include +// The empty line above is on purpose as otherwise clang-format will +// automatically move before . #include #include "tensorflow/core/lib/core/errors.h" -- GitLab From 07ad8e36896f8c9a787b10927d76dacb9519e891 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Sat, 30 Jun 2018 19:07:36 -0700 Subject: [PATCH 211/437] Build fix for interpreter_wrapper.h Signed-off-by: Yong Tang --- .../lite/python/interpreter_wrapper/interpreter_wrapper.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tensorflow/contrib/lite/python/interpreter_wrapper/interpreter_wrapper.h b/tensorflow/contrib/lite/python/interpreter_wrapper/interpreter_wrapper.h index 3e03751da4..f83063627a 100644 --- a/tensorflow/contrib/lite/python/interpreter_wrapper/interpreter_wrapper.h +++ b/tensorflow/contrib/lite/python/interpreter_wrapper/interpreter_wrapper.h @@ -21,6 +21,11 @@ limitations under the License. #include #include +// Place `` before to avoid build failures in macOS. +#include + +// The empty line above is on purpose as otherwise clang-format will +// automatically move before . #include // We forward declare TFLite classes here to avoid exposing them to SWIG. -- GitLab From 46d4c0f254b2e39b74723a026530c8c6cff4f867 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Wed, 8 Aug 2018 19:40:28 +0000 Subject: [PATCH 212/437] Fix merge conflict. Signed-off-by: Yong Tang --- .../lite/python/interpreter_wrapper/interpreter_wrapper.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/tensorflow/contrib/lite/python/interpreter_wrapper/interpreter_wrapper.h b/tensorflow/contrib/lite/python/interpreter_wrapper/interpreter_wrapper.h index f83063627a..641dd93db5 100644 --- a/tensorflow/contrib/lite/python/interpreter_wrapper/interpreter_wrapper.h +++ b/tensorflow/contrib/lite/python/interpreter_wrapper/interpreter_wrapper.h @@ -15,8 +15,6 @@ limitations under the License. #ifndef TENSORFLOW_CONTRIB_LITE_PYTHON_INTERPRETER_WRAPPER_INTERPRETER_WRAPPER_H_ #define TENSORFLOW_CONTRIB_LITE_PYTHON_INTERPRETER_WRAPPER_INTERPRETER_WRAPPER_H_ -// Place `` before to avoid build failures in macOS. -#include #include #include #include -- GitLab From 4827c10422cf23a8a445dbbe9165340cb6ac3cc9 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Wed, 8 Aug 2018 12:34:44 -0700 Subject: [PATCH 213/437] Keras Lambda Layer - enable list of input tensors in eager mode PiperOrigin-RevId: 207928740 --- tensorflow/python/keras/layers/core.py | 3 +-- tensorflow/python/keras/layers/core_test.py | 8 ++++++++ .../api/golden/v1/tensorflow.keras.layers.-lambda.pbtxt | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tensorflow/python/keras/layers/core.py b/tensorflow/python/keras/layers/core.py index 2a42816854..4032202986 100644 --- a/tensorflow/python/keras/layers/core.py +++ b/tensorflow/python/keras/layers/core.py @@ -681,9 +681,8 @@ class Lambda(Layer): 'must be a list, a tuple, or a function.') self._output_shape = output_shape + @tf_utils.shape_type_conversion def compute_output_shape(self, input_shape): - input_shape = tuple(tensor_shape.TensorShape(input_shape).as_list()) - if self._output_shape is None: if context.executing_eagerly(): raise NotImplementedError diff --git a/tensorflow/python/keras/layers/core_test.py b/tensorflow/python/keras/layers/core_test.py index 0ff392ebb3..49ca68ee9e 100644 --- a/tensorflow/python/keras/layers/core_test.py +++ b/tensorflow/python/keras/layers/core_test.py @@ -187,6 +187,14 @@ class CoreLayersTest(test.TestCase): config = ld.get_config() ld = keras.layers.Lambda.from_config(config) + @tf_test_util.run_in_graph_and_eager_modes + def test_lambda_multiple_inputs(self): + ld = keras.layers.Lambda(lambda x: x[0], output_shape=lambda x: x[0]) + x1 = np.ones([3, 2], np.float32) + x2 = np.ones([3, 5], np.float32) + out = ld([x1, x2]) + self.assertAllEqual(out.shape, [3, 2]) + @tf_test_util.run_in_graph_and_eager_modes def test_dense(self): testing_utils.layer_test( diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-lambda.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-lambda.pbtxt index 5d05cf689f..2dff7a6de4 100644 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-lambda.pbtxt +++ b/tensorflow/tools/api/golden/v1/tensorflow.keras.layers.-lambda.pbtxt @@ -118,7 +118,7 @@ tf_class { } member_method { name: "compute_output_shape" - argspec: "args=[\'self\', \'input_shape\'], varargs=None, keywords=None, defaults=None" + argspec: "args=[\'instance\', \'input_shape\'], varargs=None, keywords=None, defaults=None" } member_method { name: "count_params" -- GitLab From 054b0463ebd748b7fe41e5ac22337c8df0ed9821 Mon Sep 17 00:00:00 2001 From: Mark Daoust Date: Wed, 8 Aug 2018 12:47:33 -0700 Subject: [PATCH 214/437] Move Estimator Overview to first element of "High Level APIs". PiperOrigin-RevId: 207930697 --- tensorflow/docs_src/guide/estimators.md | 7 +++++-- tensorflow/docs_src/guide/index.md | 5 ++--- tensorflow/docs_src/guide/leftnav_files | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tensorflow/docs_src/guide/estimators.md b/tensorflow/docs_src/guide/estimators.md index ed9a3da284..7b54e3de29 100644 --- a/tensorflow/docs_src/guide/estimators.md +++ b/tensorflow/docs_src/guide/estimators.md @@ -13,6 +13,9 @@ You may either use the pre-made Estimators we provide or write your own custom Estimators. All Estimators--whether pre-made or custom--are classes based on the `tf.estimator.Estimator` class. +For a quick example try [Estimator tutorials]](../tutorials/estimators/linear). +To see each sub-topic in depth, see the [Estimator guides](premade_estimators). + Note: TensorFlow also includes a deprecated `Estimator` class at `tf.contrib.learn.Estimator`, which you should not use. @@ -29,14 +32,14 @@ Estimators provide the following benefits: * You can develop a state of the art model with high-level intuitive code. In short, it is generally much easier to create models with Estimators than with the low-level TensorFlow APIs. -* Estimators are themselves built on `tf.layers`, which +* Estimators are themselves built on `tf.keras.layers`, which simplifies customization. * Estimators build the graph for you. * Estimators provide a safe distributed training loop that controls how and when to: * build the graph * initialize variables - * start queues + * load data * handle exceptions * create checkpoint files and recover from failures * save summaries for TensorBoard diff --git a/tensorflow/docs_src/guide/index.md b/tensorflow/docs_src/guide/index.md index f78dfc9a89..1c920e7d70 100644 --- a/tensorflow/docs_src/guide/index.md +++ b/tensorflow/docs_src/guide/index.md @@ -9,14 +9,13 @@ works. The units are as follows: training deep learning models. * @{$guide/eager}, an API for writing TensorFlow code imperatively, like you would use Numpy. - * @{$guide/estimators}, a high-level API that provides - fully-packaged models ready for large-scale training and production. * @{$guide/datasets}, easy input pipelines to bring your data into your TensorFlow program. + * @{$guide/estimators}, a high-level API that provides + fully-packaged models ready for large-scale training and production. ## Estimators -* @{$estimators}, learn how to use Estimators for machine learning. * @{$premade_estimators}, the basics of premade Estimators. * @{$checkpoints}, save training progress and resume where you left off. * @{$feature_columns}, handle a variety of input data types without changes to the model. diff --git a/tensorflow/docs_src/guide/leftnav_files b/tensorflow/docs_src/guide/leftnav_files index c4e235b41a..8e227e0c8f 100644 --- a/tensorflow/docs_src/guide/leftnav_files +++ b/tensorflow/docs_src/guide/leftnav_files @@ -4,9 +4,9 @@ index.md keras.md eager.md datasets.md +estimators.md: Introduction to Estimators ### Estimators -estimators.md: Introduction to Estimators premade_estimators.md checkpoints.md feature_columns.md -- GitLab From 151aed209dc5e11059046367a3a115bba324800d Mon Sep 17 00:00:00 2001 From: Eugene Brevdo Date: Wed, 8 Aug 2018 13:04:16 -0700 Subject: [PATCH 215/437] Bring back TFShouldUse without the memory leaks. PiperOrigin-RevId: 207933109 --- tensorflow/python/util/tf_should_use.py | 169 +++++++++++++------ tensorflow/python/util/tf_should_use_test.py | 80 ++++----- 2 files changed, 161 insertions(+), 88 deletions(-) diff --git a/tensorflow/python/util/tf_should_use.py b/tensorflow/python/util/tf_should_use.py index 28e49afa02..ca6710bcf2 100644 --- a/tensorflow/python/util/tf_should_use.py +++ b/tensorflow/python/util/tf_should_use.py @@ -17,23 +17,124 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import functools -import types +import copy +import sys +import traceback import six # pylint: disable=unused-import -from tensorflow.python.eager import context +from tensorflow.python.platform import tf_logging from tensorflow.python.util import tf_decorator # pylint: enable=g-bad-import-order,g-import-not-at-top -# TODO(b/65412899): Re-implement to avoid leaking python objects. -# This function / class remains since the API is public (mark_used()). +class _TFShouldUseHelper(object): + """Object stored in TFShouldUse-wrapped objects. + + When it is deleted it will emit a warning or error if its `sate` method + has not been called by time of deletion. + """ + + def __init__(self, type_, repr_, stack_frame, fatal_error_if_unsated): + self._type = type_ + self._repr = repr_ + self._stack_frame = stack_frame + self._fatal_error_if_unsated = fatal_error_if_unsated + self._sated = False + + def sate(self): + self._sated = True + self._type = None + self._repr = None + self._stack_frame = None + self._logging_module = None + + def __del__(self): + if self._sated: + return + if self._fatal_error_if_unsated: + logger = tf_logging.fatal + else: + logger = tf_logging.error + creation_stack = ''.join( + [line.rstrip() for line in traceback.format_stack(self._stack_frame)]) + logger( + '==================================\n' + 'Object was never used (type %s):\n%s\nIf you want to mark it as ' + 'used call its "mark_used()" method.\nIt was originally created ' + 'here:\n%s\n' + '==================================' % + (self._type, self._repr, creation_stack)) + + +def _new__init__(self, true_value, tf_should_use_helper): + # pylint: disable=protected-access + self._tf_should_use_helper = tf_should_use_helper + self._true_value = true_value + + +def _new__setattr__(self, key, value): + if key in ('_tf_should_use_helper', '_true_value'): + return object.__setattr__(self, key, value) + return setattr( + object.__getattribute__(self, '_true_value'), + key, value) + + +def _new__getattribute__(self, key): + if key not in ('_tf_should_use_helper', '_true_value'): + object.__getattribute__(self, '_tf_should_use_helper').sate() + if key in ('_tf_should_use_helper', 'mark_used', '__setatt__'): + return object.__getattribute__(self, key) + return getattr(object.__getattribute__(self, '_true_value'), key) + + +def _new_mark_used(self, *args, **kwargs): + object.__getattribute__(self, '_tf_should_use_helper').sate() + try: + mu = object.__getattribute__( + object.__getattribute__(self, '_true_value'), + 'mark_used') + return mu(*args, **kwargs) + except AttributeError: + pass + + +_WRAPPERS = dict() + + +def _get_wrapper(x, tf_should_use_helper): + """Create a wrapper for object x, whose class subclasses type(x). + + The wrapper will emit a warning if it is deleted without any of its + properties being accessed or methods being called. + + Args: + x: The instance to wrap. + tf_should_use_helper: The object that tracks usage. + + Returns: + An object wrapping `x`, of type `type(x)`. + """ + type_x = type(x) + memoized = _WRAPPERS.get(type_x, None) + if memoized: + return memoized(x, tf_should_use_helper) + + tx = copy.deepcopy(type_x) + copy_tx = type(tx.__name__, tx.__bases__, dict(tx.__dict__)) + copy_tx.__init__ = _new__init__ + copy_tx.__getattribute__ = _new__getattribute__ + copy_tx.mark_used = _new_mark_used + copy_tx.__setattr__ = _new__setattr__ + _WRAPPERS[type_x] = copy_tx + + return copy_tx(x, tf_should_use_helper) + + def _add_should_use_warning(x, fatal_error=False): """Wraps object x so that if it is never used, a warning is logged. - Does nothing when executing eagerly. - Args: x: Python object. fatal_error: Python bool. If `True`, tf.logging.fatal is raised @@ -43,50 +144,22 @@ def _add_should_use_warning(x, fatal_error=False): An instance of `TFShouldUseWarningWrapper` which subclasses `type(x)` and is a very shallow wrapper for `x` which logs access into `x`. """ - del fatal_error if x is None or x == []: # pylint: disable=g-explicit-bool-comparison return x - if context.executing_eagerly(): - # Typically not needed when executing eagerly (the main use case is for ops - # which need to be incorporated into the graph), and even the no-op wrapper - # creates reference cycles which require garbage collection. - return x - - def override_method(method): - def fn(self, *args, **kwargs): - return method(self, *args, **kwargs) - return fn - - class TFShouldUseWarningWrapper(type(x)): - """Wrapper for objects that keeps track of their use.""" - - def __init__(self, true_self): - self.__dict__ = true_self.__dict__ + # Extract the current frame for later use by traceback printing. + try: + raise ValueError() + except ValueError: + stack_frame = sys.exc_info()[2].tb_frame.f_back - # Not sure why this pylint warning is being used; this is not an - # old class form. - # pylint: disable=super-on-old-class - def __getattribute__(self, name): - return super(TFShouldUseWarningWrapper, self).__getattribute__(name) - - def mark_used(self, *args, **kwargs): - return + tf_should_use_helper = _TFShouldUseHelper( + type_=type(x), + repr_=repr(x), + stack_frame=stack_frame, + fatal_error_if_unsated=fatal_error) - # pylint: enable=super-on-old-class - - for name in dir(TFShouldUseWarningWrapper): - method = getattr(TFShouldUseWarningWrapper, name) - if not isinstance(method, types.FunctionType): - continue - if name in ('__init__', '__getattribute__', '__del__', 'mark_used'): - continue - setattr(TFShouldUseWarningWrapper, name, - functools.wraps(method)(override_method(method))) - - wrapped = TFShouldUseWarningWrapper(x) - wrapped.__doc__ = x.__doc__ # functools.wraps fails on some objects. - return wrapped + return _get_wrapper(x, tf_should_use_helper) def should_use_result(fn): @@ -106,8 +179,6 @@ def should_use_result(fn): - `t != 0`. In this case, comparison is done on types / ids. - `isinstance(t, tf.Tensor)`. Similar to above. - Does nothing when executing eagerly. - Args: fn: The function to wrap. @@ -142,8 +213,6 @@ def must_use_result_or_fatal(fn): - `t != 0`. In this case, comparison is done on types / ids. - `isinstance(t, tf.Tensor)`. Similar to above. - Does nothing when executing eagerly. - Args: fn: The function to wrap. diff --git a/tensorflow/python/util/tf_should_use_test.py b/tensorflow/python/util/tf_should_use_test.py index 4c6e48b11c..4c09c2107e 100644 --- a/tensorflow/python/util/tf_should_use_test.py +++ b/tensorflow/python/util/tf_should_use_test.py @@ -30,48 +30,53 @@ from tensorflow.python.util import tf_should_use @contextlib.contextmanager -def reroute_error(captured): +def reroute_error(): """Temporarily reroute errors written to tf_logging.error into `captured`.""" - del captured[:] - true_logger = tf_logging.error - def capture_errors(*args, **unused_kwargs): - captured.extend(args) - tf_logging.error = capture_errors - try: - yield - finally: - tf_logging.error = true_logger + with test.mock.patch.object(tf_should_use.tf_logging, 'error') as error: + with test.mock.patch.object(tf_should_use.tf_logging, 'fatal') as fatal: + yield error, fatal class TfShouldUseTest(test.TestCase): def testAddShouldUseWarningWhenNotUsed(self): - self.skipTest('b/65412899') c = constant_op.constant(0, name='blah0') - captured = [] - with reroute_error(captured): - def in_this_function(): - h = tf_should_use._add_should_use_warning(c) - del h + def in_this_function(): + h = tf_should_use._add_should_use_warning(c) + del h + with reroute_error() as (error, _): in_this_function() - self.assertIn('Object was never used', '\n'.join(captured)) - self.assertIn('blah0:0', '\n'.join(captured)) - self.assertIn('in_this_function', '\n'.join(captured)) - gc.collect() + error.assert_called() + msg = '\n'.join(error.call_args[0]) + self.assertIn('Object was never used', msg) + self.assertIn('blah0:0', msg) + self.assertIn('in_this_function', msg) + self.assertFalse(gc.garbage) + + def testAddShouldUseFatalWhenNotUsed(self): + c = constant_op.constant(0, name='blah0') + def in_this_function(): + h = tf_should_use._add_should_use_warning(c, fatal_error=True) + del h + with reroute_error() as (_, fatal): + in_this_function() + fatal.assert_called() + msg = '\n'.join(fatal.call_args[0]) + self.assertIn('Object was never used', msg) + self.assertIn('blah0:0', msg) + self.assertIn('in_this_function', msg) self.assertFalse(gc.garbage) def _testAddShouldUseWarningWhenUsed(self, fn, name): c = constant_op.constant(0, name=name) - captured = [] - with reroute_error(captured): + with reroute_error() as (error, fatal): h = tf_should_use._add_should_use_warning(c) fn(h) del h - self.assertNotIn('Object was never used', '\n'.join(captured)) - self.assertNotIn('%s:0' % name, '\n'.join(captured)) + error.assert_not_called() + fatal.assert_not_called() def testAddShouldUseWarningWhenUsedWithAdd(self): - self.skipTest('b/65412899') def add(h): _ = h + 1 self._testAddShouldUseWarningWhenUsed(add, name='blah_add') @@ -79,7 +84,6 @@ class TfShouldUseTest(test.TestCase): self.assertFalse(gc.garbage) def testAddShouldUseWarningWhenUsedWithGetName(self): - self.skipTest('b/65412899') def get_name(h): _ = h.name self._testAddShouldUseWarningWhenUsed(get_name, name='blah_get_name') @@ -87,35 +91,35 @@ class TfShouldUseTest(test.TestCase): self.assertFalse(gc.garbage) def testShouldUseResult(self): - self.skipTest('b/65412899') @tf_should_use.should_use_result def return_const(value): return constant_op.constant(value, name='blah2') - captured = [] - with reroute_error(captured): + with reroute_error() as (error, _): return_const(0.0) - self.assertIn('Object was never used', '\n'.join(captured)) - self.assertIn('blah2:0', '\n'.join(captured)) - self.assertIn('return_const', '\n'.join(captured)) + error.assert_called() + msg = '\n'.join(error.call_args[0]) + self.assertIn('Object was never used', msg) + self.assertIn('blah2:0', msg) + self.assertIn('return_const', msg) gc.collect() self.assertFalse(gc.garbage) def testShouldUseResultWhenNotReallyUsed(self): - self.skipTest('b/65412899') @tf_should_use.should_use_result def return_const(value): return constant_op.constant(value, name='blah3') - captured = [] - with reroute_error(captured): + with reroute_error() as (error, _): with self.test_session(): return_const(0.0) # Creating another op and executing it does not mark the # unused op as being "used". v = constant_op.constant(1.0, name='meh') v.eval() - self.assertIn('Object was never used', '\n'.join(captured)) - self.assertIn('blah3:0', '\n'.join(captured)) - self.assertIn('return_const', '\n'.join(captured)) + error.assert_called() + msg = '\n'.join(error.call_args[0]) + self.assertIn('Object was never used', msg) + self.assertIn('blah3:0', msg) + self.assertIn('return_const', msg) gc.collect() self.assertFalse(gc.garbage) -- GitLab From 0004e45e5e13672c68cfef71e1d6a7996c79b5a4 Mon Sep 17 00:00:00 2001 From: Rachel Lim Date: Wed, 8 Aug 2018 13:18:48 -0700 Subject: [PATCH 216/437] Add a (internal) `MapFn` op that maps a function over batches of inputs. PiperOrigin-RevId: 207935291 --- .../contrib/data/python/kernel_tests/BUILD | 19 ++ .../python/kernel_tests/map_defun_op_test.py | 126 ++++++++++++ tensorflow/contrib/data/python/ops/BUILD | 12 ++ .../contrib/data/python/ops/map_defun.py | 58 ++++++ .../api_def/base_api/api_def_MapDefun.pbtxt | 34 ++++ tensorflow/core/kernels/data/BUILD | 13 ++ tensorflow/core/kernels/data/map_defun_op.cc | 192 ++++++++++++++++++ tensorflow/core/ops/dataset_ops.cc | 42 ++++ 8 files changed, 496 insertions(+) create mode 100644 tensorflow/contrib/data/python/kernel_tests/map_defun_op_test.py create mode 100644 tensorflow/contrib/data/python/ops/map_defun.py create mode 100644 tensorflow/core/api_def/base_api/api_def_MapDefun.pbtxt create mode 100644 tensorflow/core/kernels/data/map_defun_op.cc diff --git a/tensorflow/contrib/data/python/kernel_tests/BUILD b/tensorflow/contrib/data/python/kernel_tests/BUILD index 24c7ee68db..ea92191f3e 100644 --- a/tensorflow/contrib/data/python/kernel_tests/BUILD +++ b/tensorflow/contrib/data/python/kernel_tests/BUILD @@ -205,6 +205,25 @@ py_test( ], ) +py_test( + name = "map_defun_op_test", + size = "small", + srcs = ["map_defun_op_test.py"], + srcs_version = "PY2AND3", + tags = ["no_pip"], + deps = [ + "//tensorflow/contrib/data/python/ops:map_defun", + "//tensorflow/python:array_ops", + "//tensorflow/python:check_ops", + "//tensorflow/python:client_testlib", + "//tensorflow/python:constant_op", + "//tensorflow/python:dtypes", + "//tensorflow/python:framework_ops", + "//tensorflow/python:function", + "//tensorflow/python:math_ops", + ], +) + py_test( name = "optimize_dataset_op_test", size = "small", diff --git a/tensorflow/contrib/data/python/kernel_tests/map_defun_op_test.py b/tensorflow/contrib/data/python/kernel_tests/map_defun_op_test.py new file mode 100644 index 0000000000..a711325dae --- /dev/null +++ b/tensorflow/contrib/data/python/kernel_tests/map_defun_op_test.py @@ -0,0 +1,126 @@ +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== +"""Tests for MapDefunOp.""" +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +from tensorflow.contrib.data.python.ops import map_defun +from tensorflow.python.framework import constant_op +from tensorflow.python.framework import dtypes +from tensorflow.python.framework import errors +from tensorflow.python.framework import function +from tensorflow.python.framework import ops +from tensorflow.python.ops import array_ops +from tensorflow.python.ops import check_ops +from tensorflow.python.ops import math_ops +from tensorflow.python.platform import test + + +class MapDefunTest(test.TestCase): + + def testMapDefun_Simple(self): + + @function.Defun(dtypes.int32) + def simple_fn(x): + return x * 2 + 3 + + with self.test_session(): + nums = [[1, 2], [3, 4], [5, 6]] + elems = constant_op.constant(nums, dtype=dtypes.int32, name="data") + r = map_defun.map_defun(simple_fn, [elems], [dtypes.int32], [(2,)])[0] + expected = elems * 2 + 3 + self.assertAllEqual(self.evaluate(r), self.evaluate(expected)) + + def testMapDefun_MismatchedTypes(self): + + @function.Defun(dtypes.int32) + def fn(x): + return math_ops.cast(x, dtypes.float64) + + with self.test_session(): + nums = [1, 2, 3, 4, 5, 6] + elems = constant_op.constant(nums, dtype=dtypes.int32, name="data") + r = map_defun.map_defun(fn, [elems], [dtypes.int32], [()])[0] + with self.assertRaises(errors.InvalidArgumentError): + self.evaluate(r) + + def testMapDefun_MultipleOutputs(self): + + @function.Defun(dtypes.int32) + def fn(x): + return (x, math_ops.cast(x * 2 + 3, dtypes.float64)) + + with self.test_session(): + nums = [[1, 2], [3, 4], [5, 6]] + elems = constant_op.constant(nums, dtype=dtypes.int32, name="data") + r = map_defun.map_defun(fn, [elems], [dtypes.int32, dtypes.float64], + [(2,), (2,)]) + expected = [elems, elems * 2 + 3] + self.assertAllEqual(self.evaluate(r), self.evaluate(expected)) + + def testMapDefun_ShapeInference(self): + + @function.Defun(dtypes.int32) + def fn(x): + return x + + nums = [[1, 2], [3, 4], [5, 6]] + elems = constant_op.constant(nums, dtype=dtypes.int32, name="data") + result = map_defun.map_defun(fn, [elems], [dtypes.int32], [(2,)])[0] + self.assertEqual(result.get_shape(), (3, 2)) + + def testMapDefun_PartialShapeInference(self): + + @function.Defun(dtypes.int32) + def fn(x): + return x + + elems = array_ops.placeholder(dtypes.int64, (None, 2)) + result = map_defun.map_defun(fn, [elems], [dtypes.int32], [(2,)]) + self.assertEqual(result[0].get_shape().as_list(), [None, 2]) + + def testMapDefun_RaisesErrorOnRuntimeShapeMismatch(self): + + @function.Defun(dtypes.int32, dtypes.int32) + def fn(x, y): + return x, y + + elems1 = array_ops.placeholder(dtypes.int32) + elems2 = array_ops.placeholder(dtypes.int32) + result = map_defun.map_defun(fn, [elems1, elems2], + [dtypes.int32, dtypes.int32], [(), ()]) + with self.test_session() as sess: + with self.assertRaisesWithPredicateMatch( + errors.InvalidArgumentError, + "All inputs must have the same dimension 0."): + sess.run(result, feed_dict={elems1: [1, 2, 3, 4, 5], elems2: [1, 2, 3]}) + + def testMapDefun_RaisesDefunError(self): + + @function.Defun(dtypes.int32) + def fn(x): + with ops.control_dependencies([check_ops.assert_equal(x, 0)]): + return array_ops.identity(x) + + elems = constant_op.constant([0, 0, 0, 37, 0]) + result = map_defun.map_defun(fn, [elems], [dtypes.int32], [()]) + with self.test_session(): + with self.assertRaises(errors.InvalidArgumentError): + self.evaluate(result) + + +if __name__ == "__main__": + test.main() diff --git a/tensorflow/contrib/data/python/ops/BUILD b/tensorflow/contrib/data/python/ops/BUILD index 1ad021ea03..ad9378dfb9 100644 --- a/tensorflow/contrib/data/python/ops/BUILD +++ b/tensorflow/contrib/data/python/ops/BUILD @@ -210,6 +210,17 @@ py_library( ], ) +py_library( + name = "map_defun", + srcs = ["map_defun.py"], + srcs_version = "PY2AND3", + deps = [ + "//tensorflow/python:dataset_ops_gen", + "//tensorflow/python:framework_ops", + "//tensorflow/python:tensor_shape", + ], +) + py_library( name = "resampling", srcs = ["resampling.py"], @@ -370,6 +381,7 @@ py_library( ":get_single_element", ":grouping", ":interleave_ops", + ":map_defun", ":optimization", ":prefetching_ops", ":readers", diff --git a/tensorflow/contrib/data/python/ops/map_defun.py b/tensorflow/contrib/data/python/ops/map_defun.py new file mode 100644 index 0000000000..54d5cd6da0 --- /dev/null +++ b/tensorflow/contrib/data/python/ops/map_defun.py @@ -0,0 +1,58 @@ +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== +"""Experimental API for optimizing `tf.data` pipelines.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +from tensorflow.python.framework import ops +from tensorflow.python.framework import tensor_shape +from tensorflow.python.ops import gen_dataset_ops + + +def map_defun(fn, elems, output_dtypes, output_shapes): + """Map a function on the list of tensors unpacked from `elems` on dimension 0. + + Args: + fn: A function (`function.Defun`) that takes a list of tensors and returns + another list of tensors. The output list has the same types as + output_dtypes. The elements of the output list have the same dimension 0 + as `elems`, and the remaining dimensions correspond to those of + `fn_output_shapes`. + elems: A list of tensors. + output_dtypes: A list of dtypes corresponding to the output types of the + function. + output_shapes: A list of `TensorShape`s corresponding to the output + shapes from each invocation of the function on slices of inputs. + + Raises: + ValueError: if any of the inputs are malformed. + + Returns: + A list of `Tensor` objects with the same types as `output_dtypes`. + """ + if not isinstance(elems, list): + raise ValueError("`elems` must be a list of tensors.") + if not isinstance(output_dtypes, list): + raise ValueError("`output_dtypes` must be a list of tensors.") + if not isinstance(output_shapes, list): + raise ValueError("`output_shapes` must be a list of tensors.") + + elems = [ops.convert_to_tensor(e) for e in elems] + output_shapes = [tensor_shape.TensorShape(s) for s in output_shapes] + if not all(s.is_fully_defined() for s in output_shapes): + raise ValueError("All fn output shapes must be fully defined.") + return gen_dataset_ops.map_defun(elems, output_dtypes, output_shapes, fn) diff --git a/tensorflow/core/api_def/base_api/api_def_MapDefun.pbtxt b/tensorflow/core/api_def/base_api/api_def_MapDefun.pbtxt new file mode 100644 index 0000000000..4433693759 --- /dev/null +++ b/tensorflow/core/api_def/base_api/api_def_MapDefun.pbtxt @@ -0,0 +1,34 @@ +op { + graph_op_name: "MapDefun" + visibility: HIDDEN + in_arg { + name: "arguments" + description: <step_id = ctx->step_id(); + opts->rendezvous = ctx->rendezvous(); + opts->cancellation_manager = ctx->cancellation_manager(); + if (always_collect_stats) { + opts->stats_collector = ctx->stats_collector(); + } + opts->runner = ctx->runner(); +} + +class MapDefunOp : public AsyncOpKernel { + public: + explicit MapDefunOp(OpKernelConstruction* ctx) : AsyncOpKernel(ctx) { + auto func_lib = ctx->function_library(); + OP_REQUIRES(ctx, func_lib != nullptr, + errors::Internal("No function library.")); + const NameAttrList* func; + OP_REQUIRES_OK(ctx, ctx->GetAttr("f", &func)); + OP_REQUIRES_OK(ctx, + func_lib->Instantiate(func->name(), AttrSlice(&func->attr()), + &func_handle_)); + OP_REQUIRES_OK(ctx, ctx->GetAttr("output_shapes", &output_shapes_)); + + OP_REQUIRES(ctx, ctx->num_inputs() >= 0, + errors::InvalidArgument("Must have at least one input.")); + OP_REQUIRES(ctx, ctx->num_outputs() >= 0, + errors::InvalidArgument("Must have at least one output.")); + OP_REQUIRES(ctx, ctx->num_outputs() == output_shapes_.size(), + errors::InvalidArgument( + "Length of output_shapes and output_types must match.")); + } + + ~MapDefunOp() override {} + + void ComputeAsync(OpKernelContext* ctx, DoneCallback done) override { + int64 batch_size = ctx->input(0).dim_size(0); + // Inputs + auto* args = new std::vector; + auto* arg_shapes = new std::vector; + arg_shapes->reserve(ctx->num_inputs()); + args->reserve(ctx->num_inputs()); + + for (size_t i = 0; i < ctx->num_inputs(); ++i) { + args->push_back(ctx->input(i)); + arg_shapes->push_back(ctx->input(i).shape()); + arg_shapes->at(i).RemoveDim(0); // Remove the first batch dimension + OP_REQUIRES_ASYNC( + ctx, batch_size == ctx->input(i).dim_size(0), + errors::InvalidArgument("All inputs must have the same dimension 0."), + done); + } + + // Outputs + auto* output = new OpOutputList; + OP_REQUIRES_OK_ASYNC(ctx, ctx->output_list("output", output), done); + + for (size_t i = 0; i < output_types().size(); ++i) { + Tensor* out = nullptr; + TensorShape output_shape = output_shapes_.at(i); + output_shape.InsertDim(0, batch_size); + OP_REQUIRES_OK_ASYNC(ctx, output->allocate(i, output_shape, &out), done); + } + + SetRunOptions(ctx, &opts_, false); + + // Run loop + StatusCallback callback = std::bind( + [](OpKernelContext* ctx, std::vector* args, + std::vector* arg_shapes, OpOutputList* output, + DoneCallback& done, const Status& status) { + delete args; + delete arg_shapes; + delete output; + ctx->SetStatus(status); + done(); + }, + ctx, args, arg_shapes, output, std::move(done), std::placeholders::_1); + + auto* refcounted = new ReffedStatusCallback(std::move(callback)); + + for (size_t i = 1; i < static_cast(batch_size); ++i) { + // Start from i = 1 because refcounted is initialized with refcount = 1 + refcounted->Ref(); + } + for (size_t i = 0; i < static_cast(batch_size); ++i) { + auto* call_frame = + new MapFunctionCallFrame(*args, *arg_shapes, output, this, i); + ctx->function_library()->Run( + opts_, func_handle_, call_frame, + [call_frame, refcounted](const Status& func_status) { + delete call_frame; + refcounted->UpdateStatus(func_status); + refcounted->Unref(); + }); + } + } + + private: + FunctionLibraryRuntime::Handle func_handle_; + FunctionLibraryRuntime::Options opts_; + std::vector output_shapes_; + + class MapFunctionCallFrame : public CallFrameInterface { + public: + MapFunctionCallFrame(const std::vector& args, + const std::vector& arg_shapes, + OpOutputList* output, OpKernel* kernel, size_t iter) + : args_(args), + arg_shapes_(arg_shapes), + output_(output), + kernel_(kernel), + iter_(iter) {} + + ~MapFunctionCallFrame() override {} + + size_t num_args() const override { return args_.size(); } + size_t num_retvals() const override { + return static_cast(kernel_->num_outputs()); + } + + Status GetArg(int index, Tensor* val) const override { + if (index < 0 || index >= args_.size()) { + return errors::InvalidArgument( + "Mismatch in number of function inputs."); + } + bool result = val->CopyFrom(args_.at(index).Slice(iter_, iter_ + 1), + arg_shapes_.at(index)); + if (!result) { + return errors::Internal("GetArg failed."); + } else if (!val->IsAligned()) { + // Ensure alignment + *val = tensor::DeepCopy(*val); + } + + return Status::OK(); + } + + Status SetRetval(int index, const Tensor& val) override { + if (index < 0 || index >= kernel_->num_outputs()) { + return errors::InvalidArgument( + "Mismatch in number of function outputs."); + } + + if (val.dtype() != kernel_->output_type(index)) { + return errors::InvalidArgument( + "Mismatch in function return type and expected output type for " + "output: ", + index); + } + return batch_util::CopyElementToSlice(val, (*output_)[index], iter_); + } + + private: + const std::vector& args_; + const std::vector& arg_shapes_; + OpOutputList* output_; + const OpKernel* kernel_; + const size_t iter_; + }; +}; // namespace + +REGISTER_KERNEL_BUILDER(Name("MapDefun").Device(DEVICE_CPU), MapDefunOp); +} // namespace +} // namespace tensorflow diff --git a/tensorflow/core/ops/dataset_ops.cc b/tensorflow/core/ops/dataset_ops.cc index 7a02454b25..13733d48f0 100644 --- a/tensorflow/core/ops/dataset_ops.cc +++ b/tensorflow/core/ops/dataset_ops.cc @@ -854,4 +854,46 @@ REGISTER_OP("IteratorGetNextAsOptional") .Attr("output_shapes: list(shape) >= 1") .SetShapeFn(shape_inference::ScalarShape); +REGISTER_OP("MapDefun") + .Input("arguments: Targuments") + .Output("output: output_types") + .Attr("Targuments: list(type) >= 1") + .Attr("output_types: list(type) >= 1") + .Attr("output_shapes: list(shape) >= 1") + .Attr("f: func") + .SetShapeFn([](shape_inference::InferenceContext* c) { + std::vector output_shapes; + TF_RETURN_IF_ERROR(c->GetAttr("output_shapes", &output_shapes)); + if (output_shapes.size() != c->num_outputs()) { + return errors::InvalidArgument( + "`output_shapes` must be the same length as `output_types` (", + output_shapes.size(), " vs. ", c->num_outputs(), ")"); + } + + int64 dim_zero = -1; + for (size_t i = 0; i < static_cast(c->num_inputs()); ++i) { + auto dim_handle = c->Dim(c->input(i), 0); + if (c->ValueKnown(dim_handle)) { + if (dim_zero == -1) { + dim_zero = c->Value(dim_handle); + } else if (c->Value(dim_handle) != dim_zero) { + return errors::InvalidArgument( + "Inputs must have the same dimension 0."); + } + } + } + + for (size_t i = 0; i < output_shapes.size(); ++i) { + PartialTensorShape s({}); + s = s.Concatenate(dim_zero); + s = s.Concatenate(output_shapes[i]); + shape_inference::ShapeHandle output_shape_handle; + + TF_RETURN_IF_ERROR( + c->MakeShapeFromPartialTensorShape(s, &output_shape_handle)); + c->set_output(static_cast(i), output_shape_handle); + } + return Status::OK(); + }); + } // namespace tensorflow -- GitLab From 1ce16d0f9e5282d74c51f8471d1962ada8c566ed Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Wed, 8 Aug 2018 13:20:58 -0700 Subject: [PATCH 217/437] Update ops-related pbtxt files. PiperOrigin-RevId: 207935625 --- .../core/ops/compat/ops_history.v1.pbtxt | 33 +++++++++++++++++++ tensorflow/core/ops/ops.pbtxt | 33 +++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/tensorflow/core/ops/compat/ops_history.v1.pbtxt b/tensorflow/core/ops/compat/ops_history.v1.pbtxt index 3418fcfa0a..31db467693 100644 --- a/tensorflow/core/ops/compat/ops_history.v1.pbtxt +++ b/tensorflow/core/ops/compat/ops_history.v1.pbtxt @@ -29285,6 +29285,39 @@ op { minimum: 1 } } +op { + name: "MapDefun" + input_arg { + name: "arguments" + type_list_attr: "Targuments" + } + output_arg { + name: "output" + type_list_attr: "output_types" + } + attr { + name: "Targuments" + type: "list(type)" + has_minimum: true + minimum: 1 + } + attr { + name: "output_types" + type: "list(type)" + has_minimum: true + minimum: 1 + } + attr { + name: "output_shapes" + type: "list(shape)" + has_minimum: true + minimum: 1 + } + attr { + name: "f" + type: "func" + } +} op { name: "MapIncompleteSize" output_arg { diff --git a/tensorflow/core/ops/ops.pbtxt b/tensorflow/core/ops/ops.pbtxt index a67678ab9a..0f21a4f28c 100644 --- a/tensorflow/core/ops/ops.pbtxt +++ b/tensorflow/core/ops/ops.pbtxt @@ -14510,6 +14510,39 @@ op { minimum: 1 } } +op { + name: "MapDefun" + input_arg { + name: "arguments" + type_list_attr: "Targuments" + } + output_arg { + name: "output" + type_list_attr: "output_types" + } + attr { + name: "Targuments" + type: "list(type)" + has_minimum: true + minimum: 1 + } + attr { + name: "output_types" + type: "list(type)" + has_minimum: true + minimum: 1 + } + attr { + name: "output_shapes" + type: "list(shape)" + has_minimum: true + minimum: 1 + } + attr { + name: "f" + type: "func" + } +} op { name: "MapIncompleteSize" output_arg { -- GitLab From 54d92a58cad8619460889bd1b1ef34df89d1b612 Mon Sep 17 00:00:00 2001 From: Nupur Garg Date: Wed, 8 Aug 2018 13:33:49 -0700 Subject: [PATCH 218/437] Minor fixes to Eager delegate. PiperOrigin-RevId: 207937525 --- tensorflow/contrib/lite/delegates/eager/BUILD | 2 + .../contrib/lite/delegates/eager/delegate.cc | 38 +++++++++++-------- .../contrib/lite/delegates/eager/delegate.h | 8 ++-- .../contrib/lite/delegates/eager/util.cc | 6 +++ .../contrib/lite/delegates/eager/util.h | 4 ++ .../contrib/lite/delegates/eager/util_test.cc | 10 +++++ tensorflow/contrib/lite/interpreter.h | 7 ++-- 7 files changed, 52 insertions(+), 23 deletions(-) diff --git a/tensorflow/contrib/lite/delegates/eager/BUILD b/tensorflow/contrib/lite/delegates/eager/BUILD index 332a871446..f21540d524 100644 --- a/tensorflow/contrib/lite/delegates/eager/BUILD +++ b/tensorflow/contrib/lite/delegates/eager/BUILD @@ -50,6 +50,7 @@ cc_library( ":buffer_map", ":delegate_data", ":kernel", + ":util", "//tensorflow/contrib/lite:framework", "//tensorflow/contrib/lite:kernel_api", "//tensorflow/contrib/lite:util", @@ -154,6 +155,7 @@ cc_library( srcs = ["util.cc"], hdrs = ["util.h"], deps = [ + ":constants", "//tensorflow/c:c_api_internal", "//tensorflow/contrib/lite:framework", "//tensorflow/contrib/lite:kernel_api", diff --git a/tensorflow/contrib/lite/delegates/eager/delegate.cc b/tensorflow/contrib/lite/delegates/eager/delegate.cc index 673859da48..7d22b45419 100644 --- a/tensorflow/contrib/lite/delegates/eager/delegate.cc +++ b/tensorflow/contrib/lite/delegates/eager/delegate.cc @@ -19,6 +19,7 @@ limitations under the License. #include "tensorflow/contrib/lite/context_util.h" #include "tensorflow/contrib/lite/delegates/eager/buffer_map.h" #include "tensorflow/contrib/lite/delegates/eager/kernel.h" +#include "tensorflow/contrib/lite/delegates/eager/util.h" #include "tensorflow/contrib/lite/util.h" #include "tensorflow/core/lib/core/status.h" @@ -27,7 +28,7 @@ namespace eager { namespace delegate { TfLiteStatus Prepare(TfLiteContext* context, TfLiteDelegate* delegate) { - // Get the nodes in the current execution plan. + // Get the nodes in the current execution plan. Interpreter owns this array. TfLiteIntArray* plan; TF_LITE_ENSURE_STATUS(context->GetExecutionPlan(context, &plan)); @@ -39,8 +40,7 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteDelegate* delegate) { TF_LITE_ENSURE_STATUS(context->GetNodeAndRegistration( context, node_index, &node, ®istration)); - if (registration->custom_name && - strncmp(registration->custom_name, "Eager", 5) == 0) { + if (IsEagerOp(registration->custom_name)) { supported_nodes.push_back(node_index); } } @@ -63,6 +63,7 @@ TfLiteStatus CopyFromBufferHandle(TfLiteDelegate* delegate, BufferMap* buffer_map = reinterpret_cast(delegate->data_)->GetBufferMap(); + // TODO(nupurgarg): Use TfLiteContext's ReportError instead of fprinf. if (!buffer_map->HasTensor(buffer_handle)) { fprintf(stderr, "Invalid tensor index %d.\n", buffer_handle); return kTfLiteError; @@ -83,20 +84,27 @@ TfLiteStatus CopyFromBufferHandle(TfLiteDelegate* delegate, } // namespace delegate } // namespace eager -EagerDelegate::EagerDelegate() { - if (!eager::DelegateData::Create(&delegate_data_).ok()) { - fprintf(stderr, "Unable to initialize TensorFlow context.\n"); - return; +EagerDelegate::EagerDelegate() {} + +EagerDelegate::~EagerDelegate() {} + +TfLiteStatus EagerDelegate::Apply(Interpreter* interpreter) { + if (!delegate_) { + if (!eager::DelegateData::Create(&delegate_data_).ok()) { + fprintf(stderr, "Unable to initialize TensorFlow context.\n"); + return kTfLiteError; + } + + delegate_.reset(new TfLiteDelegate{ + /*data_=*/delegate_data_.get(), + /*nullptr,*/ &eager::delegate::Prepare, + /*CopyFromBufferHandle=*/&eager::delegate::CopyFromBufferHandle, + /*CopyToBufferHandle=*/nullptr, + /*FreeBufferHandle=*/nullptr}); } - delegate_.reset(new TfLiteDelegate{ - /*data_=*/delegate_data_.get(), - /*nullptr,*/ &eager::delegate::Prepare, - /*CopyFromBufferHandle=*/&eager::delegate::CopyFromBufferHandle, - /*CopyToBufferHandle=*/nullptr, - /*FreeBufferHandle=*/nullptr}); + return interpreter->ModifyGraphWithDelegate(delegate_.get(), + /*allow_dynamic_tensors=*/true); } -EagerDelegate::~EagerDelegate() {} - } // namespace tflite diff --git a/tensorflow/contrib/lite/delegates/eager/delegate.h b/tensorflow/contrib/lite/delegates/eager/delegate.h index 6259b35931..0defca7c32 100644 --- a/tensorflow/contrib/lite/delegates/eager/delegate.h +++ b/tensorflow/contrib/lite/delegates/eager/delegate.h @@ -30,7 +30,7 @@ namespace tflite { // interpreter. // // Usage: -// EagerDelegate delegate(); +// EagerDelegate delegate; // ... build interpreter ... // // delegate.Apply(interpreter); @@ -42,10 +42,8 @@ class EagerDelegate { EagerDelegate(); ~EagerDelegate(); - TfLiteStatus Apply(Interpreter* interpreter) { - return interpreter->ModifyGraphWithDelegate(delegate_.get(), - /*allow_dynamic_tensors=*/true); - } + // Modifies the graph loaded in the interpreter. + TfLiteStatus Apply(Interpreter* interpreter); private: std::unique_ptr delegate_data_; diff --git a/tensorflow/contrib/lite/delegates/eager/util.cc b/tensorflow/contrib/lite/delegates/eager/util.cc index 4426c653e6..c8aa0b7f69 100644 --- a/tensorflow/contrib/lite/delegates/eager/util.cc +++ b/tensorflow/contrib/lite/delegates/eager/util.cc @@ -13,10 +13,16 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #include "tensorflow/contrib/lite/delegates/eager/util.h" +#include "tensorflow/contrib/lite/delegates/eager/constants.h" namespace tflite { namespace eager { +bool IsEagerOp(const char* custom_name) { + return custom_name && strncmp(custom_name, kCustomCodePrefix, + strlen(kCustomCodePrefix)) == 0; +} + TfLiteStatus ConvertStatus(TfLiteContext* context, const tensorflow::Status& status) { if (!status.ok()) { diff --git a/tensorflow/contrib/lite/delegates/eager/util.h b/tensorflow/contrib/lite/delegates/eager/util.h index a9407be071..b7363361be 100644 --- a/tensorflow/contrib/lite/delegates/eager/util.h +++ b/tensorflow/contrib/lite/delegates/eager/util.h @@ -23,6 +23,10 @@ limitations under the License. namespace tflite { namespace eager { +// Checks whether the prefix of the custom name indicates the operation is an +// Eager operation. +bool IsEagerOp(const char* custom_name); + // Converts a tensorflow:Status into a TfLiteStatus. If the original status // represented an error, reports it using the given 'context'. TfLiteStatus ConvertStatus(TfLiteContext* context, diff --git a/tensorflow/contrib/lite/delegates/eager/util_test.cc b/tensorflow/contrib/lite/delegates/eager/util_test.cc index c4fbf54127..4e92da8d34 100644 --- a/tensorflow/contrib/lite/delegates/eager/util_test.cc +++ b/tensorflow/contrib/lite/delegates/eager/util_test.cc @@ -102,6 +102,16 @@ TEST(UtilTest, TypeConversions) { EXPECT_EQ(TF_BOOL, GetTensorFlowDataType(kTfLiteBool)); } +TEST(UtilTest, IsEagerOp) { + EXPECT_TRUE(IsEagerOp("Eager")); + EXPECT_TRUE(IsEagerOp("EagerOp")); + EXPECT_FALSE(IsEagerOp("eager")); + EXPECT_FALSE(IsEagerOp("Eage")); + EXPECT_FALSE(IsEagerOp("OpEager")); + EXPECT_FALSE(IsEagerOp(nullptr)); + EXPECT_FALSE(IsEagerOp("")); +} + } // namespace } // namespace eager } // namespace tflite diff --git a/tensorflow/contrib/lite/interpreter.h b/tensorflow/contrib/lite/interpreter.h index be149a8cc0..e8301ff507 100644 --- a/tensorflow/contrib/lite/interpreter.h +++ b/tensorflow/contrib/lite/interpreter.h @@ -527,12 +527,13 @@ class Interpreter { TfLiteRegistration** registration); // WARNING: This is an experimental interface that is subject to change. - // Gets an TfLiteIntArray* representing the execution plan. The caller owns - // this memory and must free it with TfLiteIntArrayFree(). + // Gets an TfLiteIntArray* representing the execution plan. The interpreter + // owns this memory and it is only guaranteed to exist during the invocation + // of the delegate prepare. TfLiteStatus GetExecutionPlan(TfLiteIntArray** execution_plan); // WARNING: This is an experimental interface that is subject to change. - // Entry point for C node plugin API to get the execution plan + // Entry point for C node plugin API to get the execution plan. static TfLiteStatus GetExecutionPlan(struct TfLiteContext* context, TfLiteIntArray** execution_plan); -- GitLab From 99ae68bba52bb6338af06f37bb104128d7af6fb4 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Wed, 8 Aug 2018 13:53:22 -0700 Subject: [PATCH 219/437] Go: Update generated wrapper functions for TensorFlow ops. PiperOrigin-RevId: 207940651 --- tensorflow/go/op/wrappers.go | 246 +++++++++++++++++------------------ 1 file changed, 123 insertions(+), 123 deletions(-) diff --git a/tensorflow/go/op/wrappers.go b/tensorflow/go/op/wrappers.go index ca1521e641..f11c37f9ec 100644 --- a/tensorflow/go/op/wrappers.go +++ b/tensorflow/go/op/wrappers.go @@ -2618,70 +2618,6 @@ func Reverse(scope *Scope, tensor tf.Output, dims tf.Output) (output tf.Output) return op.Output(0) } -// Copy a tensor setting everything outside a central band in each innermost matrix -// -// to zero. -// -// The `band` part is computed as follows: -// Assume `input` has `k` dimensions `[I, J, K, ..., M, N]`, then the output is a -// tensor with the same shape where -// -// `band[i, j, k, ..., m, n] = in_band(m, n) * input[i, j, k, ..., m, n]`. -// -// The indicator function -// -// `in_band(m, n) = (num_lower < 0 || (m-n) <= num_lower)) && -// (num_upper < 0 || (n-m) <= num_upper)`. -// -// For example: -// -// ``` -// # if 'input' is [[ 0, 1, 2, 3] -// [-1, 0, 1, 2] -// [-2, -1, 0, 1] -// [-3, -2, -1, 0]], -// -// tf.matrix_band_part(input, 1, -1) ==> [[ 0, 1, 2, 3] -// [-1, 0, 1, 2] -// [ 0, -1, 0, 1] -// [ 0, 0, -1, 0]], -// -// tf.matrix_band_part(input, 2, 1) ==> [[ 0, 1, 0, 0] -// [-1, 0, 1, 0] -// [-2, -1, 0, 1] -// [ 0, -2, -1, 0]] -// ``` -// -// Useful special cases: -// -// ``` -// tf.matrix_band_part(input, 0, -1) ==> Upper triangular part. -// tf.matrix_band_part(input, -1, 0) ==> Lower triangular part. -// tf.matrix_band_part(input, 0, 0) ==> Diagonal. -// ``` -// -// Arguments: -// input: Rank `k` tensor. -// num_lower: 0-D tensor. Number of subdiagonals to keep. If negative, keep entire -// lower triangle. -// num_upper: 0-D tensor. Number of superdiagonals to keep. If negative, keep -// entire upper triangle. -// -// Returns Rank `k` tensor of the same shape as input. The extracted banded tensor. -func MatrixBandPart(scope *Scope, input tf.Output, num_lower tf.Output, num_upper tf.Output) (band tf.Output) { - if scope.Err() != nil { - return - } - opspec := tf.OpSpec{ - Type: "MatrixBandPart", - Input: []tf.Input{ - input, num_lower, num_upper, - }, - } - op := scope.AddOperation(opspec) - return op.Output(0) -} - // Returns the batched diagonal part of a batched tensor. // // This operation returns a tensor with the `diagonal` part @@ -12594,6 +12530,65 @@ func ResourceSparseApplyAdagrad(scope *Scope, var_ tf.Output, accum tf.Output, l return scope.AddOperation(opspec) } +// Elementwise computes the bitwise right-shift of `x` and `y`. +// +// Performs a logical shift for unsigned integer types, and an arithmetic shift +// for signed integer types. +// +// If `y` is negative, or greater than or equal to than the width of `x` in bits +// the result is implementation defined. +func RightShift(scope *Scope, x tf.Output, y tf.Output) (z tf.Output) { + if scope.Err() != nil { + return + } + opspec := tf.OpSpec{ + Type: "RightShift", + Input: []tf.Input{ + x, y, + }, + } + op := scope.AddOperation(opspec) + return op.Output(0) +} + +// TensorListStackAttr is an optional argument to TensorListStack. +type TensorListStackAttr func(optionalAttr) + +// TensorListStackNumElements sets the optional num_elements attribute to value. +// If not specified, defaults to -1 +func TensorListStackNumElements(value int64) TensorListStackAttr { + return func(m optionalAttr) { + m["num_elements"] = value + } +} + +// Stacks all tensors in the list. +// +// Requires that all tensors have the same shape. +// +// input_handle: the input list +// tensor: the gathered result +// num_elements: optional. If not -1, the number of elements in the list. +// +func TensorListStack(scope *Scope, input_handle tf.Output, element_dtype tf.DataType, optional ...TensorListStackAttr) (tensor tf.Output) { + if scope.Err() != nil { + return + } + attrs := map[string]interface{}{"element_dtype": element_dtype} + for _, a := range optional { + a(attrs) + } + opspec := tf.OpSpec{ + Type: "TensorListStack", + Input: []tf.Input{ + input_handle, + }, + Attrs: attrs, + } + op := scope.AddOperation(opspec) + return op.Output(0) +} + // StatelessRandomUniformAttr is an optional argument to StatelessRandomUniform. type StatelessRandomUniformAttr func(optionalAttr) @@ -19393,6 +19388,70 @@ func LogMatrixDeterminant(scope *Scope, input tf.Output) (sign tf.Output, log_ab return op.Output(0), op.Output(1) } +// Copy a tensor setting everything outside a central band in each innermost matrix +// +// to zero. +// +// The `band` part is computed as follows: +// Assume `input` has `k` dimensions `[I, J, K, ..., M, N]`, then the output is a +// tensor with the same shape where +// +// `band[i, j, k, ..., m, n] = in_band(m, n) * input[i, j, k, ..., m, n]`. +// +// The indicator function +// +// `in_band(m, n) = (num_lower < 0 || (m-n) <= num_lower)) && +// (num_upper < 0 || (n-m) <= num_upper)`. +// +// For example: +// +// ``` +// # if 'input' is [[ 0, 1, 2, 3] +// [-1, 0, 1, 2] +// [-2, -1, 0, 1] +// [-3, -2, -1, 0]], +// +// tf.matrix_band_part(input, 1, -1) ==> [[ 0, 1, 2, 3] +// [-1, 0, 1, 2] +// [ 0, -1, 0, 1] +// [ 0, 0, -1, 0]], +// +// tf.matrix_band_part(input, 2, 1) ==> [[ 0, 1, 0, 0] +// [-1, 0, 1, 0] +// [-2, -1, 0, 1] +// [ 0, -2, -1, 0]] +// ``` +// +// Useful special cases: +// +// ``` +// tf.matrix_band_part(input, 0, -1) ==> Upper triangular part. +// tf.matrix_band_part(input, -1, 0) ==> Lower triangular part. +// tf.matrix_band_part(input, 0, 0) ==> Diagonal. +// ``` +// +// Arguments: +// input: Rank `k` tensor. +// num_lower: 0-D tensor. Number of subdiagonals to keep. If negative, keep entire +// lower triangle. +// num_upper: 0-D tensor. Number of superdiagonals to keep. If negative, keep +// entire upper triangle. +// +// Returns Rank `k` tensor of the same shape as input. The extracted banded tensor. +func MatrixBandPart(scope *Scope, input tf.Output, num_lower tf.Output, num_upper tf.Output) (band tf.Output) { + if scope.Err() != nil { + return + } + opspec := tf.OpSpec{ + Type: "MatrixBandPart", + Input: []tf.Input{ + input, num_lower, num_upper, + }, + } + op := scope.AddOperation(opspec) + return op.Output(0) +} + // SumAttr is an optional argument to Sum. type SumAttr func(optionalAttr) @@ -31857,62 +31916,3 @@ func LeftShift(scope *Scope, x tf.Output, y tf.Output) (z tf.Output) { op := scope.AddOperation(opspec) return op.Output(0) } - -// TensorListStackAttr is an optional argument to TensorListStack. -type TensorListStackAttr func(optionalAttr) - -// TensorListStackNumElements sets the optional num_elements attribute to value. -// If not specified, defaults to -1 -func TensorListStackNumElements(value int64) TensorListStackAttr { - return func(m optionalAttr) { - m["num_elements"] = value - } -} - -// Stacks all tensors in the list. -// -// Requires that all tensors have the same shape. -// -// input_handle: the input list -// tensor: the gathered result -// num_elements: optional. If not -1, the number of elements in the list. -// -func TensorListStack(scope *Scope, input_handle tf.Output, element_dtype tf.DataType, optional ...TensorListStackAttr) (tensor tf.Output) { - if scope.Err() != nil { - return - } - attrs := map[string]interface{}{"element_dtype": element_dtype} - for _, a := range optional { - a(attrs) - } - opspec := tf.OpSpec{ - Type: "TensorListStack", - Input: []tf.Input{ - input_handle, - }, - Attrs: attrs, - } - op := scope.AddOperation(opspec) - return op.Output(0) -} - -// Elementwise computes the bitwise right-shift of `x` and `y`. -// -// Performs a logical shift for unsigned integer types, and an arithmetic shift -// for signed integer types. -// -// If `y` is negative, or greater than or equal to than the width of `x` in bits -// the result is implementation defined. -func RightShift(scope *Scope, x tf.Output, y tf.Output) (z tf.Output) { - if scope.Err() != nil { - return - } - opspec := tf.OpSpec{ - Type: "RightShift", - Input: []tf.Input{ - x, y, - }, - } - op := scope.AddOperation(opspec) - return op.Output(0) -} -- GitLab From 3d1661826ec668d717122a88463ab9b1c1e6f7ae Mon Sep 17 00:00:00 2001 From: Anna R Date: Wed, 8 Aug 2018 14:26:37 -0700 Subject: [PATCH 220/437] Internal change. PiperOrigin-RevId: 207945991 --- tensorflow/contrib/lite/delegates/nnapi/BUILD | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tensorflow/contrib/lite/delegates/nnapi/BUILD b/tensorflow/contrib/lite/delegates/nnapi/BUILD index 091f8fbce7..954955f24b 100644 --- a/tensorflow/contrib/lite/delegates/nnapi/BUILD +++ b/tensorflow/contrib/lite/delegates/nnapi/BUILD @@ -22,7 +22,10 @@ tf_cc_test( name = "nnapi_delegate_test", size = "small", srcs = ["nnapi_delegate_test.cc"], - tags = ["no_oss"], + tags = [ + "no_oss", + "noasan", # TODO(b/112326936): re-enable for asan once fixed. + ], deps = [ ":nnapi_delegate", "//tensorflow/contrib/lite:framework", -- GitLab From 2b4fd1c2b7a37367e61bbae3d27d194a894cb7bb Mon Sep 17 00:00:00 2001 From: Suyog Gupta Date: Wed, 8 Aug 2018 14:30:30 -0700 Subject: [PATCH 221/437] Add helper function for validating the user-provided pruning hparams PiperOrigin-RevId: 207946581 --- tensorflow/contrib/model_pruning/README.md | 2 +- .../contrib/model_pruning/python/pruning.py | 36 ++++++++++++++++--- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/tensorflow/contrib/model_pruning/README.md b/tensorflow/contrib/model_pruning/README.md index 0761dea900..a5267fd904 100644 --- a/tensorflow/contrib/model_pruning/README.md +++ b/tensorflow/contrib/model_pruning/README.md @@ -5,7 +5,7 @@ neural network's weight tensors. The API helps inject necessary tensorflow op into the training graph so the model can be pruned while it is being trained. ## Table of contents -1. [Model creation](# model-creation) +1. [Model creation](#model-creation) 2. [Hyperparameters for pruning](#hyperparameters) - [Block sparsity](#block-sparsity) 3. [Adding pruning ops to the training graph](#adding-pruning-ops) diff --git a/tensorflow/contrib/model_pruning/python/pruning.py b/tensorflow/contrib/model_pruning/python/pruning.py index 723dab9369..cd58526ed3 100644 --- a/tensorflow/contrib/model_pruning/python/pruning.py +++ b/tensorflow/contrib/model_pruning/python/pruning.py @@ -237,6 +237,9 @@ class Pruning(object): # Pruning specification self._spec = spec if spec else get_pruning_hparams() + # Sanity check for pruning hparams + self._validate_spec() + # A tensorflow variable that tracks the sparsity function. # If not provided as input, the graph must already contain the global_step # variable before calling this constructor. @@ -262,6 +265,34 @@ class Pruning(object): # Mapping of weight names and target sparsity self._weight_sparsity_map = self._get_weight_sparsity_map() + def _validate_spec(self): + spec = self._spec + if spec.begin_pruning_step < 0: + raise ValueError('Illegal value for begin_pruning_step') + + if spec.begin_pruning_step >= spec.end_pruning_step: + if spec.end_pruning_step != -1: + raise ValueError( + 'Pruning must begin before it can end. begin_step=%d, end_step=%d.' + 'Set end_pruning_step to -1 if pruning is required till training' + 'stops' % (spec.begin_pruning_step, spec.end_pruning_step)) + + if spec.sparsity_function_begin_step < 0: + raise ValueError('Illegal value for sparsity_function_begin_step') + + if spec.sparsity_function_begin_step >= spec.sparsity_function_end_step: + raise ValueError( + 'Sparsity function requires begin_step < end_step') + + if not 0.0 <= spec.threshold_decay < 1.0: + raise ValueError('threshold_decay must be in range [0,1)') + + if not 0.0 <= spec.initial_sparsity < 1.0: + raise ValueError('initial_sparsity must be in range [0,1)') + + if not 0.0 <= spec.target_sparsity < 1.0: + raise ValueError('target_sparsity must be in range [0,1)') + def _setup_global_step(self, global_step): graph_global_step = global_step if graph_global_step is None: @@ -276,11 +307,6 @@ class Pruning(object): target_sparsity = self._spec.target_sparsity exponent = self._spec.sparsity_function_exponent - if begin_step >= end_step: - raise ValueError( - 'Pruning must begin before it can end. begin_step=%d, end_step=%d' % - (begin_step, end_step)) - with ops.name_scope(self._spec.name): p = math_ops.minimum( 1.0, -- GitLab From 8f283eaa394147437bb85aa81b375cc37cb9fab4 Mon Sep 17 00:00:00 2001 From: Akshay Modi Date: Wed, 8 Aug 2018 15:00:02 -0700 Subject: [PATCH 222/437] Make eager's RunMetadata marginally more useful by including the correct duration. When generating the trace using tensorflow/python/client/timeline.py, all_end_rel_micros is used instead of op_end_rel_micros: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/client/timeline.py#L426 PiperOrigin-RevId: 207951399 --- tensorflow/core/common_runtime/eager/execute.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tensorflow/core/common_runtime/eager/execute.cc b/tensorflow/core/common_runtime/eager/execute.cc index 51b770d035..8eaa6e4429 100644 --- a/tensorflow/core/common_runtime/eager/execute.cc +++ b/tensorflow/core/common_runtime/eager/execute.cc @@ -148,6 +148,9 @@ Status MaybeCopyInputToExpectedDevice(EagerOperation* op, int i, node_stats->set_op_end_rel_micros((now_nanos - pre_time_nanos) / EnvTime::kMicrosToNanos); node_stats->set_op_end_rel_nanos(now_nanos - pre_time_nanos); + node_stats->set_all_end_rel_micros((now_nanos - pre_time_nanos) / + EnvTime::kMicrosToNanos); + node_stats->set_all_end_rel_nanos(now_nanos - pre_time_nanos); } if (!status.ok()) { if (result_handle != nullptr) result_handle->Unref(); @@ -664,6 +667,9 @@ Status EagerExecute(EagerContext* ctx, Device* device, maybe_stats->set_op_end_rel_micros(nanos / EnvTime::kMicrosToNanos - maybe_stats->all_start_micros()); maybe_stats->set_op_end_rel_nanos(nanos - maybe_stats->all_start_nanos()); + maybe_stats->set_all_end_rel_micros(nanos / EnvTime::kMicrosToNanos - + maybe_stats->all_start_micros()); + maybe_stats->set_all_end_rel_nanos(nanos - maybe_stats->all_start_nanos()); mutex_lock ml(*ctx->MetadataMu()); if (ctx->ShouldStoreMetadata()) { auto* step_stats = ctx->RunMetadataProto()->mutable_step_stats(); -- GitLab From 60bb01f1a7871958646669863a289960231be374 Mon Sep 17 00:00:00 2001 From: Francois Chollet Date: Wed, 8 Aug 2018 15:12:17 -0700 Subject: [PATCH 223/437] Make tf.keras rely on external keras_applications and keras_preprocessing modules. PiperOrigin-RevId: 207953769 --- .../api/keras/preprocessing/image/__init__.py | 2 - tensorflow/python/keras/BUILD | 1 + .../python/keras/applications/__init__.py | 18 +- .../python/keras/applications/densenet.py | 345 +--- .../keras/applications/imagenet_utils.py | 340 +--- .../keras/applications/imagenet_utils_test.py | 106 -- .../keras/applications/inception_resnet_v2.py | 368 +--- .../python/keras/applications/inception_v3.py | 399 +--- .../python/keras/applications/mobilenet.py | 461 +---- .../keras/applications/mobilenet_test.py | 30 - .../python/keras/applications/mobilenet_v2.py | 32 + .../python/keras/applications/nasnet.py | 781 +------- .../python/keras/applications/resnet50.py | 285 +-- tensorflow/python/keras/applications/vgg16.py | 211 +-- tensorflow/python/keras/applications/vgg19.py | 220 +-- .../python/keras/applications/xception.py | 327 +--- .../python/keras/preprocessing/__init__.py | 8 + .../python/keras/preprocessing/image.py | 1620 +---------------- .../python/keras/preprocessing/image_test.py | 3 - .../python/keras/preprocessing/sequence.py | 388 +--- tensorflow/python/keras/preprocessing/text.py | 383 +--- tensorflow/python/keras/utils/__init__.py | 1 + .../tools/api/generator/api_init_files.bzl | 1 + .../tools/api/generator/api_init_files_v1.bzl | 1 + ...nsorflow.keras.applications.densenet.pbtxt | 23 - ...ras.applications.inception_resnet_v2.pbtxt | 15 - ...flow.keras.applications.inception_v3.pbtxt | 15 - ...sorflow.keras.applications.mobilenet.pbtxt | 15 - ...tensorflow.keras.applications.nasnet.pbtxt | 19 - .../v1/tensorflow.keras.applications.pbtxt | 87 - ...nsorflow.keras.applications.resnet50.pbtxt | 15 - .../tensorflow.keras.applications.vgg16.pbtxt | 15 - .../tensorflow.keras.applications.vgg19.pbtxt | 15 - ...nsorflow.keras.applications.xception.pbtxt | 15 - ...processing.image.-directory-iterator.pbtxt | 23 - ...ocessing.image.-image-data-generator.pbtxt | 29 - ....keras.preprocessing.image.-iterator.pbtxt | 18 - ...ocessing.image.-numpy-array-iterator.pbtxt | 23 - ...tensorflow.keras.preprocessing.image.pbtxt | 63 - .../v1/tensorflow.keras.preprocessing.pbtxt | 15 - ...ssing.sequence.-timeseries-generator.pbtxt | 14 - ...sorflow.keras.preprocessing.sequence.pbtxt | 19 - ....keras.preprocessing.text.-tokenizer.pbtxt | 33 - .../tensorflow.keras.preprocessing.text.pbtxt | 19 - tensorflow/tools/ci_build/Dockerfile.cmake | 4 +- .../ci_build/install/install_pip_packages.sh | 8 +- .../install/install_python3.5_pip_packages.sh | 4 +- .../install/install_python3.6_pip_packages.sh | 4 +- tensorflow/tools/common/public_api.py | 2 + tensorflow/tools/pip_package/setup.py | 2 + 50 files changed, 240 insertions(+), 6605 deletions(-) create mode 100644 tensorflow/python/keras/applications/mobilenet_v2.py delete mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.applications.densenet.pbtxt delete mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.applications.inception_resnet_v2.pbtxt delete mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.applications.inception_v3.pbtxt delete mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.applications.mobilenet.pbtxt delete mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.applications.nasnet.pbtxt delete mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.applications.pbtxt delete mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.applications.resnet50.pbtxt delete mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.applications.vgg16.pbtxt delete mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.applications.vgg19.pbtxt delete mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.applications.xception.pbtxt delete mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-directory-iterator.pbtxt delete mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-image-data-generator.pbtxt delete mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-iterator.pbtxt delete mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-numpy-array-iterator.pbtxt delete mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.pbtxt delete mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.pbtxt delete mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.sequence.-timeseries-generator.pbtxt delete mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.sequence.pbtxt delete mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.text.-tokenizer.pbtxt delete mode 100644 tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.text.pbtxt diff --git a/tensorflow/contrib/keras/api/keras/preprocessing/image/__init__.py b/tensorflow/contrib/keras/api/keras/preprocessing/image/__init__.py index 1f9e82b41b..cb649a3751 100644 --- a/tensorflow/contrib/keras/api/keras/preprocessing/image/__init__.py +++ b/tensorflow/contrib/keras/api/keras/preprocessing/image/__init__.py @@ -18,10 +18,8 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -from tensorflow.python.keras.preprocessing.image import apply_transform from tensorflow.python.keras.preprocessing.image import array_to_img from tensorflow.python.keras.preprocessing.image import DirectoryIterator -from tensorflow.python.keras.preprocessing.image import flip_axis from tensorflow.python.keras.preprocessing.image import ImageDataGenerator from tensorflow.python.keras.preprocessing.image import img_to_array from tensorflow.python.keras.preprocessing.image import Iterator diff --git a/tensorflow/python/keras/BUILD b/tensorflow/python/keras/BUILD index 446cf6355a..e04d0e93e2 100755 --- a/tensorflow/python/keras/BUILD +++ b/tensorflow/python/keras/BUILD @@ -25,6 +25,7 @@ py_library( "applications/inception_resnet_v2.py", "applications/inception_v3.py", "applications/mobilenet.py", + "applications/mobilenet_v2.py", "applications/nasnet.py", "applications/resnet50.py", "applications/vgg16.py", diff --git a/tensorflow/python/keras/applications/__init__.py b/tensorflow/python/keras/applications/__init__.py index 062135266d..51cc51998c 100644 --- a/tensorflow/python/keras/applications/__init__.py +++ b/tensorflow/python/keras/applications/__init__.py @@ -13,17 +13,33 @@ # limitations under the License. # ============================================================================== """Keras Applications are canned architectures with pre-trained weights.""" - +# pylint: disable=g-import-not-at-top from __future__ import absolute_import from __future__ import division from __future__ import print_function +import keras_applications + +from tensorflow.python.keras import backend +from tensorflow.python.keras import engine +from tensorflow.python.keras import layers +from tensorflow.python.keras import models +from tensorflow.python.keras import utils + +keras_applications.set_keras_submodules( + backend=backend, + engine=engine, + layers=layers, + models=models, + utils=utils) + from tensorflow.python.keras.applications.densenet import DenseNet121 from tensorflow.python.keras.applications.densenet import DenseNet169 from tensorflow.python.keras.applications.densenet import DenseNet201 from tensorflow.python.keras.applications.inception_resnet_v2 import InceptionResNetV2 from tensorflow.python.keras.applications.inception_v3 import InceptionV3 from tensorflow.python.keras.applications.mobilenet import MobileNet +from tensorflow.python.keras.applications.mobilenet_v2 import MobileNetV2 from tensorflow.python.keras.applications.nasnet import NASNetLarge from tensorflow.python.keras.applications.nasnet import NASNetMobile from tensorflow.python.keras.applications.resnet50 import ResNet50 diff --git a/tensorflow/python/keras/applications/densenet.py b/tensorflow/python/keras/applications/densenet.py index 8df6d08611..fbdcc66d2d 100644 --- a/tensorflow/python/keras/applications/densenet.py +++ b/tensorflow/python/keras/applications/densenet.py @@ -13,342 +13,25 @@ # limitations under the License. # ============================================================================== # pylint: disable=invalid-name -# pylint: disable=unused-import """DenseNet models for Keras. - -# Reference paper - -- [Densely Connected Convolutional Networks] - (https://arxiv.org/abs/1608.06993) (CVPR 2017 Best Paper Award) """ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os - -from tensorflow.python.keras import backend as K -from tensorflow.python.keras.applications import imagenet_utils -from tensorflow.python.keras.applications.imagenet_utils import _obtain_input_shape -from tensorflow.python.keras.applications.imagenet_utils import decode_predictions -from tensorflow.python.keras.layers import Activation -from tensorflow.python.keras.layers import AveragePooling2D -from tensorflow.python.keras.layers import BatchNormalization -from tensorflow.python.keras.layers import Concatenate -from tensorflow.python.keras.layers import Conv2D -from tensorflow.python.keras.layers import Dense -from tensorflow.python.keras.layers import GlobalAveragePooling2D -from tensorflow.python.keras.layers import GlobalMaxPooling2D -from tensorflow.python.keras.layers import Input -from tensorflow.python.keras.layers import MaxPooling2D -from tensorflow.python.keras.layers import ZeroPadding2D -from tensorflow.python.keras.models import Model -from tensorflow.python.keras.utils import layer_utils -from tensorflow.python.keras.utils.data_utils import get_file +from keras_applications import densenet from tensorflow.python.util.tf_export import tf_export - -DENSENET121_WEIGHT_PATH = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.8/densenet121_weights_tf_dim_ordering_tf_kernels.h5' -DENSENET121_WEIGHT_PATH_NO_TOP = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.8/densenet121_weights_tf_dim_ordering_tf_kernels_notop.h5' -DENSENET169_WEIGHT_PATH = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.8/densenet169_weights_tf_dim_ordering_tf_kernels.h5' -DENSENET169_WEIGHT_PATH_NO_TOP = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.8/densenet169_weights_tf_dim_ordering_tf_kernels_notop.h5' -DENSENET201_WEIGHT_PATH = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.8/densenet201_weights_tf_dim_ordering_tf_kernels.h5' -DENSENET201_WEIGHT_PATH_NO_TOP = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.8/densenet201_weights_tf_dim_ordering_tf_kernels_notop.h5' - - -def dense_block(x, blocks, name): - """A dense block. - - Arguments: - x: input tensor. - blocks: integer, the number of building blocks. - name: string, block label. - - Returns: - output tensor for the block. - """ - for i in range(blocks): - x = conv_block(x, 32, name=name + '_block' + str(i + 1)) - return x - - -def transition_block(x, reduction, name): - """A transition block. - - Arguments: - x: input tensor. - reduction: float, compression rate at transition layers. - name: string, block label. - - Returns: - output tensor for the block. - """ - bn_axis = 3 if K.image_data_format() == 'channels_last' else 1 - x = BatchNormalization(axis=bn_axis, epsilon=1.001e-5, name=name + '_bn')(x) - x = Activation('relu', name=name + '_relu')(x) - x = Conv2D( - int(K.int_shape(x)[bn_axis] * reduction), - 1, - use_bias=False, - name=name + '_conv')( - x) - x = AveragePooling2D(2, strides=2, name=name + '_pool')(x) - return x - - -def conv_block(x, growth_rate, name): - """A building block for a dense block. - - Arguments: - x: input tensor. - growth_rate: float, growth rate at dense layers. - name: string, block label. - - Returns: - output tensor for the block. - """ - bn_axis = 3 if K.image_data_format() == 'channels_last' else 1 - x1 = BatchNormalization( - axis=bn_axis, epsilon=1.001e-5, name=name + '_0_bn')( - x) - x1 = Activation('relu', name=name + '_0_relu')(x1) - x1 = Conv2D(4 * growth_rate, 1, use_bias=False, name=name + '_1_conv')(x1) - x1 = BatchNormalization( - axis=bn_axis, epsilon=1.001e-5, name=name + '_1_bn')( - x1) - x1 = Activation('relu', name=name + '_1_relu')(x1) - x1 = Conv2D( - growth_rate, 3, padding='same', use_bias=False, name=name + '_2_conv')( - x1) - x = Concatenate(axis=bn_axis, name=name + '_concat')([x, x1]) - return x - - -def DenseNet(blocks, - include_top=True, - weights='imagenet', - input_tensor=None, - input_shape=None, - pooling=None, - classes=1000): - """Instantiates the DenseNet architecture. - - Optionally loads weights pre-trained - on ImageNet. Note that when using TensorFlow, - for best performance you should set - `image_data_format='channels_last'` in your Keras config - at ~/.keras/keras.json. - - The model and the weights are compatible with - TensorFlow, Theano, and CNTK. The data format - convention used by the model is the one - specified in your Keras config file. - - Arguments: - blocks: numbers of building blocks for the four dense layers. - include_top: whether to include the fully-connected - layer at the top of the network. - weights: one of `None` (random initialization), - 'imagenet' (pre-training on ImageNet), - or the path to the weights file to be loaded. - input_tensor: optional Keras tensor (i.e. output of `layers.Input()`) - to use as image input for the model. - input_shape: optional shape tuple, only to be specified - if `include_top` is False (otherwise the input shape - has to be `(224, 224, 3)` (with `channels_last` data format) - or `(3, 224, 224)` (with `channels_first` data format). - It should have exactly 3 inputs channels. - pooling: optional pooling mode for feature extraction - when `include_top` is `False`. - - `None` means that the output of the model will be - the 4D tensor output of the - last convolutional layer. - - `avg` means that global average pooling - will be applied to the output of the - last convolutional layer, and thus - the output of the model will be a 2D tensor. - - `max` means that global max pooling will - be applied. - classes: optional number of classes to classify images - into, only to be specified if `include_top` is True, and - if no `weights` argument is specified. - - Returns: - A Keras model instance. - - Raises: - ValueError: in case of invalid argument for `weights`, - or invalid input shape. - """ - if not (weights in {'imagenet', None} or os.path.exists(weights)): - raise ValueError('The `weights` argument should be either ' - '`None` (random initialization), `imagenet` ' - '(pre-training on ImageNet), ' - 'or the path to the weights file to be loaded.') - - if weights == 'imagenet' and include_top and classes != 1000: - raise ValueError('If using `weights` as imagenet with `include_top`' - ' as true, `classes` should be 1000') - - # Determine proper input shape - input_shape = _obtain_input_shape( - input_shape, - default_size=224, - min_size=221, - data_format=K.image_data_format(), - require_flatten=include_top, - weights=weights) - - if input_tensor is None: - img_input = Input(shape=input_shape) - else: - if not K.is_keras_tensor(input_tensor): - img_input = Input(tensor=input_tensor, shape=input_shape) - else: - img_input = input_tensor - - bn_axis = 3 if K.image_data_format() == 'channels_last' else 1 - - x = ZeroPadding2D(padding=((3, 3), (3, 3)))(img_input) - x = Conv2D(64, 7, strides=2, use_bias=False, name='conv1/conv')(x) - x = BatchNormalization(axis=bn_axis, epsilon=1.001e-5, name='conv1/bn')(x) - x = Activation('relu', name='conv1/relu')(x) - x = ZeroPadding2D(padding=((1, 1), (1, 1)))(x) - x = MaxPooling2D(3, strides=2, name='pool1')(x) - - x = dense_block(x, blocks[0], name='conv2') - x = transition_block(x, 0.5, name='pool2') - x = dense_block(x, blocks[1], name='conv3') - x = transition_block(x, 0.5, name='pool3') - x = dense_block(x, blocks[2], name='conv4') - x = transition_block(x, 0.5, name='pool4') - x = dense_block(x, blocks[3], name='conv5') - - x = BatchNormalization(axis=bn_axis, epsilon=1.001e-5, name='bn')(x) - - if include_top: - x = GlobalAveragePooling2D(name='avg_pool')(x) - x = Dense(classes, activation='softmax', name='fc1000')(x) - else: - if pooling == 'avg': - x = GlobalAveragePooling2D(name='avg_pool')(x) - elif pooling == 'max': - x = GlobalMaxPooling2D(name='max_pool')(x) - - # Ensure that the model takes into account - # any potential predecessors of `input_tensor`. - if input_tensor is not None: - inputs = layer_utils.get_source_inputs(input_tensor) - else: - inputs = img_input - - # Create model. - if blocks == [6, 12, 24, 16]: - model = Model(inputs, x, name='densenet121') - elif blocks == [6, 12, 32, 32]: - model = Model(inputs, x, name='densenet169') - elif blocks == [6, 12, 48, 32]: - model = Model(inputs, x, name='densenet201') - else: - model = Model(inputs, x, name='densenet') - - # Load weights. - if weights == 'imagenet': - if include_top: - if blocks == [6, 12, 24, 16]: - weights_path = get_file( - 'densenet121_weights_tf_dim_ordering_tf_kernels.h5', - DENSENET121_WEIGHT_PATH, - cache_subdir='models', - file_hash='0962ca643bae20f9b6771cb844dca3b0') - elif blocks == [6, 12, 32, 32]: - weights_path = get_file( - 'densenet169_weights_tf_dim_ordering_tf_kernels.h5', - DENSENET169_WEIGHT_PATH, - cache_subdir='models', - file_hash='bcf9965cf5064a5f9eb6d7dc69386f43') - elif blocks == [6, 12, 48, 32]: - weights_path = get_file( - 'densenet201_weights_tf_dim_ordering_tf_kernels.h5', - DENSENET201_WEIGHT_PATH, - cache_subdir='models', - file_hash='7bb75edd58cb43163be7e0005fbe95ef') - else: - if blocks == [6, 12, 24, 16]: - weights_path = get_file( - 'densenet121_weights_tf_dim_ordering_tf_kernels_notop.h5', - DENSENET121_WEIGHT_PATH_NO_TOP, - cache_subdir='models', - file_hash='4912a53fbd2a69346e7f2c0b5ec8c6d3') - elif blocks == [6, 12, 32, 32]: - weights_path = get_file( - 'densenet169_weights_tf_dim_ordering_tf_kernels_notop.h5', - DENSENET169_WEIGHT_PATH_NO_TOP, - cache_subdir='models', - file_hash='50662582284e4cf834ce40ab4dfa58c6') - elif blocks == [6, 12, 48, 32]: - weights_path = get_file( - 'densenet201_weights_tf_dim_ordering_tf_kernels_notop.h5', - DENSENET201_WEIGHT_PATH_NO_TOP, - cache_subdir='models', - file_hash='1c2de60ee40562448dbac34a0737e798') - model.load_weights(weights_path) - elif weights is not None: - model.load_weights(weights) - - return model - - -@tf_export('keras.applications.DenseNet121', - 'keras.applications.densenet.DenseNet121') -def DenseNet121(include_top=True, - weights='imagenet', - input_tensor=None, - input_shape=None, - pooling=None, - classes=1000): - return DenseNet([6, 12, 24, 16], include_top, weights, input_tensor, - input_shape, pooling, classes) - - -@tf_export('keras.applications.DenseNet169', - 'keras.applications.densenet.DenseNet169') -def DenseNet169(include_top=True, - weights='imagenet', - input_tensor=None, - input_shape=None, - pooling=None, - classes=1000): - return DenseNet([6, 12, 32, 32], include_top, weights, input_tensor, - input_shape, pooling, classes) - - -@tf_export('keras.applications.DenseNet201', - 'keras.applications.densenet.DenseNet201') -def DenseNet201(include_top=True, - weights='imagenet', - input_tensor=None, - input_shape=None, - pooling=None, - classes=1000): - return DenseNet([6, 12, 48, 32], include_top, weights, input_tensor, - input_shape, pooling, classes) - - -@tf_export('keras.applications.densenet.preprocess_input') -def preprocess_input(x, data_format=None): - """Preprocesses a numpy array encoding a batch of images. - - Arguments: - x: a 3D or 4D numpy array consists of RGB values within [0, 255]. - data_format: data format of the image tensor. - - Returns: - Preprocessed array. - """ - return imagenet_utils.preprocess_input(x, data_format, mode='torch') - - -setattr(DenseNet121, '__doc__', DenseNet.__doc__) -setattr(DenseNet169, '__doc__', DenseNet.__doc__) -setattr(DenseNet201, '__doc__', DenseNet.__doc__) +DenseNet121 = densenet.DenseNet121 +DenseNet169 = densenet.DenseNet169 +DenseNet201 = densenet.DenseNet201 +decode_predictions = densenet.decode_predictions +preprocess_input = densenet.preprocess_input + +tf_export('keras.applications.densenet.DenseNet121', + 'keras.applications.DenseNet121')(DenseNet121) +tf_export('keras.applications.densenet.DenseNet169', + 'keras.applications.DenseNet169')(DenseNet169) +tf_export('keras.applications.densenet.DenseNet201', + 'keras.applications.DenseNet201')(DenseNet201) +tf_export('keras.applications.densenet.preprocess_input')(preprocess_input) diff --git a/tensorflow/python/keras/applications/imagenet_utils.py b/tensorflow/python/keras/applications/imagenet_utils.py index 0d8ccca1b5..70f8f6fb32 100644 --- a/tensorflow/python/keras/applications/imagenet_utils.py +++ b/tensorflow/python/keras/applications/imagenet_utils.py @@ -18,322 +18,28 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import json - -import numpy as np - -from tensorflow.python.framework import constant_op -from tensorflow.python.keras import backend as K -from tensorflow.python.keras.utils.data_utils import get_file -from tensorflow.python.ops import math_ops -from tensorflow.python.platform import tf_logging as logging +from keras_applications import imagenet_utils from tensorflow.python.util.tf_export import tf_export - -CLASS_INDEX = None -CLASS_INDEX_PATH = 'https://s3.amazonaws.com/deep-learning-models/image-models/imagenet_class_index.json' - -# Global tensor of imagenet mean for preprocessing symbolic inputs -_IMAGENET_MEAN = None - - -def _preprocess_numpy_input(x, data_format, mode): - """Preprocesses a Numpy array encoding a batch of images. - - Arguments: - x: Input array, 3D or 4D. - data_format: Data format of the image array. - mode: One of "caffe", "tf" or "torch". - - caffe: will convert the images from RGB to BGR, - then will zero-center each color channel with - respect to the ImageNet dataset, - without scaling. - - tf: will scale pixels between -1 and 1, - sample-wise. - - torch: will scale pixels between 0 and 1 and then - will normalize each channel with respect to the - ImageNet dataset. - - Returns: - Preprocessed Numpy array. - """ - if mode == 'tf': - x /= 127.5 - x -= 1. - return x - - if mode == 'torch': - x /= 255. - mean = [0.485, 0.456, 0.406] - std = [0.229, 0.224, 0.225] - else: - if data_format == 'channels_first': - # 'RGB'->'BGR' - if x.ndim == 3: - x = x[::-1, ...] - else: - x = x[:, ::-1, ...] - else: - # 'RGB'->'BGR' - x = x[..., ::-1] - mean = [103.939, 116.779, 123.68] - std = None - - # Zero-center by mean pixel - if data_format == 'channels_first': - if x.ndim == 3: - x[0, :, :] -= mean[0] - x[1, :, :] -= mean[1] - x[2, :, :] -= mean[2] - if std is not None: - x[0, :, :] /= std[0] - x[1, :, :] /= std[1] - x[2, :, :] /= std[2] - else: - x[:, 0, :, :] -= mean[0] - x[:, 1, :, :] -= mean[1] - x[:, 2, :, :] -= mean[2] - if std is not None: - x[:, 0, :, :] /= std[0] - x[:, 1, :, :] /= std[1] - x[:, 2, :, :] /= std[2] - else: - x[..., 0] -= mean[0] - x[..., 1] -= mean[1] - x[..., 2] -= mean[2] - if std is not None: - x[..., 0] /= std[0] - x[..., 1] /= std[1] - x[..., 2] /= std[2] - return x - - -def _preprocess_symbolic_input(x, data_format, mode): - """Preprocesses a tensor encoding a batch of images. - - Arguments: - x: Input tensor, 3D or 4D. - data_format: Data format of the image tensor. - mode: One of "caffe", "tf" or "torch". - - caffe: will convert the images from RGB to BGR, - then will zero-center each color channel with - respect to the ImageNet dataset, - without scaling. - - tf: will scale pixels between -1 and 1, - sample-wise. - - torch: will scale pixels between 0 and 1 and then - will normalize each channel with respect to the - ImageNet dataset. - - Returns: - Preprocessed tensor. - """ - global _IMAGENET_MEAN - - if mode == 'tf': - x /= 127.5 - x -= 1. - return x - - if mode == 'torch': - x /= 255. - mean = [0.485, 0.456, 0.406] - std = [0.229, 0.224, 0.225] - else: - if data_format == 'channels_first': - # 'RGB'->'BGR' - if K.ndim(x) == 3: - x = x[::-1, ...] - else: - x = x[:, ::-1, ...] - else: - # 'RGB'->'BGR' - x = x[..., ::-1] - mean = [103.939, 116.779, 123.68] - std = None - - if _IMAGENET_MEAN is None: - _IMAGENET_MEAN = constant_op.constant(-np.array(mean), dtype=K.floatx()) - - # Zero-center by mean pixel - if K.dtype(x) != K.dtype(_IMAGENET_MEAN): - x = K.bias_add(x, math_ops.cast(_IMAGENET_MEAN, K.dtype(x)), data_format) - else: - x = K.bias_add(x, _IMAGENET_MEAN, data_format) - if std is not None: - x /= std - return x - - -@tf_export('keras.applications.resnet50.preprocess_input', - 'keras.applications.vgg19.preprocess_input', - 'keras.applications.vgg16.preprocess_input') -def preprocess_input(x, data_format=None, mode='caffe'): - """Preprocesses a tensor or Numpy array encoding a batch of images. - - Arguments: - x: Input Numpy or symbolic tensor, 3D or 4D. - data_format: Data format of the image tensor/array. - mode: One of "caffe", "tf". - - caffe: will convert the images from RGB to BGR, - then will zero-center each color channel with - respect to the ImageNet dataset, - without scaling. - - tf: will scale pixels between -1 and 1, - sample-wise. - - Returns: - Preprocessed tensor or Numpy array. - - Raises: - ValueError: In case of unknown `data_format` argument. - """ - if data_format is None: - data_format = K.image_data_format() - if data_format not in {'channels_first', 'channels_last'}: - raise ValueError('Unknown data_format ' + str(data_format)) - - if isinstance(x, np.ndarray): - return _preprocess_numpy_input(x, data_format=data_format, mode=mode) - else: - return _preprocess_symbolic_input(x, data_format=data_format, mode=mode) - - -@tf_export('keras.applications.nasnet.decode_predictions', - 'keras.applications.resnet50.decode_predictions', - 'keras.applications.vgg19.decode_predictions', - 'keras.applications.vgg16.decode_predictions', - 'keras.applications.inception_resnet_v2.decode_predictions', - 'keras.applications.inception_v3.decode_predictions', - 'keras.applications.densenet.decode_predictions', - 'keras.applications.mobilenet.decode_predictions', - 'keras.applications.xception.decode_predictions') -def decode_predictions(preds, top=5): - """Decodes the prediction of an ImageNet model. - - Arguments: - preds: Numpy tensor encoding a batch of predictions. - top: Integer, how many top-guesses to return. - - Returns: - A list of lists of top class prediction tuples - `(class_name, class_description, score)`. - One list of tuples per sample in batch input. - - Raises: - ValueError: In case of invalid shape of the `pred` array - (must be 2D). - """ - global CLASS_INDEX - if len(preds.shape) != 2 or preds.shape[1] != 1000: - raise ValueError('`decode_predictions` expects ' - 'a batch of predictions ' - '(i.e. a 2D array of shape (samples, 1000)). ' - 'Found array with shape: ' + str(preds.shape)) - if CLASS_INDEX is None: - fpath = get_file( - 'imagenet_class_index.json', - CLASS_INDEX_PATH, - cache_subdir='models', - file_hash='c2c37ea517e94d9795004a39431a14cb') - with open(fpath) as f: - CLASS_INDEX = json.load(f) - results = [] - for pred in preds: - top_indices = pred.argsort()[-top:][::-1] - result = [tuple(CLASS_INDEX[str(i)]) + (pred[i],) for i in top_indices] - result.sort(key=lambda x: x[2], reverse=True) - results.append(result) - return results - - -def _obtain_input_shape(input_shape, - default_size, - min_size, - data_format, - require_flatten, - weights=None): - """Internal utility to compute/validate a model's input shape. - - Arguments: - input_shape: Either None (will return the default network input shape), - or a user-provided shape to be validated. - default_size: Default input width/height for the model. - min_size: Minimum input width/height accepted by the model. - data_format: Image data format to use. - require_flatten: Whether the model is expected to - be linked to a classifier via a Flatten layer. - weights: One of `None` (random initialization) - or 'imagenet' (pre-training on ImageNet). - If weights='imagenet' input channels must be equal to 3. - - Returns: - An integer shape tuple (may include None entries). - - Raises: - ValueError: In case of invalid argument values. - """ - if weights != 'imagenet' and input_shape and len(input_shape) == 3: - if data_format == 'channels_first': - if input_shape[0] not in {1, 3}: - logging.warning('This model usually expects 1 or 3 input channels. ' - 'However, it was passed an input_shape with ' + - str(input_shape[0]) + ' input channels.') - default_shape = (input_shape[0], default_size, default_size) - else: - if input_shape[-1] not in {1, 3}: - logging.warning('This model usually expects 1 or 3 input channels. ' - 'However, it was passed an input_shape with ' + - str(input_shape[-1]) + ' input channels.') - default_shape = (default_size, default_size, input_shape[-1]) - else: - if data_format == 'channels_first': - default_shape = (3, default_size, default_size) - else: - default_shape = (default_size, default_size, 3) - if weights == 'imagenet' and require_flatten: - if input_shape is not None: - if input_shape != default_shape: - raise ValueError('When setting`include_top=True` ' - 'and loading `imagenet` weights, ' - '`input_shape` should be ' + str(default_shape) + '.') - return default_shape - if input_shape: - if data_format == 'channels_first': - if input_shape is not None: - if len(input_shape) != 3: - raise ValueError('`input_shape` must be a tuple of three integers.') - if input_shape[0] != 3 and weights == 'imagenet': - raise ValueError('The input must have 3 channels; got ' - '`input_shape=' + str(input_shape) + '`') - if ((input_shape[1] is not None and input_shape[1] < min_size) or - (input_shape[2] is not None and input_shape[2] < min_size)): - raise ValueError('Input size must be at least ' + str(min_size) + - 'x' + str(min_size) + '; got ' - '`input_shape=' + str(input_shape) + '`') - else: - if input_shape is not None: - if len(input_shape) != 3: - raise ValueError('`input_shape` must be a tuple of three integers.') - if input_shape[-1] != 3 and weights == 'imagenet': - raise ValueError('The input must have 3 channels; got ' - '`input_shape=' + str(input_shape) + '`') - if ((input_shape[0] is not None and input_shape[0] < min_size) or - (input_shape[1] is not None and input_shape[1] < min_size)): - raise ValueError('Input size must be at least ' + str(min_size) + - 'x' + str(min_size) + '; got ' - '`input_shape=' + str(input_shape) + '`') - else: - if require_flatten: - input_shape = default_shape - else: - if data_format == 'channels_first': - input_shape = (3, None, None) - else: - input_shape = (None, None, 3) - if require_flatten: - if None in input_shape: - raise ValueError('If `include_top` is True, ' - 'you should specify a static `input_shape`. ' - 'Got `input_shape=' + str(input_shape) + '`') - return input_shape +decode_predictions = imagenet_utils.decode_predictions +preprocess_input = imagenet_utils.preprocess_input + +tf_export( + 'keras.applications.imagenet_utils.decode_predictions', + 'keras.applications.densenet.decode_predictions', + 'keras.applications.inception_resnet_v2.decode_predictions', + 'keras.applications.inception_v3.decode_predictions', + 'keras.applications.mobilenet.decode_predictions', + 'keras.applications.mobilenet_v2.decode_predictions', + 'keras.applications.nasnet.decode_predictions', + 'keras.applications.resnet50.decode_predictions', + 'keras.applications.vgg16.decode_predictions', + 'keras.applications.vgg19.decode_predictions', + 'keras.applications.xception.decode_predictions', +)(decode_predictions) +tf_export( + 'keras.applications.imagenet_utils.preprocess_input', + 'keras.applications.resnet50.preprocess_input', + 'keras.applications.vgg16.preprocess_input', + 'keras.applications.vgg19.preprocess_input', +)(preprocess_input) diff --git a/tensorflow/python/keras/applications/imagenet_utils_test.py b/tensorflow/python/keras/applications/imagenet_utils_test.py index 3493393090..037e939ac5 100644 --- a/tensorflow/python/keras/applications/imagenet_utils_test.py +++ b/tensorflow/python/keras/applications/imagenet_utils_test.py @@ -88,112 +88,6 @@ class ImageNetUtilsTest(test.TestCase): out2 = model2.predict(x2[np.newaxis])[0] self.assertAllClose(out1, out2.transpose(1, 2, 0)) - def test_obtain_input_shape(self): - # input_shape and default_size are not identical. - with self.assertRaises(ValueError): - keras.applications.imagenet_utils._obtain_input_shape( - input_shape=(224, 224, 3), - default_size=299, - min_size=139, - data_format='channels_last', - require_flatten=True, - weights='imagenet') - - # Test invalid use cases - for data_format in ['channels_last', 'channels_first']: - # input_shape is smaller than min_size. - shape = (100, 100) - if data_format == 'channels_last': - input_shape = shape + (3,) - else: - input_shape = (3,) + shape - with self.assertRaises(ValueError): - keras.applications.imagenet_utils._obtain_input_shape( - input_shape=input_shape, - default_size=None, - min_size=139, - data_format=data_format, - require_flatten=False) - - # shape is 1D. - shape = (100,) - if data_format == 'channels_last': - input_shape = shape + (3,) - else: - input_shape = (3,) + shape - with self.assertRaises(ValueError): - keras.applications.imagenet_utils._obtain_input_shape( - input_shape=input_shape, - default_size=None, - min_size=139, - data_format=data_format, - require_flatten=False) - - # the number of channels is 5 not 3. - shape = (100, 100) - if data_format == 'channels_last': - input_shape = shape + (5,) - else: - input_shape = (5,) + shape - with self.assertRaises(ValueError): - keras.applications.imagenet_utils._obtain_input_shape( - input_shape=input_shape, - default_size=None, - min_size=139, - data_format=data_format, - require_flatten=False) - - # require_flatten=True with dynamic input shape. - with self.assertRaises(ValueError): - keras.applications.imagenet_utils._obtain_input_shape( - input_shape=None, - default_size=None, - min_size=139, - data_format='channels_first', - require_flatten=True) - - assert keras.applications.imagenet_utils._obtain_input_shape( - input_shape=(3, 200, 200), - default_size=None, - min_size=139, - data_format='channels_first', - require_flatten=True) == (3, 200, 200) - - assert keras.applications.imagenet_utils._obtain_input_shape( - input_shape=None, - default_size=None, - min_size=139, - data_format='channels_last', - require_flatten=False) == (None, None, 3) - - assert keras.applications.imagenet_utils._obtain_input_shape( - input_shape=None, - default_size=None, - min_size=139, - data_format='channels_first', - require_flatten=False) == (3, None, None) - - assert keras.applications.imagenet_utils._obtain_input_shape( - input_shape=None, - default_size=None, - min_size=139, - data_format='channels_last', - require_flatten=False) == (None, None, 3) - - assert keras.applications.imagenet_utils._obtain_input_shape( - input_shape=(150, 150, 3), - default_size=None, - min_size=139, - data_format='channels_last', - require_flatten=False) == (150, 150, 3) - - assert keras.applications.imagenet_utils._obtain_input_shape( - input_shape=(3, None, None), - default_size=None, - min_size=139, - data_format='channels_first', - require_flatten=False) == (3, None, None) - if __name__ == '__main__': test.main() diff --git a/tensorflow/python/keras/applications/inception_resnet_v2.py b/tensorflow/python/keras/applications/inception_resnet_v2.py index 14e3b6aa60..63debb4e0d 100644 --- a/tensorflow/python/keras/applications/inception_resnet_v2.py +++ b/tensorflow/python/keras/applications/inception_resnet_v2.py @@ -13,372 +13,20 @@ # limitations under the License. # ============================================================================== # pylint: disable=invalid-name -# pylint: disable=unused-import """Inception-ResNet V2 model for Keras. - -# Reference -- [Inception-v4, Inception-ResNet and the Impact of - Residual Connections on Learning](https://arxiv.org/abs/1602.07261) - """ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os - -from tensorflow.python.keras import backend as K -from tensorflow.python.keras.applications import imagenet_utils -from tensorflow.python.keras.applications.imagenet_utils import _obtain_input_shape -from tensorflow.python.keras.applications.imagenet_utils import decode_predictions -from tensorflow.python.keras.layers import Activation -from tensorflow.python.keras.layers import AveragePooling2D -from tensorflow.python.keras.layers import BatchNormalization -from tensorflow.python.keras.layers import Concatenate -from tensorflow.python.keras.layers import Conv2D -from tensorflow.python.keras.layers import Dense -from tensorflow.python.keras.layers import GlobalAveragePooling2D -from tensorflow.python.keras.layers import GlobalMaxPooling2D -from tensorflow.python.keras.layers import Input -from tensorflow.python.keras.layers import Lambda -from tensorflow.python.keras.layers import MaxPooling2D -from tensorflow.python.keras.models import Model -from tensorflow.python.keras.utils import layer_utils -from tensorflow.python.keras.utils.data_utils import get_file -from tensorflow.python.platform import tf_logging as logging +from keras_applications import inception_resnet_v2 from tensorflow.python.util.tf_export import tf_export +InceptionResNetV2 = inception_resnet_v2.InceptionResNetV2 +decode_predictions = inception_resnet_v2.decode_predictions +preprocess_input = inception_resnet_v2.preprocess_input -BASE_WEIGHT_URL = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.7/' - - -@tf_export('keras.applications.inception_resnet_v2.preprocess_input') -def preprocess_input(x): - """Preprocesses a numpy array encoding a batch of images. - - Arguments: - x: a 4D numpy array consists of RGB values within [0, 255]. - - Returns: - Preprocessed array. - """ - return imagenet_utils.preprocess_input(x, mode='tf') - - -def conv2d_bn(x, - filters, - kernel_size, - strides=1, - padding='same', - activation='relu', - use_bias=False, - name=None): - """Utility function to apply conv + BN. - - Arguments: - x: input tensor. - filters: filters in `Conv2D`. - kernel_size: kernel size as in `Conv2D`. - strides: strides in `Conv2D`. - padding: padding mode in `Conv2D`. - activation: activation in `Conv2D`. - use_bias: whether to use a bias in `Conv2D`. - name: name of the ops; will become `name + '_ac'` for the activation - and `name + '_bn'` for the batch norm layer. - - Returns: - Output tensor after applying `Conv2D` and `BatchNormalization`. - """ - x = Conv2D( - filters, - kernel_size, - strides=strides, - padding=padding, - use_bias=use_bias, - name=name)( - x) - if not use_bias: - bn_axis = 1 if K.image_data_format() == 'channels_first' else 3 - bn_name = None if name is None else name + '_bn' - x = BatchNormalization(axis=bn_axis, scale=False, name=bn_name)(x) - if activation is not None: - ac_name = None if name is None else name + '_ac' - x = Activation(activation, name=ac_name)(x) - return x - - -def inception_resnet_block(x, scale, block_type, block_idx, activation='relu'): - """Adds a Inception-ResNet block. - - This function builds 3 types of Inception-ResNet blocks mentioned - in the paper, controlled by the `block_type` argument (which is the - block name used in the official TF-slim implementation): - - Inception-ResNet-A: `block_type='block35'` - - Inception-ResNet-B: `block_type='block17'` - - Inception-ResNet-C: `block_type='block8'` - - Arguments: - x: input tensor. - scale: scaling factor to scale the residuals (i.e., the output of - passing `x` through an inception module) before adding them - to the shortcut branch. Let `r` be the output from the residual - branch, - the output of this block will be `x + scale * r`. - block_type: `'block35'`, `'block17'` or `'block8'`, determines - the network structure in the residual branch. - block_idx: an `int` used for generating layer names. The Inception-ResNet - blocks - are repeated many times in this network. We use `block_idx` to - identify - each of the repetitions. For example, the first Inception-ResNet-A - block - will have `block_type='block35', block_idx=0`, ane the layer names - will have - a common prefix `'block35_0'`. - activation: activation function to use at the end of the block. - When `activation=None`, no activation is applied - (i.e., "linear" activation: `a(x) = x`). - - Returns: - Output tensor for the block. - - Raises: - ValueError: if `block_type` is not one of `'block35'`, - `'block17'` or `'block8'`. - """ - if block_type == 'block35': - branch_0 = conv2d_bn(x, 32, 1) - branch_1 = conv2d_bn(x, 32, 1) - branch_1 = conv2d_bn(branch_1, 32, 3) - branch_2 = conv2d_bn(x, 32, 1) - branch_2 = conv2d_bn(branch_2, 48, 3) - branch_2 = conv2d_bn(branch_2, 64, 3) - branches = [branch_0, branch_1, branch_2] - elif block_type == 'block17': - branch_0 = conv2d_bn(x, 192, 1) - branch_1 = conv2d_bn(x, 128, 1) - branch_1 = conv2d_bn(branch_1, 160, [1, 7]) - branch_1 = conv2d_bn(branch_1, 192, [7, 1]) - branches = [branch_0, branch_1] - elif block_type == 'block8': - branch_0 = conv2d_bn(x, 192, 1) - branch_1 = conv2d_bn(x, 192, 1) - branch_1 = conv2d_bn(branch_1, 224, [1, 3]) - branch_1 = conv2d_bn(branch_1, 256, [3, 1]) - branches = [branch_0, branch_1] - else: - raise ValueError('Unknown Inception-ResNet block type. ' - 'Expects "block35", "block17" or "block8", ' - 'but got: ' + str(block_type)) - - block_name = block_type + '_' + str(block_idx) - channel_axis = 1 if K.image_data_format() == 'channels_first' else 3 - mixed = Concatenate(axis=channel_axis, name=block_name + '_mixed')(branches) - up = conv2d_bn( - mixed, - K.int_shape(x)[channel_axis], - 1, - activation=None, - use_bias=True, - name=block_name + '_conv') - - x = Lambda( - lambda inputs, scale: inputs[0] + inputs[1] * scale, - output_shape=K.int_shape(x)[1:], - arguments={'scale': scale}, - name=block_name)([x, up]) - if activation is not None: - x = Activation(activation, name=block_name + '_ac')(x) - return x - - -@tf_export('keras.applications.InceptionResNetV2', - 'keras.applications.inception_resnet_v2.InceptionResNetV2') -def InceptionResNetV2(include_top=True, - weights='imagenet', - input_tensor=None, - input_shape=None, - pooling=None, - classes=1000): - """Instantiates the Inception-ResNet v2 architecture. - - Optionally loads weights pre-trained on ImageNet. - Note that when using TensorFlow, for best performance you should - set `"image_data_format": "channels_last"` in your Keras config - at `~/.keras/keras.json`. - - The model and the weights are compatible with TensorFlow, Theano and - CNTK backends. The data format convention used by the model is - the one specified in your Keras config file. - - Note that the default input image size for this model is 299x299, instead - of 224x224 as in the VGG16 and ResNet models. Also, the input preprocessing - function is different (i.e., do not use `imagenet_utils.preprocess_input()` - with this model. Use `preprocess_input()` defined in this module instead). - - Arguments: - include_top: whether to include the fully-connected - layer at the top of the network. - weights: one of `None` (random initialization), - 'imagenet' (pre-training on ImageNet), - or the path to the weights file to be loaded. - input_tensor: optional Keras tensor (i.e. output of `layers.Input()`) - to use as image input for the model. - input_shape: optional shape tuple, only to be specified - if `include_top` is `False` (otherwise the input shape - has to be `(299, 299, 3)` (with `'channels_last'` data format) - or `(3, 299, 299)` (with `'channels_first'` data format). - It should have exactly 3 inputs channels, - and width and height should be no smaller than 139. - E.g. `(150, 150, 3)` would be one valid value. - pooling: Optional pooling mode for feature extraction - when `include_top` is `False`. - - `None` means that the output of the model will be - the 4D tensor output of the last convolutional layer. - - `'avg'` means that global average pooling - will be applied to the output of the - last convolutional layer, and thus - the output of the model will be a 2D tensor. - - `'max'` means that global max pooling will be applied. - classes: optional number of classes to classify images - into, only to be specified if `include_top` is `True`, and - if no `weights` argument is specified. - - Returns: - A Keras `Model` instance. - - Raises: - ValueError: in case of invalid argument for `weights`, - or invalid input shape. - """ - if not (weights in {'imagenet', None} or os.path.exists(weights)): - raise ValueError('The `weights` argument should be either ' - '`None` (random initialization), `imagenet` ' - '(pre-training on ImageNet), ' - 'or the path to the weights file to be loaded.') - - if weights == 'imagenet' and include_top and classes != 1000: - raise ValueError('If using `weights` as imagenet with `include_top`' - ' as true, `classes` should be 1000') - - # Determine proper input shape - input_shape = _obtain_input_shape( - input_shape, - default_size=299, - min_size=139, - data_format=K.image_data_format(), - require_flatten=False, - weights=weights) - - if input_tensor is None: - img_input = Input(shape=input_shape) - else: - if not K.is_keras_tensor(input_tensor): - img_input = Input(tensor=input_tensor, shape=input_shape) - else: - img_input = input_tensor - - # Stem block: 35 x 35 x 192 - x = conv2d_bn(img_input, 32, 3, strides=2, padding='valid') - x = conv2d_bn(x, 32, 3, padding='valid') - x = conv2d_bn(x, 64, 3) - x = MaxPooling2D(3, strides=2)(x) - x = conv2d_bn(x, 80, 1, padding='valid') - x = conv2d_bn(x, 192, 3, padding='valid') - x = MaxPooling2D(3, strides=2)(x) - - # Mixed 5b (Inception-A block): 35 x 35 x 320 - branch_0 = conv2d_bn(x, 96, 1) - branch_1 = conv2d_bn(x, 48, 1) - branch_1 = conv2d_bn(branch_1, 64, 5) - branch_2 = conv2d_bn(x, 64, 1) - branch_2 = conv2d_bn(branch_2, 96, 3) - branch_2 = conv2d_bn(branch_2, 96, 3) - branch_pool = AveragePooling2D(3, strides=1, padding='same')(x) - branch_pool = conv2d_bn(branch_pool, 64, 1) - branches = [branch_0, branch_1, branch_2, branch_pool] - channel_axis = 1 if K.image_data_format() == 'channels_first' else 3 - x = Concatenate(axis=channel_axis, name='mixed_5b')(branches) - - # 10x block35 (Inception-ResNet-A block): 35 x 35 x 320 - for block_idx in range(1, 11): - x = inception_resnet_block( - x, scale=0.17, block_type='block35', block_idx=block_idx) - - # Mixed 6a (Reduction-A block): 17 x 17 x 1088 - branch_0 = conv2d_bn(x, 384, 3, strides=2, padding='valid') - branch_1 = conv2d_bn(x, 256, 1) - branch_1 = conv2d_bn(branch_1, 256, 3) - branch_1 = conv2d_bn(branch_1, 384, 3, strides=2, padding='valid') - branch_pool = MaxPooling2D(3, strides=2, padding='valid')(x) - branches = [branch_0, branch_1, branch_pool] - x = Concatenate(axis=channel_axis, name='mixed_6a')(branches) - - # 20x block17 (Inception-ResNet-B block): 17 x 17 x 1088 - for block_idx in range(1, 21): - x = inception_resnet_block( - x, scale=0.1, block_type='block17', block_idx=block_idx) - - # Mixed 7a (Reduction-B block): 8 x 8 x 2080 - branch_0 = conv2d_bn(x, 256, 1) - branch_0 = conv2d_bn(branch_0, 384, 3, strides=2, padding='valid') - branch_1 = conv2d_bn(x, 256, 1) - branch_1 = conv2d_bn(branch_1, 288, 3, strides=2, padding='valid') - branch_2 = conv2d_bn(x, 256, 1) - branch_2 = conv2d_bn(branch_2, 288, 3) - branch_2 = conv2d_bn(branch_2, 320, 3, strides=2, padding='valid') - branch_pool = MaxPooling2D(3, strides=2, padding='valid')(x) - branches = [branch_0, branch_1, branch_2, branch_pool] - x = Concatenate(axis=channel_axis, name='mixed_7a')(branches) - - # 10x block8 (Inception-ResNet-C block): 8 x 8 x 2080 - for block_idx in range(1, 10): - x = inception_resnet_block( - x, scale=0.2, block_type='block8', block_idx=block_idx) - x = inception_resnet_block( - x, scale=1., activation=None, block_type='block8', block_idx=10) - - # Final convolution block: 8 x 8 x 1536 - x = conv2d_bn(x, 1536, 1, name='conv_7b') - - if include_top: - # Classification block - x = GlobalAveragePooling2D(name='avg_pool')(x) - x = Dense(classes, activation='softmax', name='predictions')(x) - else: - if pooling == 'avg': - x = GlobalAveragePooling2D()(x) - elif pooling == 'max': - x = GlobalMaxPooling2D()(x) - - # Ensure that the model takes into account - # any potential predecessors of `input_tensor` - if input_tensor is not None: - inputs = layer_utils.get_source_inputs(input_tensor) - else: - inputs = img_input - - # Create model - model = Model(inputs, x, name='inception_resnet_v2') - - # Load weights - if weights == 'imagenet': - if include_top: - fname = 'inception_resnet_v2_weights_tf_dim_ordering_tf_kernels.h5' - weights_path = get_file( - fname, - BASE_WEIGHT_URL + fname, - cache_subdir='models', - file_hash='e693bd0210a403b3192acc6073ad2e96') - else: - fname = 'inception_resnet_v2_weights_tf_dim_ordering_tf_kernels_notop.h5' - weights_path = get_file( - fname, - BASE_WEIGHT_URL + fname, - cache_subdir='models', - file_hash='d19885ff4a710c122648d3b5c3b684e4') - model.load_weights(weights_path) - elif weights is not None: - model.load_weights(weights) - - return model +tf_export('keras.applications.inception_resnet_v2.InceptionResNetV2', + 'keras.applications.InceptionResNetV2')(InceptionResNetV2) +tf_export( + 'keras.applications.inception_resnet_v2.preprocess_input')(preprocess_input) diff --git a/tensorflow/python/keras/applications/inception_v3.py b/tensorflow/python/keras/applications/inception_v3.py index b5e28c781f..87534086c8 100644 --- a/tensorflow/python/keras/applications/inception_v3.py +++ b/tensorflow/python/keras/applications/inception_v3.py @@ -13,404 +13,19 @@ # limitations under the License. # ============================================================================== # pylint: disable=invalid-name -# pylint: disable=unused-import """Inception V3 model for Keras. - -Note that the input image format for this model is different than for -the VGG16 and ResNet models (299x299 instead of 224x224), -and that the input preprocessing function is also different (same as Xception). - -# Reference - -- [Rethinking the Inception Architecture for Computer -Vision](http://arxiv.org/abs/1512.00567) - """ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os - -from tensorflow.python.keras import backend as K -from tensorflow.python.keras import layers -from tensorflow.python.keras.applications import imagenet_utils -from tensorflow.python.keras.applications.imagenet_utils import _obtain_input_shape -from tensorflow.python.keras.applications.imagenet_utils import decode_predictions -from tensorflow.python.keras.layers import Activation -from tensorflow.python.keras.layers import AveragePooling2D -from tensorflow.python.keras.layers import BatchNormalization -from tensorflow.python.keras.layers import Conv2D -from tensorflow.python.keras.layers import Dense -from tensorflow.python.keras.layers import GlobalAveragePooling2D -from tensorflow.python.keras.layers import GlobalMaxPooling2D -from tensorflow.python.keras.layers import Input -from tensorflow.python.keras.layers import MaxPooling2D -from tensorflow.python.keras.models import Model -from tensorflow.python.keras.utils import layer_utils -from tensorflow.python.keras.utils.data_utils import get_file -from tensorflow.python.platform import tf_logging as logging +from keras_applications import inception_v3 from tensorflow.python.util.tf_export import tf_export +InceptionV3 = inception_v3.InceptionV3 +decode_predictions = inception_v3.decode_predictions +preprocess_input = inception_v3.preprocess_input -WEIGHTS_PATH = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.5/inception_v3_weights_tf_dim_ordering_tf_kernels.h5' -WEIGHTS_PATH_NO_TOP = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.5/inception_v3_weights_tf_dim_ordering_tf_kernels_notop.h5' - - -def conv2d_bn(x, - filters, - num_row, - num_col, - padding='same', - strides=(1, 1), - name=None): - """Utility function to apply conv + BN. - - Arguments: - x: input tensor. - filters: filters in `Conv2D`. - num_row: height of the convolution kernel. - num_col: width of the convolution kernel. - padding: padding mode in `Conv2D`. - strides: strides in `Conv2D`. - name: name of the ops; will become `name + '_conv'` - for the convolution and `name + '_bn'` for the - batch norm layer. - - Returns: - Output tensor after applying `Conv2D` and `BatchNormalization`. - """ - if name is not None: - bn_name = name + '_bn' - conv_name = name + '_conv' - else: - bn_name = None - conv_name = None - if K.image_data_format() == 'channels_first': - bn_axis = 1 - else: - bn_axis = 3 - x = Conv2D( - filters, (num_row, num_col), - strides=strides, - padding=padding, - use_bias=False, - name=conv_name)( - x) - x = BatchNormalization(axis=bn_axis, scale=False, name=bn_name)(x) - x = Activation('relu', name=name)(x) - return x - - -@tf_export('keras.applications.InceptionV3', - 'keras.applications.inception_v3.InceptionV3') -def InceptionV3(include_top=True, - weights='imagenet', - input_tensor=None, - input_shape=None, - pooling=None, - classes=1000): - """Instantiates the Inception v3 architecture. - - Optionally loads weights pre-trained - on ImageNet. Note that when using TensorFlow, - for best performance you should set - `image_data_format='channels_last'` in your Keras config - at ~/.keras/keras.json. - The model and the weights are compatible with both - TensorFlow and Theano. The data format - convention used by the model is the one - specified in your Keras config file. - Note that the default input image size for this model is 299x299. - - Arguments: - include_top: whether to include the fully-connected - layer at the top of the network. - weights: one of `None` (random initialization), - 'imagenet' (pre-training on ImageNet), - or the path to the weights file to be loaded. - input_tensor: optional Keras tensor (i.e. output of `layers.Input()`) - to use as image input for the model. - input_shape: optional shape tuple, only to be specified - if `include_top` is False (otherwise the input shape - has to be `(299, 299, 3)` (with `channels_last` data format) - or `(3, 299, 299)` (with `channels_first` data format). - It should have exactly 3 inputs channels, - and width and height should be no smaller than 139. - E.g. `(150, 150, 3)` would be one valid value. - pooling: Optional pooling mode for feature extraction - when `include_top` is `False`. - - `None` means that the output of the model will be - the 4D tensor output of the - last convolutional layer. - - `avg` means that global average pooling - will be applied to the output of the - last convolutional layer, and thus - the output of the model will be a 2D tensor. - - `max` means that global max pooling will - be applied. - classes: optional number of classes to classify images - into, only to be specified if `include_top` is True, and - if no `weights` argument is specified. - - Returns: - A Keras model instance. - - Raises: - ValueError: in case of invalid argument for `weights`, - or invalid input shape. - """ - if not (weights in {'imagenet', None} or os.path.exists(weights)): - raise ValueError('The `weights` argument should be either ' - '`None` (random initialization), `imagenet` ' - '(pre-training on ImageNet), ' - 'or the path to the weights file to be loaded.') - - if weights == 'imagenet' and include_top and classes != 1000: - raise ValueError('If using `weights` as imagenet with `include_top`' - ' as true, `classes` should be 1000') - - # Determine proper input shape - input_shape = _obtain_input_shape( - input_shape, - default_size=299, - min_size=139, - data_format=K.image_data_format(), - require_flatten=False, - weights=weights) - - if input_tensor is None: - img_input = Input(shape=input_shape) - else: - if not K.is_keras_tensor(input_tensor): - img_input = Input(tensor=input_tensor, shape=input_shape) - else: - img_input = input_tensor - - if K.image_data_format() == 'channels_first': - channel_axis = 1 - else: - channel_axis = 3 - - x = conv2d_bn(img_input, 32, 3, 3, strides=(2, 2), padding='valid') - x = conv2d_bn(x, 32, 3, 3, padding='valid') - x = conv2d_bn(x, 64, 3, 3) - x = MaxPooling2D((3, 3), strides=(2, 2))(x) - - x = conv2d_bn(x, 80, 1, 1, padding='valid') - x = conv2d_bn(x, 192, 3, 3, padding='valid') - x = MaxPooling2D((3, 3), strides=(2, 2))(x) - - # mixed 0, 1, 2: 35 x 35 x 256 - branch1x1 = conv2d_bn(x, 64, 1, 1) - - branch5x5 = conv2d_bn(x, 48, 1, 1) - branch5x5 = conv2d_bn(branch5x5, 64, 5, 5) - - branch3x3dbl = conv2d_bn(x, 64, 1, 1) - branch3x3dbl = conv2d_bn(branch3x3dbl, 96, 3, 3) - branch3x3dbl = conv2d_bn(branch3x3dbl, 96, 3, 3) - - branch_pool = AveragePooling2D((3, 3), strides=(1, 1), padding='same')(x) - branch_pool = conv2d_bn(branch_pool, 32, 1, 1) - x = layers.concatenate( - [branch1x1, branch5x5, branch3x3dbl, branch_pool], - axis=channel_axis, - name='mixed0') - - # mixed 1: 35 x 35 x 256 - branch1x1 = conv2d_bn(x, 64, 1, 1) - - branch5x5 = conv2d_bn(x, 48, 1, 1) - branch5x5 = conv2d_bn(branch5x5, 64, 5, 5) - - branch3x3dbl = conv2d_bn(x, 64, 1, 1) - branch3x3dbl = conv2d_bn(branch3x3dbl, 96, 3, 3) - branch3x3dbl = conv2d_bn(branch3x3dbl, 96, 3, 3) - - branch_pool = AveragePooling2D((3, 3), strides=(1, 1), padding='same')(x) - branch_pool = conv2d_bn(branch_pool, 64, 1, 1) - x = layers.concatenate( - [branch1x1, branch5x5, branch3x3dbl, branch_pool], - axis=channel_axis, - name='mixed1') - - # mixed 2: 35 x 35 x 256 - branch1x1 = conv2d_bn(x, 64, 1, 1) - - branch5x5 = conv2d_bn(x, 48, 1, 1) - branch5x5 = conv2d_bn(branch5x5, 64, 5, 5) - - branch3x3dbl = conv2d_bn(x, 64, 1, 1) - branch3x3dbl = conv2d_bn(branch3x3dbl, 96, 3, 3) - branch3x3dbl = conv2d_bn(branch3x3dbl, 96, 3, 3) - - branch_pool = AveragePooling2D((3, 3), strides=(1, 1), padding='same')(x) - branch_pool = conv2d_bn(branch_pool, 64, 1, 1) - x = layers.concatenate( - [branch1x1, branch5x5, branch3x3dbl, branch_pool], - axis=channel_axis, - name='mixed2') - - # mixed 3: 17 x 17 x 768 - branch3x3 = conv2d_bn(x, 384, 3, 3, strides=(2, 2), padding='valid') - - branch3x3dbl = conv2d_bn(x, 64, 1, 1) - branch3x3dbl = conv2d_bn(branch3x3dbl, 96, 3, 3) - branch3x3dbl = conv2d_bn( - branch3x3dbl, 96, 3, 3, strides=(2, 2), padding='valid') - - branch_pool = MaxPooling2D((3, 3), strides=(2, 2))(x) - x = layers.concatenate( - [branch3x3, branch3x3dbl, branch_pool], axis=channel_axis, name='mixed3') - - # mixed 4: 17 x 17 x 768 - branch1x1 = conv2d_bn(x, 192, 1, 1) - - branch7x7 = conv2d_bn(x, 128, 1, 1) - branch7x7 = conv2d_bn(branch7x7, 128, 1, 7) - branch7x7 = conv2d_bn(branch7x7, 192, 7, 1) - - branch7x7dbl = conv2d_bn(x, 128, 1, 1) - branch7x7dbl = conv2d_bn(branch7x7dbl, 128, 7, 1) - branch7x7dbl = conv2d_bn(branch7x7dbl, 128, 1, 7) - branch7x7dbl = conv2d_bn(branch7x7dbl, 128, 7, 1) - branch7x7dbl = conv2d_bn(branch7x7dbl, 192, 1, 7) - - branch_pool = AveragePooling2D((3, 3), strides=(1, 1), padding='same')(x) - branch_pool = conv2d_bn(branch_pool, 192, 1, 1) - x = layers.concatenate( - [branch1x1, branch7x7, branch7x7dbl, branch_pool], - axis=channel_axis, - name='mixed4') - - # mixed 5, 6: 17 x 17 x 768 - for i in range(2): - branch1x1 = conv2d_bn(x, 192, 1, 1) - - branch7x7 = conv2d_bn(x, 160, 1, 1) - branch7x7 = conv2d_bn(branch7x7, 160, 1, 7) - branch7x7 = conv2d_bn(branch7x7, 192, 7, 1) - - branch7x7dbl = conv2d_bn(x, 160, 1, 1) - branch7x7dbl = conv2d_bn(branch7x7dbl, 160, 7, 1) - branch7x7dbl = conv2d_bn(branch7x7dbl, 160, 1, 7) - branch7x7dbl = conv2d_bn(branch7x7dbl, 160, 7, 1) - branch7x7dbl = conv2d_bn(branch7x7dbl, 192, 1, 7) - - branch_pool = AveragePooling2D((3, 3), strides=(1, 1), padding='same')(x) - branch_pool = conv2d_bn(branch_pool, 192, 1, 1) - x = layers.concatenate( - [branch1x1, branch7x7, branch7x7dbl, branch_pool], - axis=channel_axis, - name='mixed' + str(5 + i)) - - # mixed 7: 17 x 17 x 768 - branch1x1 = conv2d_bn(x, 192, 1, 1) - - branch7x7 = conv2d_bn(x, 192, 1, 1) - branch7x7 = conv2d_bn(branch7x7, 192, 1, 7) - branch7x7 = conv2d_bn(branch7x7, 192, 7, 1) - - branch7x7dbl = conv2d_bn(x, 192, 1, 1) - branch7x7dbl = conv2d_bn(branch7x7dbl, 192, 7, 1) - branch7x7dbl = conv2d_bn(branch7x7dbl, 192, 1, 7) - branch7x7dbl = conv2d_bn(branch7x7dbl, 192, 7, 1) - branch7x7dbl = conv2d_bn(branch7x7dbl, 192, 1, 7) - - branch_pool = AveragePooling2D((3, 3), strides=(1, 1), padding='same')(x) - branch_pool = conv2d_bn(branch_pool, 192, 1, 1) - x = layers.concatenate( - [branch1x1, branch7x7, branch7x7dbl, branch_pool], - axis=channel_axis, - name='mixed7') - - # mixed 8: 8 x 8 x 1280 - branch3x3 = conv2d_bn(x, 192, 1, 1) - branch3x3 = conv2d_bn(branch3x3, 320, 3, 3, strides=(2, 2), padding='valid') - - branch7x7x3 = conv2d_bn(x, 192, 1, 1) - branch7x7x3 = conv2d_bn(branch7x7x3, 192, 1, 7) - branch7x7x3 = conv2d_bn(branch7x7x3, 192, 7, 1) - branch7x7x3 = conv2d_bn( - branch7x7x3, 192, 3, 3, strides=(2, 2), padding='valid') - - branch_pool = MaxPooling2D((3, 3), strides=(2, 2))(x) - x = layers.concatenate( - [branch3x3, branch7x7x3, branch_pool], axis=channel_axis, name='mixed8') - - # mixed 9: 8 x 8 x 2048 - for i in range(2): - branch1x1 = conv2d_bn(x, 320, 1, 1) - - branch3x3 = conv2d_bn(x, 384, 1, 1) - branch3x3_1 = conv2d_bn(branch3x3, 384, 1, 3) - branch3x3_2 = conv2d_bn(branch3x3, 384, 3, 1) - branch3x3 = layers.concatenate( - [branch3x3_1, branch3x3_2], axis=channel_axis, name='mixed9_' + str(i)) - - branch3x3dbl = conv2d_bn(x, 448, 1, 1) - branch3x3dbl = conv2d_bn(branch3x3dbl, 384, 3, 3) - branch3x3dbl_1 = conv2d_bn(branch3x3dbl, 384, 1, 3) - branch3x3dbl_2 = conv2d_bn(branch3x3dbl, 384, 3, 1) - branch3x3dbl = layers.concatenate( - [branch3x3dbl_1, branch3x3dbl_2], axis=channel_axis) - - branch_pool = AveragePooling2D((3, 3), strides=(1, 1), padding='same')(x) - branch_pool = conv2d_bn(branch_pool, 192, 1, 1) - x = layers.concatenate( - [branch1x1, branch3x3, branch3x3dbl, branch_pool], - axis=channel_axis, - name='mixed' + str(9 + i)) - if include_top: - # Classification block - x = GlobalAveragePooling2D(name='avg_pool')(x) - x = Dense(classes, activation='softmax', name='predictions')(x) - else: - if pooling == 'avg': - x = GlobalAveragePooling2D()(x) - elif pooling == 'max': - x = GlobalMaxPooling2D()(x) - - # Ensure that the model takes into account - # any potential predecessors of `input_tensor`. - if input_tensor is not None: - inputs = layer_utils.get_source_inputs(input_tensor) - else: - inputs = img_input - # Create model. - model = Model(inputs, x, name='inception_v3') - - # load weights - if weights == 'imagenet': - if include_top: - weights_path = get_file( - 'inception_v3_weights_tf_dim_ordering_tf_kernels.h5', - WEIGHTS_PATH, - cache_subdir='models', - file_hash='9a0d58056eeedaa3f26cb7ebd46da564') - else: - weights_path = get_file( - 'inception_v3_weights_tf_dim_ordering_tf_kernels_notop.h5', - WEIGHTS_PATH_NO_TOP, - cache_subdir='models', - file_hash='bcbd6486424b2319ff4ef7d526e38f63') - model.load_weights(weights_path) - elif weights is not None: - model.load_weights(weights) - - return model - - -@tf_export('keras.applications.nasnet.preprocess_input', - 'keras.applications.inception_v3.preprocess_input') -def preprocess_input(x): - """Preprocesses a numpy array encoding a batch of images. - - Arguments: - x: a 4D numpy array consists of RGB values within [0, 255]. - - Returns: - Preprocessed array. - """ - return imagenet_utils.preprocess_input(x, mode='tf') +tf_export('keras.applications.inception_v3.InceptionV3', + 'keras.applications.InceptionV3')(InceptionV3) +tf_export('keras.applications.inception_v3.preprocess_input')(preprocess_input) diff --git a/tensorflow/python/keras/applications/mobilenet.py b/tensorflow/python/keras/applications/mobilenet.py index 7285e03963..3528f027b3 100644 --- a/tensorflow/python/keras/applications/mobilenet.py +++ b/tensorflow/python/keras/applications/mobilenet.py @@ -13,466 +13,19 @@ # limitations under the License. # ============================================================================== # pylint: disable=invalid-name -# pylint: disable=unused-import """MobileNet v1 models for Keras. - -MobileNet is a general architecture and can be used for multiple use cases. -Depending on the use case, it can use different input layer size and -different width factors. This allows different width models to reduce -the number of multiply-adds and thereby -reduce inference cost on mobile devices. - -MobileNets support any input size greater than 32 x 32, with larger image sizes -offering better performance. -The number of parameters and number of multiply-adds -can be modified by using the `alpha` parameter, -which increases/decreases the number of filters in each layer. -By altering the image size and `alpha` parameter, -all 16 models from the paper can be built, with ImageNet weights provided. - -The paper demonstrates the performance of MobileNets using `alpha` values of -1.0 (also called 100 % MobileNet), 0.75, 0.5 and 0.25. -For each of these `alpha` values, weights for 4 different input image sizes -are provided (224, 192, 160, 128). - -The following table describes the size and accuracy of the 100% MobileNet -on size 224 x 224: ----------------------------------------------------------------------------- -Width Multiplier (alpha) | ImageNet Acc | Multiply-Adds (M) | Params (M) ----------------------------------------------------------------------------- -| 1.0 MobileNet-224 | 70.6 % | 529 | 4.2 | -| 0.75 MobileNet-224 | 68.4 % | 325 | 2.6 | -| 0.50 MobileNet-224 | 63.7 % | 149 | 1.3 | -| 0.25 MobileNet-224 | 50.6 % | 41 | 0.5 | ----------------------------------------------------------------------------- - -The following table describes the performance of -the 100 % MobileNet on various input sizes: ------------------------------------------------------------------------- - Resolution | ImageNet Acc | Multiply-Adds (M) | Params (M) ------------------------------------------------------------------------- -| 1.0 MobileNet-224 | 70.6 % | 529 | 4.2 | -| 1.0 MobileNet-192 | 69.1 % | 529 | 4.2 | -| 1.0 MobileNet-160 | 67.2 % | 529 | 4.2 | -| 1.0 MobileNet-128 | 64.4 % | 529 | 4.2 | ------------------------------------------------------------------------- - -The weights for all 16 models are obtained and translated -from TensorFlow checkpoints found at -https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet_v1.md - -# Reference -- [MobileNets: Efficient Convolutional Neural Networks for - Mobile Vision Applications](https://arxiv.org/pdf/1704.04861.pdf)) """ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os - -from tensorflow.python.keras import backend as K -from tensorflow.python.keras.applications import imagenet_utils -from tensorflow.python.keras.applications.imagenet_utils import _obtain_input_shape -from tensorflow.python.keras.applications.imagenet_utils import decode_predictions -from tensorflow.python.keras.layers import Activation -from tensorflow.python.keras.layers import BatchNormalization -from tensorflow.python.keras.layers import Conv2D -from tensorflow.python.keras.layers import DepthwiseConv2D -from tensorflow.python.keras.layers import Dropout -from tensorflow.python.keras.layers import GlobalAveragePooling2D -from tensorflow.python.keras.layers import GlobalMaxPooling2D -from tensorflow.python.keras.layers import Input -from tensorflow.python.keras.layers import ReLU -from tensorflow.python.keras.layers import Reshape -from tensorflow.python.keras.layers import ZeroPadding2D -from tensorflow.python.keras.models import Model -from tensorflow.python.keras.utils import layer_utils -from tensorflow.python.keras.utils.data_utils import get_file -from tensorflow.python.platform import tf_logging as logging +from keras_applications import mobilenet from tensorflow.python.util.tf_export import tf_export +MobileNet = mobilenet.MobileNet +decode_predictions = mobilenet.decode_predictions +preprocess_input = mobilenet.preprocess_input -BASE_WEIGHT_PATH = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.6/' - - -@tf_export('keras.applications.mobilenet.preprocess_input') -def preprocess_input(x): - """Preprocesses a numpy array encoding a batch of images. - - Arguments: - x: a 4D numpy array consists of RGB values within [0, 255]. - - Returns: - Preprocessed array. - """ - return imagenet_utils.preprocess_input(x, mode='tf') - - -@tf_export('keras.applications.MobileNet', - 'keras.applications.mobilenet.MobileNet') -def MobileNet(input_shape=None, - alpha=1.0, - depth_multiplier=1, - dropout=1e-3, - include_top=True, - weights='imagenet', - input_tensor=None, - pooling=None, - classes=1000): - """Instantiates the MobileNet architecture. - - Arguments: - input_shape: optional shape tuple, only to be specified - if `include_top` is False (otherwise the input shape - has to be `(224, 224, 3)` (with `channels_last` data format) - or (3, 224, 224) (with `channels_first` data format). - It should have exactly 3 inputs channels, - and width and height should be no smaller than 32. - E.g. `(200, 200, 3)` would be one valid value. - alpha: controls the width of the network. - - If `alpha` < 1.0, proportionally decreases the number - of filters in each layer. - - If `alpha` > 1.0, proportionally increases the number - of filters in each layer. - - If `alpha` = 1, default number of filters from the paper - are used at each layer. - depth_multiplier: depth multiplier for depthwise convolution - (also called the resolution multiplier) - dropout: dropout rate - include_top: whether to include the fully-connected - layer at the top of the network. - weights: one of `None` (random initialization), - 'imagenet' (pre-training on ImageNet), - or the path to the weights file to be loaded. - input_tensor: optional Keras tensor (i.e. output of - `layers.Input()`) - to use as image input for the model. - pooling: Optional pooling mode for feature extraction - when `include_top` is `False`. - - `None` means that the output of the model - will be the 4D tensor output of the - last convolutional layer. - - `avg` means that global average pooling - will be applied to the output of the - last convolutional layer, and thus - the output of the model will be a - 2D tensor. - - `max` means that global max pooling will - be applied. - classes: optional number of classes to classify images - into, only to be specified if `include_top` is True, and - if no `weights` argument is specified. - - Returns: - A Keras model instance. - - Raises: - ValueError: in case of invalid argument for `weights`, - or invalid input shape. - RuntimeError: If attempting to run this model with a - backend that does not support separable convolutions. - """ - - if not (weights in {'imagenet', None} or os.path.exists(weights)): - raise ValueError('The `weights` argument should be either ' - '`None` (random initialization), `imagenet` ' - '(pre-training on ImageNet), ' - 'or the path to the weights file to be loaded.') - - if weights == 'imagenet' and include_top and classes != 1000: - raise ValueError('If using `weights` as ImageNet with `include_top` ' - 'as true, `classes` should be 1000') - - # Determine proper input shape and default size. - if input_shape is None: - default_size = 224 - else: - if K.image_data_format() == 'channels_first': - rows = input_shape[1] - cols = input_shape[2] - else: - rows = input_shape[0] - cols = input_shape[1] - - if rows == cols and rows in [128, 160, 192, 224]: - default_size = rows - else: - default_size = 224 - - input_shape = _obtain_input_shape( - input_shape, - default_size=default_size, - min_size=32, - data_format=K.image_data_format(), - require_flatten=include_top, - weights=weights) - - if K.image_data_format() == 'channels_last': - row_axis, col_axis = (0, 1) - else: - row_axis, col_axis = (1, 2) - rows = input_shape[row_axis] - cols = input_shape[col_axis] - - if weights == 'imagenet': - if depth_multiplier != 1: - raise ValueError('If imagenet weights are being loaded, ' - 'depth multiplier must be 1') - - if alpha not in [0.25, 0.50, 0.75, 1.0]: - raise ValueError('If imagenet weights are being loaded, ' - 'alpha can be one of' - '`0.25`, `0.50`, `0.75` or `1.0` only.') - - if rows != cols or rows not in [128, 160, 192, 224]: - if rows is None: - rows = 224 - logging.warning('MobileNet shape is undefined.' - ' Weights for input shape (224, 224) will be loaded.') - else: - raise ValueError('If imagenet weights are being loaded, ' - 'input must have a static square shape (one of ' - '(128, 128), (160, 160), (192, 192), or (224, 224)).' - ' Input shape provided = %s' % (input_shape,)) - - if K.image_data_format() != 'channels_last': - logging.warning('The MobileNet family of models is only available ' - 'for the input data format "channels_last" ' - '(width, height, channels). ' - 'However your settings specify the default ' - 'data format "channels_first" (channels, width, height).' - ' You should set `image_data_format="channels_last"` ' - 'in your Keras config located at ~/.keras/keras.json. ' - 'The model being returned right now will expect inputs ' - 'to follow the "channels_last" data format.') - K.set_image_data_format('channels_last') - old_data_format = 'channels_first' - else: - old_data_format = None - - if input_tensor is None: - img_input = Input(shape=input_shape) - else: - if not K.is_keras_tensor(input_tensor): - img_input = Input(tensor=input_tensor, shape=input_shape) - else: - img_input = input_tensor - - x = _conv_block(img_input, 32, alpha, strides=(2, 2)) - x = _depthwise_conv_block(x, 64, alpha, depth_multiplier, block_id=1) - - x = _depthwise_conv_block( - x, 128, alpha, depth_multiplier, strides=(2, 2), block_id=2) - x = _depthwise_conv_block(x, 128, alpha, depth_multiplier, block_id=3) - - x = _depthwise_conv_block( - x, 256, alpha, depth_multiplier, strides=(2, 2), block_id=4) - x = _depthwise_conv_block(x, 256, alpha, depth_multiplier, block_id=5) - - x = _depthwise_conv_block( - x, 512, alpha, depth_multiplier, strides=(2, 2), block_id=6) - x = _depthwise_conv_block(x, 512, alpha, depth_multiplier, block_id=7) - x = _depthwise_conv_block(x, 512, alpha, depth_multiplier, block_id=8) - x = _depthwise_conv_block(x, 512, alpha, depth_multiplier, block_id=9) - x = _depthwise_conv_block(x, 512, alpha, depth_multiplier, block_id=10) - x = _depthwise_conv_block(x, 512, alpha, depth_multiplier, block_id=11) - - x = _depthwise_conv_block( - x, 1024, alpha, depth_multiplier, strides=(2, 2), block_id=12) - x = _depthwise_conv_block(x, 1024, alpha, depth_multiplier, block_id=13) - - if include_top: - if K.image_data_format() == 'channels_first': - shape = (int(1024 * alpha), 1, 1) - else: - shape = (1, 1, int(1024 * alpha)) - - x = GlobalAveragePooling2D()(x) - x = Reshape(shape, name='reshape_1')(x) - x = Dropout(dropout, name='dropout')(x) - x = Conv2D(classes, (1, 1), padding='same', name='conv_preds')(x) - x = Activation('softmax', name='act_softmax')(x) - x = Reshape((classes,), name='reshape_2')(x) - else: - if pooling == 'avg': - x = GlobalAveragePooling2D()(x) - elif pooling == 'max': - x = GlobalMaxPooling2D()(x) - - # Ensure that the model takes into account - # any potential predecessors of `input_tensor`. - if input_tensor is not None: - inputs = layer_utils.get_source_inputs(input_tensor) - else: - inputs = img_input - - # Create model. - model = Model(inputs, x, name='mobilenet_%0.2f_%s' % (alpha, rows)) - - # load weights - if weights == 'imagenet': - if K.image_data_format() == 'channels_first': - raise ValueError('Weights for "channels_first" format ' - 'are not available.') - if alpha == 1.0: - alpha_text = '1_0' - elif alpha == 0.75: - alpha_text = '7_5' - elif alpha == 0.50: - alpha_text = '5_0' - else: - alpha_text = '2_5' - - if include_top: - model_name = 'mobilenet_%s_%d_tf.h5' % (alpha_text, rows) - weigh_path = BASE_WEIGHT_PATH + model_name - weights_path = get_file(model_name, weigh_path, cache_subdir='models') - else: - model_name = 'mobilenet_%s_%d_tf_no_top.h5' % (alpha_text, rows) - weigh_path = BASE_WEIGHT_PATH + model_name - weights_path = get_file(model_name, weigh_path, cache_subdir='models') - model.load_weights(weights_path) - elif weights is not None: - model.load_weights(weights) - - if old_data_format: - K.set_image_data_format(old_data_format) - return model - - -def _conv_block(inputs, filters, alpha, kernel=(3, 3), strides=(1, 1)): - """Adds an initial convolution layer (with batch normalization and relu6). - - Arguments: - inputs: Input tensor of shape `(rows, cols, 3)` - (with `channels_last` data format) or - (3, rows, cols) (with `channels_first` data format). - It should have exactly 3 inputs channels, - and width and height should be no smaller than 32. - E.g. `(224, 224, 3)` would be one valid value. - filters: Integer, the dimensionality of the output space - (i.e. the number of output filters in the convolution). - alpha: controls the width of the network. - - If `alpha` < 1.0, proportionally decreases the number - of filters in each layer. - - If `alpha` > 1.0, proportionally increases the number - of filters in each layer. - - If `alpha` = 1, default number of filters from the paper - are used at each layer. - kernel: An integer or tuple/list of 2 integers, specifying the - width and height of the 2D convolution window. - Can be a single integer to specify the same value for - all spatial dimensions. - strides: An integer or tuple/list of 2 integers, - specifying the strides of the convolution along the width and height. - Can be a single integer to specify the same value for - all spatial dimensions. - Specifying any stride value != 1 is incompatible with specifying - any `dilation_rate` value != 1. - - Input shape: - 4D tensor with shape: - `(samples, channels, rows, cols)` if data_format='channels_first' - or 4D tensor with shape: - `(samples, rows, cols, channels)` if data_format='channels_last'. - - Output shape: - 4D tensor with shape: - `(samples, filters, new_rows, new_cols)` if data_format='channels_first' - or 4D tensor with shape: - `(samples, new_rows, new_cols, filters)` if data_format='channels_last'. - `rows` and `cols` values might have changed due to stride. - - Returns: - Output tensor of block. - """ - channel_axis = 1 if K.image_data_format() == 'channels_first' else -1 - filters = int(filters * alpha) - x = ZeroPadding2D(padding=(1, 1), name='conv1_pad')(inputs) - x = Conv2D( - filters, - kernel, - padding='valid', - use_bias=False, - strides=strides, - name='conv1')(x) - x = BatchNormalization(axis=channel_axis, name='conv1_bn')(x) - return ReLU(6, name='conv1_relu')(x) - - -def _depthwise_conv_block(inputs, - pointwise_conv_filters, - alpha, - depth_multiplier=1, - strides=(1, 1), - block_id=1): - """Adds a depthwise convolution block. - - A depthwise convolution block consists of a depthwise conv, - batch normalization, relu6, pointwise convolution, - batch normalization and relu6 activation. - - Arguments: - inputs: Input tensor of shape `(rows, cols, channels)` - (with `channels_last` data format) or - (channels, rows, cols) (with `channels_first` data format). - pointwise_conv_filters: Integer, the dimensionality of the output space - (i.e. the number of output filters in the pointwise convolution). - alpha: controls the width of the network. - - If `alpha` < 1.0, proportionally decreases the number - of filters in each layer. - - If `alpha` > 1.0, proportionally increases the number - of filters in each layer. - - If `alpha` = 1, default number of filters from the paper - are used at each layer. - depth_multiplier: The number of depthwise convolution output channels - for each input channel. - The total number of depthwise convolution output - channels will be equal to `filters_in * depth_multiplier`. - strides: An integer or tuple/list of 2 integers, - specifying the strides of the convolution along the width and height. - Can be a single integer to specify the same value for - all spatial dimensions. - Specifying any stride value != 1 is incompatible with specifying - any `dilation_rate` value != 1. - block_id: Integer, a unique identification designating the block number. - - Input shape: - 4D tensor with shape: - `(batch, channels, rows, cols)` if data_format='channels_first' - or 4D tensor with shape: - `(batch, rows, cols, channels)` if data_format='channels_last'. - - Output shape: - 4D tensor with shape: - `(batch, filters, new_rows, new_cols)` if data_format='channels_first' - or 4D tensor with shape: - `(batch, new_rows, new_cols, filters)` if data_format='channels_last'. - `rows` and `cols` values might have changed due to stride. - - Returns: - Output tensor of block. - """ - channel_axis = 1 if K.image_data_format() == 'channels_first' else -1 - pointwise_conv_filters = int(pointwise_conv_filters * alpha) - x = ZeroPadding2D(padding=(1, 1), name='conv_pad_%d' % block_id)(inputs) - x = DepthwiseConv2D( # pylint: disable=not-callable - (3, 3), - padding='valid', - depth_multiplier=depth_multiplier, - strides=strides, - use_bias=False, - name='conv_dw_%d' % block_id)(x) - x = BatchNormalization(axis=channel_axis, name='conv_dw_%d_bn' % block_id)(x) - x = ReLU(6, name='conv_dw_%d_relu' % block_id)(x) - - x = Conv2D( - pointwise_conv_filters, (1, 1), - padding='same', - use_bias=False, - strides=(1, 1), - name='conv_pw_%d' % block_id)( - x) - x = BatchNormalization(axis=channel_axis, name='conv_pw_%d_bn' % block_id)(x) - return ReLU(6, name='conv_pw_%d_relu' % block_id)(x) +tf_export('keras.applications.mobilenet.MobileNet', + 'keras.applications.MobileNet')(MobileNet) +tf_export('keras.applications.mobilenet.preprocess_input')(preprocess_input) diff --git a/tensorflow/python/keras/applications/mobilenet_test.py b/tensorflow/python/keras/applications/mobilenet_test.py index 5661ed7856..65e4991ded 100644 --- a/tensorflow/python/keras/applications/mobilenet_test.py +++ b/tensorflow/python/keras/applications/mobilenet_test.py @@ -53,12 +53,6 @@ class MobileNetTest(test.TestCase): out1 = keras.applications.mobilenet.preprocess_input(x) self.assertAllClose(np.mean(out1), 0., atol=0.1) - def test_invalid_use_cases(self): - keras.backend.set_image_data_format('channels_first') - model = keras.applications.MobileNet(weights=None) - self.assertEqual(model.output_shape, (None, 1000)) - keras.backend.set_image_data_format('channels_last') - def test_mobilenet_variable_input_channels(self): input_shape = (None, None, 1) model = keras.applications.MobileNet(weights=None, @@ -72,30 +66,6 @@ class MobileNetTest(test.TestCase): input_shape=input_shape) self.assertEqual(model.output_shape, (None, None, None, 1024)) - def test_mobilenet_image_size(self): - with self.test_session(): - valid_image_sizes = [128, 160, 192, 224] - for size in valid_image_sizes: - keras.backend.set_image_data_format('channels_last') - input_shape = (size, size, 3) - model = keras.applications.MobileNet(input_shape=input_shape, - weights=None, - include_top=True) - self.assertEqual(model.input_shape, (None,) + input_shape) - - keras.backend.set_image_data_format('channels_first') - input_shape = (3, size, size) - model = keras.applications.MobileNet(input_shape=input_shape, - weights=None, - include_top=True) - self.assertEqual(model.input_shape, (None,) + input_shape) - - keras.backend.set_image_data_format('channels_last') - invalid_image_shape = (112, 112, 3) - with self.assertRaises(ValueError): - model = keras.applications.MobileNet(input_shape=invalid_image_shape, - weights='imagenet', - include_top=True) if __name__ == '__main__': test.main() diff --git a/tensorflow/python/keras/applications/mobilenet_v2.py b/tensorflow/python/keras/applications/mobilenet_v2.py new file mode 100644 index 0000000000..74b8b029f8 --- /dev/null +++ b/tensorflow/python/keras/applications/mobilenet_v2.py @@ -0,0 +1,32 @@ +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== +# pylint: disable=invalid-name +"""MobileNet v2 models for Keras. +""" +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +from keras_applications import mobilenet_v2 + +from tensorflow.python.util.tf_export import tf_export + +MobileNetV2 = mobilenet_v2.MobileNetV2 +decode_predictions = mobilenet_v2.decode_predictions +preprocess_input = mobilenet_v2.preprocess_input + +tf_export('keras.applications.mobilenet_v2.MobileNetV2', + 'keras.applications.MobileNetV2')(MobileNetV2) +tf_export('keras.applications.mobilenet_v2.preprocess_input')(preprocess_input) diff --git a/tensorflow/python/keras/applications/nasnet.py b/tensorflow/python/keras/applications/nasnet.py index ff79b3a057..26ff5db53f 100644 --- a/tensorflow/python/keras/applications/nasnet.py +++ b/tensorflow/python/keras/applications/nasnet.py @@ -12,784 +12,23 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== -# pylint: disable=line-too-long # pylint: disable=invalid-name -# pylint: disable=unused-import """NASNet-A models for Keras. - -NASNet refers to Neural Architecture Search Network, a family of models -that were designed automatically by learning the model architectures -directly on the dataset of interest. - -Here we consider NASNet-A, the highest performance model that was found -for the CIFAR-10 dataset, and then extended to ImageNet 2012 dataset, -obtaining state of the art performance on CIFAR-10 and ImageNet 2012. -Only the NASNet-A models, and their respective weights, which are suited -for ImageNet 2012 are provided. - -The below table describes the performance on ImageNet 2012: --------------------------------------------------------------------------------- - Architecture | Top-1 Acc | Top-5 Acc | Multiply-Adds | Params (M) --------------------------------------------------------------------------------- -| NASNet-A (4 @ 1056) | 74.0 % | 91.6 % | 564 M | 5.3 | -| NASNet-A (6 @ 4032) | 82.7 % | 96.2 % | 23.8 B | 88.9 | --------------------------------------------------------------------------------- - -References: - - [Learning Transferable Architectures for Scalable Image Recognition] - (https://arxiv.org/abs/1707.07012) """ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os - -from tensorflow.python.keras import backend as K -from tensorflow.python.keras.applications.imagenet_utils import _obtain_input_shape -from tensorflow.python.keras.applications.imagenet_utils import decode_predictions -from tensorflow.python.keras.applications.inception_v3 import preprocess_input -from tensorflow.python.keras.layers import Activation -from tensorflow.python.keras.layers import add -from tensorflow.python.keras.layers import AveragePooling2D -from tensorflow.python.keras.layers import BatchNormalization -from tensorflow.python.keras.layers import concatenate -from tensorflow.python.keras.layers import Conv2D -from tensorflow.python.keras.layers import Cropping2D -from tensorflow.python.keras.layers import Dense -from tensorflow.python.keras.layers import GlobalAveragePooling2D -from tensorflow.python.keras.layers import GlobalMaxPooling2D -from tensorflow.python.keras.layers import Input -from tensorflow.python.keras.layers import MaxPooling2D -from tensorflow.python.keras.layers import SeparableConv2D -from tensorflow.python.keras.layers import ZeroPadding2D -from tensorflow.python.keras.models import Model -from tensorflow.python.keras.utils import layer_utils -from tensorflow.python.keras.utils.data_utils import get_file -from tensorflow.python.platform import tf_logging as logging +from keras_applications import nasnet from tensorflow.python.util.tf_export import tf_export +NASNetMobile = nasnet.NASNetMobile +NASNetLarge = nasnet.NASNetLarge +decode_predictions = nasnet.decode_predictions +preprocess_input = nasnet.preprocess_input -NASNET_MOBILE_WEIGHT_PATH = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.8/NASNet-mobile.h5' -NASNET_MOBILE_WEIGHT_PATH_NO_TOP = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.8/NASNet-mobile-no-top.h5' -NASNET_LARGE_WEIGHT_PATH = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.8/NASNet-large.h5' -NASNET_LARGE_WEIGHT_PATH_NO_TOP = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.8/NASNet-large-no-top.h5' - - -def NASNet(input_shape=None, - penultimate_filters=4032, - num_blocks=6, - stem_block_filters=96, - skip_reduction=True, - filter_multiplier=2, - include_top=True, - weights=None, - input_tensor=None, - pooling=None, - classes=1000, - default_size=None): - """Instantiates a NASNet model. - - Note that only TensorFlow is supported for now, - therefore it only works with the data format - `image_data_format='channels_last'` in your Keras config - at `~/.keras/keras.json`. - - Arguments: - input_shape: Optional shape tuple, the input shape - is by default `(331, 331, 3)` for NASNetLarge and - `(224, 224, 3)` for NASNetMobile. - It should have exactly 3 inputs channels, - and width and height should be no smaller than 32. - E.g. `(224, 224, 3)` would be one valid value. - penultimate_filters: Number of filters in the penultimate layer. - NASNet models use the notation `NASNet (N @ P)`, where: - - N is the number of blocks - - P is the number of penultimate filters - num_blocks: Number of repeated blocks of the NASNet model. - NASNet models use the notation `NASNet (N @ P)`, where: - - N is the number of blocks - - P is the number of penultimate filters - stem_block_filters: Number of filters in the initial stem block - skip_reduction: Whether to skip the reduction step at the tail - end of the network. Set to `False` for CIFAR models. - filter_multiplier: Controls the width of the network. - - If `filter_multiplier` < 1.0, proportionally decreases the number - of filters in each layer. - - If `filter_multiplier` > 1.0, proportionally increases the number - of filters in each layer. - - If `filter_multiplier` = 1, default number of filters from the - paper are used at each layer. - include_top: Whether to include the fully-connected - layer at the top of the network. - weights: `None` (random initialization) or - `imagenet` (ImageNet weights) - input_tensor: Optional Keras tensor (i.e. output of - `layers.Input()`) - to use as image input for the model. - pooling: Optional pooling mode for feature extraction - when `include_top` is `False`. - - `None` means that the output of the model - will be the 4D tensor output of the - last convolutional layer. - - `avg` means that global average pooling - will be applied to the output of the - last convolutional layer, and thus - the output of the model will be a - 2D tensor. - - `max` means that global max pooling will - be applied. - classes: Optional number of classes to classify images - into, only to be specified if `include_top` is True, and - if no `weights` argument is specified. - default_size: Specifies the default image size of the model - - Returns: - A Keras model instance. - - Raises: - ValueError: In case of invalid argument for `weights`, - invalid input shape or invalid `penultimate_filters` value. - RuntimeError: If attempting to run this model with a - backend that does not support separable convolutions. - """ - if K.backend() != 'tensorflow': - raise RuntimeError('Only Tensorflow backend is currently supported, ' - 'as other backends do not support ' - 'separable convolution.') - - if not (weights in {'imagenet', None} or os.path.exists(weights)): - raise ValueError('The `weights` argument should be either ' - '`None` (random initialization), `imagenet` ' - '(pre-training on ImageNet), ' - 'or the path to the weights file to be loaded.') - - if weights == 'imagenet' and include_top and classes != 1000: - raise ValueError('If using `weights` as ImageNet with `include_top` ' - 'as true, `classes` should be 1000') - - if (isinstance(input_shape, tuple) and None in input_shape and - weights == 'imagenet'): - raise ValueError('When specifying the input shape of a NASNet' - ' and loading `ImageNet` weights, ' - 'the input_shape argument must be static ' - '(no None entries). Got: `input_shape=' + - str(input_shape) + '`.') - - if default_size is None: - default_size = 331 - - # Determine proper input shape and default size. - input_shape = _obtain_input_shape( - input_shape, - default_size=default_size, - min_size=32, - data_format=K.image_data_format(), - require_flatten=False, - weights=weights) - - if K.image_data_format() != 'channels_last': - logging.warning('The NASNet family of models is only available ' - 'for the input data format "channels_last" ' - '(width, height, channels). ' - 'However your settings specify the default ' - 'data format "channels_first" (channels, width, height).' - ' You should set `image_data_format="channels_last"` ' - 'in your Keras config located at ~/.keras/keras.json. ' - 'The model being returned right now will expect inputs ' - 'to follow the "channels_last" data format.') - K.set_image_data_format('channels_last') - old_data_format = 'channels_first' - else: - old_data_format = None - - if input_tensor is None: - img_input = Input(shape=input_shape) - else: - if not K.is_keras_tensor(input_tensor): - img_input = Input(tensor=input_tensor, shape=input_shape) - else: - img_input = input_tensor - - if penultimate_filters % 24 != 0: - raise ValueError( - 'For NASNet-A models, the value of `penultimate_filters` ' - 'needs to be divisible by 24. Current value: %d' % penultimate_filters) - - channel_dim = 1 if K.image_data_format() == 'channels_first' else -1 - filters = penultimate_filters // 24 - - if not skip_reduction: - x = Conv2D( - stem_block_filters, (3, 3), - strides=(2, 2), - padding='valid', - use_bias=False, - name='stem_conv1', - kernel_initializer='he_normal')( - img_input) - else: - x = Conv2D( - stem_block_filters, (3, 3), - strides=(1, 1), - padding='same', - use_bias=False, - name='stem_conv1', - kernel_initializer='he_normal')( - img_input) - - x = BatchNormalization( - axis=channel_dim, momentum=0.9997, epsilon=1e-3, name='stem_bn1')( - x) - - p = None - if not skip_reduction: # imagenet / mobile mode - x, p = _reduction_a_cell( - x, p, filters // (filter_multiplier**2), block_id='stem_1') - x, p = _reduction_a_cell( - x, p, filters // filter_multiplier, block_id='stem_2') - - for i in range(num_blocks): - x, p = _normal_a_cell(x, p, filters, block_id='%d' % (i)) - - x, p0 = _reduction_a_cell( - x, p, filters * filter_multiplier, block_id='reduce_%d' % (num_blocks)) - - p = p0 if not skip_reduction else p - - for i in range(num_blocks): - x, p = _normal_a_cell( - x, p, filters * filter_multiplier, block_id='%d' % (num_blocks + i + 1)) - - x, p0 = _reduction_a_cell( - x, - p, - filters * filter_multiplier**2, - block_id='reduce_%d' % (2 * num_blocks)) - - p = p0 if not skip_reduction else p - - for i in range(num_blocks): - x, p = _normal_a_cell( - x, - p, - filters * filter_multiplier**2, - block_id='%d' % (2 * num_blocks + i + 1)) - - x = Activation('relu')(x) - - if include_top: - x = GlobalAveragePooling2D()(x) - x = Dense(classes, activation='softmax', name='predictions')(x) - else: - if pooling == 'avg': - x = GlobalAveragePooling2D()(x) - elif pooling == 'max': - x = GlobalMaxPooling2D()(x) - - # Ensure that the model takes into account - # any potential predecessors of `input_tensor`. - if input_tensor is not None: - inputs = layer_utils.get_source_inputs(input_tensor) - else: - inputs = img_input - - model = Model(inputs, x, name='NASNet') - - # load weights - if weights == 'imagenet': - if default_size == 224: # mobile version - if include_top: - weight_path = NASNET_MOBILE_WEIGHT_PATH - model_name = 'nasnet_mobile.h5' - else: - weight_path = NASNET_MOBILE_WEIGHT_PATH_NO_TOP - model_name = 'nasnet_mobile_no_top.h5' - - weights_file = get_file(model_name, weight_path, cache_subdir='models') - model.load_weights(weights_file) - - elif default_size == 331: # large version - if include_top: - weight_path = NASNET_LARGE_WEIGHT_PATH - model_name = 'nasnet_large.h5' - else: - weight_path = NASNET_LARGE_WEIGHT_PATH_NO_TOP - model_name = 'nasnet_large_no_top.h5' - - weights_file = get_file(model_name, weight_path, cache_subdir='models') - model.load_weights(weights_file) - else: - raise ValueError('ImageNet weights can only be loaded with NASNetLarge' - ' or NASNetMobile') - elif weights is not None: - model.load_weights(weights) - - if old_data_format: - K.set_image_data_format(old_data_format) - - return model - - -@tf_export('keras.applications.NASNetLarge', - 'keras.applications.nasnet.NASNetLarge') -def NASNetLarge(input_shape=None, - include_top=True, - weights='imagenet', - input_tensor=None, - pooling=None, - classes=1000): - """Instantiates a NASNet model in ImageNet mode. - - Note that only TensorFlow is supported for now, - therefore it only works with the data format - `image_data_format='channels_last'` in your Keras config - at `~/.keras/keras.json`. - - Arguments: - input_shape: Optional shape tuple, only to be specified - if `include_top` is False (otherwise the input shape - has to be `(331, 331, 3)` for NASNetLarge. - It should have exactly 3 inputs channels, - and width and height should be no smaller than 32. - E.g. `(224, 224, 3)` would be one valid value. - include_top: Whether to include the fully-connected - layer at the top of the network. - weights: `None` (random initialization) or - `imagenet` (ImageNet weights) - input_tensor: Optional Keras tensor (i.e. output of - `layers.Input()`) - to use as image input for the model. - pooling: Optional pooling mode for feature extraction - when `include_top` is `False`. - - `None` means that the output of the model - will be the 4D tensor output of the - last convolutional layer. - - `avg` means that global average pooling - will be applied to the output of the - last convolutional layer, and thus - the output of the model will be a - 2D tensor. - - `max` means that global max pooling will - be applied. - classes: Optional number of classes to classify images - into, only to be specified if `include_top` is True, and - if no `weights` argument is specified. - - Returns: - A Keras model instance. - - Raises: - ValueError: in case of invalid argument for `weights`, - or invalid input shape. - RuntimeError: If attempting to run this model with a - backend that does not support separable convolutions. - """ - return NASNet( - input_shape, - penultimate_filters=4032, - num_blocks=6, - stem_block_filters=96, - skip_reduction=False, - filter_multiplier=2, - include_top=include_top, - weights=weights, - input_tensor=input_tensor, - pooling=pooling, - classes=classes, - default_size=331) - - -@tf_export('keras.applications.NASNetMobile', - 'keras.applications.nasnet.NASNetMobile') -def NASNetMobile(input_shape=None, - include_top=True, - weights='imagenet', - input_tensor=None, - pooling=None, - classes=1000): - """Instantiates a Mobile NASNet model in ImageNet mode. - - Note that only TensorFlow is supported for now, - therefore it only works with the data format - `image_data_format='channels_last'` in your Keras config - at `~/.keras/keras.json`. - - Arguments: - input_shape: Optional shape tuple, only to be specified - if `include_top` is False (otherwise the input shape - has to be `(224, 224, 3)` for NASNetMobile - It should have exactly 3 inputs channels, - and width and height should be no smaller than 32. - E.g. `(224, 224, 3)` would be one valid value. - include_top: Whether to include the fully-connected - layer at the top of the network. - weights: `None` (random initialization) or - `imagenet` (ImageNet weights) - input_tensor: Optional Keras tensor (i.e. output of - `layers.Input()`) - to use as image input for the model. - pooling: Optional pooling mode for feature extraction - when `include_top` is `False`. - - `None` means that the output of the model - will be the 4D tensor output of the - last convolutional layer. - - `avg` means that global average pooling - will be applied to the output of the - last convolutional layer, and thus - the output of the model will be a - 2D tensor. - - `max` means that global max pooling will - be applied. - classes: Optional number of classes to classify images - into, only to be specified if `include_top` is True, and - if no `weights` argument is specified. - - Returns: - A Keras model instance. - - Raises: - ValueError: In case of invalid argument for `weights`, - or invalid input shape. - RuntimeError: If attempting to run this model with a - backend that does not support separable convolutions. - """ - return NASNet( - input_shape, - penultimate_filters=1056, - num_blocks=4, - stem_block_filters=32, - skip_reduction=False, - filter_multiplier=2, - include_top=include_top, - weights=weights, - input_tensor=input_tensor, - pooling=pooling, - classes=classes, - default_size=224) - - -def _separable_conv_block(ip, - filters, - kernel_size=(3, 3), - strides=(1, 1), - block_id=None): - """Adds 2 blocks of [relu-separable conv-batchnorm]. - - Arguments: - ip: Input tensor - filters: Number of output filters per layer - kernel_size: Kernel size of separable convolutions - strides: Strided convolution for downsampling - block_id: String block_id - - Returns: - A Keras tensor - """ - channel_dim = 1 if K.image_data_format() == 'channels_first' else -1 - - with K.name_scope('separable_conv_block_%s' % block_id): - x = Activation('relu')(ip) - x = SeparableConv2D( - filters, - kernel_size, - strides=strides, - name='separable_conv_1_%s' % block_id, - padding='same', - use_bias=False, - kernel_initializer='he_normal')( - x) - x = BatchNormalization( - axis=channel_dim, - momentum=0.9997, - epsilon=1e-3, - name='separable_conv_1_bn_%s' % (block_id))( - x) - x = Activation('relu')(x) - x = SeparableConv2D( - filters, - kernel_size, - name='separable_conv_2_%s' % block_id, - padding='same', - use_bias=False, - kernel_initializer='he_normal')( - x) - x = BatchNormalization( - axis=channel_dim, - momentum=0.9997, - epsilon=1e-3, - name='separable_conv_2_bn_%s' % (block_id))( - x) - return x - - -def _adjust_block(p, ip, filters, block_id=None): - """Adjusts the input `previous path` to match the shape of the `input`. - - Used in situations where the output number of filters needs to be changed. - - Arguments: - p: Input tensor which needs to be modified - ip: Input tensor whose shape needs to be matched - filters: Number of output filters to be matched - block_id: String block_id - - Returns: - Adjusted Keras tensor - """ - channel_dim = 1 if K.image_data_format() == 'channels_first' else -1 - img_dim = 2 if K.image_data_format() == 'channels_first' else -2 - - ip_shape = K.int_shape(ip) - - if p is not None: - p_shape = K.int_shape(p) - - with K.name_scope('adjust_block'): - if p is None: - p = ip - - elif p_shape[img_dim] != ip_shape[img_dim]: - with K.name_scope('adjust_reduction_block_%s' % block_id): - p = Activation('relu', name='adjust_relu_1_%s' % block_id)(p) - - p1 = AveragePooling2D( - (1, 1), - strides=(2, 2), - padding='valid', - name='adjust_avg_pool_1_%s' % block_id)( - p) - p1 = Conv2D( - filters // 2, (1, 1), - padding='same', - use_bias=False, - name='adjust_conv_1_%s' % block_id, - kernel_initializer='he_normal')( - p1) - - p2 = ZeroPadding2D(padding=((0, 1), (0, 1)))(p) - p2 = Cropping2D(cropping=((1, 0), (1, 0)))(p2) - p2 = AveragePooling2D( - (1, 1), - strides=(2, 2), - padding='valid', - name='adjust_avg_pool_2_%s' % block_id)( - p2) - p2 = Conv2D( - filters // 2, (1, 1), - padding='same', - use_bias=False, - name='adjust_conv_2_%s' % block_id, - kernel_initializer='he_normal')( - p2) - - p = concatenate([p1, p2], axis=channel_dim) - p = BatchNormalization( - axis=channel_dim, - momentum=0.9997, - epsilon=1e-3, - name='adjust_bn_%s' % block_id)( - p) - - elif p_shape[channel_dim] != filters: - with K.name_scope('adjust_projection_block_%s' % block_id): - p = Activation('relu')(p) - p = Conv2D( - filters, (1, 1), - strides=(1, 1), - padding='same', - name='adjust_conv_projection_%s' % block_id, - use_bias=False, - kernel_initializer='he_normal')( - p) - p = BatchNormalization( - axis=channel_dim, - momentum=0.9997, - epsilon=1e-3, - name='adjust_bn_%s' % block_id)( - p) - return p - - -def _normal_a_cell(ip, p, filters, block_id=None): - """Adds a Normal cell for NASNet-A (Fig. 4 in the paper). - - Arguments: - ip: Input tensor `x` - p: Input tensor `p` - filters: Number of output filters - block_id: String block_id - - Returns: - A Keras tensor - """ - channel_dim = 1 if K.image_data_format() == 'channels_first' else -1 - - with K.name_scope('normal_A_block_%s' % block_id): - p = _adjust_block(p, ip, filters, block_id) - - h = Activation('relu')(ip) - h = Conv2D( - filters, (1, 1), - strides=(1, 1), - padding='same', - name='normal_conv_1_%s' % block_id, - use_bias=False, - kernel_initializer='he_normal')( - h) - h = BatchNormalization( - axis=channel_dim, - momentum=0.9997, - epsilon=1e-3, - name='normal_bn_1_%s' % block_id)( - h) - - with K.name_scope('block_1'): - x1_1 = _separable_conv_block( - h, filters, kernel_size=(5, 5), block_id='normal_left1_%s' % block_id) - x1_2 = _separable_conv_block( - p, filters, block_id='normal_right1_%s' % block_id) - x1 = add([x1_1, x1_2], name='normal_add_1_%s' % block_id) - - with K.name_scope('block_2'): - x2_1 = _separable_conv_block( - p, filters, (5, 5), block_id='normal_left2_%s' % block_id) - x2_2 = _separable_conv_block( - p, filters, (3, 3), block_id='normal_right2_%s' % block_id) - x2 = add([x2_1, x2_2], name='normal_add_2_%s' % block_id) - - with K.name_scope('block_3'): - x3 = AveragePooling2D( - (3, 3), - strides=(1, 1), - padding='same', - name='normal_left3_%s' % (block_id))( - h) - x3 = add([x3, p], name='normal_add_3_%s' % block_id) - - with K.name_scope('block_4'): - x4_1 = AveragePooling2D( - (3, 3), - strides=(1, 1), - padding='same', - name='normal_left4_%s' % (block_id))( - p) - x4_2 = AveragePooling2D( - (3, 3), - strides=(1, 1), - padding='same', - name='normal_right4_%s' % (block_id))( - p) - x4 = add([x4_1, x4_2], name='normal_add_4_%s' % block_id) - - with K.name_scope('block_5'): - x5 = _separable_conv_block( - h, filters, block_id='normal_left5_%s' % block_id) - x5 = add([x5, h], name='normal_add_5_%s' % block_id) - - x = concatenate( - [p, x1, x2, x3, x4, x5], - axis=channel_dim, - name='normal_concat_%s' % block_id) - return x, ip - - -def _reduction_a_cell(ip, p, filters, block_id=None): - """Adds a Reduction cell for NASNet-A (Fig. 4 in the paper). - - Arguments: - ip: Input tensor `x` - p: Input tensor `p` - filters: Number of output filters - block_id: String block_id - - Returns: - A Keras tensor - """ - channel_dim = 1 if K.image_data_format() == 'channels_first' else -1 - - with K.name_scope('reduction_A_block_%s' % block_id): - p = _adjust_block(p, ip, filters, block_id) - - h = Activation('relu')(ip) - h = Conv2D( - filters, (1, 1), - strides=(1, 1), - padding='same', - name='reduction_conv_1_%s' % block_id, - use_bias=False, - kernel_initializer='he_normal')( - h) - h = BatchNormalization( - axis=channel_dim, - momentum=0.9997, - epsilon=1e-3, - name='reduction_bn_1_%s' % block_id)( - h) - - with K.name_scope('block_1'): - x1_1 = _separable_conv_block( - h, - filters, (5, 5), - strides=(2, 2), - block_id='reduction_left1_%s' % block_id) - x1_2 = _separable_conv_block( - p, - filters, (7, 7), - strides=(2, 2), - block_id='reduction_1_%s' % block_id) - x1 = add([x1_1, x1_2], name='reduction_add_1_%s' % block_id) - - with K.name_scope('block_2'): - x2_1 = MaxPooling2D( - (3, 3), - strides=(2, 2), - padding='same', - name='reduction_left2_%s' % block_id)( - h) - x2_2 = _separable_conv_block( - p, - filters, (7, 7), - strides=(2, 2), - block_id='reduction_right2_%s' % block_id) - x2 = add([x2_1, x2_2], name='reduction_add_2_%s' % block_id) - - with K.name_scope('block_3'): - x3_1 = AveragePooling2D( - (3, 3), - strides=(2, 2), - padding='same', - name='reduction_left3_%s' % block_id)( - h) - x3_2 = _separable_conv_block( - p, - filters, (5, 5), - strides=(2, 2), - block_id='reduction_right3_%s' % block_id) - x3 = add([x3_1, x3_2], name='reduction_add3_%s' % block_id) - - with K.name_scope('block_4'): - x4 = AveragePooling2D( - (3, 3), - strides=(1, 1), - padding='same', - name='reduction_left4_%s' % block_id)( - x1) - x4 = add([x2, x4]) - - with K.name_scope('block_5'): - x5_1 = _separable_conv_block( - x1, filters, (3, 3), block_id='reduction_left4_%s' % block_id) - x5_2 = MaxPooling2D( - (3, 3), - strides=(2, 2), - padding='same', - name='reduction_right5_%s' % block_id)( - h) - x5 = add([x5_1, x5_2], name='reduction_add4_%s' % block_id) - - x = concatenate( - [x2, x3, x4, x5], - axis=channel_dim, - name='reduction_concat_%s' % block_id) - return x, ip +tf_export('keras.applications.nasnet.NASNetMobile', + 'keras.applications.NASNetMobile')(NASNetMobile) +tf_export('keras.applications.nasnet.NASNetLarge', + 'keras.applications.NASNetLarge')(NASNetLarge) +tf_export('keras.applications.nasnet.preprocess_input')(preprocess_input) diff --git a/tensorflow/python/keras/applications/resnet50.py b/tensorflow/python/keras/applications/resnet50.py index 6afc086812..4d804a3c44 100644 --- a/tensorflow/python/keras/applications/resnet50.py +++ b/tensorflow/python/keras/applications/resnet50.py @@ -13,291 +13,18 @@ # limitations under the License. # ============================================================================== # pylint: disable=invalid-name -# pylint: disable=unused-import """ResNet50 model for Keras. - -# Reference: - -- [Deep Residual Learning for Image -Recognition](https://arxiv.org/abs/1512.03385) - -Adapted from code contributed by BigMoyan. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os - -from tensorflow.python.keras import backend as K -from tensorflow.python.keras import layers -from tensorflow.python.keras.applications.imagenet_utils import _obtain_input_shape -from tensorflow.python.keras.applications.imagenet_utils import decode_predictions -from tensorflow.python.keras.applications.imagenet_utils import preprocess_input -from tensorflow.python.keras.layers import Activation -from tensorflow.python.keras.layers import AveragePooling2D -from tensorflow.python.keras.layers import BatchNormalization -from tensorflow.python.keras.layers import Conv2D -from tensorflow.python.keras.layers import Dense -from tensorflow.python.keras.layers import Flatten -from tensorflow.python.keras.layers import GlobalAveragePooling2D -from tensorflow.python.keras.layers import GlobalMaxPooling2D -from tensorflow.python.keras.layers import Input -from tensorflow.python.keras.layers import MaxPooling2D -from tensorflow.python.keras.layers import ZeroPadding2D -from tensorflow.python.keras.models import Model -from tensorflow.python.keras.utils import layer_utils -from tensorflow.python.keras.utils.data_utils import get_file -from tensorflow.python.platform import tf_logging as logging +from keras_applications import resnet50 from tensorflow.python.util.tf_export import tf_export +ResNet50 = resnet50.ResNet50 +decode_predictions = resnet50.decode_predictions +preprocess_input = resnet50.preprocess_input -WEIGHTS_PATH = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.2/resnet50_weights_tf_dim_ordering_tf_kernels.h5' -WEIGHTS_PATH_NO_TOP = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.2/resnet50_weights_tf_dim_ordering_tf_kernels_notop.h5' - - -def identity_block(input_tensor, kernel_size, filters, stage, block): - """The identity block is the block that has no conv layer at shortcut. - - Arguments: - input_tensor: input tensor - kernel_size: default 3, the kernel size of middle conv layer at main path - filters: list of integers, the filters of 3 conv layer at main path - stage: integer, current stage label, used for generating layer names - block: 'a','b'..., current block label, used for generating layer names - - Returns: - Output tensor for the block. - """ - filters1, filters2, filters3 = filters - if K.image_data_format() == 'channels_last': - bn_axis = 3 - else: - bn_axis = 1 - conv_name_base = 'res' + str(stage) + block + '_branch' - bn_name_base = 'bn' + str(stage) + block + '_branch' - - x = Conv2D(filters1, (1, 1), name=conv_name_base + '2a')(input_tensor) - x = BatchNormalization(axis=bn_axis, name=bn_name_base + '2a')(x) - x = Activation('relu')(x) - - x = Conv2D( - filters2, kernel_size, padding='same', name=conv_name_base + '2b')( - x) - x = BatchNormalization(axis=bn_axis, name=bn_name_base + '2b')(x) - x = Activation('relu')(x) - - x = Conv2D(filters3, (1, 1), name=conv_name_base + '2c')(x) - x = BatchNormalization(axis=bn_axis, name=bn_name_base + '2c')(x) - - x = layers.add([x, input_tensor]) - x = Activation('relu')(x) - return x - - -def conv_block(input_tensor, kernel_size, filters, stage, block, strides=(2, - 2)): - """A block that has a conv layer at shortcut. - - Arguments: - input_tensor: input tensor - kernel_size: default 3, the kernel size of middle conv layer at main path - filters: list of integers, the filters of 3 conv layer at main path - stage: integer, current stage label, used for generating layer names - block: 'a','b'..., current block label, used for generating layer names - strides: Strides for the first conv layer in the block. - - Returns: - Output tensor for the block. - - Note that from stage 3, - the first conv layer at main path is with strides=(2, 2) - And the shortcut should have strides=(2, 2) as well - """ - filters1, filters2, filters3 = filters - if K.image_data_format() == 'channels_last': - bn_axis = 3 - else: - bn_axis = 1 - conv_name_base = 'res' + str(stage) + block + '_branch' - bn_name_base = 'bn' + str(stage) + block + '_branch' - - x = Conv2D( - filters1, (1, 1), strides=strides, name=conv_name_base + '2a')( - input_tensor) - x = BatchNormalization(axis=bn_axis, name=bn_name_base + '2a')(x) - x = Activation('relu')(x) - - x = Conv2D( - filters2, kernel_size, padding='same', name=conv_name_base + '2b')( - x) - x = BatchNormalization(axis=bn_axis, name=bn_name_base + '2b')(x) - x = Activation('relu')(x) - - x = Conv2D(filters3, (1, 1), name=conv_name_base + '2c')(x) - x = BatchNormalization(axis=bn_axis, name=bn_name_base + '2c')(x) - - shortcut = Conv2D( - filters3, (1, 1), strides=strides, name=conv_name_base + '1')( - input_tensor) - shortcut = BatchNormalization(axis=bn_axis, name=bn_name_base + '1')(shortcut) - - x = layers.add([x, shortcut]) - x = Activation('relu')(x) - return x - - -@tf_export('keras.applications.ResNet50', - 'keras.applications.resnet50.ResNet50') -def ResNet50(include_top=True, - weights='imagenet', - input_tensor=None, - input_shape=None, - pooling=None, - classes=1000): - """Instantiates the ResNet50 architecture. - - Optionally loads weights pre-trained - on ImageNet. Note that when using TensorFlow, - for best performance you should set - `image_data_format='channels_last'` in your Keras config - at ~/.keras/keras.json. - - The model and the weights are compatible with both - TensorFlow and Theano. The data format - convention used by the model is the one - specified in your Keras config file. - - Arguments: - include_top: whether to include the fully-connected - layer at the top of the network. - weights: one of `None` (random initialization), - 'imagenet' (pre-training on ImageNet), - or the path to the weights file to be loaded. - input_tensor: optional Keras tensor (i.e. output of `layers.Input()`) - to use as image input for the model. - input_shape: optional shape tuple, only to be specified - if `include_top` is False (otherwise the input shape - has to be `(224, 224, 3)` (with `channels_last` data format) - or `(3, 224, 224)` (with `channels_first` data format). - It should have exactly 3 inputs channels, - and width and height should be no smaller than 197. - E.g. `(200, 200, 3)` would be one valid value. - pooling: Optional pooling mode for feature extraction - when `include_top` is `False`. - - `None` means that the output of the model will be - the 4D tensor output of the - last convolutional layer. - - `avg` means that global average pooling - will be applied to the output of the - last convolutional layer, and thus - the output of the model will be a 2D tensor. - - `max` means that global max pooling will - be applied. - classes: optional number of classes to classify images - into, only to be specified if `include_top` is True, and - if no `weights` argument is specified. - - Returns: - A Keras model instance. - - Raises: - ValueError: in case of invalid argument for `weights`, - or invalid input shape. - """ - if not (weights in {'imagenet', None} or os.path.exists(weights)): - raise ValueError('The `weights` argument should be either ' - '`None` (random initialization), `imagenet` ' - '(pre-training on ImageNet), ' - 'or the path to the weights file to be loaded.') - - if weights == 'imagenet' and include_top and classes != 1000: - raise ValueError('If using `weights` as imagenet with `include_top`' - ' as true, `classes` should be 1000') - - # Determine proper input shape - input_shape = _obtain_input_shape( - input_shape, - default_size=224, - min_size=197, - data_format=K.image_data_format(), - require_flatten=include_top, - weights=weights) - - if input_tensor is None: - img_input = Input(shape=input_shape) - else: - if not K.is_keras_tensor(input_tensor): - img_input = Input(tensor=input_tensor, shape=input_shape) - else: - img_input = input_tensor - if K.image_data_format() == 'channels_last': - bn_axis = 3 - else: - bn_axis = 1 - - x = Conv2D( - 64, (7, 7), strides=(2, 2), padding='same', name='conv1')(img_input) - x = BatchNormalization(axis=bn_axis, name='bn_conv1')(x) - x = Activation('relu')(x) - x = MaxPooling2D((3, 3), strides=(2, 2))(x) - - x = conv_block(x, 3, [64, 64, 256], stage=2, block='a', strides=(1, 1)) - x = identity_block(x, 3, [64, 64, 256], stage=2, block='b') - x = identity_block(x, 3, [64, 64, 256], stage=2, block='c') - - x = conv_block(x, 3, [128, 128, 512], stage=3, block='a') - x = identity_block(x, 3, [128, 128, 512], stage=3, block='b') - x = identity_block(x, 3, [128, 128, 512], stage=3, block='c') - x = identity_block(x, 3, [128, 128, 512], stage=3, block='d') - - x = conv_block(x, 3, [256, 256, 1024], stage=4, block='a') - x = identity_block(x, 3, [256, 256, 1024], stage=4, block='b') - x = identity_block(x, 3, [256, 256, 1024], stage=4, block='c') - x = identity_block(x, 3, [256, 256, 1024], stage=4, block='d') - x = identity_block(x, 3, [256, 256, 1024], stage=4, block='e') - x = identity_block(x, 3, [256, 256, 1024], stage=4, block='f') - - x = conv_block(x, 3, [512, 512, 2048], stage=5, block='a') - x = identity_block(x, 3, [512, 512, 2048], stage=5, block='b') - x = identity_block(x, 3, [512, 512, 2048], stage=5, block='c') - - x = AveragePooling2D((7, 7), name='avg_pool')(x) - - if include_top: - x = Flatten()(x) - x = Dense(classes, activation='softmax', name='fc1000')(x) - else: - if pooling == 'avg': - x = GlobalAveragePooling2D()(x) - elif pooling == 'max': - x = GlobalMaxPooling2D()(x) - - # Ensure that the model takes into account - # any potential predecessors of `input_tensor`. - if input_tensor is not None: - inputs = layer_utils.get_source_inputs(input_tensor) - else: - inputs = img_input - # Create model. - model = Model(inputs, x, name='resnet50') - - # load weights - if weights == 'imagenet': - if include_top: - weights_path = get_file( - 'resnet50_weights_tf_dim_ordering_tf_kernels.h5', - WEIGHTS_PATH, - cache_subdir='models', - md5_hash='a7b3fe01876f51b976af0dea6bc144eb') - else: - weights_path = get_file( - 'resnet50_weights_tf_dim_ordering_tf_kernels_notop.h5', - WEIGHTS_PATH_NO_TOP, - cache_subdir='models', - md5_hash='a268eb855778b3df3c7506639542a6af') - model.load_weights(weights_path) - elif weights is not None: - model.load_weights(weights) - - return model +tf_export('keras.applications.resnet50.ResNet50', + 'keras.applications.ResNet50')(ResNet50) diff --git a/tensorflow/python/keras/applications/vgg16.py b/tensorflow/python/keras/applications/vgg16.py index cef0230da9..c420d9b81e 100644 --- a/tensorflow/python/keras/applications/vgg16.py +++ b/tensorflow/python/keras/applications/vgg16.py @@ -13,217 +13,18 @@ # limitations under the License. # ============================================================================== # pylint: disable=invalid-name -# pylint: disable=unused-import """VGG16 model for Keras. - -# Reference - -- [Very Deep Convolutional Networks for Large-Scale Image -Recognition](https://arxiv.org/abs/1409.1556) - """ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os - -from tensorflow.python.keras import backend as K -from tensorflow.python.keras.applications.imagenet_utils import _obtain_input_shape -from tensorflow.python.keras.applications.imagenet_utils import decode_predictions -from tensorflow.python.keras.applications.imagenet_utils import preprocess_input -from tensorflow.python.keras.layers import Conv2D -from tensorflow.python.keras.layers import Dense -from tensorflow.python.keras.layers import Flatten -from tensorflow.python.keras.layers import GlobalAveragePooling2D -from tensorflow.python.keras.layers import GlobalMaxPooling2D -from tensorflow.python.keras.layers import Input -from tensorflow.python.keras.layers import MaxPooling2D -from tensorflow.python.keras.models import Model -from tensorflow.python.keras.utils import layer_utils -from tensorflow.python.keras.utils.data_utils import get_file -from tensorflow.python.platform import tf_logging as logging +from keras_applications import vgg16 from tensorflow.python.util.tf_export import tf_export +VGG16 = vgg16.VGG16 +decode_predictions = vgg16.decode_predictions +preprocess_input = vgg16.preprocess_input -WEIGHTS_PATH = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.1/vgg16_weights_tf_dim_ordering_tf_kernels.h5' -WEIGHTS_PATH_NO_TOP = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.1/vgg16_weights_tf_dim_ordering_tf_kernels_notop.h5' - - -@tf_export('keras.applications.VGG16', 'keras.applications.vgg16.VGG16') -def VGG16(include_top=True, - weights='imagenet', - input_tensor=None, - input_shape=None, - pooling=None, - classes=1000): - """Instantiates the VGG16 architecture. - - Optionally loads weights pre-trained - on ImageNet. Note that when using TensorFlow, - for best performance you should set - `image_data_format='channels_last'` in your Keras config - at ~/.keras/keras.json. - - The model and the weights are compatible with both - TensorFlow and Theano. The data format - convention used by the model is the one - specified in your Keras config file. - - Arguments: - include_top: whether to include the 3 fully-connected - layers at the top of the network. - weights: one of `None` (random initialization), - 'imagenet' (pre-training on ImageNet), - or the path to the weights file to be loaded. - input_tensor: optional Keras tensor (i.e. output of `layers.Input()`) - to use as image input for the model. - input_shape: optional shape tuple, only to be specified - if `include_top` is False (otherwise the input shape - has to be `(224, 224, 3)` (with `channels_last` data format) - or `(3, 224, 224)` (with `channels_first` data format). - It should have exactly 3 input channels, - and width and height should be no smaller than 48. - E.g. `(200, 200, 3)` would be one valid value. - pooling: Optional pooling mode for feature extraction - when `include_top` is `False`. - - `None` means that the output of the model will be - the 4D tensor output of the - last convolutional layer. - - `avg` means that global average pooling - will be applied to the output of the - last convolutional layer, and thus - the output of the model will be a 2D tensor. - - `max` means that global max pooling will - be applied. - classes: optional number of classes to classify images - into, only to be specified if `include_top` is True, and - if no `weights` argument is specified. - - Returns: - A Keras model instance. - - Raises: - ValueError: in case of invalid argument for `weights`, - or invalid input shape. - """ - if not (weights in {'imagenet', None} or os.path.exists(weights)): - raise ValueError('The `weights` argument should be either ' - '`None` (random initialization), `imagenet` ' - '(pre-training on ImageNet), ' - 'or the path to the weights file to be loaded.') - - if weights == 'imagenet' and include_top and classes != 1000: - raise ValueError('If using `weights` as imagenet with `include_top`' - ' as true, `classes` should be 1000') - # Determine proper input shape - input_shape = _obtain_input_shape( - input_shape, - default_size=224, - min_size=48, - data_format=K.image_data_format(), - require_flatten=include_top, - weights=weights) - - if input_tensor is None: - img_input = Input(shape=input_shape) - else: - if not K.is_keras_tensor(input_tensor): - img_input = Input(tensor=input_tensor, shape=input_shape) - else: - img_input = input_tensor - # Block 1 - x = Conv2D( - 64, (3, 3), activation='relu', padding='same', name='block1_conv1')( - img_input) - x = Conv2D( - 64, (3, 3), activation='relu', padding='same', name='block1_conv2')( - x) - x = MaxPooling2D((2, 2), strides=(2, 2), name='block1_pool')(x) - - # Block 2 - x = Conv2D( - 128, (3, 3), activation='relu', padding='same', name='block2_conv1')( - x) - x = Conv2D( - 128, (3, 3), activation='relu', padding='same', name='block2_conv2')( - x) - x = MaxPooling2D((2, 2), strides=(2, 2), name='block2_pool')(x) - - # Block 3 - x = Conv2D( - 256, (3, 3), activation='relu', padding='same', name='block3_conv1')( - x) - x = Conv2D( - 256, (3, 3), activation='relu', padding='same', name='block3_conv2')( - x) - x = Conv2D( - 256, (3, 3), activation='relu', padding='same', name='block3_conv3')( - x) - x = MaxPooling2D((2, 2), strides=(2, 2), name='block3_pool')(x) - - # Block 4 - x = Conv2D( - 512, (3, 3), activation='relu', padding='same', name='block4_conv1')( - x) - x = Conv2D( - 512, (3, 3), activation='relu', padding='same', name='block4_conv2')( - x) - x = Conv2D( - 512, (3, 3), activation='relu', padding='same', name='block4_conv3')( - x) - x = MaxPooling2D((2, 2), strides=(2, 2), name='block4_pool')(x) - - # Block 5 - x = Conv2D( - 512, (3, 3), activation='relu', padding='same', name='block5_conv1')( - x) - x = Conv2D( - 512, (3, 3), activation='relu', padding='same', name='block5_conv2')( - x) - x = Conv2D( - 512, (3, 3), activation='relu', padding='same', name='block5_conv3')( - x) - x = MaxPooling2D((2, 2), strides=(2, 2), name='block5_pool')(x) - - if include_top: - # Classification block - x = Flatten(name='flatten')(x) - x = Dense(4096, activation='relu', name='fc1')(x) - x = Dense(4096, activation='relu', name='fc2')(x) - x = Dense(classes, activation='softmax', name='predictions')(x) - else: - if pooling == 'avg': - x = GlobalAveragePooling2D()(x) - elif pooling == 'max': - x = GlobalMaxPooling2D()(x) - - # Ensure that the model takes into account - # any potential predecessors of `input_tensor`. - if input_tensor is not None: - inputs = layer_utils.get_source_inputs(input_tensor) - else: - inputs = img_input - # Create model. - model = Model(inputs, x, name='vgg16') - - # load weights - if weights == 'imagenet': - if include_top: - weights_path = get_file( - 'vgg16_weights_tf_dim_ordering_tf_kernels.h5', - WEIGHTS_PATH, - cache_subdir='models', - file_hash='64373286793e3c8b2b4e3219cbf3544b') - else: - weights_path = get_file( - 'vgg16_weights_tf_dim_ordering_tf_kernels_notop.h5', - WEIGHTS_PATH_NO_TOP, - cache_subdir='models', - file_hash='6d6bbae143d832006294945121d1f1fc') - model.load_weights(weights_path) - - elif weights is not None: - model.load_weights(weights) - - return model +tf_export('keras.applications.vgg16.VGG16', + 'keras.applications.VGG16')(VGG16) diff --git a/tensorflow/python/keras/applications/vgg19.py b/tensorflow/python/keras/applications/vgg19.py index c4031f5510..73d3d1d1c3 100644 --- a/tensorflow/python/keras/applications/vgg19.py +++ b/tensorflow/python/keras/applications/vgg19.py @@ -13,226 +13,18 @@ # limitations under the License. # ============================================================================== # pylint: disable=invalid-name -# pylint: disable=unused-import """VGG19 model for Keras. - -# Reference - -- [Very Deep Convolutional Networks for Large-Scale Image -Recognition](https://arxiv.org/abs/1409.1556) - """ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os - -from tensorflow.python.keras import backend as K -from tensorflow.python.keras.applications.imagenet_utils import _obtain_input_shape -from tensorflow.python.keras.applications.imagenet_utils import decode_predictions -from tensorflow.python.keras.applications.imagenet_utils import preprocess_input -from tensorflow.python.keras.layers import Conv2D -from tensorflow.python.keras.layers import Dense -from tensorflow.python.keras.layers import Flatten -from tensorflow.python.keras.layers import GlobalAveragePooling2D -from tensorflow.python.keras.layers import GlobalMaxPooling2D -from tensorflow.python.keras.layers import Input -from tensorflow.python.keras.layers import MaxPooling2D -from tensorflow.python.keras.models import Model -from tensorflow.python.keras.utils import layer_utils -from tensorflow.python.keras.utils.data_utils import get_file -from tensorflow.python.platform import tf_logging as logging +from keras_applications import vgg19 from tensorflow.python.util.tf_export import tf_export +VGG19 = vgg19.VGG19 +decode_predictions = vgg19.decode_predictions +preprocess_input = vgg19.preprocess_input -WEIGHTS_PATH = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.1/vgg19_weights_tf_dim_ordering_tf_kernels.h5' -WEIGHTS_PATH_NO_TOP = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.1/vgg19_weights_tf_dim_ordering_tf_kernels_notop.h5' - - -@tf_export('keras.applications.VGG19', 'keras.applications.vgg19.VGG19') -def VGG19(include_top=True, - weights='imagenet', - input_tensor=None, - input_shape=None, - pooling=None, - classes=1000): - """Instantiates the VGG19 architecture. - - Optionally loads weights pre-trained - on ImageNet. Note that when using TensorFlow, - for best performance you should set - `image_data_format='channels_last'` in your Keras config - at ~/.keras/keras.json. - - The model and the weights are compatible with both - TensorFlow and Theano. The data format - convention used by the model is the one - specified in your Keras config file. - - Arguments: - include_top: whether to include the 3 fully-connected - layers at the top of the network. - weights: one of `None` (random initialization), - 'imagenet' (pre-training on ImageNet), - or the path to the weights file to be loaded. - input_tensor: optional Keras tensor (i.e. output of `layers.Input()`) - to use as image input for the model. - input_shape: optional shape tuple, only to be specified - if `include_top` is False (otherwise the input shape - has to be `(224, 224, 3)` (with `channels_last` data format) - or `(3, 224, 224)` (with `channels_first` data format). - It should have exactly 3 inputs channels, - and width and height should be no smaller than 48. - E.g. `(200, 200, 3)` would be one valid value. - pooling: Optional pooling mode for feature extraction - when `include_top` is `False`. - - `None` means that the output of the model will be - the 4D tensor output of the - last convolutional layer. - - `avg` means that global average pooling - will be applied to the output of the - last convolutional layer, and thus - the output of the model will be a 2D tensor. - - `max` means that global max pooling will - be applied. - classes: optional number of classes to classify images - into, only to be specified if `include_top` is True, and - if no `weights` argument is specified. - - Returns: - A Keras model instance. - - Raises: - ValueError: in case of invalid argument for `weights`, - or invalid input shape. - """ - if not (weights in {'imagenet', None} or os.path.exists(weights)): - raise ValueError('The `weights` argument should be either ' - '`None` (random initialization), `imagenet` ' - '(pre-training on ImageNet), ' - 'or the path to the weights file to be loaded.') - - if weights == 'imagenet' and include_top and classes != 1000: - raise ValueError('If using `weights` as imagenet with `include_top`' - ' as true, `classes` should be 1000') - # Determine proper input shape - input_shape = _obtain_input_shape( - input_shape, - default_size=224, - min_size=48, - data_format=K.image_data_format(), - require_flatten=include_top, - weights=weights) - - if input_tensor is None: - img_input = Input(shape=input_shape) - else: - if not K.is_keras_tensor(input_tensor): - img_input = Input(tensor=input_tensor, shape=input_shape) - else: - img_input = input_tensor - # Block 1 - x = Conv2D( - 64, (3, 3), activation='relu', padding='same', name='block1_conv1')( - img_input) - x = Conv2D( - 64, (3, 3), activation='relu', padding='same', name='block1_conv2')( - x) - x = MaxPooling2D((2, 2), strides=(2, 2), name='block1_pool')(x) - - # Block 2 - x = Conv2D( - 128, (3, 3), activation='relu', padding='same', name='block2_conv1')( - x) - x = Conv2D( - 128, (3, 3), activation='relu', padding='same', name='block2_conv2')( - x) - x = MaxPooling2D((2, 2), strides=(2, 2), name='block2_pool')(x) - - # Block 3 - x = Conv2D( - 256, (3, 3), activation='relu', padding='same', name='block3_conv1')( - x) - x = Conv2D( - 256, (3, 3), activation='relu', padding='same', name='block3_conv2')( - x) - x = Conv2D( - 256, (3, 3), activation='relu', padding='same', name='block3_conv3')( - x) - x = Conv2D( - 256, (3, 3), activation='relu', padding='same', name='block3_conv4')( - x) - x = MaxPooling2D((2, 2), strides=(2, 2), name='block3_pool')(x) - - # Block 4 - x = Conv2D( - 512, (3, 3), activation='relu', padding='same', name='block4_conv1')( - x) - x = Conv2D( - 512, (3, 3), activation='relu', padding='same', name='block4_conv2')( - x) - x = Conv2D( - 512, (3, 3), activation='relu', padding='same', name='block4_conv3')( - x) - x = Conv2D( - 512, (3, 3), activation='relu', padding='same', name='block4_conv4')( - x) - x = MaxPooling2D((2, 2), strides=(2, 2), name='block4_pool')(x) - - # Block 5 - x = Conv2D( - 512, (3, 3), activation='relu', padding='same', name='block5_conv1')( - x) - x = Conv2D( - 512, (3, 3), activation='relu', padding='same', name='block5_conv2')( - x) - x = Conv2D( - 512, (3, 3), activation='relu', padding='same', name='block5_conv3')( - x) - x = Conv2D( - 512, (3, 3), activation='relu', padding='same', name='block5_conv4')( - x) - x = MaxPooling2D((2, 2), strides=(2, 2), name='block5_pool')(x) - - if include_top: - # Classification block - x = Flatten(name='flatten')(x) - x = Dense(4096, activation='relu', name='fc1')(x) - x = Dense(4096, activation='relu', name='fc2')(x) - x = Dense(classes, activation='softmax', name='predictions')(x) - else: - if pooling == 'avg': - x = GlobalAveragePooling2D()(x) - elif pooling == 'max': - x = GlobalMaxPooling2D()(x) - - # Ensure that the model takes into account - # any potential predecessors of `input_tensor`. - if input_tensor is not None: - inputs = layer_utils.get_source_inputs(input_tensor) - else: - inputs = img_input - # Create model. - model = Model(inputs, x, name='vgg19') - - # load weights - if weights == 'imagenet': - if include_top: - weights_path = get_file( - 'vgg19_weights_tf_dim_ordering_tf_kernels.h5', - WEIGHTS_PATH, - cache_subdir='models', - file_hash='cbe5617147190e668d6c5d5026f83318') - else: - weights_path = get_file( - 'vgg19_weights_tf_dim_ordering_tf_kernels_notop.h5', - WEIGHTS_PATH_NO_TOP, - cache_subdir='models', - file_hash='253f8cb515780f3b799900260a226db6') - model.load_weights(weights_path) - - elif weights is not None: - model.load_weights(weights) - - return model +tf_export('keras.applications.vgg19.VGG19', + 'keras.applications.VGG19')(VGG19) diff --git a/tensorflow/python/keras/applications/xception.py b/tensorflow/python/keras/applications/xception.py index 01397cfac2..5b221ac8e0 100644 --- a/tensorflow/python/keras/applications/xception.py +++ b/tensorflow/python/keras/applications/xception.py @@ -13,332 +13,19 @@ # limitations under the License. # ============================================================================== # pylint: disable=invalid-name -# pylint: disable=unused-import """Xception V1 model for Keras. - -On ImageNet, this model gets to a top-1 validation accuracy of 0.790 -and a top-5 validation accuracy of 0.945. - -Do note that the input image format for this model is different than for -the VGG16 and ResNet models (299x299 instead of 224x224), -and that the input preprocessing function -is also different (same as Inception V3). - -Also do note that this model is only available for the TensorFlow backend, -due to its reliance on `SeparableConvolution` layers. - -# Reference - -- [Xception: Deep Learning with Depthwise Separable -Convolutions](https://arxiv.org/abs/1610.02357) - """ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import os - -from tensorflow.python.keras import backend as K -from tensorflow.python.keras import layers -from tensorflow.python.keras.applications import imagenet_utils -from tensorflow.python.keras.applications.imagenet_utils import _obtain_input_shape -from tensorflow.python.keras.applications.imagenet_utils import decode_predictions -from tensorflow.python.keras.layers import Activation -from tensorflow.python.keras.layers import BatchNormalization -from tensorflow.python.keras.layers import Conv2D -from tensorflow.python.keras.layers import Dense -from tensorflow.python.keras.layers import GlobalAveragePooling2D -from tensorflow.python.keras.layers import GlobalMaxPooling2D -from tensorflow.python.keras.layers import Input -from tensorflow.python.keras.layers import MaxPooling2D -from tensorflow.python.keras.layers import SeparableConv2D -from tensorflow.python.keras.models import Model -from tensorflow.python.keras.utils import layer_utils -from tensorflow.python.keras.utils.data_utils import get_file -from tensorflow.python.platform import tf_logging as logging +from keras_applications import xception from tensorflow.python.util.tf_export import tf_export +Xception = xception.Xception +decode_predictions = xception.decode_predictions +preprocess_input = xception.preprocess_input -TF_WEIGHTS_PATH = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.4/xception_weights_tf_dim_ordering_tf_kernels.h5' -TF_WEIGHTS_PATH_NO_TOP = 'https://github.com/fchollet/deep-learning-models/releases/download/v0.4/xception_weights_tf_dim_ordering_tf_kernels_notop.h5' - - -@tf_export('keras.applications.Xception', - 'keras.applications.xception.Xception') -def Xception(include_top=True, - weights='imagenet', - input_tensor=None, - input_shape=None, - pooling=None, - classes=1000): - """Instantiates the Xception architecture. - - Optionally loads weights pre-trained - on ImageNet. This model is available for TensorFlow only, - and can only be used with inputs following the TensorFlow - data format `(width, height, channels)`. - You should set `image_data_format='channels_last'` in your Keras config - located at ~/.keras/keras.json. - - Note that the default input image size for this model is 299x299. - - Arguments: - include_top: whether to include the fully-connected - layer at the top of the network. - weights: one of `None` (random initialization), - 'imagenet' (pre-training on ImageNet), - or the path to the weights file to be loaded. - input_tensor: optional Keras tensor (i.e. output of `layers.Input()`) - to use as image input for the model. - input_shape: optional shape tuple, only to be specified - if `include_top` is False (otherwise the input shape - has to be `(299, 299, 3)`. - It should have exactly 3 inputs channels, - and width and height should be no smaller than 71. - E.g. `(150, 150, 3)` would be one valid value. - pooling: Optional pooling mode for feature extraction - when `include_top` is `False`. - - `None` means that the output of the model will be - the 4D tensor output of the - last convolutional layer. - - `avg` means that global average pooling - will be applied to the output of the - last convolutional layer, and thus - the output of the model will be a 2D tensor. - - `max` means that global max pooling will - be applied. - classes: optional number of classes to classify images - into, only to be specified if `include_top` is True, and - if no `weights` argument is specified. - - Returns: - A Keras model instance. - - Raises: - ValueError: in case of invalid argument for `weights`, - or invalid input shape. - RuntimeError: If attempting to run this model with a - backend that does not support separable convolutions. - """ - if not (weights in {'imagenet', None} or os.path.exists(weights)): - raise ValueError('The `weights` argument should be either ' - '`None` (random initialization), `imagenet` ' - '(pre-training on ImageNet), ' - 'or the path to the weights file to be loaded.') - - if weights == 'imagenet' and include_top and classes != 1000: - raise ValueError('If using `weights` as imagenet with `include_top`' - ' as true, `classes` should be 1000') - - if K.image_data_format() != 'channels_last': - logging.warning( - 'The Xception model is only available for the ' - 'input data format "channels_last" ' - '(width, height, channels). ' - 'However your settings specify the default ' - 'data format "channels_first" (channels, width, height). ' - 'You should set `image_data_format="channels_last"` in your Keras ' - 'config located at ~/.keras/keras.json. ' - 'The model being returned right now will expect inputs ' - 'to follow the "channels_last" data format.') - K.set_image_data_format('channels_last') - old_data_format = 'channels_first' - else: - old_data_format = None - - # Determine proper input shape - input_shape = _obtain_input_shape( - input_shape, - default_size=299, - min_size=71, - data_format=K.image_data_format(), - require_flatten=False, - weights=weights) - - if input_tensor is None: - img_input = Input(shape=input_shape) - else: - if not K.is_keras_tensor(input_tensor): - img_input = Input(tensor=input_tensor, shape=input_shape) - else: - img_input = input_tensor - - x = Conv2D( - 32, (3, 3), strides=(2, 2), use_bias=False, name='block1_conv1')( - img_input) - x = BatchNormalization(name='block1_conv1_bn')(x) - x = Activation('relu', name='block1_conv1_act')(x) - x = Conv2D(64, (3, 3), use_bias=False, name='block1_conv2')(x) - x = BatchNormalization(name='block1_conv2_bn')(x) - x = Activation('relu', name='block1_conv2_act')(x) - - residual = Conv2D( - 128, (1, 1), strides=(2, 2), padding='same', use_bias=False)( - x) - residual = BatchNormalization()(residual) - - x = SeparableConv2D( - 128, (3, 3), padding='same', use_bias=False, name='block2_sepconv1')( - x) - x = BatchNormalization(name='block2_sepconv1_bn')(x) - x = Activation('relu', name='block2_sepconv2_act')(x) - x = SeparableConv2D( - 128, (3, 3), padding='same', use_bias=False, name='block2_sepconv2')( - x) - x = BatchNormalization(name='block2_sepconv2_bn')(x) - - x = MaxPooling2D( - (3, 3), strides=(2, 2), padding='same', name='block2_pool')( - x) - x = layers.add([x, residual]) - - residual = Conv2D( - 256, (1, 1), strides=(2, 2), padding='same', use_bias=False)( - x) - residual = BatchNormalization()(residual) - - x = Activation('relu', name='block3_sepconv1_act')(x) - x = SeparableConv2D( - 256, (3, 3), padding='same', use_bias=False, name='block3_sepconv1')( - x) - x = BatchNormalization(name='block3_sepconv1_bn')(x) - x = Activation('relu', name='block3_sepconv2_act')(x) - x = SeparableConv2D( - 256, (3, 3), padding='same', use_bias=False, name='block3_sepconv2')( - x) - x = BatchNormalization(name='block3_sepconv2_bn')(x) - - x = MaxPooling2D( - (3, 3), strides=(2, 2), padding='same', name='block3_pool')( - x) - x = layers.add([x, residual]) - - residual = Conv2D( - 728, (1, 1), strides=(2, 2), padding='same', use_bias=False)( - x) - residual = BatchNormalization()(residual) - - x = Activation('relu', name='block4_sepconv1_act')(x) - x = SeparableConv2D( - 728, (3, 3), padding='same', use_bias=False, name='block4_sepconv1')( - x) - x = BatchNormalization(name='block4_sepconv1_bn')(x) - x = Activation('relu', name='block4_sepconv2_act')(x) - x = SeparableConv2D( - 728, (3, 3), padding='same', use_bias=False, name='block4_sepconv2')( - x) - x = BatchNormalization(name='block4_sepconv2_bn')(x) - - x = MaxPooling2D( - (3, 3), strides=(2, 2), padding='same', name='block4_pool')( - x) - x = layers.add([x, residual]) - - for i in range(8): - residual = x - prefix = 'block' + str(i + 5) - - x = Activation('relu', name=prefix + '_sepconv1_act')(x) - x = SeparableConv2D( - 728, (3, 3), padding='same', use_bias=False, name=prefix + '_sepconv1')( - x) - x = BatchNormalization(name=prefix + '_sepconv1_bn')(x) - x = Activation('relu', name=prefix + '_sepconv2_act')(x) - x = SeparableConv2D( - 728, (3, 3), padding='same', use_bias=False, name=prefix + '_sepconv2')( - x) - x = BatchNormalization(name=prefix + '_sepconv2_bn')(x) - x = Activation('relu', name=prefix + '_sepconv3_act')(x) - x = SeparableConv2D( - 728, (3, 3), padding='same', use_bias=False, name=prefix + '_sepconv3')( - x) - x = BatchNormalization(name=prefix + '_sepconv3_bn')(x) - - x = layers.add([x, residual]) - - residual = Conv2D( - 1024, (1, 1), strides=(2, 2), padding='same', use_bias=False)( - x) - residual = BatchNormalization()(residual) - - x = Activation('relu', name='block13_sepconv1_act')(x) - x = SeparableConv2D( - 728, (3, 3), padding='same', use_bias=False, name='block13_sepconv1')( - x) - x = BatchNormalization(name='block13_sepconv1_bn')(x) - x = Activation('relu', name='block13_sepconv2_act')(x) - x = SeparableConv2D( - 1024, (3, 3), padding='same', use_bias=False, name='block13_sepconv2')( - x) - x = BatchNormalization(name='block13_sepconv2_bn')(x) - - x = MaxPooling2D( - (3, 3), strides=(2, 2), padding='same', name='block13_pool')( - x) - x = layers.add([x, residual]) - - x = SeparableConv2D( - 1536, (3, 3), padding='same', use_bias=False, name='block14_sepconv1')( - x) - x = BatchNormalization(name='block14_sepconv1_bn')(x) - x = Activation('relu', name='block14_sepconv1_act')(x) - - x = SeparableConv2D( - 2048, (3, 3), padding='same', use_bias=False, name='block14_sepconv2')( - x) - x = BatchNormalization(name='block14_sepconv2_bn')(x) - x = Activation('relu', name='block14_sepconv2_act')(x) - - if include_top: - x = GlobalAveragePooling2D(name='avg_pool')(x) - x = Dense(classes, activation='softmax', name='predictions')(x) - else: - if pooling == 'avg': - x = GlobalAveragePooling2D()(x) - elif pooling == 'max': - x = GlobalMaxPooling2D()(x) - - # Ensure that the model takes into account - # any potential predecessors of `input_tensor`. - if input_tensor is not None: - inputs = layer_utils.get_source_inputs(input_tensor) - else: - inputs = img_input - # Create model. - model = Model(inputs, x, name='xception') - - # load weights - if weights == 'imagenet': - if include_top: - weights_path = get_file( - 'xception_weights_tf_dim_ordering_tf_kernels.h5', - TF_WEIGHTS_PATH, - cache_subdir='models', - file_hash='0a58e3b7378bc2990ea3b43d5981f1f6') - else: - weights_path = get_file( - 'xception_weights_tf_dim_ordering_tf_kernels_notop.h5', - TF_WEIGHTS_PATH_NO_TOP, - cache_subdir='models', - file_hash='b0042744bf5b25fce3cb969f33bebb97') - model.load_weights(weights_path) - elif weights is not None: - model.load_weights(weights) - - if old_data_format: - K.set_image_data_format(old_data_format) - return model - - -@tf_export('keras.applications.xception.preprocess_input') -def preprocess_input(x): - """Preprocesses a numpy array encoding a batch of images. - - Arguments: - x: a 4D numpy array consists of RGB values within [0, 255]. - - Returns: - Preprocessed array. - """ - return imagenet_utils.preprocess_input(x, mode='tf') +tf_export('keras.applications.xception.Xception', + 'keras.applications.Xception')(Xception) +tf_export('keras.applications.xception.preprocess_input')(preprocess_input) diff --git a/tensorflow/python/keras/preprocessing/__init__.py b/tensorflow/python/keras/preprocessing/__init__.py index e6704eeaa1..2f08f88600 100644 --- a/tensorflow/python/keras/preprocessing/__init__.py +++ b/tensorflow/python/keras/preprocessing/__init__.py @@ -13,10 +13,18 @@ # limitations under the License. # ============================================================================== """Keras data preprocessing utils.""" +# pylint: disable=g-import-not-at-top from __future__ import absolute_import from __future__ import division from __future__ import print_function +import keras_preprocessing + +from tensorflow.python.keras import backend +from tensorflow.python.keras import utils + +keras_preprocessing.set_keras_submodules(backend=backend, utils=utils) + from tensorflow.python.keras.preprocessing import image from tensorflow.python.keras.preprocessing import sequence from tensorflow.python.keras.preprocessing import text diff --git a/tensorflow/python/keras/preprocessing/image.py b/tensorflow/python/keras/preprocessing/image.py index aa425df6a8..ba227385ef 100644 --- a/tensorflow/python/keras/preprocessing/image.py +++ b/tensorflow/python/keras/preprocessing/image.py @@ -12,1588 +12,58 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== +# pylint: disable=invalid-name # pylint: disable=g-import-not-at-top -"""Fairly basic set of tools for real-time data augmentation on image data. - -Can easily be extended to include new transformations, -new preprocessing methods, etc... +"""Set of tools for real-time data augmentation on image data. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function -from functools import partial -import multiprocessing.pool -import os -import re -import threading - -import numpy as np -from tensorflow.python.keras import backend as K -from tensorflow.python.keras.utils.data_utils import Sequence -from tensorflow.python.platform import tf_logging as logging -from tensorflow.python.util.tf_export import tf_export - +from keras_preprocessing import image try: - from scipy import linalg - import scipy.ndimage as ndi + from scipy import linalg # pylint: disable=unused-import + from scipy import ndimage # pylint: disable=unused-import except ImportError: - linalg = None - ndi = None - - -try: - from PIL import ImageEnhance - from PIL import Image as pil_image -except ImportError: - pil_image = None - -if pil_image is not None: - _PIL_INTERPOLATION_METHODS = { - 'nearest': pil_image.NEAREST, - 'bilinear': pil_image.BILINEAR, - 'bicubic': pil_image.BICUBIC, - } - # These methods were only introduced in version 3.4.0 (2016). - if hasattr(pil_image, 'HAMMING'): - _PIL_INTERPOLATION_METHODS['hamming'] = pil_image.HAMMING - if hasattr(pil_image, 'BOX'): - _PIL_INTERPOLATION_METHODS['box'] = pil_image.BOX - # This method is new in version 1.1.3 (2013). - if hasattr(pil_image, 'LANCZOS'): - _PIL_INTERPOLATION_METHODS['lanczos'] = pil_image.LANCZOS - - -@tf_export('keras.preprocessing.image.random_rotation') -def random_rotation(x, - rg, - row_axis=1, - col_axis=2, - channel_axis=0, - fill_mode='nearest', - cval=0.): - """Performs a random rotation of a Numpy image tensor. - - Arguments: - x: Input tensor. Must be 3D. - rg: Rotation range, in degrees. - row_axis: Index of axis for rows in the input tensor. - col_axis: Index of axis for columns in the input tensor. - channel_axis: Index of axis for channels in the input tensor. - fill_mode: Points outside the boundaries of the input - are filled according to the given mode - (one of `{'constant', 'nearest', 'reflect', 'wrap'}`). - cval: Value used for points outside the boundaries - of the input if `mode='constant'`. - - Returns: - Rotated Numpy image tensor. - """ - theta = np.deg2rad(np.random.uniform(-rg, rg)) - rotation_matrix = np.array([[np.cos(theta), -np.sin(theta), 0], - [np.sin(theta), np.cos(theta), 0], [0, 0, 1]]) - - h, w = x.shape[row_axis], x.shape[col_axis] - transform_matrix = transform_matrix_offset_center(rotation_matrix, h, w) - x = apply_transform(x, transform_matrix, channel_axis, fill_mode, cval) - return x - - -@tf_export('keras.preprocessing.image.random_shift') -def random_shift(x, - wrg, - hrg, - row_axis=1, - col_axis=2, - channel_axis=0, - fill_mode='nearest', - cval=0.): - """Performs a random spatial shift of a Numpy image tensor. - - Arguments: - x: Input tensor. Must be 3D. - wrg: Width shift range, as a float fraction of the width. - hrg: Height shift range, as a float fraction of the height. - row_axis: Index of axis for rows in the input tensor. - col_axis: Index of axis for columns in the input tensor. - channel_axis: Index of axis for channels in the input tensor. - fill_mode: Points outside the boundaries of the input - are filled according to the given mode - (one of `{'constant', 'nearest', 'reflect', 'wrap'}`). - cval: Value used for points outside the boundaries - of the input if `mode='constant'`. - - Returns: - Shifted Numpy image tensor. - """ - h, w = x.shape[row_axis], x.shape[col_axis] - tx = np.random.uniform(-hrg, hrg) * h - ty = np.random.uniform(-wrg, wrg) * w - translation_matrix = np.array([[1, 0, tx], [0, 1, ty], [0, 0, 1]]) - - transform_matrix = translation_matrix # no need to do offset - x = apply_transform(x, transform_matrix, channel_axis, fill_mode, cval) - return x - - -@tf_export('keras.preprocessing.image.random_shear') -def random_shear(x, - intensity, - row_axis=1, - col_axis=2, - channel_axis=0, - fill_mode='nearest', - cval=0.): - """Performs a random spatial shear of a Numpy image tensor. - - Arguments: - x: Input tensor. Must be 3D. - intensity: Transformation intensity in degrees. - row_axis: Index of axis for rows in the input tensor. - col_axis: Index of axis for columns in the input tensor. - channel_axis: Index of axis for channels in the input tensor. - fill_mode: Points outside the boundaries of the input - are filled according to the given mode - (one of `{'constant', 'nearest', 'reflect', 'wrap'}`). - cval: Value used for points outside the boundaries - of the input if `mode='constant'`. - - Returns: - Sheared Numpy image tensor. - """ - shear = np.deg2rad(np.random.uniform(-intensity, intensity)) - shear_matrix = np.array([[1, -np.sin(shear), 0], [0, np.cos(shear), 0], - [0, 0, 1]]) - - h, w = x.shape[row_axis], x.shape[col_axis] - transform_matrix = transform_matrix_offset_center(shear_matrix, h, w) - x = apply_transform(x, transform_matrix, channel_axis, fill_mode, cval) - return x - - -@tf_export('keras.preprocessing.image.random_zoom') -def random_zoom(x, - zoom_range, - row_axis=1, - col_axis=2, - channel_axis=0, - fill_mode='nearest', - cval=0.): - """Performs a random spatial zoom of a Numpy image tensor. - - Arguments: - x: Input tensor. Must be 3D. - zoom_range: Tuple of floats; zoom range for width and height. - row_axis: Index of axis for rows in the input tensor. - col_axis: Index of axis for columns in the input tensor. - channel_axis: Index of axis for channels in the input tensor. - fill_mode: Points outside the boundaries of the input - are filled according to the given mode - (one of `{'constant', 'nearest', 'reflect', 'wrap'}`). - cval: Value used for points outside the boundaries - of the input if `mode='constant'`. - - Returns: - Zoomed Numpy image tensor. - - Raises: - ValueError: if `zoom_range` isn't a tuple. - """ - if len(zoom_range) != 2: - raise ValueError('`zoom_range` should be a tuple or list of two floats. ' - 'Received arg: ', zoom_range) - - if zoom_range[0] == 1 and zoom_range[1] == 1: - zx, zy = 1, 1 - else: - zx, zy = np.random.uniform(zoom_range[0], zoom_range[1], 2) - zoom_matrix = np.array([[zx, 0, 0], [0, zy, 0], [0, 0, 1]]) - - h, w = x.shape[row_axis], x.shape[col_axis] - transform_matrix = transform_matrix_offset_center(zoom_matrix, h, w) - x = apply_transform(x, transform_matrix, channel_axis, fill_mode, cval) - return x - - -@tf_export('keras.preprocessing.image.random_channel_shift') -def random_channel_shift(x, intensity, channel_axis=0): - """Perform a random channel shift. - - Arguments: - x: Input tensor. Must be 3D. - intensity: Transformation intensity. - channel_axis: Index of axis for channels in the input tensor. - - Returns: - Numpy image tensor. - """ - x = np.rollaxis(x, channel_axis, 0) - min_x, max_x = np.min(x), np.max(x) - channel_images = [ - np.clip(x_channel + np.random.uniform(-intensity, intensity), min_x, - max_x) for x_channel in x - ] - x = np.stack(channel_images, axis=0) - x = np.rollaxis(x, 0, channel_axis + 1) - return x - - -@tf_export('keras.preprocessing.image.random_brightness') -def random_brightness(x, brightness_range): - """Performs a random adjustment of brightness of a Numpy image tensor. - - Arguments: - x: Input tensor. Must be 3D. - brightness_range: Tuple of floats; range to pick a brightness value from. - - Returns: - Brightness adjusted Numpy image tensor. - - Raises: - ValueError: if `brightness_range` isn't a tuple. - """ - if len(brightness_range) != 2: - raise ValueError('`brightness_range should be tuple or list of two floats. ' - 'Received arg: ', brightness_range) - - x = array_to_img(x) - x = ImageEnhance.Brightness(x) - u = np.random.uniform(brightness_range[0], brightness_range[1]) - x = x.enhance(u) - x = img_to_array(x) - return x - - -def transform_matrix_offset_center(matrix, x, y): - o_x = float(x) / 2 + 0.5 - o_y = float(y) / 2 + 0.5 - offset_matrix = np.array([[1, 0, o_x], [0, 1, o_y], [0, 0, 1]]) - reset_matrix = np.array([[1, 0, -o_x], [0, 1, -o_y], [0, 0, 1]]) - transform_matrix = np.dot(np.dot(offset_matrix, matrix), reset_matrix) - return transform_matrix - - -@tf_export('keras.preprocessing.image.apply_transform') -def apply_transform(x, - transform_matrix, - channel_axis=0, - fill_mode='nearest', - cval=0.): - """Apply the image transformation specified by a matrix. - - Arguments: - x: 2D numpy array, single image. - transform_matrix: Numpy array specifying the geometric transformation. - channel_axis: Index of axis for channels in the input tensor. - fill_mode: Points outside the boundaries of the input - are filled according to the given mode - (one of `{'constant', 'nearest', 'reflect', 'wrap'}`). - cval: Value used for points outside the boundaries - of the input if `mode='constant'`. - - Returns: - The transformed version of the input. - """ - x = np.rollaxis(x, channel_axis, 0) - final_affine_matrix = transform_matrix[:2, :2] - final_offset = transform_matrix[:2, 2] - channel_images = [ - ndi.interpolation.affine_transform( - x_channel, - final_affine_matrix, - final_offset, - order=1, - mode=fill_mode, - cval=cval) for x_channel in x - ] - x = np.stack(channel_images, axis=0) - x = np.rollaxis(x, 0, channel_axis + 1) - return x - - -@tf_export('keras.preprocessing.image.flip_axis') -def flip_axis(x, axis): - x = np.asarray(x).swapaxes(axis, 0) - x = x[::-1, ...] - x = x.swapaxes(0, axis) - return x - - -@tf_export('keras.preprocessing.image.array_to_img') -def array_to_img(x, data_format=None, scale=True): - """Converts a 3D Numpy array to a PIL Image instance. - - Arguments: - x: Input Numpy array. - data_format: Image data format. - scale: Whether to rescale image values - to be within [0, 255]. - - Returns: - A PIL Image instance. - - Raises: - ImportError: if PIL is not available. - ValueError: if invalid `x` or `data_format` is passed. - """ - if pil_image is None: - raise ImportError('Could not import PIL.Image. ' - 'The use of `array_to_img` requires PIL.') - x = np.asarray(x, dtype=K.floatx()) - if x.ndim != 3: - raise ValueError('Expected image array to have rank 3 (single image). ' - 'Got array with shape:', x.shape) - - if data_format is None: - data_format = K.image_data_format() - if data_format not in {'channels_first', 'channels_last'}: - raise ValueError('Invalid data_format:', data_format) - - # Original Numpy array x has format (height, width, channel) - # or (channel, height, width) - # but target PIL image has format (width, height, channel) - if data_format == 'channels_first': - x = x.transpose(1, 2, 0) - if scale: - x = x + max(-np.min(x), 0) # pylint: disable=g-no-augmented-assignment - x_max = np.max(x) - if x_max != 0: - x /= x_max - x *= 255 - if x.shape[2] == 3: - # RGB - return pil_image.fromarray(x.astype('uint8'), 'RGB') - elif x.shape[2] == 1: - # grayscale - return pil_image.fromarray(x[:, :, 0].astype('uint8'), 'L') - else: - raise ValueError('Unsupported channel number: ', x.shape[2]) - - -@tf_export('keras.preprocessing.image.img_to_array') -def img_to_array(img, data_format=None): - """Converts a PIL Image instance to a Numpy array. - - Arguments: - img: PIL Image instance. - data_format: Image data format. - - Returns: - A 3D Numpy array. - - Raises: - ValueError: if invalid `img` or `data_format` is passed. - """ - if data_format is None: - data_format = K.image_data_format() - if data_format not in {'channels_first', 'channels_last'}: - raise ValueError('Unknown data_format: ', data_format) - # Numpy array x has format (height, width, channel) - # or (channel, height, width) - # but original PIL image has format (width, height, channel) - x = np.asarray(img, dtype=K.floatx()) - if len(x.shape) == 3: - if data_format == 'channels_first': - x = x.transpose(2, 0, 1) - elif len(x.shape) == 2: - if data_format == 'channels_first': - x = x.reshape((1, x.shape[0], x.shape[1])) - else: - x = x.reshape((x.shape[0], x.shape[1], 1)) - else: - raise ValueError('Unsupported image shape: ', x.shape) - return x - - -@tf_export('keras.preprocessing.image.load_img') -def load_img(path, grayscale=False, target_size=None, interpolation='nearest'): - """Loads an image into PIL format. - - Arguments: - path: Path to image file - grayscale: Boolean, whether to load the image as grayscale. - target_size: Either `None` (default to original size) - or tuple of ints `(img_height, img_width)`. - interpolation: Interpolation method used to resample the image if the - target size is different from that of the loaded image. - Supported methods are "nearest", "bilinear", and "bicubic". - If PIL version 1.1.3 or newer is installed, "lanczos" is also - supported. If PIL version 3.4.0 or newer is installed, "box" and - "hamming" are also supported. By default, "nearest" is used. - - Returns: - A PIL Image instance. - - Raises: - ImportError: if PIL is not available. - ValueError: if interpolation method is not supported. - """ - if pil_image is None: - raise ImportError('Could not import PIL.Image. ' - 'The use of `array_to_img` requires PIL.') - img = pil_image.open(path) - if grayscale: - if img.mode != 'L': - img = img.convert('L') - else: - if img.mode != 'RGB': - img = img.convert('RGB') - if target_size is not None: - width_height_tuple = (target_size[1], target_size[0]) - if img.size != width_height_tuple: - if interpolation not in _PIL_INTERPOLATION_METHODS: - raise ValueError('Invalid interpolation method {} specified. Supported ' - 'methods are {}'.format(interpolation, ', '.join( - _PIL_INTERPOLATION_METHODS.keys()))) - resample = _PIL_INTERPOLATION_METHODS[interpolation] - img = img.resize(width_height_tuple, resample) - return img - - -def list_pictures(directory, ext='jpg|jpeg|bmp|png|ppm'): - return [ - os.path.join(root, f) - for root, _, files in os.walk(directory) - for f in files - if re.match(r'([\w]+\.(?:' + ext + '))', f) - ] - - -@tf_export('keras.preprocessing.image.ImageDataGenerator') -class ImageDataGenerator(object): - """Generates batches of tensor image data with real-time data augmentation. - The data will be looped over (in batches). - - Arguments: - featurewise_center: boolean, set input mean to 0 over the dataset, - feature-wise. - samplewise_center: boolean, set each sample mean to 0. - featurewise_std_normalization: boolean, divide inputs by std - of the dataset, feature-wise. - samplewise_std_normalization: boolean, divide each input by its std. - zca_epsilon: epsilon for ZCA whitening. Default is 1e-6. - zca_whitening: boolean, apply ZCA whitening. - rotation_range: int, degree range for random rotations. - width_shift_range: float, 1-D array-like or int - float: fraction of total width, if < 1, or pixels if >= 1. - 1-D array-like: random elements from the array. - int: integer number of pixels from interval - `(-width_shift_range, +width_shift_range)` - With `width_shift_range=2` possible values are integers [-1, 0, +1], - same as with `width_shift_range=[-1, 0, +1]`, - while with `width_shift_range=1.0` possible values are floats in - the interval [-1.0, +1.0). - shear_range: float, shear Intensity - (Shear angle in counter-clockwise direction in degrees) - zoom_range: float or [lower, upper], Range for random zoom. - If a float, `[lower, upper] = [1-zoom_range, 1+zoom_range]`. - channel_shift_range: float, range for random channel shifts. - fill_mode: One of {"constant", "nearest", "reflect" or "wrap"}. - Default is 'nearest'. Points outside the boundaries of the input - are filled according to the given mode: - 'constant': kkkkkkkk|abcd|kkkkkkkk (cval=k) - 'nearest': aaaaaaaa|abcd|dddddddd - 'reflect': abcddcba|abcd|dcbaabcd - 'wrap': abcdabcd|abcd|abcdabcd - cval: float or int, value used for points outside the boundaries - when `fill_mode = "constant"`. - horizontal_flip: boolean, randomly flip inputs horizontally. - vertical_flip: boolean, randomly flip inputs vertically. - rescale: rescaling factor. Defaults to None. If None or 0, no rescaling - is applied, otherwise we multiply the data by the value provided - (before applying any other transformation). - preprocessing_function: function that will be implied on each input. - The function will run after the image is resized and augmented. - The function should take one argument: - one image (Numpy tensor with rank 3), - and should output a Numpy tensor with the same shape. - data_format: One of {"channels_first", "channels_last"}. - "channels_last" mode means that the images should have shape - `(samples, height, width, channels)`, - "channels_first" mode means that the images should have shape - `(samples, channels, height, width)`. - It defaults to the `image_data_format` value found in your - Keras config file at `~/.keras/keras.json`. - If you never set it, then it will be "channels_last". - validation_split: float, fraction of images reserved for validation - (strictly between 0 and 1). - - Examples: - Example of using `.flow(x, y)`: - ```python - (x_train, y_train), (x_test, y_test) = cifar10.load_data() - y_train = np_utils.to_categorical(y_train, num_classes) - y_test = np_utils.to_categorical(y_test, num_classes) - datagen = ImageDataGenerator( - featurewise_center=True, - featurewise_std_normalization=True, - rotation_range=20, - width_shift_range=0.2, - height_shift_range=0.2, - horizontal_flip=True) - # compute quantities required for featurewise normalization - # (std, mean, and principal components if ZCA whitening is applied) - datagen.fit(x_train) - # fits the model on batches with real-time data augmentation: - model.fit_generator(datagen.flow(x_train, y_train, batch_size=32), - steps_per_epoch=len(x_train) / 32, epochs=epochs) - # here's a more "manual" example - for e in range(epochs): - print('Epoch', e) - batches = 0 - for x_batch, y_batch in datagen.flow(x_train, y_train, batch_size=32): - model.fit(x_batch, y_batch) - batches += 1 - if batches >= len(x_train) / 32: - # we need to break the loop by hand because - # the generator loops indefinitely - break - ``` - Example of using `.flow_from_directory(directory)`: - ```python - train_datagen = ImageDataGenerator( - rescale=1./255, - shear_range=0.2, - zoom_range=0.2, - horizontal_flip=True) - test_datagen = ImageDataGenerator(rescale=1./255) - train_generator = train_datagen.flow_from_directory( - 'data/train', - target_size=(150, 150), - batch_size=32, - class_mode='binary') - validation_generator = test_datagen.flow_from_directory( - 'data/validation', - target_size=(150, 150), - batch_size=32, - class_mode='binary') - model.fit_generator( - train_generator, - steps_per_epoch=2000, - epochs=50, - validation_data=validation_generator, - validation_steps=800) - ``` - Example of transforming images and masks together. - ```python - # we create two instances with the same arguments - data_gen_args = dict(featurewise_center=True, - featurewise_std_normalization=True, - rotation_range=90., - width_shift_range=0.1, - height_shift_range=0.1, - zoom_range=0.2) - image_datagen = ImageDataGenerator(**data_gen_args) - mask_datagen = ImageDataGenerator(**data_gen_args) - # Provide the same seed and keyword arguments to the fit and flow methods - seed = 1 - image_datagen.fit(images, augment=True, seed=seed) - mask_datagen.fit(masks, augment=True, seed=seed) - image_generator = image_datagen.flow_from_directory( - 'data/images', - class_mode=None, - seed=seed) - mask_generator = mask_datagen.flow_from_directory( - 'data/masks', - class_mode=None, - seed=seed) - # combine generators into one which yields image and masks - train_generator = zip(image_generator, mask_generator) - model.fit_generator( - train_generator, - steps_per_epoch=2000, - epochs=50) - ``` - """ - - def __init__(self, - featurewise_center=False, - samplewise_center=False, - featurewise_std_normalization=False, - samplewise_std_normalization=False, - zca_whitening=False, - zca_epsilon=1e-6, - rotation_range=0., - width_shift_range=0., - height_shift_range=0., - brightness_range=None, - shear_range=0., - zoom_range=0., - channel_shift_range=0., - fill_mode='nearest', - cval=0., - horizontal_flip=False, - vertical_flip=False, - rescale=None, - preprocessing_function=None, - data_format=None, - validation_split=0.0): - if data_format is None: - data_format = K.image_data_format() - self.featurewise_center = featurewise_center - self.samplewise_center = samplewise_center - self.featurewise_std_normalization = featurewise_std_normalization - self.samplewise_std_normalization = samplewise_std_normalization - self.zca_whitening = zca_whitening - self.zca_epsilon = zca_epsilon - self.rotation_range = rotation_range - self.width_shift_range = width_shift_range - self.height_shift_range = height_shift_range - self.brightness_range = brightness_range - self.shear_range = shear_range - self.zoom_range = zoom_range - self.channel_shift_range = channel_shift_range - self.fill_mode = fill_mode - self.cval = cval - self.horizontal_flip = horizontal_flip - self.vertical_flip = vertical_flip - self.rescale = rescale - self.preprocessing_function = preprocessing_function - - if data_format not in {'channels_last', 'channels_first'}: - raise ValueError( - '`data_format` should be `"channels_last"` (channel after row and ' - 'column) or `"channels_first"` (channel before row and column). ' - 'Received arg: ', data_format) - self.data_format = data_format - if data_format == 'channels_first': - self.channel_axis = 1 - self.row_axis = 2 - self.col_axis = 3 - if data_format == 'channels_last': - self.channel_axis = 3 - self.row_axis = 1 - self.col_axis = 2 - if validation_split and not 0 < validation_split < 1: - raise ValueError('`validation_split` must be strictly between 0 and 1. ' - 'Received arg: ', validation_split) - self.validation_split = validation_split - - self.mean = None - self.std = None - self.principal_components = None - - if np.isscalar(zoom_range): - self.zoom_range = [1 - zoom_range, 1 + zoom_range] - elif len(zoom_range) == 2: - self.zoom_range = [zoom_range[0], zoom_range[1]] - else: - raise ValueError('`zoom_range` should be a float or ' - 'a tuple or list of two floats. ' - 'Received arg: ', zoom_range) - if zca_whitening: - if not featurewise_center: - self.featurewise_center = True - logging.warning('This ImageDataGenerator specifies ' - '`zca_whitening`, which overrides ' - 'setting of `featurewise_center`.') - if featurewise_std_normalization: - self.featurewise_std_normalization = False - logging.warning('This ImageDataGenerator specifies ' - '`zca_whitening` ' - 'which overrides setting of' - '`featurewise_std_normalization`.') - if featurewise_std_normalization: - if not featurewise_center: - self.featurewise_center = True - logging.warning('This ImageDataGenerator specifies ' - '`featurewise_std_normalization`, ' - 'which overrides setting of ' - '`featurewise_center`.') - if samplewise_std_normalization: - if not samplewise_center: - self.samplewise_center = True - logging.warning('This ImageDataGenerator specifies ' - '`samplewise_std_normalization`, ' - 'which overrides setting of ' - '`samplewise_center`.') - - def flow(self, - x, - y=None, - batch_size=32, - shuffle=True, - seed=None, - save_to_dir=None, - save_prefix='', - save_format='png', - subset=None): - """Generates batches of augmented/normalized data with given numpy arrays. - - Arguments: - x: data. Should have rank 4. - In case of grayscale data, the channels axis should have value 1 - and in case of RGB data, it should have value 3. - y: labels. - batch_size: int (default: 32). - shuffle: boolean (default: True). - seed: int (default: None). - save_to_dir: None or str (default: None). - This allows you to optionally specify a directory - to which to save the augmented pictures being generated - (useful for visualizing what you are doing). - save_prefix: str (default: `''`). Prefix to use for filenames of - saved pictures (only relevant if `save_to_dir` is set). - save_format: one of "png", "jpeg". Default: "png". - (only relevant if `save_to_dir` is set) - subset: Subset of data (`"training"` or `"validation"`) if - `validation_split` is set in `ImageDataGenerator`. - - Returns: - An Iterator yielding tuples of `(x, y)` where `x` is a numpy array of - image data and `y` is a numpy array of corresponding labels. - """ - return NumpyArrayIterator( - x, - y, - self, - batch_size=batch_size, - shuffle=shuffle, - seed=seed, - data_format=self.data_format, - save_to_dir=save_to_dir, - save_prefix=save_prefix, - save_format=save_format, - subset=subset) - - def flow_from_directory(self, - directory, - target_size=(256, 256), - color_mode='rgb', - classes=None, - class_mode='categorical', - batch_size=32, - shuffle=True, - seed=None, - save_to_dir=None, - save_prefix='', - save_format='png', - follow_links=False, - subset=None, - interpolation='nearest'): - """Generates batches of augmented/normalized data given directory path. - - Arguments: - directory: path to the target directory. It should contain one - subdirectory per class. Any PNG, JPG, BMP, PPM or TIF images - inside each of the subdirectories directory tree will be included - in the generator. See [this script] - (https://gist.github.com/fchollet/0830affa1f7f19fd47b06d4cf89ed44d) - for more details. - target_size: tuple of integers `(height, width)`, default: `(256, - 256)`. The dimensions to which all images found will be resized. - color_mode: one of "grayscale", "rbg". Default: "rgb". Whether the - images will be converted to have 1 or 3 color channels. - classes: optional list of class subdirectories (e.g. `['dogs', - 'cats']`). Default: None. If not provided, the list of classes - will be automatically inferred from the subdirectory - names/structure under `directory`, where each subdirectory will be - treated as a different class (and the order of the classes, which - will map to the label indices, will be alphanumeric). The - dictionary containing the mapping from class names to class - indices can be obtained via the attribute `class_indices`. - class_mode: one of "categorical", "binary", "sparse", "input" or - None. Default: "categorical". Determines the type of label arrays - that are returned: "categorical" will be 2D one-hot encoded - labels, "binary" will be 1D binary labels, "sparse" will be 1D - integer labels, "input" will be images identical to input images - (mainly used to work with autoencoders). If None, no labels are - returned (the generator will only yield batches of image data, - which is useful to use `model.predict_generator()`, - `model.evaluate_generator()`, etc.). Please note that in case of - class_mode None, the data still needs to reside in a subdirectory - of `directory` for it to work correctly. - batch_size: size of the batches of data (default: 32). - shuffle: whether to shuffle the data (default: True) - seed: optional random seed for shuffling and transformations. - save_to_dir: None or str (default: None). This allows you to - optionally specify a directory to which to save the augmented - pictures being generated (useful for visualizing what you are doing) - save_prefix: str. Prefix to use for filenames of saved pictures - (only relevant if `save_to_dir` is set). - save_format: one of "png", "jpeg" (only relevant if `save_to_dir` is - set). Default: "png". - follow_links: whether to follow symlinks inside class subdirectories - (default: False). - subset: Subset of data (`"training"` or `"validation"`) if - ` validation_split` is set in `ImageDataGenerator`. - interpolation: Interpolation method used to resample the image if - the target size is different from that of the loaded image. - Supported methods are `"nearest"`, `"bilinear"`, and `"bicubic"`. - If PIL version 1.1.3 or newer is installed, `"lanczos"` is also - supported. If PIL version 3.4.0 or newer is installed, `"box"` and - `"hamming"` are also supported. By default, `"nearest"` is used. - - Returns: - A DirectoryIterator yielding tuples of `(x, y)` where `x` is a - numpy array containing a batch of images with shape - `(batch_size, *target_size, channels)` and `y` is a numpy - array of corresponding labels. - """ - return DirectoryIterator( - directory, - self, - target_size=target_size, - color_mode=color_mode, - classes=classes, - class_mode=class_mode, - data_format=self.data_format, - batch_size=batch_size, - shuffle=shuffle, - seed=seed, - save_to_dir=save_to_dir, - save_prefix=save_prefix, - save_format=save_format, - follow_links=follow_links, - subset=subset, - interpolation=interpolation) - - def standardize(self, x): - """Apply the normalization configuration to a batch of inputs. - - Arguments: - x: batch of inputs to be normalized. - - Returns: - The inputs, normalized. - """ - if self.preprocessing_function: - x = self.preprocessing_function(x) - if self.rescale: - x *= self.rescale - if self.samplewise_center: - x -= np.mean(x, keepdims=True) - if self.samplewise_std_normalization: - x /= (np.std(x, keepdims=True) + K.epsilon()) + pass - if self.featurewise_center: - if self.mean is not None: - x -= self.mean - else: - logging.warning('This ImageDataGenerator specifies ' - '`featurewise_center`, but it hasn\'t ' - 'been fit on any training data. Fit it ' - 'first by calling `.fit(numpy_data)`.') - if self.featurewise_std_normalization: - if self.std is not None: - x /= (self.std + K.epsilon()) - else: - logging.warning('This ImageDataGenerator specifies ' - '`featurewise_std_normalization`, but it hasn\'t ' - 'been fit on any training data. Fit it ' - 'first by calling `.fit(numpy_data)`.') - if self.zca_whitening: - if self.principal_components is not None: - flatx = np.reshape(x, (-1, np.prod(x.shape[-3:]))) - whitex = np.dot(flatx, self.principal_components) - x = np.reshape(whitex, x.shape) - else: - logging.warning('This ImageDataGenerator specifies ' - '`zca_whitening`, but it hasn\'t ' - 'been fit on any training data. Fit it ' - 'first by calling `.fit(numpy_data)`.') - return x - - def random_transform(self, x, seed=None): - """Randomly augment a single image tensor. - - Arguments: - x: 3D tensor, single image. - seed: random seed. - - Returns: - A randomly transformed version of the input (same shape). - - Raises: - ImportError: if Scipy is not available. - """ - if ndi is None: - raise ImportError('Scipy is required for image transformations.') - # x is a single image, so it doesn't have image number at index 0 - img_row_axis = self.row_axis - 1 - img_col_axis = self.col_axis - 1 - img_channel_axis = self.channel_axis - 1 - - if seed is not None: - np.random.seed(seed) - - # use composition of homographies - # to generate final transform that needs to be applied - if self.rotation_range: - theta = np.deg2rad( - np.random.uniform(-self.rotation_range, self.rotation_range)) - else: - theta = 0 - - if self.height_shift_range: - try: # 1-D array-like or int - tx = np.random.choice(self.height_shift_range) - tx *= np.random.choice([-1, 1]) - except ValueError: # floating point - tx = np.random.uniform(-self.height_shift_range, - self.height_shift_range) - if np.max(self.height_shift_range) < 1: - tx *= x.shape[img_row_axis] - else: - tx = 0 - - if self.width_shift_range: - try: # 1-D array-like or int - ty = np.random.choice(self.width_shift_range) - ty *= np.random.choice([-1, 1]) - except ValueError: # floating point - ty = np.random.uniform(-self.width_shift_range, self.width_shift_range) - if np.max(self.width_shift_range) < 1: - ty *= x.shape[img_col_axis] - else: - ty = 0 - - if self.shear_range: - shear = np.deg2rad(np.random.uniform(-self.shear_range, self.shear_range)) - else: - shear = 0 - - if self.zoom_range[0] == 1 and self.zoom_range[1] == 1: - zx, zy = 1, 1 - else: - zx, zy = np.random.uniform(self.zoom_range[0], self.zoom_range[1], 2) - - transform_matrix = None - if theta != 0: - rotation_matrix = np.array([[np.cos(theta), -np.sin(theta), 0], - [np.sin(theta), - np.cos(theta), 0], [0, 0, 1]]) - transform_matrix = rotation_matrix - - if tx != 0 or ty != 0: - shift_matrix = np.array([[1, 0, tx], [0, 1, ty], [0, 0, 1]]) - transform_matrix = shift_matrix if transform_matrix is None else np.dot( - transform_matrix, shift_matrix) - - if shear != 0: - shear_matrix = np.array([[1, -np.sin(shear), 0], [0, np.cos(shear), 0], - [0, 0, 1]]) - transform_matrix = shear_matrix if transform_matrix is None else np.dot( - transform_matrix, shear_matrix) - - if zx != 1 or zy != 1: - zoom_matrix = np.array([[zx, 0, 0], [0, zy, 0], [0, 0, 1]]) - transform_matrix = zoom_matrix if transform_matrix is None else np.dot( - transform_matrix, zoom_matrix) - - if transform_matrix is not None: - h, w = x.shape[img_row_axis], x.shape[img_col_axis] - transform_matrix = transform_matrix_offset_center(transform_matrix, h, w) - x = apply_transform( - x, - transform_matrix, - img_channel_axis, - fill_mode=self.fill_mode, - cval=self.cval) - - if self.channel_shift_range != 0: - x = random_channel_shift(x, self.channel_shift_range, img_channel_axis) - if self.horizontal_flip: - if np.random.random() < 0.5: - x = flip_axis(x, img_col_axis) - - if self.vertical_flip: - if np.random.random() < 0.5: - x = flip_axis(x, img_row_axis) - - if self.brightness_range is not None: - x = random_brightness(x, self.brightness_range) - - return x - - def fit(self, x, augment=False, rounds=1, seed=None): - """Computes the internal data statistics based on an array of sample data. - - These are statistics related to the data-dependent transformations. - Only required if featurewise_center or featurewise_std_normalization or - zca_whitening. - - Arguments: - x: sample data. Should have rank 4. - In case of grayscale data, the channels axis should have value 1 - and in case of RGB data, it should have value 3. - augment: Boolean (default: False). Whether to fit on randomly - augmented samples. - rounds: int (default: 1). If augment, how many augmentation passes - over the data to use. - seed: int (default: None). Random seed. - - Raises: - ValueError: If input rank is not 4. - ImportError: If scipy is not imported. - """ - x = np.asarray(x, dtype=K.floatx()) - if x.ndim != 4: - raise ValueError('Input to `.fit()` should have rank 4. ' - 'Got array with shape: ' + str(x.shape)) - if x.shape[self.channel_axis] not in {1, 3, 4}: - logging.warning( - 'Expected input to be images (as Numpy array) ' - 'following the data format convention "' + self.data_format + '" ' - '(channels on axis ' + str(self.channel_axis) + '), i.e. expected ' - 'either 1, 3 or 4 channels on axis ' + str(self.channel_axis) + '. ' - 'However, it was passed an array with shape ' + str(x.shape) + ' (' + - str(x.shape[self.channel_axis]) + ' channels).') - - if seed is not None: - np.random.seed(seed) - - x = np.copy(x) - if augment: - ax = np.zeros( - tuple([rounds * x.shape[0]] + list(x.shape)[1:]), dtype=K.floatx()) - for r in range(rounds): - for i in range(x.shape[0]): - ax[i + r * x.shape[0]] = self.random_transform(x[i]) - x = ax - - if self.featurewise_center: - self.mean = np.mean(x, axis=(0, self.row_axis, self.col_axis)) - broadcast_shape = [1, 1, 1] - broadcast_shape[self.channel_axis - 1] = x.shape[self.channel_axis] - self.mean = np.reshape(self.mean, broadcast_shape) - x -= self.mean - - if self.featurewise_std_normalization: - self.std = np.std(x, axis=(0, self.row_axis, self.col_axis)) - broadcast_shape = [1, 1, 1] - broadcast_shape[self.channel_axis - 1] = x.shape[self.channel_axis] - self.std = np.reshape(self.std, broadcast_shape) - x /= (self.std + K.epsilon()) - - if self.zca_whitening: - if linalg is None: - raise ImportError('Scipy is required for zca_whitening.') - - flat_x = np.reshape(x, (x.shape[0], x.shape[1] * x.shape[2] * x.shape[3])) - sigma = np.dot(flat_x.T, flat_x) / flat_x.shape[0] - u, s, _ = linalg.svd(sigma) - s_inv = 1. / np.sqrt(s[np.newaxis] + self.zca_epsilon) - self.principal_components = (u * s_inv).dot(u.T) - - -@tf_export('keras.preprocessing.image.Iterator') -class Iterator(Sequence): - """Base class for image data iterators. - - Every `Iterator` must implement the `_get_batches_of_transformed_samples` - method. - - Arguments: - n: Integer, total number of samples in the dataset to loop over. - batch_size: Integer, size of a batch. - shuffle: Boolean, whether to shuffle the data between epochs. - seed: Random seeding for data shuffling. - """ - - def __init__(self, n, batch_size, shuffle, seed): - self.n = n - self.batch_size = batch_size - self.seed = seed - self.shuffle = shuffle - self.batch_index = 0 - self.total_batches_seen = 0 - self.lock = threading.Lock() - self.index_array = None - self.index_generator = self._flow_index() - - def _set_index_array(self): - self.index_array = np.arange(self.n) - if self.shuffle: - self.index_array = np.random.permutation(self.n) - - def __getitem__(self, idx): - if idx >= len(self): - raise ValueError('Asked to retrieve element {idx}, ' - 'but the Sequence ' - 'has length {length}'.format(idx=idx, length=len(self))) - if self.seed is not None: - np.random.seed(self.seed + self.total_batches_seen) - self.total_batches_seen += 1 - if self.index_array is None: - self._set_index_array() - index_array = self.index_array[self.batch_size * idx:self.batch_size * ( - idx + 1)] - return self._get_batches_of_transformed_samples(index_array) - - def __len__(self): - return (self.n + self.batch_size - 1) // self.batch_size # round up - - def on_epoch_end(self): - self._set_index_array() - - def reset(self): - self.batch_index = 0 - - def _flow_index(self): - # Ensure self.batch_index is 0. - self.reset() - while 1: - if self.seed is not None: - np.random.seed(self.seed + self.total_batches_seen) - if self.batch_index == 0: - self._set_index_array() - - current_index = (self.batch_index * self.batch_size) % self.n - if self.n > current_index + self.batch_size: - self.batch_index += 1 - else: - self.batch_index = 0 - self.total_batches_seen += 1 - yield self.index_array[current_index:current_index + self.batch_size] - - def __iter__(self): # pylint: disable=non-iterator-returned - # Needed if we want to do something like: - # for x, y in data_gen.flow(...): - return self - - def __next__(self, *args, **kwargs): - return self.next(*args, **kwargs) - - def _get_batches_of_transformed_samples(self, index_array): - """Gets a batch of transformed samples. - - Arguments: - index_array: array of sample indices to include in batch. - - Returns: - A batch of transformed samples. - """ - raise NotImplementedError - - -@tf_export('keras.preprocessing.image.NumpyArrayIterator') -class NumpyArrayIterator(Iterator): - """Iterator yielding data from a Numpy array. - - Arguments: - x: Numpy array of input data. - y: Numpy array of targets data. - image_data_generator: Instance of `ImageDataGenerator` - to use for random transformations and normalization. - batch_size: Integer, size of a batch. - shuffle: Boolean, whether to shuffle the data between epochs. - seed: Random seed for data shuffling. - data_format: String, one of `channels_first`, `channels_last`. - save_to_dir: Optional directory where to save the pictures - being yielded, in a viewable format. This is useful - for visualizing the random transformations being - applied, for debugging purposes. - save_prefix: String prefix to use for saving sample - images (if `save_to_dir` is set). - save_format: Format to use for saving sample images - (if `save_to_dir` is set). - subset: Subset of data (`"training"` or `"validation"`) if - validation_split is set in ImageDataGenerator. - """ - - def __init__(self, - x, - y, - image_data_generator, - batch_size=32, - shuffle=False, - seed=None, - data_format=None, - save_to_dir=None, - save_prefix='', - save_format='png', - subset=None): - if y is not None and len(x) != len(y): - raise ValueError('`x` (images tensor) and `y` (labels) ' - 'should have the same length. ' - 'Found: x.shape = %s, y.shape = %s' % - (np.asarray(x).shape, np.asarray(y).shape)) - if subset is not None: - if subset not in {'training', 'validation'}: - raise ValueError('Invalid subset name:', subset, - '; expected "training" or "validation".') - split_idx = int(len(x) * image_data_generator.validation_split) - if subset == 'validation': - x = x[:split_idx] - if y is not None: - y = y[:split_idx] - else: - x = x[split_idx:] - if y is not None: - y = y[split_idx:] - if data_format is None: - data_format = K.image_data_format() - self.x = np.asarray(x, dtype=K.floatx()) - if self.x.ndim != 4: - raise ValueError('Input data in `NumpyArrayIterator` ' - 'should have rank 4. You passed an array ' - 'with shape', self.x.shape) - channels_axis = 3 if data_format == 'channels_last' else 1 - if self.x.shape[channels_axis] not in {1, 3, 4}: - logging.warning( - 'NumpyArrayIterator is set to use the ' - 'data format convention "' + data_format + '" ' - '(channels on axis ' + str(channels_axis) + '), i.e. expected ' - 'either 1, 3 or 4 channels on axis ' + str(channels_axis) + '. ' - 'However, it was passed an array with shape ' + str(self.x.shape) + - ' (' + str(self.x.shape[channels_axis]) + ' channels).') - if y is not None: - self.y = np.asarray(y) - else: - self.y = None - self.image_data_generator = image_data_generator - self.data_format = data_format - self.save_to_dir = save_to_dir - self.save_prefix = save_prefix - self.save_format = save_format - super(NumpyArrayIterator, self).__init__(x.shape[0], batch_size, shuffle, - seed) - - def _get_batches_of_transformed_samples(self, index_array): - batch_x = np.zeros( - tuple([len(index_array)] + list(self.x.shape)[1:]), dtype=K.floatx()) - for i, j in enumerate(index_array): - x = self.x[j] - x = self.image_data_generator.random_transform(x.astype(K.floatx())) - x = self.image_data_generator.standardize(x) - batch_x[i] = x - if self.save_to_dir: - for i, j in enumerate(index_array): - img = array_to_img(batch_x[i], self.data_format, scale=True) - fname = '{prefix}_{index}_{hash}.{format}'.format( - prefix=self.save_prefix, - index=j, - hash=np.random.randint(1e4), - format=self.save_format) - img.save(os.path.join(self.save_to_dir, fname)) - if self.y is None: - return batch_x - batch_y = self.y[index_array] - return batch_x, batch_y - - def next(self): - """For python 2.x. - - Returns: - The next batch. - """ - # Keeps under lock only the mechanism which advances - # the indexing of each batch. - with self.lock: - index_array = next(self.index_generator) - # The transformation of images is not under thread lock - # so it can be done in parallel - return self._get_batches_of_transformed_samples(index_array) - - -def _iter_valid_files(directory, white_list_formats, follow_links): - """Count files with extension in `white_list_formats` contained in directory. - - Arguments: - directory: absolute path to the directory - containing files to be counted - white_list_formats: set of strings containing allowed extensions for - the files to be counted. - follow_links: boolean. - - Yields: - tuple of (root, filename) with extension in `white_list_formats`. - """ - - def _recursive_list(subpath): - return sorted( - os.walk(subpath, followlinks=follow_links), key=lambda x: x[0]) - - for root, _, files in _recursive_list(directory): - for fname in sorted(files): - for extension in white_list_formats: - if fname.lower().endswith('.tiff'): - logging.warning( - 'Using \'.tiff\' files with multiple bands will cause ' - 'distortion. Please verify your output.') - if fname.lower().endswith('.' + extension): - yield root, fname - - -def _count_valid_files_in_directory(directory, white_list_formats, split, - follow_links): - """Count files with extension in `white_list_formats` contained in directory. - - Arguments: - directory: absolute path to the directory - containing files to be counted - white_list_formats: set of strings containing allowed extensions for - the files to be counted. - split: tuple of floats (e.g. `(0.2, 0.6)`) to only take into - account a certain fraction of files in each directory. - E.g.: `segment=(0.6, 1.0)` would only account for last 40 percent - of images in each directory. - follow_links: boolean. - - Returns: - the count of files with extension in `white_list_formats` contained in - the directory. - """ - num_files = len( - list(_iter_valid_files(directory, white_list_formats, follow_links))) - if split: - start, stop = int(split[0] * num_files), int(split[1] * num_files) - else: - start, stop = 0, num_files - return stop - start - - -def _list_valid_filenames_in_directory(directory, white_list_formats, split, - class_indices, follow_links): - """List paths of files in `subdir` with extensions in `white_list_formats`. - - Arguments: - directory: absolute path to a directory containing the files to list. - The directory name is used as class label and must be a key of - `class_indices`. - white_list_formats: set of strings containing allowed extensions for - the files to be counted. - split: tuple of floats (e.g. `(0.2, 0.6)`) to only take into - account a certain fraction of files in each directory. - E.g.: `segment=(0.6, 1.0)` would only account for last 40 percent - of images in each directory. - class_indices: dictionary mapping a class name to its index. - follow_links: boolean. - - Returns: - classes: a list of class indices - filenames: the path of valid files in `directory`, relative from - `directory`'s parent (e.g., if `directory` is "dataset/class1", - the filenames will be ["class1/file1.jpg", "class1/file2.jpg", ...]). - """ - dirname = os.path.basename(directory) - if split: - num_files = len( - list(_iter_valid_files(directory, white_list_formats, follow_links))) - start, stop = int(split[0] * num_files), int(split[1] * num_files) - valid_files = list( - _iter_valid_files(directory, white_list_formats, - follow_links))[start:stop] - else: - valid_files = _iter_valid_files(directory, white_list_formats, follow_links) - - classes = [] - filenames = [] - for root, fname in valid_files: - classes.append(class_indices[dirname]) - absolute_path = os.path.join(root, fname) - relative_path = os.path.join(dirname, - os.path.relpath(absolute_path, directory)) - filenames.append(relative_path) - - return classes, filenames - - -@tf_export('keras.preprocessing.image.DirectoryIterator') -class DirectoryIterator(Iterator): - """Iterator capable of reading images from a directory on disk. - - Arguments: - directory: Path to the directory to read images from. - Each subdirectory in this directory will be - considered to contain images from one class, - or alternatively you could specify class subdirectories - via the `classes` argument. - image_data_generator: Instance of `ImageDataGenerator` - to use for random transformations and normalization. - target_size: tuple of integers, dimensions to resize input images to. - color_mode: One of `"rgb"`, `"grayscale"`. Color mode to read images. - classes: Optional list of strings, names of subdirectories - containing images from each class (e.g. `["dogs", "cats"]`). - It will be computed automatically if not set. - class_mode: Mode for yielding the targets: - `"binary"`: binary targets (if there are only two classes), - `"categorical"`: categorical targets, - `"sparse"`: integer targets, - `"input"`: targets are images identical to input images (mainly - used to work with autoencoders), - `None`: no targets get yielded (only input images are yielded). - batch_size: Integer, size of a batch. - shuffle: Boolean, whether to shuffle the data between epochs. - seed: Random seed for data shuffling. - data_format: String, one of `channels_first`, `channels_last`. - save_to_dir: Optional directory where to save the pictures - being yielded, in a viewable format. This is useful - for visualizing the random transformations being - applied, for debugging purposes. - save_prefix: String prefix to use for saving sample - images (if `save_to_dir` is set). - save_format: Format to use for saving sample images - (if `save_to_dir` is set). - subset: Subset of data (`"training"` or `"validation"`) if - validation_split is set in ImageDataGenerator. - interpolation: Interpolation method used to resample the image if the - target size is different from that of the loaded image. - Supported methods are "nearest", "bilinear", and "bicubic". - If PIL version 1.1.3 or newer is installed, "lanczos" is also - supported. If PIL version 3.4.0 or newer is installed, "box" and - "hamming" are also supported. By default, "nearest" is used. - """ - - def __init__(self, - directory, - image_data_generator, - target_size=(256, 256), - color_mode='rgb', - classes=None, - class_mode='categorical', - batch_size=32, - shuffle=True, - seed=None, - data_format=None, - save_to_dir=None, - save_prefix='', - save_format='png', - follow_links=False, - subset=None, - interpolation='nearest'): - if data_format is None: - data_format = K.image_data_format() - self.directory = directory - self.image_data_generator = image_data_generator - self.target_size = tuple(target_size) - if color_mode not in {'rgb', 'grayscale'}: - raise ValueError('Invalid color mode:', color_mode, - '; expected "rgb" or "grayscale".') - self.color_mode = color_mode - self.data_format = data_format - if self.color_mode == 'rgb': - if self.data_format == 'channels_last': - self.image_shape = self.target_size + (3,) - else: - self.image_shape = (3,) + self.target_size - else: - if self.data_format == 'channels_last': - self.image_shape = self.target_size + (1,) - else: - self.image_shape = (1,) + self.target_size - self.classes = classes - if class_mode not in {'categorical', 'binary', 'sparse', 'input', None}: - raise ValueError('Invalid class_mode:', class_mode, - '; expected one of "categorical", ' - '"binary", "sparse", "input"' - ' or None.') - self.class_mode = class_mode - self.save_to_dir = save_to_dir - self.save_prefix = save_prefix - self.save_format = save_format - self.interpolation = interpolation - - if subset is not None: - validation_split = self.image_data_generator.validation_split - if subset == 'validation': - split = (0, validation_split) - elif subset == 'training': - split = (validation_split, 1) - else: - raise ValueError('Invalid subset name: ', subset, - '; expected "training" or "validation"') - else: - split = None - self.subset = subset - - white_list_formats = {'png', 'jpg', 'jpeg', 'bmp', 'ppm', 'tif', 'tiff'} - - # first, count the number of samples and classes - self.samples = 0 - - if not classes: - classes = [] - for subdir in sorted(os.listdir(directory)): - if os.path.isdir(os.path.join(directory, subdir)): - classes.append(subdir) - self.num_classes = len(classes) - self.class_indices = dict(zip(classes, range(len(classes)))) - - pool = multiprocessing.pool.ThreadPool() - function_partial = partial( - _count_valid_files_in_directory, - white_list_formats=white_list_formats, - follow_links=follow_links, - split=split) - self.samples = sum( - pool.map(function_partial, - (os.path.join(directory, subdir) for subdir in classes))) - - print('Found %d images belonging to %d classes.' % (self.samples, - self.num_classes)) - - # second, build an index of the images in the different class subfolders - results = [] - - self.filenames = [] - self.classes = np.zeros((self.samples,), dtype='int32') - i = 0 - for dirpath in (os.path.join(directory, subdir) for subdir in classes): - results.append( - pool.apply_async(_list_valid_filenames_in_directory, - (dirpath, white_list_formats, split, - self.class_indices, follow_links))) - for res in results: - classes, filenames = res.get() - self.classes[i:i + len(classes)] = classes - self.filenames += filenames - i += len(classes) - - pool.close() - pool.join() - super(DirectoryIterator, self).__init__(self.samples, batch_size, shuffle, - seed) - - def _get_batches_of_transformed_samples(self, index_array): - batch_x = np.zeros((len(index_array),) + self.image_shape, dtype=K.floatx()) - grayscale = self.color_mode == 'grayscale' - # build batch of image data - for i, j in enumerate(index_array): - fname = self.filenames[j] - img = load_img( - os.path.join(self.directory, fname), - grayscale=grayscale, - target_size=self.target_size, - interpolation=self.interpolation) - x = img_to_array(img, data_format=self.data_format) - x = self.image_data_generator.random_transform(x) - x = self.image_data_generator.standardize(x) - batch_x[i] = x - # optionally save augmented images to disk for debugging purposes - if self.save_to_dir: - for i, j in enumerate(index_array): - img = array_to_img(batch_x[i], self.data_format, scale=True) - fname = '{prefix}_{index}_{hash}.{format}'.format( - prefix=self.save_prefix, - index=j, - hash=np.random.randint(1e7), - format=self.save_format) - img.save(os.path.join(self.save_to_dir, fname)) - # build batch of labels - if self.class_mode == 'input': - batch_y = batch_x.copy() - elif self.class_mode == 'sparse': - batch_y = self.classes[index_array] - elif self.class_mode == 'binary': - batch_y = self.classes[index_array].astype(K.floatx()) - elif self.class_mode == 'categorical': - batch_y = np.zeros((len(batch_x), self.num_classes), dtype=K.floatx()) - for i, label in enumerate(self.classes[index_array]): - batch_y[i, label] = 1. - else: - return batch_x - return batch_x, batch_y - - def next(self): - """For python 2.x. +from tensorflow.python.util.tf_export import tf_export - Returns: - The next batch. - """ - with self.lock: - index_array = next(self.index_generator) - # The transformation of images is not under thread lock - # so it can be done in parallel - return self._get_batches_of_transformed_samples(index_array) +random_rotation = image.random_rotation +random_shift = image.random_shift +random_shear = image.random_shear +random_zoom = image.random_zoom +apply_channel_shift = image.apply_channel_shift +random_channel_shift = image.random_channel_shift +apply_brightness_shift = image.apply_brightness_shift +random_brightness = image.random_brightness +apply_affine_transform = image.apply_affine_transform +array_to_img = image.array_to_img +img_to_array = image.img_to_array +save_img = image.save_img +load_img = image.load_img +ImageDataGenerator = image.ImageDataGenerator +Iterator = image.Iterator +NumpyArrayIterator = image.NumpyArrayIterator +DirectoryIterator = image.DirectoryIterator + +tf_export('keras.preprocessing.image.random_rotation')(random_rotation) +tf_export('keras.preprocessing.image.random_shift')(random_shift) +tf_export('keras.preprocessing.image.random_shear')(random_shear) +tf_export('keras.preprocessing.image.random_zoom')(random_zoom) +tf_export('keras.preprocessing.image.apply_channel_shift')(apply_channel_shift) +tf_export( + 'keras.preprocessing.image.random_channel_shift')(random_channel_shift) +tf_export( + 'keras.preprocessing.image.apply_brightness_shift')(apply_brightness_shift) +tf_export('keras.preprocessing.image.random_brightness')(random_brightness) +tf_export( + 'keras.preprocessing.image.apply_affine_transform')(apply_affine_transform) +tf_export('keras.preprocessing.image.array_to_img')(array_to_img) +tf_export('keras.preprocessing.image.img_to_array')(img_to_array) +tf_export('keras.preprocessing.image.save_img')(save_img) +tf_export('keras.preprocessing.image.load_img')(load_img) +tf_export('keras.preprocessing.image.ImageDataGenerator')(ImageDataGenerator) +tf_export('keras.preprocessing.image.Iterator')(Iterator) +tf_export('keras.preprocessing.image.NumpyArrayIterator')(NumpyArrayIterator) +tf_export('keras.preprocessing.image.DirectoryIterator')(DirectoryIterator) diff --git a/tensorflow/python/keras/preprocessing/image_test.py b/tensorflow/python/keras/preprocessing/image_test.py index 275808a615..362cbc1dc9 100644 --- a/tensorflow/python/keras/preprocessing/image_test.py +++ b/tensorflow/python/keras/preprocessing/image_test.py @@ -161,9 +161,6 @@ class TestImage(test.TestCase): generator = keras.preprocessing.image.ImageDataGenerator( zoom_range=(2, 2)) - with self.assertRaises(ValueError): - generator = keras.preprocessing.image.ImageDataGenerator( - zoom_range=(2, 2, 2)) def test_image_data_generator_fit(self): generator = keras.preprocessing.image.ImageDataGenerator( diff --git a/tensorflow/python/keras/preprocessing/sequence.py b/tensorflow/python/keras/preprocessing/sequence.py index e0924f837a..116d3108d9 100644 --- a/tensorflow/python/keras/preprocessing/sequence.py +++ b/tensorflow/python/keras/preprocessing/sequence.py @@ -14,383 +14,25 @@ # ============================================================================== """Utilities for preprocessing sequence data. """ +# pylint: disable=invalid-name from __future__ import absolute_import from __future__ import division from __future__ import print_function -import random +from keras_preprocessing import sequence -import numpy as np -from six.moves import range # pylint: disable=redefined-builtin - -from tensorflow.python.keras.utils.data_utils import Sequence from tensorflow.python.util.tf_export import tf_export - -@tf_export('keras.preprocessing.sequence.pad_sequences') -def pad_sequences(sequences, - maxlen=None, - dtype='int32', - padding='pre', - truncating='pre', - value=0.): - """Pads sequences to the same length. - - This function transforms a list of - `num_samples` sequences (lists of integers) - into a 2D Numpy array of shape `(num_samples, num_timesteps)`. - `num_timesteps` is either the `maxlen` argument if provided, - or the length of the longest sequence otherwise. - - Sequences that are shorter than `num_timesteps` - are padded with `value` at the end. - - Sequences longer than `num_timesteps` are truncated - so that they fit the desired length. - The position where padding or truncation happens is determined by - the arguments `padding` and `truncating`, respectively. - - Pre-padding is the default. - - Arguments: - sequences: List of lists, where each element is a sequence. - maxlen: Int, maximum length of all sequences. - dtype: Type of the output sequences. - padding: String, 'pre' or 'post': - pad either before or after each sequence. - truncating: String, 'pre' or 'post': - remove values from sequences larger than - `maxlen`, either at the beginning or at the end of the sequences. - value: Float, padding value. - - Returns: - x: Numpy array with shape `(len(sequences), maxlen)` - - Raises: - ValueError: In case of invalid values for `truncating` or `padding`, - or in case of invalid shape for a `sequences` entry. - """ - if not hasattr(sequences, '__len__'): - raise ValueError('`sequences` must be iterable.') - lengths = [] - for x in sequences: - if not hasattr(x, '__len__'): - raise ValueError('`sequences` must be a list of iterables. ' - 'Found non-iterable: ' + str(x)) - lengths.append(len(x)) - - num_samples = len(sequences) - if maxlen is None: - maxlen = np.max(lengths) - - # take the sample shape from the first non empty sequence - # checking for consistency in the main loop below. - sample_shape = tuple() - for s in sequences: - if len(s) > 0: # pylint: disable=g-explicit-length-test - sample_shape = np.asarray(s).shape[1:] - break - - x = (np.ones((num_samples, maxlen) + sample_shape) * value).astype(dtype) - for idx, s in enumerate(sequences): - if not len(s): # pylint: disable=g-explicit-length-test - continue # empty list/array was found - if truncating == 'pre': - trunc = s[-maxlen:] # pylint: disable=invalid-unary-operand-type - elif truncating == 'post': - trunc = s[:maxlen] - else: - raise ValueError('Truncating type "%s" not understood' % truncating) - - # check `trunc` has expected shape - trunc = np.asarray(trunc, dtype=dtype) - if trunc.shape[1:] != sample_shape: - raise ValueError('Shape of sample %s of sequence at position %s ' - 'is different from expected shape %s' % - (trunc.shape[1:], idx, sample_shape)) - - if padding == 'post': - x[idx, :len(trunc)] = trunc - elif padding == 'pre': - x[idx, -len(trunc):] = trunc - else: - raise ValueError('Padding type "%s" not understood' % padding) - return x - - -@tf_export('keras.preprocessing.sequence.make_sampling_table') -def make_sampling_table(size, sampling_factor=1e-5): - """Generates a word rank-based probabilistic sampling table. - - Used for generating the `sampling_table` argument for `skipgrams`. - `sampling_table[i]` is the probability of sampling - the word i-th most common word in a dataset - (more common words should be sampled less frequently, for balance). - - The sampling probabilities are generated according - to the sampling distribution used in word2vec: - - `p(word) = min(1, sqrt(word_frequency / sampling_factor) / (word_frequency / - sampling_factor))` - - We assume that the word frequencies follow Zipf's law (s=1) to derive - a numerical approximation of frequency(rank): - - `frequency(rank) ~ 1/(rank * (log(rank) + gamma) + 1/2 - 1/(12*rank))` - where `gamma` is the Euler-Mascheroni constant. - - Arguments: - size: Int, number of possible words to sample. - sampling_factor: The sampling factor in the word2vec formula. - - Returns: - A 1D Numpy array of length `size` where the ith entry - is the probability that a word of rank i should be sampled. - """ - gamma = 0.577 - rank = np.arange(size) - rank[0] = 1 - inv_fq = rank * (np.log(rank) + gamma) + 0.5 - 1. / (12. * rank) - f = sampling_factor * inv_fq - - return np.minimum(1., f / np.sqrt(f)) - - -@tf_export('keras.preprocessing.sequence.skipgrams') -def skipgrams(sequence, - vocabulary_size, - window_size=4, - negative_samples=1., - shuffle=True, - categorical=False, - sampling_table=None, - seed=None): - """Generates skipgram word pairs. - - This function transforms a sequence of word indexes (list of integers) - into tuples of words of the form: - - - (word, word in the same window), with label 1 (positive samples). - - (word, random word from the vocabulary), with label 0 (negative samples). - - Read more about Skipgram in this gnomic paper by Mikolov et al.: - [Efficient Estimation of Word Representations in - Vector Space](http://arxiv.org/pdf/1301.3781v3.pdf) - - Arguments: - sequence: A word sequence (sentence), encoded as a list - of word indices (integers). If using a `sampling_table`, - word indices are expected to match the rank - of the words in a reference dataset (e.g. 10 would encode - the 10-th most frequently occurring token). - Note that index 0 is expected to be a non-word and will be skipped. - vocabulary_size: Int, maximum possible word index + 1 - window_size: Int, size of sampling windows (technically half-window). - The window of a word `w_i` will be - `[i - window_size, i + window_size+1]`. - negative_samples: Float >= 0. 0 for no negative (i.e. random) samples. - 1 for same number as positive samples. - shuffle: Whether to shuffle the word couples before returning them. - categorical: bool. if False, labels will be - integers (eg. `[0, 1, 1 .. ]`), - if `True`, labels will be categorical, e.g. - `[[1,0],[0,1],[0,1] .. ]`. - sampling_table: 1D array of size `vocabulary_size` where the entry i - encodes the probability to sample a word of rank i. - seed: Random seed. - - Returns: - couples, labels: where `couples` are int pairs and - `labels` are either 0 or 1. - - # Note - By convention, index 0 in the vocabulary is - a non-word and will be skipped. - """ - couples = [] - labels = [] - for i, wi in enumerate(sequence): - if not wi: - continue - if sampling_table is not None: - if sampling_table[wi] < random.random(): - continue - - window_start = max(0, i - window_size) - window_end = min(len(sequence), i + window_size + 1) - for j in range(window_start, window_end): - if j != i: - wj = sequence[j] - if not wj: - continue - couples.append([wi, wj]) - if categorical: - labels.append([0, 1]) - else: - labels.append(1) - - if negative_samples > 0: - num_negative_samples = int(len(labels) * negative_samples) - words = [c[0] for c in couples] - random.shuffle(words) - - couples += [[words[i % len(words)], - random.randint(1, vocabulary_size - 1)] - for i in range(num_negative_samples)] - if categorical: - labels += [[1, 0]] * num_negative_samples - else: - labels += [0] * num_negative_samples - - if shuffle: - if seed is None: - seed = random.randint(0, 10e6) - random.seed(seed) - random.shuffle(couples) - random.seed(seed) - random.shuffle(labels) - - return couples, labels - - -def _remove_long_seq(maxlen, seq, label): - """Removes sequences that exceed the maximum length. - - Arguments: - maxlen: Int, maximum length of the output sequences. - seq: List of lists, where each sublist is a sequence. - label: List where each element is an integer. - - Returns: - new_seq, new_label: shortened lists for `seq` and `label`. - """ - new_seq, new_label = [], [] - for x, y in zip(seq, label): - if len(x) < maxlen: - new_seq.append(x) - new_label.append(y) - return new_seq, new_label - - -@tf_export('keras.preprocessing.sequence.TimeseriesGenerator') -class TimeseriesGenerator(Sequence): - """Utility class for generating batches of temporal data. - - This class takes in a sequence of data-points gathered at - equal intervals, along with time series parameters such as - stride, length of history, etc., to produce batches for - training/validation. - - Arguments: - data: Indexable generator (such as list or Numpy array) - containing consecutive data points (timesteps). - The data should be at 2D, and axis 0 is expected - to be the time dimension. - targets: Targets corresponding to timesteps in `data`. - It should have same length as `data`. - length: Length of the output sequences (in number of timesteps). - sampling_rate: Period between successive individual timesteps - within sequences. For rate `r`, timesteps - `data[i]`, `data[i-r]`, ... `data[i - length]` - are used for create a sample sequence. - stride: Period between successive output sequences. - For stride `s`, consecutive output samples would - be centered around `data[i]`, `data[i+s]`, `data[i+2*s]`, etc. - start_index, end_index: Data points earlier than `start_index` - or later than `end_index` will not be used in the output sequences. - This is useful to reserve part of the data for test or validation. - shuffle: Whether to shuffle output samples, - or instead draw them in chronological order. - reverse: Boolean: if `true`, timesteps in each output sample will be - in reverse chronological order. - batch_size: Number of timeseries samples in each batch - (except maybe the last one). - - Returns: - A [Sequence](/utils/#sequence) instance. - - Examples: - - ```python - from keras.preprocessing.sequence import TimeseriesGenerator - import numpy as np - - data = np.array([[i] for i in range(50)]) - targets = np.array([[i] for i in range(50)]) - - data_gen = TimeseriesGenerator(data, targets, - length=10, sampling_rate=2, - batch_size=2) - assert len(data_gen) == 20 - - batch_0 = data_gen[0] - x, y = batch_0 - assert np.array_equal(x, - np.array([[[0], [2], [4], [6], [8]], - [[1], [3], [5], [7], [9]]])) - assert np.array_equal(y, - np.array([[10], [11]])) - ``` - """ - - def __init__(self, - data, - targets, - length, - sampling_rate=1, - stride=1, - start_index=0, - end_index=None, - shuffle=False, - reverse=False, - batch_size=128): - self.data = data - self.targets = targets - self.length = length - self.sampling_rate = sampling_rate - self.stride = stride - self.start_index = start_index + length - if end_index is None: - end_index = len(data) - 1 - self.end_index = end_index - self.shuffle = shuffle - self.reverse = reverse - self.batch_size = batch_size - - if self.start_index > self.end_index: - raise ValueError('`start_index+length=%i > end_index=%i` ' - 'is disallowed, as no part of the sequence ' - 'would be left to be used as current step.' % - (self.start_index, self.end_index)) - - def __len__(self): - length = int( - np.ceil((self.end_index - self.start_index + 1) / - (self.batch_size * self.stride))) - return length if length >= 0 else 0 - - def _empty_batch(self, num_rows): - samples_shape = [num_rows, self.length // self.sampling_rate] - samples_shape.extend(self.data.shape[1:]) - targets_shape = [num_rows] - targets_shape.extend(self.targets.shape[1:]) - return np.empty(samples_shape), np.empty(targets_shape) - - def __getitem__(self, index): - if self.shuffle: - rows = np.random.randint( - self.start_index, self.end_index + 1, size=self.batch_size) - else: - i = self.start_index + self.batch_size * self.stride * index - rows = np.arange( - i, min(i + self.batch_size * self.stride, self.end_index + 1), - self.stride) - - samples, targets = self._empty_batch(len(rows)) - for j in range(len(rows)): - indices = range(rows[j] - self.length, rows[j], self.sampling_rate) - samples[j] = self.data[indices] - targets[j] = self.targets[rows[j]] - if self.reverse: - return samples[:, ::-1, ...], targets - return samples, targets +pad_sequences = sequence.pad_sequences +make_sampling_table = sequence.make_sampling_table +skipgrams = sequence.skipgrams +# TODO(fchollet): consider making `_remove_long_seq` public. +_remove_long_seq = sequence._remove_long_seq # pylint: disable=protected-access +TimeseriesGenerator = sequence.TimeseriesGenerator + +tf_export('keras.preprocessing.sequence.pad_sequences')(pad_sequences) +tf_export( + 'keras.preprocessing.sequence.make_sampling_table')(make_sampling_table) +tf_export('keras.preprocessing.sequence.skipgrams')(skipgrams) +tf_export( + 'keras.preprocessing.sequence.TimeseriesGenerator')(TimeseriesGenerator) diff --git a/tensorflow/python/keras/preprocessing/text.py b/tensorflow/python/keras/preprocessing/text.py index f3b57de257..57e5d00e04 100644 --- a/tensorflow/python/keras/preprocessing/text.py +++ b/tensorflow/python/keras/preprocessing/text.py @@ -14,383 +14,22 @@ # ============================================================================== """Utilities for text input preprocessing. """ +# pylint: disable=invalid-name from __future__ import absolute_import from __future__ import division from __future__ import print_function -from collections import OrderedDict -from hashlib import md5 -import string -import sys +from keras_preprocessing import text -import numpy as np -from six.moves import range # pylint: disable=redefined-builtin -from six.moves import zip # pylint: disable=redefined-builtin - -from tensorflow.python.platform import tf_logging as logging from tensorflow.python.util.tf_export import tf_export +text_to_word_sequence = text.text_to_word_sequence +one_hot = text.one_hot +hashing_trick = text.hashing_trick +Tokenizer = text.Tokenizer -if sys.version_info < (3,): - maketrans = string.maketrans -else: - maketrans = str.maketrans - - -@tf_export('keras.preprocessing.text.text_to_word_sequence') -def text_to_word_sequence(text, - filters='!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~\t\n', - lower=True, - split=' '): - r"""Converts a text to a sequence of words (or tokens). - - Arguments: - text: Input text (string). - filters: list (or concatenation) of characters to filter out, such as - punctuation. Default: '!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~\t\n', - includes basic punctuation, tabs, and newlines. - lower: boolean, whether to convert the input to lowercase. - split: string, separator for word splitting. - - Returns: - A list of words (or tokens). - """ - if lower: - text = text.lower() - - if sys.version_info < (3,): - if isinstance(text, unicode): - translate_map = dict((ord(c), unicode(split)) for c in filters) - text = text.translate(translate_map) - elif len(split) == 1: - translate_map = maketrans(filters, split * len(filters)) - text = text.translate(translate_map) - else: - for c in filters: - text = text.replace(c, split) - else: - translate_dict = dict((c, split) for c in filters) - translate_map = maketrans(translate_dict) - text = text.translate(translate_map) - - seq = text.split(split) - return [i for i in seq if i] - - -@tf_export('keras.preprocessing.text.one_hot') -def one_hot(text, - n, - filters='!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~\t\n', - lower=True, - split=' '): - r"""One-hot encodes a text into a list of word indexes of size n. - - This is a wrapper to the `hashing_trick` function using `hash` as the - hashing function; unicity of word to index mapping non-guaranteed. - - Arguments: - text: Input text (string). - n: int, size of vocabulary. - filters: list (or concatenation) of characters to filter out, such as - punctuation. Default: '!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~\t\n', - includes basic punctuation, tabs, and newlines. - lower: boolean, whether to set the text to lowercase. - split: string, separator for word splitting. - - Returns: - List of integers in [1, n]. - Each integer encodes a word (unicity non-guaranteed). - """ - return hashing_trick( - text, n, hash_function=hash, filters=filters, lower=lower, split=split) - - -@tf_export('keras.preprocessing.text.hashing_trick') -def hashing_trick(text, - n, - hash_function=None, - filters='!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~\t\n', - lower=True, - split=' '): - r"""Converts a text to a sequence of indexes in a fixed-size hashing space. - - Arguments: - text: Input text (string). - n: Dimension of the hashing space. - hash_function: defaults to python `hash` function, can be 'md5' or - any function that takes in input a string and returns a int. - Note that 'hash' is not a stable hashing function, so - it is not consistent across different runs, while 'md5' - is a stable hashing function. - filters: list (or concatenation) of characters to filter out, such as - punctuation. Default: '!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~\t\n', - includes basic punctuation, tabs, and newlines. - lower: boolean, whether to set the text to lowercase. - split: string, separator for word splitting. - - Returns: - A list of integer word indices (unicity non-guaranteed). - - `0` is a reserved index that won't be assigned to any word. - - Two or more words may be assigned to the same index, due to possible - collisions by the hashing function. - The - probability - of a collision is in relation to the dimension of the hashing space and - the number of distinct objects. - """ - if hash_function is None: - hash_function = hash - elif hash_function == 'md5': - hash_function = lambda w: int(md5(w.encode()).hexdigest(), 16) - - seq = text_to_word_sequence(text, filters=filters, lower=lower, split=split) - return [(hash_function(w) % (n - 1) + 1) for w in seq] - - -@tf_export('keras.preprocessing.text.Tokenizer') -class Tokenizer(object): - """Text tokenization utility class. - - This class allows to vectorize a text corpus, by turning each - text into either a sequence of integers (each integer being the index - of a token in a dictionary) or into a vector where the coefficient - for each token could be binary, based on word count, based on tf-idf... - - Arguments: - num_words: the maximum number of words to keep, based - on word frequency. Only the most common `num_words` words will - be kept. - filters: a string where each element is a character that will be - filtered from the texts. The default is all punctuation, plus - tabs and line breaks, minus the `'` character. - lower: boolean. Whether to convert the texts to lowercase. - split: string, separator for word splitting. - char_level: if True, every character will be treated as a token. - oov_token: if given, it will be added to word_index and used to - replace out-of-vocabulary words during text_to_sequence calls - - By default, all punctuation is removed, turning the texts into - space-separated sequences of words - (words maybe include the `'` character). These sequences are then - split into lists of tokens. They will then be indexed or vectorized. - - `0` is a reserved index that won't be assigned to any word. - """ - - def __init__(self, - num_words=None, - filters='!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~\t\n', - lower=True, - split=' ', - char_level=False, - oov_token=None, - **kwargs): - # Legacy support - if 'nb_words' in kwargs: - logging.warning('The `nb_words` argument in `Tokenizer` ' - 'has been renamed `num_words`.') - num_words = kwargs.pop('nb_words') - if kwargs: - raise TypeError('Unrecognized keyword arguments: ' + str(kwargs)) - - self.word_counts = OrderedDict() - self.word_docs = {} - self.filters = filters - self.split = split - self.lower = lower - self.num_words = num_words - self.document_count = 0 - self.char_level = char_level - self.oov_token = oov_token - self.index_docs = {} - - def fit_on_texts(self, texts): - """Updates internal vocabulary based on a list of texts. - - In the case where texts contains lists, we assume each entry of the lists - to be a token. - - Required before using `texts_to_sequences` or `texts_to_matrix`. - - Arguments: - texts: can be a list of strings, - a generator of strings (for memory-efficiency), - or a list of list of strings. - """ - for text in texts: - self.document_count += 1 - if self.char_level or isinstance(text, list): - seq = text - else: - seq = text_to_word_sequence(text, self.filters, self.lower, self.split) - for w in seq: - if w in self.word_counts: - self.word_counts[w] += 1 - else: - self.word_counts[w] = 1 - for w in set(seq): - if w in self.word_docs: - self.word_docs[w] += 1 - else: - self.word_docs[w] = 1 - - wcounts = list(self.word_counts.items()) - wcounts.sort(key=lambda x: x[1], reverse=True) - sorted_voc = [wc[0] for wc in wcounts] - # note that index 0 is reserved, never assigned to an existing word - self.word_index = dict( - list(zip(sorted_voc, list(range(1, - len(sorted_voc) + 1))))) - - if self.oov_token is not None: - i = self.word_index.get(self.oov_token) - if i is None: - self.word_index[self.oov_token] = len(self.word_index) + 1 - - for w, c in list(self.word_docs.items()): - self.index_docs[self.word_index[w]] = c - - def fit_on_sequences(self, sequences): - """Updates internal vocabulary based on a list of sequences. - - Required before using `sequences_to_matrix` - (if `fit_on_texts` was never called). - - Arguments: - sequences: A list of sequence. - A "sequence" is a list of integer word indices. - """ - self.document_count += len(sequences) - for seq in sequences: - seq = set(seq) - for i in seq: - if i not in self.index_docs: - self.index_docs[i] = 1 - else: - self.index_docs[i] += 1 - - def texts_to_sequences(self, texts): - """Transforms each text in texts in a sequence of integers. - - Only top "num_words" most frequent words will be taken into account. - Only words known by the tokenizer will be taken into account. - - Arguments: - texts: A list of texts (strings). - - Returns: - A list of sequences. - """ - res = [] - for vect in self.texts_to_sequences_generator(texts): - res.append(vect) - return res - - def texts_to_sequences_generator(self, texts): - """Transforms each text in `texts` in a sequence of integers. - - Each item in texts can also be a list, in which case we assume each item of - that list - to be a token. - - Only top "num_words" most frequent words will be taken into account. - Only words known by the tokenizer will be taken into account. - - Arguments: - texts: A list of texts (strings). - - Yields: - Yields individual sequences. - """ - num_words = self.num_words - for text in texts: - if self.char_level or isinstance(text, list): - seq = text - else: - seq = text_to_word_sequence(text, self.filters, self.lower, self.split) - vect = [] - for w in seq: - i = self.word_index.get(w) - if i is not None: - if num_words and i >= num_words: - continue - else: - vect.append(i) - elif self.oov_token is not None: - i = self.word_index.get(self.oov_token) - if i is not None: - vect.append(i) - yield vect - - def texts_to_matrix(self, texts, mode='binary'): - """Convert a list of texts to a Numpy matrix. - - Arguments: - texts: list of strings. - mode: one of "binary", "count", "tfidf", "freq". - - Returns: - A Numpy matrix. - """ - sequences = self.texts_to_sequences(texts) - return self.sequences_to_matrix(sequences, mode=mode) - - def sequences_to_matrix(self, sequences, mode='binary'): - """Converts a list of sequences into a Numpy matrix. - - Arguments: - sequences: list of sequences - (a sequence is a list of integer word indices). - mode: one of "binary", "count", "tfidf", "freq" - - Returns: - A Numpy matrix. - - Raises: - ValueError: In case of invalid `mode` argument, - or if the Tokenizer requires to be fit to sample data. - """ - if not self.num_words: - if self.word_index: - num_words = len(self.word_index) + 1 - else: - raise ValueError('Specify a dimension (num_words argument), ' - 'or fit on some text data first.') - else: - num_words = self.num_words - - if mode == 'tfidf' and not self.document_count: - raise ValueError('Fit the Tokenizer on some data ' - 'before using tfidf mode.') - - x = np.zeros((len(sequences), num_words)) - for i, seq in enumerate(sequences): - if not seq: - continue - counts = {} - for j in seq: - if j >= num_words: - continue - if j not in counts: - counts[j] = 1. - else: - counts[j] += 1 - for j, c in list(counts.items()): - if mode == 'count': - x[i][j] = c - elif mode == 'freq': - x[i][j] = c / len(seq) - elif mode == 'binary': - x[i][j] = 1 - elif mode == 'tfidf': - # Use weighting scheme 2 in - # https://en.wikipedia.org/wiki/Tf%E2%80%93idf - tf = 1 + np.log(c) - idf = np.log(1 + self.document_count / - (1 + self.index_docs.get(j, 0))) - x[i][j] = tf * idf - else: - raise ValueError('Unknown vectorization mode:', mode) - return x +tf_export( + 'keras.preprocessing.text.text_to_word_sequence')(text_to_word_sequence) +tf_export('keras.preprocessing.text.one_hot')(one_hot) +tf_export('keras.preprocessing.text.hashing_trick')(hashing_trick) +tf_export('keras.preprocessing.text.Tokenizer')(Tokenizer) diff --git a/tensorflow/python/keras/utils/__init__.py b/tensorflow/python/keras/utils/__init__.py index 69337b6a8d..c442b31116 100644 --- a/tensorflow/python/keras/utils/__init__.py +++ b/tensorflow/python/keras/utils/__init__.py @@ -31,6 +31,7 @@ from tensorflow.python.keras.utils.generic_utils import Progbar from tensorflow.python.keras.utils.generic_utils import serialize_keras_object from tensorflow.python.keras.utils.io_utils import HDF5Matrix from tensorflow.python.keras.utils.layer_utils import convert_all_kernels_in_model +from tensorflow.python.keras.utils.layer_utils import get_source_inputs from tensorflow.python.keras.utils.multi_gpu_utils import multi_gpu_model from tensorflow.python.keras.utils.np_utils import normalize from tensorflow.python.keras.utils.np_utils import to_categorical diff --git a/tensorflow/python/tools/api/generator/api_init_files.bzl b/tensorflow/python/tools/api/generator/api_init_files.bzl index 7001e566ce..64f0469482 100644 --- a/tensorflow/python/tools/api/generator/api_init_files.bzl +++ b/tensorflow/python/tools/api/generator/api_init_files.bzl @@ -25,6 +25,7 @@ TENSORFLOW_API_INIT_FILES = [ "keras/applications/inception_resnet_v2/__init__.py", "keras/applications/inception_v3/__init__.py", "keras/applications/mobilenet/__init__.py", + "keras/applications/mobilenet_v2/__init__.py", "keras/applications/nasnet/__init__.py", "keras/applications/resnet50/__init__.py", "keras/applications/vgg16/__init__.py", diff --git a/tensorflow/python/tools/api/generator/api_init_files_v1.bzl b/tensorflow/python/tools/api/generator/api_init_files_v1.bzl index 73d11199d9..bc2f3516d1 100644 --- a/tensorflow/python/tools/api/generator/api_init_files_v1.bzl +++ b/tensorflow/python/tools/api/generator/api_init_files_v1.bzl @@ -25,6 +25,7 @@ TENSORFLOW_API_INIT_FILES_V1 = [ "keras/applications/inception_resnet_v2/__init__.py", "keras/applications/inception_v3/__init__.py", "keras/applications/mobilenet/__init__.py", + "keras/applications/mobilenet_v2/__init__.py", "keras/applications/nasnet/__init__.py", "keras/applications/resnet50/__init__.py", "keras/applications/vgg16/__init__.py", diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.densenet.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.densenet.pbtxt deleted file mode 100644 index 42cb914450..0000000000 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.densenet.pbtxt +++ /dev/null @@ -1,23 +0,0 @@ -path: "tensorflow.keras.applications.densenet" -tf_module { - member_method { - name: "DenseNet121" - argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "DenseNet169" - argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "DenseNet201" - argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "decode_predictions" - argspec: "args=[\'preds\', \'top\'], varargs=None, keywords=None, defaults=[\'5\'], " - } - member_method { - name: "preprocess_input" - argspec: "args=[\'x\', \'data_format\'], varargs=None, keywords=None, defaults=[\'None\'], " - } -} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.inception_resnet_v2.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.inception_resnet_v2.pbtxt deleted file mode 100644 index 211080c19b..0000000000 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.inception_resnet_v2.pbtxt +++ /dev/null @@ -1,15 +0,0 @@ -path: "tensorflow.keras.applications.inception_resnet_v2" -tf_module { - member_method { - name: "InceptionResNetV2" - argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "decode_predictions" - argspec: "args=[\'preds\', \'top\'], varargs=None, keywords=None, defaults=[\'5\'], " - } - member_method { - name: "preprocess_input" - argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" - } -} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.inception_v3.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.inception_v3.pbtxt deleted file mode 100644 index b67cee80ab..0000000000 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.inception_v3.pbtxt +++ /dev/null @@ -1,15 +0,0 @@ -path: "tensorflow.keras.applications.inception_v3" -tf_module { - member_method { - name: "InceptionV3" - argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "decode_predictions" - argspec: "args=[\'preds\', \'top\'], varargs=None, keywords=None, defaults=[\'5\'], " - } - member_method { - name: "preprocess_input" - argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" - } -} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.mobilenet.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.mobilenet.pbtxt deleted file mode 100644 index ef774e1dd7..0000000000 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.mobilenet.pbtxt +++ /dev/null @@ -1,15 +0,0 @@ -path: "tensorflow.keras.applications.mobilenet" -tf_module { - member_method { - name: "MobileNet" - argspec: "args=[\'input_shape\', \'alpha\', \'depth_multiplier\', \'dropout\', \'include_top\', \'weights\', \'input_tensor\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'None\', \'1.0\', \'1\', \'0.001\', \'True\', \'imagenet\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "decode_predictions" - argspec: "args=[\'preds\', \'top\'], varargs=None, keywords=None, defaults=[\'5\'], " - } - member_method { - name: "preprocess_input" - argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" - } -} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.nasnet.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.nasnet.pbtxt deleted file mode 100644 index cd75b87540..0000000000 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.nasnet.pbtxt +++ /dev/null @@ -1,19 +0,0 @@ -path: "tensorflow.keras.applications.nasnet" -tf_module { - member_method { - name: "NASNetLarge" - argspec: "args=[\'input_shape\', \'include_top\', \'weights\', \'input_tensor\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'None\', \'True\', \'imagenet\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "NASNetMobile" - argspec: "args=[\'input_shape\', \'include_top\', \'weights\', \'input_tensor\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'None\', \'True\', \'imagenet\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "decode_predictions" - argspec: "args=[\'preds\', \'top\'], varargs=None, keywords=None, defaults=[\'5\'], " - } - member_method { - name: "preprocess_input" - argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" - } -} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.pbtxt deleted file mode 100644 index 9fc086eb8e..0000000000 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.pbtxt +++ /dev/null @@ -1,87 +0,0 @@ -path: "tensorflow.keras.applications" -tf_module { - member { - name: "densenet" - mtype: "" - } - member { - name: "inception_resnet_v2" - mtype: "" - } - member { - name: "inception_v3" - mtype: "" - } - member { - name: "mobilenet" - mtype: "" - } - member { - name: "nasnet" - mtype: "" - } - member { - name: "resnet50" - mtype: "" - } - member { - name: "vgg16" - mtype: "" - } - member { - name: "vgg19" - mtype: "" - } - member { - name: "xception" - mtype: "" - } - member_method { - name: "DenseNet121" - argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "DenseNet169" - argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "DenseNet201" - argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "InceptionResNetV2" - argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "InceptionV3" - argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "MobileNet" - argspec: "args=[\'input_shape\', \'alpha\', \'depth_multiplier\', \'dropout\', \'include_top\', \'weights\', \'input_tensor\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'None\', \'1.0\', \'1\', \'0.001\', \'True\', \'imagenet\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "NASNetLarge" - argspec: "args=[\'input_shape\', \'include_top\', \'weights\', \'input_tensor\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'None\', \'True\', \'imagenet\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "NASNetMobile" - argspec: "args=[\'input_shape\', \'include_top\', \'weights\', \'input_tensor\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'None\', \'True\', \'imagenet\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "ResNet50" - argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "VGG16" - argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "VGG19" - argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "Xception" - argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " - } -} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.resnet50.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.resnet50.pbtxt deleted file mode 100644 index 7385af064d..0000000000 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.resnet50.pbtxt +++ /dev/null @@ -1,15 +0,0 @@ -path: "tensorflow.keras.applications.resnet50" -tf_module { - member_method { - name: "ResNet50" - argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "decode_predictions" - argspec: "args=[\'preds\', \'top\'], varargs=None, keywords=None, defaults=[\'5\'], " - } - member_method { - name: "preprocess_input" - argspec: "args=[\'x\', \'data_format\', \'mode\'], varargs=None, keywords=None, defaults=[\'None\', \'caffe\'], " - } -} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.vgg16.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.vgg16.pbtxt deleted file mode 100644 index ba66fba8f3..0000000000 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.vgg16.pbtxt +++ /dev/null @@ -1,15 +0,0 @@ -path: "tensorflow.keras.applications.vgg16" -tf_module { - member_method { - name: "VGG16" - argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "decode_predictions" - argspec: "args=[\'preds\', \'top\'], varargs=None, keywords=None, defaults=[\'5\'], " - } - member_method { - name: "preprocess_input" - argspec: "args=[\'x\', \'data_format\', \'mode\'], varargs=None, keywords=None, defaults=[\'None\', \'caffe\'], " - } -} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.vgg19.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.vgg19.pbtxt deleted file mode 100644 index e55a1345b6..0000000000 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.vgg19.pbtxt +++ /dev/null @@ -1,15 +0,0 @@ -path: "tensorflow.keras.applications.vgg19" -tf_module { - member_method { - name: "VGG19" - argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "decode_predictions" - argspec: "args=[\'preds\', \'top\'], varargs=None, keywords=None, defaults=[\'5\'], " - } - member_method { - name: "preprocess_input" - argspec: "args=[\'x\', \'data_format\', \'mode\'], varargs=None, keywords=None, defaults=[\'None\', \'caffe\'], " - } -} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.xception.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.xception.pbtxt deleted file mode 100644 index 59dd2108f2..0000000000 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.applications.xception.pbtxt +++ /dev/null @@ -1,15 +0,0 @@ -path: "tensorflow.keras.applications.xception" -tf_module { - member_method { - name: "Xception" - argspec: "args=[\'include_top\', \'weights\', \'input_tensor\', \'input_shape\', \'pooling\', \'classes\'], varargs=None, keywords=None, defaults=[\'True\', \'imagenet\', \'None\', \'None\', \'None\', \'1000\'], " - } - member_method { - name: "decode_predictions" - argspec: "args=[\'preds\', \'top\'], varargs=None, keywords=None, defaults=[\'5\'], " - } - member_method { - name: "preprocess_input" - argspec: "args=[\'x\'], varargs=None, keywords=None, defaults=None" - } -} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-directory-iterator.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-directory-iterator.pbtxt deleted file mode 100644 index dddace87dc..0000000000 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-directory-iterator.pbtxt +++ /dev/null @@ -1,23 +0,0 @@ -path: "tensorflow.keras.preprocessing.image.DirectoryIterator" -tf_class { - is_instance: "" - is_instance: "" - is_instance: "" - is_instance: "" - member_method { - name: "__init__" - argspec: "args=[\'self\', \'directory\', \'image_data_generator\', \'target_size\', \'color_mode\', \'classes\', \'class_mode\', \'batch_size\', \'shuffle\', \'seed\', \'data_format\', \'save_to_dir\', \'save_prefix\', \'save_format\', \'follow_links\', \'subset\', \'interpolation\'], varargs=None, keywords=None, defaults=[\'(256, 256)\', \'rgb\', \'None\', \'categorical\', \'32\', \'True\', \'None\', \'None\', \'None\', \'\', \'png\', \'False\', \'None\', \'nearest\'], " - } - member_method { - name: "next" - argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" - } - member_method { - name: "on_epoch_end" - argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" - } - member_method { - name: "reset" - argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" - } -} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-image-data-generator.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-image-data-generator.pbtxt deleted file mode 100644 index c1e2e94f0b..0000000000 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-image-data-generator.pbtxt +++ /dev/null @@ -1,29 +0,0 @@ -path: "tensorflow.keras.preprocessing.image.ImageDataGenerator" -tf_class { - is_instance: "" - is_instance: "" - member_method { - name: "__init__" - argspec: "args=[\'self\', \'featurewise_center\', \'samplewise_center\', \'featurewise_std_normalization\', \'samplewise_std_normalization\', \'zca_whitening\', \'zca_epsilon\', \'rotation_range\', \'width_shift_range\', \'height_shift_range\', \'brightness_range\', \'shear_range\', \'zoom_range\', \'channel_shift_range\', \'fill_mode\', \'cval\', \'horizontal_flip\', \'vertical_flip\', \'rescale\', \'preprocessing_function\', \'data_format\', \'validation_split\'], varargs=None, keywords=None, defaults=[\'False\', \'False\', \'False\', \'False\', \'False\', \'1e-06\', \'0.0\', \'0.0\', \'0.0\', \'None\', \'0.0\', \'0.0\', \'0.0\', \'nearest\', \'0.0\', \'False\', \'False\', \'None\', \'None\', \'None\', \'0.0\'], " - } - member_method { - name: "fit" - argspec: "args=[\'self\', \'x\', \'augment\', \'rounds\', \'seed\'], varargs=None, keywords=None, defaults=[\'False\', \'1\', \'None\'], " - } - member_method { - name: "flow" - argspec: "args=[\'self\', \'x\', \'y\', \'batch_size\', \'shuffle\', \'seed\', \'save_to_dir\', \'save_prefix\', \'save_format\', \'subset\'], varargs=None, keywords=None, defaults=[\'None\', \'32\', \'True\', \'None\', \'None\', \'\', \'png\', \'None\'], " - } - member_method { - name: "flow_from_directory" - argspec: "args=[\'self\', \'directory\', \'target_size\', \'color_mode\', \'classes\', \'class_mode\', \'batch_size\', \'shuffle\', \'seed\', \'save_to_dir\', \'save_prefix\', \'save_format\', \'follow_links\', \'subset\', \'interpolation\'], varargs=None, keywords=None, defaults=[\'(256, 256)\', \'rgb\', \'None\', \'categorical\', \'32\', \'True\', \'None\', \'None\', \'\', \'png\', \'False\', \'None\', \'nearest\'], " - } - member_method { - name: "random_transform" - argspec: "args=[\'self\', \'x\', \'seed\'], varargs=None, keywords=None, defaults=[\'None\'], " - } - member_method { - name: "standardize" - argspec: "args=[\'self\', \'x\'], varargs=None, keywords=None, defaults=None" - } -} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-iterator.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-iterator.pbtxt deleted file mode 100644 index 825d9f1d1d..0000000000 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-iterator.pbtxt +++ /dev/null @@ -1,18 +0,0 @@ -path: "tensorflow.keras.preprocessing.image.Iterator" -tf_class { - is_instance: "" - is_instance: "" - is_instance: "" - member_method { - name: "__init__" - argspec: "args=[\'self\', \'n\', \'batch_size\', \'shuffle\', \'seed\'], varargs=None, keywords=None, defaults=None" - } - member_method { - name: "on_epoch_end" - argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" - } - member_method { - name: "reset" - argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" - } -} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-numpy-array-iterator.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-numpy-array-iterator.pbtxt deleted file mode 100644 index 75924a254a..0000000000 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.-numpy-array-iterator.pbtxt +++ /dev/null @@ -1,23 +0,0 @@ -path: "tensorflow.keras.preprocessing.image.NumpyArrayIterator" -tf_class { - is_instance: "" - is_instance: "" - is_instance: "" - is_instance: "" - member_method { - name: "__init__" - argspec: "args=[\'self\', \'x\', \'y\', \'image_data_generator\', \'batch_size\', \'shuffle\', \'seed\', \'data_format\', \'save_to_dir\', \'save_prefix\', \'save_format\', \'subset\'], varargs=None, keywords=None, defaults=[\'32\', \'False\', \'None\', \'None\', \'None\', \'\', \'png\', \'None\'], " - } - member_method { - name: "next" - argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" - } - member_method { - name: "on_epoch_end" - argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" - } - member_method { - name: "reset" - argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" - } -} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.pbtxt deleted file mode 100644 index 6b850dd6b7..0000000000 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.image.pbtxt +++ /dev/null @@ -1,63 +0,0 @@ -path: "tensorflow.keras.preprocessing.image" -tf_module { - member { - name: "DirectoryIterator" - mtype: "" - } - member { - name: "ImageDataGenerator" - mtype: "" - } - member { - name: "Iterator" - mtype: "" - } - member { - name: "NumpyArrayIterator" - mtype: "" - } - member_method { - name: "apply_transform" - argspec: "args=[\'x\', \'transform_matrix\', \'channel_axis\', \'fill_mode\', \'cval\'], varargs=None, keywords=None, defaults=[\'0\', \'nearest\', \'0.0\'], " - } - member_method { - name: "array_to_img" - argspec: "args=[\'x\', \'data_format\', \'scale\'], varargs=None, keywords=None, defaults=[\'None\', \'True\'], " - } - member_method { - name: "flip_axis" - argspec: "args=[\'x\', \'axis\'], varargs=None, keywords=None, defaults=None" - } - member_method { - name: "img_to_array" - argspec: "args=[\'img\', \'data_format\'], varargs=None, keywords=None, defaults=[\'None\'], " - } - member_method { - name: "load_img" - argspec: "args=[\'path\', \'grayscale\', \'target_size\', \'interpolation\'], varargs=None, keywords=None, defaults=[\'False\', \'None\', \'nearest\'], " - } - member_method { - name: "random_brightness" - argspec: "args=[\'x\', \'brightness_range\'], varargs=None, keywords=None, defaults=None" - } - member_method { - name: "random_channel_shift" - argspec: "args=[\'x\', \'intensity\', \'channel_axis\'], varargs=None, keywords=None, defaults=[\'0\'], " - } - member_method { - name: "random_rotation" - argspec: "args=[\'x\', \'rg\', \'row_axis\', \'col_axis\', \'channel_axis\', \'fill_mode\', \'cval\'], varargs=None, keywords=None, defaults=[\'1\', \'2\', \'0\', \'nearest\', \'0.0\'], " - } - member_method { - name: "random_shear" - argspec: "args=[\'x\', \'intensity\', \'row_axis\', \'col_axis\', \'channel_axis\', \'fill_mode\', \'cval\'], varargs=None, keywords=None, defaults=[\'1\', \'2\', \'0\', \'nearest\', \'0.0\'], " - } - member_method { - name: "random_shift" - argspec: "args=[\'x\', \'wrg\', \'hrg\', \'row_axis\', \'col_axis\', \'channel_axis\', \'fill_mode\', \'cval\'], varargs=None, keywords=None, defaults=[\'1\', \'2\', \'0\', \'nearest\', \'0.0\'], " - } - member_method { - name: "random_zoom" - argspec: "args=[\'x\', \'zoom_range\', \'row_axis\', \'col_axis\', \'channel_axis\', \'fill_mode\', \'cval\'], varargs=None, keywords=None, defaults=[\'1\', \'2\', \'0\', \'nearest\', \'0.0\'], " - } -} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.pbtxt deleted file mode 100644 index 5a78581fc5..0000000000 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.pbtxt +++ /dev/null @@ -1,15 +0,0 @@ -path: "tensorflow.keras.preprocessing" -tf_module { - member { - name: "image" - mtype: "" - } - member { - name: "sequence" - mtype: "" - } - member { - name: "text" - mtype: "" - } -} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.sequence.-timeseries-generator.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.sequence.-timeseries-generator.pbtxt deleted file mode 100644 index 326b1fa4fd..0000000000 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.sequence.-timeseries-generator.pbtxt +++ /dev/null @@ -1,14 +0,0 @@ -path: "tensorflow.keras.preprocessing.sequence.TimeseriesGenerator" -tf_class { - is_instance: "" - is_instance: "" - is_instance: "" - member_method { - name: "__init__" - argspec: "args=[\'self\', \'data\', \'targets\', \'length\', \'sampling_rate\', \'stride\', \'start_index\', \'end_index\', \'shuffle\', \'reverse\', \'batch_size\'], varargs=None, keywords=None, defaults=[\'1\', \'1\', \'0\', \'None\', \'False\', \'False\', \'128\'], " - } - member_method { - name: "on_epoch_end" - argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None" - } -} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.sequence.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.sequence.pbtxt deleted file mode 100644 index cf59f8a272..0000000000 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.sequence.pbtxt +++ /dev/null @@ -1,19 +0,0 @@ -path: "tensorflow.keras.preprocessing.sequence" -tf_module { - member { - name: "TimeseriesGenerator" - mtype: "" - } - member_method { - name: "make_sampling_table" - argspec: "args=[\'size\', \'sampling_factor\'], varargs=None, keywords=None, defaults=[\'1e-05\'], " - } - member_method { - name: "pad_sequences" - argspec: "args=[\'sequences\', \'maxlen\', \'dtype\', \'padding\', \'truncating\', \'value\'], varargs=None, keywords=None, defaults=[\'None\', \'int32\', \'pre\', \'pre\', \'0.0\'], " - } - member_method { - name: "skipgrams" - argspec: "args=[\'sequence\', \'vocabulary_size\', \'window_size\', \'negative_samples\', \'shuffle\', \'categorical\', \'sampling_table\', \'seed\'], varargs=None, keywords=None, defaults=[\'4\', \'1.0\', \'True\', \'False\', \'None\', \'None\'], " - } -} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.text.-tokenizer.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.text.-tokenizer.pbtxt deleted file mode 100644 index b42b12b6c0..0000000000 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.text.-tokenizer.pbtxt +++ /dev/null @@ -1,33 +0,0 @@ -path: "tensorflow.keras.preprocessing.text.Tokenizer" -tf_class { - is_instance: "" - is_instance: "" - member_method { - name: "__init__" - argspec: "args=[\'self\', \'num_words\', \'filters\', \'lower\', \'split\', \'char_level\', \'oov_token\'], varargs=None, keywords=kwargs, defaults=[\'None\', \'!\"#$%&()*+,-./:;<=>?@[\\\\]^_`{|}~\\t\\n\', \'True\', \' \', \'False\', \'None\'], " - } - member_method { - name: "fit_on_sequences" - argspec: "args=[\'self\', \'sequences\'], varargs=None, keywords=None, defaults=None" - } - member_method { - name: "fit_on_texts" - argspec: "args=[\'self\', \'texts\'], varargs=None, keywords=None, defaults=None" - } - member_method { - name: "sequences_to_matrix" - argspec: "args=[\'self\', \'sequences\', \'mode\'], varargs=None, keywords=None, defaults=[\'binary\'], " - } - member_method { - name: "texts_to_matrix" - argspec: "args=[\'self\', \'texts\', \'mode\'], varargs=None, keywords=None, defaults=[\'binary\'], " - } - member_method { - name: "texts_to_sequences" - argspec: "args=[\'self\', \'texts\'], varargs=None, keywords=None, defaults=None" - } - member_method { - name: "texts_to_sequences_generator" - argspec: "args=[\'self\', \'texts\'], varargs=None, keywords=None, defaults=None" - } -} diff --git a/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.text.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.text.pbtxt deleted file mode 100644 index 50b54fc7e1..0000000000 --- a/tensorflow/tools/api/golden/v1/tensorflow.keras.preprocessing.text.pbtxt +++ /dev/null @@ -1,19 +0,0 @@ -path: "tensorflow.keras.preprocessing.text" -tf_module { - member { - name: "Tokenizer" - mtype: "" - } - member_method { - name: "hashing_trick" - argspec: "args=[\'text\', \'n\', \'hash_function\', \'filters\', \'lower\', \'split\'], varargs=None, keywords=None, defaults=[\'None\', \'!\"#$%&()*+,-./:;<=>?@[\\\\]^_`{|}~\\t\\n\', \'True\', \' \'], " - } - member_method { - name: "one_hot" - argspec: "args=[\'text\', \'n\', \'filters\', \'lower\', \'split\'], varargs=None, keywords=None, defaults=[\'!\"#$%&()*+,-./:;<=>?@[\\\\]^_`{|}~\\t\\n\', \'True\', \' \'], " - } - member_method { - name: "text_to_word_sequence" - argspec: "args=[\'text\', \'filters\', \'lower\', \'split\'], varargs=None, keywords=None, defaults=[\'!\"#$%&()*+,-./:;<=>?@[\\\\]^_`{|}~\\t\\n\', \'True\', \' \'], " - } -} diff --git a/tensorflow/tools/ci_build/Dockerfile.cmake b/tensorflow/tools/ci_build/Dockerfile.cmake index e8c3199828..4587bcf891 100644 --- a/tensorflow/tools/ci_build/Dockerfile.cmake +++ b/tensorflow/tools/ci_build/Dockerfile.cmake @@ -28,8 +28,8 @@ RUN pip install --upgrade astor RUN pip install --upgrade gast RUN pip install --upgrade numpy RUN pip install --upgrade termcolor -RUN pip install keras_applications==1.0.2 -RUN pip install keras_preprocessing==1.0.1 +RUN pip install keras_applications==1.0.4 +RUN pip install keras_preprocessing==1.0.2 # Install golang RUN apt-get install -t xenial-backports -y golang-1.9 diff --git a/tensorflow/tools/ci_build/install/install_pip_packages.sh b/tensorflow/tools/ci_build/install/install_pip_packages.sh index c3c537328f..bb316ecfc9 100755 --- a/tensorflow/tools/ci_build/install/install_pip_packages.sh +++ b/tensorflow/tools/ci_build/install/install_pip_packages.sh @@ -115,10 +115,10 @@ pip2 install --upgrade setuptools==39.1.0 pip3 install --upgrade setuptools==39.1.0 # Keras -pip2 install keras_applications==1.0.2 -pip3 install keras_applications==1.0.2 -pip2 install keras_preprocessing==1.0.1 -pip3 install keras_preprocessing==1.0.1 +pip2 install keras_applications==1.0.4 --no-deps +pip3 install keras_applications==1.0.4 --no-deps +pip2 install keras_preprocessing==1.0.2 --no-deps +pip3 install keras_preprocessing==1.0.2 --no-deps # Install last working version of setuptools. pip2 install --upgrade setuptools==39.1.0 diff --git a/tensorflow/tools/ci_build/install/install_python3.5_pip_packages.sh b/tensorflow/tools/ci_build/install/install_python3.5_pip_packages.sh index b6f5de57c9..15e4396ce3 100755 --- a/tensorflow/tools/ci_build/install/install_python3.5_pip_packages.sh +++ b/tensorflow/tools/ci_build/install/install_python3.5_pip_packages.sh @@ -85,8 +85,8 @@ pip3.5 install --upgrade termcolor pip3.5 install --upgrade setuptools==39.1.0 # Keras -pip3.5 install keras_applications==1.0.2 -pip3.5 install keras_preprocessing==1.0.1 +pip3.5 install keras_applications==1.0.4 +pip3.5 install keras_preprocessing==1.0.2 # Install last working version of setuptools. pip3.5 install --upgrade setuptools==39.1.0 diff --git a/tensorflow/tools/ci_build/install/install_python3.6_pip_packages.sh b/tensorflow/tools/ci_build/install/install_python3.6_pip_packages.sh index 8868664132..0fc3eee71c 100755 --- a/tensorflow/tools/ci_build/install/install_python3.6_pip_packages.sh +++ b/tensorflow/tools/ci_build/install/install_python3.6_pip_packages.sh @@ -101,7 +101,7 @@ pip3 install --upgrade termcolor pip3 install --upgrade setuptools==39.1.0 # Keras -pip3 install keras_applications==1.0.2 -pip3 install keras_preprocessing==1.0.1 +pip3 install keras_applications==1.0.4 +pip3 install keras_preprocessing==1.0.2 # LINT.ThenChange(//tensorflow/tools/ci_build/install/install_python3.5_pip_packages.sh) diff --git a/tensorflow/tools/common/public_api.py b/tensorflow/tools/common/public_api.py index b40e4155df..09933d266b 100644 --- a/tensorflow/tools/common/public_api.py +++ b/tensorflow/tools/common/public_api.py @@ -70,6 +70,8 @@ class PublicAPIVisitor(object): 'tf.app': ['flags'], # Imported for compatibility between py2/3. 'tf.test': ['mock'], + # Externalized modules of the Keras API. + 'tf.keras': ['applications', 'preprocessing'] } @property diff --git a/tensorflow/tools/pip_package/setup.py b/tensorflow/tools/pip_package/setup.py index 085f3dd88a..53b1ca3301 100644 --- a/tensorflow/tools/pip_package/setup.py +++ b/tensorflow/tools/pip_package/setup.py @@ -51,6 +51,8 @@ REQUIRED_PACKAGES = [ 'absl-py >= 0.1.6', 'astor >= 0.6.0', 'gast >= 0.2.0', + 'keras_applications == 1.0.4', + 'keras_preprocessing == 1.0.2', 'numpy >= 1.13.3, <= 1.14.5', 'six >= 1.10.0', 'protobuf >= 3.6.0', -- GitLab From a1915c5f008cd7e6f01d563f83b36de783a76a0a Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Wed, 8 Aug 2018 15:16:18 -0700 Subject: [PATCH 224/437] Added int32 concatenation to TFLite. PiperOrigin-RevId: 207954437 --- .../contrib/lite/kernels/concatenation.cc | 19 ++++++++++++++++++- .../contrib/lite/testing/generate_examples.py | 13 ++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/tensorflow/contrib/lite/kernels/concatenation.cc b/tensorflow/contrib/lite/kernels/concatenation.cc index ad211e9c67..605a20ac3e 100644 --- a/tensorflow/contrib/lite/kernels/concatenation.cc +++ b/tensorflow/contrib/lite/kernels/concatenation.cc @@ -57,7 +57,9 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { TF_LITE_ENSURE(context, t0->dims->size <= 4); TF_LITE_ENSURE_EQ(context, params->activation, kTfLiteActNone); TF_LITE_ENSURE(context, - input_type == kTfLiteFloat32 || input_type == kTfLiteUInt8); + input_type == kTfLiteFloat32 || input_type == kTfLiteUInt8 || + input_type == kTfLiteInt16 || input_type == kTfLiteInt32 || + input_type == kTfLiteInt64); // Output dimensions will match input dimensions, except 'axis', which // will be the sum of inputs @@ -121,6 +123,13 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { TF_LITE_CONCATENATION(optimized_ops, float); } break; + case kTfLiteInt32: + if (kernel_type == kReference) { + TF_LITE_CONCATENATION(reference_ops, int32); + } else { + TF_LITE_CONCATENATION(optimized_ops, int32); + } + break; case kTfLiteUInt8: if (kernel_type == kReference) { TF_LITE_CONCATENATION_QUANTIZED(reference_ops); @@ -128,6 +137,14 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { TF_LITE_CONCATENATION_QUANTIZED(optimized_ops); } break; + case kTfLiteInt64: + if (kernel_type == kReference) { + TF_LITE_CONCATENATION(reference_ops, int64_t); + } else { + TF_LITE_CONCATENATION(optimized_ops, int64_t); + } + break; + default: context->ReportError(context, "Only float32 and uint8 are currently supported."); diff --git a/tensorflow/contrib/lite/testing/generate_examples.py b/tensorflow/contrib/lite/testing/generate_examples.py index 1dfd086f5a..52ef0d5b86 100644 --- a/tensorflow/contrib/lite/testing/generate_examples.py +++ b/tensorflow/contrib/lite/testing/generate_examples.py @@ -226,6 +226,7 @@ _TF_TYPE_INFO = { tf.float16: (np.float16, "FLOAT"), tf.int32: (np.int32, "INT32"), tf.uint8: (np.uint8, "QUANTIZED_UINT8"), + tf.int16: (np.int16, "QUANTIZED_INT16"), tf.int64: (np.int64, "INT64"), tf.bool: (np.bool, "BOOL"), } @@ -239,7 +240,7 @@ def create_tensor_data(dtype, shape, min_value=-100, max_value=100): if dtype in (tf.float32, tf.float16): value = (max_value-min_value)*np.random.random_sample(shape)+min_value - elif dtype in (tf.int32, tf.uint8, tf.int64): + elif dtype in (tf.int32, tf.uint8, tf.int64, tf.int16): value = np.random.randint(min_value, max_value+1, shape) elif dtype == tf.bool: value = np.random.choice([True, False], size=shape) @@ -255,7 +256,7 @@ def create_scalar_data(dtype, min_value=-100, max_value=100): if dtype in (tf.float32, tf.float16): value = (max_value - min_value) * np.random.random() + min_value - elif dtype in (tf.int32, tf.uint8, tf.int64): + elif dtype in (tf.int32, tf.uint8, tf.int64, tf.int16): value = np.random.randint(min_value, max_value + 1) return np.array(value, dtype=dtype) @@ -1356,6 +1357,7 @@ def make_concat_tests(zip_path): "base_shape": [[1, 3, 4, 3], [3, 4]], "num_tensors": [1, 2, 3, 4, 5, 6], "axis": [0, 1, 2, 3, -3, -2, -1], + "type": [tf.float32, tf.uint8, tf.int32, tf.int64], }] def get_shape(parameters, delta): @@ -1371,7 +1373,8 @@ def make_concat_tests(zip_path): def build_graph(parameters): all_tensors = [] for n in range(0, parameters["num_tensors"]): - input_tensor = tf.placeholder(dtype=tf.float32, name=("input%d" % n), + input_tensor = tf.placeholder(dtype=parameters["type"], + name=("input%d" % n), shape=get_shape(parameters, n)) all_tensors.append(input_tensor) out = tf.concat(all_tensors, parameters["axis"]) @@ -1380,8 +1383,8 @@ def make_concat_tests(zip_path): def build_inputs(parameters, sess, inputs, outputs): all_values = [] for n in range(0, parameters["num_tensors"]): - input_values = create_tensor_data(np.float32, - get_shape(parameters, n)) + input_values = create_tensor_data( + parameters["type"], get_shape(parameters, n)) all_values.append(input_values) return all_values, sess.run( outputs, feed_dict=dict(zip(inputs, all_values))) -- GitLab From 80dae290b7d4e24b005d419da866f2c22410d818 Mon Sep 17 00:00:00 2001 From: Eugene Brevdo Date: Wed, 8 Aug 2018 15:28:29 -0700 Subject: [PATCH 225/437] Automated rollback of commit 151aed209dc5e11059046367a3a115bba324800d PiperOrigin-RevId: 207956477 --- tensorflow/python/util/tf_should_use.py | 169 ++++++------------- tensorflow/python/util/tf_should_use_test.py | 80 +++++---- 2 files changed, 88 insertions(+), 161 deletions(-) diff --git a/tensorflow/python/util/tf_should_use.py b/tensorflow/python/util/tf_should_use.py index ca6710bcf2..28e49afa02 100644 --- a/tensorflow/python/util/tf_should_use.py +++ b/tensorflow/python/util/tf_should_use.py @@ -17,124 +17,23 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import copy -import sys -import traceback +import functools +import types import six # pylint: disable=unused-import -from tensorflow.python.platform import tf_logging +from tensorflow.python.eager import context from tensorflow.python.util import tf_decorator # pylint: enable=g-bad-import-order,g-import-not-at-top -class _TFShouldUseHelper(object): - """Object stored in TFShouldUse-wrapped objects. - - When it is deleted it will emit a warning or error if its `sate` method - has not been called by time of deletion. - """ - - def __init__(self, type_, repr_, stack_frame, fatal_error_if_unsated): - self._type = type_ - self._repr = repr_ - self._stack_frame = stack_frame - self._fatal_error_if_unsated = fatal_error_if_unsated - self._sated = False - - def sate(self): - self._sated = True - self._type = None - self._repr = None - self._stack_frame = None - self._logging_module = None - - def __del__(self): - if self._sated: - return - if self._fatal_error_if_unsated: - logger = tf_logging.fatal - else: - logger = tf_logging.error - creation_stack = ''.join( - [line.rstrip() for line in traceback.format_stack(self._stack_frame)]) - logger( - '==================================\n' - 'Object was never used (type %s):\n%s\nIf you want to mark it as ' - 'used call its "mark_used()" method.\nIt was originally created ' - 'here:\n%s\n' - '==================================' % - (self._type, self._repr, creation_stack)) - - -def _new__init__(self, true_value, tf_should_use_helper): - # pylint: disable=protected-access - self._tf_should_use_helper = tf_should_use_helper - self._true_value = true_value - - -def _new__setattr__(self, key, value): - if key in ('_tf_should_use_helper', '_true_value'): - return object.__setattr__(self, key, value) - return setattr( - object.__getattribute__(self, '_true_value'), - key, value) - - -def _new__getattribute__(self, key): - if key not in ('_tf_should_use_helper', '_true_value'): - object.__getattribute__(self, '_tf_should_use_helper').sate() - if key in ('_tf_should_use_helper', 'mark_used', '__setatt__'): - return object.__getattribute__(self, key) - return getattr(object.__getattribute__(self, '_true_value'), key) - - -def _new_mark_used(self, *args, **kwargs): - object.__getattribute__(self, '_tf_should_use_helper').sate() - try: - mu = object.__getattribute__( - object.__getattribute__(self, '_true_value'), - 'mark_used') - return mu(*args, **kwargs) - except AttributeError: - pass - - -_WRAPPERS = dict() - - -def _get_wrapper(x, tf_should_use_helper): - """Create a wrapper for object x, whose class subclasses type(x). - - The wrapper will emit a warning if it is deleted without any of its - properties being accessed or methods being called. - - Args: - x: The instance to wrap. - tf_should_use_helper: The object that tracks usage. - - Returns: - An object wrapping `x`, of type `type(x)`. - """ - type_x = type(x) - memoized = _WRAPPERS.get(type_x, None) - if memoized: - return memoized(x, tf_should_use_helper) - - tx = copy.deepcopy(type_x) - copy_tx = type(tx.__name__, tx.__bases__, dict(tx.__dict__)) - copy_tx.__init__ = _new__init__ - copy_tx.__getattribute__ = _new__getattribute__ - copy_tx.mark_used = _new_mark_used - copy_tx.__setattr__ = _new__setattr__ - _WRAPPERS[type_x] = copy_tx - - return copy_tx(x, tf_should_use_helper) - - +# TODO(b/65412899): Re-implement to avoid leaking python objects. +# This function / class remains since the API is public (mark_used()). def _add_should_use_warning(x, fatal_error=False): """Wraps object x so that if it is never used, a warning is logged. + Does nothing when executing eagerly. + Args: x: Python object. fatal_error: Python bool. If `True`, tf.logging.fatal is raised @@ -144,22 +43,50 @@ def _add_should_use_warning(x, fatal_error=False): An instance of `TFShouldUseWarningWrapper` which subclasses `type(x)` and is a very shallow wrapper for `x` which logs access into `x`. """ + del fatal_error if x is None or x == []: # pylint: disable=g-explicit-bool-comparison return x - # Extract the current frame for later use by traceback printing. - try: - raise ValueError() - except ValueError: - stack_frame = sys.exc_info()[2].tb_frame.f_back + if context.executing_eagerly(): + # Typically not needed when executing eagerly (the main use case is for ops + # which need to be incorporated into the graph), and even the no-op wrapper + # creates reference cycles which require garbage collection. + return x + + def override_method(method): + def fn(self, *args, **kwargs): + return method(self, *args, **kwargs) + return fn + + class TFShouldUseWarningWrapper(type(x)): + """Wrapper for objects that keeps track of their use.""" + + def __init__(self, true_self): + self.__dict__ = true_self.__dict__ - tf_should_use_helper = _TFShouldUseHelper( - type_=type(x), - repr_=repr(x), - stack_frame=stack_frame, - fatal_error_if_unsated=fatal_error) + # Not sure why this pylint warning is being used; this is not an + # old class form. + # pylint: disable=super-on-old-class + def __getattribute__(self, name): + return super(TFShouldUseWarningWrapper, self).__getattribute__(name) + + def mark_used(self, *args, **kwargs): + return - return _get_wrapper(x, tf_should_use_helper) + # pylint: enable=super-on-old-class + + for name in dir(TFShouldUseWarningWrapper): + method = getattr(TFShouldUseWarningWrapper, name) + if not isinstance(method, types.FunctionType): + continue + if name in ('__init__', '__getattribute__', '__del__', 'mark_used'): + continue + setattr(TFShouldUseWarningWrapper, name, + functools.wraps(method)(override_method(method))) + + wrapped = TFShouldUseWarningWrapper(x) + wrapped.__doc__ = x.__doc__ # functools.wraps fails on some objects. + return wrapped def should_use_result(fn): @@ -179,6 +106,8 @@ def should_use_result(fn): - `t != 0`. In this case, comparison is done on types / ids. - `isinstance(t, tf.Tensor)`. Similar to above. + Does nothing when executing eagerly. + Args: fn: The function to wrap. @@ -213,6 +142,8 @@ def must_use_result_or_fatal(fn): - `t != 0`. In this case, comparison is done on types / ids. - `isinstance(t, tf.Tensor)`. Similar to above. + Does nothing when executing eagerly. + Args: fn: The function to wrap. diff --git a/tensorflow/python/util/tf_should_use_test.py b/tensorflow/python/util/tf_should_use_test.py index 4c09c2107e..4c6e48b11c 100644 --- a/tensorflow/python/util/tf_should_use_test.py +++ b/tensorflow/python/util/tf_should_use_test.py @@ -30,53 +30,48 @@ from tensorflow.python.util import tf_should_use @contextlib.contextmanager -def reroute_error(): +def reroute_error(captured): """Temporarily reroute errors written to tf_logging.error into `captured`.""" - with test.mock.patch.object(tf_should_use.tf_logging, 'error') as error: - with test.mock.patch.object(tf_should_use.tf_logging, 'fatal') as fatal: - yield error, fatal + del captured[:] + true_logger = tf_logging.error + def capture_errors(*args, **unused_kwargs): + captured.extend(args) + tf_logging.error = capture_errors + try: + yield + finally: + tf_logging.error = true_logger class TfShouldUseTest(test.TestCase): def testAddShouldUseWarningWhenNotUsed(self): + self.skipTest('b/65412899') c = constant_op.constant(0, name='blah0') - def in_this_function(): - h = tf_should_use._add_should_use_warning(c) - del h - with reroute_error() as (error, _): - in_this_function() - error.assert_called() - msg = '\n'.join(error.call_args[0]) - self.assertIn('Object was never used', msg) - self.assertIn('blah0:0', msg) - self.assertIn('in_this_function', msg) - self.assertFalse(gc.garbage) - - def testAddShouldUseFatalWhenNotUsed(self): - c = constant_op.constant(0, name='blah0') - def in_this_function(): - h = tf_should_use._add_should_use_warning(c, fatal_error=True) - del h - with reroute_error() as (_, fatal): + captured = [] + with reroute_error(captured): + def in_this_function(): + h = tf_should_use._add_should_use_warning(c) + del h in_this_function() - fatal.assert_called() - msg = '\n'.join(fatal.call_args[0]) - self.assertIn('Object was never used', msg) - self.assertIn('blah0:0', msg) - self.assertIn('in_this_function', msg) + self.assertIn('Object was never used', '\n'.join(captured)) + self.assertIn('blah0:0', '\n'.join(captured)) + self.assertIn('in_this_function', '\n'.join(captured)) + gc.collect() self.assertFalse(gc.garbage) def _testAddShouldUseWarningWhenUsed(self, fn, name): c = constant_op.constant(0, name=name) - with reroute_error() as (error, fatal): + captured = [] + with reroute_error(captured): h = tf_should_use._add_should_use_warning(c) fn(h) del h - error.assert_not_called() - fatal.assert_not_called() + self.assertNotIn('Object was never used', '\n'.join(captured)) + self.assertNotIn('%s:0' % name, '\n'.join(captured)) def testAddShouldUseWarningWhenUsedWithAdd(self): + self.skipTest('b/65412899') def add(h): _ = h + 1 self._testAddShouldUseWarningWhenUsed(add, name='blah_add') @@ -84,6 +79,7 @@ class TfShouldUseTest(test.TestCase): self.assertFalse(gc.garbage) def testAddShouldUseWarningWhenUsedWithGetName(self): + self.skipTest('b/65412899') def get_name(h): _ = h.name self._testAddShouldUseWarningWhenUsed(get_name, name='blah_get_name') @@ -91,35 +87,35 @@ class TfShouldUseTest(test.TestCase): self.assertFalse(gc.garbage) def testShouldUseResult(self): + self.skipTest('b/65412899') @tf_should_use.should_use_result def return_const(value): return constant_op.constant(value, name='blah2') - with reroute_error() as (error, _): + captured = [] + with reroute_error(captured): return_const(0.0) - error.assert_called() - msg = '\n'.join(error.call_args[0]) - self.assertIn('Object was never used', msg) - self.assertIn('blah2:0', msg) - self.assertIn('return_const', msg) + self.assertIn('Object was never used', '\n'.join(captured)) + self.assertIn('blah2:0', '\n'.join(captured)) + self.assertIn('return_const', '\n'.join(captured)) gc.collect() self.assertFalse(gc.garbage) def testShouldUseResultWhenNotReallyUsed(self): + self.skipTest('b/65412899') @tf_should_use.should_use_result def return_const(value): return constant_op.constant(value, name='blah3') - with reroute_error() as (error, _): + captured = [] + with reroute_error(captured): with self.test_session(): return_const(0.0) # Creating another op and executing it does not mark the # unused op as being "used". v = constant_op.constant(1.0, name='meh') v.eval() - error.assert_called() - msg = '\n'.join(error.call_args[0]) - self.assertIn('Object was never used', msg) - self.assertIn('blah3:0', msg) - self.assertIn('return_const', msg) + self.assertIn('Object was never used', '\n'.join(captured)) + self.assertIn('blah3:0', '\n'.join(captured)) + self.assertIn('return_const', '\n'.join(captured)) gc.collect() self.assertFalse(gc.garbage) -- GitLab From 0c4cf5b0ddfdf1bf4c08cfbfa40005d55ec94c6f Mon Sep 17 00:00:00 2001 From: Amit Patankar Date: Wed, 8 Aug 2018 15:47:51 -0700 Subject: [PATCH 226/437] Cherrypick r1.10 back to master. --- RELEASE.md | 2 +- tensorflow/core/public/version.h | 2 +- tensorflow/docs_src/install/install_c.md | 2 +- tensorflow/docs_src/install/install_go.md | 2 +- tensorflow/docs_src/install/install_java.md | 22 +++++++++---------- tensorflow/docs_src/install/install_linux.md | 18 +++++++-------- tensorflow/docs_src/install/install_mac.md | 10 ++++----- .../docs_src/install/install_sources.md | 4 ++-- tensorflow/tools/pip_package/setup.py | 2 +- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 078aafd374..ae41d56e14 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -19,7 +19,7 @@ * `tf.data`: * `tf.contrib.data.group_by_reducer()` is now available via the public API. * `tf.contrib.data.choose_from_datasets()` is now available via the public API. - * Adding `drop_remainder` argument to `tf.data.Dataset.batch()` and `tf.data.Dataset.padded_batch()`, deprecating tf.contrib.data.batch_and_drop_remainder()` and `tf.contrib.data.padded_batch_and_drop_remainder()`. + * Adding `drop_remainder` argument to `tf.data.Dataset.batch()` and `tf.data.Dataset.padded_batch()`, deprecating `tf.contrib.data.batch_and_drop_remainder()` and `tf.contrib.data.padded_batch_and_drop_remainder()`. * `tf.estimator`: * `Estimator`s now use custom savers included in `EstimatorSpec` scaffolds for saving SavedModels during export. * `EstimatorSpec` will now add a default prediction output for export if no `export_output` is provided, eliminating the need to explicitly include a `PredictOutput` object in the `model_fn` for simple use-cases. diff --git a/tensorflow/core/public/version.h b/tensorflow/core/public/version.h index 6f564e7e1e..563564119f 100644 --- a/tensorflow/core/public/version.h +++ b/tensorflow/core/public/version.h @@ -24,7 +24,7 @@ limitations under the License. // TF_VERSION_SUFFIX is non-empty for pre-releases (e.g. "-alpha", "-alpha.1", // "-beta", "-rc", "-rc.1") -#define TF_VERSION_SUFFIX "-rc1" +#define TF_VERSION_SUFFIX "" #define TF_STR_HELPER(x) #x #define TF_STR(x) TF_STR_HELPER(x) diff --git a/tensorflow/docs_src/install/install_c.md b/tensorflow/docs_src/install/install_c.md index 5e26facaba..4a63f11fca 100644 --- a/tensorflow/docs_src/install/install_c.md +++ b/tensorflow/docs_src/install/install_c.md @@ -38,7 +38,7 @@ enable TensorFlow for C: OS="linux" # Change to "darwin" for macOS TARGET_DIRECTORY="/usr/local" curl -L \ - "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-${TF_TYPE}-${OS}-x86_64-1.10.0-rc1.tar.gz" | + "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-${TF_TYPE}-${OS}-x86_64-1.10.0.tar.gz" | sudo tar -C $TARGET_DIRECTORY -xz The `tar` command extracts the TensorFlow C library into the `lib` diff --git a/tensorflow/docs_src/install/install_go.md b/tensorflow/docs_src/install/install_go.md index a59c2741e1..961386b15c 100644 --- a/tensorflow/docs_src/install/install_go.md +++ b/tensorflow/docs_src/install/install_go.md @@ -38,7 +38,7 @@ steps to install this library and enable TensorFlow for Go: TF_TYPE="cpu" # Change to "gpu" for GPU support TARGET_DIRECTORY='/usr/local' curl -L \ - "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-${TF_TYPE}-$(go env GOOS)-x86_64-1.10.0-rc1.tar.gz" | + "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-${TF_TYPE}-$(go env GOOS)-x86_64-1.10.0.tar.gz" | sudo tar -C $TARGET_DIRECTORY -xz The `tar` command extracts the TensorFlow C library into the `lib` diff --git a/tensorflow/docs_src/install/install_java.md b/tensorflow/docs_src/install/install_java.md index e9c6650c92..c131a2ea76 100644 --- a/tensorflow/docs_src/install/install_java.md +++ b/tensorflow/docs_src/install/install_java.md @@ -36,7 +36,7 @@ following to the project's `pom.xml` to use the TensorFlow Java APIs: org.tensorflow tensorflow - 1.10.0-rc1 + 1.10.0 ``` @@ -65,7 +65,7 @@ As an example, these steps will create a Maven project that uses TensorFlow: org.tensorflow tensorflow - 1.10.0-rc1 + 1.10.0 @@ -124,12 +124,12 @@ instead: org.tensorflow libtensorflow - 1.10.0-rc1 + 1.10.0 org.tensorflow libtensorflow_jni_gpu - 1.10.0-rc1 + 1.10.0 ``` @@ -148,7 +148,7 @@ refer to the simpler instructions above instead. Take the following steps to install TensorFlow for Java on Linux or macOS: 1. Download - [libtensorflow.jar](https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-1.10.0-rc1.jar), + [libtensorflow.jar](https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-1.10.0.jar), which is the TensorFlow Java Archive (JAR). 2. Decide whether you will run TensorFlow for Java on CPU(s) only or with @@ -167,7 +167,7 @@ Take the following steps to install TensorFlow for Java on Linux or macOS: OS=$(uname -s | tr '[:upper:]' '[:lower:]') mkdir -p ./jni curl -L \ - "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow_jni-${TF_TYPE}-${OS}-x86_64-1.10.0-rc1.tar.gz" | + "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow_jni-${TF_TYPE}-${OS}-x86_64-1.10.0.tar.gz" | tar -xz -C ./jni ### Install on Windows @@ -175,10 +175,10 @@ Take the following steps to install TensorFlow for Java on Linux or macOS: Take the following steps to install TensorFlow for Java on Windows: 1. Download - [libtensorflow.jar](https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-1.10.0-rc1.jar), + [libtensorflow.jar](https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-1.10.0.jar), which is the TensorFlow Java Archive (JAR). 2. Download the following Java Native Interface (JNI) file appropriate for - [TensorFlow for Java on Windows](https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow_jni-cpu-windows-x86_64-1.10.0-rc1.zip). + [TensorFlow for Java on Windows](https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow_jni-cpu-windows-x86_64-1.10.0.zip). 3. Extract this .zip file. __Note__: The native library (`tensorflow_jni.dll`) requires `msvcp140.dll` at runtime, which is included in the [Visual C++ 2015 Redistributable](https://www.microsoft.com/en-us/download/details.aspx?id=48145) package. @@ -227,7 +227,7 @@ must be part of your `classpath`. For example, you can include the downloaded `.jar` in your `classpath` by using the `-cp` compilation flag as follows: -
javac -cp libtensorflow-1.10.0-rc1.jar HelloTF.java
+
javac -cp libtensorflow-1.10.0.jar HelloTF.java
### Running @@ -241,11 +241,11 @@ two files are available to the JVM: For example, the following command line executes the `HelloTF` program on Linux and macOS X: -
java -cp libtensorflow-1.10.0-rc1.jar:. -Djava.library.path=./jni HelloTF
+
java -cp libtensorflow-1.10.0.jar:. -Djava.library.path=./jni HelloTF
And the following command line executes the `HelloTF` program on Windows: -
java -cp libtensorflow-1.10.0-rc1.jar;. -Djava.library.path=jni HelloTF
+
java -cp libtensorflow-1.10.0.jar;. -Djava.library.path=jni HelloTF
If the program prints Hello from version, you've successfully installed TensorFlow for Java and are ready to use the API. If the program diff --git a/tensorflow/docs_src/install/install_linux.md b/tensorflow/docs_src/install/install_linux.md index 005ad437bc..0febdee99f 100644 --- a/tensorflow/docs_src/install/install_linux.md +++ b/tensorflow/docs_src/install/install_linux.md @@ -436,7 +436,7 @@ Take the following steps to install TensorFlow in an Anaconda environment:
      (tensorflow)$ pip install --ignore-installed --upgrade \
-     https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.10.0rc1-cp34-cp34m-linux_x86_64.whl
+ https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.10.0-cp34-cp34m-linux_x86_64.whl @@ -650,13 +650,13 @@ This section documents the relevant values for Linux installations. CPU only:
-https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.10.0rc1-cp27-none-linux_x86_64.whl
+https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.10.0-cp27-none-linux_x86_64.whl
 
GPU support:
-https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.10.0rc1-cp27-none-linux_x86_64.whl
+https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.10.0-cp27-none-linux_x86_64.whl
 
Note that GPU support requires the NVIDIA hardware and software described in @@ -667,13 +667,13 @@ Note that GPU support requires the NVIDIA hardware and software described in CPU only:
-https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.10.0rc1-cp34-cp34m-linux_x86_64.whl
+https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.10.0-cp34-cp34m-linux_x86_64.whl
 
GPU support:
-https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.10.0rc1-cp34-cp34m-linux_x86_64.whl
+https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.10.0-cp34-cp34m-linux_x86_64.whl
 
Note that GPU support requires the NVIDIA hardware and software described in @@ -684,13 +684,13 @@ Note that GPU support requires the NVIDIA hardware and software described in CPU only:
-https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.10.0rc1-cp35-cp35m-linux_x86_64.whl
+https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.10.0-cp35-cp35m-linux_x86_64.whl
 
GPU support:
-https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.10.0rc1-cp35-cp35m-linux_x86_64.whl
+https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.10.0-cp35-cp35m-linux_x86_64.whl
 
Note that GPU support requires the NVIDIA hardware and software described in @@ -701,13 +701,13 @@ Note that GPU support requires the NVIDIA hardware and software described in CPU only:
-https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.10.0rc1-cp36-cp36m-linux_x86_64.whl
+https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.10.0-cp36-cp36m-linux_x86_64.whl
 
GPU support:
-https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.10.0rc1-cp36-cp36m-linux_x86_64.whl
+https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.10.0-cp36-cp36m-linux_x86_64.whl
 
Note that GPU support requires the NVIDIA hardware and software described in diff --git a/tensorflow/docs_src/install/install_mac.md b/tensorflow/docs_src/install/install_mac.md index 3a8637bfb1..c4d63cc107 100644 --- a/tensorflow/docs_src/install/install_mac.md +++ b/tensorflow/docs_src/install/install_mac.md @@ -119,7 +119,7 @@ Take the following steps to install TensorFlow with Virtualenv: TensorFlow in the active Virtualenv is as follows:
 $ pip3 install --upgrade \
-     https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.10.0rc1-py3-none-any.whl
+ https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.10.0-py3-none-any.whl If you encounter installation problems, see [Common Installation Problems](#common-installation-problems). @@ -242,7 +242,7 @@ take the following steps: issue the following command:
 $ sudo pip3 install --upgrade \
-     https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.10.0rc1-py3-none-any.whl 
+ https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.10.0-py3-none-any.whl If the preceding command fails, see [installation problems](#common-installation-problems). @@ -350,7 +350,7 @@ Take the following steps to install TensorFlow in an Anaconda environment: TensorFlow for Python 2.7:
 (targetDirectory)$ pip install --ignore-installed --upgrade \
-     https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.10.0rc1-py2-none-any.whl
+ https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.10.0-py2-none-any.whl @@ -517,7 +517,7 @@ The value you specify depends on your Python version.
-https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.10.0rc1-py2-none-any.whl
+https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.10.0-py2-none-any.whl
 
@@ -525,5 +525,5 @@ https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.10.0rc1-py2-none-
-https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.10.0rc1-py3-none-any.whl
+https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.10.0-py3-none-any.whl
 
diff --git a/tensorflow/docs_src/install/install_sources.md b/tensorflow/docs_src/install/install_sources.md index 8bb09f4021..1d108d8bd5 100644 --- a/tensorflow/docs_src/install/install_sources.md +++ b/tensorflow/docs_src/install/install_sources.md @@ -375,10 +375,10 @@ Invoke `pip install` to install that pip package. The filename of the `.whl` file depends on your platform. For example, the following command will install the pip package -for TensorFlow 1.10.0rc1 on Linux: +for TensorFlow 1.10.0 on Linux:
-$ sudo pip install /tmp/tensorflow_pkg/tensorflow-1.10.0rc1-py2-none-any.whl
+$ sudo pip install /tmp/tensorflow_pkg/tensorflow-1.10.0-py2-none-any.whl
 
## Validate your installation diff --git a/tensorflow/tools/pip_package/setup.py b/tensorflow/tools/pip_package/setup.py index 53b1ca3301..5e179079c5 100644 --- a/tensorflow/tools/pip_package/setup.py +++ b/tensorflow/tools/pip_package/setup.py @@ -45,7 +45,7 @@ DOCLINES = __doc__.split('\n') # This version string is semver compatible, but incompatible with pip. # For pip, we will remove all '-' characters from this string, and use the # result for pip. -_VERSION = '1.10.0-rc1' +_VERSION = '1.10.0' REQUIRED_PACKAGES = [ 'absl-py >= 0.1.6', -- GitLab From da9d06cfe7a3e3a24fcaad8a52c7eaba13703272 Mon Sep 17 00:00:00 2001 From: Anna R Date: Wed, 8 Aug 2018 15:52:24 -0700 Subject: [PATCH 227/437] Internal change. PiperOrigin-RevId: 207960122 --- tensorflow/contrib/distributions/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/contrib/distributions/BUILD b/tensorflow/contrib/distributions/BUILD index ad00d1734d..a8d0d493ab 100644 --- a/tensorflow/contrib/distributions/BUILD +++ b/tensorflow/contrib/distributions/BUILD @@ -124,7 +124,7 @@ cuda_py_test( cuda_py_test( name = "conditional_distribution_test", - size = "small", + size = "medium", srcs = [ "python/kernel_tests/conditional_distribution_test.py", "python/kernel_tests/distribution_test.py", -- GitLab From 643d809b50127682bf5ef70b8871f929183d5a10 Mon Sep 17 00:00:00 2001 From: Allen Lavoie Date: Wed, 8 Aug 2018 15:58:41 -0700 Subject: [PATCH 228/437] Make sure Sequential opens sub-Layer name scopes when lazily building Layers Adds a test for Sequential variable naming. PiperOrigin-RevId: 207961048 --- tensorflow/python/keras/engine/sequential.py | 4 +++- tensorflow/python/keras/engine/sequential_test.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tensorflow/python/keras/engine/sequential.py b/tensorflow/python/keras/engine/sequential.py index b3a2ad8b0c..822262f1b3 100644 --- a/tensorflow/python/keras/engine/sequential.py +++ b/tensorflow/python/keras/engine/sequential.py @@ -22,6 +22,7 @@ from __future__ import print_function import copy from tensorflow.python.eager import context +from tensorflow.python.framework import ops from tensorflow.python.keras import layers as layer_module from tensorflow.python.keras.engine import base_layer from tensorflow.python.keras.engine.input_layer import Input @@ -217,7 +218,8 @@ class Sequential(Model): shape = input_shape for layer in self.layers: if not layer.built: - layer.build(shape) + with ops.name_scope(layer._name_scope()): + layer.build(shape) layer.built = True shape = layer.compute_output_shape(shape) self.built = True diff --git a/tensorflow/python/keras/engine/sequential_test.py b/tensorflow/python/keras/engine/sequential_test.py index 9d3f65e0c6..826ad3a929 100644 --- a/tensorflow/python/keras/engine/sequential_test.py +++ b/tensorflow/python/keras/engine/sequential_test.py @@ -307,6 +307,16 @@ class TestSequential(test.TestCase, parameterized.TestCase): y = np.random.random((2, 5)) model.fit(x, y, epochs=1) + @tf_test_util.run_in_graph_and_eager_modes + def test_variable_names(self): + model = keras.models.Sequential([keras.layers.Dense(3)]) + model.add(keras.layers.Dense(2)) + model(array_ops.ones([2, 4])) + self.assertEqual( + ['sequential/dense/kernel:0', 'sequential/dense/bias:0', + 'sequential/dense_1/kernel:0', 'sequential/dense_1/bias:0'], + [v.name for v in model.variables]) + if __name__ == '__main__': test.main() -- GitLab From 96a77055bd1f0c86e37708f65d5ac72cc6026c66 Mon Sep 17 00:00:00 2001 From: Priya Gupta Date: Wed, 8 Aug 2018 16:04:13 -0700 Subject: [PATCH 229/437] Add an API to distribution strategy that allows running N steps. Implement this for MirroredStrategy and OneDeviceStrategy. Implemented in TPUStrategy earlier. PiperOrigin-RevId: 207961939 --- .../distribute/python/mirrored_strategy.py | 52 ++++++++ .../distribute/python/one_device_strategy.py | 38 ++++++ .../contrib/distribute/python/tpu_strategy.py | 92 ++++++++++---- .../contrib/distribute/python/values.py | 119 +++++++++++------- tensorflow/python/estimator/estimator.py | 38 +++--- tensorflow/python/training/distribute.py | 80 ++++++++++++ 6 files changed, 335 insertions(+), 84 deletions(-) diff --git a/tensorflow/contrib/distribute/python/mirrored_strategy.py b/tensorflow/contrib/distribute/python/mirrored_strategy.py index c5d6e978e7..3c1760c03c 100644 --- a/tensorflow/contrib/distribute/python/mirrored_strategy.py +++ b/tensorflow/contrib/distribute/python/mirrored_strategy.py @@ -27,13 +27,17 @@ from tensorflow.contrib.distribute.python import values from tensorflow.python import pywrap_tensorflow from tensorflow.python.eager import context from tensorflow.python.eager import tape +from tensorflow.python.framework import constant_op from tensorflow.python.framework import device as tf_device from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops +from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import variable_scope +from tensorflow.python.ops import variables as variables_lib from tensorflow.python.training import coordinator from tensorflow.python.training import device_util from tensorflow.python.training import distribute as distribute_lib +from tensorflow.python.util import nest # TODO(josh11b): Replace asserts in this file with if ...: raise ... @@ -357,6 +361,54 @@ class MirroredStrategy(distribute_lib.DistributionStrategy): self._call_dataset_fn(dataset_fn), self._devices, self._prefetch_on_device) + # TODO(priyag): Deal with OutOfRange errors once b/111349762 is fixed. + def _run_steps_on_dataset(self, fn, iterator, iterations, + initial_loop_values=None): + if initial_loop_values is None: + initial_loop_values = {} + initial_loop_values = nest.flatten(initial_loop_values) + + ctx = values.MultiStepContext() + def body(i, *args): + """A wrapper around `fn` to create the while loop body.""" + del args + fn_result = fn(ctx, iterator.get_next()) + for (name, output) in ctx.last_step_outputs.items(): + # Convert all outputs to tensors, potentially from `DistributedValues`. + ctx.last_step_outputs[name] = self.unwrap(output) + flat_last_step_outputs = nest.flatten(ctx.last_step_outputs) + with ops.control_dependencies([fn_result]): + return [i + 1] + flat_last_step_outputs + + cond = lambda i, *args: i < iterations + i = constant_op.constant(0) + loop_result = control_flow_ops.while_loop( + cond, body, [i] + initial_loop_values, name="", + parallel_iterations=1, back_prop=False, swap_memory=False, + return_same_structure=True) + + ctx.run_op = control_flow_ops.group(loop_result) + + # Convert the last_step_outputs from a list to the original dict structure + # of last_step_outputs. + last_step_tensor_outputs = loop_result[1:] + last_step_tensor_outputs_dict = nest.pack_sequence_as( + ctx.last_step_outputs, last_step_tensor_outputs) + + for (name, aggregation) in ctx._last_step_outputs_aggregations.items(): # pylint: disable=protected-access + output = last_step_tensor_outputs_dict[name] + # For outputs that have already been aggregated, wrap them in a Mirrored + # container, else in a PerDevice container. + if aggregation is variables_lib.VariableAggregation.NONE: + last_step_tensor_outputs_dict[name] = values.regroup( + {d: t for d, t in zip(self._devices, output)}, values.PerDevice) + else: + assert len(output) == 1 + last_step_tensor_outputs_dict[name] = output[0] + + ctx._set_last_step_outputs(last_step_tensor_outputs_dict) # pylint: disable=protected-access + return ctx + def _broadcast(self, tensor, destinations): # TODO(josh11b): In eager mode, use one thread per device, or async mode. return self._get_cross_tower_ops().broadcast(tensor, destinations or diff --git a/tensorflow/contrib/distribute/python/one_device_strategy.py b/tensorflow/contrib/distribute/python/one_device_strategy.py index a7f2e2e586..016978cdb3 100644 --- a/tensorflow/contrib/distribute/python/one_device_strategy.py +++ b/tensorflow/contrib/distribute/python/one_device_strategy.py @@ -21,11 +21,14 @@ from __future__ import print_function import six from tensorflow.contrib.distribute.python import values +from tensorflow.python.framework import constant_op from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops +from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import variable_scope as vs from tensorflow.python.training import distribute as distribute_lib +from tensorflow.python.util import nest # TODO(josh11b): Replace asserts in this file with if ...: raise ... @@ -66,6 +69,41 @@ class OneDeviceStrategy(distribute_lib.DistributionStrategy): def _broadcast(self, tensor, destinations): return tensor + # TODO(priyag): Deal with OutOfRange errors once b/111349762 is fixed. + def _run_steps_on_dataset(self, fn, iterator, iterations, + initial_loop_values=None): + if initial_loop_values is None: + initial_loop_values = {} + initial_loop_values = nest.flatten(initial_loop_values) + + ctx = values.MultiStepContext() + def body(i, *args): + """A wrapper around `fn` to create the while loop body.""" + del args + fn_result = fn(ctx, iterator.get_next()) + flat_last_step_outputs = nest.flatten(ctx.last_step_outputs) + with ops.control_dependencies([fn_result]): + return [i + 1] + flat_last_step_outputs + + cond = lambda i, *args: i < iterations + i = constant_op.constant(0) + # TODO(priyag): Use max_iterations instead of an explicit counter. + loop_result = control_flow_ops.while_loop( + cond, body, [i] + initial_loop_values, name="", + parallel_iterations=1, back_prop=False, swap_memory=False, + return_same_structure=True) + + ctx.run_op = control_flow_ops.group(loop_result) + + # Convert the last_step_outputs from a list to the original dict structure + # of last_step_outputs. + last_step_tensor_outputs = loop_result[1:] + last_step_tensor_outputs_dict = nest.pack_sequence_as( + ctx.last_step_outputs, last_step_tensor_outputs) + + ctx._set_last_step_outputs(last_step_tensor_outputs_dict) # pylint: disable=protected-access + return ctx + def _call_for_each_tower(self, fn, *args, **kwargs): # We don't run `fn` in multiple threads in OneDeviceStrategy. kwargs.pop("run_concurrently", None) diff --git a/tensorflow/contrib/distribute/python/tpu_strategy.py b/tensorflow/contrib/distribute/python/tpu_strategy.py index d34258703c..83af37fc81 100644 --- a/tensorflow/contrib/distribute/python/tpu_strategy.py +++ b/tensorflow/contrib/distribute/python/tpu_strategy.py @@ -28,12 +28,14 @@ from tensorflow.contrib.tpu.python.ops import tpu_ops from tensorflow.contrib.tpu.python.tpu import tpu from tensorflow.contrib.tpu.python.tpu import tpu_system_metadata as tpu_system_metadata_lib from tensorflow.contrib.tpu.python.tpu import training_loop +from tensorflow.python.eager import context from tensorflow.python.framework import constant_op from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import variable_scope as vs +from tensorflow.python.ops import variables as variables_lib from tensorflow.python.training import device_util from tensorflow.python.training import server_lib from tensorflow.python.util import nest @@ -79,7 +81,7 @@ class TPUStrategy(one_device_strategy.OneDeviceStrategy): # TODO(priyag): Perhaps distribute across cores here. return self._call_dataset_fn(dataset_fn) - # TODO(priyag): Deal with OutOfRange errors. + # TODO(priyag): Deal with OutOfRange errors once b/111349762 is fixed. # TODO(sourabhbajaj): Remove the initial_loop_values parameter when we have # a mechanism to infer the outputs of `fn`. Pending b/110550782. def _run_steps_on_dataset(self, fn, iterator, iterations, @@ -129,53 +131,90 @@ class TPUStrategy(one_device_strategy.OneDeviceStrategy): # Wrap `fn` for repeat. if initial_loop_values is None: - initial_loop_values = [] - ctx = values.MultiStepContext(initial_loop_values) + initial_loop_values = {} + initial_loop_values = nest.flatten(initial_loop_values) + ctx = values.MultiStepContext() def run_fn(*args, **kwargs): del args, kwargs fn_result = fn(ctx, dequeue_fn()) - if ctx.last_step_outputs is None: - ctx.last_step_outputs = [] - with ops.control_dependencies([fn_result]): - return array_ops.identity(ctx.last_step_outputs) + flat_last_step_outputs = nest.flatten(ctx.last_step_outputs) + if flat_last_step_outputs: + with ops.control_dependencies([fn_result]): + return [array_ops.identity(f) for f in flat_last_step_outputs] + else: + return fn_result # TODO(sourabhbajaj): The input to while loop should be based on the output # type of the step_fn def iterate_on_tpu(): - return training_loop.repeat(iterations, run_fn, [initial_loop_values]) + return training_loop.repeat(iterations, run_fn, initial_loop_values) replicate_inputs = [[]] * self.num_towers - outputs = tpu.replicate(iterate_on_tpu, replicate_inputs) - last_step_tensor_outputs = [list(x) for x in zip(*outputs)] - - # Take index [0] of last_step_tensor_outputs as we wrapped - # initial_loop_values in a list in the `repeat` call. - return (control_flow_ops.group(last_step_tensor_outputs, enqueue_ops), - last_step_tensor_outputs[0], ctx) + replicate_outputs = tpu.replicate(iterate_on_tpu, replicate_inputs) + ctx.run_op = control_flow_ops.group(replicate_outputs, enqueue_ops) + + # Filter out any ops from the outputs, typically this would be the case + # when there were no tensor outputs. + last_step_tensor_outputs = [x for x in replicate_outputs + if not isinstance(x, ops.Operation)] + + # Outputs are currently of the structure (grouped by device) + # [[output0_device0, output1_device0, output2_device0], + # [output0_device1, output1_device1, output2_device1]] + # Convert this to the following structure instead: (grouped by output) + # [[output0_device0, output0_device1], + # [output1_device0, output1_device1], + # [output2_device0, output2_device1]] + last_step_tensor_outputs = [list(x) for x in zip(*last_step_tensor_outputs)] + + # Convert replicate_outputs to the original dict structure of + # last_step_outputs. + last_step_tensor_outputs_dict = nest.pack_sequence_as( + ctx.last_step_outputs, last_step_tensor_outputs) + + for (name, aggregation) in ctx._last_step_outputs_aggregations.items(): # pylint: disable=protected-access + output = last_step_tensor_outputs_dict[name] + # For outputs that have already been aggregated, take the first value + # from the list as each value should be the same. Else return the full + # list of values. + if aggregation is not variables_lib.VariableAggregation.NONE: + # TODO(priyag): Should this return the element or a list with 1 element + last_step_tensor_outputs_dict[name] = output[0] + ctx._set_last_step_outputs(last_step_tensor_outputs_dict) # pylint: disable=protected-access + + return ctx def _call_for_each_tower(self, fn, *args, **kwargs): kwargs.pop('run_concurrently', None) with one_device_strategy._OneDeviceTowerContext(self): # pylint: disable=protected-access return fn(*args, **kwargs) - def get_initialization_ops(self): - return [tpu.initialize_system()] + def initialize(self): + if context.executing_eagerly(): + # TODO(priyag): Add appopriate call here when eager is supported for TPUs. + raise NotImplementedError('Eager mode not supported in TPUStrategy.') + else: + return [tpu.initialize_system()] - def get_finalize_ops(self): - return [tpu.shutdown_system()] + def finalize(self): + if context.executing_eagerly(): + # TODO(priyag): Add appopriate call here when eager is supported for TPUs. + raise NotImplementedError('Eager mode not supported in TPUStrategy.') + else: + return [tpu.shutdown_system()] def _reduce(self, aggregation, value, destinations): graph = ops.get_default_graph() - context = graph._get_control_flow_context() # pylint: disable=protected-access + cf_context = graph._get_control_flow_context() # pylint: disable=protected-access # If we're inside the ReplicateContext, reduction should be done using # CrossReplicaSum while outside we can directly use an add_n op. - while context: - if isinstance(context, tpu.TPUReplicateContext): + while cf_context: + if isinstance(cf_context, tpu.TPUReplicateContext): if aggregation == vs.VariableAggregation.MEAN: # TODO(jhseu): Revisit once we support model-parallelism. - value *= (1. / self._num_cores_per_host) + value *= (1. / self.num_towers) return tpu_ops.cross_replica_sum(value) - context = context.outer_context + cf_context = cf_context.outer_context # Validate that the destination is same as the host device # Note we don't do this when in replicate context as the reduction is @@ -192,6 +231,11 @@ class TPUStrategy(one_device_strategy.OneDeviceStrategy): return output * (1. / len(value)) return output + def _unwrap(self, value): + if isinstance(value, list): + return value + return [value] + @property def num_towers(self): return self._tpu_metadata.num_of_cores_per_host diff --git a/tensorflow/contrib/distribute/python/values.py b/tensorflow/contrib/distribute/python/values.py index 6f34dd4746..5fd4c9de69 100644 --- a/tensorflow/contrib/distribute/python/values.py +++ b/tensorflow/contrib/distribute/python/values.py @@ -35,6 +35,7 @@ from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import variable_scope as vs +from tensorflow.python.ops import variables as variables_lib from tensorflow.python.training import device_util from tensorflow.python.training import distribute as distribute_lib from tensorflow.python.training import saver @@ -934,67 +935,99 @@ class MultiStepContext(object): This context object is useful when running multiple steps at a time using the `run_steps_on_dataset` API. For e.g. it allows the user's step function to - specify which outputs to emit at what frequency. Currently it only supports - capturing output from the last step, but will soon be augmented to support - other use cases such as output each N steps. + specify which outputs to emit at what frequency. Currently it supports + capturing output from the last step, as well as capturing non tensor outputs. + In the future it will be augmented to support other use cases such as output + each N steps. """ - def __init__(self, initial_loop_values=None): + def __init__(self): """Initializes an output context. - Args: - initial_loop_values: Initial values passed to the run steps - while loop. The only purpose is to verify the shapes and types - when the actual output is set. This will be removed once we - automatically infer the output shapes and types (and do not need to - check for user error in specifying them manually). Returns: A context object. """ - self._last_step_outputs = None - self._non_tensor_outputs = None - self._initial_loop_values = initial_loop_values + self._last_step_outputs = {} + self._last_step_outputs_aggregations = {} + self._non_tensor_outputs = {} @property def last_step_outputs(self): - """Return the last step's outputs.""" + """A dictionary consisting of outputs to be captured on last step. + + Keys in the dictionary are names of tensors to be captured, as specified + when `set_last_step_output` is called. + Values in the dictionary are the tensors themselves. If + `set_last_step_output` was called with an `aggregation` for this output, + then the value is the aggregated value. + + Returns: + A dictionary with last step outputs. + """ return self._last_step_outputs - @last_step_outputs.setter - def last_step_outputs(self, outputs): - """Set the last step's outputs.""" - self._verify_structure_shapes_types(outputs, self._initial_loop_values) + def _set_last_step_outputs(self, outputs): + """Replace the entire dictionary of last step outputs.""" + if not isinstance(outputs, dict): + raise ValueError("Need a dictionary to set last_step_outputs.") self._last_step_outputs = outputs + def set_last_step_output(self, name, output, + aggregation=variables_lib.VariableAggregation.NONE): + """Set `output` with `name` to be outputted from the last step. + + Args: + name: String, name to identify the output. Doesn't need to match tensor + name. + output: The tensors that should be outputted with `name`. See below for + actual types supported. + aggregation: Aggregation method to use to aggregate outputs from multiple + towers. Required if `set_last_step_output` is called in a tower context. + Optional in cross_tower_context. + When present, the outputs from all the towers are aggregated using the + current distribution strategy's `reduce` method. Hence, the type of + `output` must be what's supported by the corresponding `reduce` method. + For e.g. if using MirroredStrategy and aggregation is set, output + must be a `PerDevice` value. + The aggregation method is also recorded in a dictionary + `_last_step_outputs_aggregations` for later interpreting of the + outputs as already reduced or not. + + """ + if distribute_lib.get_cross_tower_context(): + self._last_step_outputs_aggregations[name] = aggregation + if aggregation is variables_lib.VariableAggregation.NONE: + self._last_step_outputs[name] = output + else: + distribution = distribute_lib.get_distribution_strategy() + self._last_step_outputs[name] = distribution.reduce( + aggregation, output, destinations="/device:CPU:0") + else: + assert aggregation is not variables_lib.VariableAggregation.NONE + def merge_fn(distribution, value): + self._last_step_outputs[name] = distribution.reduce( + aggregation, value, destinations="/device:CPU:0") + # Setting this inside the `merge_fn` because all towers share the same + # context object, so it's more robust to set it only once (even if all + # the towers are trying to set the same value). + self._last_step_outputs_aggregations[name] = aggregation + distribute_lib.get_tower_context().merge_call(merge_fn, output) + @property def non_tensor_outputs(self): - """Return the non tensor outputs.""" + """A dictionary consisting of any non tensor outputs to be captured.""" return self._non_tensor_outputs - @non_tensor_outputs.setter - def non_tensor_outputs(self, outputs): - """Set any non tensor outputs.""" - self._non_tensor_outputs = outputs - - def _verify_structure_shapes_types(self, left, right): - """Verify that the structure, shapes and types of left are same as right.""" - nest.assert_same_structure(left, right) - flat_left = nest.flatten(left) - flat_right = nest.flatten(right) - assert len(flat_left) == len(flat_right), ( - "Length of left {} and right {} should be same.". - format(len(flat_left), len(flat_right))) - - for o, i in zip(flat_left, flat_right): - # TODO(priyag): Add checks for other types like IndexedSlices. - if isinstance(o, ops.Tensor): - assert isinstance(i, ops.Tensor) - assert o.shape == i.shape, ( - "Shape {} of left {} doesn't match shape {} of right {}.". - format(o.shape, o, i.shape, i)) - assert o.dtype == i.dtype, ( - "Dtype {} of left {} doesn't match dtype {} of right {}.". - format(o.dtype, o, i.dtype, i)) + def set_non_tensor_output(self, name, output): + """Set `output` with `name` to be captured as a non tensor output.""" + if distribute_lib.get_cross_tower_context(): + self._non_tensor_outputs[name] = output + else: + def merge_fn(distribution, value): + # NOTE(priyag): For non tensor outputs, we simply return all the values + # in a list as aggregation doesn't make sense on non tensors. + self._non_tensor_outputs[name] = distribution.unwrap(value) + distribute_lib.get_tower_context().merge_call(merge_fn, output) def value_container(val): diff --git a/tensorflow/python/estimator/estimator.py b/tensorflow/python/estimator/estimator.py index 2fe44bc6ce..3b6b180b25 100644 --- a/tensorflow/python/estimator/estimator.py +++ b/tensorflow/python/estimator/estimator.py @@ -1215,19 +1215,23 @@ class Estimator(object): labels, model_fn_lib.ModeKeys.TRAIN, self.config) - ctx.last_step_outputs = estimator_spec.loss - ctx.non_tensor_outputs = {'estimator_spec': estimator_spec} - with ops.control_dependencies([estimator_spec.train_op]): - return array_ops.identity(estimator_spec.loss) + ctx.set_last_step_output( + name='loss', + output=estimator_spec.loss, + aggregation=distribute_lib.get_loss_reduction()) + ctx.set_non_tensor_output( + name='estimator_spec', output=estimator_spec) + return estimator_spec.train_op # Create new train_op post graph rewrites # TODO(sourabhbajaj): Make sure train_steps and tpu_iterations # work correctly. Currently hardcoded at 2 initial_training_loss = constant_op.constant(1e7) - distributed_train_op, tpu_result, ctx = \ - self._train_distribution._run_steps_on_dataset( # pylint: disable=protected-access - step_fn, iterator, iterations=2, - initial_loop_values=initial_training_loss) + ctx = self._train_distribution.run_steps_on_dataset( + step_fn, iterator, iterations=2, + initial_loop_values={'loss': initial_training_loss}) + distributed_train_op = ctx.run_op + tpu_result = ctx.last_step_outputs grouped_estimator_spec = ctx.non_tensor_outputs['estimator_spec'] else: features, labels, input_hooks = ( @@ -1263,22 +1267,22 @@ class Estimator(object): # TODO(sourabhbajaj): Merge the two code paths and clean up the code if is_tpu_strategy: - distributed_loss = tpu_result + loss = tpu_result['loss'] worker_hooks.append( estimator_util.StrategyInitFinalizeHook( - self._train_distribution.get_initialization_ops, - self._train_distribution.get_finalize_ops)) + self._train_distribution.initialize, + self._train_distribution.finalize)) else: - distributed_loss = grouped_estimator_spec.loss + loss = self._train_distribution.unwrap( + self._train_distribution.reduce( + distribute_lib.get_loss_reduction(), + grouped_estimator_spec.loss, + destinations='/device:CPU:0'))[0] distributed_train_op = grouped_estimator_spec.train_op estimator_spec = model_fn_lib.EstimatorSpec( mode=grouped_estimator_spec.mode, - loss=self._train_distribution.unwrap( - self._train_distribution.reduce( - distribute_lib.get_loss_reduction(), - distributed_loss, - destinations='/device:CPU:0'))[0], + loss=loss, train_op=self._train_distribution.group(distributed_train_op), training_hooks=training_hooks, training_chief_hooks=training_chief_hooks, diff --git a/tensorflow/python/training/distribute.py b/tensorflow/python/training/distribute.py index 170d68397b..5f7a53e186 100644 --- a/tensorflow/python/training/distribute.py +++ b/tensorflow/python/training/distribute.py @@ -21,6 +21,7 @@ from __future__ import print_function import threading from tensorflow.python.data.ops import dataset_ops +from tensorflow.python.eager import context from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops @@ -727,6 +728,85 @@ class DistributionStrategy(object): def _broadcast(self, tensor, destinations): raise NotImplementedError("must be implemented in descendants") + def initialize(self): + """Any initialization to be done before running any computations. + + In eager mode, it executes any initialization as a side effect. + In graph mode, it creates the initialization ops and returns them. + + For example, TPU initialize_system ops. + + Returns: + In eager mode, returns `None`. + In graph mode, a list of ops to execute. Empty list if nothing to be done. + """ + if context.executing_eagerly(): + return + else: + return [] + + def finalize(self): + """Any final actions to be done at the end of all computations. + + In eager mode, it executes any finalize actions as a side effect. + In graph mode, it creates the finalize ops and returns them. + + For example, TPU shutdown ops. + + Returns: + In eager mode, returns `None`. + In graph mode, a list of ops to execute. Empty list if nothing to be done. + """ + if context.executing_eagerly(): + return + else: + return [] + + def run_steps_on_dataset(self, fn, iterator, iterations=1, + initial_loop_values=None): + """Run `fn` with input from `iterator` for `iterations` times. + + This method can be used to run a step function for training a number of + times using input from a dataset. + + Args: + fn: function to run using this distribution strategy. The function must + have the following signature: def fn(context, inputs). + `context` is an instance of `MultiStepContext` that will be passed when + `fn` is run. `context` can be used to specify the outputs to be returned + from `fn` by calling `context.set_last_step_output`. It can also be used + to capture non tensor outputs by `context.set_non_tensor_output`. + See `MultiStepContext` documentation for more information. + `inputs` will have same type/structure as `iterator.get_next()`. + Typically, `fn` will use `call_for_each_tower` method of the strategy + to distribute the computation over multiple towers. + iterator: Iterator of a dataset that represents the input for `fn`. The + caller is responsible for initializing the iterator as needed. + iterations: (Optional) Number of iterations that `fn` should be run. + Defaults to 1. + initial_loop_values: (Optional) Initial values to be passed into the + loop that runs `fn`. Defaults to `None`. # TODO(priyag): Remove + initial_loop_values argument when we have a mechanism to infer the + outputs of `fn`. + + Returns: + Returns the `MultiStepContext` object which has the following properties, + among other things: + - run_op: An op that runs `fn` `iterations` times. + - last_step_outputs: A dictionary containing tensors set using + `context.set_last_step_output`. Evaluating this returns the value of + the tensors after the last iteration. + - non_tensor_outputs: A dictionatry containing anything that was set by + `fn` by calling `context.set_non_tensor_output`. + """ + _require_cross_tower_context(self) + return self._run_steps_on_dataset(fn, iterator, iterations, + initial_loop_values) + + def _run_steps_on_dataset(self, fn, iterator, iterations, + initial_loop_values): + raise NotImplementedError("must be implemented in descendants") + def call_for_each_tower(self, fn, *args, **kwargs): """Run `fn` once per tower. -- GitLab From b7d97e85a509dc14f3e81bb289fdb7bad64f0bbe Mon Sep 17 00:00:00 2001 From: Niall Moran Date: Thu, 9 Aug 2018 00:29:49 +0100 Subject: [PATCH 230/437] Update cuda and cudnn paths to for debian --- configure.py | 13 +++++++------ third_party/gpus/cuda_configure.bzl | 4 +++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/configure.py b/configure.py index f97bf8a668..bf570a9fa3 100644 --- a/configure.py +++ b/configure.py @@ -839,15 +839,16 @@ def set_tf_cuda_version(environ_cp): cuda_toolkit_path = cygpath(cuda_toolkit_path) if is_windows(): - cuda_rt_lib_path = 'lib/x64/cudart.lib' + cuda_rt_lib_paths = ['lib/x64/cudart.lib'] elif is_linux(): - cuda_rt_lib_path = 'lib64/libcudart.so.%s' % tf_cuda_version + cuda_rt_lib_paths = ['%s/libcudart.so.%s' % (x, tf_cuda_version) + for x in ['lib64', 'lib/x86_64-linux-gnu']] elif is_macos(): - cuda_rt_lib_path = 'lib/libcudart.%s.dylib' % tf_cuda_version + cuda_rt_lib_paths = ['lib/libcudart.%s.dylib' % tf_cuda_version] - cuda_toolkit_path_full = os.path.join(cuda_toolkit_path, cuda_rt_lib_path) - if os.path.exists(cuda_toolkit_path_full): - break + cuda_toolkit_paths_full = [os.path.join(cuda_toolkit_path, x) for x in cuda_rt_lib_paths] + if any([os.path.exists(x) for x in cuda_toolkit_paths_full]): + break # Reset and retry print('Invalid path to CUDA %s toolkit. %s cannot be found' % diff --git a/third_party/gpus/cuda_configure.bzl b/third_party/gpus/cuda_configure.bzl index e848fa175c..f6a39aeaf1 100644 --- a/third_party/gpus/cuda_configure.bzl +++ b/third_party/gpus/cuda_configure.bzl @@ -61,6 +61,7 @@ CUDA_LIB_PATHS = [ CUPTI_HEADER_PATHS = [ "extras/CUPTI/include/", "include/cuda/CUPTI/", + "include/", ] # Lookup paths for the cupti library, relative to the @@ -69,7 +70,7 @@ CUPTI_HEADER_PATHS = [ # the other CUDA libraries but rather in a special extras/CUPTI directory. CUPTI_LIB_PATHS = [ "extras/CUPTI/lib64/", - "lib/x86_64-linux-gnu", + "lib/x86_64-linux-gnu/", "lib64/", "extras/CUPTI/libx64/", "extras/CUPTI/lib/", @@ -96,6 +97,7 @@ CUDNN_INCLUDE_PATHS = [ NVVM_LIBDEVICE_PATHS = [ "nvvm/libdevice/", "share/cuda/", + "lib/nvidia-cuda-toolkit/libdevice/", ] # Files used to detect the NVVM libdevice path. -- GitLab From e6921fdc23d020fd24781c8757b97e2877ea491e Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Wed, 8 Aug 2018 16:38:14 -0700 Subject: [PATCH 231/437] Add support for ResourceVariables in Shampoo optimizer. Updates Shampoo default matrix size to ones that work better on TPUs. Change norm to use the F norm. PiperOrigin-RevId: 207967042 --- tensorflow/contrib/opt/BUILD | 2 + .../contrib/opt/python/training/shampoo.py | 39 +++-- .../opt/python/training/shampoo_test.py | 163 ++++++++++++------ 3 files changed, 141 insertions(+), 63 deletions(-) diff --git a/tensorflow/contrib/opt/BUILD b/tensorflow/contrib/opt/BUILD index 280d4a5492..778b710d78 100644 --- a/tensorflow/contrib/opt/BUILD +++ b/tensorflow/contrib/opt/BUILD @@ -348,6 +348,7 @@ py_test( py_test( name = "shampoo_test", + size = "large", srcs = ["python/training/shampoo_test.py"], srcs_version = "PY2AND3", deps = [ @@ -361,5 +362,6 @@ py_test( "//tensorflow/python:resource_variable_ops", "//tensorflow/python:variables", "//third_party/py/numpy", + "@absl_py//absl/testing:parameterized", ], ) diff --git a/tensorflow/contrib/opt/python/training/shampoo.py b/tensorflow/contrib/opt/python/training/shampoo.py index 7afa0998f4..a98866b180 100644 --- a/tensorflow/contrib/opt/python/training/shampoo.py +++ b/tensorflow/contrib/opt/python/training/shampoo.py @@ -66,8 +66,9 @@ class ShampooOptimizer(optimizer.Optimizer): a lambda function that depends on step. """ - def __init__(self, global_step=0, - max_matrix_size=500, + def __init__(self, + global_step=0, + max_matrix_size=768, gbar_decay=0.0, gbar_weight=1.0, mat_gbar_decay=1.0, @@ -149,18 +150,27 @@ class ShampooOptimizer(optimizer.Optimizer): _ = self._get_or_make_slot(v, mat_g_init, "Gbar_" + str(i), self._name) + def _resource_apply_dense(self, grad, var): + return self._apply_dense(grad, var) + def _apply_dense(self, grad, var): return self._apply_gradient(grad, var) + def _resource_apply_sparse(self, grad_values, var, grad_indices): + return self._apply_sparse_shared(grad_values, grad_indices, var) + def _apply_sparse(self, grad, var): + return self._apply_sparse_shared(grad.values, grad.indices, var) + + def _apply_sparse_shared(self, grad_values, grad_indices, var): if var.get_shape()[0] < self._max_matrix_size or self._gbar_decay != 0.0: # The dimension is small enough, we can make the variable dense and # do a dense update dense_grad = array_ops.scatter_nd( - array_ops.expand_dims(grad.indices, axis=1), - grad.values, array_ops.shape(var, out_type=grad.indices.dtype)) + array_ops.expand_dims(grad_indices, axis=1), grad_values, + array_ops.shape(var, out_type=grad_indices.dtype)) return self._apply_gradient(dense_grad, var) - return self._apply_gradient(grad.values, var, grad.indices) + return self._apply_gradient(grad_values, var, grad_indices) def _weighted_average(self, var, weight, weight_t, rest): """Computes exponential weighted average: var = weight_t * var + rest. @@ -304,7 +314,7 @@ class ShampooOptimizer(optimizer.Optimizer): mat_h = math_ops.pow(mat_g + self._epsilon, alpha) else: damped_mat_g = mat_g + self._epsilon * identity - z = (1 - 1/alpha) / (2 * linalg_ops.norm(damped_mat_g, ord=2)) + z = (1 - 1 / alpha) / (2 * linalg_ops.norm(damped_mat_g)) # The best value for z is # (1 - 1/alpha) * (c_max^{-alpha} - c_min^{-alpha}) / # (c_max^{1-alpha} - c_min^{1-alpha}) @@ -326,12 +336,13 @@ class ShampooOptimizer(optimizer.Optimizer): def _compute_power(self, var, mat_g, mat_g_size, alpha, mat_h_slot_name=None): """Just a switch between the iterative power vs svd.""" - if self._use_iterative_root: - return self._compute_power_iter(var, mat_g, mat_g_size, alpha, - mat_h_slot_name) - else: - return self._compute_power_svd(var, mat_g, mat_g_size, alpha, - mat_h_slot_name) + with ops.name_scope("matrix_iterative_power"): + if self._use_iterative_root: + return self._compute_power_iter(var, mat_g, mat_g_size, alpha, + mat_h_slot_name) + else: + return self._compute_power_svd(var, mat_g, mat_g_size, alpha, + mat_h_slot_name) def _apply_gradient(self, grad, var, indices=None): """The main function to update a variable. @@ -455,8 +466,8 @@ class ShampooOptimizer(optimizer.Optimizer): # Update the variable based on the Shampoo update learning_rate_t = GetParam(self._learning_rate, global_step) if indices is not None: - var_updated = state_ops.scatter_sub(var, indices, - learning_rate_t * preconditioned_grad) + var_updated = state_ops.scatter_add( + var, indices, -learning_rate_t * preconditioned_grad) else: var_updated = state_ops.assign_sub(var, learning_rate_t * preconditioned_grad) diff --git a/tensorflow/contrib/opt/python/training/shampoo_test.py b/tensorflow/contrib/opt/python/training/shampoo_test.py index 3148d02296..2e0a202ae2 100644 --- a/tensorflow/contrib/opt/python/training/shampoo_test.py +++ b/tensorflow/contrib/opt/python/training/shampoo_test.py @@ -19,6 +19,7 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +from absl.testing import parameterized import numpy as np from tensorflow.contrib.opt.python.training import shampoo @@ -40,9 +41,10 @@ def np_power(mat_g, alpha): return np.dot(np.dot(mat_u, np.diag(diag_d)), mat_v) -class ShampooTest(test.TestCase): +class ShampooTest(test.TestCase, parameterized.TestCase): - def testBasicVector(self): + @parameterized.named_parameters(('Var', False), ('ResourceVar', True)) + def testBasicVector(self, use_resource_var): """Similar to the full Adagrad update.""" size = 20 @@ -51,8 +53,10 @@ class ShampooTest(test.TestCase): grad_np_2 = np.random.rand(size) with self.test_session() as sess: - global_step = variables.Variable(0, dtype=dtypes.int64) - var = variables.Variable(init_var_np, dtype=dtypes.float32) + global_step = variables.Variable( + 0, dtype=dtypes.int64, use_resource=use_resource_var) + var = variables.Variable( + init_var_np, dtype=dtypes.float32, use_resource=use_resource_var) grad = constant_op.constant(grad_np, dtype=dtypes.float32) grad_2 = constant_op.constant(grad_np_2, dtype=dtypes.float32) @@ -91,7 +95,8 @@ class ShampooTest(test.TestCase): self.assertAllCloseAccordingToType(new_val_np, new_val, atol=TOLERANCE, rtol=TOLERANCE) - def testBasicMatrix(self): + @parameterized.named_parameters(('Var', False), ('ResourceVar', True)) + def testBasicMatrix(self, use_resource_var): """Check update when gradient is a matrix.""" size = [10, 5] init_var_np = np.zeros(size) @@ -99,8 +104,10 @@ class ShampooTest(test.TestCase): grad_np_2 = np.random.rand(size[0], size[1]) with self.test_session() as sess: - global_step = variables.Variable(0, dtype=dtypes.int64) - var = variables.Variable(init_var_np, dtype=dtypes.float32) + global_step = variables.Variable( + 0, dtype=dtypes.int64, use_resource=use_resource_var) + var = variables.Variable( + init_var_np, dtype=dtypes.float32, use_resource=use_resource_var) grad = constant_op.constant(grad_np, dtype=dtypes.float32) grad_2 = constant_op.constant(grad_np_2, dtype=dtypes.float32) @@ -143,16 +150,23 @@ class ShampooTest(test.TestCase): self.assertAllCloseAccordingToType(new_val_np, new_val, atol=TOLERANCE, rtol=TOLERANCE) - def _testBasicTensor(self, use_iterative_root): - """Check update when gradient is a tensor.""" + def _testBasicTensor(self, use_iterative_root, use_resource_var): + """Check update when gradient is a tensor. + + Args: + use_iterative_root: use iterative power method or SVD to find nth roots. + use_resource_var: use resource var as variables. + """ size = [10, 5, 7] init_var_np = np.zeros(size) grad_np = np.random.rand(size[0], size[1], size[2]) grad_np_2 = np.random.rand(size[0], size[1], size[2]) with self.test_session() as sess: - global_step = variables.Variable(0, dtype=dtypes.int64) - var = variables.Variable(init_var_np, dtype=dtypes.float32) + global_step = variables.Variable( + 0, dtype=dtypes.int64, use_resource=use_resource_var) + var = variables.Variable( + init_var_np, dtype=dtypes.float32, use_resource=use_resource_var) grad = constant_op.constant(grad_np, dtype=dtypes.float32) grad_2 = constant_op.constant(grad_np_2, dtype=dtypes.float32) @@ -208,11 +222,17 @@ class ShampooTest(test.TestCase): self.assertAllCloseAccordingToType(new_val_np, new_val, atol=TOLERANCE, rtol=TOLERANCE) - def testBasicTensor(self): - for use_iterative_root in [True, False]: - self._testBasicTensor(use_iterative_root) - - def testLargeVector(self): + @parameterized.named_parameters( + ('SVDWithVar', False, False), + ('SVDWithResourceVar', False, True), + ('IterRootWithVar', True, False), + ('IterRootWithResourceVar', True, True), + ) + def testBasicTensor(self, use_iterative_root, use_resource_var): + self._testBasicTensor(use_iterative_root, use_resource_var) + + @parameterized.named_parameters(('Var', False), ('ResourceVar', True)) + def testLargeVector(self, use_resource_var): """This is just the diagonal Adagrad update.""" size = 2000 @@ -221,8 +241,10 @@ class ShampooTest(test.TestCase): grad_np_2 = np.random.rand(size) with self.test_session() as sess: - global_step = variables.Variable(0, dtype=dtypes.int64) - var = variables.Variable(init_var_np, dtype=dtypes.float32) + global_step = variables.Variable( + 0, dtype=dtypes.int64, use_resource=use_resource_var) + var = variables.Variable( + init_var_np, dtype=dtypes.float32, use_resource=use_resource_var) grad = constant_op.constant(grad_np, dtype=dtypes.float32) grad_2 = constant_op.constant(grad_np_2, dtype=dtypes.float32) @@ -257,10 +279,14 @@ class ShampooTest(test.TestCase): self.assertAllCloseAccordingToType(new_val_np, new_val) - def testLargeMatrix(self): + @parameterized.named_parameters(('Var', False), ('ResourceVar', True)) + def testLargeMatrix(self, use_resource_var): """Gradient is a matrix, one of whose dimensions is large. We do diagonal updates for large dimensions. + + Args: + use_resource_var: use resource var as variables. """ size = [2000, 3] @@ -269,8 +295,10 @@ class ShampooTest(test.TestCase): grad_np_2 = np.random.rand(size[0], size[1]) with self.test_session() as sess: - global_step = variables.Variable(0, dtype=dtypes.int64) - var = variables.Variable(init_var_np, dtype=dtypes.float32) + global_step = variables.Variable( + 0, dtype=dtypes.int64, use_resource=use_resource_var) + var = variables.Variable( + init_var_np, dtype=dtypes.float32, use_resource=use_resource_var) grad = constant_op.constant(grad_np, dtype=dtypes.float32) grad_2 = constant_op.constant(grad_np_2, dtype=dtypes.float32) @@ -316,12 +344,15 @@ class ShampooTest(test.TestCase): self.assertAllCloseAccordingToType(new_val_np, new_val, atol=TOLERANCE, rtol=TOLERANCE) - def testSparseUpdateLarge(self): + @parameterized.named_parameters(('Var', False)) + def testSparseUpdateLarge(self, use_resource_var): """Check update when gradient is of type IndexSlices. We do diagonal updates for the first dimension, unless it is very small. - """ + Args: + use_resource_var: use resource var as variables. + """ size = [2000, 3] sample_size_1 = 100 init_var_np = np.zeros(size) @@ -335,8 +366,10 @@ class ShampooTest(test.TestCase): grad_np_2 = np.random.rand(sample_size_2, size[1]) with self.test_session() as sess: - global_step = variables.Variable(0, dtype=dtypes.int64) - var = variables.Variable(init_var_np, dtype=dtypes.float32) + global_step = variables.Variable( + 0, dtype=dtypes.int64, use_resource=use_resource_var) + var = variables.Variable( + init_var_np, dtype=dtypes.float32, use_resource=use_resource_var) grad = ops.IndexedSlices( constant_op.constant(grad_np, dtype=dtypes.float32), constant_op.constant(grad_indices), @@ -395,13 +428,14 @@ class ShampooTest(test.TestCase): self.assertAllCloseAccordingToType(new_val_np, new_val, atol=TOLERANCE, rtol=TOLERANCE) - def _testSparseUpdateSmall(self, use_iterative_root): + def _testSparseUpdateSmall(self, use_iterative_root, use_resource_var): """Gradient is of type IndexSlices, but the first dimension is small. We create dense gradient and do the full update with SVD etc. Args: use_iterative_root: use iterative power method or SVD to find nth roots. + use_resource_var: use resource var as variables. """ size = [100, 3, 5] @@ -412,8 +446,10 @@ class ShampooTest(test.TestCase): grad_np = np.random.rand(sample_size, size[1], size[2]) with self.test_session() as sess: - global_step = variables.Variable(0, dtype=dtypes.int64) - var = variables.Variable(init_var_np, dtype=dtypes.float32) + global_step = variables.Variable( + 0, dtype=dtypes.int64, use_resource=use_resource_var) + var = variables.Variable( + init_var_np, dtype=dtypes.float32, use_resource=use_resource_var) grad = ops.IndexedSlices( constant_op.constant(grad_np, dtype=dtypes.float32), constant_op.constant(grad_indices), @@ -453,15 +489,21 @@ class ShampooTest(test.TestCase): self.assertAllCloseAccordingToType(new_val_np, new_val, atol=TOLERANCE, rtol=TOLERANCE) - def testSparseUpdateSmall(self): - for use_iterative_root in [True, False]: - self._testSparseUpdateSmall(use_iterative_root) + @parameterized.named_parameters( + ('SVDWithVar', False, False), + ('SVDWithResourceVar', False, True), + ('IterRootWithVar', True, False), + ('IterRootWithResourceVar', True, True), + ) + def testSparseUpdateSmall(self, use_iterative_root, use_resource_var): + self._testSparseUpdateSmall(use_iterative_root, use_resource_var) - def _testBasicTensorWithMomentum(self, use_iterative_root): + def _testBasicTensorWithMomentum(self, use_iterative_root, use_resource_var): """Check update with momentum when gradient is a tensor. Args: use_iterative_root: use iterative power method or SVD to find nth roots. + use_resource_var: use resource var as variables. """ size = [10, 5, 7] init_var_np = np.zeros(size) @@ -471,8 +513,10 @@ class ShampooTest(test.TestCase): gbar_weight = 0.1 with self.test_session() as sess: - global_step = variables.Variable(0, dtype=dtypes.int64) - var = variables.Variable(init_var_np, dtype=dtypes.float32) + global_step = variables.Variable( + 0, dtype=dtypes.int64, use_resource=use_resource_var) + var = variables.Variable( + init_var_np, dtype=dtypes.float32, use_resource=use_resource_var) grad = constant_op.constant(grad_np, dtype=dtypes.float32) grad_2 = constant_op.constant(grad_np_2, dtype=dtypes.float32) @@ -528,15 +572,21 @@ class ShampooTest(test.TestCase): self.assertAllCloseAccordingToType(new_val_np, new_val, atol=TOLERANCE, rtol=TOLERANCE) - def testBasicTensorWithMomentum(self): - for use_iterative_root in [True, False]: - self._testBasicTensorWithMomentum(use_iterative_root) + @parameterized.named_parameters( + ('SVDWithVar', False, False), + ('SVDWithResourceVar', False, True), + ('IterRootWithVar', True, False), + ('IterRootWithResourceVar', True, True), + ) + def testBasicTensorWithMomentum(self, use_iterative_root, use_resource_var): + self._testBasicTensorWithMomentum(use_iterative_root, use_resource_var) - def _testDelayedSVD(self, use_iterative_root): + def _testDelayedSVD(self, use_iterative_root, use_resource_var): """Performing the SVD every nth step. Args: use_iterative_root: use iterative power method or SVD to find nth roots. + use_resource_var: use resource var as variables. """ size = [10, 5, 7] init_var_np = np.zeros(size).astype(np.float32) @@ -552,8 +602,10 @@ class ShampooTest(test.TestCase): mat_g3 = np.zeros_like(mat_g3_a) with self.test_session() as sess: - global_step = variables.Variable(0, dtype=dtypes.int64) - var = variables.Variable(init_var_np, dtype=dtypes.float32) + global_step = variables.Variable( + 0, dtype=dtypes.int64, use_resource=use_resource_var) + var = variables.Variable( + init_var_np, dtype=dtypes.float32, use_resource=use_resource_var) grad = array_ops.placeholder(dtypes.float32, shape=size) opt = shampoo.ShampooOptimizer(global_step, svd_interval=svd_interval, @@ -590,15 +642,21 @@ class ShampooTest(test.TestCase): self.assertAllCloseAccordingToType(new_val_np, new_val, atol=TOLERANCE, rtol=TOLERANCE) - def testDelayedSVD(self): - for use_iterative_root in [True, False]: - self._testDelayedSVD(use_iterative_root) + @parameterized.named_parameters( + ('SVDWithVar', False, False), + ('SVDWithResourceVar', False, True), + ('IterRootWithVar', True, False), + ('IterRootWithResourceVar', True, True), + ) + def testDelayedSVD(self, use_iterative_root, use_resource_var): + self._testDelayedSVD(use_iterative_root, use_resource_var) - def _testDelayedPrecondUpdate(self, use_iterative_root): + def _testDelayedPrecondUpdate(self, use_iterative_root, use_resource_var): """Update the squared sum every nth step, drop the other steps. Args: use_iterative_root: use iterative power method or SVD to find nth roots. + use_resource_var: use resource var as variables. """ size = [10, 5, 7] init_var_np = np.zeros(size).astype(np.float32) @@ -615,8 +673,10 @@ class ShampooTest(test.TestCase): mat_g3 = np.zeros_like(mat_g3_a) with self.test_session() as sess: - global_step = variables.Variable(0, dtype=dtypes.int64) - var = variables.Variable(init_var_np, dtype=dtypes.float32) + global_step = variables.Variable( + 0, dtype=dtypes.int64, use_resource=use_resource_var) + var = variables.Variable( + init_var_np, dtype=dtypes.float32, use_resource=use_resource_var) grad = array_ops.placeholder(dtypes.float32, shape=size) opt = shampoo.ShampooOptimizer( @@ -660,9 +720,14 @@ class ShampooTest(test.TestCase): self.assertAllCloseAccordingToType(new_val_np, new_val, atol=TOLERANCE, rtol=TOLERANCE) - def testDelayedPrecondUpdate(self): - for use_iterative_root in [True, False]: - self._testDelayedPrecondUpdate(use_iterative_root) + @parameterized.named_parameters( + ('SVDWithVar', False, False), + ('SVDWithResourceVar', False, True), + ('IterRootWithVar', True, False), + ('IterRootWithResourceVar', True, True), + ) + def testDelayedPrecondUpdate(self, use_iterative_root, use_resource_var): + self._testDelayedPrecondUpdate(use_iterative_root, use_resource_var) if __name__ == '__main__': -- GitLab From aacb29a4ab88f9fa27c3301977e7f2cc289a3976 Mon Sep 17 00:00:00 2001 From: Xuechen Li Date: Wed, 8 Aug 2018 16:45:10 -0700 Subject: [PATCH 232/437] Add a unit test from the blog post code demonstration. PiperOrigin-RevId: 207968029 --- .../python/examples/revnet/blocks_test.py | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tensorflow/contrib/eager/python/examples/revnet/blocks_test.py b/tensorflow/contrib/eager/python/examples/revnet/blocks_test.py index fda9020ddf..9ff6b605b9 100644 --- a/tensorflow/contrib/eager/python/examples/revnet/blocks_test.py +++ b/tensorflow/contrib/eager/python/examples/revnet/blocks_test.py @@ -188,6 +188,40 @@ class RevBlockTest(tf.test.TestCase): self._check_grad_angle(dx_true, dx) self._check_grad_angle(dw_true, dw) + def test_backward_grads_with_nativepy(self): + if not tf.test.is_gpu_available(): + self.skipTest("GPU not available") + + input_shape = (128, 8, 8) + data_shape = (16,) + input_shape + x = tf.random_normal(shape=data_shape, dtype=tf.float64) + dy = tf.random_normal(shape=data_shape, dtype=tf.float64) + dy1, dy2 = tf.split(dy, num_or_size_splits=2, axis=1) + block = blocks.RevBlock( + n_res=3, + filters=128, + strides=(1, 1), + input_shape=input_shape, + fused=False, + dtype=tf.float64) + with tf.GradientTape() as tape: + tape.watch(x) + x1, x2 = tf.split(x, num_or_size_splits=2, axis=1) + y1, y2 = block((x1, x2), training=True) + y = tf.concat((y1, y2), axis=1) + + # Compute true grads + dx_true = tape.gradient(y, x, output_gradients=dy) + + # Compute grads from reconstruction + (dx1, dx2), _ = block.backward_grads( + x=(x1, x2), y=(y1, y2), dy=(dy1, dy2), training=True) + dx = tf.concat((dx1, dx2), axis=1) + + thres = 1e-5 + diff_abs = tf.reshape(abs(dx - dx_true), [-1]) + assert all(diff_abs < thres) + class _ResidualTest(tf.test.TestCase): -- GitLab From 3e02edc1f33fb3bfa43b5828d8ecea0dbc7738ea Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Wed, 8 Aug 2018 17:10:33 -0700 Subject: [PATCH 233/437] [XLA] Add the xla interface for AllToAll. PiperOrigin-RevId: 207971529 --- tensorflow/compiler/xla/client/xla_builder.cc | 62 ++++++++++++++++ tensorflow/compiler/xla/client/xla_builder.h | 27 +++++-- .../compiler/xla/client/xla_builder_test.cc | 15 ++++ .../compiler/xla/service/dfs_hlo_visitor.h | 1 + .../service/dfs_hlo_visitor_with_default.h | 3 + tensorflow/compiler/xla/service/hlo.proto | 5 +- .../compiler/xla/service/hlo_cost_analysis.cc | 13 ++++ .../compiler/xla/service/hlo_cost_analysis.h | 1 + .../compiler/xla/service/hlo_graph_dumper.cc | 1 + .../compiler/xla/service/hlo_instruction.cc | 36 ++++++++- .../compiler/xla/service/hlo_instruction.h | 23 ++++++ .../compiler/xla/service/hlo_instructions.cc | 61 ++++++++++++++++ .../compiler/xla/service/hlo_instructions.h | 41 +++++++++++ tensorflow/compiler/xla/service/hlo_opcode.h | 1 + tensorflow/compiler/xla/service/hlo_parser.cc | 67 +++++++++++++++++ .../compiler/xla/service/hlo_parser_test.cc | 24 ++++++ .../compiler/xla/service/hlo_verifier.cc | 9 +++ .../compiler/xla/service/hlo_verifier.h | 1 + .../xla/service/instruction_fusion.cc | 1 + .../compiler/xla/service/shape_inference.cc | 45 ++++++++++++ .../compiler/xla/service/shape_inference.h | 13 +++- tensorflow/compiler/xla/xla_data.proto | 8 ++ .../performance/xla/operation_semantics.md | 73 +++++++++++++++++++ 23 files changed, 522 insertions(+), 9 deletions(-) diff --git a/tensorflow/compiler/xla/client/xla_builder.cc b/tensorflow/compiler/xla/client/xla_builder.cc index 073d66bcd2..b3b00e2fff 100644 --- a/tensorflow/compiler/xla/client/xla_builder.cc +++ b/tensorflow/compiler/xla/client/xla_builder.cc @@ -1881,6 +1881,61 @@ XlaOp XlaBuilder::CrossReplicaSum( }); } +XlaOp XlaBuilder::AllToAll(const XlaOp& operand, int64 split_dimension, + int64 concat_dimension, int64 split_count, + const std::vector& replica_groups) { + return ReportErrorOrReturn([&]() -> StatusOr { + TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); + + // The HloInstruction for Alltoall currently only handles the data + // communication: it accepts N already split parts and scatters them to N + // cores, and each core gathers the N received parts into a tuple as the + // output. So here we explicitly split the operand before the hlo alltoall, + // and concat the tuple elements. + // + // First, run shape inference to make sure the shapes are valid. + TF_RETURN_IF_ERROR( + ShapeInference::InferAllToAllShape(operand_shape, split_dimension, + concat_dimension, split_count) + .status()); + + // Split into N parts. + std::vector slices; + slices.reserve(split_count); + const int64 block_size = + operand_shape.dimensions(split_dimension) / split_count; + for (int i = 0; i < split_count; i++) { + slices.push_back(SliceInDim(operand, /*start_index=*/i * block_size, + /*limit_index=*/(i + 1) * block_size, + /*stride=*/1, /*dimno=*/split_dimension)); + } + + // Handle data communication. + HloInstructionProto instr; + TF_ASSIGN_OR_RETURN(auto slice_shapes, this->GetOperandShapes(slices)); + std::vector slice_shape_ptrs; + c_transform(slice_shapes, std::back_inserter(slice_shape_ptrs), + [](const Shape& shape) { return &shape; }); + TF_ASSIGN_OR_RETURN( + *instr.mutable_shape(), + ShapeInference::InferAllToAllTupleShape(slice_shape_ptrs)); + for (const ReplicaGroup& group : replica_groups) { + *instr.add_replica_groups() = group; + } + TF_ASSIGN_OR_RETURN( + XlaOp alltoall, + AddInstruction(std::move(instr), HloOpcode::kAllToAll, slices)); + + // Concat the N received parts. + std::vector received; + received.reserve(split_count); + for (int i = 0; i < split_count; i++) { + received.push_back(this->GetTupleElement(alltoall, i)); + } + return this->ConcatInDim(received, concat_dimension); + }); +} + XlaOp XlaBuilder::SelectAndScatter( const XlaOp& operand, const XlaComputation& select, tensorflow::gtl::ArraySlice window_dimensions, @@ -2677,6 +2732,13 @@ XlaOp CrossReplicaSum( replica_group_ids, channel_id); } +XlaOp AllToAll(const XlaOp& operand, int64 split_dimension, + int64 concat_dimension, int64 split_count, + const std::vector& replica_groups) { + return operand.builder()->AllToAll(operand, split_dimension, concat_dimension, + split_count, replica_groups); +} + XlaOp SelectAndScatter(const XlaOp& operand, const XlaComputation& select, tensorflow::gtl::ArraySlice window_dimensions, tensorflow::gtl::ArraySlice window_strides, diff --git a/tensorflow/compiler/xla/client/xla_builder.h b/tensorflow/compiler/xla/client/xla_builder.h index 3c5f8c8d53..9403d7ca8d 100644 --- a/tensorflow/compiler/xla/client/xla_builder.h +++ b/tensorflow/compiler/xla/client/xla_builder.h @@ -699,9 +699,9 @@ class XlaBuilder { // For example, we have 4 replicas, then replica_group_ids={0,1,0,1} means, // replica 0 and 2 are in subgroup 0, replica 1 and 3 are in subgroup 1. // - // - `channel_id`: for Allreduce nodes from different models, if they have the - // same channel_id, they will be 'Allreduce'd. If empty, Allreduce will not be - // applied cross models. + // - `channel_id`: for Allreduce nodes from different modules, if they have + // the same channel_id, they will be 'Allreduce'd. If empty, Allreduce will + // not be applied cross modules. // // TODO(b/79737069): Rename this to AllReduce when it's ready to use. XlaOp CrossReplicaSum( @@ -710,6 +710,13 @@ class XlaBuilder { const tensorflow::gtl::optional& channel_id = tensorflow::gtl::nullopt); + // Enqueues an operation that do an Alltoall of the operand cross cores. + // + // TODO(b/110096724): This is NOT YET ready to use. + XlaOp AllToAll(const XlaOp& operand, int64 split_dimension, + int64 concat_dimension, int64 split_count, + const std::vector& replica_groups); + // Enqueues an operation that scatters the `source` array to the selected // indices of each window. XlaOp SelectAndScatter(const XlaOp& operand, const XlaComputation& select, @@ -1246,6 +1253,9 @@ class XlaBuilder { const XlaOp& operand, const XlaComputation& computation, tensorflow::gtl::ArraySlice replica_group_ids, const tensorflow::gtl::optional& channel_id); + friend XlaOp AllToAll(const XlaOp& operand, int64 split_dimension, + int64 concat_dimension, int64 split_count, + const std::vector& replica_groups); friend XlaOp SelectAndScatter( const XlaOp& operand, const XlaComputation& select, tensorflow::gtl::ArraySlice window_dimensions, @@ -1832,9 +1842,9 @@ XlaOp CrossReplicaSum( // For example, we have 4 replicas, then replica_group_ids={0,1,0,1} means, // replica 0 and 2 are in subgroup 0, replica 1 and 3 are in subgroup 1. // -// - `channel_id`: for Allreduce nodes from different models, if they have the +// - `channel_id`: for Allreduce nodes from different modules, if they have the // same channel_id, they will be 'Allreduce'd. If empty, Allreduce will not be -// applied cross models. +// applied cross modules. // // TODO(b/79737069): Rename this to AllReduce when it's ready to use. XlaOp CrossReplicaSum(const XlaOp& operand, const XlaComputation& computation, @@ -1842,6 +1852,13 @@ XlaOp CrossReplicaSum(const XlaOp& operand, const XlaComputation& computation, const tensorflow::gtl::optional& channel_id = tensorflow::gtl::nullopt); +// Enqueues an operation that do an Alltoall of the operand cross cores. +// +// TODO(b/110096724): This is NOT YET ready to use. +XlaOp AllToAll(const XlaOp& operand, int64 split_dimension, + int64 concat_dimension, int64 split_count, + const std::vector& replica_groups = {}); + // Enqueues an operation that scatters the `source` array to the selected // indices of each window. XlaOp SelectAndScatter(const XlaOp& operand, const XlaComputation& select, diff --git a/tensorflow/compiler/xla/client/xla_builder_test.cc b/tensorflow/compiler/xla/client/xla_builder_test.cc index afe5be29f0..49a15ec3b4 100644 --- a/tensorflow/compiler/xla/client/xla_builder_test.cc +++ b/tensorflow/compiler/xla/client/xla_builder_test.cc @@ -305,6 +305,21 @@ TEST_F(XlaBuilderTest, Transpose) { EXPECT_THAT(root, op::Transpose(op::Parameter())); } +TEST_F(XlaBuilderTest, AllToAll) { + XlaBuilder b(TestName()); + auto x = Parameter(&b, 0, ShapeUtil::MakeShape(F32, {4, 16}), "x"); + AllToAll(x, /*split_dimension=*/1, /*concat_dimension=*/0, + /*split_count=*/2); + TF_ASSERT_OK_AND_ASSIGN(auto module, BuildHloModule(&b)); + auto root = module->entry_computation()->root_instruction(); + + // AllToAll is decomposed into slices -> all-to-all -> gte -> concat. + EXPECT_EQ(root->opcode(), HloOpcode::kConcatenate); + EXPECT_EQ(root->operand(0)->operand(0)->opcode(), HloOpcode::kAllToAll); + EXPECT_TRUE( + ShapeUtil::Equal(root->shape(), ShapeUtil::MakeShape(F32, {8, 8}))); +} + TEST_F(XlaBuilderTest, ReportError) { XlaBuilder b(TestName()); auto x = Parameter(&b, 0, ShapeUtil::MakeShape(F32, {5, 7}), "x"); diff --git a/tensorflow/compiler/xla/service/dfs_hlo_visitor.h b/tensorflow/compiler/xla/service/dfs_hlo_visitor.h index 9f86749125..86d57581f8 100644 --- a/tensorflow/compiler/xla/service/dfs_hlo_visitor.h +++ b/tensorflow/compiler/xla/service/dfs_hlo_visitor.h @@ -106,6 +106,7 @@ class DfsHloVisitorBase { virtual Status HandleConvolution(HloInstructionPtr hlo) = 0; virtual Status HandleFft(HloInstructionPtr fft) = 0; virtual Status HandleCrossReplicaSum(HloInstructionPtr hlo) = 0; + virtual Status HandleAllToAll(HloInstructionPtr hlo) = 0; virtual Status HandleCompare(HloInstructionPtr hlo) { return HandleElementwiseBinary(hlo); } diff --git a/tensorflow/compiler/xla/service/dfs_hlo_visitor_with_default.h b/tensorflow/compiler/xla/service/dfs_hlo_visitor_with_default.h index ae8a066d62..617a5a2eb4 100644 --- a/tensorflow/compiler/xla/service/dfs_hlo_visitor_with_default.h +++ b/tensorflow/compiler/xla/service/dfs_hlo_visitor_with_default.h @@ -94,6 +94,9 @@ class DfsHloVisitorWithDefaultBase Status HandleCrossReplicaSum(HloInstructionPtr crs) override { return DefaultAction(crs); } + Status HandleAllToAll(HloInstructionPtr crs) override { + return DefaultAction(crs); + } Status HandleRng(HloInstructionPtr random) override { return DefaultAction(random); } diff --git a/tensorflow/compiler/xla/service/hlo.proto b/tensorflow/compiler/xla/service/hlo.proto index 0b93d97c11..be9098f555 100644 --- a/tensorflow/compiler/xla/service/hlo.proto +++ b/tensorflow/compiler/xla/service/hlo.proto @@ -151,8 +151,11 @@ message HloInstructionProto { // Backend configuration for the instruction. Has backend-specific meaning. string backend_config = 43; - // Cross Replica Sum fields. + // Cross replica op fields. + // TODO(b/112107579): remove replica_group_ids field and always use + // replica_groups. repeated int64 replica_group_ids = 44; + repeated ReplicaGroup replica_groups = 49; int64 all_reduce_id = 45; string cross_replica_sum_barrier = 46; diff --git a/tensorflow/compiler/xla/service/hlo_cost_analysis.cc b/tensorflow/compiler/xla/service/hlo_cost_analysis.cc index a2cefd2621..1bbb0ff08e 100644 --- a/tensorflow/compiler/xla/service/hlo_cost_analysis.cc +++ b/tensorflow/compiler/xla/service/hlo_cost_analysis.cc @@ -543,6 +543,19 @@ Status HloCostAnalysis::HandleCrossReplicaSum(const HloInstruction* crs) { return Status::OK(); } +Status HloCostAnalysis::HandleAllToAll(const HloInstruction* hlo) { + // TODO(b/110096724): Compute correct cost here. + double flops = 0.0; + ShapeUtil::ForEachSubshape(hlo->shape(), + [&](const Shape& subshape, const ShapeIndex&) { + if (ShapeUtil::IsArray(subshape)) { + flops += ShapeUtil::ElementsIn(subshape); + } + }); + current_properties_[kFlopsKey] = flops; + return Status::OK(); +} + Status HloCostAnalysis::HandleRng(const HloInstruction* random) { // TODO(b/26346211): Implement better estimates for the RNG cost, since the // cost changes with the implementation and the distribution. For now, assume diff --git a/tensorflow/compiler/xla/service/hlo_cost_analysis.h b/tensorflow/compiler/xla/service/hlo_cost_analysis.h index 0a79c92f4a..193a04bea0 100644 --- a/tensorflow/compiler/xla/service/hlo_cost_analysis.h +++ b/tensorflow/compiler/xla/service/hlo_cost_analysis.h @@ -71,6 +71,7 @@ class HloCostAnalysis : public ConstDfsHloVisitor { Status HandleConvolution(const HloInstruction* convolution) override; Status HandleFft(const HloInstruction* fft) override; Status HandleCrossReplicaSum(const HloInstruction* crs) override; + Status HandleAllToAll(const HloInstruction* hlo) override; Status HandleInfeed(const HloInstruction* infeed) override; Status HandleOutfeed(const HloInstruction* outfeed) override; Status HandleHostCompute(const HloInstruction* host_compute) override; diff --git a/tensorflow/compiler/xla/service/hlo_graph_dumper.cc b/tensorflow/compiler/xla/service/hlo_graph_dumper.cc index bfe83cabf1..1efa6eb5bd 100644 --- a/tensorflow/compiler/xla/service/hlo_graph_dumper.cc +++ b/tensorflow/compiler/xla/service/hlo_graph_dumper.cc @@ -1048,6 +1048,7 @@ ColorScheme HloDotDumper::GetInstructionColor(const HloInstruction* instr) { case HloOpcode::kMap: return kGray; case HloOpcode::kCrossReplicaSum: + case HloOpcode::kAllToAll: case HloOpcode::kInfeed: case HloOpcode::kOutfeed: case HloOpcode::kRecv: diff --git a/tensorflow/compiler/xla/service/hlo_instruction.cc b/tensorflow/compiler/xla/service/hlo_instruction.cc index 7591b99204..8690f2cdaa 100644 --- a/tensorflow/compiler/xla/service/hlo_instruction.cc +++ b/tensorflow/compiler/xla/service/hlo_instruction.cc @@ -320,6 +320,15 @@ StatusOr> HloInstruction::CreateFromProto( /*all_reduce_id=*/all_reduce_id); break; } + case HloOpcode::kAllToAll: { + instruction = CreateAllToAll( + proto.shape(), all_operands(), + /*replica_groups=*/ + std::vector(proto.replica_groups().begin(), + proto.replica_groups().end()), + /*barrier=*/proto.cross_replica_sum_barrier()); + break; + } case HloOpcode::kConvolution: TF_RET_CHECK(proto.operand_ids_size() == 2) << "Convolution instruction should have 2 operands but sees " @@ -671,6 +680,14 @@ HloInstruction::CreateCrossReplicaSum( all_reduce_id); } +/* static */ std::unique_ptr HloInstruction::CreateAllToAll( + const Shape& shape, tensorflow::gtl::ArraySlice operands, + const std::vector& replica_groups, + tensorflow::StringPiece barrier) { + return MakeUnique(shape, operands, replica_groups, + barrier); +} + /* static */ std::unique_ptr HloInstruction::CreateInfeed( const Shape& infeed_shape, HloInstruction* token_operand, const string& config) { @@ -1153,6 +1170,7 @@ std::unique_ptr HloInstruction::CloneWithNewOperands( case HloOpcode::kGetTupleElement: case HloOpcode::kReducePrecision: case HloOpcode::kCrossReplicaSum: + case HloOpcode::kAllToAll: case HloOpcode::kInfeed: case HloOpcode::kOutfeed: case HloOpcode::kConvolution: @@ -1620,6 +1638,7 @@ bool HloInstruction::IdenticalSlowPath( case HloOpcode::kInfeed: case HloOpcode::kOutfeed: case HloOpcode::kCrossReplicaSum: + case HloOpcode::kAllToAll: case HloOpcode::kConvolution: case HloOpcode::kCustomCall: case HloOpcode::kReduceWindow: @@ -2265,6 +2284,8 @@ Status HloInstruction::Visit(DfsHloVisitorBase* visitor) { return visitor->HandleFft(this); case HloOpcode::kCrossReplicaSum: return visitor->HandleCrossReplicaSum(this); + case HloOpcode::kAllToAll: + return visitor->HandleAllToAll(this); case HloOpcode::kTuple: return visitor->HandleTuple(this); case HloOpcode::kMap: @@ -3139,12 +3160,23 @@ const std::vector& HloInstruction::replica_group_ids() const { return Cast(this)->replica_group_ids(); } +const std::vector& HloInstruction::replica_groups() const { + return Cast(this)->replica_groups(); +} + string HloInstruction::cross_replica_sum_barrier() const { - return Cast(this)->cross_replica_sum_barrier(); + if (opcode() == HloOpcode::kCrossReplicaSum) { + return Cast(this)->cross_replica_sum_barrier(); + } + return Cast(this)->cross_replica_sum_barrier(); } void HloInstruction::set_cross_replica_sum_barrier(const string& barrier) { - return Cast(this)->set_cross_replica_sum_barrier( + if (opcode() == HloOpcode::kCrossReplicaSum) { + return Cast(this)->set_cross_replica_sum_barrier( + barrier); + } + return Cast(this)->set_cross_replica_sum_barrier( barrier); } diff --git a/tensorflow/compiler/xla/service/hlo_instruction.h b/tensorflow/compiler/xla/service/hlo_instruction.h index e722086732..3c575ae6ea 100644 --- a/tensorflow/compiler/xla/service/hlo_instruction.h +++ b/tensorflow/compiler/xla/service/hlo_instruction.h @@ -449,6 +449,26 @@ class HloInstruction { tensorflow::StringPiece barrier, const tensorflow::gtl::optional& all_reduce_id); + // This op handles the communication of an Alltoall operation. On each core, + // the operands are N ops in the same shape, where N is the number of cores + // participating the Alltoall. Then the N operands are scattered to N cores, + // e.g., the ith operand is sent to the ith core. Then each core gathers the + // received data into a tuple. + // + // - `replica_groups`: each ReplicaGroup contains a list of replica id. If + // empty, all replicas belong to one group in the order of 0 - (n-1). Alltoall + // will be applied within subgroups in the specified order. For example, + // replica groups = {{1,2,3},{4,5,0}} means, an Alltoall will be applied + // within replica 1, 2, 3, and in the gather phase, the received blocks will + // be concatenated in the order of 1, 2, 3; another Alltoall will be applied + // within replica 4, 5, 0, and the concatenation order is 4, 5, 0. + // + // TODO(b/110096724): This is NOT YET ready to use. + static std::unique_ptr CreateAllToAll( + const Shape& shape, tensorflow::gtl::ArraySlice operands, + const std::vector& replica_groups, + tensorflow::StringPiece barrier); + // Creates a conversion instruction, where operand is the data to convert and // shape is the target shape for the conversion. static std::unique_ptr CreateConvert(const Shape& shape, @@ -1414,6 +1434,9 @@ class HloInstruction { // Delegates to HloAllReduceInstruction::replica_group_ids. const std::vector& replica_group_ids() const; + // Delegates to HloAllToAllInstruction::replica_groups. + const std::vector& replica_groups() const; + // Delegates to HloAllReduceInstruction::cross_replica_sum_barrier. string cross_replica_sum_barrier() const; void set_cross_replica_sum_barrier(const string& barrier); diff --git a/tensorflow/compiler/xla/service/hlo_instructions.cc b/tensorflow/compiler/xla/service/hlo_instructions.cc index 1d71a74c40..1de5032670 100644 --- a/tensorflow/compiler/xla/service/hlo_instructions.cc +++ b/tensorflow/compiler/xla/service/hlo_instructions.cc @@ -359,6 +359,67 @@ HloAllReduceInstruction::CloneWithNewOperandsImpl( cross_replica_sum_barrier(), all_reduce_id()); } +HloAllToAllInstruction::HloAllToAllInstruction( + const Shape& shape, tensorflow::gtl::ArraySlice operands, + const std::vector& replica_groups, + tensorflow::StringPiece barrier) + : HloInstruction(HloOpcode::kAllToAll, shape), + replica_groups_(replica_groups), + cross_replica_sum_barrier_(barrier.begin(), barrier.end()) { + for (auto operand : operands) { + AppendOperand(operand); + } +} + +bool HloAllToAllInstruction::IdenticalSlowPath( + const HloInstruction& other, + const std::function& + eq_computations) const { + const auto& casted_other = static_cast(other); + return ContainersEqual(replica_groups(), casted_other.replica_groups(), + [](const ReplicaGroup& a, const ReplicaGroup& b) { + return ContainersEqual(a.replica_ids(), + b.replica_ids()); + }) && + cross_replica_sum_barrier() == + casted_other.cross_replica_sum_barrier(); +} + +std::unique_ptr +HloAllToAllInstruction::CloneWithNewOperandsImpl( + const Shape& shape, + tensorflow::gtl::ArraySlice new_operands, + HloCloneContext* /*context*/) const { + return MakeUnique( + shape, new_operands, replica_groups(), cross_replica_sum_barrier()); +} + +std::vector HloAllToAllInstruction::ExtraAttributesToStringImpl( + const HloPrintOptions& options) const { + std::vector result; + std::vector replica_group_str; + for (const ReplicaGroup& group : replica_groups()) { + replica_group_str.push_back( + StrCat("{", Join(group.replica_ids(), ","), "}")); + } + result.push_back( + StrCat("replica_groups={", Join(replica_group_str, ","), "}")); + + if (!cross_replica_sum_barrier().empty()) { + result.push_back(StrCat("barrier=\"", cross_replica_sum_barrier(), "\"")); + } + + return result; +} + +HloInstructionProto HloAllToAllInstruction::ToProto() const { + HloInstructionProto proto = HloInstruction::ToProto(); + *proto.mutable_replica_groups() = {replica_groups_.begin(), + replica_groups_.end()}; + proto.set_cross_replica_sum_barrier(cross_replica_sum_barrier_); + return proto; +} + HloReverseInstruction::HloReverseInstruction( const Shape& shape, HloInstruction* operand, tensorflow::gtl::ArraySlice dimensions) diff --git a/tensorflow/compiler/xla/service/hlo_instructions.h b/tensorflow/compiler/xla/service/hlo_instructions.h index 9250b2b846..9586ad6673 100644 --- a/tensorflow/compiler/xla/service/hlo_instructions.h +++ b/tensorflow/compiler/xla/service/hlo_instructions.h @@ -273,6 +273,47 @@ class HloAllReduceInstruction : public HloInstruction { tensorflow::gtl::optional all_reduce_id_; }; +class HloAllToAllInstruction : public HloInstruction { + public: + explicit HloAllToAllInstruction( + const Shape& shape, tensorflow::gtl::ArraySlice operand, + const std::vector& replica_groups, + tensorflow::StringPiece barrier); + + const std::vector& replica_groups() const { + return replica_groups_; + } + + // TODO(b/110096724): rename this. + void set_cross_replica_sum_barrier(string barrier) { + cross_replica_sum_barrier_ = barrier; + } + string cross_replica_sum_barrier() const { + return cross_replica_sum_barrier_; + } + + HloInstructionProto ToProto() const override; + + private: + std::vector ExtraAttributesToStringImpl( + const HloPrintOptions& options) const override; + bool IdenticalSlowPath( + const HloInstruction& other, + const std::function& + eq_computations) const override; + + // Implementation for non-common logic of CloneWithNewOperands. + std::unique_ptr CloneWithNewOperandsImpl( + const Shape& shape, + tensorflow::gtl::ArraySlice new_operands, + HloCloneContext* context) const override; + + std::vector replica_groups_; + + // The string representation of the barrier config. + string cross_replica_sum_barrier_; +}; + class HloReverseInstruction : public HloInstruction { public: explicit HloReverseInstruction(const Shape& shape, HloInstruction* operand, diff --git a/tensorflow/compiler/xla/service/hlo_opcode.h b/tensorflow/compiler/xla/service/hlo_opcode.h index 88531b6f20..ec279867e5 100644 --- a/tensorflow/compiler/xla/service/hlo_opcode.h +++ b/tensorflow/compiler/xla/service/hlo_opcode.h @@ -47,6 +47,7 @@ namespace xla { #define HLO_OPCODE_LIST(V) \ V(kAbs, "abs") \ V(kAdd, "add") \ + V(kAllToAll, "all-to-all") \ V(kAtan2, "atan2") \ V(kBatchNormGrad, "batch-norm-grad") \ V(kBatchNormInference, "batch-norm-inference") \ diff --git a/tensorflow/compiler/xla/service/hlo_parser.cc b/tensorflow/compiler/xla/service/hlo_parser.cc index de73b38dec..2a8c6ecd92 100644 --- a/tensorflow/compiler/xla/service/hlo_parser.cc +++ b/tensorflow/compiler/xla/service/hlo_parser.cc @@ -125,6 +125,7 @@ class HloParser { kFloat, kString, kBracedInt64List, + kBracedInt64ListList, kHloComputation, kFftType, kWindow, @@ -205,6 +206,10 @@ class HloParser { bool ParseInt64List(const TokKind start, const TokKind end, const TokKind delim, std::vector* result); + // 'parse_and_add_item' is an lambda to parse an element in the list and add + // the parsed element to the result. It's supposed to capture the result. + bool ParseList(const TokKind start, const TokKind end, const TokKind delim, + const std::function& parse_and_add_item); bool ParseParamListToShape(Shape* shape, LocTy* shape_loc); bool ParseParamList(); @@ -619,6 +624,28 @@ bool HloParser::ParseInstruction(HloComputation::Builder* builder, } break; } + case HloOpcode::kAllToAll: { + optional>> tmp_groups; + optional barrier; + attrs["replica_groups"] = {/*required=*/false, + AttrTy::kBracedInt64ListList, &tmp_groups}; + attrs["barrier"] = {/*required=*/false, AttrTy::kString, &barrier}; + if (!ParseOperands(&operands) || !ParseAttributes(attrs)) { + return false; + } + std::vector replica_groups; + if (tmp_groups) { + c_transform(*tmp_groups, std::back_inserter(replica_groups), + [](const std::vector& ids) { + ReplicaGroup group; + *group.mutable_replica_ids() = {ids.begin(), ids.end()}; + return group; + }); + } + instruction = builder->AddInstruction(HloInstruction::CreateAllToAll( + shape, operands, replica_groups, barrier ? *barrier : "")); + break; + } case HloOpcode::kReshape: { if (!ParseOperands(&operands, /*expected_size=*/1) || !ParseAttributes(attrs)) { @@ -2244,6 +2271,26 @@ bool HloParser::ParseAttributeHelper( ->emplace(result); return true; } + case AttrTy::kBracedInt64ListList: { + std::vector> result; + auto parse_and_add_item = [&]() { + std::vector item; + if (!ParseInt64List(TokKind::kLbrace, TokKind::kRbrace, + TokKind::kComma, &item)) { + return false; + } + result.push_back(item); + return true; + }; + if (!ParseList(TokKind::kLbrace, TokKind::kRbrace, TokKind::kComma, + parse_and_add_item)) { + return false; + } + static_cast>>*>( + attr_out_ptr) + ->emplace(result); + return true; + } case AttrTy::kSliceRanges: { SliceRanges result; if (!ParseSliceRanges(&result)) { @@ -2586,6 +2633,26 @@ bool HloParser::ParseInt64List(const TokKind start, const TokKind end, end, StrCat("expects an int64 list to end with ", TokKindToString(end))); } +bool HloParser::ParseList(const TokKind start, const TokKind end, + const TokKind delim, + const std::function& parse_and_add_item) { + if (!ParseToken(start, StrCat("expects a list starting with ", + TokKindToString(start)))) { + return false; + } + if (lexer_.GetKind() == end) { + // empty + } else { + do { + if (!parse_and_add_item()) { + return false; + } + } while (EatIfPresent(delim)); + } + return ParseToken( + end, StrCat("expects a list to end with ", TokKindToString(end))); +} + // param_list_to_shape ::= param_list '->' shape bool HloParser::ParseParamListToShape(Shape* shape, LocTy* shape_loc) { if (!ParseParamList() || !ParseToken(TokKind::kArrow, "expects '->'")) { diff --git a/tensorflow/compiler/xla/service/hlo_parser_test.cc b/tensorflow/compiler/xla/service/hlo_parser_test.cc index 7344679bb6..4cd21841f4 100644 --- a/tensorflow/compiler/xla/service/hlo_parser_test.cc +++ b/tensorflow/compiler/xla/service/hlo_parser_test.cc @@ -1070,6 +1070,30 @@ ENTRY CrossReplicaSumWithSubgroups { ROOT cross-replica-sum = f32[128,32]{0,1} cross-replica-sum(input), replica_group_ids={0,0,1,1}, barrier="abc", to_apply=add } +)" +}, +// all-to-all +{ +"AllToAll", +R"(HloModule AllToAll + +ENTRY AllToAll { + input = f32[128,32]{0,1} parameter(0) + ROOT a2a = f32[128,32]{0,1} all-to-all(input), replica_groups={} +} + +)" +}, +// all-to-all with subgroups +{ +"AllToAllWithSubgroups", +R"(HloModule AllToAllWithSubgroups + +ENTRY AllToAllWithSubgroups { + input = f32[128,32]{0,1} parameter(0) + ROOT a2a = f32[128,32]{0,1} all-to-all(input), replica_groups={{1,2},{3,0}}, barrier="abc" +} + )" }, // Iota diff --git a/tensorflow/compiler/xla/service/hlo_verifier.cc b/tensorflow/compiler/xla/service/hlo_verifier.cc index 1a8c206aaf..3fae61f704 100644 --- a/tensorflow/compiler/xla/service/hlo_verifier.cc +++ b/tensorflow/compiler/xla/service/hlo_verifier.cc @@ -105,6 +105,15 @@ Status ShapeVerifier::HandleCrossReplicaSum(HloInstruction* crs) { ShapeInference::InferCrossReplicaSumShape(operand_shapes)); } +Status ShapeVerifier::HandleAllToAll(HloInstruction* hlo) { + std::vector operand_shapes; + for (const HloInstruction* operand : hlo->operands()) { + operand_shapes.push_back(&operand->shape()); + } + return CheckShape(hlo, + ShapeInference::InferAllToAllTupleShape(operand_shapes)); +} + Status ShapeVerifier::HandleReducePrecision(HloInstruction* reduce_precision) { return CheckShape(reduce_precision, ShapeInference::InferReducePrecisionShape( reduce_precision->operand(0)->shape(), diff --git a/tensorflow/compiler/xla/service/hlo_verifier.h b/tensorflow/compiler/xla/service/hlo_verifier.h index 7feddaeabf..5a56a44f35 100644 --- a/tensorflow/compiler/xla/service/hlo_verifier.h +++ b/tensorflow/compiler/xla/service/hlo_verifier.h @@ -45,6 +45,7 @@ class ShapeVerifier : public DfsHloVisitor { Status HandleConvolution(HloInstruction* convolution) override; Status HandleFft(HloInstruction* fft) override; Status HandleCrossReplicaSum(HloInstruction* crs) override; + Status HandleAllToAll(HloInstruction* hlo) override; Status HandleReducePrecision(HloInstruction* reduce_precision) override; Status HandleInfeed(HloInstruction*) override; Status HandleOutfeed(HloInstruction*) override; diff --git a/tensorflow/compiler/xla/service/instruction_fusion.cc b/tensorflow/compiler/xla/service/instruction_fusion.cc index e2191aedb7..f33942d679 100644 --- a/tensorflow/compiler/xla/service/instruction_fusion.cc +++ b/tensorflow/compiler/xla/service/instruction_fusion.cc @@ -120,6 +120,7 @@ bool IsAlwaysDuplicable(const HloInstruction& instruction) { case HloOpcode::kConditional: case HloOpcode::kConvolution: case HloOpcode::kCrossReplicaSum: + case HloOpcode::kAllToAll: case HloOpcode::kCustomCall: case HloOpcode::kDivide: case HloOpcode::kDomain: diff --git a/tensorflow/compiler/xla/service/shape_inference.cc b/tensorflow/compiler/xla/service/shape_inference.cc index c888bbf144..a4ea2b28f4 100644 --- a/tensorflow/compiler/xla/service/shape_inference.cc +++ b/tensorflow/compiler/xla/service/shape_inference.cc @@ -1779,6 +1779,51 @@ ShapeInference::InferDegenerateDimensionBroadcastShape(HloOpcode operation, return ShapeUtil::MakeTupleShape(operand_shape_values); } +/* static */ StatusOr ShapeInference::InferAllToAllShape( + const Shape& shape, int64 split_dimension, int64 concat_dimension, + int64 split_count) { + TF_RET_CHECK(split_count > 0); + if (split_dimension >= ShapeUtil::Rank(shape) || split_dimension < 0) { + return InvalidArgument( + "AllToAll split_dimension %lld is out-of-bounds in shape %s.", + split_dimension, ShapeUtil::HumanString(shape).c_str()); + } + if (concat_dimension >= ShapeUtil::Rank(shape) || concat_dimension < 0) { + return InvalidArgument( + "AllToAll concat_dimension %lld is out-of-bounds in shape %s.", + concat_dimension, ShapeUtil::HumanString(shape).c_str()); + } + if (shape.dimensions(split_dimension) % split_count != 0) { + return InvalidArgument( + "AllToAll split dimension size %lld must be dividable by split_count " + "%lld.", + shape.dimensions(split_dimension), split_count); + } + std::vector new_dimensions(shape.dimensions().begin(), + shape.dimensions().end()); + new_dimensions[split_dimension] /= split_count; + new_dimensions[concat_dimension] *= split_count; + return ShapeUtil::MakeShape(shape.element_type(), new_dimensions); +} + +/* static */ StatusOr ShapeInference::InferAllToAllTupleShape( + tensorflow::gtl::ArraySlice operand_shapes) { + // An Alltoall HLO instruction receives N operands (with the same shape) and + // returns a tuple that contains N array shapes. + TF_RET_CHECK(!operand_shapes.empty()); + for (int i = 0; i < operand_shapes.size(); i++) { + if (!ShapeUtil::Equal(*operand_shapes[0], *operand_shapes[i])) { + return InvalidArgument( + "HLO all-to-all has operands with different shapes: the 0th " + "operand shape %s, but the %dth operand has shape %s.", + ShapeUtil::HumanString(*operand_shapes[0]).c_str(), i, + ShapeUtil::HumanString(*operand_shapes[i]).c_str()); + } + } + + return InferVariadicOpShape(HloOpcode::kTuple, operand_shapes); +} + /* static */ StatusOr ShapeInference::InferReduceShape( tensorflow::gtl::ArraySlice arg_shapes, tensorflow::gtl::ArraySlice dimensions_to_reduce, diff --git a/tensorflow/compiler/xla/service/shape_inference.h b/tensorflow/compiler/xla/service/shape_inference.h index 33da323b3d..c185b0a1bd 100644 --- a/tensorflow/compiler/xla/service/shape_inference.h +++ b/tensorflow/compiler/xla/service/shape_inference.h @@ -119,11 +119,22 @@ class ShapeInference { const Shape& in, FftType fft_type, tensorflow::gtl::ArraySlice fft_length); - // Infers the shape produced a cross replica sum with the given operand + // Infers the shape produced by a cross replica sum with the given operand // shapes. static StatusOr InferCrossReplicaSumShape( tensorflow::gtl::ArraySlice operand_shapes); + // Infers final shape of an Alltoall operation that is created by the xla + // builder. + static StatusOr InferAllToAllShape(const Shape& shape, + int64 split_dimension, + int64 concat_dimension, + int64 split_count); + + // Infers the shape of an HLO all-to-all instruction. + static StatusOr InferAllToAllTupleShape( + tensorflow::gtl::ArraySlice operand_shapes); + // Infers the shape produced by applying the given reduction computation // shape to the given input operand shape. // diff --git a/tensorflow/compiler/xla/xla_data.proto b/tensorflow/compiler/xla/xla_data.proto index fd784e909c..4c35e93d38 100644 --- a/tensorflow/compiler/xla/xla_data.proto +++ b/tensorflow/compiler/xla/xla_data.proto @@ -561,3 +561,11 @@ message OpSharding { // to. repeated OpSharding tuple_shardings = 5; } + +// Describes the replica groups in a cross replica op (e.g., all-reduce and +// all-to-all). +message ReplicaGroup { + // The ids of the replicas that belongs to the same group. The ordering of the + // ids matters in some op (e.g., all-to-all). + repeated int64 replica_ids = 1; +} diff --git a/tensorflow/docs_src/performance/xla/operation_semantics.md b/tensorflow/docs_src/performance/xla/operation_semantics.md index 165f6f5914..02af71f8a3 100644 --- a/tensorflow/docs_src/performance/xla/operation_semantics.md +++ b/tensorflow/docs_src/performance/xla/operation_semantics.md @@ -13,6 +13,79 @@ arbitrary-dimensional array. For convenience, special cases have more specific and familiar names; for example a *vector* is a 1-dimensional array and a *matrix* is a 2-dimensional array. +## AllToAll + +See also +[`XlaBuilder::AllToAll`](https://www.tensorflow.org/code/tensorflow/compiler/xla/client/xla_builder.h). + +Alltoall is a collective operation that sends data from all cores to all cores. +It has two phases: + +1. the scatter phase. On each core, the operand is split into `split_count` + number of blocks along the `split_dimensions`, and the blocks are scatterd + to all cores, e.g., the ith block is send to the ith core. +2. the gather phase. Each core concatenates the received blocks along the + `concat_dimension`. + +The participating cores can be configured by: + +- `replica_groups`: each ReplicaGroup contains a list of replica id. If empty, + all replicas belong to one group in the order of 0 - (n-1). Alltoall will be + applied within subgroups in the specified order. For example, replica + groups = {{1,2,3},{4,5,0}} means, an Alltoall will be applied within replica + 1, 2, 3, and in the gather phase, the received blocks will be concatenated + in the order of 1, 2, 3; another Alltoall will be applied within replica 4, + 5, 0, and the concatenation order is 4, 5, 0. + +Prerequisites: + +- The dimension size of the operand on the split_dimension is divisible by + split_count. +- The operand's shape is not tuple. + + `AllToAll(operand, split_dimension, concat_dimension, split_count, +replica_groups)` + + +| Arguments | Type | Semantics | +| ------------------ | --------------------- | ------------------------------- | +| `operand` | `XlaOp` | n dimensional input array | +| `split_dimension` | `int64` | A value in the interval `[0, | +: : : n)` that names the dimension : +: : : along which the operand is : +: : : split : +| `concat_dimension` | `int64` | a value in the interval `[0, | +: : : n)` that names the dimension : +: : : along which the split blocks : +: : : are concatenated : +| `split_count` | `int64` | the number of cores that | +: : : participate this operation. If : +: : : `replica_groups` is empty, this : +: : : should be the number of : +: : : replicas; otherwise, this : +: : : should be equal to the number : +: : : of replicas in each group. : +| `replica_groups` | `ReplicaGroup` vector | each group contains a list of | +: : : replica id. : + +Below shows an example of Alltoall. + +``` +XlaBuilder b("alltoall"); +auto x = Parameter(&b, 0, ShapeUtil::MakeShape(F32, {4, 16}), "x"); +AllToAll(x, /*split_dimension=*/1, /*concat_dimension=*/0, /*split_count=*/4); +``` + +
+ +
+ +In this example, there are 4 cores participating the Alltoall. On each core, the +operand is split into 4 parts along dimension 0, so each part has shape +f32[4,4]. The 4 parts are scattered to all cores. Then each core concatenates +the received parts along dimension 1, in the order or core 0-4. So the output on +each core has shape f32[16,4]. + ## BatchNormGrad See also -- GitLab From 3325275eff98ffddb52a16db932481983a9de9a8 Mon Sep 17 00:00:00 2001 From: Akshay Modi Date: Wed, 8 Aug 2018 17:11:32 -0700 Subject: [PATCH 234/437] Support keep alive so we can reclaim memory in the remote case. PiperOrigin-RevId: 207971672 --- tensorflow/c/eager/c_api.cc | 21 +++--- tensorflow/c/eager/c_api.h | 1 + tensorflow/c/eager/c_api_test.cc | 8 +-- .../core/common_runtime/eager/context.cc | 59 +++++++++++++++- .../core/common_runtime/eager/context.h | 14 +++- .../eager/eager_service_impl.cc | 17 +++-- .../eager/eager_service_impl.h | 68 ++++++++++++++++++- .../eager/eager_service_impl_test.cc | 41 +++++++++++ tensorflow/python/eager/context.py | 11 ++- 9 files changed, 214 insertions(+), 26 deletions(-) diff --git a/tensorflow/c/eager/c_api.cc b/tensorflow/c/eager/c_api.cc index d7073d8e05..dfb1c9a376 100644 --- a/tensorflow/c/eager/c_api.cc +++ b/tensorflow/c/eager/c_api.cc @@ -110,7 +110,7 @@ tensorflow::Status GetAllRemoteDevices( tensorflow::Status CreateRemoteContexts( const std::vector& remote_workers, int64 rendezvous_id, - const tensorflow::ServerDef& server_def, + int keep_alive_secs, const tensorflow::ServerDef& server_def, tensorflow::eager::EagerClientCache* remote_eager_workers, bool async, tensorflow::gtl::FlatMap* remote_contexts) { for (int i = 0; i < remote_workers.size(); i++) { @@ -129,6 +129,7 @@ tensorflow::Status CreateRemoteContexts( request.mutable_server_def()->set_job_name(parsed_name.job); request.mutable_server_def()->set_task_index(parsed_name.task); request.set_async(async); + request.set_keep_alive_secs(keep_alive_secs); auto* eager_client = remote_eager_workers->GetClient(remote_worker); if (eager_client == nullptr) { return tensorflow::errors::Internal( @@ -151,7 +152,8 @@ tensorflow::Status CreateRemoteContexts( } tensorflow::Status UpdateTFE_ContextWithServerDef( - const tensorflow::ServerDef& server_def, TFE_Context* ctx) { + int keep_alive_secs, const tensorflow::ServerDef& server_def, + TFE_Context* ctx) { // We don't use the TF_RETURN_IF_ERROR macro directly since that destroys the // server object (which currently CHECK-fails) and we miss the error, instead, // we log the error, and then return to allow the user to see the error @@ -202,8 +204,8 @@ tensorflow::Status UpdateTFE_ContextWithServerDef( // Initialize remote eager workers. tensorflow::gtl::FlatMap remote_contexts; LOG_AND_RETURN_IF_ERROR(CreateRemoteContexts( - remote_workers, rendezvous_id, server_def, remote_eager_workers.get(), - ctx->context.Async(), &remote_contexts)); + remote_workers, rendezvous_id, keep_alive_secs, server_def, + remote_eager_workers.get(), ctx->context.Async(), &remote_contexts)); tensorflow::RemoteRendezvous* r = grpc_server->worker_env()->rendezvous_mgr->Find(rendezvous_id); @@ -222,9 +224,10 @@ tensorflow::Status UpdateTFE_ContextWithServerDef( auto* device_mgr = grpc_server->worker_env()->device_mgr; - ctx->context.InitializeRemote( - std::move(server), std::move(remote_eager_workers), - std::move(remote_device_mgr), remote_contexts, r, device_mgr); + ctx->context.InitializeRemote(std::move(server), + std::move(remote_eager_workers), + std::move(remote_device_mgr), remote_contexts, + r, device_mgr, keep_alive_secs); return tensorflow::Status::OK(); #undef LOG_AND_RETURN_IF_ERROR @@ -288,6 +291,7 @@ void TFE_ContextClearCaches(TFE_Context* ctx) { ctx->context.ClearCaches(); } // Set server_def on the context, possibly updating it. TF_CAPI_EXPORT extern void TFE_ContextSetServerDef(TFE_Context* ctx, + int keep_alive_secs, const void* proto, size_t proto_len, TF_Status* status) { @@ -297,7 +301,8 @@ TF_CAPI_EXPORT extern void TFE_ContextSetServerDef(TFE_Context* ctx, "Invalid tensorflow.ServerDef protocol buffer"); return; } - status->status = UpdateTFE_ContextWithServerDef(server_def, ctx); + status->status = + UpdateTFE_ContextWithServerDef(keep_alive_secs, server_def, ctx); } void TFE_ContextSetThreadLocalDevicePlacementPolicy( diff --git a/tensorflow/c/eager/c_api.h b/tensorflow/c/eager/c_api.h index 092af45731..a0ebc6fa0a 100644 --- a/tensorflow/c/eager/c_api.h +++ b/tensorflow/c/eager/c_api.h @@ -124,6 +124,7 @@ TF_CAPI_EXPORT extern void TFE_ContextSetAsyncForThread(TFE_Context*, // If the following is set, all servers identified by the // ServerDef must be up when the context is created. TF_CAPI_EXPORT extern void TFE_ContextSetServerDef(TFE_Context* ctx, + int keep_alive_secs, const void* proto, size_t proto_len, TF_Status* status); diff --git a/tensorflow/c/eager/c_api_test.cc b/tensorflow/c/eager/c_api_test.cc index 00a0a71fca..71d5f3613c 100644 --- a/tensorflow/c/eager/c_api_test.cc +++ b/tensorflow/c/eager/c_api_test.cc @@ -151,7 +151,7 @@ void TestRemoteExecute(bool async) { EXPECT_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status); TFE_DeleteContextOptions(opts); - TFE_ContextSetServerDef(ctx, serialized.data(), serialized.size(), status); + TFE_ContextSetServerDef(ctx, 0, serialized.data(), serialized.size(), status); EXPECT_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status); TFE_TensorHandle* h0_task0 = TestMatrixTensorHandle(); @@ -239,7 +239,7 @@ void TestRemoteExecuteSilentCopies(bool async) { EXPECT_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status); TFE_DeleteContextOptions(opts); - TFE_ContextSetServerDef(ctx, serialized.data(), serialized.size(), status); + TFE_ContextSetServerDef(ctx, 0, serialized.data(), serialized.size(), status); EXPECT_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status); TFE_TensorHandle* h0_task0 = TestMatrixTensorHandle(); @@ -371,7 +371,7 @@ void TestRemoteExecuteChangeServerDef(bool async) { EXPECT_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status); TFE_DeleteContextOptions(opts); - TFE_ContextSetServerDef(ctx, serialized.data(), serialized.size(), status); + TFE_ContextSetServerDef(ctx, 0, serialized.data(), serialized.size(), status); EXPECT_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status); const char remote_device_name[] = @@ -397,7 +397,7 @@ void TestRemoteExecuteChangeServerDef(bool async) { ASSERT_TRUE(s.ok()) << s.error_message(); ASSERT_TRUE(worker_server->Start().ok()); - TFE_ContextSetServerDef(ctx, serialized.data(), serialized.size(), status); + TFE_ContextSetServerDef(ctx, 0, serialized.data(), serialized.size(), status); EXPECT_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status); // Create a new tensor_handle. diff --git a/tensorflow/core/common_runtime/eager/context.cc b/tensorflow/core/common_runtime/eager/context.cc index e5fe87fc37..5bdd547c7f 100644 --- a/tensorflow/core/common_runtime/eager/context.cc +++ b/tensorflow/core/common_runtime/eager/context.cc @@ -163,6 +163,13 @@ EagerContext::~EagerContext() { server_.release(); } + { + mutex_lock l(keep_alive_thread_shutdown_mu_); + shutting_down_ = true; + keep_alive_thread_cv_.notify_all(); + } + keep_alive_thread_.reset(); + CloseRemoteContexts(); #endif @@ -334,7 +341,9 @@ void EagerContext::InitializeRemote( std::unique_ptr remote_eager_workers, std::unique_ptr remote_device_manager, const gtl::FlatMap& remote_contexts, Rendezvous* r, - DeviceMgr* local_device_mgr) { + DeviceMgr* local_device_mgr, int keep_alive_secs) { + mutex_lock l(remote_state_mu_); + if (!remote_contexts_.empty()) { CloseRemoteContexts(); } @@ -376,6 +385,54 @@ void EagerContext::InitializeRemote( InitDeviceMapAndAsync(); ClearCaches(); + + keep_alive_secs_ = keep_alive_secs; + + sleep_for_secs_ = std::max(1, keep_alive_secs_ / 2); + + // Only schedule a single closure. + if (keep_alive_thread_ == nullptr) { + keep_alive_thread_.reset( + env_->StartThread({}, "EagerKeepAliveThread", [this]() { + while (true) { + { + { + mutex_lock l(keep_alive_thread_shutdown_mu_); + keep_alive_thread_cv_.wait_for( + l, std::chrono::seconds(sleep_for_secs_)); + + if (shutting_down_) { + return; + } + } + { + mutex_lock l(remote_state_mu_); + if (keep_alive_secs_ > 0) { + { + for (const auto& worker_and_context_id : remote_contexts_) { + auto* client = remote_eager_workers_->GetClient( + worker_and_context_id.first); + + eager::KeepAliveRequest* request = + new eager::KeepAliveRequest; + eager::KeepAliveResponse* response = + new eager::KeepAliveResponse; + + request->set_context_id(worker_and_context_id.second); + client->KeepAliveAsync( + request, response, + [request, response](const Status& s) { + delete request; + delete response; + }); + } + } + } + } + } + } + })); + } } #endif diff --git a/tensorflow/core/common_runtime/eager/context.h b/tensorflow/core/common_runtime/eager/context.h index 3eea56b5e3..ebaf500bb3 100644 --- a/tensorflow/core/common_runtime/eager/context.h +++ b/tensorflow/core/common_runtime/eager/context.h @@ -180,7 +180,7 @@ class EagerContext { std::unique_ptr remote_eager_workers, std::unique_ptr remote_device_manager, const gtl::FlatMap& remote_contexts, Rendezvous* r, - DeviceMgr* local_device_mgr); + DeviceMgr* local_device_mgr, int keep_alive_secs); bool HasActiveRemoteContext(uint64 context_id) { return active_remote_contexts_.find(context_id) != @@ -190,7 +190,7 @@ class EagerContext { // If true, then tensors should be shipped across processes via the // EagerService.SendTensor RPC. If false, _Send/_Recv ops should be used - // instead (which in-turn use WorkerService.RecvTensor RPCs. + // instead (which in-turn use WorkerService.RecvTensor RPCs). bool UseSendTensorRPC() { return use_send_tensor_rpc_; } private: @@ -263,10 +263,20 @@ class EagerContext { std::unique_ptr server_; std::unique_ptr remote_eager_workers_; + mutex remote_state_mu_; + gtl::FlatMap remote_contexts_; gtl::FlatSet active_remote_contexts_; gtl::FlatMap> device_to_client_cache_; + + int keep_alive_secs_ GUARDED_BY(remote_state_mu_); + std::atomic sleep_for_secs_; + + std::unique_ptr keep_alive_thread_; + mutex keep_alive_thread_shutdown_mu_; + condition_variable keep_alive_thread_cv_; + bool shutting_down_ GUARDED_BY(keep_alive_thread_shutdown_mu_) = false; #endif bool use_send_tensor_rpc_; diff --git a/tensorflow/core/distributed_runtime/eager/eager_service_impl.cc b/tensorflow/core/distributed_runtime/eager/eager_service_impl.cc index 916c8720f0..b8af63724a 100644 --- a/tensorflow/core/distributed_runtime/eager/eager_service_impl.cc +++ b/tensorflow/core/distributed_runtime/eager/eager_service_impl.cc @@ -126,7 +126,9 @@ Status EagerServiceImpl::CreateContext(const CreateContextRequest* request, do { context_id = random::New64(); } while (contexts_.find(context_id) != contexts_.end()); - contexts_.emplace(context_id, new ServerContext(std::move(ctx))); + contexts_.emplace( + context_id, + new ServerContext(std::move(ctx), request->keep_alive_secs(), env_)); } response->set_context_id(context_id); @@ -231,9 +233,11 @@ Status EagerServiceImpl::WaitQueueDone(const WaitQueueDoneRequest* request, Status EagerServiceImpl::KeepAlive(const KeepAliveRequest* request, KeepAliveResponse* response) { - // TODO(nareshmodi): Automated context_id cleaning is not implemented - return errors::Unimplemented( - "EagerServiceImpl::KeepAlive is not implemented."); + ServerContext* context = nullptr; + TF_RETURN_IF_ERROR(GetServerContext(request->context_id(), &context)); + core::ScopedUnref context_unref(context); + + return Status::OK(); } Status EagerServiceImpl::CloseContext(const CloseContextRequest* request, @@ -304,12 +308,15 @@ tensorflow::Status EagerServiceImpl::GetServerContext( *server_context = nullptr; return errors::InvalidArgument(strings::Printf( "Unable to find a context_id matching the specified one " - "(%lld). Perhaps the worker was restarted?", + "(%lld). Perhaps the worker was restarted, or the context was GC'd?", context_id)); } *server_context = iter->second; (*server_context)->Ref(); + + (*server_context)->RecordAccess(); + return Status::OK(); } diff --git a/tensorflow/core/distributed_runtime/eager/eager_service_impl.h b/tensorflow/core/distributed_runtime/eager/eager_service_impl.h index 718b4e2457..5723106aa6 100644 --- a/tensorflow/core/distributed_runtime/eager/eager_service_impl.h +++ b/tensorflow/core/distributed_runtime/eager/eager_service_impl.h @@ -38,8 +38,41 @@ namespace eager { // over this (e.g. gRPC). class EagerServiceImpl { public: - explicit EagerServiceImpl(const WorkerEnv* env) : env_(env) {} + explicit EagerServiceImpl(const WorkerEnv* env) : env_(env) { + gc_thread_.reset( + env_->env->StartThread({}, "EagerServiceContextGC", [this]() { + while (true) { + { + mutex_lock l(gc_thread_shutdown_mu_); + gc_thread_cv_.wait_for(l, std::chrono::seconds(1)); + + if (shutting_down_) { + return; + } + } + { + mutex_lock l(contexts_mu_); + for (auto it = contexts_.begin(); it != contexts_.end();) { + if (it->second->IsStale()) { + it->second->Unref(); + it = contexts_.erase(it); + } else { + it++; + } + } + } + } + })); + } virtual ~EagerServiceImpl() { + { + mutex_lock l(gc_thread_shutdown_mu_); + shutting_down_ = true; + gc_thread_cv_.notify_all(); + } + gc_thread_.reset(); + + mutex_lock l(contexts_mu_); for (auto& entry : contexts_) { entry.second->Unref(); } @@ -71,8 +104,13 @@ class EagerServiceImpl { // and the EagerContext). class ServerContext : public core::RefCounted { public: - explicit ServerContext(std::unique_ptr ctx) - : ctx_(std::move(ctx)) {} + explicit ServerContext(std::unique_ptr ctx, + int64 destroy_after_secs, const WorkerEnv* env) + : ctx_(std::move(ctx)), env_(env) { + destroy_after_micros_ = + destroy_after_secs * tensorflow::EnvTime::kSecondsToMicros; + RecordAccess(); + } ~ServerContext() { for (const auto& entry : tensors_) { entry.second->Unref(); @@ -122,6 +160,18 @@ class EagerServiceImpl { return Status::OK(); } + void RecordAccess() { + mutex_lock l(last_accessed_mu_); + last_accessed_micros_ = env_->env->NowMicros(); + } + + bool IsStale() { + mutex_lock l(last_accessed_mu_); + return (destroy_after_micros_ <= 0 || + (env_->env->NowMicros() - last_accessed_micros_) > + destroy_after_micros_); + } + private: using RemoteTensorHandleMap = gtl::FlatMap ctx_; + // The state related to the context for this execution. mutex tensors_mu_; RemoteTensorHandleMap tensors_ GUARDED_BY(tensors_mu_); + + const WorkerEnv* const env_; // Not owned. + + mutex last_accessed_mu_; + int64 last_accessed_micros_ GUARDED_BY(last_accessed_mu_); + int64 destroy_after_micros_; }; // The returned ServerContext will need to be Unrefed. tensorflow::Status GetServerContext(uint64, ServerContext**); @@ -145,6 +202,11 @@ class EagerServiceImpl { mutex contexts_mu_; std::unordered_map contexts_ GUARDED_BY(contexts_mu_); + std::unique_ptr gc_thread_; + mutex gc_thread_shutdown_mu_; + condition_variable gc_thread_cv_; + bool shutting_down_ GUARDED_BY(gc_thread_shutdown_mu_) = false; + TF_DISALLOW_COPY_AND_ASSIGN(EagerServiceImpl); }; diff --git a/tensorflow/core/distributed_runtime/eager/eager_service_impl_test.cc b/tensorflow/core/distributed_runtime/eager/eager_service_impl_test.cc index d1f2a6da8f..5c9b33b345 100644 --- a/tensorflow/core/distributed_runtime/eager/eager_service_impl_test.cc +++ b/tensorflow/core/distributed_runtime/eager/eager_service_impl_test.cc @@ -365,6 +365,47 @@ TEST_F(EagerServiceImplTest, SendTensorTest) { &close_context_response)); } +TEST_F(EagerServiceImplTest, KeepAliveTest) { + TestEagerServiceImpl eager_service_impl(&worker_env_); + + CreateContextRequest request; + request.mutable_server_def()->set_job_name("localhost"); + request.mutable_server_def()->set_task_index(0); + request.set_rendezvous_id(random::New64()); + request.set_keep_alive_secs(3); + CreateContextResponse response; + + TF_ASSERT_OK(eager_service_impl.CreateContext(&request, &response)); + + worker_env_.env->SleepForMicroseconds(5 * + tensorflow::EnvTime::kSecondsToMicros); + + KeepAliveRequest keep_alive_request; + KeepAliveResponse keep_alive_response; + + keep_alive_request.set_context_id(response.context_id()); + + Status status = + eager_service_impl.KeepAlive(&keep_alive_request, &keep_alive_response); + + EXPECT_EQ(status.code(), error::INVALID_ARGUMENT); + EXPECT_PRED_FORMAT2(::testing::IsSubstring, "Unable to find a context_id", + status.error_message()); + + // Create a new context. + request.set_rendezvous_id(random::New64()); + TF_ASSERT_OK(eager_service_impl.CreateContext(&request, &response)); + + // The context should not be GC'd. + worker_env_.env->SleepForMicroseconds(1 * + tensorflow::EnvTime::kSecondsToMicros); + + keep_alive_request.set_context_id(response.context_id()); + + TF_ASSERT_OK( + eager_service_impl.KeepAlive(&keep_alive_request, &keep_alive_response)); +} + } // namespace } // namespace eager } // namespace tensorflow diff --git a/tensorflow/python/eager/context.py b/tensorflow/python/eager/context.py index 09223c86d4..aa57ca03e6 100644 --- a/tensorflow/python/eager/context.py +++ b/tensorflow/python/eager/context.py @@ -265,7 +265,7 @@ class Context(object): pywrap_tensorflow.TFE_DeleteContextOptions(opts) if self._server_def is not None: server_def_str = self._server_def.SerializeToString() - pywrap_tensorflow.TFE_ContextSetServerDef(self._context_handle, + pywrap_tensorflow.TFE_ContextSetServerDef(self._context_handle, 600, server_def_str) self._initialize_devices() @@ -275,7 +275,7 @@ class Context(object): self.ones_rank_cache().flush() self.zeros_cache().flush() - def set_server_def(self, server_def): + def set_server_def(self, server_def, keep_alive_secs=600): """Allow setting a server_def on the context. When a server def is replaced, it effectively clears a bunch of caches @@ -285,6 +285,11 @@ class Context(object): Args: server_def: A tensorflow::ServerDef proto. Enables execution on remote devices. + keep_alive_secs: Num. seconds after which the remote end will hang up. + As long as the client is still alive, the server state for the context + will be kept alive. If the client is killed (or there is some failure), + the server will clean up its context keep_alive_secs after the final RPC + it receives. Raises: ValueError: if server_def is None. @@ -296,7 +301,7 @@ class Context(object): else: server_def_str = server_def.SerializeToString() pywrap_tensorflow.TFE_ContextSetServerDef(self._context_handle, - server_def_str) + keep_alive_secs, server_def_str) # Clear all the caches in case there are remote tensors in them. self._clear_caches() -- GitLab From 963ef37203c76e0338ede21b469020e425fb9208 Mon Sep 17 00:00:00 2001 From: Kay Zhu Date: Wed, 8 Aug 2018 17:16:53 -0700 Subject: [PATCH 235/437] [TF:XLA] Introduce MutableBorrowingLiteral to enable interacting with a (tensor) buffer not owned by XLA/Literal class directly, without having to memcpy the Literal to a (Host)Tensor. PiperOrigin-RevId: 207972410 --- tensorflow/compiler/jit/xla_device_context.cc | 21 +- tensorflow/compiler/tf2xla/literal_util.cc | 17 ++ tensorflow/compiler/tf2xla/literal_util.h | 10 + .../compiler/xla/client/local_client.cc | 2 +- tensorflow/compiler/xla/literal.cc | 189 ++++++++++++++---- tensorflow/compiler/xla/literal.h | 186 ++++++++++------- tensorflow/compiler/xla/literal_util.cc | 1 + .../xla/service/cpu/cpu_transfer_manager.cc | 32 +-- .../xla/service/cpu/cpu_transfer_manager.h | 3 +- .../xla/service/generic_transfer_manager.cc | 22 +- .../xla/service/generic_transfer_manager.h | 15 +- .../xla/service/gpu/gpu_transfer_manager.cc | 21 +- .../xla/service/gpu/gpu_transfer_manager.h | 2 +- .../xla/service/gpu/outfeed_manager.h | 11 +- .../compiler/xla/service/gpu/outfeed_thunk.cc | 4 - tensorflow/compiler/xla/service/service.cc | 4 +- .../compiler/xla/service/transfer_manager.cc | 50 ++++- .../compiler/xla/service/transfer_manager.h | 24 ++- tensorflow/compiler/xla/tests/tuple_test.cc | 4 +- 19 files changed, 404 insertions(+), 214 deletions(-) diff --git a/tensorflow/compiler/jit/xla_device_context.cc b/tensorflow/compiler/jit/xla_device_context.cc index 8cf198239c..0100bf51ed 100644 --- a/tensorflow/compiler/jit/xla_device_context.cc +++ b/tensorflow/compiler/jit/xla_device_context.cc @@ -101,34 +101,27 @@ Status XlaTransferManager::TransferLiteralToDevice( // Unref the host tensor, and capture the literal shared_ptr too so it goes // out of scope when the lambda completes. host_to_device_stream_->ThenDoHostCallback([ref, literal]() { ref.Unref(); }); + return Status::OK(); } void XlaTransferManager::TransferLiteralFromDevice( Tensor* host_tensor, const Tensor& device_tensor, const StatusCallback& done) const { + xla::MutableBorrowingLiteral literal; + TF_CHECK_OK(HostTensorToMutableBorrowingLiteral(host_tensor, &literal)); + const xla::ShapedBuffer& shaped_buffer = XlaTensor::FromTensor(&device_tensor)->shaped_buffer(); TensorReference ref(device_tensor); transfer_manager_->TransferLiteralFromDevice( - device_to_host_stream_, shaped_buffer, - [=, &shaped_buffer]( - xla::StatusOr > literal_or) { + device_to_host_stream_, shaped_buffer, literal, + [=, &shaped_buffer, &literal](xla::Status status) { ref.Unref(); done([&]() -> Status { - TF_ASSIGN_OR_RETURN(auto literal, std::move(literal_or)); - VLOG(1) << "Transfer from device as literal: " << literal->ToString() + VLOG(1) << "Transfer from device as literal: " << literal.ToString() << " " << shaped_buffer.ToString(); - Tensor tensor; - TF_RETURN_IF_ERROR( - LiteralToHostTensor(*literal, host_tensor->dtype(), &tensor)); - // Reshape the tensor back to its declared shape. - Status status; - if (!host_tensor->CopyFrom(tensor, device_tensor.shape())) { - status = errors::Internal( - "Tensor::CopyFrom failed when copying from XLA device to CPU"); - } return status; }()); }); diff --git a/tensorflow/compiler/tf2xla/literal_util.cc b/tensorflow/compiler/tf2xla/literal_util.cc index 2fb66913ad..77da1bf29c 100644 --- a/tensorflow/compiler/tf2xla/literal_util.cc +++ b/tensorflow/compiler/tf2xla/literal_util.cc @@ -32,6 +32,23 @@ Status HostTensorToBorrowingLiteral(const Tensor& host_tensor, return Status::OK(); } +Status HostTensorToMutableBorrowingLiteral( + Tensor* host_tensor, xla::MutableBorrowingLiteral* literal) { + xla::Shape xla_shape; + TF_RETURN_IF_ERROR(TensorShapeToXLAShape(host_tensor->dtype(), + host_tensor->shape(), &xla_shape)); + return HostTensorToMutableBorrowingLiteral(xla_shape, host_tensor, literal); +} + +Status HostTensorToMutableBorrowingLiteral( + const xla::Shape& xla_shape, Tensor* host_tensor, + xla::MutableBorrowingLiteral* literal) { + *literal = xla::MutableBorrowingLiteral( + static_cast(DMAHelper::base(host_tensor)), xla_shape); + + return Status::OK(); +} + Status HostTensorsToBorrowingLiteralTuple( tensorflow::gtl::ArraySlice host_tensors, xla::BorrowingLiteral* literal) { diff --git a/tensorflow/compiler/tf2xla/literal_util.h b/tensorflow/compiler/tf2xla/literal_util.h index 0610a57029..09d6fa8116 100644 --- a/tensorflow/compiler/tf2xla/literal_util.h +++ b/tensorflow/compiler/tf2xla/literal_util.h @@ -30,6 +30,16 @@ namespace tensorflow { // 'host_tensor'. Status HostTensorToBorrowingLiteral(const Tensor& host_tensor, xla::BorrowingLiteral* literal); +// Returns a MutableBorrowingLiteral that utilizes the same underlying buffer +// owned by 'host_tensor', but is mutable via the xla::Literal methods. +Status HostTensorToMutableBorrowingLiteral( + Tensor* host_tensor, xla::MutableBorrowingLiteral* literal); +// Similar as above, except the literal shape is explicitly provided and used +// instead of obtaining it from the 'host_tensor'. The provided literal shape +// 'xla_shape' must be compatible with the shape of 'host_tensor'. +Status HostTensorToMutableBorrowingLiteral( + const xla::Shape& xla_shape, Tensor* host_tensor, + xla::MutableBorrowingLiteral* literal); // Returns a BorrowingLiteral tuple that utilizes the same underlying buffers // owned by 'host_tensors'. diff --git a/tensorflow/compiler/xla/client/local_client.cc b/tensorflow/compiler/xla/client/local_client.cc index 8a6c5fb9a7..4d96316d3b 100644 --- a/tensorflow/compiler/xla/client/local_client.cc +++ b/tensorflow/compiler/xla/client/local_client.cc @@ -303,7 +303,7 @@ StatusOr> LocalClient::TransferFromOutfeedLocal( const Shape& shape, int device_ordinal) { TF_ASSIGN_OR_RETURN(se::StreamExecutor * executor, backend().stream_executor(device_ordinal)); - auto literal = MakeUnique(); + auto literal = MakeUnique(shape); TF_RETURN_IF_ERROR(backend().transfer_manager()->TransferLiteralFromOutfeed( executor, shape, literal.get())); return std::move(literal); diff --git a/tensorflow/compiler/xla/literal.cc b/tensorflow/compiler/xla/literal.cc index 0545deb096..36e472568e 100644 --- a/tensorflow/compiler/xla/literal.cc +++ b/tensorflow/compiler/xla/literal.cc @@ -71,7 +71,7 @@ std::ostream& operator<<(std::ostream& out, const Literal& literal) { return out; } -Literal::StrideConfig::StrideConfig( +MutableLiteralBase::StrideConfig::StrideConfig( const Shape& source_shape, const Shape& dest_shape, tensorflow::gtl::ArraySlice dimensions) : dimensions(dimensions), @@ -133,7 +133,8 @@ void Literal::SetPiece(const Shape& shape, Piece* piece, bool allocate_arrays) { } Literal::Literal(const Shape& shape, bool allocate_arrays) - : LiteralBase(), shape_(MakeUnique(shape)) { + : MutableLiteralBase() { + shape_ = MakeUnique(shape); CHECK(LayoutUtil::HasLayout(*shape_)); root_piece_ = new Piece(); root_piece_->set_subshape(shape_.get()); @@ -159,7 +160,9 @@ void Literal::DeallocateBuffers() { }); } -Literal::Literal(Literal&& other) : LiteralBase() { *this = std::move(other); } +Literal::Literal(Literal&& other) : MutableLiteralBase() { + *this = std::move(other); +} Literal& Literal::operator=(Literal&& other) { DCHECK(&other.root_piece_->subshape() == other.shape_.get()); @@ -187,12 +190,13 @@ const SparseIndexArray* LiteralBase::sparse_indices( return piece(shape_index).sparse_indices(); } -SparseIndexArray* Literal::sparse_indices(const ShapeIndex& shape_index) { +SparseIndexArray* MutableLiteralBase::sparse_indices( + const ShapeIndex& shape_index) { return piece(shape_index).sparse_indices(); } template -Status Literal::CopySliceFromInternal( +Status MutableLiteralBase::CopySliceFromInternal( const LiteralBase& src_literal, tensorflow::gtl::ArraySlice src_base, tensorflow::gtl::ArraySlice dest_base, tensorflow::gtl::ArraySlice copy_size) { @@ -225,8 +229,8 @@ Status Literal::CopySliceFromInternal( // proper stride size at the matching dimension. DimensionVector src_indexes(src_base.size(), 0); DimensionVector dest_indexes(dest_base.size(), 0); - Literal::StrideConfig stride_config(src_literal.shape(), shape(), - copy_size); + MutableLiteralBase::StrideConfig stride_config(src_literal.shape(), shape(), + copy_size); auto copy_proc = [&](tensorflow::gtl::ArraySlice indexes) { // Map from multi-dimensional index, to source index. @@ -253,9 +257,10 @@ Status Literal::CopySliceFromInternal( return Status::OK(); } -Status Literal::CopyElementFrom(const LiteralSlice& src_literal, - tensorflow::gtl::ArraySlice src_index, - tensorflow::gtl::ArraySlice dest_index) { +Status MutableLiteralBase::CopyElementFrom( + const LiteralSlice& src_literal, + tensorflow::gtl::ArraySlice src_index, + tensorflow::gtl::ArraySlice dest_index) { DCHECK_EQ(shape().element_type(), src_literal.shape().element_type()); const int64 src_linear_index = IndexUtil::MultidimensionalIndexToLinearIndex( src_literal.shape(), src_index); @@ -275,8 +280,8 @@ Status Literal::CopyElementFrom(const LiteralSlice& src_literal, return Status::OK(); } -/* static */ StatusOr> Literal::CreateFromProto( - const LiteralProto& proto) { +/* static */ StatusOr> +MutableLiteralBase::CreateFromProto(const LiteralProto& proto) { if (!proto.has_shape()) { return InvalidArgument("LiteralProto has no shape"); } @@ -405,9 +410,9 @@ Status LiteralBase::Piece::CopyFrom(const LiteralBase::Piece& src) { return Status::OK(); } -Status Literal::CopyFrom(const LiteralSlice& src_literal, - const ShapeIndex& dest_shape_index, - const ShapeIndex& src_shape_index) { +Status MutableLiteralBase::CopyFrom(const LiteralSlice& src_literal, + const ShapeIndex& dest_shape_index, + const ShapeIndex& src_shape_index) { const Shape& dest_subshape = ShapeUtil::GetSubshape(shape(), dest_shape_index); const Shape& src_subshape = @@ -482,10 +487,11 @@ Status Literal::MoveFrom(Literal&& src_literal, return Status::OK(); } -Status Literal::CopySliceFrom(const LiteralSlice& src_literal, - tensorflow::gtl::ArraySlice src_base, - tensorflow::gtl::ArraySlice dest_base, - tensorflow::gtl::ArraySlice copy_size) { +Status MutableLiteralBase::CopySliceFrom( + const LiteralSlice& src_literal, + tensorflow::gtl::ArraySlice src_base, + tensorflow::gtl::ArraySlice dest_base, + tensorflow::gtl::ArraySlice copy_size) { TF_RET_CHECK(ShapeUtil::IsArray(shape())) << ShapeUtil::HumanString(shape()); TF_RET_CHECK(ShapeUtil::IsArray(src_literal.shape())) << ShapeUtil::HumanString(src_literal.shape()); @@ -543,7 +549,7 @@ Status Literal::CopySliceFrom(const LiteralSlice& src_literal, shape().element_type()); } -void Literal::PopulateR1(const tensorflow::core::Bitmap& values) { +void MutableLiteralBase::PopulateR1(const tensorflow::core::Bitmap& values) { CHECK(ShapeUtil::IsArray(shape())); CHECK_EQ(ShapeUtil::Rank(shape()), 1); CHECK_EQ(element_count(), values.bits()); @@ -895,8 +901,8 @@ size_t LiteralBase::Hash() const { return hash_value; } -Status Literal::SetIntegralAsS64(tensorflow::gtl::ArraySlice multi_index, - int64 value) { +Status MutableLiteralBase::SetIntegralAsS64( + tensorflow::gtl::ArraySlice multi_index, int64 value) { CHECK(LayoutUtil::IsDenseArray(shape())); switch (shape().element_type()) { case PRED: @@ -933,7 +939,7 @@ tensorflow::gtl::ArraySlice LiteralBase::GetSparseIndex( return p.sparse_indices()->At(sparse_element_number); } -void Literal::SortSparseElements(const ShapeIndex& shape_index) { +void MutableLiteralBase::SortSparseElements(const ShapeIndex& shape_index) { piece(shape_index).SortSparseElements(); } @@ -1391,11 +1397,11 @@ StatusOr> LiteralBase::ConvertToShape( elements.push_back(std::move(*new_element)); } auto converted = MakeUnique(); - *converted = Literal::MoveIntoTuple(&elements); + *converted = MutableLiteralBase::MoveIntoTuple(&elements); return std::move(converted); } -/* static */ Literal Literal::MoveIntoTuple( +/* static */ Literal MutableLiteralBase::MoveIntoTuple( tensorflow::gtl::MutableArraySlice elements) { std::vector element_shapes; for (const Literal& element : elements) { @@ -1808,7 +1814,8 @@ Status CopyFromRepeatedField(tensorflow::gtl::MutableArraySlice dest, } // namespace Status LiteralBase::Piece::CopyFromProto(const LiteralProto& proto) { - // These conditions should have been checked in Literal::CreateFromProto. + // These conditions should have been checked in + // MutableLiteralBase::CreateFromProto. TF_RET_CHECK(proto.has_shape()); TF_RET_CHECK(LayoutUtil::HasLayout(proto.shape())); TF_RET_CHECK(ShapeUtil::Equal(proto.shape(), subshape())); @@ -1900,7 +1907,7 @@ const void* LiteralBase::untyped_data(const ShapeIndex& shape_index) const { return piece(shape_index).untyped_data(); } -void* Literal::untyped_data(const ShapeIndex& shape_index) { +void* MutableLiteralBase::untyped_data(const ShapeIndex& shape_index) { return piece(shape_index).untyped_data(); } @@ -1916,6 +1923,127 @@ string LiteralBase::GetR1U8AsString() const { ShapeUtil::ElementsIn(shape())); } +void MutableBorrowingLiteral::CopyPieceSubtree(const Shape& shape, + Piece* src_piece, + Piece* dest_piece) { + DCHECK(ShapeUtil::Equal(src_piece->subshape(), dest_piece->subshape())) + << "src_piece has shape: " + << ShapeUtil::HumanString(src_piece->subshape()) + << "dest_piece has shape: " + << ShapeUtil::HumanString(dest_piece->subshape()); + if (ShapeUtil::IsTuple(shape)) { + for (int i = 0; i < ShapeUtil::TupleElementCount(shape); ++i) { + const Shape& subshape = shape.tuple_shapes(i); + + auto child_piece = Piece(); + child_piece.set_subshape(&subshape); + + CopyPieceSubtree(subshape, &src_piece->child(i), &child_piece); + + dest_piece->emplace_back(std::move(child_piece)); + } + } else if (ShapeUtil::IsArray(shape)) { + dest_piece->set_buffer(src_piece->buffer()); + } else { + // If the shape is neither an array nor tuple, then it must be + // zero-sized. Otherwise, some memory needs to be allocated for it. + CHECK_EQ(dest_piece->size_bytes(), 0); + } +} + +MutableLiteralBase::~MutableLiteralBase() {} + +MutableBorrowingLiteral::MutableBorrowingLiteral( + const MutableBorrowingLiteral& literal) + : MutableLiteralBase() { + shape_ = MakeUnique(literal.shape()); + CHECK(LayoutUtil::HasLayout(*shape_)); + + root_piece_ = new Piece(); + root_piece_->set_subshape(shape_.get()); + + CopyPieceSubtree(*shape_, &literal.root_piece(), root_piece_); +} + +MutableBorrowingLiteral& MutableBorrowingLiteral::operator=( + const MutableBorrowingLiteral& literal) { + shape_ = MakeUnique(literal.shape()); + CHECK(LayoutUtil::HasLayout(*shape_)); + + root_piece_ = new Piece(); + root_piece_->set_subshape(shape_.get()); + + CopyPieceSubtree(*shape_, &literal.root_piece(), root_piece_); + + return *this; +} + +MutableBorrowingLiteral::MutableBorrowingLiteral( + const MutableLiteralBase& literal) + : MutableLiteralBase() { + shape_ = MakeUnique(literal.shape()); + CHECK(LayoutUtil::HasLayout(*shape_)); + + root_piece_ = new Piece(); + root_piece_->set_subshape(shape_.get()); + + CopyPieceSubtree(*shape_, &literal.root_piece(), root_piece_); +} + +MutableBorrowingLiteral::MutableBorrowingLiteral(MutableLiteralBase* literal) + : MutableLiteralBase() { + shape_ = MakeUnique(literal->shape()); + CHECK(LayoutUtil::HasLayout(*shape_)); + + root_piece_ = new Piece(); + root_piece_->set_subshape(shape_.get()); + + CopyPieceSubtree(*shape_, &literal->root_piece(), root_piece_); +} + +MutableBorrowingLiteral::MutableBorrowingLiteral( + MutableBorrowingLiteral literal, const ShapeIndex& view_root) + : MutableLiteralBase() { + shape_ = MakeUnique(literal.piece(view_root).subshape()); + CHECK(LayoutUtil::HasLayout(*shape_)); + + root_piece_ = new Piece(); + root_piece_->set_subshape(shape_.get()); + + CopyPieceSubtree(*shape_, &literal.piece(view_root), root_piece_); +} + +MutableBorrowingLiteral::MutableBorrowingLiteral(const char* src_buf_ptr, + const Shape& shape) + : MutableLiteralBase() { + shape_ = MakeUnique(shape); + CHECK(LayoutUtil::HasLayout(*shape_)); + CHECK(!ShapeUtil::IsTuple(*shape_)); + + root_piece_ = new Piece(); + root_piece_->set_buffer(const_cast(src_buf_ptr)); + root_piece_->set_subshape(shape_.get()); +} + +MutableBorrowingLiteral::~MutableBorrowingLiteral() { + if (root_piece_ != nullptr) { + root_piece_->ForEachMutableSubpiece( + [&](const ShapeIndex& index, Piece* piece) { + if (piece->buffer() != nullptr) { + delete piece->sparse_indices(); + } + }); + delete root_piece_; + } +} + +LiteralSlice::LiteralSlice(const LiteralBase& literal) + : LiteralBase(), root_piece_(&literal.root_piece()) {} + +LiteralSlice::LiteralSlice(const LiteralBase& literal, + const ShapeIndex& view_root) + : LiteralBase(), root_piece_(&literal.piece(view_root)) {} + void BorrowingLiteral::BuildPieceSubtree(const Shape& shape, Piece* piece) { CHECK(ShapeUtil::IsTuple(shape)); for (int i = 0; i < ShapeUtil::TupleElementCount(shape); ++i) { @@ -1932,13 +2060,6 @@ void BorrowingLiteral::BuildPieceSubtree(const Shape& shape, Piece* piece) { } } -LiteralSlice::LiteralSlice(const LiteralBase& literal) - : LiteralBase(), root_piece_(&literal.root_piece()) {} - -LiteralSlice::LiteralSlice(const LiteralBase& literal, - const ShapeIndex& view_root) - : LiteralBase(), root_piece_(&literal.piece(view_root)) {} - BorrowingLiteral::BorrowingLiteral(const char* src_buf_ptr, const Shape& shape) : LiteralBase(), shape_(MakeUnique(shape)) { CHECK(ShapeUtil::IsArray(*shape_)); diff --git a/tensorflow/compiler/xla/literal.h b/tensorflow/compiler/xla/literal.h index dd67dfa8d4..92c0f903cb 100644 --- a/tensorflow/compiler/xla/literal.h +++ b/tensorflow/compiler/xla/literal.h @@ -310,9 +310,10 @@ class LiteralBase { // type of literal itself (0 for numeric types, and false for predicates). // // Note: It's an antipattern to use this method then immediately call - // Literal::Populate on the result (since that results in zero initialization, - // then reinitialization. Conside if a call to MakeUnique(shape), - // followed by the call to Literal::Populate can be used instead. + // MutableLiteralBase::Populate on the result (since that results in zero + // initialization, then reinitialization. Conside if a call to + // MakeUnique(shape), followed by the call to + // MutableLiteralBase::Populate can be used instead. static std::unique_ptr CreateFromShape(const Shape& shape); protected: @@ -534,7 +535,7 @@ class LiteralBase { virtual const Piece& root_piece() const = 0; // LiteralSlice and Literal must access Pieces of other Literals. - friend class Literal; + friend class MutableLiteralBase; friend class LiteralSlice; friend class BorrowingLiteral; @@ -545,33 +546,10 @@ class LiteralBase { tensorflow::gtl::ArraySlice start_indices) const; }; -// Class representing literal values in XLA. -// -// The underlying buffer and shape is always owned by this class. -class Literal : public LiteralBase { +// Abstract base class representing a mutable literal in XLA. +class MutableLiteralBase : public LiteralBase { public: - Literal() : Literal(ShapeUtil::MakeNil()) {} - - // Create a literal of the given shape. The literal is allocated sufficient - // memory to hold the shape. Memory is uninitialized. - explicit Literal(const Shape& shape); - virtual ~Literal(); - - // Literals are moveable, but not copyable. To copy a literal use - // Literal::Clone or Literal::CloneToUnique. This prevents inadvertent copies - // of literals which can be expensive. - Literal(const Literal& other) = delete; - Literal& operator=(const Literal& other) = delete; - Literal(Literal&& other); - // 'allocate_arrays' indicates whether to allocate memory for the arrays in - // the shape. If false, buffer pointers inside of the Literal::Pieces are set - // to nullptr. - Literal(const Shape& shape, bool allocate_arrays); - Literal& operator=(Literal&& other); - - // TODO(b/67651157): Remove this accessor. Literal users should not be able to - // mutate the shape as this can produce malformed Literals. - Shape* mutable_shape_do_not_use() { return shape_.get(); } + virtual ~MutableLiteralBase() = 0; // Returns a MutableArraySlice view of the array for this literal for the // given NativeT (e.g., float). CHECKs if the subshape of the literal at the @@ -587,6 +565,10 @@ class Literal : public LiteralBase { // is not a sparse array. SparseIndexArray* sparse_indices(const ShapeIndex& shape_index = {}); + // TODO(b/67651157): Remove this accessor. Literal users should not be able to + // mutate the shape as this can produce malformed Literals. + Shape* mutable_shape_do_not_use() { return shape_.get(); } + // Returns a pointer to the underlying buffer holding the array at the given // shape index. CHECKs if the subshape of the literal at the given ShapeIndex // is not array. @@ -613,21 +595,6 @@ class Literal : public LiteralBase { const ShapeIndex& dest_shape_index = {}, const ShapeIndex& src_shape_index = {}); - // Returns a vector containing the tuple elements of this Literal as separate - // Literals. This Literal must be tuple-shaped and can be a nested tuple. The - // elements are moved into the new Literals; no data is copied. Upon return - // this Literal is set to a nil shape (empty tuple) - std::vector DecomposeTuple(); - - // Similar to CopyFrom, but with move semantincs. The subshape of this literal - // rooted at 'dest_shape_index' must be *equal* to the shape 'src_literal' - // (layouts and shapes must match), but need not be arrays. The memory - // allocated in this literal for the subshape at dest_shape_index is - // deallocated, and the respective buffers are replaced with those in - // src_literal. Upon return, src_literal is set to a nil shape (empty tuple). - Status MoveFrom(Literal&& src_literal, - const ShapeIndex& dest_shape_index = {}); - // Copies the values from src_literal, starting at src_base shape indexes, // to this literal, starting at dest_base, where the copy size in each // dimension is specified by copy_size. @@ -730,12 +697,7 @@ class Literal : public LiteralBase { static StatusOr> CreateFromProto( const LiteralProto& proto); - private: - // Recursively sets the subshapes and buffers of all subpieces rooted at - // 'piece'. If 'allocate_array' is true, memory is allocated for the arrays in - // the shape. - void SetPiece(const Shape& shape, Piece* piece, bool allocate_arrays); - + protected: // Returns the piece at the given ShapeIndex. Piece& piece(const ShapeIndex& shape_index) { return const_cast(LiteralBase::piece(shape_index)); @@ -783,12 +745,83 @@ class Literal : public LiteralBase { template Status PopulateInternal(const FnType& generator, bool parallel); + friend class LiteralBase; + friend class MutableBorrowingLiteral; +}; +std::ostream& operator<<(std::ostream& out, const Literal& literal); + +// The underlying buffer and shape is always owned by this class. +class Literal : public MutableLiteralBase { + public: + Literal() : Literal(ShapeUtil::MakeNil()) {} + + // Create a literal of the given shape. The literal is allocated sufficient + // memory to hold the shape. Memory is uninitialized. + explicit Literal(const Shape& shape); + virtual ~Literal(); + + // Literals are moveable, but not copyable. To copy a literal use + // Literal::Clone or Literal::CloneToUnique. This prevents inadvertent copies + // of literals which can be expensive. + Literal(const Literal& other) = delete; + Literal& operator=(const Literal& other) = delete; + Literal(Literal&& other); + // 'allocate_arrays' indicates whether to allocate memory for the arrays in + // the shape. If false, buffer pointers inside of the Literal::Pieces are set + // to nullptr. + Literal(const Shape& shape, bool allocate_arrays); + Literal& operator=(Literal&& other); + + // Similar to CopyFrom, but with move semantincs. The subshape of this literal + // rooted at 'dest_shape_index' must be *equal* to the shape 'src_literal' + // (layouts and shapes must match), but need not be arrays. The memory + // allocated in this literal for the subshape at dest_shape_index is + // deallocated, and the respective buffers are replaced with those in + // src_literal. Upon return, src_literal is set to a nil shape (empty tuple). + virtual Status MoveFrom(Literal&& src_literal, + const ShapeIndex& dest_shape_index = {}); + + // Returns a vector containing the tuple elements of this Literal as separate + // Literals. This Literal must be tuple-shaped and can be a nested tuple. The + // elements are moved into the new Literals; no data is copied. Upon return + // this Literal is set to a nil shape (empty tuple) + std::vector DecomposeTuple(); + + private: // Deallocate the buffers held by this literal. void DeallocateBuffers(); - friend class LiteralBase; + // Recursively sets the subshapes and buffers of all subpieces rooted at + // 'piece'. If 'allocate_array' is true, memory is allocated for the arrays in + // the shape. + void SetPiece(const Shape& shape, Piece* piece, bool allocate_arrays); +}; + +// The underlying buffer is not owned by this class and is always owned by +// others. The shape is not owned by this class and not mutable. +class MutableBorrowingLiteral : public MutableLiteralBase { + public: + virtual ~MutableBorrowingLiteral(); + + MutableBorrowingLiteral() : MutableLiteralBase() {} + + MutableBorrowingLiteral(const MutableBorrowingLiteral& literal); + MutableBorrowingLiteral& operator=(const MutableBorrowingLiteral& literal); + + // Implicit conversion constructors. + MutableBorrowingLiteral(const MutableLiteralBase& literal); + MutableBorrowingLiteral(MutableLiteralBase* literal); + MutableBorrowingLiteral(MutableBorrowingLiteral literal, + const ShapeIndex& view_root); + MutableBorrowingLiteral(const char* src_buf_ptr, const Shape& shape); + + private: + // Recursively copies the subtree from the `src_piece` at the given child + // index to the `dest_piece`. For buffers only the pointers are copied, but + // not the content. + void CopyPieceSubtree(const Shape& shape, Piece* src_piece, + Piece* dest_piece); }; -std::ostream& operator<<(std::ostream& out, const Literal& literal); // A read-only view of a Literal. A LiteralSlice contains pointers to shape and // literal buffers always owned by others. @@ -831,9 +864,9 @@ class BorrowingLiteral : public LiteralBase { const Piece& root_piece() const override { return root_piece_; }; Piece root_piece_; - // Shape of this literal. Stored as unique_ptr so such that the (default) - // move construction of this class would be trivially correct: the pointer to - // Shape root_piece_ stores will still point to the correct address. + // Shape of this literal. Stored as unique_ptr such that the (default) move + // construction of this class would be trivially correct: the pointer to Shape + // root_piece_ stores will still point to the correct address. std::unique_ptr shape_; }; @@ -886,7 +919,7 @@ tensorflow::gtl::ArraySlice LiteralBase::data( } template -tensorflow::gtl::MutableArraySlice Literal::data( +tensorflow::gtl::MutableArraySlice MutableLiteralBase::data( const ShapeIndex& shape_index) { return piece(shape_index).data(); } @@ -904,14 +937,15 @@ inline NativeT LiteralBase::Get( } template -inline void Literal::Set(tensorflow::gtl::ArraySlice multi_index, - const ShapeIndex& shape_index, NativeT value) { +inline void MutableLiteralBase::Set( + tensorflow::gtl::ArraySlice multi_index, + const ShapeIndex& shape_index, NativeT value) { return piece(shape_index).Set(multi_index, value); } template -inline void Literal::Set(tensorflow::gtl::ArraySlice multi_index, - NativeT value) { +inline void MutableLiteralBase::Set( + tensorflow::gtl::ArraySlice multi_index, NativeT value) { return root_piece().Set(multi_index, value); } @@ -929,7 +963,7 @@ NativeT LiteralBase::GetSparseElement(int64 sparse_element_number, } template -void Literal::AppendSparseElement( +void MutableLiteralBase::AppendSparseElement( tensorflow::gtl::ArraySlice multi_index, NativeT value, const ShapeIndex& shape_index) { Piece& p = piece(shape_index); @@ -959,7 +993,8 @@ void LiteralBase::EachCell( } template -inline void Literal::PopulateR1(tensorflow::gtl::ArraySlice values) { +inline void MutableLiteralBase::PopulateR1( + tensorflow::gtl::ArraySlice values) { CHECK(ShapeUtil::IsArray(shape())); CHECK_EQ(ShapeUtil::Rank(shape()), 1); CHECK_EQ(ShapeUtil::ElementsIn(shape()), values.size()); @@ -971,7 +1006,7 @@ inline void Literal::PopulateR1(tensorflow::gtl::ArraySlice values) { } template -void Literal::PopulateR2( +void MutableLiteralBase::PopulateR2( std::initializer_list> values) { CHECK(ShapeUtil::IsArray(shape())); CHECK_EQ(ShapeUtil::Rank(shape()), 2); @@ -996,7 +1031,7 @@ void Literal::PopulateR2( } template -void Literal::PopulateFromArray(const Array& values) { +void MutableLiteralBase::PopulateFromArray(const Array& values) { CHECK(ShapeUtil::IsArray(shape())); CHECK_EQ(shape().element_type(), primitive_util::NativeToPrimitiveType()); @@ -1009,24 +1044,24 @@ void Literal::PopulateFromArray(const Array& values) { } template -void Literal::PopulateR2FromArray2D(const Array2D& values) { +void MutableLiteralBase::PopulateR2FromArray2D(const Array2D& values) { PopulateFromArray(values); } template -void Literal::PopulateR3FromArray3D(const Array3D& values) { +void MutableLiteralBase::PopulateR3FromArray3D(const Array3D& values) { PopulateFromArray(values); } template -void Literal::PopulateR4FromArray4D(const Array4D& values) { +void MutableLiteralBase::PopulateR4FromArray4D(const Array4D& values) { PopulateFromArray(values); } template -void Literal::PopulateSparse(SparseIndexArray indices, - tensorflow::gtl::ArraySlice values, - bool sort) { +void MutableLiteralBase::PopulateSparse( + SparseIndexArray indices, tensorflow::gtl::ArraySlice values, + bool sort) { CHECK(LayoutUtil::IsSparseArray(shape())); int rank = ShapeUtil::Rank(shape()); CHECK_EQ(indices.rank(), rank); @@ -1049,7 +1084,8 @@ void Literal::PopulateSparse(SparseIndexArray indices, } template -Status Literal::PopulateInternal(const FnType& generator, bool parallel) { +Status MutableLiteralBase::PopulateInternal(const FnType& generator, + bool parallel) { const Shape& this_shape = shape(); const int64 rank = ShapeUtil::Rank(this_shape); TF_RET_CHECK(LayoutUtil::IsDenseArray(this_shape)); @@ -1092,17 +1128,17 @@ Status Literal::PopulateInternal(const FnType& generator, bool parallel) { return Status::OK(); } template -Status Literal::Populate(const FnType& generator) { +Status MutableLiteralBase::Populate(const FnType& generator) { return PopulateInternal(generator, /*parallel=*/false); } template -Status Literal::PopulateParallel(const FnType& generator) { +Status MutableLiteralBase::PopulateParallel(const FnType& generator) { return PopulateInternal(generator, /*parallel=*/true); } template -void Literal::PopulateWithValue(NativeT value) { +void MutableLiteralBase::PopulateWithValue(NativeT value) { CHECK(ShapeUtil::IsArray(shape())); CHECK_EQ(shape().element_type(), primitive_util::NativeToPrimitiveType()); diff --git a/tensorflow/compiler/xla/literal_util.cc b/tensorflow/compiler/xla/literal_util.cc index 356f12ed78..5d33df7d40 100644 --- a/tensorflow/compiler/xla/literal_util.cc +++ b/tensorflow/compiler/xla/literal_util.cc @@ -34,6 +34,7 @@ limitations under the License. #include "tensorflow/core/lib/strings/strcat.h" #include "tensorflow/core/lib/strings/stringprintf.h" #include "tensorflow/core/platform/logging.h" +#include "tensorflow/core/platform/mem.h" #include "tensorflow/core/platform/types.h" using tensorflow::strings::StrCat; diff --git a/tensorflow/compiler/xla/service/cpu/cpu_transfer_manager.cc b/tensorflow/compiler/xla/service/cpu/cpu_transfer_manager.cc index 156166bf2b..59bc7e0e16 100644 --- a/tensorflow/compiler/xla/service/cpu/cpu_transfer_manager.cc +++ b/tensorflow/compiler/xla/service/cpu/cpu_transfer_manager.cc @@ -173,7 +173,7 @@ CpuTransferManager::TransferBufferToInfeedInternal(se::StreamExecutor* executor, Status CpuTransferManager::TransferLiteralFromOutfeed( se::StreamExecutor* executor, const Shape& literal_shape, - Literal* literal) { + MutableBorrowingLiteral literal) { if (!ShapeUtil::IsTuple(literal_shape)) { int64 size = GetByteSizeRequirement(literal_shape); // Note: OSS build didn't like implicit conversion from @@ -181,18 +181,16 @@ Status CpuTransferManager::TransferLiteralFromOutfeed( tensorflow::gtl::ArraySlice dimensions( tensorflow::bit_cast(literal_shape.dimensions().data()), literal_shape.dimensions().size()); - *literal = std::move(*LiteralUtil::CreateFromDimensions( - literal_shape.element_type(), dimensions)); - TF_ASSIGN_OR_RETURN(Shape received_shape, - TransferArrayBufferFromOutfeed( - executor, literal->untyped_data(), size)); - TF_RET_CHECK(ShapeUtil::Compatible(received_shape, literal->shape())) + TF_ASSIGN_OR_RETURN( + Shape received_shape, + TransferArrayBufferFromOutfeed(executor, literal.untyped_data(), size)); + TF_RET_CHECK(ShapeUtil::Compatible(received_shape, literal.shape())) << "Shape received from outfeed " << ShapeUtil::HumanString(received_shape) << " did not match the shape that was requested for outfeed: " << ShapeUtil::HumanString(literal_shape); TF_RET_CHECK(size == GetByteSizeRequirement(received_shape)); - *literal->mutable_shape_do_not_use() = received_shape; + *literal.mutable_shape_do_not_use() = received_shape; return Status::OK(); } @@ -201,22 +199,12 @@ Status CpuTransferManager::TransferLiteralFromOutfeed( "Nested tuple outfeeds are not yet implemented on CPU."); } - std::vector> elements; std::vector> buffer_data; for (int64 i = 0; i < literal_shape.tuple_shapes_size(); ++i) { const Shape& tuple_element_shape = ShapeUtil::GetTupleElementShape(literal_shape, i); - // Note: OSS build didn't like implicit conversion from - // literal_shape.dimensions() to the array slice on 2017-07-10. - tensorflow::gtl::ArraySlice dimensions( - tensorflow::bit_cast( - tuple_element_shape.dimensions().data()), - tuple_element_shape.dimensions().size()); - auto empty = LiteralUtil::CreateFromDimensions( - tuple_element_shape.element_type(), dimensions); int64 size = GetByteSizeRequirement(tuple_element_shape); - buffer_data.push_back({empty->untyped_data(), size}); - elements.push_back(std::move(empty)); + buffer_data.push_back({literal.untyped_data({i}), size}); } TF_ASSIGN_OR_RETURN(Shape received_shape, @@ -230,11 +218,7 @@ Status CpuTransferManager::TransferLiteralFromOutfeed( TF_RET_CHECK(GetByteSizeRequirement(literal_shape) == GetByteSizeRequirement(received_shape)); - for (int64 i = 0; i < literal_shape.tuple_shapes_size(); ++i) { - *elements[i]->mutable_shape_do_not_use() = received_shape.tuple_shapes(i); - } - *literal = std::move(*LiteralUtil::MakeTupleOwned(std::move(elements))); - TF_RET_CHECK(ShapeUtil::Equal(literal->shape(), literal_shape)); + TF_RET_CHECK(ShapeUtil::Equal(literal.shape(), literal_shape)); return Status::OK(); } diff --git a/tensorflow/compiler/xla/service/cpu/cpu_transfer_manager.h b/tensorflow/compiler/xla/service/cpu/cpu_transfer_manager.h index 593575c0fd..80ef953d53 100644 --- a/tensorflow/compiler/xla/service/cpu/cpu_transfer_manager.h +++ b/tensorflow/compiler/xla/service/cpu/cpu_transfer_manager.h @@ -18,6 +18,7 @@ limitations under the License. #include +#include "tensorflow/compiler/xla/literal.h" #include "tensorflow/compiler/xla/service/cpu/xfeed_manager.h" #include "tensorflow/compiler/xla/service/generic_transfer_manager.h" #include "tensorflow/compiler/xla/service/transfer_manager.h" @@ -41,7 +42,7 @@ class CpuTransferManager : public GenericTransferManager { const LiteralSlice& literal) override; Status TransferLiteralFromOutfeed(se::StreamExecutor* executor, const Shape& literal_shape, - Literal* literal) override; + MutableBorrowingLiteral literal) override; private: Status TransferBufferToInfeed(se::StreamExecutor* executor, int64 size, diff --git a/tensorflow/compiler/xla/service/generic_transfer_manager.cc b/tensorflow/compiler/xla/service/generic_transfer_manager.cc index e314a469f0..0ce2db907b 100644 --- a/tensorflow/compiler/xla/service/generic_transfer_manager.cc +++ b/tensorflow/compiler/xla/service/generic_transfer_manager.cc @@ -24,7 +24,6 @@ limitations under the License. #include "tensorflow/compiler/xla/service/interpreter/platform_id.h" #include "tensorflow/compiler/xla/shape_util.h" #include "tensorflow/compiler/xla/status_macros.h" -#include "tensorflow/compiler/xla/statusor.h" #include "tensorflow/compiler/xla/types.h" #include "tensorflow/compiler/xla/util.h" #include "tensorflow/compiler/xla/xla_data.pb.h" @@ -60,17 +59,19 @@ Status GenericTransferManager::WriteSingleTupleIndexTable( void GenericTransferManager::TransferLiteralFromDevice( se::Stream* stream, const ShapedBuffer& device_buffer, - std::function>)> done) { + MutableBorrowingLiteral literal, std::function done) { Status status = stream->BlockHostUntilDone(); if (!status.ok()) { return done(status); } - done(TransferLiteralFromDeviceInternal(stream->parent(), device_buffer)); + + done(TransferLiteralFromDeviceInternal(stream->parent(), device_buffer, + literal)); } -StatusOr> -GenericTransferManager::TransferLiteralFromDeviceInternal( - se::StreamExecutor* executor, const ShapedBuffer& device_buffer) { +Status GenericTransferManager::TransferLiteralFromDeviceInternal( + se::StreamExecutor* executor, const ShapedBuffer& device_buffer, + MutableBorrowingLiteral literal) { VLOG(2) << "transferring literal from device ordinal " << executor->device_ordinal() << "; device buffer: " << device_buffer; TF_RET_CHECK(executor->device_ordinal() == device_buffer.device_ordinal()); @@ -80,9 +81,6 @@ GenericTransferManager::TransferLiteralFromDeviceInternal( TF_RET_CHECK(ShapeUtil::Equal(device_buffer.on_device_shape(), device_buffer.on_host_shape())); - std::unique_ptr literal = - Literal::CreateFromShape(device_buffer.on_host_shape()); - TF_RETURN_IF_ERROR(ShapeUtil::ForEachSubshapeWithStatus( device_buffer.on_host_shape(), [&](const Shape& subshape, const ShapeIndex& index) -> Status { @@ -91,12 +89,12 @@ GenericTransferManager::TransferLiteralFromDeviceInternal( /*source=*/device_buffer.buffer(index), /*size=*/GetByteSizeRequirement(subshape), /*destination=*/ - literal->untyped_data(index))); + literal.untyped_data(index))); } return Status::OK(); })); - return std::move(literal); + return Status::OK(); } Status GenericTransferManager::TransferLiteralToDeviceAsync( @@ -160,7 +158,7 @@ Status GenericTransferManager::TransferLiteralToInfeed( Status GenericTransferManager::TransferLiteralFromOutfeed( se::StreamExecutor* executor, const Shape& literal_shape, - Literal* literal) { + MutableBorrowingLiteral literal) { return Unimplemented("Generic transfer from Outfeed"); } diff --git a/tensorflow/compiler/xla/service/generic_transfer_manager.h b/tensorflow/compiler/xla/service/generic_transfer_manager.h index 3cd002c1bf..6c1a21587a 100644 --- a/tensorflow/compiler/xla/service/generic_transfer_manager.h +++ b/tensorflow/compiler/xla/service/generic_transfer_manager.h @@ -19,7 +19,6 @@ limitations under the License. #include #include "tensorflow/compiler/xla/service/transfer_manager.h" -#include "tensorflow/compiler/xla/statusor.h" #include "tensorflow/compiler/xla/xla_data.pb.h" #include "tensorflow/core/platform/macros.h" #include "tensorflow/core/platform/stream_executor_no_cuda.h" @@ -41,9 +40,10 @@ class GenericTransferManager : public TransferManager { se::Platform::Id PlatformId() const override; - void TransferLiteralFromDevice( - se::Stream* stream, const ShapedBuffer& device_buffer, - std::function>)> done) override; + void TransferLiteralFromDevice(se::Stream* stream, + const ShapedBuffer& device_buffer, + MutableBorrowingLiteral literal, + std::function done) override; Status TransferLiteralToDeviceAsync( se::Stream* stream, const LiteralSlice& literal, @@ -53,7 +53,7 @@ class GenericTransferManager : public TransferManager { const LiteralSlice& literal) override; Status TransferLiteralFromOutfeed(se::StreamExecutor* executor, const Shape& literal_shape, - Literal* literal) override; + MutableBorrowingLiteral literal) override; Status ResetDevices( tensorflow::gtl::ArraySlice executors) override; @@ -67,8 +67,9 @@ class GenericTransferManager : public TransferManager { const Shape& shape, se::DeviceMemoryBase* region) override; private: - StatusOr> TransferLiteralFromDeviceInternal( - se::StreamExecutor* executor, const ShapedBuffer& device_buffer); + Status TransferLiteralFromDeviceInternal(se::StreamExecutor* executor, + const ShapedBuffer& device_buffer, + MutableBorrowingLiteral literal); // The platform this transfer manager targets. const se::Platform::Id platform_id_; diff --git a/tensorflow/compiler/xla/service/gpu/gpu_transfer_manager.cc b/tensorflow/compiler/xla/service/gpu/gpu_transfer_manager.cc index 79b3f1efec..a2f53f8446 100644 --- a/tensorflow/compiler/xla/service/gpu/gpu_transfer_manager.cc +++ b/tensorflow/compiler/xla/service/gpu/gpu_transfer_manager.cc @@ -117,38 +117,37 @@ StatusOr GpuTransferManager::TransferBufferToInfeedInternal( return std::move(buffer); } -static std::unique_ptr ShapeTreeToLiteral( +static void ShapeTreeToLiteral( ShapeTree>* shape_tree) { // This is a struct instead of a lambda for std::function-free recursion. struct Helper { - static std::unique_ptr helper( + static void helper( ShapeTree>* shape_tree, ShapeIndex* index) { const Shape& shape = ShapeUtil::GetSubshape(shape_tree->shape(), *index); if (ShapeUtil::IsArray(shape)) { - return (*shape_tree->mutable_element(*index))->WaitUntilAvailable(); + (*shape_tree->mutable_element(*index))->WaitUntilAvailable(); + return; } CHECK(ShapeUtil::IsTuple(shape)) << ShapeUtil::HumanStringWithLayout(shape); const int64 tuple_element_count = ShapeUtil::TupleElementCount(shape); index->push_back(0); - std::vector> tuple_operands; for (int64 i = 0; i < tuple_element_count; ++i) { index->back() = i; - tuple_operands.push_back(helper(shape_tree, index)); + helper(shape_tree, index); } index->pop_back(); - return LiteralUtil::MakeTupleOwned(std::move(tuple_operands)); } }; ShapeIndex index; - return Helper::helper(shape_tree, &index); + Helper::helper(shape_tree, &index); } Status GpuTransferManager::TransferLiteralFromOutfeed( se::StreamExecutor* /*executor*/, const Shape& literal_shape, - Literal* literal) { + MutableBorrowingLiteral literal) { ShapeTree> outfeed_buffers( &literal_shape); @@ -162,6 +161,8 @@ Status GpuTransferManager::TransferLiteralFromOutfeed( return; } *buffer = MakeUnique(GetByteSizeRequirement(shape)); + (*buffer)->set_destination( + MakeUnique(literal, index)); }); // Give the tree of buffers to the outfeed mananger. The device will fill it @@ -169,8 +170,8 @@ Status GpuTransferManager::TransferLiteralFromOutfeed( gpu::OutfeedManager* outfeed_manager = gpu::GetOrCreateOutfeedManager(); outfeed_manager->EnqueueDestination(&outfeed_buffers); - // Now turn the tree of buffers back into a literal. - *literal = std::move(*ShapeTreeToLiteral(&outfeed_buffers)); + // Now wait for the tree of buffers are written. + ShapeTreeToLiteral(&outfeed_buffers); return Status::OK(); } diff --git a/tensorflow/compiler/xla/service/gpu/gpu_transfer_manager.h b/tensorflow/compiler/xla/service/gpu/gpu_transfer_manager.h index dceeb9e2eb..7929042869 100644 --- a/tensorflow/compiler/xla/service/gpu/gpu_transfer_manager.h +++ b/tensorflow/compiler/xla/service/gpu/gpu_transfer_manager.h @@ -42,7 +42,7 @@ class GpuTransferManager : public GenericTransferManager { const LiteralSlice& literal) override; Status TransferLiteralFromOutfeed(se::StreamExecutor* executor, const Shape& literal_shape, - Literal* literal) override; + MutableBorrowingLiteral literal) override; private: // Initiates the infeed data transfers. InfeedBuffer->Done() must be diff --git a/tensorflow/compiler/xla/service/gpu/outfeed_manager.h b/tensorflow/compiler/xla/service/gpu/outfeed_manager.h index a752eb7011..160ba4b691 100644 --- a/tensorflow/compiler/xla/service/gpu/outfeed_manager.h +++ b/tensorflow/compiler/xla/service/gpu/outfeed_manager.h @@ -36,22 +36,19 @@ class OutfeedBuffer { OutfeedBuffer(int64 length) : length_(length) {} // Waits for the device transfer to be finished. - std::unique_ptr WaitUntilAvailable() { - done_.WaitForNotification(); - return std::move(destination_); - } + void WaitUntilAvailable() { done_.WaitForNotification(); } int64 length() const { return length_; } - void set_destination(std::unique_ptr destination) { + void set_destination(std::unique_ptr destination) { destination_ = std::move(destination); } - Literal* destination() { return destination_.get(); } + MutableBorrowingLiteral* destination() { return destination_.get(); } // Callback to signal that this buffer is consumed. void Done() { done_.Notify(); } private: - std::unique_ptr destination_; + std::unique_ptr destination_; const int64 length_; tensorflow::Notification done_; }; diff --git a/tensorflow/compiler/xla/service/gpu/outfeed_thunk.cc b/tensorflow/compiler/xla/service/gpu/outfeed_thunk.cc index 7986e63f43..b99d998c4d 100644 --- a/tensorflow/compiler/xla/service/gpu/outfeed_thunk.cc +++ b/tensorflow/compiler/xla/service/gpu/outfeed_thunk.cc @@ -50,10 +50,6 @@ Status OutfeedThunk::ExecuteOnStream( if (!*buffer) { // Tuple pointers. return Status::OK(); } - // Allocate storage for the literal data. - const Shape& shape = - ShapeUtil::GetSubshape(outfeed_buffers->shape(), index); - (*buffer)->set_destination(Literal::CreateFromShape(shape)); BufferAllocation::Slice slice = outfeed_slices_.element(index); se::DeviceMemoryBase data_address; diff --git a/tensorflow/compiler/xla/service/service.cc b/tensorflow/compiler/xla/service/service.cc index 212db0643c..e970e885c5 100644 --- a/tensorflow/compiler/xla/service/service.cc +++ b/tensorflow/compiler/xla/service/service.cc @@ -1052,10 +1052,10 @@ Status Service::TransferFromOutfeed(const TransferFromOutfeedRequest* arg, executor = replicas[arg->replica_id()]; } - Literal literal; + Literal literal(arg->shape_with_layout()); TF_RETURN_IF_ERROR( execute_backend_->transfer_manager()->TransferLiteralFromOutfeed( - executor, arg->shape_with_layout(), &literal)); + executor, arg->shape_with_layout(), literal)); *result->mutable_literal() = literal.ToProto(); return Status::OK(); } diff --git a/tensorflow/compiler/xla/service/transfer_manager.cc b/tensorflow/compiler/xla/service/transfer_manager.cc index 7232c658b3..32d368a904 100644 --- a/tensorflow/compiler/xla/service/transfer_manager.cc +++ b/tensorflow/compiler/xla/service/transfer_manager.cc @@ -43,15 +43,39 @@ TransferManager::GetPlatformTransferManagers() { StatusOr> TransferManager::TransferLiteralFromDevice( se::Stream* stream, const ShapedBuffer& device_buffer) { StatusOr> ret; + se::Stream* substream = stream->GetOrCreateSubStream(); substream->ThenWaitFor(stream); auto cleanup = tensorflow::gtl::MakeCleanup( [&]() { stream->ReturnSubStream(substream); }); tensorflow::Notification n; - TransferLiteralFromDevice(substream, device_buffer, - [&](StatusOr> arg) { - ret = std::move(arg); + Status s; + Literal literal(device_buffer.on_host_shape()); + TransferLiteralFromDevice(substream, device_buffer, literal, + [&](Status status) { + s = status; + n.Notify(); + }); + n.WaitForNotification(); + if (!s.ok()) { + return s; + } + return MakeUnique(std::move(literal)); +} + +Status TransferManager::TransferLiteralFromDevice( + se::Stream* stream, const ShapedBuffer& device_buffer, + const MutableBorrowingLiteral& literal) { + se::Stream* substream = stream->GetOrCreateSubStream(); + auto cleanup = tensorflow::gtl::MakeCleanup( + [&]() { stream->ReturnSubStream(substream); }); + + Status ret; + tensorflow::Notification n; + TransferLiteralFromDevice(substream, device_buffer, literal, + [&](Status status) { + ret = status; n.Notify(); }); n.WaitForNotification(); @@ -76,22 +100,27 @@ Status TransferManager::TransferLiteralToDevice( StatusOr> TransferManager::TransferArrayFromDevice( se::Stream* stream, const Shape& shape, const se::DeviceMemoryBase& source) { + StatusOr> ret; // Implement the synchronous version by waiting on the asynchronous version. // Use a substream so that if we are called from a HostCallback we don't // deadlock. - StatusOr> ret; se::Stream* substream = stream->GetOrCreateSubStream(); auto cleanup = tensorflow::gtl::MakeCleanup( [&]() { stream->ReturnSubStream(substream); }); tensorflow::Notification n; - TransferArrayFromDevice(substream, shape, source, - [&](StatusOr> arg) { - ret = std::move(arg); + Literal literal(shape); + Status s; + TransferArrayFromDevice(substream, shape, source, literal, + [&](Status status) { + s = status; n.Notify(); }); n.WaitForNotification(); - return ret; + if (!s.ok()) { + return s; + } + return MakeUnique(std::move(literal)); } Status TransferManager::TransferArrayToDevice( @@ -130,7 +159,7 @@ Status TransferManager::TransferArrayToDeviceAsync( void TransferManager::TransferArrayFromDevice( se::Stream* stream, const Shape& shape, const se::DeviceMemoryBase& source, - std::function>)> done) { + const MutableBorrowingLiteral& literal, std::function done) { if (!ShapeUtil::Equal(HostShapeToDeviceShape(shape), shape)) { auto error = StrCat("Shape ", ShapeUtil::HumanString(shape), " has a differently shaped representation on-device: ", @@ -147,7 +176,8 @@ void TransferManager::TransferArrayFromDevice( stream->parent()->platform(), stream->parent()->device_ordinal()); shaped_buffer.set_buffer(source, /*index=*/{}); - return TransferLiteralFromDevice(stream, shaped_buffer, std::move(done)); + return TransferLiteralFromDevice(stream, shaped_buffer, literal, + std::move(done)); } /* static */ void TransferManager::RegisterTransferManager( diff --git a/tensorflow/compiler/xla/service/transfer_manager.h b/tensorflow/compiler/xla/service/transfer_manager.h index 82c599e482..475a2e5c14 100644 --- a/tensorflow/compiler/xla/service/transfer_manager.h +++ b/tensorflow/compiler/xla/service/transfer_manager.h @@ -59,6 +59,9 @@ class TransferManager { // This function should be avoided in favor of the asynchronous version below. virtual StatusOr> TransferLiteralFromDevice( se::Stream* stream, const ShapedBuffer& device_buffer); + virtual Status TransferLiteralFromDevice( + se::Stream* stream, const ShapedBuffer& device_buffer, + const MutableBorrowingLiteral& literal); // Begins transferring a literal containing the data held in the given // ShapedBuffer using the provided executor. @@ -69,9 +72,10 @@ class TransferManager { // // device_buffer is copied by reference and must live at least until done() is // invoked. - virtual void TransferLiteralFromDevice( - se::Stream* stream, const ShapedBuffer& device_buffer, - std::function>)> done) = 0; + virtual void TransferLiteralFromDevice(se::Stream* stream, + const ShapedBuffer& device_buffer, + MutableBorrowingLiteral literal, + std::function done) = 0; // Transfers the given literal into the previously allocated device memory // represented by the given ShapedBuffer using the given executor. The shape @@ -101,10 +105,10 @@ class TransferManager { // transfer an array at a known address. Status TransferArrayToDevice(se::Stream* stream, const LiteralSlice& literal, const se::DeviceMemoryBase& dest); - void TransferArrayFromDevice( - se::Stream* stream, const Shape& shape, - const se::DeviceMemoryBase& source, - std::function>)> done); + void TransferArrayFromDevice(se::Stream* stream, const Shape& shape, + const se::DeviceMemoryBase& source, + const MutableBorrowingLiteral& literal, + std::function done); Status TransferArrayToDeviceAsync(se::Stream* stream, const LiteralSlice& literal, @@ -120,9 +124,9 @@ class TransferManager { // Transfers the given literal from the Outfeed interface of the device, // using the given executor. - virtual Status TransferLiteralFromOutfeed(se::StreamExecutor* executor, - const Shape& literal_shape, - Literal* literal) = 0; + virtual Status TransferLiteralFromOutfeed( + se::StreamExecutor* executor, const Shape& literal_shape, + MutableBorrowingLiteral literal) = 0; // Resets the devices associated with this transfer manager. virtual Status ResetDevices( diff --git a/tensorflow/compiler/xla/tests/tuple_test.cc b/tensorflow/compiler/xla/tests/tuple_test.cc index 2fd70b72b5..d9c1dfa3f7 100644 --- a/tensorflow/compiler/xla/tests/tuple_test.cc +++ b/tensorflow/compiler/xla/tests/tuple_test.cc @@ -586,9 +586,9 @@ XLA_TEST_F(TupleHloTest, })); auto expected = LiteralUtil::MakeTupleOwned(LiteralUtil::CreateR1({2, 3})); - auto literal = MakeUnique(); + auto literal = MakeUnique(expected->shape()); TF_EXPECT_OK(backend().transfer_manager()->TransferLiteralFromOutfeed( - backend().default_stream_executor(), expected->shape(), literal.get())); + backend().default_stream_executor(), expected->shape(), *literal)); EXPECT_TRUE(LiteralTestUtil::Equal(*expected, *literal)); } -- GitLab From 63cd1e5999d36f91dd938af4a4c2864640c76caa Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Wed, 8 Aug 2018 17:18:07 -0700 Subject: [PATCH 236/437] Enable quantization support for ExpandDims PiperOrigin-RevId: 207972564 --- .../contrib/lite/toco/graph_transformations/hardcode_min_max.cc | 1 + tensorflow/contrib/lite/toco/graph_transformations/quantize.cc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tensorflow/contrib/lite/toco/graph_transformations/hardcode_min_max.cc b/tensorflow/contrib/lite/toco/graph_transformations/hardcode_min_max.cc index 527013bfa3..d26c3b2878 100644 --- a/tensorflow/contrib/lite/toco/graph_transformations/hardcode_min_max.cc +++ b/tensorflow/contrib/lite/toco/graph_transformations/hardcode_min_max.cc @@ -371,6 +371,7 @@ bool HardcodeMinMax::Run(Model* model, std::size_t op_index) { case OperatorType::kStridedSlice: case OperatorType::kSqueeze: case OperatorType::kReshape: + case OperatorType::kExpandDims: case OperatorType::kPad: case OperatorType::kGather: case OperatorType::kTranspose: diff --git a/tensorflow/contrib/lite/toco/graph_transformations/quantize.cc b/tensorflow/contrib/lite/toco/graph_transformations/quantize.cc index b5a6554c1d..8d22ae2eb1 100644 --- a/tensorflow/contrib/lite/toco/graph_transformations/quantize.cc +++ b/tensorflow/contrib/lite/toco/graph_transformations/quantize.cc @@ -62,7 +62,7 @@ bool SupportsQuantization(const Operator& op) { type == OperatorType::kLessEqual || type == OperatorType::kSelect || type == OperatorType::kArgMax || type == OperatorType::kRelu || type == OperatorType::kRelu1 || type == OperatorType::kRelu6 || - type == OperatorType::kShape; + type == OperatorType::kShape || type == OperatorType::kExpandDims; } // The quantized op allows output arrays of type float using -- GitLab From f7d5e2e1038bedd008962e83b0acdc83a316de03 Mon Sep 17 00:00:00 2001 From: Xuechen Li Date: Wed, 8 Aug 2018 17:20:13 -0700 Subject: [PATCH 237/437] Update readme regarding TensorFlow verion requirement. PiperOrigin-RevId: 207972787 --- .../eager/python/examples/revnet/README.md | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tensorflow/contrib/eager/python/examples/revnet/README.md b/tensorflow/contrib/eager/python/examples/revnet/README.md index 2875d0ffb3..822d86e9c7 100644 --- a/tensorflow/contrib/eager/python/examples/revnet/README.md +++ b/tensorflow/contrib/eager/python/examples/revnet/README.md @@ -1,6 +1,6 @@ # RevNet with TensorFlow eager execution -This folder contains a TensorFlow eager implementation of the [Reversible Residual Network](https://arxiv.org/pdf/1707.04585.pdf) adapted from the released implementation by the authors. The presented implementation can be ran both in eager and graph mode. The code is considerably simplified with `tf.GradientTape`. Moreover, we reduce the step of reconstructing the outputs. This saves us from using `tf.stop_gradient` and makes the model run faster. +This folder contains a TensorFlow eager implementation of the [Reversible Residual Network](https://arxiv.org/pdf/1707.04585.pdf) adapted from the released implementation by the authors. The presented implementation can be ran with both eager and graph execution. The code is considerably simplified with `tf.GradientTape`. Moreover, we reduce the a redundant forward pass in the implementation by the authors. This saves us from using `tf.stop_gradient` and makes the model run faster. ## Content @@ -16,7 +16,7 @@ This folder contains a TensorFlow eager implementation of the [Reversible Residu - `resnet_preprocessing.py`, `imagenet_input.py`: Boilerplate to read ImageNet data from TFRecords. ## Train on CIFAR-10/CIFAR-100 -- Make sure you have installed TensorFlow 1.9+ or the latest `tf-nightly` +- Make sure you have installed TensorFlow 1.10+ or the latest `tf-nightly` or `tf-nightly-gpu` pip package in order to access the eager execution feature. - First run @@ -41,11 +41,13 @@ python main.py --data_dir ${PWD}/cifar - `config`: RevNet configuration. - `use_defun`: Use `tfe.defun` to boost performance. -- To train a model with estimators in graph-mode, run +- To train a model with estimators in graph execution, run ```bash python main_estimator.py --data_dir ${PWD}/cifar ``` +To ensure our code works properly when using the Keras model in an estimator, +`tf-nightly` or `tf-nightly-gpu` is highly recommended as of August 2018. - Optional arguments for `main.py` include - `model_dir`: Directory to store eventfiles and checkpoints. @@ -54,13 +56,19 @@ python main_estimator.py --data_dir ${PWD}/cifar - `export`: Export the model for serving if True. ## Speed up with `tfe.defun` -Even though the speed difference between pure eager execution and graph-mode execution is noticeable, -the difference between fully "defunned" model training and graph-mode +To ensure that `tf.contrib.eager.defun` in our code works properly with all +part of the model during training, the latest `tf-nightly` or `tf-nightly-gpu` +is highly recommended as of August 2018. + +Even though the speed difference between pure eager execution and graph execution is noticeable, +the difference between fully "defunned" model training and graph training is negligible. ## Train on ImageNet with Cloud TPUs -The standard way to train models on Cloud TPUs is via TPU estimators and graph-mode +The standard way to train models on Cloud TPUs is via TPU estimators and graph execution. Models built with the `tf.keras` API are fully compatible with TPU estimators. +To ensure our code works properly in this setting, +`tf-nightly` or `tf-nightly-gpu` is highly recommended as of August 2018. ### Setup a Google Cloud project @@ -96,7 +104,8 @@ python main_estimator_tpu.py \ ``` ## Performance -- With the current implementation, RevNet-38 achieves >92% on CIFAR-10 and >71% on CIFAR-100. +- RevNet-38 achieves >92% and >71% accuracy on CIFAR-10 and CIFAR-100 respectively. +- RevNet-56 achieves <26% top-1 error rate on ImageNet. ## Reference The Reversible Residual Network: Backpropagation Without Storing Activations. -- GitLab From a8aa908df4b18bcb597080a3c6f38e86e87c5587 Mon Sep 17 00:00:00 2001 From: Saurabh Saxena Date: Wed, 8 Aug 2018 17:33:44 -0700 Subject: [PATCH 238/437] Remove identity ops for ys added during gradient computation. This was added to avoid issues with computing gradients when ys were dependent. The real issue behind that has however since been fixed so adding identity ops is no longer relevant. PiperOrigin-RevId: 207974344 --- tensorflow/python/kernel_tests/cond_v2_test.py | 18 ++++++++++++++++-- tensorflow/python/ops/cond_v2_impl.py | 2 +- tensorflow/python/ops/gradients_impl.py | 3 --- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/tensorflow/python/kernel_tests/cond_v2_test.py b/tensorflow/python/kernel_tests/cond_v2_test.py index 97ce245fc8..4d074218d1 100644 --- a/tensorflow/python/kernel_tests/cond_v2_test.py +++ b/tensorflow/python/kernel_tests/cond_v2_test.py @@ -78,6 +78,20 @@ class CondV2Test(test.TestCase): self._testCond(true_fn, false_fn, [x, y]) self._testCond(true_fn, false_fn, [y]) + def testMultipleOutputs(self): + x = constant_op.constant(1.0, name="x") + y = constant_op.constant(3.0, name="y") + + def true_fn(): + return x * y, y + + def false_fn(): + return x, y * 3.0 + + self._testCond(true_fn, false_fn, [x]) + self._testCond(true_fn, false_fn, [x, y]) + self._testCond(true_fn, false_fn, [y]) + def testBasic2(self): x = constant_op.constant(1.0, name="x") y = constant_op.constant(2.0, name="y") @@ -104,8 +118,8 @@ class CondV2Test(test.TestCase): out = cond_v2.cond_v2(pred, true_fn, false_fn) - self.assertEqual(sess.run(out, {pred: True}), [1.0]) - self.assertEqual(sess.run(out, {pred: False}), [2.0]) + self.assertEqual(sess.run(out, {pred: True}), (1.0,)) + self.assertEqual(sess.run(out, {pred: False}), (2.0,)) def _createCond(self, name): pred = constant_op.constant(True, name="pred") diff --git a/tensorflow/python/ops/cond_v2_impl.py b/tensorflow/python/ops/cond_v2_impl.py index 44c5c050c0..680632d6f8 100644 --- a/tensorflow/python/ops/cond_v2_impl.py +++ b/tensorflow/python/ops/cond_v2_impl.py @@ -132,7 +132,7 @@ def cond_v2(pred, true_fn, false_fn, name="cond"): attr_value_pb2.AttrValue(b=True)) # pylint: enable=protected-access - return tensors[:num_cond_outputs] + return tuple(tensors[:num_cond_outputs]) @ops.RegisterGradient("If") diff --git a/tensorflow/python/ops/gradients_impl.py b/tensorflow/python/ops/gradients_impl.py index b64a66be03..a68f680224 100644 --- a/tensorflow/python/ops/gradients_impl.py +++ b/tensorflow/python/ops/gradients_impl.py @@ -653,9 +653,6 @@ def _GradientsHelper(ys, # Initialize the pending count for ops in the connected subgraph from ys # to the xs. - if len(ys) > 1: - ys = [array_ops.identity(y) if _Consumers(y, func_graphs) else y - for y in ys] to_ops = [t.op for t in ys] from_ops = [t.op for t in xs] stop_gradient_ops = [t.op for t in stop_gradients] -- GitLab From 8453e23a8b65423a4f2bfb2a98a928954771498f Mon Sep 17 00:00:00 2001 From: Mingsheng Hong Date: Wed, 8 Aug 2018 18:00:05 -0700 Subject: [PATCH 239/437] Added forked versions of stateless If and While ops. They should only be used, when the if then/else body of If or the While body funcs do not have stateful ops. The are lowered to the same XLA ops. One use case is in the S4TF compiler: https://github.com/apple/swift/pull/18509 PiperOrigin-RevId: 207977126 --- tensorflow/c/c_api_function_test.cc | 61 +++++++++++++++++++ tensorflow/c/c_test_util.cc | 18 ++++++ tensorflow/c/c_test_util.h | 5 ++ tensorflow/compiler/tf2xla/kernels/if_op.cc | 1 + .../compiler/tf2xla/kernels/while_op.cc | 1 + .../base_api/api_def_StatelessIf.pbtxt | 43 +++++++++++++ .../base_api/api_def_StatelessWhile.pbtxt | 36 +++++++++++ .../python_api/api_def_StatelessIf.pbtxt | 1 + .../python_api/api_def_StatelessWhile.pbtxt | 1 + tensorflow/core/kernels/functional_ops.cc | 7 +++ tensorflow/core/ops/functional_ops.cc | 26 +++++++- 11 files changed, 198 insertions(+), 2 deletions(-) create mode 100644 tensorflow/core/api_def/base_api/api_def_StatelessIf.pbtxt create mode 100644 tensorflow/core/api_def/base_api/api_def_StatelessWhile.pbtxt create mode 100644 tensorflow/core/api_def/python_api/api_def_StatelessIf.pbtxt create mode 100644 tensorflow/core/api_def/python_api/api_def_StatelessWhile.pbtxt diff --git a/tensorflow/c/c_api_function_test.cc b/tensorflow/c/c_api_function_test.cc index bb9433ce25..73fe73769b 100644 --- a/tensorflow/c/c_api_function_test.cc +++ b/tensorflow/c/c_api_function_test.cc @@ -1619,5 +1619,66 @@ TEST_F(CApiFunctionTest, GetFunctionsFromGraph) { TF_DeleteFunction(func1); } +// This test only works when the TF build includes XLA compiler. One way to set +// this up is via bazel build option "--define with_xla_support=true". +// +// FIXME: generalize the macro name TENSORFLOW_EAGER_USE_XLA to +// something like TENSORFLOW_CAPI_USE_XLA. +#ifdef TENSORFLOW_EAGER_USE_XLA +TEST_F(CApiFunctionTest, StatelessIf_XLA) { + TF_Function* func; + const std::string funcName = "BranchFunc"; + DefineFunction(funcName.c_str(), &func); + TF_GraphCopyFunction(host_graph_, func, nullptr, s_); + ASSERT_EQ(TF_OK, TF_GetCode(s_)) << TF_Message(s_); + + TF_Operation* feed = Placeholder(host_graph_, s_); + ASSERT_EQ(TF_OK, TF_GetCode(s_)) << TF_Message(s_); + + TF_Operation* true_cond = ScalarConst(true, host_graph_, s_); + ASSERT_EQ(TF_OK, TF_GetCode(s_)) << TF_Message(s_); + + TF_OperationDescription* desc = + TF_NewOperation(host_graph_, "StatelessIf", "IfNode"); + TF_AddInput(desc, {true_cond, 0}); + TF_Output inputs[] = {{feed, 0}}; + TF_AddInputList(desc, inputs, TF_ARRAYSIZE(inputs)); + ASSERT_EQ(TF_OK, TF_GetCode(s_)) << TF_Message(s_); + TF_SetAttrType(desc, "Tcond", TF_BOOL); + TF_DataType inputType = TF_INT32; + TF_SetAttrTypeList(desc, "Tin", &inputType, 1); + TF_SetAttrTypeList(desc, "Tout", &inputType, 1); + TF_SetAttrFuncName(desc, "then_branch", funcName.data(), funcName.size()); + TF_SetAttrFuncName(desc, "else_branch", funcName.data(), funcName.size()); + TF_SetDevice(desc, "/device:XLA_CPU:0"); + auto op = TF_FinishOperation(desc, s_); + ASSERT_EQ(TF_OK, TF_GetCode(s_)) << TF_Message(s_); + ASSERT_NE(op, nullptr); + + // Create a session for this graph. + CSession csession(host_graph_, s_, /*use_XLA*/ true); + ASSERT_EQ(TF_OK, TF_GetCode(s_)) << TF_Message(s_); + + // Run the graph. + csession.SetInputs({{feed, Int32Tensor(17)}}); + csession.SetOutputs({op}); + csession.Run(s_); + ASSERT_EQ(TF_OK, TF_GetCode(s_)) << TF_Message(s_); + TF_Tensor* out = csession.output_tensor(0); + ASSERT_TRUE(out != nullptr); + EXPECT_EQ(TF_INT32, TF_TensorType(out)); + EXPECT_EQ(0, TF_NumDims(out)); // scalar + ASSERT_EQ(sizeof(int32), TF_TensorByteSize(out)); + int32* output_contents = static_cast(TF_TensorData(out)); + EXPECT_EQ(-17, *output_contents); + + // Clean up + csession.CloseAndDelete(s_); + ASSERT_EQ(TF_OK, TF_GetCode(s_)) << TF_Message(s_); + + TF_DeleteFunction(func); +} +#endif // TENSORFLOW_EAGER_USE_XLA + } // namespace } // namespace tensorflow diff --git a/tensorflow/c/c_test_util.cc b/tensorflow/c/c_test_util.cc index 24eb6c069b..f15d9ee20a 100644 --- a/tensorflow/c/c_test_util.cc +++ b/tensorflow/c/c_test_util.cc @@ -26,6 +26,10 @@ limitations under the License. using tensorflow::GraphDef; using tensorflow::NodeDef; +static void BoolDeallocator(void* data, size_t, void* arg) { + delete[] static_cast(data); +} + static void Int32Deallocator(void* data, size_t, void* arg) { delete[] static_cast(data); } @@ -38,6 +42,14 @@ static void FloatDeallocator(void* data, size_t, void* arg) { delete[] static_cast(data); } +TF_Tensor* BoolTensor(bool v) { + const int num_bytes = sizeof(bool); + bool* values = new bool[1]; + values[0] = v; + return TF_NewTensor(TF_BOOL, nullptr, 0, values, num_bytes, &BoolDeallocator, + nullptr); +} + TF_Tensor* Int8Tensor(const int64_t* dims, int num_dims, const char* values) { int64_t num_values = 1; for (int i = 0; i < num_dims; ++i) { @@ -131,6 +143,12 @@ TF_Operation* Const(TF_Tensor* t, TF_Graph* graph, TF_Status* s, return op; } +TF_Operation* ScalarConst(bool v, TF_Graph* graph, TF_Status* s, + const char* name) { + unique_tensor_ptr tensor(BoolTensor(v), TF_DeleteTensor); + return Const(tensor.get(), graph, s, name); +} + TF_Operation* ScalarConst(int32_t v, TF_Graph* graph, TF_Status* s, const char* name) { unique_tensor_ptr tensor(Int32Tensor(v), TF_DeleteTensor); diff --git a/tensorflow/c/c_test_util.h b/tensorflow/c/c_test_util.h index 38313d647c..7eeb1ee5e1 100644 --- a/tensorflow/c/c_test_util.h +++ b/tensorflow/c/c_test_util.h @@ -31,6 +31,8 @@ using ::tensorflow::string; typedef std::unique_ptr unique_tensor_ptr; +TF_Tensor* BoolTensor(int32_t v); + // Create a tensor with values of type TF_INT8 provided by `values`. TF_Tensor* Int8Tensor(const int64_t* dims, int num_dims, const char* values); @@ -55,6 +57,9 @@ TF_Operation* Placeholder(TF_Graph* graph, TF_Status* s, TF_Operation* Const(TF_Tensor* t, TF_Graph* graph, TF_Status* s, const char* name = "const"); +TF_Operation* ScalarConst(bool v, TF_Graph* graph, TF_Status* s, + const char* name = "scalar"); + TF_Operation* ScalarConst(int32_t v, TF_Graph* graph, TF_Status* s, const char* name = "scalar"); diff --git a/tensorflow/compiler/tf2xla/kernels/if_op.cc b/tensorflow/compiler/tf2xla/kernels/if_op.cc index ceb2af756c..462e0e4395 100644 --- a/tensorflow/compiler/tf2xla/kernels/if_op.cc +++ b/tensorflow/compiler/tf2xla/kernels/if_op.cc @@ -247,6 +247,7 @@ void XlaIfOp::Compile(XlaOpKernelContext* ctx) { } REGISTER_XLA_OP(Name("If").AllowResourceTypes(), XlaIfOp); +REGISTER_XLA_OP(Name("StatelessIf").AllowResourceTypes(), XlaIfOp); REGISTER_XLA_OP(Name("XlaIf").AllowResourceTypes(), XlaIfOp); } // namespace tensorflow diff --git a/tensorflow/compiler/tf2xla/kernels/while_op.cc b/tensorflow/compiler/tf2xla/kernels/while_op.cc index 1e8a376765..296518229e 100644 --- a/tensorflow/compiler/tf2xla/kernels/while_op.cc +++ b/tensorflow/compiler/tf2xla/kernels/while_op.cc @@ -301,6 +301,7 @@ void XlaWhileOp::Compile(XlaOpKernelContext* ctx) { } REGISTER_XLA_OP(Name("While").AllowResourceTypes(), XlaWhileOp); +REGISTER_XLA_OP(Name("StatelessWhile").AllowResourceTypes(), XlaWhileOp); REGISTER_XLA_OP(Name("XlaWhile").AllowResourceTypes(), XlaWhileOp); } // namespace tensorflow diff --git a/tensorflow/core/api_def/base_api/api_def_StatelessIf.pbtxt b/tensorflow/core/api_def/base_api/api_def_StatelessIf.pbtxt new file mode 100644 index 0000000000..c0a6ba15e6 --- /dev/null +++ b/tensorflow/core/api_def/base_api/api_def_StatelessIf.pbtxt @@ -0,0 +1,43 @@ +op { + graph_op_name: "StatelessIf" + in_arg { name: "cond" description: "The predicate." } + in_arg { + name: "cond" + description: <
\n", - "\n", - " Run in Google Colab \n", - "\n", - "View source on GitHub
" + "\u003ctable class=\"tfo-notebook-buttons\" align=\"left\"\u003e\u003ctd\u003e\n", + "\u003ca target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/tensorflow/blob/master/tensorflow/contrib/eager/python/examples/nmt_with_attention/nmt_with_attention.ipynb\"\u003e\n", + " \u003cimg src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" /\u003eRun in Google Colab\u003c/a\u003e \n", + "\u003c/td\u003e\u003ctd\u003e\n", + "\u003ca target=\"_blank\" href=\"https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/eager/python/examples/nmt_with_attention/nmt_with_attention.ipynb\"\u003e\u003cimg width=32px src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\" /\u003eView source on GitHub\u003c/a\u003e\u003c/td\u003e\u003c/table\u003e" ] }, { + "cell_type": "markdown", "metadata": { - "id": "CiwtNgENbx2g", - "colab_type": "text" + "colab_type": "text", + "id": "CiwtNgENbx2g" }, - "cell_type": "markdown", "source": [ "This notebook trains a sequence to sequence (seq2seq) model for Spanish to English translation using [tf.keras](https://www.tensorflow.org/programmers_guide/keras) and [eager execution](https://www.tensorflow.org/programmers_guide/eager). This is an advanced example that assumes some knowledge of sequence to sequence models.\n", "\n", @@ -61,27 +33,24 @@ "\n", "The translation quality is reasonable for a toy example, but the generated attention plot is perhaps more interesting. This shows which parts of the input sentence has the model's attention while translating:\n", "\n", - "\"spanish-english\n", + "\u003cimg src=\"https://tensorflow.org/images/spanish-english.png\" alt=\"spanish-english attention plot\"\u003e\n", "\n", "Note: This example takes approximately 10 mintues to run on a single P100 GPU." ] }, { + "cell_type": "code", + "execution_count": 0, "metadata": { - "id": "tnxXKDjq3jEL", + "colab": {}, "colab_type": "code", - "colab": { - "autoexec": { - "startup": false, - "wait_interval": 0 - } - } + "id": "tnxXKDjq3jEL" }, - "cell_type": "code", + "outputs": [], "source": [ "from __future__ import absolute_import, division, print_function\n", "\n", - "# Import TensorFlow >= 1.9 and enable eager execution\n", + "# Import TensorFlow \u003e= 1.10 and enable eager execution\n", "import tensorflow as tf\n", "\n", "tf.enable_eager_execution()\n", @@ -96,16 +65,14 @@ "import time\n", "\n", "print(tf.__version__)" - ], - "execution_count": 0, - "outputs": [] + ] }, { + "cell_type": "markdown", "metadata": { - "id": "wfodePkj3jEa", - "colab_type": "text" + "colab_type": "text", + "id": "wfodePkj3jEa" }, - "cell_type": "markdown", "source": [ "## Download and prepare the dataset\n", "\n", @@ -124,17 +91,14 @@ ] }, { + "cell_type": "code", + "execution_count": 0, "metadata": { - "id": "kRVATYOgJs1b", + "colab": {}, "colab_type": "code", - "colab": { - "autoexec": { - "startup": false, - "wait_interval": 0 - } - } + "id": "kRVATYOgJs1b" }, - "cell_type": "code", + "outputs": [], "source": [ "# Download the file\n", "path_to_zip = tf.keras.utils.get_file(\n", @@ -142,22 +106,17 @@ " extract=True)\n", "\n", "path_to_file = os.path.dirname(path_to_zip)+\"/spa-eng/spa.txt\"" - ], - "execution_count": 0, - "outputs": [] + ] }, { + "cell_type": "code", + "execution_count": 0, "metadata": { - "id": "rd0jw-eC3jEh", + "colab": {}, "colab_type": "code", - "colab": { - "autoexec": { - "startup": false, - "wait_interval": 0 - } - } + "id": "rd0jw-eC3jEh" }, - "cell_type": "code", + "outputs": [], "source": [ "# Converts the unicode file to ascii\n", "def unicode_to_ascii(s):\n", @@ -169,7 +128,7 @@ " w = unicode_to_ascii(w.lower().strip())\n", " \n", " # creating a space between a word and the punctuation following it\n", - " # eg: \"he is a boy.\" => \"he is a boy .\" \n", + " # eg: \"he is a boy.\" =\u003e \"he is a boy .\" \n", " # Reference:- https://stackoverflow.com/questions/3645931/python-padding-punctuation-with-white-spaces-keeping-punctuation\n", " w = re.sub(r\"([?.!,¿])\", r\" \\1 \", w)\n", " w = re.sub(r'[\" \"]+', \" \", w)\n", @@ -181,24 +140,19 @@ " \n", " # adding a start and an end token to the sentence\n", " # so that the model know when to start and stop predicting.\n", - " w = ' ' + w + ' '\n", + " w = '\u003cstart\u003e ' + w + ' \u003cend\u003e'\n", " return w" - ], - "execution_count": 0, - "outputs": [] + ] }, { + "cell_type": "code", + "execution_count": 0, "metadata": { - "id": "OHn4Dct23jEm", + "colab": {}, "colab_type": "code", - "colab": { - "autoexec": { - "startup": false, - "wait_interval": 0 - } - } + "id": "OHn4Dct23jEm" }, - "cell_type": "code", + "outputs": [], "source": [ "# 1. Remove the accents\n", "# 2. Clean the sentences\n", @@ -209,25 +163,20 @@ " word_pairs = [[preprocess_sentence(w) for w in l.split('\\t')] for l in lines[:num_examples]]\n", " \n", " return word_pairs" - ], - "execution_count": 0, - "outputs": [] + ] }, { + "cell_type": "code", + "execution_count": 0, "metadata": { - "id": "9xbqO7Iie9bb", + "colab": {}, "colab_type": "code", - "colab": { - "autoexec": { - "startup": false, - "wait_interval": 0 - } - } + "id": "9xbqO7Iie9bb" }, - "cell_type": "code", + "outputs": [], "source": [ - "# This class creates a word -> index mapping (e.g,. \"dad\" -> 5) and vice-versa \n", - "# (e.g., 5 -> \"dad\") for each language,\n", + "# This class creates a word -\u003e index mapping (e.g,. \"dad\" -\u003e 5) and vice-versa \n", + "# (e.g., 5 -\u003e \"dad\") for each language,\n", "class LanguageIndex():\n", " def __init__(self, lang):\n", " self.lang = lang\n", @@ -243,28 +192,23 @@ " \n", " self.vocab = sorted(self.vocab)\n", " \n", - " self.word2idx[''] = 0\n", + " self.word2idx['\u003cpad\u003e'] = 0\n", " for index, word in enumerate(self.vocab):\n", " self.word2idx[word] = index + 1\n", " \n", " for word, index in self.word2idx.items():\n", " self.idx2word[index] = word" - ], - "execution_count": 0, - "outputs": [] + ] }, { + "cell_type": "code", + "execution_count": 0, "metadata": { - "id": "eAY9k49G3jE_", + "colab": {}, "colab_type": "code", - "colab": { - "autoexec": { - "startup": false, - "wait_interval": 0 - } - } + "id": "eAY9k49G3jE_" }, - "cell_type": "code", + "outputs": [], "source": [ "def max_length(tensor):\n", " return max(len(t) for t in tensor)\n", @@ -300,86 +244,71 @@ " padding='post')\n", " \n", " return input_tensor, target_tensor, inp_lang, targ_lang, max_length_inp, max_length_tar" - ], - "execution_count": 0, - "outputs": [] + ] }, { + "cell_type": "markdown", "metadata": { - "id": "GOi42V79Ydlr", - "colab_type": "text" + "colab_type": "text", + "id": "GOi42V79Ydlr" }, - "cell_type": "markdown", "source": [ "### Limit the size of the dataset to experiment faster (optional)\n", "\n", - "Training on the complete dataset of >100,000 sentences will take a long time. To train faster, we can limit the size of the dataset to 30,000 sentences (of course, translation quality degrades with less data):" + "Training on the complete dataset of \u003e100,000 sentences will take a long time. To train faster, we can limit the size of the dataset to 30,000 sentences (of course, translation quality degrades with less data):" ] }, { + "cell_type": "code", + "execution_count": 0, "metadata": { - "id": "cnxC7q-j3jFD", + "colab": {}, "colab_type": "code", - "colab": { - "autoexec": { - "startup": false, - "wait_interval": 0 - } - } + "id": "cnxC7q-j3jFD" }, - "cell_type": "code", + "outputs": [], "source": [ "# Try experimenting with the size of that dataset\n", "num_examples = 30000\n", "input_tensor, target_tensor, inp_lang, targ_lang, max_length_inp, max_length_targ = load_dataset(path_to_file, num_examples)" - ], - "execution_count": 0, - "outputs": [] + ] }, { + "cell_type": "code", + "execution_count": 0, "metadata": { - "id": "4QILQkOs3jFG", + "colab": {}, "colab_type": "code", - "colab": { - "autoexec": { - "startup": false, - "wait_interval": 0 - } - } + "id": "4QILQkOs3jFG" }, - "cell_type": "code", + "outputs": [], "source": [ "# Creating training and validation sets using an 80-20 split\n", "input_tensor_train, input_tensor_val, target_tensor_train, target_tensor_val = train_test_split(input_tensor, target_tensor, test_size=0.2)\n", "\n", "# Show length\n", "len(input_tensor_train), len(target_tensor_train), len(input_tensor_val), len(target_tensor_val)" - ], - "execution_count": 0, - "outputs": [] + ] }, { + "cell_type": "markdown", "metadata": { - "id": "rgCLkfv5uO3d", - "colab_type": "text" + "colab_type": "text", + "id": "rgCLkfv5uO3d" }, - "cell_type": "markdown", "source": [ "### Create a tf.data dataset" ] }, { + "cell_type": "code", + "execution_count": 0, "metadata": { - "id": "TqHsArVZ3jFS", + "colab": {}, "colab_type": "code", - "colab": { - "autoexec": { - "startup": false, - "wait_interval": 0 - } - } + "id": "TqHsArVZ3jFS" }, - "cell_type": "code", + "outputs": [], "source": [ "BUFFER_SIZE = len(input_tensor_train)\n", "BATCH_SIZE = 64\n", @@ -391,29 +320,27 @@ "\n", "dataset = tf.data.Dataset.from_tensor_slices((input_tensor_train, target_tensor_train)).shuffle(BUFFER_SIZE)\n", "dataset = dataset.apply(tf.contrib.data.batch_and_drop_remainder(BATCH_SIZE))" - ], - "execution_count": 0, - "outputs": [] + ] }, { + "cell_type": "markdown", "metadata": { - "id": "TNfHIF71ulLu", - "colab_type": "text" + "colab_type": "text", + "id": "TNfHIF71ulLu" }, - "cell_type": "markdown", "source": [ "## Write the encoder and decoder model\n", "\n", "Here, we'll implement an encoder-decoder model with attention which you can read about in the TensorFlow [Neural Machine Translation (seq2seq) tutorial](https://www.tensorflow.org/tutorials/seq2seq). This example uses a more recent set of APIs. This notebook implements the [attention equations](https://www.tensorflow.org/tutorials/seq2seq#background_on_the_attention_mechanism) from the seq2seq tutorial. The following diagram shows that each input words is assigned a weight by the attention mechanism which is then used by the decoder to predict the next word in the sentence.\n", "\n", - "\"attention\n", + "\u003cimg src=\"https://www.tensorflow.org/images/seq2seq/attention_mechanism.jpg\" width=\"500\" alt=\"attention mechanism\"\u003e\n", "\n", "The input is put through an encoder model which gives us the encoder output of shape *(batch_size, max_length, hidden_size)* and the encoder hidden state of shape *(batch_size, hidden_size)*. \n", "\n", "Here are the equations that are implemented:\n", "\n", - "\"attention\n", - "\"attention\n", + "\u003cimg src=\"https://www.tensorflow.org/images/seq2seq/attention_equation_0.jpg\" alt=\"attention equation 0\" width=\"800\"\u003e\n", + "\u003cimg src=\"https://www.tensorflow.org/images/seq2seq/attention_equation_1.jpg\" alt=\"attention equation 1\" width=\"800\"\u003e\n", "\n", "We're using *Bahdanau attention*. Lets decide on notation before writing the simplified form:\n", "\n", @@ -435,17 +362,14 @@ ] }, { + "cell_type": "code", + "execution_count": 0, "metadata": { - "id": "avyJ_4VIUoHb", + "colab": {}, "colab_type": "code", - "colab": { - "autoexec": { - "startup": false, - "wait_interval": 0 - } - } + "id": "avyJ_4VIUoHb" }, - "cell_type": "code", + "outputs": [], "source": [ "def gru(units):\n", " # If you have a GPU, we recommend using CuDNNGRU(provides a 3x speedup than GRU)\n", @@ -461,22 +385,17 @@ " return_state=True, \n", " recurrent_activation='sigmoid', \n", " recurrent_initializer='glorot_uniform')" - ], - "execution_count": 0, - "outputs": [] + ] }, { + "cell_type": "code", + "execution_count": 0, "metadata": { - "id": "nZ2rI24i3jFg", + "colab": {}, "colab_type": "code", - "colab": { - "autoexec": { - "startup": false, - "wait_interval": 0 - } - } + "id": "nZ2rI24i3jFg" }, - "cell_type": "code", + "outputs": [], "source": [ "class Encoder(tf.keras.Model):\n", " def __init__(self, vocab_size, embedding_dim, enc_units, batch_sz):\n", @@ -493,22 +412,17 @@ " \n", " def initialize_hidden_state(self):\n", " return tf.zeros((self.batch_sz, self.enc_units))" - ], - "execution_count": 0, - "outputs": [] + ] }, { + "cell_type": "code", + "execution_count": 0, "metadata": { - "id": "yJ_B3mhW3jFk", + "colab": {}, "colab_type": "code", - "colab": { - "autoexec": { - "startup": false, - "wait_interval": 0 - } - } + "id": "yJ_B3mhW3jFk" }, - "cell_type": "code", + "outputs": [], "source": [ "class Decoder(tf.keras.Model):\n", " def __init__(self, vocab_size, embedding_dim, dec_units, batch_sz):\n", @@ -562,51 +476,41 @@ " \n", " def initialize_hidden_state(self):\n", " return tf.zeros((self.batch_sz, self.dec_units))" - ], - "execution_count": 0, - "outputs": [] + ] }, { + "cell_type": "code", + "execution_count": 0, "metadata": { - "id": "P5UY8wko3jFp", + "colab": {}, "colab_type": "code", - "colab": { - "autoexec": { - "startup": false, - "wait_interval": 0 - } - } + "id": "P5UY8wko3jFp" }, - "cell_type": "code", + "outputs": [], "source": [ "encoder = Encoder(vocab_inp_size, embedding_dim, units, BATCH_SIZE)\n", "decoder = Decoder(vocab_tar_size, embedding_dim, units, BATCH_SIZE)" - ], - "execution_count": 0, - "outputs": [] + ] }, { + "cell_type": "markdown", "metadata": { - "id": "_ch_71VbIRfK", - "colab_type": "text" + "colab_type": "text", + "id": "_ch_71VbIRfK" }, - "cell_type": "markdown", "source": [ "## Define the optimizer and the loss function" ] }, { + "cell_type": "code", + "execution_count": 0, "metadata": { - "id": "WmTHr5iV3jFr", + "colab": {}, "colab_type": "code", - "colab": { - "autoexec": { - "startup": false, - "wait_interval": 0 - } - } + "id": "WmTHr5iV3jFr" }, - "cell_type": "code", + "outputs": [], "source": [ "optimizer = tf.train.AdamOptimizer()\n", "\n", @@ -615,16 +519,41 @@ " mask = 1 - np.equal(real, 0)\n", " loss_ = tf.nn.sparse_softmax_cross_entropy_with_logits(labels=real, logits=pred) * mask\n", " return tf.reduce_mean(loss_)" - ], - "execution_count": 0, - "outputs": [] + ] }, { + "cell_type": "markdown", "metadata": { - "id": "hpObfY22IddU", - "colab_type": "text" + "colab_type": "text", + "id": "DMVWzzsfNl4e" }, + "source": [ + "## Checkpoints (Object-based saving)" + ] + }, + { + "cell_type": "code", + "execution_count": 0, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "Zj8bXQTgNwrF" + }, + "outputs": [], + "source": [ + "checkpoint_dir = './training_checkpoints'\n", + "checkpoint_prefix = os.path.join(checkpoint_dir, \"ckpt\")\n", + "checkpoint = tf.train.Checkpoint(optimizer=optimizer,\n", + " encoder=encoder,\n", + " decoder=decoder)" + ] + }, + { "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "hpObfY22IddU" + }, "source": [ "## Training\n", "\n", @@ -638,17 +567,14 @@ ] }, { + "cell_type": "code", + "execution_count": 0, "metadata": { - "id": "ddefjBMa3jF0", + "colab": {}, "colab_type": "code", - "colab": { - "autoexec": { - "startup": false, - "wait_interval": 0 - } - } + "id": "ddefjBMa3jF0" }, - "cell_type": "code", + "outputs": [], "source": [ "EPOCHS = 10\n", "\n", @@ -666,7 +592,7 @@ " \n", " dec_hidden = enc_hidden\n", " \n", - " dec_input = tf.expand_dims([targ_lang.word2idx['']] * BATCH_SIZE, 1) \n", + " dec_input = tf.expand_dims([targ_lang.word2idx['\u003cstart\u003e']] * BATCH_SIZE, 1) \n", " \n", " # Teacher forcing - feeding the target as the next input\n", " for t in range(1, targ.shape[1]):\n", @@ -686,26 +612,27 @@ " \n", " gradients = tape.gradient(loss, variables)\n", " \n", - " optimizer.apply_gradients(zip(gradients, variables), tf.train.get_or_create_global_step())\n", + " optimizer.apply_gradients(zip(gradients, variables))\n", " \n", " if batch % 100 == 0:\n", " print('Epoch {} Batch {} Loss {:.4f}'.format(epoch + 1,\n", " batch,\n", " batch_loss.numpy()))\n", + " # saving (checkpoint) the model every 2 epochs\n", + " if epoch % 2 == 0:\n", + " checkpoint.save(file_prefix = checkpoint_prefix)\n", " \n", " print('Epoch {} Loss {:.4f}'.format(epoch + 1,\n", " total_loss / N_BATCH))\n", " print('Time taken for 1 epoch {} sec\\n'.format(time.time() - start))" - ], - "execution_count": 0, - "outputs": [] + ] }, { + "cell_type": "markdown", "metadata": { - "id": "mU3Ce8M6I3rz", - "colab_type": "text" + "colab_type": "text", + "id": "mU3Ce8M6I3rz" }, - "cell_type": "markdown", "source": [ "## Translate\n", "\n", @@ -717,17 +644,14 @@ ] }, { + "cell_type": "code", + "execution_count": 0, "metadata": { - "id": "EbQpyYs13jF_", + "colab": {}, "colab_type": "code", - "colab": { - "autoexec": { - "startup": false, - "wait_interval": 0 - } - } + "id": "EbQpyYs13jF_" }, - "cell_type": "code", + "outputs": [], "source": [ "def evaluate(sentence, encoder, decoder, inp_lang, targ_lang, max_length_inp, max_length_targ):\n", " attention_plot = np.zeros((max_length_targ, max_length_inp))\n", @@ -744,7 +668,7 @@ " enc_out, enc_hidden = encoder(inputs, hidden)\n", "\n", " dec_hidden = enc_hidden\n", - " dec_input = tf.expand_dims([targ_lang.word2idx['']], 0)\n", + " dec_input = tf.expand_dims([targ_lang.word2idx['\u003cstart\u003e']], 0)\n", "\n", " for t in range(max_length_targ):\n", " predictions, dec_hidden, attention_weights = decoder(dec_input, dec_hidden, enc_out)\n", @@ -757,29 +681,24 @@ "\n", " result += targ_lang.idx2word[predicted_id] + ' '\n", "\n", - " if targ_lang.idx2word[predicted_id] == '':\n", + " if targ_lang.idx2word[predicted_id] == '\u003cend\u003e':\n", " return result, sentence, attention_plot\n", " \n", " # the predicted ID is fed back into the model\n", " dec_input = tf.expand_dims([predicted_id], 0)\n", "\n", " return result, sentence, attention_plot" - ], - "execution_count": 0, - "outputs": [] + ] }, { + "cell_type": "code", + "execution_count": 0, "metadata": { - "id": "s5hQWlbN3jGF", + "colab": {}, "colab_type": "code", - "colab": { - "autoexec": { - "startup": false, - "wait_interval": 0 - } - } + "id": "s5hQWlbN3jGF" }, - "cell_type": "code", + "outputs": [], "source": [ "# function for plotting the attention weights\n", "def plot_attention(attention, sentence, predicted_sentence):\n", @@ -793,22 +712,17 @@ " ax.set_yticklabels([''] + predicted_sentence, fontdict=fontdict)\n", "\n", " plt.show()" - ], - "execution_count": 0, - "outputs": [] + ] }, { + "cell_type": "code", + "execution_count": 0, "metadata": { - "id": "sl9zUHzg3jGI", + "colab": {}, "colab_type": "code", - "colab": { - "autoexec": { - "startup": false, - "wait_interval": 0 - } - } + "id": "sl9zUHzg3jGI" }, - "cell_type": "code", + "outputs": [], "source": [ "def translate(sentence, encoder, decoder, inp_lang, targ_lang, max_length_inp, max_length_targ):\n", " result, sentence, attention_plot = evaluate(sentence, encoder, decoder, inp_lang, targ_lang, max_length_inp, max_length_targ)\n", @@ -818,89 +732,91 @@ " \n", " attention_plot = attention_plot[:len(result.split(' ')), :len(sentence.split(' '))]\n", " plot_attention(attention_plot, sentence.split(' '), result.split(' '))" - ], - "execution_count": 0, - "outputs": [] + ] }, { + "cell_type": "markdown", "metadata": { - "id": "WrAM0FDomq3E", + "colab_type": "text", + "id": "n250XbnjOaqP" + }, + "source": [ + "## Restore the latest checkpoint and test" + ] + }, + { + "cell_type": "code", + "execution_count": 0, + "metadata": { + "colab": {}, "colab_type": "code", - "colab": { - "autoexec": { - "startup": false, - "wait_interval": 0 - } - } + "id": "UJpT9D5_OgP6" }, + "outputs": [], + "source": [ + "# restoring the latest checkpoint in checkpoint_dir\n", + "checkpoint.restore(tf.train.latest_checkpoint(checkpoint_dir))" + ] + }, + { "cell_type": "code", + "execution_count": 0, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "WrAM0FDomq3E" + }, + "outputs": [], "source": [ "translate('hace mucho frio aqui.', encoder, decoder, inp_lang, targ_lang, max_length_inp, max_length_targ)" - ], - "execution_count": 0, - "outputs": [] + ] }, { + "cell_type": "code", + "execution_count": 0, "metadata": { - "id": "zSx2iM36EZQZ", + "colab": {}, "colab_type": "code", - "colab": { - "autoexec": { - "startup": false, - "wait_interval": 0 - } - } + "id": "zSx2iM36EZQZ" }, - "cell_type": "code", + "outputs": [], "source": [ "translate('esta es mi vida.', encoder, decoder, inp_lang, targ_lang, max_length_inp, max_length_targ)" - ], - "execution_count": 0, - "outputs": [] + ] }, { + "cell_type": "code", + "execution_count": 0, "metadata": { - "id": "A3LLCx3ZE0Ls", + "colab": {}, "colab_type": "code", - "colab": { - "autoexec": { - "startup": false, - "wait_interval": 0 - } - } + "id": "A3LLCx3ZE0Ls" }, - "cell_type": "code", + "outputs": [], "source": [ "translate('¿todavia estan en casa?', encoder, decoder, inp_lang, targ_lang, max_length_inp, max_length_targ)" - ], - "execution_count": 0, - "outputs": [] + ] }, { + "cell_type": "code", + "execution_count": 0, "metadata": { - "id": "DUQVLVqUE1YW", + "colab": {}, "colab_type": "code", - "colab": { - "autoexec": { - "startup": false, - "wait_interval": 0 - } - } + "id": "DUQVLVqUE1YW" }, - "cell_type": "code", + "outputs": [], "source": [ "# wrong translation\n", "translate('trata de averiguarlo.', encoder, decoder, inp_lang, targ_lang, max_length_inp, max_length_targ)" - ], - "execution_count": 0, - "outputs": [] + ] }, { + "cell_type": "markdown", "metadata": { - "id": "RTe5P5ioMJwN", - "colab_type": "text" + "colab_type": "text", + "id": "RTe5P5ioMJwN" }, - "cell_type": "markdown", "source": [ "## Next steps\n", "\n", @@ -908,5 +824,31 @@ "* Experiment with training on a larger dataset, or using more epochs\n" ] } - ] + ], + "metadata": { + "accelerator": "GPU", + "colab": { + "collapsed_sections": [], + "name": "nmt_with_attention.ipynb", + "private_outputs": true, + "provenance": [ + { + "file_id": "1C4fpM7_7IL8ZzF7Gc5abywqQjeQNS2-U", + "timestamp": 1527858391290 + }, + { + "file_id": "1pExo6aUuw0S6MISFWoinfJv0Ftm9V4qv", + "timestamp": 1527776041613 + } + ], + "toc_visible": true, + "version": "0.3.2" + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 } diff --git a/tensorflow/contrib/eager/python/examples/pix2pix/pix2pix_eager.ipynb b/tensorflow/contrib/eager/python/examples/pix2pix/pix2pix_eager.ipynb index 6a0a1335ca..acc0f5b653 100644 --- a/tensorflow/contrib/eager/python/examples/pix2pix/pix2pix_eager.ipynb +++ b/tensorflow/contrib/eager/python/examples/pix2pix/pix2pix_eager.ipynb @@ -60,7 +60,7 @@ }, "outputs": [], "source": [ - "# Import TensorFlow \u003e= 1.9 and enable eager execution\n", + "# Import TensorFlow \u003e= 1.10 and enable eager execution\n", "import tensorflow as tf\n", "tf.enable_eager_execution()\n", "\n", @@ -565,6 +565,34 @@ "discriminator_optimizer = tf.train.AdamOptimizer(2e-4, beta1=0.5)" ] }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "aKUZnDiqQrAh" + }, + "source": [ + "## Checkpoints (Object-based saving)" + ] + }, + { + "cell_type": "code", + "execution_count": 0, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "WJnftd5sQsv6" + }, + "outputs": [], + "source": [ + "checkpoint_dir = './training_checkpoints'\n", + "checkpoint_prefix = os.path.join(checkpoint_dir, \"ckpt\")\n", + "checkpoint = tf.train.Checkpoint(generator_optimizer=generator_optimizer,\n", + " discriminator_optimizer=discriminator_optimizer,\n", + " generator=generator,\n", + " discriminator=discriminator)" + ] + }, { "cell_type": "markdown", "metadata": { @@ -671,6 +699,10 @@ " clear_output(wait=True)\n", " for inp, tar in test_dataset.take(1):\n", " generate_images(generator, inp, tar)\n", + " \n", + " # saving (checkpoint) the model every 20 epochs\n", + " if epoch % 20 == 0:\n", + " checkpoint.save(file_prefix = checkpoint_prefix)\n", "\n", " print ('Time taken for epoch {} is {} sec\\n'.format(epoch + 1,\n", " time.time()-start))" @@ -689,6 +721,30 @@ "train(train_dataset, EPOCHS)" ] }, + { + "cell_type": "markdown", + "metadata": { + "colab_type": "text", + "id": "kz80bY3aQ1VZ" + }, + "source": [ + "## Restore the latest checkpoint and test" + ] + }, + { + "cell_type": "code", + "execution_count": 0, + "metadata": { + "colab": {}, + "colab_type": "code", + "id": "4t4x69adQ5xb" + }, + "outputs": [], + "source": [ + "# restoring the latest checkpoint in checkpoint_dir\n", + "checkpoint.restore(tf.train.latest_checkpoint(checkpoint_dir))" + ] + }, { "cell_type": "markdown", "metadata": { -- GitLab From a578153a0aeb9a2350992bdf7b35fcea671cacca Mon Sep 17 00:00:00 2001 From: Josh Gordon Date: Fri, 10 Aug 2018 13:29:03 -0700 Subject: [PATCH 352/437] Adding additional example for tf.keras and eager execution. PiperOrigin-RevId: 208258892 --- tensorflow/docs_src/tutorials/_toc.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tensorflow/docs_src/tutorials/_toc.yaml b/tensorflow/docs_src/tutorials/_toc.yaml index d33869af6e..0e25208a00 100644 --- a/tensorflow/docs_src/tutorials/_toc.yaml +++ b/tensorflow/docs_src/tutorials/_toc.yaml @@ -37,9 +37,30 @@ toc: status: external - title: "Custom training: walkthrough" path: /tutorials/eager/custom_training_walkthrough + - title: Text generation + path: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/eager/python/examples/generative_examples/text_generation.ipynb + status: external - title: Translation with attention path: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/eager/python/examples/nmt_with_attention/nmt_with_attention.ipynb status: external + - title: Image captioning + path: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/eager/python/examples/generative_examples/image_captioning_with_attention.ipynb + status: external + - title: Neural Style Transfer + path: https://github.com/tensorflow/models/blob/master/research/nst_blogpost/4_Neural_Style_Transfer_with_Eager_Execution.ipynb + status: external + - title: DCGAN + path: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/eager/python/examples/generative_examples/dcgan.ipynb + status: external + - title: VAE + path: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/eager/python/examples/generative_examples/cvae.ipynb + status: external + - title: Pix2Pix + path: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/eager/python/examples/pix2pix/pix2pix_eager.ipynb + status: external + - title: Image Segmentation + path: https://github.com/tensorflow/models/blob/master/samples/outreach/blogs/segmentation_blogpost/image_segmentation.ipynb + status: external - title: ML at production scale style: accordion -- GitLab From 79c95b754c241afe3dab741a895ffdbb9646bd65 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Fri, 10 Aug 2018 13:37:39 -0700 Subject: [PATCH 353/437] Consolidate logic for configuring Keras Callbacks across different training loops. PiperOrigin-RevId: 208260082 --- tensorflow/python/keras/callbacks.py | 106 +++++++++++++++++- tensorflow/python/keras/callbacks_test.py | 4 + tensorflow/python/keras/engine/training.py | 16 ++- .../python/keras/engine/training_arrays.py | 93 ++++----------- .../keras/engine/training_distributed.py | 65 +++-------- .../python/keras/engine/training_eager.py | 105 ++++------------- .../python/keras/engine/training_generator.py | 73 ++++-------- 7 files changed, 205 insertions(+), 257 deletions(-) diff --git a/tensorflow/python/keras/callbacks.py b/tensorflow/python/keras/callbacks.py index 070d41147d..3e112b3132 100644 --- a/tensorflow/python/keras/callbacks.py +++ b/tensorflow/python/keras/callbacks.py @@ -22,6 +22,7 @@ from __future__ import print_function from collections import deque from collections import Iterable from collections import OrderedDict +import copy import csv import json import math @@ -31,10 +32,12 @@ import time import numpy as np import six +from tensorflow.python.data.ops import iterator_ops from tensorflow.python.eager import context from tensorflow.python.framework import dtypes from tensorflow.python.keras import backend as K from tensorflow.python.keras.engine.training_utils import standardize_input_data +from tensorflow.python.keras.utils.data_utils import Sequence from tensorflow.python.keras.utils.generic_utils import Progbar from tensorflow.python.ops import array_ops from tensorflow.python.ops import state_ops @@ -52,6 +55,103 @@ except ImportError: requests = None +def configure_callbacks(callbacks, + model, + do_validation=False, + val_inputs=None, + val_targets=None, + val_sample_weights=None, + batch_size=None, + epochs=None, + steps_per_epoch=None, + samples=None, + validation_steps=None, + verbose=1, + count_mode='steps'): + """Configures callbacks for use in various training loops. + + Arguments: + callbacks: List of Callbacks. + model: Model being trained. + do_validation: Whether or not validation loop will be run. + val_inputs: Inputs to Model for validation loop. Can be any + data format Keras accepts. + val_targets: Targets for Model for validation loop. Can be any + data format Keras accepts. + val_sample_weights: Sample weights for Model for validation loop. + Can be any data format Keras accepts. + batch_size: Number of samples per batch. + epochs: Number of epoch to train. + steps_per_epoch: Number of batches to run per training epoch. + samples: Number of training samples. + validation_steps: Number of batches to run per validation epoch. + verbose: int, 0 or 1. Keras logging verbosity to pass to ProgbarLogger. + count_mode: One of 'steps' or 'samples'. Per-batch or per-sample count. + + Returns: + Instance of CallbackList used to control all Callbacks. + """ + + # Add additional callbacks + model.history = History() + callbacks = [BaseLogger()] + (callbacks or []) + [model.history] + if verbose: + callbacks.append(ProgbarLogger(count_mode)) + callback_list = CallbackList(callbacks) + + # Set callback model + callback_model = model._get_callback_model() # pylint: disable=protected-access + if do_validation and val_inputs and not context.executing_eagerly(): + # Need to create the test_function before start of the first epoch + # because TensorBoard callback on_epoch_begin adds summary to the + # list of fetches of the test_function + callback_model._make_test_function() # pylint: disable=protected-access + callback_list.set_model(callback_model) + + # Set callback parameters + callback_metrics = [] + if model._is_compiled: # pylint: disable=protected-access + callback_metrics = copy.copy(model.metrics_names) + if do_validation: + callback_metrics += ['val_' + n for n in model.metrics_names] + if validation_steps is None and isinstance(val_inputs, Sequence): + validation_steps = len(val_inputs) + callback_params = { + 'batch_size': batch_size, + 'epochs': epochs, + 'steps': steps_per_epoch, + 'samples': samples, + 'verbose': verbose, + 'do_validation': do_validation, + 'metrics': callback_metrics, + 'validation_steps': validation_steps + } + callback_list.set_params(callback_params) + + # Pass validation data to callbacks + if not val_inputs: + val_data = [] + elif _is_generator_like(val_inputs): + val_data = val_inputs + else: + val_data = val_inputs + val_targets + if val_sample_weights: + val_data += val_sample_weights + if model.uses_learning_phase and not isinstance(K.learning_phase(), int): + val_data += [0.] + for cbk in callbacks: + cbk.validation_data = val_data + + callback_list.model.stop_training = False + return callback_list + + +def _is_generator_like(data): + """Checks if data is a generator, Sequence, or Iterator.""" + return (hasattr(data, 'next') or hasattr(data, '__next__') or isinstance( + data, (Sequence, iterator_ops.Iterator, iterator_ops.EagerIterator))) + + class CallbackList(object): """Container abstracting a list of callbacks. @@ -65,15 +165,19 @@ class CallbackList(object): callbacks = callbacks or [] self.callbacks = [c for c in callbacks] self.queue_length = queue_length + self.params = {} + self.model = None def append(self, callback): self.callbacks.append(callback) def set_params(self, params): + self.params = params for callback in self.callbacks: callback.set_params(params) def set_model(self, model): + self.model = model for callback in self.callbacks: callback.set_model(model) @@ -939,7 +1043,7 @@ class TensorBoard(Callback): """Checks if histogram summaries can be run.""" # will never be set when in eager if self.histogram_freq: - if 'validation_steps' in self.params: + if self.params.get('validation_steps', None) is not None: self._validation_batches = self.params['validation_steps'] elif self.validation_data: self._validation_batches = math.ceil( diff --git a/tensorflow/python/keras/callbacks_test.py b/tensorflow/python/keras/callbacks_test.py index bd088a559c..e84e023384 100644 --- a/tensorflow/python/keras/callbacks_test.py +++ b/tensorflow/python/keras/callbacks_test.py @@ -728,6 +728,8 @@ class KerasCallbacksTest(test.TestCase): verbose=0) # fit generator without validation data + # histogram_freq must be zero + tsb.histogram_freq = 0 model.fit_generator( data_generator(True), len(x_train), @@ -736,6 +738,7 @@ class KerasCallbacksTest(test.TestCase): verbose=0) # fit generator with validation data and accuracy + tsb.histogram_freq = 1 model.fit_generator( data_generator(True), len(x_train), @@ -745,6 +748,7 @@ class KerasCallbacksTest(test.TestCase): verbose=0) # fit generator without validation data and accuracy + tsb.histogram_freq = 0 model.fit_generator( data_generator(True), len(x_train), epochs=2, callbacks=cbks) assert os.path.exists(temp_dir) diff --git a/tensorflow/python/keras/engine/training.py b/tensorflow/python/keras/engine/training.py index ac6b8e295b..28ced47b0f 100644 --- a/tensorflow/python/keras/engine/training.py +++ b/tensorflow/python/keras/engine/training.py @@ -2030,6 +2030,21 @@ class Model(Network): use_multiprocessing=use_multiprocessing, verbose=verbose) + def _get_callback_model(self): + """Returns the Callback Model for this Model.""" + + if hasattr(self, '_replicated_model') and self._replicated_model: + # When using training_distributed, we set the callback model + # to an instance of the `DistributedModel` that we create in + # the `compile` call. The `DistributedModel` is initialized + # with the first replicated model. We need to set the callback + # model to a DistributedModel to allow us to override saving + # and loading weights when we checkpoint the model during training. + return self._replicated_model + if hasattr(self, 'callback_model') and self.callback_model: + return self.callback_model + return self + class DistributedCallbackModel(Model): """Model that is used for callbacks with DistributionStrategy.""" @@ -2070,4 +2085,3 @@ class DistributedCallbackModel(Model): logging.warning('You are accessing attribute ' + item + 'of the' 'DistributedCallbackModel that may not have been set' 'correctly.') - diff --git a/tensorflow/python/keras/engine/training_arrays.py b/tensorflow/python/keras/engine/training_arrays.py index d24f4b64b9..e2c458c65f 100644 --- a/tensorflow/python/keras/engine/training_arrays.py +++ b/tensorflow/python/keras/engine/training_arrays.py @@ -19,8 +19,6 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import copy - import numpy as np from tensorflow.python.framework import errors @@ -92,14 +90,8 @@ def fit_loop(model, val_sample_weights = val_sample_weights or [] if model.uses_learning_phase and not isinstance(K.learning_phase(), int): ins = inputs + targets + sample_weights + [1] - if val_inputs: - val_ins = val_inputs + val_targets + val_sample_weights + [1] else: ins = inputs + targets + sample_weights - if val_inputs: - val_ins = val_inputs + val_targets + val_sample_weights - if not val_inputs: - val_ins = [] do_validation = False if val_inputs: @@ -116,65 +108,27 @@ def fit_loop(model, 'training, i.e. `steps_per_epoch` ' 'must be set.') - out_labels = model.metrics_names - if do_validation: - callback_metrics = copy.copy(out_labels) + ['val_' + n for n in out_labels] - # need to create the test_function before start of the first epoch - # because TensorBoard callback on_epoch_begin adds summary to the - # list of fetches of the test_function - model._make_test_function() - else: - callback_metrics = copy.copy(out_labels) - num_train_samples = training_utils.check_num_samples( ins, batch_size, steps_per_epoch, 'steps_per_epoch') + count_mode = 'steps' if steps_per_epoch else 'samples' + callbacks = cbks.configure_callbacks( + callbacks, + model, + do_validation=do_validation, + val_inputs=val_inputs, + val_targets=val_targets, + val_sample_weights=val_sample_weights, + batch_size=batch_size, + epochs=epochs, + steps_per_epoch=steps_per_epoch, + samples=num_train_samples, + validation_steps=validation_steps, + verbose=verbose, + count_mode=count_mode) + if num_train_samples is not None: index_array = np.arange(num_train_samples) - model.history = cbks.History() - all_callbacks = [cbks.BaseLogger( - stateful_metrics=model.stateful_metric_names)] - if verbose: - if steps_per_epoch is not None: - count_mode = 'steps' - else: - count_mode = 'samples' - all_callbacks.append( - cbks.ProgbarLogger( - count_mode, stateful_metrics=model.stateful_metric_names)) - all_callbacks += (callbacks or []) + [model.history] - callbacks = cbks.CallbackList(all_callbacks) - out_labels = out_labels or [] - - # it's possible to callback a different model than self - # (used by Sequential models) - if hasattr(model, 'callback_model') and model.callback_model: - callback_model = model.callback_model - else: - callback_model = model - - callbacks.set_model(callback_model) - - callback_params = { - 'batch_size': batch_size, - 'epochs': epochs, - 'steps': steps_per_epoch, - 'samples': num_train_samples, - 'verbose': verbose, - 'do_validation': do_validation, - 'metrics': callback_metrics or [], - } - if validation_steps: - callback_params.update({'validation_steps': validation_steps}) - callbacks.set_params(callback_params) - - for cbk in callbacks: - cbk.validation_data = val_ins - # validation_data must be set before on_train_begin() is called - # so that TensorboardCallback can validate its input - callbacks.on_train_begin() - callback_model.stop_training = False - # To prevent a slowdown, we find beforehand the arrays that need conversion. feed = model._feed_inputs + model._feed_targets + model._feed_sample_weights indices_for_conversion_to_dense = [] @@ -182,6 +136,7 @@ def fit_loop(model, if issparse is not None and issparse(ins[i]) and not K.is_sparse(feed[i]): indices_for_conversion_to_dense.append(i) + callbacks.on_train_begin() for epoch in range(initial_epoch, epochs): # Reset stateful metrics for m in model.stateful_metric_functions: @@ -208,11 +163,11 @@ def fit_loop(model, if not isinstance(outs, list): outs = [outs] - for l, o in zip(out_labels, outs): + for l, o in zip(model.metrics_names, outs): batch_logs[l] = o callbacks.on_batch_end(step_index, batch_logs) - if callback_model.stop_training: + if callbacks.model.stop_training: break if do_validation: @@ -226,7 +181,7 @@ def fit_loop(model, if not isinstance(val_outs, list): val_outs = [val_outs] # Same labels assumed. - for l, o in zip(out_labels, val_outs): + for l, o in zip(model.metrics_names, val_outs): epoch_logs['val_' + l] = o else: # Sample-wise fit loop. @@ -259,11 +214,11 @@ def fit_loop(model, outs = f(ins_batch) if not isinstance(outs, list): outs = [outs] - for l, o in zip(out_labels, outs): + for l, o in zip(model.metrics_names, outs): batch_logs[l] = o callbacks.on_batch_end(batch_index, batch_logs) - if callback_model.stop_training: + if callbacks.model.stop_training: break if batch_index == len(batches) - 1: # Last batch. @@ -278,10 +233,10 @@ def fit_loop(model, if not isinstance(val_outs, list): val_outs = [val_outs] # Same labels assumed. - for l, o in zip(out_labels, val_outs): + for l, o in zip(model.metrics_names, val_outs): epoch_logs['val_' + l] = o callbacks.on_epoch_end(epoch, epoch_logs) - if callback_model.stop_training: + if callbacks.model.stop_training: break callbacks.on_train_end() return model.history diff --git a/tensorflow/python/keras/engine/training_distributed.py b/tensorflow/python/keras/engine/training_distributed.py index 5fa6c3c47d..5feedc43a5 100644 --- a/tensorflow/python/keras/engine/training_distributed.py +++ b/tensorflow/python/keras/engine/training_distributed.py @@ -18,7 +18,6 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import copy import numpy as np from tensorflow.python.framework import errors from tensorflow.python.keras import backend as K @@ -38,7 +37,6 @@ def fit_loop( callbacks=None, val_inputs=None, val_targets=None, - callback_metrics=None, initial_epoch=0, steps_per_epoch=None, validation_steps=None): @@ -53,10 +51,6 @@ def fit_loop( callbacks: List of callbacks to be called during training val_inputs: List of input arrays. val_targets: List of target arrays. - callback_metrics: List of strings, the display names of the metrics - passed to the callbacks. They should be the - concatenation of list the display names of the outputs of - `f` and the list of display names of the outputs of `f_val`. initial_epoch: Epoch at which to start training (useful for resuming a previous training run) steps_per_epoch: Total number of steps (batches of samples) @@ -126,50 +120,6 @@ def fit_loop( 'when doing step-wise ' 'training, i.e. `steps_per_epoch` ' 'must be set.') - out_labels = model.metrics_names - if do_validation: - callback_metrics = copy.copy(out_labels) + [ - 'val_' + n for n in out_labels - ] - else: - callback_metrics = copy.copy(out_labels) - - model.history = cbks.History() - all_callbacks = [cbks.BaseLogger( - stateful_metrics=model.stateful_metric_names)] - if verbose: - # We assume that `steps_per_epoch` is always set since we have to use - # Datasets. - count_mode = 'steps' - - all_callbacks.append( - cbks.ProgbarLogger( - count_mode, stateful_metrics=model.stateful_metric_names)) - all_callbacks += (callbacks or []) + [model.history] - callbacks = cbks.CallbackList(all_callbacks) - out_labels = out_labels or [] - - # We set the callback model to an instance of the `DistributedModel` that we - # create in the `compile` call. The `DistributedModel` is initialized with - # the first replicated model. We need to set the callback model to a - # DistributedModel to allow us to override saving and loading weights when - # we checkpoint the model during training. - callback_model = model._replicated_model - - callbacks.set_model(callback_model) - - callbacks.set_params({ - 'epochs': epochs, - 'steps': steps_per_epoch, - 'samples': None, - 'verbose': verbose, - 'do_validation': do_validation, - 'metrics': callback_metrics or [], - }) - callbacks.on_train_begin() - callback_model.stop_training = False - - out_labels = out_labels or [] # Copy the weights from the original model to each of the replicated models. orig_model_weights = model.get_weights() @@ -178,6 +128,17 @@ def fit_loop( distributed_training_utils.set_weights( current_strategy, distributed_model, orig_model_weights) + callbacks = cbks.configure_callbacks( + callbacks, + model, + do_validation=do_validation, + val_inputs=None, + val_targets=None, + epochs=epochs, + steps_per_epoch=steps_per_epoch, + verbose=verbose) + out_labels = model.metrics_names or [] + callbacks.on_train_begin() for epoch in range(initial_epoch, epochs): callbacks.on_epoch_begin(epoch) if steps_per_epoch is not None: @@ -203,7 +164,7 @@ def fit_loop( for l, o in zip(out_labels, outs): batch_logs[l] = o callbacks.on_batch_end(step_index, batch_logs) - if callback_model.stop_training: + if callbacks.model.stop_training: break if do_validation: val_outs = test_loop( @@ -219,7 +180,7 @@ def fit_loop( epoch_logs['val_' + l] = o callbacks.on_epoch_end(epoch, epoch_logs) - if callback_model.stop_training: + if callbacks.model.stop_training: break callbacks.on_train_end() diff --git a/tensorflow/python/keras/engine/training_eager.py b/tensorflow/python/keras/engine/training_eager.py index d5a47efb98..965a62ffa3 100644 --- a/tensorflow/python/keras/engine/training_eager.py +++ b/tensorflow/python/keras/engine/training_eager.py @@ -153,8 +153,6 @@ def iterator_fit_loop(model, inputs, class_weight, steps_per_epoch, - callback_model, - out_labels, epoch_logs, val_inputs=None, val_targets=None, @@ -162,7 +160,6 @@ def iterator_fit_loop(model, epochs=1, verbose=1, callbacks=None, - callback_metrics=None, validation_steps=None, do_validation=False, batch_size=None): @@ -179,19 +176,13 @@ def iterator_fit_loop(model, steps_per_epoch: Total number of steps (batches of samples) before declaring one epoch finished and starting the next epoch. - callback_model: Instance of `Model` to callback. - out_labels: Output labels generated from model metric names. epoch_logs: Dictionary of logs from every epoch. val_inputs: Input data for validation. val_targets: Target data for validation. val_sample_weights: Sample weight data for validation. epochs: Number of times to iterate over the data verbose: Verbosity mode, 0, 1 or 2 - callbacks: List of callbacks to be called during training - callback_metrics: List of strings, the display names of the metrics - passed to the callbacks. They should be the - concatenation of list the display names of the outputs of - `f` and the list of display names of the outputs of `f_val`. + callbacks: CallbackList instance. Controls callbacks during training. validation_steps: Number of steps to run validation for (only if doing validation from data tensors). Ignored with default value of `None`. do_validation: Boolean value indicating whether we should do validation. @@ -244,20 +235,18 @@ def iterator_fit_loop(model, if val is not None else None for val in sample_weights ] - if step_index == 0 and not callback_metrics: - out_labels = model.metrics_names + if step_index == 0 and not callbacks.params['metrics']: + callback_metrics = copy.copy(model.metrics_names) if do_validation: - callback_metrics = copy.copy(out_labels) + [ - 'val_' + n for n in out_labels - ] - else: - callback_metrics = copy.copy(out_labels) + callback_metrics += ['val_' + n for n in model.metrics_names] callbacks.set_params({ + 'batch_size': batch_size, 'epochs': epochs, 'steps': steps_per_epoch, 'verbose': verbose, 'do_validation': do_validation, 'metrics': callback_metrics or [], + 'validation_steps': validation_steps }) # Train model. @@ -267,7 +256,7 @@ def iterator_fit_loop(model, outs = [outs] # Calculate metrics. - for l, o in zip(out_labels, outs): + for l, o in zip(model.metrics_names, outs): batch_logs[l] = o # Required for eager execution metrics_results = _eager_metrics_fn(model, outs, y) @@ -277,7 +266,7 @@ def iterator_fit_loop(model, [backend.mean(loss)] + loss_metrics + metrics_results): batch_logs[k] = tensor_util.constant_value(v) callbacks.on_batch_end(step_index, batch_logs) - if callback_model.stop_training: + if callbacks.model.stop_training: break if step_index == steps_per_epoch - 1: @@ -293,7 +282,7 @@ def iterator_fit_loop(model, if not isinstance(val_outs, list): val_outs = [val_outs] # Same labels assumed. - for l, o in zip(out_labels, val_outs): + for l, o in zip(model.metrics_names, val_outs): epoch_logs['val_' + l] = o @@ -643,64 +632,21 @@ def fit_loop(model, shuffle=shuffle) # Required for eager execution with backend.learning_phase_scope(1): - do_validation = False - if val_inputs: - do_validation = True - - num_train_samples = None - out_labels = None - callback_metrics = None - if model._is_compiled: - out_labels = model.metrics_names - if do_validation: - callback_metrics = copy.copy(out_labels) + [ - 'val_' + n for n in out_labels - ] - else: - callback_metrics = copy.copy(out_labels) - - model.history = cbks.History() - callbacks = [cbks.BaseLogger()] + (callbacks or []) + [model.history] - if verbose: - callbacks += [cbks.ProgbarLogger('steps')] - callbacks = cbks.CallbackList(callbacks) - - # it's possible to callback a different model than self - # (used by Sequential models) - if hasattr(model, 'callback_model') and model.callback_model: - callback_model = model.callback_model - else: - callback_model = model - - callbacks.set_model(callback_model) - - callback_params = { - 'batch_size': batch_size, - 'epochs': epochs, - 'steps': steps_per_epoch, - 'samples': num_train_samples, - 'verbose': verbose, - 'do_validation': do_validation, - 'metrics': callback_metrics or [], - } - if validation_steps: - callback_params.update({'validation_steps': validation_steps}) - callbacks.set_params(callback_params) - - for cbk in callbacks: - if not val_inputs: - cbk.validation_data = [] - elif isinstance(val_inputs, iterator_ops.EagerIterator): - cbk.validation_data = val_inputs - elif val_sample_weights: - cbk.validation_data = val_inputs + val_targets + val_sample_weights - else: - cbk.validation_data = val_inputs + val_targets - # validation_data must be set before on_train_begin() is called - # so that TensorboardCallback can validate its input - callbacks.on_train_begin() - callback_model.stop_training = False + do_validation = val_inputs is not None + callbacks = cbks.configure_callbacks( + callbacks, + model, + do_validation=do_validation, + batch_size=batch_size, + epochs=epochs, + steps_per_epoch=steps_per_epoch, + val_inputs=val_inputs, + val_targets=val_targets, + val_sample_weights=val_sample_weights, + validation_steps=validation_steps, + verbose=verbose) + callbacks.on_train_begin() for epoch in range(initial_epoch, epochs): callbacks.on_epoch_begin(epoch) epoch_logs = {} @@ -709,8 +655,6 @@ def fit_loop(model, inputs, class_weight, steps_per_epoch=steps_per_epoch, - callback_model=callback_model, - out_labels=out_labels, epoch_logs=epoch_logs, val_inputs=val_inputs, val_targets=val_targets, @@ -718,12 +662,11 @@ def fit_loop(model, epochs=epochs, verbose=verbose, callbacks=callbacks, - callback_metrics=callback_metrics, validation_steps=validation_steps, do_validation=do_validation, batch_size=batch_size) callbacks.on_epoch_end(epoch, epoch_logs) - if callback_model.stop_training: + if callbacks.model.stop_training: break callbacks.on_train_end() return model.history diff --git a/tensorflow/python/keras/engine/training_generator.py b/tensorflow/python/keras/engine/training_generator.py index 432cf2bddd..a7fd440e86 100644 --- a/tensorflow/python/keras/engine/training_generator.py +++ b/tensorflow/python/keras/engine/training_generator.py @@ -21,7 +21,6 @@ from __future__ import print_function import numpy as np -from tensorflow.python.keras import backend as K from tensorflow.python.keras import callbacks as cbks from tensorflow.python.keras.utils.data_utils import GeneratorEnqueuer from tensorflow.python.keras.utils.data_utils import OrderedEnqueuer @@ -79,66 +78,37 @@ def fit_generator(model, ' class. Please specify `validation_steps` or use' ' the `keras.utils.Sequence` class.') - # Prepare display labels. - out_labels = model.metrics_names - callback_metrics = out_labels + ['val_%s' % n for n in out_labels] - - # prepare callbacks - model.history = cbks.History() - callbacks = [cbks.BaseLogger()] + (callbacks or []) + [model.history] - if verbose: - callbacks += [cbks.ProgbarLogger(count_mode='steps')] - callbacks = cbks.CallbackList(callbacks) - - # it's possible to callback a different model than self: - if hasattr(model, 'callback_model') and model.callback_model: - callback_model = model.callback_model - else: - callback_model = model - callbacks.set_model(callback_model) - - callback_params = { - 'epochs': epochs, - 'steps': steps_per_epoch, - 'verbose': verbose, - 'do_validation': do_validation, - 'metrics': callback_metrics, - } - if do_validation: - # need to create the test_function before start of the first epoch - # because TensorBoard callback on_epoch_begin adds summary to the - # list of fetches of the test_function - model._make_test_function() - # determine the number of validation batches given a generator - if validation_steps: - callback_params.update({'validation_steps': validation_steps}) - elif isinstance(validation_data, Sequence): - callback_params.update({'validation_steps': len(validation_data)}) - callbacks.set_params(callback_params) - enqueuer = None val_enqueuer = None try: + val_x, val_y, val_sample_weights = validation_data, None, None if do_validation and not val_gen: # Prepare data for validation if len(validation_data) == 2: val_x, val_y = validation_data # pylint: disable=unpacking-non-sequence - val_sample_weight = None + val_sample_weights = None elif len(validation_data) == 3: - val_x, val_y, val_sample_weight = validation_data # pylint: disable=unpacking-non-sequence + val_x, val_y, val_sample_weights = validation_data # pylint: disable=unpacking-non-sequence else: raise ValueError( '`validation_data` should be a tuple ' '`(val_x, val_y, val_sample_weight)` ' 'or `(val_x, val_y)`. Found: ' + str(validation_data)) val_x, val_y, val_sample_weights = model._standardize_user_data( - val_x, val_y, val_sample_weight) - val_data = val_x + val_y + val_sample_weights - if model.uses_learning_phase and not isinstance(K.learning_phase(), int): - val_data += [0.] - for cbk in callbacks: - cbk.validation_data = val_data + val_x, val_y, val_sample_weights) + + callbacks = cbks.configure_callbacks( + callbacks, + model, + do_validation=do_validation, + val_inputs=val_x, + val_targets=val_y, + val_sample_weights=val_sample_weights, + epochs=epochs, + validation_steps=validation_steps, + steps_per_epoch=steps_per_epoch, + verbose=verbose) if workers > 0: if is_sequence: @@ -159,9 +129,6 @@ def fit_generator(model, else: output_generator = generator - callback_model.stop_training = False - # validation_data must be set before on_train_begin() is called - # so that TensorboardCallback can validate its input callbacks.on_train_begin() # Construct epoch logs. epoch_logs = {} @@ -205,7 +172,7 @@ def fit_generator(model, if not isinstance(outs, list): outs = [outs] - for l, o in zip(out_labels, outs): + for l, o in zip(model.metrics_names, outs): batch_logs[l] = o callbacks.on_batch_end(batch_index, batch_logs) @@ -235,15 +202,15 @@ def fit_generator(model, if not isinstance(val_outs, list): val_outs = [val_outs] # Same labels assumed. - for l, o in zip(out_labels, val_outs): + for l, o in zip(model.metrics_names, val_outs): epoch_logs['val_' + l] = o - if callback_model.stop_training: + if callbacks.model.stop_training: break callbacks.on_epoch_end(epoch, epoch_logs) epoch += 1 - if callback_model.stop_training: + if callbacks.model.stop_training: break finally: -- GitLab From ba76f5ca8f722d8c66e4687d8a2161d858e9b407 Mon Sep 17 00:00:00 2001 From: Igor Ganichev Date: Fri, 10 Aug 2018 13:40:00 -0700 Subject: [PATCH 354/437] Use global counter for XLA rng seed PiperOrigin-RevId: 208260479 --- tensorflow/compiler/jit/BUILD | 1 + tensorflow/compiler/jit/kernels/BUILD | 1 + .../compiler/jit/kernels/xla_launch_op.cc | 3 ++- .../compiler/jit/xla_compile_on_demand_op.cc | 3 ++- tensorflow/compiler/tests/eager_test.py | 9 +++++++ tensorflow/compiler/tests/random_ops_test.py | 14 +++------- tensorflow/compiler/tf2xla/tf2xla_util.cc | 26 +++++++++++++++++++ tensorflow/compiler/tf2xla/tf2xla_util.h | 3 +++ 8 files changed, 48 insertions(+), 12 deletions(-) diff --git a/tensorflow/compiler/jit/BUILD b/tensorflow/compiler/jit/BUILD index 15f9ba217f..55b98da472 100644 --- a/tensorflow/compiler/jit/BUILD +++ b/tensorflow/compiler/jit/BUILD @@ -160,6 +160,7 @@ cc_library( "//tensorflow/compiler/jit/ops:xla_ops", "//tensorflow/compiler/tf2xla:common", "//tensorflow/compiler/tf2xla:dump_graph", + "//tensorflow/compiler/tf2xla:tf2xla_util", "//tensorflow/compiler/tf2xla:xla_compiler", "//tensorflow/compiler/tf2xla/kernels:xla_ops", "//tensorflow/compiler/xla:util", diff --git a/tensorflow/compiler/jit/kernels/BUILD b/tensorflow/compiler/jit/kernels/BUILD index 00a6f4075f..8f78c110cb 100644 --- a/tensorflow/compiler/jit/kernels/BUILD +++ b/tensorflow/compiler/jit/kernels/BUILD @@ -16,6 +16,7 @@ cc_library( "//tensorflow/compiler/jit:xla_device", "//tensorflow/compiler/jit:xla_launch_util", "//tensorflow/compiler/tf2xla:common", + "//tensorflow/compiler/tf2xla:tf2xla_util", "//tensorflow/compiler/tf2xla:xla_compiler", "//tensorflow/compiler/xla:statusor", "//tensorflow/compiler/xla/client:client_library", diff --git a/tensorflow/compiler/jit/kernels/xla_launch_op.cc b/tensorflow/compiler/jit/kernels/xla_launch_op.cc index b313d48011..37a2f3b5ac 100644 --- a/tensorflow/compiler/jit/kernels/xla_launch_op.cc +++ b/tensorflow/compiler/jit/kernels/xla_launch_op.cc @@ -19,6 +19,7 @@ limitations under the License. #include "tensorflow/compiler/jit/xla_device.h" #include "tensorflow/compiler/jit/xla_launch_util.h" #include "tensorflow/compiler/tf2xla/shape_util.h" +#include "tensorflow/compiler/tf2xla/tf2xla_util.h" #include "tensorflow/compiler/tf2xla/xla_compiler.h" #include "tensorflow/compiler/tf2xla/xla_op_registry.h" #include "tensorflow/compiler/xla/client/client_library.h" @@ -199,7 +200,7 @@ void XlaLocalLaunchBase::Compute(OpKernelContext* ctx) { run_options.set_stream(stream); run_options.set_allocator(xla_allocator); run_options.set_intra_op_thread_pool(&ctx->eigen_cpu_device()); - run_options.set_rng_seed(ctx->step_id()); + run_options.set_rng_seed(GetXLARandomSeed()); Env* env = Env::Default(); auto start_time = env->NowMicros(); diff --git a/tensorflow/compiler/jit/xla_compile_on_demand_op.cc b/tensorflow/compiler/jit/xla_compile_on_demand_op.cc index d288d37bc7..f65f89ebf5 100644 --- a/tensorflow/compiler/jit/xla_compile_on_demand_op.cc +++ b/tensorflow/compiler/jit/xla_compile_on_demand_op.cc @@ -18,6 +18,7 @@ limitations under the License. #include "tensorflow/compiler/jit/xla_compile_on_demand_op.h" #include "tensorflow/compiler/jit/xla_device.h" #include "tensorflow/compiler/jit/xla_launch_util.h" +#include "tensorflow/compiler/tf2xla/tf2xla_util.h" #include "tensorflow/compiler/tf2xla/xla_compiler.h" #include "tensorflow/compiler/tf2xla/xla_op_registry.h" @@ -71,7 +72,7 @@ Status XlaCompileOnDemandOp::Run(OpKernelContext* ctx, run_options.set_stream(stream); run_options.set_allocator(client->backend().memory_allocator()); run_options.set_intra_op_thread_pool(&ctx->eigen_cpu_device()); - run_options.set_rng_seed(ctx->step_id()); + run_options.set_rng_seed(GetXLARandomSeed()); xla::StatusOr run_result = executable->Run(launch_context.arguments(), run_options); diff --git a/tensorflow/compiler/tests/eager_test.py b/tensorflow/compiler/tests/eager_test.py index 422f36d43b..ff097f80f1 100644 --- a/tensorflow/compiler/tests/eager_test.py +++ b/tensorflow/compiler/tests/eager_test.py @@ -32,6 +32,7 @@ from tensorflow.python.layers import convolutional from tensorflow.python.layers import pooling from tensorflow.python.ops import array_ops from tensorflow.python.ops import embedding_ops +from tensorflow.python.ops import gen_random_ops from tensorflow.python.ops import init_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import nn_ops @@ -122,6 +123,14 @@ class EagerTest(xla_test.XLATestCase): with self.test_scope(): self.assertAllEqual(2, array_ops.identity(2)) + def testRandomOps(self): + with self.test_scope(): + tensor = gen_random_ops.random_uniform((2, 2), dtypes.float32) + row0 = tensor[0].numpy() + row1 = tensor[1].numpy() + # It should be very unlikely to rng to generate two equal rows. + self.assertFalse((row0 == row1).all()) + def testIdentityOnVariable(self): with self.test_scope(): v = resource_variable_ops.ResourceVariable(True) diff --git a/tensorflow/compiler/tests/random_ops_test.py b/tensorflow/compiler/tests/random_ops_test.py index cc0e9b2f98..8c4e16e4e0 100644 --- a/tensorflow/compiler/tests/random_ops_test.py +++ b/tensorflow/compiler/tests/random_ops_test.py @@ -101,7 +101,7 @@ class RandomOpsTest(xla_test.XLATestCase): for dtype in [dtypes.float32]: with self.test_session() as sess: with self.test_scope(): - x = random_ops.truncated_normal(shape=[count], dtype=dtype, seed=42) + x = random_ops.truncated_normal(shape=[count], dtype=dtype) y = sess.run(x) def normal_cdf(x): @@ -130,24 +130,18 @@ class RandomOpsTest(xla_test.XLATestCase): # Department of Scientific Computing website. Florida State University. expected_mean = mu + (normal_pdf(alpha) - normal_pdf(beta)) / z * sigma actual_mean = np.mean(y) - atol = 2e-4 - if self.device in ["XLA_GPU", "XLA_CPU"]: - atol = 2.2e-4 - self.assertAllClose(actual_mean, expected_mean, atol=atol) + self.assertAllClose(actual_mean, expected_mean, atol=2e-3) expected_median = mu + probit( (normal_cdf(alpha) + normal_cdf(beta)) / 2.) * sigma actual_median = np.median(y) - self.assertAllClose(actual_median, expected_median, atol=1e-3) + self.assertAllClose(actual_median, expected_median, atol=1e-2) expected_variance = sigma**2 * (1 + ( (alpha * normal_pdf(alpha) - beta * normal_pdf(beta)) / z) - ( (normal_pdf(alpha) - normal_pdf(beta)) / z)**2) actual_variance = np.var(y) - rtol = 1e-3 - if self.device in ["XLA_GPU", "XLA_CPU"]: - rtol = 4e-4 - self.assertAllClose(actual_variance, expected_variance, rtol=rtol) + self.assertAllClose(actual_variance, expected_variance, rtol=2*1e-3) def testShuffle1d(self): # TODO(b/26783907): this test requires the CPU backend to implement sort. diff --git a/tensorflow/compiler/tf2xla/tf2xla_util.cc b/tensorflow/compiler/tf2xla/tf2xla_util.cc index 9203e8d9e6..0e07485d18 100644 --- a/tensorflow/compiler/tf2xla/tf2xla_util.cc +++ b/tensorflow/compiler/tf2xla/tf2xla_util.cc @@ -16,6 +16,7 @@ limitations under the License. #include "tensorflow/compiler/tf2xla/tf2xla_util.h" #include +#include #include #include @@ -297,4 +298,29 @@ void AddDtypeToKernalDefConstraint(StringPiece name, DataType dtype, } } +namespace { +uint32 InitialRandomSeed() { + // Support plumbing the TF seed through to XLA is being worked on. + // If a user wants deterministic behavior, their best option + // is to start with a known checkpoint. This also handles issues when + // multiple random calls can be invoked in any order by TF executor. + // Another option is to use stateless random ops. They have much cleaner + // semantics. + // If a user really wants to set a deterministic seed for XLA-based + // devices, this is the place to do it. + std::random_device rd; + // Make the starting value odd. + return rd() | 1; +} +} // namespace + +uint32 GetXLARandomSeed() { + // We initialize counter with an odd number and increment it by two + // everytime. This ensures that it will never be zero, even + // after an overflow. When seeded with zero, some XLA backends + // can return all zeros instead of random numbers. + static std::atomic counter(InitialRandomSeed()); + return counter.fetch_add(2); +} + } // namespace tensorflow diff --git a/tensorflow/compiler/tf2xla/tf2xla_util.h b/tensorflow/compiler/tf2xla/tf2xla_util.h index 745beb39c1..33620ef810 100644 --- a/tensorflow/compiler/tf2xla/tf2xla_util.h +++ b/tensorflow/compiler/tf2xla/tf2xla_util.h @@ -56,6 +56,9 @@ Status SetNodeShardingFromNeighbors(Node* n, bool out_edges); void AddDtypeToKernalDefConstraint(StringPiece name, DataType dtype, KernelDef* kdef); +// Returns the next random seed to use for seeding xla rng. +uint32 GetXLARandomSeed(); + } // namespace tensorflow #endif // TENSORFLOW_COMPILER_TF2XLA_TF2XLA_UTIL_H_ -- GitLab From db294c86cc299d5fc8c5cbf089b07e59723a4664 Mon Sep 17 00:00:00 2001 From: Suharsh Sivakumar Date: Fri, 10 Aug 2018 13:56:34 -0700 Subject: [PATCH 355/437] Fix unnecessary semicolon (lint warning) PiperOrigin-RevId: 208262999 --- tensorflow/contrib/lite/interpreter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/contrib/lite/interpreter.h b/tensorflow/contrib/lite/interpreter.h index e8301ff507..159ff7bc20 100644 --- a/tensorflow/contrib/lite/interpreter.h +++ b/tensorflow/contrib/lite/interpreter.h @@ -165,7 +165,7 @@ class Interpreter { return SetTensorParametersReadOnly(tensor_index, type, name, dims.size(), dims.data(), quantization, buffer, bytes, allocation); - }; + } TfLiteStatus SetTensorParametersReadOnly( int tensor_index, TfLiteType type, const char* name, const size_t rank, -- GitLab From f7cb9d504f1a675375171fa19cee70fa64c28c64 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Fri, 10 Aug 2018 13:57:11 -0700 Subject: [PATCH 356/437] Permit TensorFlow server to access Cloud Bigtable. PiperOrigin-RevId: 208263100 --- tensorflow/contrib/bigtable/kernels/bigtable_kernels.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tensorflow/contrib/bigtable/kernels/bigtable_kernels.cc b/tensorflow/contrib/bigtable/kernels/bigtable_kernels.cc index a6755a3496..1790b4bc11 100644 --- a/tensorflow/contrib/bigtable/kernels/bigtable_kernels.cc +++ b/tensorflow/contrib/bigtable/kernels/bigtable_kernels.cc @@ -84,6 +84,8 @@ class BigtableClientOp : public OpKernel { channel_args.SetMaxReceiveMessageSize( max_receive_message_size_); channel_args.SetUserAgentPrefix("tensorflow"); + channel_args.SetInt(GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS, 0); + channel_args.SetInt(GRPC_ARG_KEEPALIVE_TIMEOUT_MS, 60 * 1000); client_options.set_channel_arguments(channel_args); std::shared_ptr client = google::cloud::bigtable::CreateDefaultDataClient( -- GitLab From 430dd8d1c14cd665aafdcdee82c76ec304f51ef1 Mon Sep 17 00:00:00 2001 From: Akshay Agrawal Date: Fri, 10 Aug 2018 14:36:47 -0700 Subject: [PATCH 357/437] Fix flaky layers test. PiperOrigin-RevId: 208269820 --- tensorflow/contrib/layers/python/layers/layers_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow/contrib/layers/python/layers/layers_test.py b/tensorflow/contrib/layers/python/layers/layers_test.py index c5c7269b1f..51c7abb105 100644 --- a/tensorflow/contrib/layers/python/layers/layers_test.py +++ b/tensorflow/contrib/layers/python/layers/layers_test.py @@ -1189,7 +1189,7 @@ class ConvolutionInPlaneTest(test.TestCase): result = sess.run(horz_gradients) expected = np.zeros((1, 10, 9, 1)) - self.assertAllEqual(result, expected) + self.assertAllClose(result, expected, rtol=1e-5, atol=1e-5) def testHorzConvWithBlankImageAndPlaceholder(self): image = array_ops.placeholder(dtypes.float32, shape=(None, None, None, 1)) @@ -1209,7 +1209,7 @@ class ConvolutionInPlaneTest(test.TestCase): }) expected = np.zeros((1, 10, 9, 1)) - self.assertAllEqual(result, expected) + self.assertAllClose(result, expected, rtol=1e-5, atol=1e-5) def testHorzConvWithRandomImageMultiBatch(self): np.random.seed(1) -- GitLab From 0b36ff79021b907f5447bfcbaa060dbdc2114c67 Mon Sep 17 00:00:00 2001 From: Anna R Date: Fri, 10 Aug 2018 14:42:11 -0700 Subject: [PATCH 358/437] Automated rollback of commit 9eb310c3f651d69b9a8eea016f6397049c5a0a31 PiperOrigin-RevId: 208270711 --- .../xla/service/cpu/cpu_executable.cc | 38 ++++++++++--------- .../compiler/xla/service/cpu/cpu_executable.h | 10 ----- 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/tensorflow/compiler/xla/service/cpu/cpu_executable.cc b/tensorflow/compiler/xla/service/cpu/cpu_executable.cc index c376864c3e..946f5124b8 100644 --- a/tensorflow/compiler/xla/service/cpu/cpu_executable.cc +++ b/tensorflow/compiler/xla/service/cpu/cpu_executable.cc @@ -249,11 +249,24 @@ StatusOr CpuExecutable::ExecuteOnStream( const ServiceExecutableRunOptions* run_options, tensorflow::gtl::ArraySlice arguments, HloExecutionProfile* hlo_execution_profile) { + if (GetRootPointsToSet().IsAmbiguous()) { + return Unimplemented("Points-to set of root instruction is ambiguous"); + } + + se::Stream* stream = run_options->stream(); + DeviceMemoryAllocator* memory_allocator = run_options->allocator(); + + std::vector owning_buffers; + std::vector unowning_buffers; TF_ASSIGN_OR_RETURN( - auto result, - ExecuteAsyncOnStreamImpl(run_options, arguments, hlo_execution_profile)); - TF_RETURN_IF_ERROR(run_options->stream()->BlockHostUntilDone()); - return std::move(result); + std::tie(unowning_buffers, owning_buffers), + CreateTempArray(memory_allocator, stream->parent()->device_ordinal(), + arguments)); + + TF_RETURN_IF_ERROR(ExecuteComputeFunction( + &run_options->run_options(), unowning_buffers, hlo_execution_profile)); + + return CreateResultShapedBuffer(run_options, &owning_buffers); } StatusOr CpuExecutable::ExecuteAsyncOnStream( @@ -264,16 +277,6 @@ StatusOr CpuExecutable::ExecuteAsyncOnStream( "Asynchronous execution on stream with hlo profiling is not yet " "supported on CPU."); } - return ExecuteAsyncOnStreamImpl(run_options, arguments, nullptr); -} - -StatusOr CpuExecutable::ExecuteAsyncOnStreamImpl( - const ServiceExecutableRunOptions* run_options, - tensorflow::gtl::ArraySlice arguments, - HloExecutionProfile* hlo_execution_profile) { - if (GetRootPointsToSet().IsAmbiguous()) { - return Unimplemented("Points-to set of root instruction is ambiguous"); - } auto* host_stream = dynamic_cast( run_options->stream()->implementation()); @@ -307,20 +310,19 @@ StatusOr CpuExecutable::ExecuteAsyncOnStreamImpl( ServiceExecutableRunOptions run_options; std::vector unowning_buffers; std::shared_ptr> buffers; - HloExecutionProfile* hlo_execution_profile; void operator()() { // Failing a CHECK here is not great, but I don't see an obvious way to // return a failed Status asynchronously. TF_CHECK_OK(executable->ExecuteComputeFunction( - &run_options.run_options(), unowning_buffers, hlo_execution_profile)); + &run_options.run_options(), unowning_buffers, + /*hlo_execution_profile=*/nullptr)); } }; host_stream->EnqueueTask( AsyncRunTask{this, *run_options, std::move(unowning_buffers), std::make_shared>( - std::move(owning_buffers)), - hlo_execution_profile}); + std::move(owning_buffers))}); return std::move(result); } diff --git a/tensorflow/compiler/xla/service/cpu/cpu_executable.h b/tensorflow/compiler/xla/service/cpu/cpu_executable.h index 96e53de57e..8af8a5dfec 100644 --- a/tensorflow/compiler/xla/service/cpu/cpu_executable.h +++ b/tensorflow/compiler/xla/service/cpu/cpu_executable.h @@ -85,16 +85,6 @@ class CpuExecutable : public Executable { const BufferAssignment& buffer_assignment() const { return *assignment_; } private: - // This is for sharing the code between ExecuteOnStream and - // ExecuteAsyncOnStream. - // - // Notice that it's tricky to use correctly, as the profile object (when it - // exists) must out-live the task. - StatusOr ExecuteAsyncOnStreamImpl( - const ServiceExecutableRunOptions* run_options, - tensorflow::gtl::ArraySlice arguments, - HloExecutionProfile* hlo_execution_profile); - // Creates an array suitable for passing as the "temps" argument to the JIT // compiled function pointer. // -- GitLab From 39b6df56193d6fc00b49634ba255ad24e52e9e90 Mon Sep 17 00:00:00 2001 From: Akshay Agrawal Date: Fri, 10 Aug 2018 14:44:38 -0700 Subject: [PATCH 359/437] Make FunctionLibraryDefinition thread-safe. The eager runtime mutates the FunctionLibraryRuntime's FunctionLibraryDefinition, which is shared across threads; at the same time, OpKernels might read the FunctionLibraryDefinition. This is not thread-safe unless FunctionLibraryDefinition is thread-safe. This change makes FunctionLibraryDefinition, which is basically a map from function names to FunctionDefs, thread-safe. This is almost entirely accomplished by guarding the map with a mutex. There is however one complication: Find and RemoveFunction cannot be made thread-safe in a straightforward way (Find returns a raw pointer to a FunctionDef while Remove can delete the corresponding FunctionDef). In light of the fact that clients only ever call RemoveFunction when they in fact want to replace an existing function with a new one, we make the following modifications to FunctionLibraryDefinition's API: 1. A Contains method is added to check for the existence of a function. 2. A ReplaceFunction method is added. 3. RemoveFunction and RemoveGradient are made private. We also update clients of the FunctionLibraryDefinition to use Contains & ReplaceFunction instead of Find and RemoveFunction. PiperOrigin-RevId: 208271076 --- .../jit/encapsulate_subgraphs_pass.cc | 3 +- .../core/common_runtime/eager/context.h | 2 - .../core/common_runtime/eager/execute.cc | 17 +--- .../common_runtime/eager/kernel_and_device.h | 7 -- .../common_runtime/graph_execution_state.cc | 5 +- tensorflow/core/framework/function.cc | 65 ++++++++++++--- tensorflow/core/framework/function.h | 79 +++++++++++++------ .../grappler/optimizers/meta_optimizer.cc | 3 +- tensorflow/python/eager/function_test.py | 56 +++++++++++++ 9 files changed, 169 insertions(+), 68 deletions(-) diff --git a/tensorflow/compiler/jit/encapsulate_subgraphs_pass.cc b/tensorflow/compiler/jit/encapsulate_subgraphs_pass.cc index fdd71c6a58..f150bf1819 100644 --- a/tensorflow/compiler/jit/encapsulate_subgraphs_pass.cc +++ b/tensorflow/compiler/jit/encapsulate_subgraphs_pass.cc @@ -1161,8 +1161,7 @@ Status Encapsulator::Subgraph::ReplaceFunctionDef( strings::StrCat("replace_encapsulate_fdef_", name), fdef); } - TF_RETURN_IF_ERROR(library->RemoveFunction(name)); - TF_RETURN_IF_ERROR(library->AddFunctionDef(fdef)); + TF_RETURN_IF_ERROR(library->ReplaceFunction(name, fdef)); return Status::OK(); } diff --git a/tensorflow/core/common_runtime/eager/context.h b/tensorflow/core/common_runtime/eager/context.h index ebaf500bb3..21c5bdf8e9 100644 --- a/tensorflow/core/common_runtime/eager/context.h +++ b/tensorflow/core/common_runtime/eager/context.h @@ -134,8 +134,6 @@ class EagerContext { Rendezvous* GetRendezvous() { return rendezvous_; } - mutex* FunctionsMu() { return &functions_mu_; } - const tensorflow::DeviceMgr* local_device_mgr() const { return (local_device_manager_ != nullptr) ? local_device_manager_.get() : local_unowned_device_manager_; diff --git a/tensorflow/core/common_runtime/eager/execute.cc b/tensorflow/core/common_runtime/eager/execute.cc index 8eaa6e4429..46065f399c 100644 --- a/tensorflow/core/common_runtime/eager/execute.cc +++ b/tensorflow/core/common_runtime/eager/execute.cc @@ -300,12 +300,6 @@ Status EagerLocalExecute(EagerOperation* op, << device->name(); } kernel = new KernelAndDevice(ctx->GetRendezvous()); - // Knowledge of the implementation of Init (and in-turn - // FunctionLibraryRuntime::CreateKernel) tells us that ctx->func_lib_def - // will be accessed, so grab on to the lock. - // See WARNING comment in Execute (before kernel->Run) - would be nice to - // rework to avoid this subtlety. - tf_shared_lock l(*ctx->FunctionsMu()); auto* flr = ctx->func_lib(device); if (flr == nullptr) { @@ -646,15 +640,8 @@ Status EagerExecute(EagerContext* ctx, Device* device, TF_RETURN_IF_ERROR(op_inputs[i]->Tensor(&input_tensor)); inputs[i] = *input_tensor; } - // WARNING: kernel->Run utilizes the FunctionLibraryRuntime - // (ctx->func_lib(device)), which in turn holds a pointer to func_lib_def. - // But knowledge of the implementation - // of FunctionLibraryRuntime tells us that func_lib_def is not accessed by - // FunctionLibraryRuntime::Run(), so there is no thread-safety concern here. - // This is quite subtle. Re-work things to make this better? (Would it make - // sense for FunctionLibraryRuntime to ensure thread-safe access to - // FunctionLibraryDefinition?). TODO(apassos) figure out how to record stats - // for ops which are a part of functions. + // TODO(apassos) figure out how to record stats for ops which are a part of + // functions. // TODO(agarwal): change Run to take vector of handles ? ScopedStepContainer* container = ctx->StepContainer(); if (container == nullptr) { diff --git a/tensorflow/core/common_runtime/eager/kernel_and_device.h b/tensorflow/core/common_runtime/eager/kernel_and_device.h index 751cf687b2..0ef419cbaa 100644 --- a/tensorflow/core/common_runtime/eager/kernel_and_device.h +++ b/tensorflow/core/common_runtime/eager/kernel_and_device.h @@ -49,13 +49,6 @@ class KernelAndDevice { // // The provided FunctionLibraryRuntime MUST outlive all calls to // Run() on the returned KernelAndDevice. - // - // TODO(ashankar): Figure out thread-safety concerns around - // FunctionLibraryRuntime (in particular, how the underlying - // FunctionLibraryDefinition might be mutated by another thread as new - // functions are registered with it). Conservatively, thread-safe usage of - // the FunctionLibraryRuntime is pushed on to the caller (see locking in - // c_api.cc). static Status Init(const NodeDef& ndef, FunctionLibraryRuntime* flib, std::function)>* runner, KernelAndDevice* out); diff --git a/tensorflow/core/common_runtime/graph_execution_state.cc b/tensorflow/core/common_runtime/graph_execution_state.cc index 9c9eacb5b5..c23b7d3699 100644 --- a/tensorflow/core/common_runtime/graph_execution_state.cc +++ b/tensorflow/core/common_runtime/graph_execution_state.cc @@ -643,10 +643,9 @@ Status GraphExecutionState::OptimizeGraph( for (const FunctionDef& fdef : new_graph.library().function()) { const string& func_name = fdef.signature().name(); - if ((*optimized_flib)->Find(func_name)) { + if ((*optimized_flib)->Contains(func_name)) { VLOG(3) << "Replace function: name=" << func_name; - TF_RETURN_IF_ERROR((*optimized_flib)->RemoveFunction(func_name)); - TF_RETURN_IF_ERROR((*optimized_flib)->AddFunctionDef(fdef)); + TF_RETURN_IF_ERROR((*optimized_flib)->ReplaceFunction(func_name, fdef)); } else { VLOG(3) << "Add new function: name=" << func_name; TF_RETURN_IF_ERROR((*optimized_flib)->AddFunctionDef(fdef)); diff --git a/tensorflow/core/framework/function.cc b/tensorflow/core/framework/function.cc index 57bcc0f513..6b92e10d76 100644 --- a/tensorflow/core/framework/function.cc +++ b/tensorflow/core/framework/function.cc @@ -920,10 +920,12 @@ FunctionLibraryDefinition::FunctionDefAndOpRegistration:: FunctionLibraryDefinition::FunctionLibraryDefinition( const FunctionLibraryDefinition& other) - : default_registry_(other.default_registry_), func_grad_(other.func_grad_) { + : default_registry_(other.default_registry_) { + tf_shared_lock l(other.mu_); for (const auto& it : other.function_defs_) { TF_CHECK_OK(AddFunctionDef(it.second->fdef)); } + func_grad_ = other.func_grad_; } FunctionLibraryDefinition::FunctionLibraryDefinition( @@ -943,8 +945,19 @@ FunctionLibraryDefinition::FunctionLibraryDefinition( FunctionLibraryDefinition::~FunctionLibraryDefinition() {} -const FunctionDef* FunctionLibraryDefinition::Find(const string& name) const { - auto iter = function_defs_.find(name); +bool FunctionLibraryDefinition::Contains(const string& func) const { + tf_shared_lock l(mu_); + return function_defs_.find(func) != function_defs_.end(); +} + +const FunctionDef* FunctionLibraryDefinition::Find(const string& func) const { + tf_shared_lock l(mu_); + return FindHelper(func); +} + +const FunctionDef* FunctionLibraryDefinition::FindHelper( + const string& func) const { + auto iter = function_defs_.find(func); if (iter == function_defs_.end()) { return nullptr; } else { @@ -953,6 +966,7 @@ const FunctionDef* FunctionLibraryDefinition::Find(const string& name) const { } Status FunctionLibraryDefinition::AddFunctionDef(const FunctionDef& fdef) { + mutex_lock l(mu_); bool added; return AddFunctionDefHelper(fdef, &added); } @@ -984,6 +998,7 @@ Status FunctionLibraryDefinition::AddFunctionDefHelper(const FunctionDef& fdef, } Status FunctionLibraryDefinition::AddGradientDef(const GradientDef& grad) { + mutex_lock l(mu_); bool added; return AddGradientDefHelper(grad, &added); } @@ -1009,13 +1024,17 @@ Status FunctionLibraryDefinition::AddGradientDefHelper(const GradientDef& grad, Status FunctionLibraryDefinition::AddLibrary( const FunctionLibraryDefinition& other) { + // Clone `other` to ensure thread-safety (grabbing `other`'s lock for + // the duration of the function could lead to deadlock). + FunctionLibraryDefinition clone(other); + mutex_lock l(mu_); // Remember the funcs and grads that we added successfully so that // we can roll them back on error. std::vector funcs; std::vector funcs_with_grads; Status s; bool added; - for (auto iter : other.function_defs_) { + for (auto iter : clone.function_defs_) { s = AddFunctionDefHelper(iter.second->fdef, &added); if (!s.ok()) { Remove(funcs, funcs_with_grads); @@ -1025,7 +1044,7 @@ Status FunctionLibraryDefinition::AddLibrary( funcs.push_back(iter.second->fdef.signature().name()); } } - for (auto iter : other.func_grad_) { + for (auto iter : clone.func_grad_) { GradientDef grad; grad.set_function_name(iter.first); grad.set_gradient_func(iter.second); @@ -1045,6 +1064,7 @@ Status FunctionLibraryDefinition::AddLibrary( const FunctionDefLibrary& lib_def) { // Remember the funcs and grads that we added successfully so that // we can roll them back on error. + mutex_lock l(mu_); std::vector funcs; std::vector funcs_with_grads; Status s; @@ -1072,6 +1092,15 @@ Status FunctionLibraryDefinition::AddLibrary( return Status::OK(); } +Status FunctionLibraryDefinition::ReplaceFunction(const string& func, + const FunctionDef& fdef) { + mutex_lock l(mu_); + bool added; + TF_RETURN_IF_ERROR(RemoveFunction(func)); + TF_RETURN_IF_ERROR(AddFunctionDefHelper(fdef, &added)); + return Status::OK(); +} + Status FunctionLibraryDefinition::RemoveFunction(const string& func) { const auto& i = function_defs_.find(func); if (i == function_defs_.end()) { @@ -1106,11 +1135,17 @@ void FunctionLibraryDefinition::Remove( } string FunctionLibraryDefinition::FindGradient(const string& func) const { + tf_shared_lock l(mu_); + return gtl::FindWithDefault(func_grad_, func, ""); +} + +string FunctionLibraryDefinition::FindGradientHelper(const string& func) const { return gtl::FindWithDefault(func_grad_, func, ""); } Status FunctionLibraryDefinition::LookUp( const string& op, const OpRegistrationData** op_reg_data) const { + tf_shared_lock l(mu_); auto iter = function_defs_.find(op); if (iter != function_defs_.end()) { *op_reg_data = &iter->second->op_registration_data; @@ -1134,18 +1169,22 @@ const FunctionDef* FunctionLibraryDefinition::GetAttrImpl( return nullptr; } const string& func_name = forward_func_attrs->name(); - const string& grad_name = FindGradient(func_name); - // If 'func' has a user-defined gradient function, uses the grad - // function's attrs to see if noinline is specified. Otherwise, - // uses func's attrs. - if (!grad_name.empty()) { - return Find(grad_name); - } - return Find(func_name); + { + tf_shared_lock l(mu_); + const string& grad_name = FindGradientHelper(func_name); + // If 'func' has a user-defined gradient function, uses the grad + // function's attrs to see if noinline is specified. Otherwise, + // uses func's attrs. + if (!grad_name.empty()) { + return FindHelper(grad_name); + } + return FindHelper(func_name); + } } FunctionDefLibrary FunctionLibraryDefinition::ToProto() const { FunctionDefLibrary lib; + tf_shared_lock l(mu_); for (const auto& f : function_defs_) { *lib.add_function() = f.second->fdef; } diff --git a/tensorflow/core/framework/function.h b/tensorflow/core/framework/function.h index 31a816ac5f..c81f4a4450 100644 --- a/tensorflow/core/framework/function.h +++ b/tensorflow/core/framework/function.h @@ -28,6 +28,7 @@ limitations under the License. #include "tensorflow/core/lib/hash/hash.h" #include "tensorflow/core/platform/env.h" #include "tensorflow/core/platform/macros.h" +#include "tensorflow/core/platform/mutex.h" #include "tensorflow/core/platform/protobuf.h" namespace tensorflow { @@ -288,8 +289,11 @@ class FunctionCallFrame : public CallFrameInterface { // Helper to maintain a map between function names in a given // FunctionDefLibrary and function definitions. +// +// This class is thread-safe. class FunctionLibraryDefinition : public OpRegistryInterface { public: + // Note: This constructor grabs `lib_def`'s lock in shared mode. explicit FunctionLibraryDefinition(const FunctionLibraryDefinition& lib_def); FunctionLibraryDefinition(const OpRegistryInterface* default_registry, const FunctionDefLibrary& lib_def); @@ -298,9 +302,15 @@ class FunctionLibraryDefinition : public OpRegistryInterface { FunctionLibraryDefinition& operator=(const FunctionLibraryDefinition&) = delete; + // Returns True if the library contains `func`, False otherwise. + bool Contains(const string& func) const; + // Returns nullptr if "func" is not defined in "lib_def". Otherwise, // returns its definition proto. - const FunctionDef* Find(const string& func) const; + // + // NB: This function returns a borrowed pointer, which can be invalidated by a + // subsequent call to `ReplaceFunction()` with the given name. + const FunctionDef* Find(const string& func) const LOCKS_EXCLUDED(mu_); // Adds function definition 'fdef' to this function library. // Returns status 'ok' on success, or error otherwise. This is a no-op if @@ -308,45 +318,45 @@ class FunctionLibraryDefinition : public OpRegistryInterface { // If 'fdef' is successfully added to the library, it will be accessible // from 'LookUp' and included in the proto returned by 'ToProto'. // This operation is atomic. - Status AddFunctionDef(const FunctionDef& fdef); + Status AddFunctionDef(const FunctionDef& fdef) LOCKS_EXCLUDED(mu_); // Adds gradient definition 'grad' to this function library. // This is a no-op if 'grad' already exists in this function library. // If 'grad' is successfully added, it will be accessible via 'FindGradient' // and included in the proto returned by 'ToProto'. // This operation is atomic. - Status AddGradientDef(const GradientDef& grad); + Status AddGradientDef(const GradientDef& grad) LOCKS_EXCLUDED(mu_); - // Remove function `func` from the library. Returns non-OK Status unless - // `func` is in the library. - Status RemoveFunction(const string& func); - - // Remove gradient of function `func` from the library. Returns non-OK Status - // unless `func` has a gradient. - Status RemoveGradient(const string& func); + // Replaces the function corresponding to `func` with `fdef`. Returns + // a non-OK status if "func" was not found in the library, OK otherwise. + Status ReplaceFunction(const string& func, const FunctionDef& fdef); // Adds the functions and gradients in 'other' to this function library. // Duplicate functions and gradients are ignored. // This operation is atomic. - Status AddLibrary(const FunctionLibraryDefinition& other); + Status AddLibrary(const FunctionLibraryDefinition& other) LOCKS_EXCLUDED(mu_); // Adds the functions and gradients in 'lib_def' to this function library. // Duplicate functions and gradients are ignored. // This operation is atomic. - Status AddLibrary(const FunctionDefLibrary& lib_def); + Status AddLibrary(const FunctionDefLibrary& lib_def) LOCKS_EXCLUDED(mu_); // If the gradient function for 'func' is specified explicitly in // the library, returns the gradient function name. Otherwise, // returns an empty string. - string FindGradient(const string& func) const; + string FindGradient(const string& func) const LOCKS_EXCLUDED(mu_); // OpRegistryInterface method. Useful for constructing a Graph. // // If "op" is defined in the library, returns its signature. // Otherwise, assume "op" is a primitive op and returns its op // signature and shape inference function. + // + // NB: This function outputs a borrowed pointer, which can be invalidated by a + // subsequent call to `ReplaceFunction()` with the given name. Status LookUp(const string& op_type_name, - const OpRegistrationData** op_reg_data) const override; + const OpRegistrationData** op_reg_data) const override + LOCKS_EXCLUDED(mu_); // Ops created for function arguments bear the name given by `kArgOp`; those // created for return values bear the name given by `kRetOp`. @@ -370,9 +380,12 @@ class FunctionLibraryDefinition : public OpRegistryInterface { Status GetAttr(const Node& node, const string& attr, T* value) const; // Returns a proto representation of the state of this function library. - FunctionDefLibrary ToProto() const; + FunctionDefLibrary ToProto() const LOCKS_EXCLUDED(mu_); - size_t num_functions() const { return function_defs_.size(); } + size_t num_functions() const { + tf_shared_lock l(mu_); + return function_defs_.size(); + } const OpRegistryInterface* default_registry() const { return default_registry_; @@ -388,24 +401,42 @@ class FunctionLibraryDefinition : public OpRegistryInterface { OpRegistrationData op_registration_data; }; + const FunctionDef* FindHelper(const string& func) const + SHARED_LOCKS_REQUIRED(mu_); + string FindGradientHelper(const string& func) const + SHARED_LOCKS_REQUIRED(mu_); + // Same as AddFunctionDef/AddGradientDef except these methods set // `added` to true if the `fdef`/`grad` were actually added to this. - Status AddFunctionDefHelper(const FunctionDef& fdef, bool* added); - Status AddGradientDefHelper(const GradientDef& grad, bool* added); + Status AddFunctionDefHelper(const FunctionDef& fdef, bool* added) + EXCLUSIVE_LOCKS_REQUIRED(mu_); + Status AddGradientDefHelper(const GradientDef& grad, bool* added) + EXCLUSIVE_LOCKS_REQUIRED(mu_); + mutable mutex mu_; const OpRegistryInterface* const default_registry_; gtl::FlatMap> - function_defs_; - gtl::FlatMap func_grad_; + function_defs_ GUARDED_BY(mu_); + gtl::FlatMap func_grad_ GUARDED_BY(mu_); // Helper function for GetAttr. Returns the FunctionDef* to get the // attr from. - const FunctionDef* GetAttrImpl(const NodeDef& ndef) const; + const FunctionDef* GetAttrImpl(const NodeDef& ndef) const LOCKS_EXCLUDED(mu_); - // Remove all functions in `funcs` and all gradients of - // functions in `funcs_with_grads` from this library. + // Remove all functions in `funcs` and all gradients of functions in + // `funcs_with_grads` from this library. void Remove(const std::vector& funcs, - const std::vector& funcs_with_grads); + const std::vector& funcs_with_grads) + EXCLUSIVE_LOCKS_REQUIRED(mu_); + + // Remove `func` from the library. Returns non-OK Status unless `func` is in + // the library. This should only be called when there is a guarantee that the + // function being removed hasn't been retrieved with `Find`. + Status RemoveFunction(const string& func) EXCLUSIVE_LOCKS_REQUIRED(mu_); + + // Remove gradient of function `func` from the library. Returns non-OK Status + // unless `func` has a gradient. + Status RemoveGradient(const string& func) EXCLUSIVE_LOCKS_REQUIRED(mu_); }; // Forward declare. Defined in common_runtime/function.h diff --git a/tensorflow/core/grappler/optimizers/meta_optimizer.cc b/tensorflow/core/grappler/optimizers/meta_optimizer.cc index e42a7807e4..e778b7879d 100644 --- a/tensorflow/core/grappler/optimizers/meta_optimizer.cc +++ b/tensorflow/core/grappler/optimizers/meta_optimizer.cc @@ -383,8 +383,7 @@ Status MetaOptimizer::Optimize(Cluster* cluster, const GrapplerItem& item, TF_RETURN_IF_ERROR(MakeFunctionDef(func_item, flib, &optimized_func)); // Replace optimized function with a new FunctionDef. - TF_RETURN_IF_ERROR(flib.RemoveFunction(func_name)); - TF_RETURN_IF_ERROR(flib.AddFunctionDef(optimized_func)); + TF_RETURN_IF_ERROR(flib.ReplaceFunction(func_name, optimized_func)); } // If optimized at least one function, update the graph library. diff --git a/tensorflow/python/eager/function_test.py b/tensorflow/python/eager/function_test.py index 7ca1131fda..0488dc9752 100644 --- a/tensorflow/python/eager/function_test.py +++ b/tensorflow/python/eager/function_test.py @@ -19,6 +19,7 @@ from __future__ import print_function import collections import functools +from multiprocessing.pool import ThreadPool import sys from tensorflow.core.protobuf import config_pb2 @@ -143,6 +144,61 @@ class FunctionTest(test.TestCase): out = sq_op(t) self.assertAllEqual(out, math_ops.matmul(t, t).numpy()) + def testExecutingStatelessDefunConcurrently(self): + + @function.defun + def stateless(x): + return math_ops.multiply(2.0, x) + + pool = ThreadPool() + inputs = [constant_op.constant(1.0 * x) for x in range(100)] + outputs = [float(out) for out in pool.map(stateless, inputs)] + expected = [float(2.0 * x) for x in inputs] + self.assertSequenceEqual(outputs, expected) + + def testExecutingManyStatelessDefunsConcurrently(self): + + @function.defun + def stateless(x): + del x + return math_ops.multiply(2.0, 2.0) + + pool = ThreadPool() + # `pool.map` below instantiates 100 functions, one for each object. + outputs = [ + float(out) + for out in pool.map(stateless, [object() for _ in range(100)]) + ] + expected = [4.0] * 100 + self.assertSequenceEqual(outputs, expected) + + def testExecutingStatefulDefunConcurrently(self): + + v = resource_variable_ops.ResourceVariable(1.0) + + @function.defun + def stateful(x): + v.assign(x) + + pool = ThreadPool() + inputs = [constant_op.constant(0.0)] * 100 + pool.map(stateful, inputs) + self.assertEqual(float(v.read_value()), 0.0) + + def testExecutingManyStatefulDefunsConcurrently(self): + + v = resource_variable_ops.ResourceVariable(1.0) + + @function.defun + def stateful(x): + del x + return v.assign(0.0) + + pool = ThreadPool() + # `pool.map` below instantiates 100 functions, one for each object. + pool.map(stateful, [object() for _ in range(100)]) + self.assertEqual(float(v.read_value()), 0.0) + def disabled_testRandomSeed(self): @function.defun -- GitLab From 0d1b1448c6f4f58f5be1c6db48a15604304c998b Mon Sep 17 00:00:00 2001 From: Jiri Simsa Date: Fri, 10 Aug 2018 14:54:00 -0700 Subject: [PATCH 360/437] [tf.data] Minor API refactoring. Renaming `AddParentDataset`, `SaveParent`, and `RestoreParent` to `AddInputDataset`, `SaveInput`, and `RestoreInput`. PiperOrigin-RevId: 208272695 --- .../data/kernels/assert_next_dataset_op.cc | 6 ++-- .../kernels/directed_interleave_dataset_op.cc | 13 ++++----- .../data/kernels/ignore_errors_dataset_op.cc | 6 ++-- .../contrib/data/kernels/unique_dataset_op.cc | 6 ++-- tensorflow/core/framework/dataset.h | 28 +++++++++---------- .../core/kernels/data/batch_dataset_op.cc | 6 ++-- .../core/kernels/data/cache_dataset_ops.cc | 20 ++++++------- .../kernels/data/concatenate_dataset_op.cc | 8 +++--- tensorflow/core/kernels/data/dataset_ops.cc | 2 +- .../data/dense_to_sparse_batch_dataset_op.cc | 6 ++-- .../data/filter_by_component_dataset_op.cc | 6 ++-- .../core/kernels/data/filter_dataset_op.cc | 6 ++-- .../core/kernels/data/flat_map_dataset_op.cc | 10 +++---- .../data/group_by_reducer_dataset_op.cc | 6 ++-- .../data/group_by_window_dataset_op.cc | 10 +++---- .../kernels/data/interleave_dataset_op.cc | 10 +++---- .../kernels/data/map_and_batch_dataset_op.cc | 6 ++-- .../core/kernels/data/map_dataset_op.cc | 6 ++-- .../core/kernels/data/optimize_dataset_op.cc | 8 +++--- .../kernels/data/padded_batch_dataset_op.cc | 6 ++-- .../data/parallel_interleave_dataset_op.cc | 10 +++---- .../kernels/data/parallel_map_dataset_op.cc | 2 +- .../kernels/data/parallel_map_iterator.cc | 4 +-- .../core/kernels/data/prefetch_dataset_op.cc | 6 ++-- .../core/kernels/data/repeat_dataset_op.cc | 10 +++---- .../core/kernels/data/scan_dataset_op.cc | 6 ++-- .../core/kernels/data/shuffle_dataset_op.cc | 10 +++---- .../core/kernels/data/skip_dataset_op.cc | 6 ++-- .../core/kernels/data/slide_dataset_op.cc | 6 ++-- .../data/stats_aggregator_dataset_op.cc | 4 +-- .../core/kernels/data/stats_dataset_ops.cc | 18 ++++++------ .../core/kernels/data/take_dataset_op.cc | 6 ++-- .../kernels/data/tensor_queue_dataset_op.cc | 6 ++-- .../core/kernels/data/unbatch_dataset_op.cc | 6 ++-- .../core/kernels/data/window_dataset_op.cc | 6 ++-- .../core/kernels/data/zip_dataset_op.cc | 6 ++-- 36 files changed, 142 insertions(+), 145 deletions(-) diff --git a/tensorflow/contrib/data/kernels/assert_next_dataset_op.cc b/tensorflow/contrib/data/kernels/assert_next_dataset_op.cc index 95b8e1f7fd..3c9858e5e5 100644 --- a/tensorflow/contrib/data/kernels/assert_next_dataset_op.cc +++ b/tensorflow/contrib/data/kernels/assert_next_dataset_op.cc @@ -79,7 +79,7 @@ class AssertNextDatasetOp : public UnaryDatasetOpKernel { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); Node* transformations_node = nullptr; TF_RETURN_IF_ERROR(b->AddVector(transformations_, &transformations_node)); TF_RETURN_IF_ERROR(b->AddDataset( @@ -121,13 +121,13 @@ class AssertNextDatasetOp : public UnaryDatasetOpKernel { protected: Status SaveInternal(IteratorStateWriter* writer) override { - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); return Status::OK(); } Status RestoreInternal(IteratorContext* ctx, IteratorStateReader* reader) override { - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); return Status::OK(); } diff --git a/tensorflow/contrib/data/kernels/directed_interleave_dataset_op.cc b/tensorflow/contrib/data/kernels/directed_interleave_dataset_op.cc index 6a12ca06f4..62e3d0d309 100644 --- a/tensorflow/contrib/data/kernels/directed_interleave_dataset_op.cc +++ b/tensorflow/contrib/data/kernels/directed_interleave_dataset_op.cc @@ -114,11 +114,11 @@ class DirectedInterleaveDatasetOp : public DatasetOpKernel { Node** output) const override { Node* selector_input_node; TF_RETURN_IF_ERROR( - b->AddParentDataset(ctx, selector_input_, &selector_input_node)); + b->AddInputDataset(ctx, selector_input_, &selector_input_node)); std::vector data_input_nodes(data_inputs_.size()); for (size_t i = 0; i < data_inputs_.size(); ++i) { TF_RETURN_IF_ERROR( - b->AddParentDataset(ctx, data_inputs_[i], &data_input_nodes[i])); + b->AddInputDataset(ctx, data_inputs_[i], &data_input_nodes[i])); } TF_RETURN_IF_ERROR(b->AddDataset(this, {{0, selector_input_node}}, {{1, data_input_nodes}}, {}, output)); @@ -204,7 +204,7 @@ class DirectedInterleaveDatasetOp : public DatasetOpKernel { Status SaveInternal(IteratorStateWriter* writer) override { mutex_lock l(mu_); if (selector_input_impl_) { - TF_RETURN_IF_ERROR(SaveParent(writer, selector_input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, selector_input_impl_)); } else { TF_RETURN_IF_ERROR( writer->WriteScalar(full_name("selector_input_impl_empty"), "")); @@ -212,7 +212,7 @@ class DirectedInterleaveDatasetOp : public DatasetOpKernel { for (size_t i = 0; i < data_input_impls_.size(); ++i) { const auto& data_input_impl = data_input_impls_[i]; if (data_input_impl) { - TF_RETURN_IF_ERROR(SaveParent(writer, data_input_impl)); + TF_RETURN_IF_ERROR(SaveInput(writer, data_input_impl)); } else { TF_RETURN_IF_ERROR(writer->WriteScalar( full_name(strings::StrCat("data_input_impl_empty[", i, "]")), @@ -226,15 +226,14 @@ class DirectedInterleaveDatasetOp : public DatasetOpKernel { IteratorStateReader* reader) override { mutex_lock l(mu_); if (!reader->Contains(full_name("selector_input_impl_empty"))) { - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, selector_input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, selector_input_impl_)); } else { selector_input_impl_.reset(); } for (size_t i = 0; i < data_input_impls_.size(); ++i) { if (!reader->Contains(full_name( strings::StrCat("data_input_impl_empty[", i, "]")))) { - TF_RETURN_IF_ERROR( - RestoreParent(ctx, reader, data_input_impls_[i])); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, data_input_impls_[i])); } else { data_input_impls_[i].reset(); } diff --git a/tensorflow/contrib/data/kernels/ignore_errors_dataset_op.cc b/tensorflow/contrib/data/kernels/ignore_errors_dataset_op.cc index bbec50681c..e5bf6fd951 100644 --- a/tensorflow/contrib/data/kernels/ignore_errors_dataset_op.cc +++ b/tensorflow/contrib/data/kernels/ignore_errors_dataset_op.cc @@ -65,7 +65,7 @@ class IgnoreErrorsDatasetOp : public UnaryDatasetOpKernel { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); TF_RETURN_IF_ERROR(b->AddDataset(this, {input_graph_node}, output)); return Status::OK(); } @@ -106,7 +106,7 @@ class IgnoreErrorsDatasetOp : public UnaryDatasetOpKernel { Status SaveInternal(IteratorStateWriter* writer) override { mutex_lock l(mu_); if (input_impl_) - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); else TF_RETURN_IF_ERROR( writer->WriteScalar(full_name("input_impls_empty"), "")); @@ -119,7 +119,7 @@ class IgnoreErrorsDatasetOp : public UnaryDatasetOpKernel { if (reader->Contains(full_name("input_impls_empty"))) input_impl_.reset(); else - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); return Status::OK(); } diff --git a/tensorflow/contrib/data/kernels/unique_dataset_op.cc b/tensorflow/contrib/data/kernels/unique_dataset_op.cc index 67c237799c..406f9c57f7 100644 --- a/tensorflow/contrib/data/kernels/unique_dataset_op.cc +++ b/tensorflow/contrib/data/kernels/unique_dataset_op.cc @@ -78,7 +78,7 @@ class UniqueDatasetOp : public UnaryDatasetOpKernel { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); TF_RETURN_IF_ERROR(b->AddDataset(this, {input_graph_node}, output)); return Status::OK(); } @@ -116,7 +116,7 @@ class UniqueDatasetOp : public UnaryDatasetOpKernel { Status SaveInternal(IteratorStateWriter* writer) override { mutex_lock l(mu_); if (input_impl_) { - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); } else { TF_RETURN_IF_ERROR( writer->WriteScalar(full_name("input_impl_empty"), "")); @@ -135,7 +135,7 @@ class UniqueDatasetOp : public UnaryDatasetOpKernel { IteratorStateReader* reader) override { mutex_lock l(mu_); if (!reader->Contains(full_name("input_impl_empty"))) { - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); } else { input_impl_.reset(); } diff --git a/tensorflow/core/framework/dataset.h b/tensorflow/core/framework/dataset.h index ad73a3d0c7..0e3d5adecd 100644 --- a/tensorflow/core/framework/dataset.h +++ b/tensorflow/core/framework/dataset.h @@ -368,19 +368,17 @@ class IteratorBase { protected: // This is needed so that sub-classes of IteratorBase can call - // `SaveInternal` on their parent iterators, e.g., in - // `RepeatDatasetOp::Dataset`. - Status SaveParent(IteratorStateWriter* writer, - const std::unique_ptr& parent) { - return parent->SaveInternal(writer); + // `SaveInternal` on their input iterators. + Status SaveInput(IteratorStateWriter* writer, + const std::unique_ptr& input) { + return input->SaveInternal(writer); } // This is needed so that sub-classes of IteratorBase can call - // `RestoreInternal` on their parent iterators, e.g., in - // `RepeatDatasetOp::Dataset`. - Status RestoreParent(IteratorContext* ctx, IteratorStateReader* reader, - const std::unique_ptr& parent) { - return parent->RestoreInternal(ctx, reader); + // `RestoreInternal` on their input iterators. + Status RestoreInput(IteratorContext* ctx, IteratorStateReader* reader, + const std::unique_ptr& input) { + return input->RestoreInternal(ctx, reader); } // Saves the state of this iterator recursively. @@ -441,8 +439,8 @@ class DatasetBase : public core::RefCounted { class DatasetGraphDefBuilder : public GraphDefBuilderWrapper { public: DatasetGraphDefBuilder(GraphDefBuilder* b) : GraphDefBuilderWrapper(b) {} - Status AddParentDataset(OpKernelContext* ctx, const DatasetBase* dataset, - Node** output) { + Status AddInputDataset(OpKernelContext* ctx, const DatasetBase* dataset, + Node** output) { return dataset->AsGraphDefInternal(ctx, this, output); } }; @@ -498,7 +496,7 @@ class GraphDatasetBase : public DatasetBase { const string op_name_; }; -// Represents an iterator that is associated with a particular parent dataset. +// Represents an iterator that is associated with a particular dataset. class DatasetBaseIterator : public IteratorBase { public: struct BaseParams { @@ -560,13 +558,13 @@ class DatasetBaseIterator : public IteratorBase { BaseParams params_; }; -// Represents an iterator that is associated with a particular parent dataset +// Represents an iterator that is associated with a particular dataset // with a particular type. template class DatasetIterator : public DatasetBaseIterator { public: struct Params { - // Borrowed pointer to the parent dataset. + // Borrowed pointer to the dataset. const DatasetType* dataset; // Identifies the sequence of iterators leading up to this iterator. diff --git a/tensorflow/core/kernels/data/batch_dataset_op.cc b/tensorflow/core/kernels/data/batch_dataset_op.cc index 58b86f2a08..2ee4548621 100644 --- a/tensorflow/core/kernels/data/batch_dataset_op.cc +++ b/tensorflow/core/kernels/data/batch_dataset_op.cc @@ -99,7 +99,7 @@ class BatchDatasetOp : public UnaryDatasetOpKernel { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); Node* batch_size = nullptr; TF_RETURN_IF_ERROR(b->AddScalar(batch_size_, &batch_size)); Node* drop_remainder = nullptr; @@ -203,7 +203,7 @@ class BatchDatasetOp : public UnaryDatasetOpKernel { TF_RETURN_IF_ERROR( writer->WriteScalar(full_name("input_impl_empty"), "")); } else { - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); } return Status::OK(); } @@ -212,7 +212,7 @@ class BatchDatasetOp : public UnaryDatasetOpKernel { IteratorStateReader* reader) override { mutex_lock l(mu_); if (!reader->Contains(full_name("input_impl_empty"))) { - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); } else { input_impl_.reset(); } diff --git a/tensorflow/core/kernels/data/cache_dataset_ops.cc b/tensorflow/core/kernels/data/cache_dataset_ops.cc index 86b0840aea..4f23d07aae 100644 --- a/tensorflow/core/kernels/data/cache_dataset_ops.cc +++ b/tensorflow/core/kernels/data/cache_dataset_ops.cc @@ -88,7 +88,7 @@ class CacheDatasetOp : public UnaryDatasetOpKernel { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph)); Node* filename = nullptr; TF_RETURN_IF_ERROR(b->AddScalar(filename_, &filename)); TF_RETURN_IF_ERROR(b->AddDataset(this, {input_graph, filename}, output)); @@ -135,7 +135,7 @@ class CacheDatasetOp : public UnaryDatasetOpKernel { Status SaveInternal(IteratorStateWriter* writer) override { mutex_lock l(mu_); TF_RETURN_IF_ERROR(writer->WriteScalar(full_name("mode"), mode_)); - return SaveParent(writer, iterator_); + return SaveInput(writer, iterator_); } Status RestoreInternal(IteratorContext* ctx, IteratorStateReader* reader) override { @@ -162,7 +162,7 @@ class CacheDatasetOp : public UnaryDatasetOpKernel { } InitializeIterator(); TF_RETURN_IF_ERROR(iterator_->Initialize(ctx)); - return RestoreParent(ctx, reader, iterator_); + return RestoreInput(ctx, reader, iterator_); } private: @@ -269,7 +269,7 @@ class CacheDatasetOp : public UnaryDatasetOpKernel { lockfile_ = strings::StrCat(filename_, ".lockfile"); lockfile_created_ = false; } - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); TF_RETURN_IF_ERROR( writer->WriteScalar(full_name("cur_index"), cur_index_)); TF_RETURN_IF_ERROR( @@ -285,7 +285,7 @@ class CacheDatasetOp : public UnaryDatasetOpKernel { return Status::OK(); } - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); int64 temp; // TODO(b/78048575): Update this when saving size_t tensors directly // is supported. @@ -569,7 +569,7 @@ class CacheDatasetOp : public UnaryDatasetOpKernel { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_node)); Node* filename_node = nullptr; TF_RETURN_IF_ERROR(b->AddScalar(string(""), &filename_node)); TF_RETURN_IF_ERROR( @@ -702,7 +702,7 @@ class CacheDatasetOp : public UnaryDatasetOpKernel { writer->WriteScalar(full_name("cache_completed"), "")); } } - return SaveParent(writer, iterator_); + return SaveInput(writer, iterator_); } Status RestoreInternal(IteratorContext* ctx, @@ -748,7 +748,7 @@ class CacheDatasetOp : public UnaryDatasetOpKernel { } InitializeIterator(); TF_RETURN_IF_ERROR(iterator_->Initialize(ctx)); - return RestoreParent(ctx, reader, iterator_); + return RestoreInput(ctx, reader, iterator_); } private: @@ -795,13 +795,13 @@ class CacheDatasetOp : public UnaryDatasetOpKernel { protected: Status SaveInternal(IteratorStateWriter* writer) override { mutex_lock l(mu_); - return SaveParent(writer, input_impl_); + return SaveInput(writer, input_impl_); } Status RestoreInternal(IteratorContext* ctx, IteratorStateReader* reader) override { mutex_lock l(mu_); - return RestoreParent(ctx, reader, input_impl_); + return RestoreInput(ctx, reader, input_impl_); } private: diff --git a/tensorflow/core/kernels/data/concatenate_dataset_op.cc b/tensorflow/core/kernels/data/concatenate_dataset_op.cc index 0012a4769d..98282d74a9 100644 --- a/tensorflow/core/kernels/data/concatenate_dataset_op.cc +++ b/tensorflow/core/kernels/data/concatenate_dataset_op.cc @@ -83,10 +83,10 @@ class ConcatenateDatasetOp : public BinaryDatasetOpKernel { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph)); Node* to_concatenate_graph = nullptr; TF_RETURN_IF_ERROR( - b->AddParentDataset(ctx, to_concatenate_, &to_concatenate_graph)); + b->AddInputDataset(ctx, to_concatenate_, &to_concatenate_graph)); TF_RETURN_IF_ERROR( b->AddDataset(this, {input_graph, to_concatenate_graph}, output)); return Status::OK(); @@ -132,7 +132,7 @@ class ConcatenateDatasetOp : public BinaryDatasetOpKernel { mutex_lock l(mu_); TF_RETURN_IF_ERROR(writer->WriteScalar(full_name("i"), i_)); if (input_impl_) { - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); } else { TF_RETURN_IF_ERROR( writer->WriteScalar(full_name("input_impl_uninitialized"), "")); @@ -157,7 +157,7 @@ class ConcatenateDatasetOp : public BinaryDatasetOpKernel { input_impl_.reset(); } if (input_impl_) { - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); } return Status::OK(); } diff --git a/tensorflow/core/kernels/data/dataset_ops.cc b/tensorflow/core/kernels/data/dataset_ops.cc index 01989a3bd9..d15cdf215e 100644 --- a/tensorflow/core/kernels/data/dataset_ops.cc +++ b/tensorflow/core/kernels/data/dataset_ops.cc @@ -32,7 +32,7 @@ class DatasetToGraphOp : public OpKernel { GraphDefBuilder b; DatasetBase::DatasetGraphDefBuilder db(&b); Node* input_node = nullptr; - OP_REQUIRES_OK(ctx, db.AddParentDataset(ctx, dataset, &input_node)); + OP_REQUIRES_OK(ctx, db.AddInputDataset(ctx, dataset, &input_node)); GraphDef graph_def; OP_REQUIRES_OK(ctx, b.ToGraphDef(&graph_def)); Tensor* result; diff --git a/tensorflow/core/kernels/data/dense_to_sparse_batch_dataset_op.cc b/tensorflow/core/kernels/data/dense_to_sparse_batch_dataset_op.cc index da4b14c8b9..77a04ef3f1 100644 --- a/tensorflow/core/kernels/data/dense_to_sparse_batch_dataset_op.cc +++ b/tensorflow/core/kernels/data/dense_to_sparse_batch_dataset_op.cc @@ -118,7 +118,7 @@ class DenseToSparseBatchDatasetOp : public UnaryDatasetOpKernel { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_node; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_node)); Node* batch_size_node; TF_RETURN_IF_ERROR(b->AddScalar(batch_size_, &batch_size_node)); Node* row_shape_node; @@ -273,14 +273,14 @@ class DenseToSparseBatchDatasetOp : public UnaryDatasetOpKernel { protected: Status SaveInternal(IteratorStateWriter* writer) override { mutex_lock l(mu_); - TF_RETURN_IF_ERROR(Iterator::SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(Iterator::SaveInput(writer, input_impl_)); return Status::OK(); } Status RestoreInternal(IteratorContext* ctx, IteratorStateReader* reader) override { mutex_lock l(mu_); - TF_RETURN_IF_ERROR(Iterator::RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(Iterator::RestoreInput(ctx, reader, input_impl_)); return Status::OK(); } diff --git a/tensorflow/core/kernels/data/filter_by_component_dataset_op.cc b/tensorflow/core/kernels/data/filter_by_component_dataset_op.cc index 8b29456354..2f6479de16 100644 --- a/tensorflow/core/kernels/data/filter_by_component_dataset_op.cc +++ b/tensorflow/core/kernels/data/filter_by_component_dataset_op.cc @@ -83,7 +83,7 @@ class FilterByLastComponentDatasetOp : public UnaryDatasetOpKernel { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); TF_RETURN_IF_ERROR(b->AddDataset( this, {std::make_pair(0, input_graph_node)}, // Single tensor inputs. @@ -143,14 +143,14 @@ class FilterByLastComponentDatasetOp : public UnaryDatasetOpKernel { protected: Status SaveInternal(IteratorStateWriter* writer) override { mutex_lock l(mu_); - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); return Status::OK(); } Status RestoreInternal(IteratorContext* ctx, IteratorStateReader* reader) override { mutex_lock l(mu_); - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); return Status::OK(); } diff --git a/tensorflow/core/kernels/data/filter_dataset_op.cc b/tensorflow/core/kernels/data/filter_dataset_op.cc index 6d6c44552d..aebc2f065f 100644 --- a/tensorflow/core/kernels/data/filter_dataset_op.cc +++ b/tensorflow/core/kernels/data/filter_dataset_op.cc @@ -113,7 +113,7 @@ class FilterDatasetOp : public UnaryDatasetOpKernel { Node** output) const override { TF_RETURN_IF_ERROR(b->AddFunction(ctx, func_.name())); Node* input_graph_node; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); DataTypeVector other_arguments_types; other_arguments_types.reserve(captured_func_->captured_inputs().size()); @@ -190,7 +190,7 @@ class FilterDatasetOp : public UnaryDatasetOpKernel { Status SaveInternal(IteratorStateWriter* writer) override { mutex_lock l(mu_); if (input_impl_) - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); else TF_RETURN_IF_ERROR( writer->WriteScalar(full_name("input_impls_empty"), "")); @@ -203,7 +203,7 @@ class FilterDatasetOp : public UnaryDatasetOpKernel { if (reader->Contains(full_name("input_impls_empty"))) input_impl_.reset(); else - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); return Status::OK(); } diff --git a/tensorflow/core/kernels/data/flat_map_dataset_op.cc b/tensorflow/core/kernels/data/flat_map_dataset_op.cc index baca022f1e..aae3f19c0d 100644 --- a/tensorflow/core/kernels/data/flat_map_dataset_op.cc +++ b/tensorflow/core/kernels/data/flat_map_dataset_op.cc @@ -95,7 +95,7 @@ class FlatMapDatasetOp : public UnaryDatasetOpKernel { Node** output) const override { TF_RETURN_IF_ERROR(b->AddFunction(ctx, func_.name())); Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); DataTypeVector other_arguments_types; other_arguments_types.reserve(captured_func_->captured_inputs().size()); @@ -174,7 +174,7 @@ class FlatMapDatasetOp : public UnaryDatasetOpKernel { Status SaveInternal(IteratorStateWriter* writer) override { mutex_lock l(mu_); if (input_impl_) { - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); TF_RETURN_IF_ERROR( writer->WriteScalar(full_name("element_index"), element_index_)); if (current_element_iterator_) { @@ -186,7 +186,7 @@ class FlatMapDatasetOp : public UnaryDatasetOpKernel { full_name(strings::StrCat("captured_func_inputs[", i, "]")), captured_func_inputs_[i])); } - TF_RETURN_IF_ERROR(SaveParent(writer, current_element_iterator_)); + TF_RETURN_IF_ERROR(SaveInput(writer, current_element_iterator_)); } else { TF_RETURN_IF_ERROR(writer->WriteScalar( full_name("current_element_iterator_uninitialized"), "")); @@ -207,7 +207,7 @@ class FlatMapDatasetOp : public UnaryDatasetOpKernel { if (!reader->Contains(full_name("exhausted"))) { TF_RETURN_IF_ERROR( dataset()->input_->MakeIterator(ctx, prefix(), &input_impl_)); - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); { int64 temp; TF_RETURN_IF_ERROR( @@ -233,7 +233,7 @@ class FlatMapDatasetOp : public UnaryDatasetOpKernel { element_index_--; TF_RETURN_IF_ERROR(BuildCurrentElementIteratorLocked(ctx)); TF_RETURN_IF_ERROR( - RestoreParent(ctx, reader, current_element_iterator_)); + RestoreInput(ctx, reader, current_element_iterator_)); } } return Status::OK(); diff --git a/tensorflow/core/kernels/data/group_by_reducer_dataset_op.cc b/tensorflow/core/kernels/data/group_by_reducer_dataset_op.cc index 7206be8c0d..f245fc402d 100644 --- a/tensorflow/core/kernels/data/group_by_reducer_dataset_op.cc +++ b/tensorflow/core/kernels/data/group_by_reducer_dataset_op.cc @@ -113,7 +113,7 @@ class GroupByReducerDatasetOp : public UnaryDatasetOpKernel { TF_RETURN_IF_ERROR(b->AddFunction(ctx, reduce_func().name())); TF_RETURN_IF_ERROR(b->AddFunction(ctx, finalize_func().name())); Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); std::vector key_func_other_arguments_node; DataTypeVector key_func_other_arguments_types; @@ -261,7 +261,7 @@ class GroupByReducerDatasetOp : public UnaryDatasetOpKernel { protected: Status SaveInternal(IteratorStateWriter* writer) override { mutex_lock l(mu_); - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); if (end_of_input_) { TF_RETURN_IF_ERROR( @@ -311,7 +311,7 @@ class GroupByReducerDatasetOp : public UnaryDatasetOpKernel { Status RestoreInternal(IteratorContext* ctx, IteratorStateReader* reader) override { mutex_lock l(mu_); - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); if (reader->Contains(full_name("end_of_input"))) end_of_input_ = true; diff --git a/tensorflow/core/kernels/data/group_by_window_dataset_op.cc b/tensorflow/core/kernels/data/group_by_window_dataset_op.cc index 23d769e1ab..f6664fc5fb 100644 --- a/tensorflow/core/kernels/data/group_by_window_dataset_op.cc +++ b/tensorflow/core/kernels/data/group_by_window_dataset_op.cc @@ -142,7 +142,7 @@ class GroupByWindowDatasetOp : public UnaryDatasetOpKernel { TF_RETURN_IF_ERROR(b->AddFunction(ctx, reduce_func_.name())); TF_RETURN_IF_ERROR(b->AddFunction(ctx, window_size_func_.name())); Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); std::vector key_func_other_arguments_node; DataTypeVector key_func_other_arguments_types; @@ -307,7 +307,7 @@ class GroupByWindowDatasetOp : public UnaryDatasetOpKernel { protected: Status SaveInternal(IteratorStateWriter* writer) override { mutex_lock l(mu_); - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); if (end_of_input_) { TF_RETURN_IF_ERROR( @@ -348,7 +348,7 @@ class GroupByWindowDatasetOp : public UnaryDatasetOpKernel { } if (current_group_iterator_) { - TF_RETURN_IF_ERROR(SaveParent(writer, current_group_iterator_)); + TF_RETURN_IF_ERROR(SaveInput(writer, current_group_iterator_)); // Saving current_key_ TF_RETURN_IF_ERROR( @@ -364,7 +364,7 @@ class GroupByWindowDatasetOp : public UnaryDatasetOpKernel { Status RestoreInternal(IteratorContext* ctx, IteratorStateReader* reader) override { mutex_lock l(mu_); - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); if (reader->Contains(full_name("end_of_input"))) end_of_input_ = true; @@ -412,7 +412,7 @@ class GroupByWindowDatasetOp : public UnaryDatasetOpKernel { TF_RETURN_IF_ERROR(StartFlushingGroup(ctx, current_key_)); // Restore current_group_iterator_ state TF_RETURN_IF_ERROR( - RestoreParent(ctx, reader, current_group_iterator_)); + RestoreInput(ctx, reader, current_group_iterator_)); } return Status::OK(); } diff --git a/tensorflow/core/kernels/data/interleave_dataset_op.cc b/tensorflow/core/kernels/data/interleave_dataset_op.cc index 0765e63993..20096a6590 100644 --- a/tensorflow/core/kernels/data/interleave_dataset_op.cc +++ b/tensorflow/core/kernels/data/interleave_dataset_op.cc @@ -118,7 +118,7 @@ class InterleaveDatasetOp : public UnaryDatasetOpKernel { Node** output) const override { TF_RETURN_IF_ERROR(b->AddFunction(ctx, func_.name())); Node* input_node; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_node)); Node* cycle_length_node; TF_RETURN_IF_ERROR(b->AddScalar(cycle_length_, &cycle_length_node)); Node* block_length_node; @@ -217,7 +217,7 @@ class InterleaveDatasetOp : public UnaryDatasetOpKernel { protected: Status SaveInternal(IteratorStateWriter* writer) override { mutex_lock l(mu_); - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); TF_RETURN_IF_ERROR( writer->WriteScalar(full_name("cycle_index"), cycle_index_)); TF_RETURN_IF_ERROR( @@ -235,7 +235,7 @@ class InterleaveDatasetOp : public UnaryDatasetOpKernel { Status RestoreInternal(IteratorContext* ctx, IteratorStateReader* reader) override { mutex_lock l(mu_); - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); int64 cycle_index; TF_RETURN_IF_ERROR( reader->ReadScalar(full_name("cycle_index"), &cycle_index)); @@ -256,7 +256,7 @@ class InterleaveDatasetOp : public UnaryDatasetOpKernel { EXCLUSIVE_LOCKS_REQUIRED(mu_) { for (int idx = 0; idx < current_elements_.size(); idx++) { if (current_elements_[idx]) { - TF_RETURN_IF_ERROR(SaveParent(writer, current_elements_[idx])); + TF_RETURN_IF_ERROR(SaveInput(writer, current_elements_[idx])); TF_RETURN_IF_ERROR(writer->WriteScalar( full_name(strings::StrCat("args_size[", idx, "]")), args_list_[idx].size())); @@ -290,7 +290,7 @@ class InterleaveDatasetOp : public UnaryDatasetOpKernel { ctx, args_list_[idx], idx, dataset()->captured_func_.get(), prefix(), ¤t_elements_[idx])); TF_RETURN_IF_ERROR( - RestoreParent(ctx, reader, current_elements_[idx])); + RestoreInput(ctx, reader, current_elements_[idx])); } else { current_elements_[idx].reset(); } diff --git a/tensorflow/core/kernels/data/map_and_batch_dataset_op.cc b/tensorflow/core/kernels/data/map_and_batch_dataset_op.cc index 5a674bea91..e0f164e784 100644 --- a/tensorflow/core/kernels/data/map_and_batch_dataset_op.cc +++ b/tensorflow/core/kernels/data/map_and_batch_dataset_op.cc @@ -148,7 +148,7 @@ class MapAndBatchDatasetOp : public UnaryDatasetOpKernel { Node** output) const override { TF_RETURN_IF_ERROR(b->AddFunction(ctx, map_fn_.name())); Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); Node* batch_size_node; TF_RETURN_IF_ERROR(b->AddScalar(batch_size_, &batch_size_node)); Node* num_parallel_calls_node; @@ -232,7 +232,7 @@ class MapAndBatchDatasetOp : public UnaryDatasetOpKernel { cond_var_.wait(l); } CHECK_EQ(num_calls_, 0); - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); TF_RETURN_IF_ERROR( writer->WriteScalar(full_name("call_counter"), call_counter_)); TF_RETURN_IF_ERROR(writer->WriteScalar(full_name("batch_results_size"), @@ -246,7 +246,7 @@ class MapAndBatchDatasetOp : public UnaryDatasetOpKernel { Status RestoreInternal(IteratorContext* ctx, IteratorStateReader* reader) override { mutex_lock l(mu_); - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); TF_RETURN_IF_ERROR( reader->ReadScalar(full_name("call_counter"), &call_counter_)); int64 batch_results_size; diff --git a/tensorflow/core/kernels/data/map_dataset_op.cc b/tensorflow/core/kernels/data/map_dataset_op.cc index aa530aea19..852c942e99 100644 --- a/tensorflow/core/kernels/data/map_dataset_op.cc +++ b/tensorflow/core/kernels/data/map_dataset_op.cc @@ -93,7 +93,7 @@ class MapDatasetOp : public UnaryDatasetOpKernel { Node** output) const override { TF_RETURN_IF_ERROR(b->AddFunction(ctx, func_.name())); Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); DataTypeVector other_arguments_types; other_arguments_types.reserve(captured_func_->captured_inputs().size()); @@ -159,13 +159,13 @@ class MapDatasetOp : public UnaryDatasetOpKernel { protected: Status SaveInternal(IteratorStateWriter* writer) override { - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); return Status::OK(); } Status RestoreInternal(IteratorContext* ctx, IteratorStateReader* reader) override { - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); return Status::OK(); } diff --git a/tensorflow/core/kernels/data/optimize_dataset_op.cc b/tensorflow/core/kernels/data/optimize_dataset_op.cc index 276f5f89c8..14a0aa7844 100644 --- a/tensorflow/core/kernels/data/optimize_dataset_op.cc +++ b/tensorflow/core/kernels/data/optimize_dataset_op.cc @@ -88,7 +88,7 @@ class OptimizeDatasetOp : public UnaryDatasetOpKernel { GraphDefBuilder b; DatasetGraphDefBuilder db(&b); Node* input_node = nullptr; - TF_RETURN_IF_ERROR(db.AddParentDataset(ctx, input_, &input_node)); + TF_RETURN_IF_ERROR(db.AddInputDataset(ctx, input_, &input_node)); string output_node = input_node->name(); GraphDef graph_def; TF_RETURN_IF_ERROR(b.ToGraphDef(&graph_def)); @@ -122,7 +122,7 @@ class OptimizeDatasetOp : public UnaryDatasetOpKernel { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); Node* optimizations_node = nullptr; TF_RETURN_IF_ERROR(b->AddVector(optimizations_, &optimizations_node)); TF_RETURN_IF_ERROR( @@ -157,13 +157,13 @@ class OptimizeDatasetOp : public UnaryDatasetOpKernel { protected: Status SaveInternal(IteratorStateWriter* writer) override { - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); return Status::OK(); } Status RestoreInternal(IteratorContext* ctx, IteratorStateReader* reader) override { - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); return Status::OK(); } diff --git a/tensorflow/core/kernels/data/padded_batch_dataset_op.cc b/tensorflow/core/kernels/data/padded_batch_dataset_op.cc index 59cbdb655d..dd4b0f9f4c 100644 --- a/tensorflow/core/kernels/data/padded_batch_dataset_op.cc +++ b/tensorflow/core/kernels/data/padded_batch_dataset_op.cc @@ -156,7 +156,7 @@ class PaddedBatchDatasetOp : public UnaryDatasetOpKernel { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); Node* batch_size = nullptr; TF_RETURN_IF_ERROR(b->AddScalar(batch_size_, &batch_size)); @@ -339,7 +339,7 @@ class PaddedBatchDatasetOp : public UnaryDatasetOpKernel { Status SaveInternal(IteratorStateWriter* writer) override { mutex_lock l(mu_); if (input_impl_) - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); else TF_RETURN_IF_ERROR(writer->WriteScalar(full_name("exhausted"), "")); return Status::OK(); @@ -353,7 +353,7 @@ class PaddedBatchDatasetOp : public UnaryDatasetOpKernel { } else { TF_RETURN_IF_ERROR( dataset()->input_->MakeIterator(ctx, prefix(), &input_impl_)); - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); } return Status::OK(); } diff --git a/tensorflow/core/kernels/data/parallel_interleave_dataset_op.cc b/tensorflow/core/kernels/data/parallel_interleave_dataset_op.cc index 6292b4536e..1995708732 100644 --- a/tensorflow/core/kernels/data/parallel_interleave_dataset_op.cc +++ b/tensorflow/core/kernels/data/parallel_interleave_dataset_op.cc @@ -138,7 +138,7 @@ class ParallelInterleaveDatasetOp : public UnaryDatasetOpKernel { Node** output) const override { TF_RETURN_IF_ERROR(b->AddFunction(ctx, interleave_func_.name())); Node* input_node; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_node)); Node* cycle_length_node; TF_RETURN_IF_ERROR(b->AddScalar(cycle_length_, &cycle_length_node)); Node* block_length_node; @@ -358,7 +358,7 @@ class ParallelInterleaveDatasetOp : public UnaryDatasetOpKernel { mutex_lock l(mu_); mutex_lock ckpt_l(ckpt_mu_); if (input_impl_) { - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); } else { TF_RETURN_IF_ERROR( writer->WriteScalar(full_name("input_exhausted"), "")); @@ -402,7 +402,7 @@ class ParallelInterleaveDatasetOp : public UnaryDatasetOpKernel { mutex_lock l(mu_); mutex_lock ckpt_l(ckpt_mu_); if (!reader->Contains(full_name("input_exhausted"))) { - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); } else { input_impl_.reset(); } @@ -858,7 +858,7 @@ class ParallelInterleaveDatasetOp : public UnaryDatasetOpKernel { string prefix = strings::StrCat("worker_thread_", index); if (worker_thread_states_[index].iterator != nullptr) { TF_RETURN_IF_ERROR( - SaveParent(writer, worker_thread_states_[index].iterator)); + SaveInput(writer, worker_thread_states_[index].iterator)); } else { TF_RETURN_IF_ERROR(writer->WriteScalar( full_name(strings::StrCat(prefix, "_iterator_exhausted")), "")); @@ -909,7 +909,7 @@ class ParallelInterleaveDatasetOp : public UnaryDatasetOpKernel { Status s = dataset::MakeIteratorFromInputElement( ctx, worker_thread_states_[index].input, index, dataset()->captured_func_.get(), prefix(), &iterator); - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, iterator)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, iterator)); worker_thread_states_[index].iterator.swap(iterator); } TF_RETURN_IF_ERROR(ReadStatusLocked( diff --git a/tensorflow/core/kernels/data/parallel_map_dataset_op.cc b/tensorflow/core/kernels/data/parallel_map_dataset_op.cc index b736b33c2e..2cbdde01ec 100644 --- a/tensorflow/core/kernels/data/parallel_map_dataset_op.cc +++ b/tensorflow/core/kernels/data/parallel_map_dataset_op.cc @@ -117,7 +117,7 @@ class ParallelMapDatasetOp : public UnaryDatasetOpKernel { Node** output) const override { // Input: input_dataset Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); // Input: other_arguments DataTypeVector other_arguments_types; diff --git a/tensorflow/core/kernels/data/parallel_map_iterator.cc b/tensorflow/core/kernels/data/parallel_map_iterator.cc index 10549df25e..4d32b719a4 100644 --- a/tensorflow/core/kernels/data/parallel_map_iterator.cc +++ b/tensorflow/core/kernels/data/parallel_map_iterator.cc @@ -78,7 +78,7 @@ class ParallelMapIterator : public DatasetBaseIterator { cond_var_.wait(l); } CHECK_EQ(num_calls_, 0); - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); TF_RETURN_IF_ERROR( writer->WriteScalar(full_name("invocation_results.size"), invocation_results_.size())); @@ -107,7 +107,7 @@ class ParallelMapIterator : public DatasetBaseIterator { Status RestoreInternal(IteratorContext* ctx, IteratorStateReader* reader) override { mutex_lock l(mu_); - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); int64 invocation_results_size; TF_RETURN_IF_ERROR(reader->ReadScalar( full_name("invocation_results.size"), &invocation_results_size)); diff --git a/tensorflow/core/kernels/data/prefetch_dataset_op.cc b/tensorflow/core/kernels/data/prefetch_dataset_op.cc index 9000842840..ccdb7c1479 100644 --- a/tensorflow/core/kernels/data/prefetch_dataset_op.cc +++ b/tensorflow/core/kernels/data/prefetch_dataset_op.cc @@ -54,7 +54,7 @@ class PrefetchDatasetOp::Dataset : public GraphDatasetBase { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); Node* buffer_size = nullptr; TF_RETURN_IF_ERROR(b->AddScalar(buffer_size_, &buffer_size)); TF_RETURN_IF_ERROR( @@ -131,7 +131,7 @@ class PrefetchDatasetOp::Dataset : public GraphDatasetBase { // all GetNext threads are blocked. mutex_lock parent_l(parent_mu_); mutex_lock l(mu_); - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); TF_RETURN_IF_ERROR( writer->WriteScalar(full_name("buffer_size"), buffer_.size())); for (size_t i = 0; i < buffer_.size(); i++) { @@ -156,7 +156,7 @@ class PrefetchDatasetOp::Dataset : public GraphDatasetBase { mutex_lock parent_l(parent_mu_); mutex_lock l(mu_); buffer_.clear(); - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); size_t buffer_size; { int64 temp; diff --git a/tensorflow/core/kernels/data/repeat_dataset_op.cc b/tensorflow/core/kernels/data/repeat_dataset_op.cc index 6b3f4ed27b..002b0ee596 100644 --- a/tensorflow/core/kernels/data/repeat_dataset_op.cc +++ b/tensorflow/core/kernels/data/repeat_dataset_op.cc @@ -75,7 +75,7 @@ class RepeatDatasetOp : public UnaryDatasetOpKernel { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); Node* count = nullptr; TF_RETURN_IF_ERROR(b->AddScalar(count_, &count)); TF_RETURN_IF_ERROR( @@ -145,7 +145,7 @@ class RepeatDatasetOp : public UnaryDatasetOpKernel { TF_RETURN_IF_ERROR( writer->WriteScalar(full_name("input_impl_empty"), "")); } else { - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); } return Status::OK(); } @@ -155,7 +155,7 @@ class RepeatDatasetOp : public UnaryDatasetOpKernel { mutex_lock l(mu_); TF_RETURN_IF_ERROR(reader->ReadScalar(full_name("i"), &i_)); if (!reader->Contains(full_name("input_impl_empty"))) { - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); } else { input_impl_.reset(); } @@ -205,7 +205,7 @@ class RepeatDatasetOp : public UnaryDatasetOpKernel { Status SaveInternal(IteratorStateWriter* writer) override { mutex_lock l(mu_); if (input_impl_) - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); else TF_RETURN_IF_ERROR( writer->WriteScalar(full_name("uninitialized"), "")); @@ -220,7 +220,7 @@ class RepeatDatasetOp : public UnaryDatasetOpKernel { } else { TF_RETURN_IF_ERROR( dataset()->input_->MakeIterator(ctx, prefix(), &input_impl_)); - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); } return Status::OK(); } diff --git a/tensorflow/core/kernels/data/scan_dataset_op.cc b/tensorflow/core/kernels/data/scan_dataset_op.cc index a3b20016a8..b0874a5509 100644 --- a/tensorflow/core/kernels/data/scan_dataset_op.cc +++ b/tensorflow/core/kernels/data/scan_dataset_op.cc @@ -110,7 +110,7 @@ class ScanDatasetOp : public UnaryDatasetOpKernel { Node** output) const override { TF_RETURN_IF_ERROR(b->AddFunction(ctx, func_.name())); Node* input_node; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_node)); std::vector initial_state_nodes; initial_state_nodes.reserve(initial_state_.size()); for (const Tensor& t : initial_state_) { @@ -222,7 +222,7 @@ class ScanDatasetOp : public UnaryDatasetOpKernel { protected: Status SaveInternal(IteratorStateWriter* writer) override { mutex_lock l(mu_); - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); if (!state_.empty()) { TF_RETURN_IF_ERROR( writer->WriteScalar(full_name("state_size"), state_.size())); @@ -237,7 +237,7 @@ class ScanDatasetOp : public UnaryDatasetOpKernel { Status RestoreInternal(IteratorContext* ctx, IteratorStateReader* reader) override { mutex_lock l(mu_); - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); if (reader->Contains(full_name("state_size"))) { int64 size; TF_RETURN_IF_ERROR( diff --git a/tensorflow/core/kernels/data/shuffle_dataset_op.cc b/tensorflow/core/kernels/data/shuffle_dataset_op.cc index 41395476eb..caf1e2af3f 100644 --- a/tensorflow/core/kernels/data/shuffle_dataset_op.cc +++ b/tensorflow/core/kernels/data/shuffle_dataset_op.cc @@ -179,7 +179,7 @@ class ShuffleDatasetOpBase : public UnaryDatasetOpKernel { TF_RETURN_IF_ERROR(writer->WriteScalar( this->full_name("end_of_input_sequence"), "")); } else { - TF_RETURN_IF_ERROR(this->SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(this->SaveInput(writer, input_impl_)); } // Save the epoch counter, buffer, and buffer slices. @@ -227,7 +227,7 @@ class ShuffleDatasetOpBase : public UnaryDatasetOpKernel { if (!reader->Contains(this->full_name("end_of_input_sequence"))) { TF_RETURN_IF_ERROR(this->dataset()->input_->MakeIterator( ctx, this->prefix(), &input_impl_)); - TF_RETURN_IF_ERROR(this->RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(this->RestoreInput(ctx, reader, input_impl_)); } else { input_impl_.reset(); } @@ -433,7 +433,7 @@ class ShuffleDatasetOp : public ShuffleDatasetOpBase { Node** output) const override { mutex_lock l(mu_); Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); Node* buffer_size = nullptr; Node* seed = nullptr; Node* seed2 = nullptr; @@ -502,7 +502,7 @@ class ShuffleDatasetOp : public ShuffleDatasetOpBase { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); Node* buffer_size = nullptr; Node* seed = nullptr; Node* seed2 = nullptr; @@ -587,7 +587,7 @@ class ShuffleAndRepeatDatasetOp : public ShuffleDatasetOpBase { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); Node* buffer_size = nullptr; Node* seed = nullptr; Node* seed2 = nullptr; diff --git a/tensorflow/core/kernels/data/skip_dataset_op.cc b/tensorflow/core/kernels/data/skip_dataset_op.cc index b84afa3e33..2da496c423 100644 --- a/tensorflow/core/kernels/data/skip_dataset_op.cc +++ b/tensorflow/core/kernels/data/skip_dataset_op.cc @@ -71,7 +71,7 @@ class SkipDatasetOp : public UnaryDatasetOpKernel { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); Node* count = nullptr; TF_RETURN_IF_ERROR(b->AddScalar(count_, &count)); TF_RETURN_IF_ERROR( @@ -152,7 +152,7 @@ class SkipDatasetOp : public UnaryDatasetOpKernel { mutex_lock l(mu_); TF_RETURN_IF_ERROR(writer->WriteScalar(full_name("i"), i_)); if (input_impl_) { - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); } else { TF_RETURN_IF_ERROR( writer->WriteScalar(full_name("input_impl_empty"), "")); @@ -165,7 +165,7 @@ class SkipDatasetOp : public UnaryDatasetOpKernel { mutex_lock l(mu_); TF_RETURN_IF_ERROR(reader->ReadScalar(full_name("i"), &i_)); if (!reader->Contains(full_name("input_impl_empty"))) { - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); } else { input_impl_.reset(); } diff --git a/tensorflow/core/kernels/data/slide_dataset_op.cc b/tensorflow/core/kernels/data/slide_dataset_op.cc index 5765c61f30..6c0384a537 100644 --- a/tensorflow/core/kernels/data/slide_dataset_op.cc +++ b/tensorflow/core/kernels/data/slide_dataset_op.cc @@ -107,7 +107,7 @@ class SlideDatasetOp : public UnaryDatasetOpKernel { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); Node* window_size = nullptr; Node* window_shift = nullptr; Node* window_stride = nullptr; @@ -228,7 +228,7 @@ class SlideDatasetOp : public UnaryDatasetOpKernel { TF_RETURN_IF_ERROR( writer->WriteScalar(full_name("input_impl_empty"), "")); } else { - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); } // Save buffer. TF_RETURN_IF_ERROR(writer->WriteScalar(strings::StrCat("buffer_size"), @@ -248,7 +248,7 @@ class SlideDatasetOp : public UnaryDatasetOpKernel { IteratorStateReader* reader) override { mutex_lock l(mu_); if (!reader->Contains(full_name("input_impl_empty"))) { - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); } else { input_impl_.reset(); } diff --git a/tensorflow/core/kernels/data/stats_aggregator_dataset_op.cc b/tensorflow/core/kernels/data/stats_aggregator_dataset_op.cc index 2ff90d7b10..61a1937e4c 100644 --- a/tensorflow/core/kernels/data/stats_aggregator_dataset_op.cc +++ b/tensorflow/core/kernels/data/stats_aggregator_dataset_op.cc @@ -111,14 +111,14 @@ class SetStatsAggregatorDatasetOp : public UnaryDatasetOpKernel { protected: Status SaveInternal(IteratorStateWriter* writer) override { mutex_lock l(mu_); - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); return Status::OK(); } Status RestoreInternal(IteratorContext* ctx, IteratorStateReader* reader) override { mutex_lock l(mu_); - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); return Status::OK(); } diff --git a/tensorflow/core/kernels/data/stats_dataset_ops.cc b/tensorflow/core/kernels/data/stats_dataset_ops.cc index 58ec3d4495..ba5ed39d83 100644 --- a/tensorflow/core/kernels/data/stats_dataset_ops.cc +++ b/tensorflow/core/kernels/data/stats_dataset_ops.cc @@ -79,7 +79,7 @@ class LatencyStatsDatasetOp : public UnaryDatasetOpKernel { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_node; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_node)); Node* tag_node; TF_RETURN_IF_ERROR(b->AddScalar(tag_, &tag_node)); TF_RETURN_IF_ERROR(b->AddDataset(this, {input_node, tag_node}, output)); @@ -114,14 +114,14 @@ class LatencyStatsDatasetOp : public UnaryDatasetOpKernel { protected: Status SaveInternal(IteratorStateWriter* writer) override { mutex_lock l(mu_); - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); return Status::OK(); } Status RestoreInternal(IteratorContext* ctx, IteratorStateReader* reader) override { mutex_lock l(mu_); - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); return Status::OK(); } @@ -178,7 +178,7 @@ class BytesProducedStatsDatasetOp : public UnaryDatasetOpKernel { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_node; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_node)); Node* tag_node; TF_RETURN_IF_ERROR(b->AddScalar(tag_, &tag_node)); TF_RETURN_IF_ERROR(b->AddDataset(this, {input_node, tag_node}, output)); @@ -215,14 +215,14 @@ class BytesProducedStatsDatasetOp : public UnaryDatasetOpKernel { protected: Status SaveInternal(IteratorStateWriter* writer) override { mutex_lock l(mu_); - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); return Status::OK(); } Status RestoreInternal(IteratorContext* ctx, IteratorStateReader* reader) override { mutex_lock l(mu_); - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); return Status::OK(); } @@ -283,7 +283,7 @@ class FeatureStatsDatasetOp : public UnaryDatasetOpKernel { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_node; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_node)); Node* tag_node; TF_RETURN_IF_ERROR(b->AddScalar(tag_, &tag_node)); TF_RETURN_IF_ERROR(b->AddDataset(this, {input_node, tag_node}, output)); @@ -406,14 +406,14 @@ class FeatureStatsDatasetOp : public UnaryDatasetOpKernel { protected: Status SaveInternal(IteratorStateWriter* writer) override { mutex_lock l(mu_); - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); return Status::OK(); } Status RestoreInternal(IteratorContext* ctx, IteratorStateReader* reader) override { mutex_lock l(mu_); - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); return Status::OK(); } diff --git a/tensorflow/core/kernels/data/take_dataset_op.cc b/tensorflow/core/kernels/data/take_dataset_op.cc index 3d29221f3e..0114629ef6 100644 --- a/tensorflow/core/kernels/data/take_dataset_op.cc +++ b/tensorflow/core/kernels/data/take_dataset_op.cc @@ -72,7 +72,7 @@ class TakeDatasetOp : public UnaryDatasetOpKernel { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); Node* count = nullptr; TF_RETURN_IF_ERROR(b->AddScalar(count_, &count)); TF_RETURN_IF_ERROR( @@ -139,7 +139,7 @@ class TakeDatasetOp : public UnaryDatasetOpKernel { mutex_lock l(mu_); TF_RETURN_IF_ERROR(writer->WriteScalar(full_name("i"), i_)); if (input_impl_) { - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); } else { TF_RETURN_IF_ERROR( writer->WriteScalar(full_name("input_impl_empty"), "")); @@ -152,7 +152,7 @@ class TakeDatasetOp : public UnaryDatasetOpKernel { mutex_lock l(mu_); TF_RETURN_IF_ERROR(reader->ReadScalar(full_name("i"), &i_)); if (!reader->Contains(full_name("input_impl_empty"))) { - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); } else { input_impl_.reset(); } diff --git a/tensorflow/core/kernels/data/tensor_queue_dataset_op.cc b/tensorflow/core/kernels/data/tensor_queue_dataset_op.cc index 29b4c9053e..d728f1ab14 100644 --- a/tensorflow/core/kernels/data/tensor_queue_dataset_op.cc +++ b/tensorflow/core/kernels/data/tensor_queue_dataset_op.cc @@ -102,7 +102,7 @@ class PrependFromQueueAndPaddedBatchDataset : public GraphDatasetBase { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph)); Node* batch_size = nullptr; TF_RETURN_IF_ERROR(b->AddScalar(batch_size_, &batch_size)); @@ -352,7 +352,7 @@ class PrependFromQueueAndPaddedBatchDataset : public GraphDatasetBase { Status Save(Iterator* iter, IteratorStateWriter* writer) { mutex_lock lock(mu_); if (input_impl_) { - TF_RETURN_IF_ERROR(iter->SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(iter->SaveInput(writer, input_impl_)); } else { TF_RETURN_IF_ERROR( writer->WriteScalar(iter->full_name("input_exhausted"), "")); @@ -378,7 +378,7 @@ class PrependFromQueueAndPaddedBatchDataset : public GraphDatasetBase { } else { TF_RETURN_IF_ERROR(iter->dataset_input()->MakeIterator( ctx, iter->prefix(), &input_impl_)); - TF_RETURN_IF_ERROR(iter->RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(iter->RestoreInput(ctx, reader, input_impl_)); } entries_.clear(); int64 entries_size = -1; diff --git a/tensorflow/core/kernels/data/unbatch_dataset_op.cc b/tensorflow/core/kernels/data/unbatch_dataset_op.cc index 2aec9fb090..692b5d8819 100644 --- a/tensorflow/core/kernels/data/unbatch_dataset_op.cc +++ b/tensorflow/core/kernels/data/unbatch_dataset_op.cc @@ -68,7 +68,7 @@ class UnbatchDatasetOp : public UnaryDatasetOpKernel { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); TF_RETURN_IF_ERROR(b->AddDataset(this, {input_graph_node}, output)); return Status::OK(); } @@ -142,7 +142,7 @@ class UnbatchDatasetOp : public UnaryDatasetOpKernel { Status SaveInternal(IteratorStateWriter* writer) override { mutex_lock l(mu_); if (input_impl_) { - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); } else { TF_RETURN_IF_ERROR( writer->WriteScalar(full_name("input_impl_empty"), "")); @@ -164,7 +164,7 @@ class UnbatchDatasetOp : public UnaryDatasetOpKernel { IteratorStateReader* reader) override { mutex_lock l(mu_); if (!reader->Contains(full_name("input_impl_empty"))) { - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); } else { input_impl_.reset(); } diff --git a/tensorflow/core/kernels/data/window_dataset_op.cc b/tensorflow/core/kernels/data/window_dataset_op.cc index 0283e5697b..c87214b3ef 100644 --- a/tensorflow/core/kernels/data/window_dataset_op.cc +++ b/tensorflow/core/kernels/data/window_dataset_op.cc @@ -77,7 +77,7 @@ class WindowDatasetOp : public UnaryDatasetOpKernel { Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input_, &input_graph_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); Node* window_size = nullptr; TF_RETURN_IF_ERROR(b->AddScalar(window_size_, &window_size)); TF_RETURN_IF_ERROR( @@ -162,7 +162,7 @@ class WindowDatasetOp : public UnaryDatasetOpKernel { TF_RETURN_IF_ERROR( writer->WriteScalar(full_name("input_impl_empty"), "")); } else { - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl_)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl_)); } return Status::OK(); } @@ -171,7 +171,7 @@ class WindowDatasetOp : public UnaryDatasetOpKernel { IteratorStateReader* reader) override { mutex_lock l(mu_); if (!reader->Contains(full_name("input_impl_empty"))) { - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl_)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl_)); } else { input_impl_.reset(); } diff --git a/tensorflow/core/kernels/data/zip_dataset_op.cc b/tensorflow/core/kernels/data/zip_dataset_op.cc index 00705236f9..8cc21cd2bc 100644 --- a/tensorflow/core/kernels/data/zip_dataset_op.cc +++ b/tensorflow/core/kernels/data/zip_dataset_op.cc @@ -83,7 +83,7 @@ class ZipDatasetOp : public DatasetOpKernel { input_graph_nodes.reserve(inputs_.size()); for (const auto& input : inputs_) { Node* input_node; - TF_RETURN_IF_ERROR(b->AddParentDataset(ctx, input, &input_node)); + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input, &input_node)); input_graph_nodes.emplace_back(input_node); } TF_RETURN_IF_ERROR(b->AddDataset( @@ -142,7 +142,7 @@ class ZipDatasetOp : public DatasetOpKernel { writer->WriteScalar(full_name("input_impls_empty"), "")); } else { for (auto& input_impl : input_impls_) - TF_RETURN_IF_ERROR(SaveParent(writer, input_impl)); + TF_RETURN_IF_ERROR(SaveInput(writer, input_impl)); } return Status::OK(); } @@ -155,7 +155,7 @@ class ZipDatasetOp : public DatasetOpKernel { } else { DCHECK_EQ(input_impls_.size(), dataset()->inputs_.size()); for (auto& input_impl : input_impls_) - TF_RETURN_IF_ERROR(RestoreParent(ctx, reader, input_impl)); + TF_RETURN_IF_ERROR(RestoreInput(ctx, reader, input_impl)); } return Status::OK(); } -- GitLab From 3d0edd130c137088d7815e1f3e67719d05fd9ab1 Mon Sep 17 00:00:00 2001 From: Mark Daoust Date: Fri, 10 Aug 2018 14:56:03 -0700 Subject: [PATCH 361/437] Add links to the C-api, and bazel-subproject instructions. PiperOrigin-RevId: 208273008 --- tensorflow/docs_src/api_guides/cc/guide.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tensorflow/docs_src/api_guides/cc/guide.md b/tensorflow/docs_src/api_guides/cc/guide.md index 0cea1d266e..2cd645afa7 100644 --- a/tensorflow/docs_src/api_guides/cc/guide.md +++ b/tensorflow/docs_src/api_guides/cc/guide.md @@ -7,6 +7,12 @@ You should, as a result, be sure you are following the [`master` version of this doc](https://www.tensorflow.org/versions/master/api_guides/cc/guide), in case there have been any changes. +Note: The C++ API is only designed to work with TensorFlow `bazel build`. +If you need a stand-alone option use the [C-api](../../install/install_c.md). +See [these instructions](https://docs.bazel.build/versions/master/external.html) +for details on how to include TensorFlow as a subproject (instead of building +your project from inside TensorFlow, as in this example). + [TOC] TensorFlow's C++ API provides mechanisms for constructing and executing a data -- GitLab From 83a1435684149e381521de528c3af40daa784570 Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Fri, 10 Aug 2018 15:02:09 -0700 Subject: [PATCH 362/437] Incremental update to the TFLite C API PiperOrigin-RevId: 208273960 --- tensorflow/contrib/lite/experimental/c/BUILD | 41 +++++++++++- .../contrib/lite/experimental/c/c_api.cc | 64 ++++++++++++++----- .../contrib/lite/experimental/c/c_api.h | 59 +++++++++++++++-- .../lite/experimental/c/c_api_experimental.cc | 31 +++++++++ .../lite/experimental/c/c_api_experimental.h | 32 ++++++++++ .../experimental/c/c_api_experimental_test.cc | 46 +++++++++++++ .../lite/experimental/c/c_api_internal.h | 41 ++++++++++++ .../contrib/lite/experimental/c/c_api_test.cc | 20 ++++-- .../TensorFlowLite/SDK/Scripts/Interpreter.cs | 16 ++++- 9 files changed, 317 insertions(+), 33 deletions(-) create mode 100644 tensorflow/contrib/lite/experimental/c/c_api_experimental.cc create mode 100644 tensorflow/contrib/lite/experimental/c/c_api_experimental.h create mode 100644 tensorflow/contrib/lite/experimental/c/c_api_experimental_test.cc create mode 100644 tensorflow/contrib/lite/experimental/c/c_api_internal.h diff --git a/tensorflow/contrib/lite/experimental/c/BUILD b/tensorflow/contrib/lite/experimental/c/BUILD index 50f8da66d0..8fc07e8eb7 100644 --- a/tensorflow/contrib/lite/experimental/c/BUILD +++ b/tensorflow/contrib/lite/experimental/c/BUILD @@ -26,17 +26,33 @@ tflite_cc_shared_object( }), deps = [ ":c_api", + ":c_api_experimental", ":exported_symbols.lds", ":version_script.lds", ], ) +cc_library( + name = "c_api_internal", + srcs = ["c_api.h"], + hdrs = ["c_api_internal.h"], + copts = tflite_copts(), + visibility = [ + "//tensorflow/contrib/lite/experimental/c:__subpackages__", + ], + deps = [ + "//tensorflow/contrib/lite:context", + "//tensorflow/contrib/lite:framework", + ], +) + cc_library( name = "c_api", srcs = ["c_api.cc"], hdrs = ["c_api.h"], copts = tflite_copts(), deps = [ + ":c_api_internal", "//tensorflow/contrib/lite:context", "//tensorflow/contrib/lite:framework", "//tensorflow/contrib/lite:schema_fbs_version", @@ -44,6 +60,17 @@ cc_library( ], ) +cc_library( + name = "c_api_experimental", + srcs = ["c_api_experimental.cc"], + hdrs = ["c_api_experimental.h"], + copts = tflite_copts(), + deps = [ + ":c_api", + ":c_api_internal", + ], +) + cc_test( name = "c_api_test", size = "small", @@ -51,9 +78,21 @@ cc_test( data = ["//tensorflow/contrib/lite:testdata/add.bin"], deps = [ ":c_api", - "//tensorflow/contrib/lite:framework", "//tensorflow/contrib/lite:kernel_api", "//tensorflow/contrib/lite/testing:util", "@com_google_googletest//:gtest", ], ) + +cc_test( + name = "c_api_experimental_test", + size = "small", + srcs = ["c_api_experimental_test.cc"], + data = ["//tensorflow/contrib/lite:testdata/add.bin"], + deps = [ + ":c_api", + ":c_api_experimental", + "//tensorflow/contrib/lite/testing:util", + "@com_google_googletest//:gtest", + ], +) diff --git a/tensorflow/contrib/lite/experimental/c/c_api.cc b/tensorflow/contrib/lite/experimental/c/c_api.cc index 9d29e8b3e0..a4ab0e8c30 100644 --- a/tensorflow/contrib/lite/experimental/c/c_api.cc +++ b/tensorflow/contrib/lite/experimental/c/c_api.cc @@ -15,6 +15,7 @@ limitations under the License. #include "tensorflow/contrib/lite/experimental/c/c_api.h" #include "tensorflow/contrib/lite/context.h" +#include "tensorflow/contrib/lite/experimental/c/c_api_internal.h" #include "tensorflow/contrib/lite/interpreter.h" #include "tensorflow/contrib/lite/kernels/register.h" #include "tensorflow/contrib/lite/model.h" @@ -23,28 +24,55 @@ limitations under the License. extern "C" { #endif // __cplusplus -struct _TFL_Interpreter { - std::unique_ptr impl; -}; - // LINT.IfChange -TFL_Interpreter* TFL_NewInterpreter(const void* model_data, - int32_t model_size) { +TFL_Model* TFL_NewModel(const void* model_data, size_t model_size) { auto model = tflite::FlatBufferModel::BuildFromBuffer( - static_cast(model_data), static_cast(model_size)); - if (!model) { + static_cast(model_data), model_size); + return model ? new TFL_Model{std::move(model)} : nullptr; +} + +TFL_Model* TFL_NewModelFromFile(const char* model_path) { + auto model = tflite::FlatBufferModel::BuildFromFile(model_path); + return model ? new TFL_Model{std::move(model)} : nullptr; +} + +void TFL_DeleteModel(TFL_Model* model) { delete model; } + +TFL_InterpreterOptions* TFL_NewInterpreterOptions() { + return new TFL_InterpreterOptions{}; +} + +void TFL_DeleteInterpreterOptions(TFL_InterpreterOptions* options) { + delete options; +} + +void TFL_InterpreterOptionsSetNumThreads(TFL_InterpreterOptions* options, + int32_t num_threads) { + options->num_threads = num_threads; +} + +TFL_Interpreter* TFL_NewInterpreter( + const TFL_Model* model, const TFL_InterpreterOptions* optional_options) { + if (!model || !model->impl) { return nullptr; } tflite::ops::builtin::BuiltinOpResolver resolver; - tflite::InterpreterBuilder builder(*model, resolver); - std::unique_ptr interpreter_impl; - if (builder(&interpreter_impl) != kTfLiteOk) { + tflite::InterpreterBuilder builder(*model->impl, resolver); + std::unique_ptr interpreter; + if (builder(&interpreter) != kTfLiteOk) { return nullptr; } - return new TFL_Interpreter{std::move(interpreter_impl)}; + if (optional_options) { + if (optional_options->num_threads != + TFL_InterpreterOptions::kDefaultNumThreads) { + interpreter->SetNumThreads(optional_options->num_threads); + } + } + + return new TFL_Interpreter{std::move(interpreter)}; } void TFL_DeleteInterpreter(TFL_Interpreter* interpreter) { delete interpreter; } @@ -97,9 +125,13 @@ int32_t TFL_TensorDim(const TFL_Tensor* tensor, int32_t dim_index) { size_t TFL_TensorByteSize(const TFL_Tensor* tensor) { return tensor->bytes; } +void* TFL_TensorData(const TFL_Tensor* tensor) { + return static_cast(tensor->data.raw); +} + TFL_Status TFL_TensorCopyFromBuffer(TFL_Tensor* tensor, const void* input_data, - int32_t input_data_size) { - if (tensor->bytes != static_cast(input_data_size)) { + size_t input_data_size) { + if (tensor->bytes != input_data_size) { return kTfLiteError; } memcpy(tensor->data.raw, input_data, input_data_size); @@ -107,8 +139,8 @@ TFL_Status TFL_TensorCopyFromBuffer(TFL_Tensor* tensor, const void* input_data, } TFL_Status TFL_TensorCopyToBuffer(const TFL_Tensor* tensor, void* output_data, - int32_t output_data_size) { - if (tensor->bytes != static_cast(output_data_size)) { + size_t output_data_size) { + if (tensor->bytes != output_data_size) { return kTfLiteError; } memcpy(output_data, tensor->data.raw, output_data_size); diff --git a/tensorflow/contrib/lite/experimental/c/c_api.h b/tensorflow/contrib/lite/experimental/c/c_api.h index 070f1add13..3757349b55 100644 --- a/tensorflow/contrib/lite/experimental/c/c_api.h +++ b/tensorflow/contrib/lite/experimental/c/c_api.h @@ -30,6 +30,9 @@ limitations under the License. // // Conventions: // * We use the prefix TFL_ for everything in the API. +// * size_t is used to represent byte sizes of objects that are +// materialized in the address space of the calling process. +// * int is used as an index into arrays. #ifdef SWIG #define TFL_CAPI_EXPORT @@ -53,16 +56,51 @@ typedef TfLiteTensor TFL_Tensor; typedef TfLiteStatus TFL_Status; typedef TfLiteType TFL_Type; +// -------------------------------------------------------------------------- +// TFL_Model wraps a loaded TensorFlow Lite model. +typedef struct TFL_Model TFL_Model; + +// Returns a model from the provided buffer, or null on failure. +TFL_CAPI_EXPORT extern TFL_Model* TFL_NewModel(const void* model_data, + size_t model_size); + +// Returns a model from the provided file, or null on failure. +TFL_CAPI_EXPORT extern TFL_Model* TFL_NewModelFromFile(const char* model_path); + +// Destroys the model instance. +TFL_CAPI_EXPORT extern void TFL_DeleteModel(TFL_Model* model); + +// -------------------------------------------------------------------------- +// TFL_InterpreterOptions allows customized interpreter configuration. +typedef struct TFL_InterpreterOptions TFL_InterpreterOptions; + +// Returns a new interpreter options instances. +TFL_CAPI_EXPORT extern TFL_InterpreterOptions* TFL_NewInterpreterOptions(); + +// Destroys the interpreter options instance. +TFL_CAPI_EXPORT extern void TFL_DeleteInterpreterOptions( + TFL_InterpreterOptions* options); + +// Sets the number of CPU threads to use for the interpreter. +TFL_CAPI_EXPORT extern void TFL_InterpreterOptionsSetNumThreads( + TFL_InterpreterOptions* options, int32_t num_threads); + // -------------------------------------------------------------------------- // TFL_Interpreter provides inference from a provided model. -typedef struct _TFL_Interpreter TFL_Interpreter; +typedef struct TFL_Interpreter TFL_Interpreter; -// Returns an interpreter for the provided model, or null on failure. +// Returns a new interpreter using the provided model and options, or null on +// failure. +// +// * `model` must be a valid model instance. The caller retains ownership of the +// object, and can destroy it immediately after creating the interpreter. +// * `optional_options` may be null. The caller retains ownership of the object, +// and can safely destroy it immediately after creating the interpreter. // // NOTE: The client *must* explicitly allocate tensors before attempting to // access input tensor data or invoke the interpreter. TFL_CAPI_EXPORT extern TFL_Interpreter* TFL_NewInterpreter( - const void* model_data, int32_t model_size); + const TFL_Model* model, const TFL_InterpreterOptions* optional_options); // Destroys the interpreter. TFL_CAPI_EXPORT extern void TFL_DeleteInterpreter(TFL_Interpreter* interpreter); @@ -76,7 +114,8 @@ TFL_CAPI_EXPORT extern int TFL_InterpreterGetInputTensorCount( TFL_CAPI_EXPORT extern TFL_Tensor* TFL_InterpreterGetInputTensor( const TFL_Interpreter* interpreter, int32_t input_index); -// Attempts to resize the specified input tensor. +// Resizes the specified input tensor. +// // NOTE: After a resize, the client *must* explicitly allocate tensors before // attempting to access the resized tensor data or invoke the interpreter. // REQUIRES: 0 <= input_index < TFL_InterpreterGetInputTensorCount(tensor) @@ -131,16 +170,24 @@ TFL_CAPI_EXPORT extern int32_t TFL_TensorDim(const TFL_Tensor* tensor, // Returns the size of the underlying data in bytes. TFL_CAPI_EXPORT extern size_t TFL_TensorByteSize(const TFL_Tensor* tensor); +// Returns a pointer to the underlying data buffer. +// +// Note: The result may be null if tensors have not yet been allocated, e.g., +// if the Tensor has just been created or resized and `TFL_AllocateTensors()` +// has yet to be called, or if the output tensor is dynamically sized and the +// interpreter hasn't been invoked. +TFL_CAPI_EXPORT extern void* TFL_TensorData(const TFL_Tensor* tensor); + // Copies from the provided input buffer into the tensor's buffer. // REQUIRES: input_data_size == TFL_TensorByteSize(tensor) TFL_CAPI_EXPORT extern TFL_Status TFL_TensorCopyFromBuffer( - TFL_Tensor* tensor, const void* input_data, int32_t input_data_size); + TFL_Tensor* tensor, const void* input_data, size_t input_data_size); // Copies to the provided output buffer from the tensor's buffer. // REQUIRES: output_data_size == TFL_TensorByteSize(tensor) TFL_CAPI_EXPORT extern TFL_Status TFL_TensorCopyToBuffer( const TFL_Tensor* output_tensor, void* output_data, - int32_t output_data_size); + size_t output_data_size); #ifdef __cplusplus } // extern "C" diff --git a/tensorflow/contrib/lite/experimental/c/c_api_experimental.cc b/tensorflow/contrib/lite/experimental/c/c_api_experimental.cc new file mode 100644 index 0000000000..c4dbc55cbf --- /dev/null +++ b/tensorflow/contrib/lite/experimental/c/c_api_experimental.cc @@ -0,0 +1,31 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#include "tensorflow/contrib/lite/experimental/c/c_api_experimental.h" + +#include "tensorflow/contrib/lite/experimental/c/c_api_internal.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +TFL_Status TFL_InterpreterResetVariableTensorsToZero( + TFL_Interpreter* interpreter) { + return interpreter->impl->ResetVariableTensorsToZero(); +} + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/tensorflow/contrib/lite/experimental/c/c_api_experimental.h b/tensorflow/contrib/lite/experimental/c/c_api_experimental.h new file mode 100644 index 0000000000..b0ac258dcf --- /dev/null +++ b/tensorflow/contrib/lite/experimental/c/c_api_experimental.h @@ -0,0 +1,32 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ +#ifndef TENSORFLOW_CONTRIB_LITE_EXPERIMENTAL_C_C_API_EXPERIMENTAL_H_ +#define TENSORFLOW_CONTRIB_LITE_EXPERIMENTAL_C_C_API_EXPERIMENTAL_H_ + +#include "tensorflow/contrib/lite/experimental/c/c_api.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Resets all variable tensors to zero. +TFL_CAPI_EXPORT extern TFL_Status TFL_InterpreterResetVariableTensorsToZero( + TFL_Interpreter* interpreter); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif // TENSORFLOW_CONTRIB_LITE_EXPERIMENTAL_C_C_API_EXPERIMENTAL_H_ diff --git a/tensorflow/contrib/lite/experimental/c/c_api_experimental_test.cc b/tensorflow/contrib/lite/experimental/c/c_api_experimental_test.cc new file mode 100644 index 0000000000..db6e5251de --- /dev/null +++ b/tensorflow/contrib/lite/experimental/c/c_api_experimental_test.cc @@ -0,0 +1,46 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#include "tensorflow/contrib/lite/experimental/c/c_api_experimental.h" + +#include +#include "tensorflow/contrib/lite/experimental/c/c_api.h" +#include "tensorflow/contrib/lite/testing/util.h" + +namespace { + +TEST(CApiExperimentalSimple, Smoke) { + TFL_Model* model = TFL_NewModelFromFile( + "tensorflow/contrib/lite/testdata/add.bin"); + ASSERT_NE(model, nullptr); + + TFL_Interpreter* interpreter = + TFL_NewInterpreter(model, /*optional_options=*/nullptr); + ASSERT_NE(interpreter, nullptr); + ASSERT_EQ(TFL_InterpreterAllocateTensors(interpreter), kTfLiteOk); + + EXPECT_EQ(TFL_InterpreterResetVariableTensorsToZero(interpreter), kTfLiteOk); + + TFL_DeleteModel(model); + TFL_DeleteInterpreter(interpreter); +} + +} // namespace + +int main(int argc, char** argv) { + ::tflite::LogToStderr(); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/tensorflow/contrib/lite/experimental/c/c_api_internal.h b/tensorflow/contrib/lite/experimental/c/c_api_internal.h new file mode 100644 index 0000000000..c5c612a4c6 --- /dev/null +++ b/tensorflow/contrib/lite/experimental/c/c_api_internal.h @@ -0,0 +1,41 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ +#ifndef TENSORFLOW_CONTRIB_LITE_EXPERIMENTAL_C_C_API_INTERNAL_H_ +#define TENSORFLOW_CONTRIB_LITE_EXPERIMENTAL_C_C_API_INTERNAL_H_ + +#include "tensorflow/contrib/lite/experimental/c/c_api.h" + +#include "tensorflow/contrib/lite/interpreter.h" +#include "tensorflow/contrib/lite/model.h" + +// Internal structures used by the C API. These are likely to change and should +// not be depended on. + +struct TFL_Model { + std::unique_ptr impl; +}; + +struct TFL_InterpreterOptions { + enum { + kDefaultNumThreads = -1, + }; + int num_threads = kDefaultNumThreads; +}; + +struct TFL_Interpreter { + std::unique_ptr impl; +}; + +#endif // TENSORFLOW_CONTRIB_LITE_EXPERIMENTAL_C_C_API_INTERNAL_H_ diff --git a/tensorflow/contrib/lite/experimental/c/c_api_test.cc b/tensorflow/contrib/lite/experimental/c/c_api_test.cc index bc925e00a6..a631dae890 100644 --- a/tensorflow/contrib/lite/experimental/c/c_api_test.cc +++ b/tensorflow/contrib/lite/experimental/c/c_api_test.cc @@ -18,22 +18,28 @@ limitations under the License. #include "tensorflow/contrib/lite/experimental/c/c_api.h" #include -#include "tensorflow/contrib/lite/allocation.h" #include "tensorflow/contrib/lite/context.h" #include "tensorflow/contrib/lite/testing/util.h" namespace { TEST(CApiSimple, Smoke) { - tflite::FileCopyAllocation model_file( - "tensorflow/contrib/lite/testdata/add.bin", - tflite::DefaultErrorReporter()); + TFL_Model* model = TFL_NewModelFromFile( + "tensorflow/contrib/lite/testdata/add.bin"); + ASSERT_NE(model, nullptr); - TFL_Interpreter* interpreter = - TFL_NewInterpreter(model_file.base(), model_file.bytes()); + TFL_InterpreterOptions* options = TFL_NewInterpreterOptions(); + ASSERT_NE(options, nullptr); + TFL_InterpreterOptionsSetNumThreads(options, 2); + + TFL_Interpreter* interpreter = TFL_NewInterpreter(model, options); ASSERT_NE(interpreter, nullptr); - ASSERT_EQ(TFL_InterpreterAllocateTensors(interpreter), kTfLiteOk); + // The options/model can be deleted immediately after interpreter creation. + TFL_DeleteInterpreterOptions(options); + TFL_DeleteModel(model); + + ASSERT_EQ(TFL_InterpreterAllocateTensors(interpreter), kTfLiteOk); ASSERT_EQ(TFL_InterpreterGetInputTensorCount(interpreter), 1); ASSERT_EQ(TFL_InterpreterGetOutputTensorCount(interpreter), 1); diff --git a/tensorflow/contrib/lite/experimental/examples/unity/TensorFlowLitePlugin/Assets/TensorFlowLite/SDK/Scripts/Interpreter.cs b/tensorflow/contrib/lite/experimental/examples/unity/TensorFlowLitePlugin/Assets/TensorFlowLite/SDK/Scripts/Interpreter.cs index ab966bae2e..b6905b5fbf 100644 --- a/tensorflow/contrib/lite/experimental/examples/unity/TensorFlowLitePlugin/Assets/TensorFlowLite/SDK/Scripts/Interpreter.cs +++ b/tensorflow/contrib/lite/experimental/examples/unity/TensorFlowLitePlugin/Assets/TensorFlowLite/SDK/Scripts/Interpreter.cs @@ -16,6 +16,8 @@ using System; using System.Runtime.InteropServices; using TFL_Interpreter = System.IntPtr; +using TFL_InterpreterOptions = System.IntPtr; +using TFL_Model = System.IntPtr; using TFL_Tensor = System.IntPtr; namespace TensorFlowLite @@ -32,7 +34,9 @@ namespace TensorFlowLite public Interpreter(byte[] modelData) { GCHandle modelDataHandle = GCHandle.Alloc(modelData, GCHandleType.Pinned); IntPtr modelDataPtr = modelDataHandle.AddrOfPinnedObject(); - handle = TFL_NewInterpreter(modelDataPtr, modelData.Length); + TFL_Model model = TFL_NewModel(modelDataPtr, modelData.Length); + handle = TFL_NewInterpreter(model, /*options=*/IntPtr.Zero); + TFL_DeleteModel(model); if (handle == IntPtr.Zero) throw new Exception("Failed to create TensorFlowLite Interpreter"); } @@ -88,10 +92,16 @@ namespace TensorFlowLite #region Externs + [DllImport (TensorFlowLibrary)] + private static extern unsafe TFL_Interpreter TFL_NewModel(IntPtr model_data, int model_size); + + [DllImport (TensorFlowLibrary)] + private static extern unsafe TFL_Interpreter TFL_DeleteModel(TFL_Model model); + [DllImport (TensorFlowLibrary)] private static extern unsafe TFL_Interpreter TFL_NewInterpreter( - IntPtr model_data, - int model_size); + TFL_Model model, + TFL_InterpreterOptions optional_options); [DllImport (TensorFlowLibrary)] private static extern unsafe void TFL_DeleteInterpreter(TFL_Interpreter interpreter); -- GitLab From 2625345c727b14f8e770d4f980fe86e9ccc8b03d Mon Sep 17 00:00:00 2001 From: Peter Ma Date: Fri, 10 Aug 2018 15:03:22 -0700 Subject: [PATCH 363/437] Add two counters in Costs Struct for number of ops processed/predicted in total, and number of ops predicted with unknown shapes PiperOrigin-RevId: 208274158 --- .../costs/analytical_cost_estimator_test.cc | 4 + .../core/grappler/costs/cost_estimator.h | 8 + .../grappler/costs/op_level_cost_estimator.cc | 23 +++ .../costs/op_level_cost_estimator_test.cc | 151 ++++++++++++++++-- .../core/grappler/costs/virtual_scheduler.cc | 20 ++- .../core/grappler/costs/virtual_scheduler.h | 1 + .../grappler/costs/virtual_scheduler_test.cc | 7 +- 7 files changed, 195 insertions(+), 19 deletions(-) diff --git a/tensorflow/core/grappler/costs/analytical_cost_estimator_test.cc b/tensorflow/core/grappler/costs/analytical_cost_estimator_test.cc index f241922471..a9a1abfa98 100644 --- a/tensorflow/core/grappler/costs/analytical_cost_estimator_test.cc +++ b/tensorflow/core/grappler/costs/analytical_cost_estimator_test.cc @@ -103,6 +103,9 @@ TEST_F(AnalyticalCostEstimatorTest, SimpleTest) { TF_ASSERT_OK(estimator.PredictCosts(item.graph, &cost_graph, &summary)); EXPECT_EQ(Costs::NanoSeconds(9151), summary.execution_time); + // Note there are totally 17 nodes (RandomUniform creates 2 nodes), but + // grappler will not process "label", therefore we have 15 here instead + EXPECT_EQ(15, summary.num_ops_total); // Make this estimate accurate: // TODO(http://b/70031255): Accurate estimator for RandomUniform op needed @@ -110,6 +113,7 @@ TEST_F(AnalyticalCostEstimatorTest, SimpleTest) { // // Change to EXPECT_FALSE when the above TODOs are done: EXPECT_TRUE(summary.inaccurate); + EXPECT_EQ(0, summary.num_ops_with_unknown_shapes); } } // end namespace grappler diff --git a/tensorflow/core/grappler/costs/cost_estimator.h b/tensorflow/core/grappler/costs/cost_estimator.h index fe8a876f8a..e91f0cc9da 100644 --- a/tensorflow/core/grappler/costs/cost_estimator.h +++ b/tensorflow/core/grappler/costs/cost_estimator.h @@ -109,8 +109,16 @@ struct Costs { int64 max_per_op_buffers; // Sum of all buffers used by the ops. int64 max_per_op_streaming; // Ignore largest input buffer, assuming it // streams from main memory. + + // Number of ops included in this Costs in total. + // Default initialized to be one. + int64 num_ops_total = 1; // If the time estimation is inaccurate. bool inaccurate = false; + // Number of ops that are estimated with unknown shapes. + int64 num_ops_with_unknown_shapes = 0; + // TODO(pcma): include a counter for total inaccurate ops and counters for + // other reasons causing the inaccuracy // Max possible memory usage per device. std::unordered_map estimated_max_memory_per_device; diff --git a/tensorflow/core/grappler/costs/op_level_cost_estimator.cc b/tensorflow/core/grappler/costs/op_level_cost_estimator.cc index 5b303f6ccb..6406a4bdbf 100644 --- a/tensorflow/core/grappler/costs/op_level_cost_estimator.cc +++ b/tensorflow/core/grappler/costs/op_level_cost_estimator.cc @@ -449,6 +449,7 @@ Costs OpLevelCostEstimator::PredictCwiseOp(const OpContext& op_context) const { if (found_unknown_shapes || !is_known_elementwise_op) { costs.inaccurate = true; } + costs.num_ops_with_unknown_shapes = found_unknown_shapes; return costs; } @@ -469,6 +470,7 @@ Costs OpLevelCostEstimator::PredictOpCountBasedCost( const double total_io_bytes = input_size + output_size; Costs costs = PredictOpCountBasedCost(operations, total_io_bytes, op_info); costs.inaccurate = unknown_shapes; + costs.num_ops_with_unknown_shapes = unknown_shapes; costs.max_memory = output_size; return costs; } @@ -627,6 +629,7 @@ int64 OpLevelCostEstimator::CountMatMulOperations( if (op_features.inputs_size() < 2) { LOG(ERROR) << "Need 2 inputs but got " << op_features.inputs_size(); + // TODO(pcma): Try to separate invalid inputs from unknown shapes *found_unknown_shapes = true; return 0; } @@ -694,11 +697,13 @@ int64 OpLevelCostEstimator::CountBatchMatMulOperations( const OpInfo& op_features, bool* found_unknown_shapes) const { if (op_features.op() != kBatchMatMul) { LOG(ERROR) << "Invalid Operation: " << op_features.op(); + // TODO(pcma): Try to separate invalid inputs from unknown shapes *found_unknown_shapes = true; return 0; } if (op_features.inputs_size() != 2) { LOG(ERROR) << "Expected 2 inputs but got " << op_features.inputs_size(); + // TODO(pcma): Try to separate invalid inputs from unknown shapes *found_unknown_shapes = true; return 0; } @@ -858,6 +863,7 @@ int64 OpLevelCostEstimator::CountConv2DBackpropInputOperations( "kDepthwiseConv2dNativeBackpropInput"; if (op_features.inputs_size() < 2) { + // TODO(pcma): Try to separate invalid inputs from unknown shapes *found_unknown_shapes = true; return ops; } @@ -935,6 +941,7 @@ int64 OpLevelCostEstimator::CountConv2DBackpropFilterOperations( } if (op_features.inputs_size() < 1) { + // TODO(pcma): Try to separate invalid inputs from unknown shapes *found_unknown_shapes = true; return ops; } @@ -1037,6 +1044,7 @@ Costs OpLevelCostEstimator::PredictConv2D(const OpContext& op_context) const { auto costs = PredictOpCountBasedCost( CountConv2DOperations(op_features, &found_unknown_shapes), op_features); costs.inaccurate = found_unknown_shapes; + costs.num_ops_with_unknown_shapes = found_unknown_shapes; return costs; } @@ -1049,6 +1057,7 @@ Costs OpLevelCostEstimator::PredictConv2DBackpropInput( op_features, nullptr, &found_unknown_shapes), op_features); costs.inaccurate = found_unknown_shapes; + costs.num_ops_with_unknown_shapes = found_unknown_shapes; return costs; } @@ -1061,6 +1070,7 @@ Costs OpLevelCostEstimator::PredictConv2DBackpropFilter( op_features, nullptr, &found_unknown_shapes), op_features); costs.inaccurate = found_unknown_shapes; + costs.num_ops_with_unknown_shapes = found_unknown_shapes; return costs; } @@ -1148,6 +1158,7 @@ Costs OpLevelCostEstimator::PredictFusedConv2DBiasActivation( // Construct component operations and run the cost computation. auto costs = PredictFusedOp(op_context_with_output, component_ops); costs.inaccurate |= found_unknown_shapes; + costs.num_ops_with_unknown_shapes = costs.inaccurate; return costs; } @@ -1157,6 +1168,7 @@ Costs OpLevelCostEstimator::PredictMatMul(const OpContext& op_context) const { auto costs = PredictOpCountBasedCost( CountMatMulOperations(op_features, &found_unknown_shapes), op_features); costs.inaccurate = found_unknown_shapes; + costs.num_ops_with_unknown_shapes = found_unknown_shapes; return costs; } @@ -1171,6 +1183,7 @@ Costs OpLevelCostEstimator::PredictIdentity(const OpContext& op_context) const { VLOG(1) << "Op:" << op_features.op() << " Execution Time 0 (ns)"; Costs result = Costs::ZeroCosts(); result.max_memory = CalculateOutputSize(op_features, &result.inaccurate); + result.num_ops_with_unknown_shapes = result.inaccurate; // Assign the minimum amount of time we can represent to the identity op since // it tends to be really cheap. result.compute_time = kMinComputeTime; @@ -1184,6 +1197,7 @@ Costs OpLevelCostEstimator::PredictVariable(const OpContext& op_context) const { Costs result = Costs::ZeroCosts(); result.persistent_memory = CalculateOutputSize(op_features, &result.inaccurate); + result.num_ops_with_unknown_shapes = result.inaccurate; result.compute_time = kMinComputeTime; result.execution_time = result.execution_time; @@ -1198,6 +1212,7 @@ Costs OpLevelCostEstimator::PredictBatchMatMul( CountBatchMatMulOperations(op_features, &found_unknown_shapes), op_features); costs.inaccurate = found_unknown_shapes; + costs.num_ops_with_unknown_shapes = found_unknown_shapes; return costs; } @@ -1205,6 +1220,7 @@ Costs OpLevelCostEstimator::PredictMetadata(const OpContext& op_context) const { const auto& op_features = op_context.op_info; Costs costs = Costs::ZeroCosts(); costs.max_memory = CalculateOutputSize(op_features, &costs.inaccurate); + costs.num_ops_with_unknown_shapes = costs.inaccurate; // Metadata operations are so cheap we assume they take the minimum amount of // time we can represent (1 ns). costs.compute_time = kMinComputeTime; @@ -1249,6 +1265,7 @@ Costs OpLevelCostEstimator::PredictGatherOrSlice( const double total_io = input_size + output_size; Costs costs = PredictOpCountBasedCost(op_count, total_io, op_info); costs.inaccurate = unknown_shapes; + costs.num_ops_with_unknown_shapes = unknown_shapes; costs.max_memory = output_size; return costs; @@ -1390,6 +1407,7 @@ Costs OpLevelCostEstimator::PredictMaxPool(const OpContext& op_context) const { Costs costs = PredictOpCountBasedCost( ops, total_input_size + total_output_size, op_info); costs.inaccurate = found_unknown_shapes; + costs.num_ops_with_unknown_shapes = found_unknown_shapes; costs.max_memory = total_output_size; return costs; } @@ -1432,6 +1450,7 @@ Costs OpLevelCostEstimator::PredictMaxPoolGrad( Costs costs = PredictOpCountBasedCost( ops, total_input_size + total_output_size, op_info); costs.inaccurate = found_unknown_shapes; + costs.num_ops_with_unknown_shapes = found_unknown_shapes; costs.max_memory = total_output_size; return costs; } @@ -1464,6 +1483,7 @@ Costs OpLevelCostEstimator::PredictAvgPool(const OpContext& op_context) const { Costs costs = PredictOpCountBasedCost( ops, total_input_size + total_output_size, op_info); costs.inaccurate = found_unknown_shapes; + costs.num_ops_with_unknown_shapes = found_unknown_shapes; costs.max_memory = total_output_size; return costs; } @@ -1516,6 +1536,7 @@ Costs OpLevelCostEstimator::PredictAvgPoolGrad( Costs costs = PredictOpCountBasedCost( ops, total_input_size + total_output_size, op_info); costs.inaccurate = found_unknown_shapes; + costs.num_ops_with_unknown_shapes = found_unknown_shapes; costs.max_memory = total_output_size; return costs; } @@ -1562,6 +1583,7 @@ Costs OpLevelCostEstimator::PredictFusedBatchNorm( ops, total_input_size + total_output_size + total_internal_read_size, op_info); costs.inaccurate = found_unknown_shapes; + costs.num_ops_with_unknown_shapes = found_unknown_shapes; costs.max_memory = total_output_size; return costs; } @@ -1595,6 +1617,7 @@ Costs OpLevelCostEstimator::PredictFusedBatchNormGrad( ops, total_input_size + total_output_size + total_internal_read_size, op_info); costs.inaccurate = found_unknown_shapes; + costs.num_ops_with_unknown_shapes = found_unknown_shapes; costs.max_memory = total_output_size; return costs; } diff --git a/tensorflow/core/grappler/costs/op_level_cost_estimator_test.cc b/tensorflow/core/grappler/costs/op_level_cost_estimator_test.cc index 77352f6652..7271a29319 100644 --- a/tensorflow/core/grappler/costs/op_level_cost_estimator_test.cc +++ b/tensorflow/core/grappler/costs/op_level_cost_estimator_test.cc @@ -488,7 +488,9 @@ TEST_F(OpLevelCostEstimatorTest, TestGatherCosts) { EXPECT_EQ(Costs::Duration(130), cost.memory_time); EXPECT_EQ(Costs::Duration(16), cost.compute_time); EXPECT_EQ(Costs::Duration(146), cost.execution_time); + EXPECT_EQ(1, cost.num_ops_total); EXPECT_FALSE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); } TEST_F(OpLevelCostEstimatorTest, TestGatherCostsWithoutOutput) { @@ -504,7 +506,9 @@ TEST_F(OpLevelCostEstimatorTest, TestGatherCostsWithoutOutput) { EXPECT_EQ(Costs::Duration(0), cost.memory_time); EXPECT_EQ(Costs::Duration(0), cost.compute_time); EXPECT_EQ(Costs::Duration(0), cost.execution_time); + EXPECT_EQ(1, cost.num_ops_total); EXPECT_TRUE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); } TEST_F(OpLevelCostEstimatorTest, TestSliceCosts) { @@ -522,7 +526,9 @@ TEST_F(OpLevelCostEstimatorTest, TestSliceCosts) { EXPECT_EQ(Costs::Duration(81), cost.memory_time); EXPECT_EQ(Costs::Duration(10), cost.compute_time); EXPECT_EQ(Costs::Duration(91), cost.execution_time); + EXPECT_EQ(1, cost.num_ops_total); EXPECT_FALSE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); } TEST_F(OpLevelCostEstimatorTest, BiasAddExecutionTime) { @@ -530,7 +536,9 @@ TEST_F(OpLevelCostEstimatorTest, BiasAddExecutionTime) { EXPECT_EQ(Costs::Duration(8400), cost.memory_time); EXPECT_EQ(Costs::Duration(1000), cost.compute_time); EXPECT_EQ(Costs::Duration(9400), cost.execution_time); + EXPECT_EQ(1, cost.num_ops_total); EXPECT_FALSE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); } TEST_F(OpLevelCostEstimatorTest, Conv2DExecutionTime) { @@ -538,7 +546,9 @@ TEST_F(OpLevelCostEstimatorTest, Conv2DExecutionTime) { EXPECT_EQ(Costs::Duration(233780), cost.memory_time); EXPECT_EQ(Costs::Duration(354877440), cost.compute_time); EXPECT_EQ(Costs::Duration(355111220), cost.execution_time); + EXPECT_EQ(1, cost.num_ops_total); EXPECT_FALSE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); } TEST_F(OpLevelCostEstimatorTest, DepthwiseConv2dNativeExecutionTime) { @@ -547,7 +557,9 @@ TEST_F(OpLevelCostEstimatorTest, DepthwiseConv2dNativeExecutionTime) { EXPECT_EQ(Costs::Duration(112340), cost.memory_time); EXPECT_EQ(Costs::Duration(4158720), cost.compute_time); EXPECT_EQ(Costs::Duration(4271060), cost.execution_time); + EXPECT_EQ(1, cost.num_ops_total); EXPECT_FALSE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); } TEST_F(OpLevelCostEstimatorTest, DummyExecutionTime) { @@ -555,7 +567,9 @@ TEST_F(OpLevelCostEstimatorTest, DummyExecutionTime) { EXPECT_EQ(Costs::Duration(2000), cost.memory_time); EXPECT_EQ(Costs::Duration(0), cost.compute_time); EXPECT_EQ(Costs::Duration(2000), cost.execution_time); + EXPECT_EQ(1, cost.num_ops_total); EXPECT_TRUE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); } TEST_F(OpLevelCostEstimatorTest, ExecutionTimeSumOrMax) { @@ -564,7 +578,9 @@ TEST_F(OpLevelCostEstimatorTest, ExecutionTimeSumOrMax) { EXPECT_EQ(Costs::Duration(2000), cost.memory_time); EXPECT_EQ(Costs::Duration(0), cost.compute_time); EXPECT_EQ(Costs::Duration(2000), cost.execution_time); // max(2000, 200) + EXPECT_EQ(1, cost.num_ops_total); EXPECT_TRUE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); SetComputeMemoryOverlap(false); // Set it back to default. } @@ -576,7 +592,9 @@ TEST_F(OpLevelCostEstimatorTest, EXPECT_EQ(Costs::Duration(825345), cost.memory_time); EXPECT_EQ(Costs::Duration(355321038), cost.compute_time); EXPECT_EQ(Costs::Duration(356146383), cost.execution_time); + EXPECT_EQ(1, cost.num_ops_total); EXPECT_FALSE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); } TEST_F(OpLevelCostEstimatorTest, FusedConv2DBiasActivationNCHW_HWIO) { @@ -586,7 +604,9 @@ TEST_F(OpLevelCostEstimatorTest, FusedConv2DBiasActivationNCHW_HWIO) { EXPECT_EQ(Costs::Duration(1416808), cost.memory_time); EXPECT_EQ(Costs::Duration(355616770), cost.compute_time); EXPECT_EQ(Costs::Duration(357033578), cost.execution_time); + EXPECT_EQ(1, cost.num_ops_total); EXPECT_FALSE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); } TEST_F(OpLevelCostEstimatorTest, FusedConv2DBiasActivationNCHW_OIHW) { @@ -596,7 +616,9 @@ TEST_F(OpLevelCostEstimatorTest, FusedConv2DBiasActivationNCHW_OIHW) { EXPECT_EQ(Costs::Duration(1416808), cost.memory_time); EXPECT_EQ(Costs::Duration(355616770), cost.compute_time); EXPECT_EQ(Costs::Duration(357033578), cost.execution_time); + EXPECT_EQ(1, cost.num_ops_total); EXPECT_FALSE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); } TEST_F(OpLevelCostEstimatorTest, FusedConv2DBiasActivationNHWC_HWIO) { @@ -606,7 +628,9 @@ TEST_F(OpLevelCostEstimatorTest, FusedConv2DBiasActivationNHWC_HWIO) { EXPECT_EQ(Costs::Duration(1416808), cost.memory_time); EXPECT_EQ(Costs::Duration(355616770), cost.compute_time); EXPECT_EQ(Costs::Duration(357033578), cost.execution_time); + EXPECT_EQ(1, cost.num_ops_total); EXPECT_FALSE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); } TEST_F(OpLevelCostEstimatorTest, FusedConv2DBiasActivationNHWC_OIHW) { @@ -616,7 +640,9 @@ TEST_F(OpLevelCostEstimatorTest, FusedConv2DBiasActivationNHWC_OIHW) { EXPECT_EQ(Costs::Duration(1416808), cost.memory_time); EXPECT_EQ(Costs::Duration(355616770), cost.compute_time); EXPECT_EQ(Costs::Duration(357033578), cost.execution_time); + EXPECT_EQ(1, cost.num_ops_total); EXPECT_FALSE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); } // TODO(yaozhang): Update once NCHW_VECT_C is supported. @@ -627,7 +653,9 @@ TEST_F(OpLevelCostEstimatorTest, FusedConv2DBiasActivationNCHW_VECT_C_OIHW) { EXPECT_EQ(Costs::Duration(0), cost.memory_time); EXPECT_EQ(Costs::Duration(0), cost.compute_time); EXPECT_EQ(Costs::Duration(0), cost.execution_time); + EXPECT_EQ(1, cost.num_ops_total); EXPECT_TRUE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); } // TODO(yaozhang): Update once OIHW_VECT_I is supported. @@ -638,7 +666,9 @@ TEST_F(OpLevelCostEstimatorTest, FusedConv2DBiasActivationNCHW_OIHW_VECT_I) { EXPECT_EQ(Costs::Duration(0), cost.memory_time); EXPECT_EQ(Costs::Duration(0), cost.compute_time); EXPECT_EQ(Costs::Duration(0), cost.execution_time); + EXPECT_EQ(1, cost.num_ops_total); EXPECT_TRUE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); } TEST_F(OpLevelCostEstimatorTest, MulExecutionTime) { @@ -646,7 +676,9 @@ TEST_F(OpLevelCostEstimatorTest, MulExecutionTime) { EXPECT_EQ(Costs::Duration(2000), cost.memory_time); EXPECT_EQ(Costs::Duration(200), cost.compute_time); EXPECT_EQ(Costs::Duration(2200), cost.execution_time); + EXPECT_EQ(1, cost.num_ops_total); EXPECT_FALSE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); } TEST_F(OpLevelCostEstimatorTest, MulBroadcastExecutionTime) { @@ -654,7 +686,9 @@ TEST_F(OpLevelCostEstimatorTest, MulBroadcastExecutionTime) { EXPECT_EQ(Costs::Duration(3600), cost.memory_time); EXPECT_EQ(Costs::Duration(400), cost.compute_time); EXPECT_EQ(Costs::Duration(4000), cost.execution_time); + EXPECT_EQ(1, cost.num_ops_total); EXPECT_FALSE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); } TEST_F(OpLevelCostEstimatorTest, ModExecutionTime) { @@ -662,7 +696,9 @@ TEST_F(OpLevelCostEstimatorTest, ModExecutionTime) { EXPECT_EQ(Costs::Duration(2000), cost.memory_time); EXPECT_EQ(Costs::Duration(1600), cost.compute_time); EXPECT_EQ(Costs::Duration(3600), cost.execution_time); + EXPECT_EQ(1, cost.num_ops_total); EXPECT_FALSE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); } TEST_F(OpLevelCostEstimatorTest, ReluExecutionTime) { @@ -670,28 +706,77 @@ TEST_F(OpLevelCostEstimatorTest, ReluExecutionTime) { EXPECT_EQ(Costs::Duration(800), cost.memory_time); EXPECT_EQ(Costs::Duration(100), cost.compute_time); EXPECT_EQ(Costs::Duration(900), cost.execution_time); + EXPECT_EQ(1, cost.num_ops_total); EXPECT_FALSE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); } TEST_F(OpLevelCostEstimatorTest, UnknownOrPartialShape) { - EXPECT_FALSE(PredictCosts(DescribeMatMul(2, 4, 7, 7)).inaccurate); - EXPECT_TRUE(PredictCosts(DescribeMatMul(-1, 4, 7, 7)).inaccurate); - EXPECT_TRUE(PredictCosts(DescribeMatMul(2, 4, -1, 7)).inaccurate); - - EXPECT_FALSE(PredictCosts(DescribeConvolution(16, 19, 19, 48, 48, 5, 5, 256)) - .inaccurate); - EXPECT_TRUE(PredictCosts(DescribeConvolution(16, -1, 19, 48, 48, 5, 5, 256)) - .inaccurate); + { + auto cost = PredictCosts(DescribeMatMul(2, 4, 7, 7)); + EXPECT_EQ(1, cost.num_ops_total); + EXPECT_FALSE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); + } + { + auto cost = PredictCosts(DescribeMatMul(-1, 4, 7, 7)); + EXPECT_EQ(1, cost.num_ops_total); + EXPECT_TRUE(cost.inaccurate); + EXPECT_EQ(1, cost.num_ops_with_unknown_shapes); + } + { + auto cost = PredictCosts(DescribeMatMul(2, 4, -1, 7)); + EXPECT_EQ(1, cost.num_ops_total); + EXPECT_TRUE(cost.inaccurate); + EXPECT_EQ(1, cost.num_ops_with_unknown_shapes); + } + { + auto cost = + PredictCosts(DescribeConvolution(16, 19, 19, 48, 48, 5, 5, 256)); + EXPECT_EQ(1, cost.num_ops_total); + EXPECT_FALSE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); + } + { + auto cost = + PredictCosts(DescribeConvolution(16, -1, 19, 48, 48, 5, 5, 256)); + EXPECT_EQ(1, cost.num_ops_total); + EXPECT_TRUE(cost.inaccurate); + EXPECT_EQ(1, cost.num_ops_with_unknown_shapes); + } } TEST_F(OpLevelCostEstimatorTest, BatchMatMul) { - EXPECT_TRUE(PredictCosts(DescribeBatchMatMul({}, {})).inaccurate); - EXPECT_TRUE(PredictCosts(DescribeBatchMatMul({2, 4}, {})).inaccurate); - EXPECT_FALSE(PredictCosts(DescribeBatchMatMul({2, 4}, {4, 2})).inaccurate); - EXPECT_FALSE( - PredictCosts(DescribeBatchMatMul({1, 2, 4}, {1, 4, 2})).inaccurate); - EXPECT_FALSE( - PredictCosts(DescribeBatchMatMul({2, 4}, {1, 3, 4, 2})).inaccurate); + { + auto cost = PredictCosts(DescribeBatchMatMul({}, {})); + EXPECT_EQ(1, cost.num_ops_total); + EXPECT_TRUE(cost.inaccurate); + EXPECT_EQ(1, cost.num_ops_with_unknown_shapes); + } + { + auto cost = PredictCosts(DescribeBatchMatMul({2, 4}, {})); + EXPECT_EQ(1, cost.num_ops_total); + EXPECT_TRUE(cost.inaccurate); + EXPECT_EQ(1, cost.num_ops_with_unknown_shapes); + } + { + auto cost = PredictCosts(DescribeBatchMatMul({2, 4}, {4, 2})); + EXPECT_EQ(1, cost.num_ops_total); + EXPECT_FALSE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); + } + { + auto cost = PredictCosts(DescribeBatchMatMul({1, 2, 4}, {1, 4, 2})); + EXPECT_EQ(1, cost.num_ops_total); + EXPECT_FALSE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); + } + { + auto cost = PredictCosts(DescribeBatchMatMul({2, 4}, {1, 3, 4, 2})); + EXPECT_EQ(1, cost.num_ops_total); + EXPECT_FALSE(cost.inaccurate); + EXPECT_EQ(0, cost.num_ops_with_unknown_shapes); + } bool matmul_inaccurate = false; bool batch_matmul_inaccurate = false; EXPECT_EQ( @@ -813,7 +898,9 @@ TEST_F(OpLevelCostEstimatorTest, PredictMaxPool) { EXPECT_EQ(Costs::Duration(1075200), costs.execution_time); EXPECT_EQ(Costs::Duration(307200), costs.compute_time); EXPECT_EQ(Costs::Duration(768000), costs.memory_time); + EXPECT_EQ(1, costs.num_ops_total); EXPECT_FALSE(costs.inaccurate); + EXPECT_EQ(0, costs.num_ops_with_unknown_shapes); } { // 1x1 window with 2x2 stride: used for shortcut in resnet-50. @@ -821,7 +908,9 @@ TEST_F(OpLevelCostEstimatorTest, PredictMaxPool) { EXPECT_EQ(Costs::Duration(499200), costs.execution_time); EXPECT_EQ(Costs::Duration(38400), costs.compute_time); EXPECT_EQ(Costs::Duration(460800), costs.memory_time); + EXPECT_EQ(1, costs.num_ops_total); EXPECT_FALSE(costs.inaccurate); + EXPECT_EQ(0, costs.num_ops_with_unknown_shapes); } { // 2x2 window with 3x3 stride. @@ -829,7 +918,9 @@ TEST_F(OpLevelCostEstimatorTest, PredictMaxPool) { EXPECT_EQ(Costs::Duration(561792), costs.execution_time); EXPECT_EQ(Costs::Duration(56448), costs.compute_time); EXPECT_EQ(Costs::Duration(505344), costs.memory_time); + EXPECT_EQ(1, costs.num_ops_total); EXPECT_FALSE(costs.inaccurate); + EXPECT_EQ(0, costs.num_ops_with_unknown_shapes); } } @@ -849,7 +940,9 @@ TEST_F(OpLevelCostEstimatorTest, PredictMaxPoolGrad) { EXPECT_EQ(Costs::Duration(1996800), costs.execution_time); EXPECT_EQ(Costs::Duration(614400), costs.compute_time); EXPECT_EQ(Costs::Duration(1382400), costs.memory_time); + EXPECT_EQ(1, costs.num_ops_total); EXPECT_FALSE(costs.inaccurate); + EXPECT_EQ(0, costs.num_ops_with_unknown_shapes); } { // 1x1 window with 2x2 stride: used for shortcut in resnet-50. @@ -857,7 +950,9 @@ TEST_F(OpLevelCostEstimatorTest, PredictMaxPoolGrad) { EXPECT_EQ(Costs::Duration(1536000), costs.execution_time); EXPECT_EQ(Costs::Duration(153600), costs.compute_time); EXPECT_EQ(Costs::Duration(1382400), costs.memory_time); + EXPECT_EQ(1, costs.num_ops_total); EXPECT_FALSE(costs.inaccurate); + EXPECT_EQ(0, costs.num_ops_with_unknown_shapes); } { // 2x2 window with 3x3 stride. @@ -865,7 +960,9 @@ TEST_F(OpLevelCostEstimatorTest, PredictMaxPoolGrad) { EXPECT_EQ(Costs::Duration(1514112), costs.execution_time); EXPECT_EQ(Costs::Duration(210048), costs.compute_time); EXPECT_EQ(Costs::Duration(1304064), costs.memory_time); + EXPECT_EQ(1, costs.num_ops_total); EXPECT_FALSE(costs.inaccurate); + EXPECT_EQ(0, costs.num_ops_with_unknown_shapes); } } @@ -884,7 +981,9 @@ TEST_F(OpLevelCostEstimatorTest, PredictAvgPool) { EXPECT_EQ(Costs::Duration(1113600), costs.execution_time); EXPECT_EQ(Costs::Duration(345600), costs.compute_time); EXPECT_EQ(Costs::Duration(768000), costs.memory_time); + EXPECT_EQ(1, costs.num_ops_total); EXPECT_FALSE(costs.inaccurate); + EXPECT_EQ(0, costs.num_ops_with_unknown_shapes); } { // 1x1 window with 2x2 stride: used for shortcut in resnet-50. @@ -892,7 +991,9 @@ TEST_F(OpLevelCostEstimatorTest, PredictAvgPool) { EXPECT_EQ(Costs::Duration(499200), costs.execution_time); EXPECT_EQ(Costs::Duration(38400), costs.compute_time); EXPECT_EQ(Costs::Duration(460800), costs.memory_time); + EXPECT_EQ(1, costs.num_ops_total); EXPECT_FALSE(costs.inaccurate); + EXPECT_EQ(0, costs.num_ops_with_unknown_shapes); } { // 2x2 window with 3x3 stride. @@ -900,7 +1001,9 @@ TEST_F(OpLevelCostEstimatorTest, PredictAvgPool) { EXPECT_EQ(Costs::Duration(580608), costs.execution_time); EXPECT_EQ(Costs::Duration(75264), costs.compute_time); EXPECT_EQ(Costs::Duration(505344), costs.memory_time); + EXPECT_EQ(1, costs.num_ops_total); EXPECT_FALSE(costs.inaccurate); + EXPECT_EQ(0, costs.num_ops_with_unknown_shapes); } } @@ -920,7 +1023,9 @@ TEST_F(OpLevelCostEstimatorTest, PredictAvgPoolGrad) { EXPECT_EQ(Costs::Duration(1305602), costs.execution_time); EXPECT_EQ(Costs::Duration(537600), costs.compute_time); EXPECT_EQ(Costs::Duration(768002), costs.memory_time); + EXPECT_EQ(1, costs.num_ops_total); EXPECT_FALSE(costs.inaccurate); + EXPECT_EQ(0, costs.num_ops_with_unknown_shapes); } { // 1x1 window with 2x2 stride: used for shortcut in resnet-50. @@ -928,7 +1033,9 @@ TEST_F(OpLevelCostEstimatorTest, PredictAvgPoolGrad) { EXPECT_EQ(Costs::Duration(960002), costs.execution_time); EXPECT_EQ(Costs::Duration(192000), costs.compute_time); EXPECT_EQ(Costs::Duration(768002), costs.memory_time); + EXPECT_EQ(1, costs.num_ops_total); EXPECT_FALSE(costs.inaccurate); + EXPECT_EQ(0, costs.num_ops_with_unknown_shapes); } { // 2x2 window with 3x3 stride. @@ -936,7 +1043,9 @@ TEST_F(OpLevelCostEstimatorTest, PredictAvgPoolGrad) { EXPECT_EQ(Costs::Duration(862082), costs.execution_time); EXPECT_EQ(Costs::Duration(172416), costs.compute_time); EXPECT_EQ(Costs::Duration(689666), costs.memory_time); + EXPECT_EQ(1, costs.num_ops_total); EXPECT_FALSE(costs.inaccurate); + EXPECT_EQ(0, costs.num_ops_with_unknown_shapes); } } @@ -953,7 +1062,9 @@ TEST_F(OpLevelCostEstimatorTest, PredictFusedBatchNorm) { EXPECT_EQ(Costs::Duration(614737), costs.execution_time); EXPECT_EQ(Costs::Duration(153706), costs.compute_time); EXPECT_EQ(Costs::Duration(461031), costs.memory_time); + EXPECT_EQ(1, costs.num_ops_total); EXPECT_FALSE(costs.inaccurate); + EXPECT_EQ(0, costs.num_ops_with_unknown_shapes); } { @@ -961,7 +1072,9 @@ TEST_F(OpLevelCostEstimatorTest, PredictFusedBatchNorm) { EXPECT_EQ(Costs::Duration(204913), costs.execution_time); EXPECT_EQ(Costs::Duration(51236), costs.compute_time); EXPECT_EQ(Costs::Duration(153677), costs.memory_time); + EXPECT_EQ(1, costs.num_ops_total); EXPECT_FALSE(costs.inaccurate); + EXPECT_EQ(0, costs.num_ops_with_unknown_shapes); } { @@ -969,7 +1082,9 @@ TEST_F(OpLevelCostEstimatorTest, PredictFusedBatchNorm) { EXPECT_EQ(Costs::Duration(384154), costs.execution_time); EXPECT_EQ(Costs::Duration(76800), costs.compute_time); EXPECT_EQ(Costs::Duration(307354), costs.memory_time); + EXPECT_EQ(1, costs.num_ops_total); EXPECT_FALSE(costs.inaccurate); + EXPECT_EQ(0, costs.num_ops_with_unknown_shapes); } { @@ -978,6 +1093,8 @@ TEST_F(OpLevelCostEstimatorTest, PredictFusedBatchNorm) { EXPECT_EQ(Costs::Duration(25600), costs.compute_time); EXPECT_EQ(Costs::Duration(102452), costs.memory_time); EXPECT_FALSE(costs.inaccurate); + EXPECT_EQ(1, costs.num_ops_total); + EXPECT_EQ(0, costs.num_ops_with_unknown_shapes); } } @@ -994,7 +1111,9 @@ TEST_F(OpLevelCostEstimatorTest, PredictFusedBatchNormGrad) { EXPECT_EQ(Costs::Duration(1037050), costs.execution_time); EXPECT_EQ(Costs::Duration(422496), costs.compute_time); EXPECT_EQ(Costs::Duration(614554), costs.memory_time); + EXPECT_EQ(1, costs.num_ops_total); EXPECT_FALSE(costs.inaccurate); + EXPECT_EQ(0, costs.num_ops_with_unknown_shapes); } { @@ -1002,7 +1121,9 @@ TEST_F(OpLevelCostEstimatorTest, PredictFusedBatchNormGrad) { EXPECT_EQ(Costs::Duration(6503809), costs.execution_time); EXPECT_EQ(Costs::Duration(2649677), costs.compute_time); EXPECT_EQ(Costs::Duration(3854132), costs.memory_time); + EXPECT_EQ(1, costs.num_ops_total); EXPECT_FALSE(costs.inaccurate); + EXPECT_EQ(0, costs.num_ops_with_unknown_shapes); } } } // end namespace grappler diff --git a/tensorflow/core/grappler/costs/virtual_scheduler.cc b/tensorflow/core/grappler/costs/virtual_scheduler.cc index f31d22e105..6e3ebdee12 100644 --- a/tensorflow/core/grappler/costs/virtual_scheduler.cc +++ b/tensorflow/core/grappler/costs/virtual_scheduler.cc @@ -47,9 +47,11 @@ Costs CombineCosts(const Costs& left, const Costs& right) { result.execution_time += right.execution_time; result.compute_time += right.compute_time; result.memory_time += right.memory_time; - if (right.inaccurate) { - result.inaccurate = true; - } + + result.num_ops_total += right.num_ops_total; + if (right.inaccurate) result.inaccurate = true; + result.num_ops_with_unknown_shapes += right.num_ops_with_unknown_shapes; + if (right.max_memory != kMemoryUnknown) { result.max_memory += right.max_memory; } @@ -283,6 +285,7 @@ VirtualScheduler::VirtualScheduler(const GrapplerItem* grappler_item, grappler_item_(grappler_item), use_static_shapes_(use_static_shapes), placer_(cluster) { + graph_costs_.num_ops_total = 0; initialized_ = false; } @@ -845,6 +848,11 @@ bool VirtualScheduler::MarkCurrNodeExecuted(const Costs& node_costs) { } Costs VirtualScheduler::Summary() const { + // Overall statement about accuracy + VLOG(1) << graph_costs_.num_ops_total << " ops processed in total, with " + << graph_costs_.num_ops_with_unknown_shapes + << " having unknown shapes"; + // Print out basic execution summary. VLOG(1) << "Expected execution time: " << graph_costs_.execution_time.count(); VLOG(1) << "Expected compute time: " << graph_costs_.compute_time.count(); @@ -906,6 +914,12 @@ Costs VirtualScheduler::Summary() const { << ", at the end: " << strings::HumanReadableNumBytes(state.memory_usage); + // Overall statement about accuracy + VLOG(1) << state.device_costs.num_ops_total + << " ops processed in total, with " + << state.device_costs.num_ops_with_unknown_shapes + << " having unknown shapes"; + VLOG(1) << "Per-op execution time / compute time / memory time " "(and memory usage at peak memory usage):"; diff --git a/tensorflow/core/grappler/costs/virtual_scheduler.h b/tensorflow/core/grappler/costs/virtual_scheduler.h index 353ca6f071..0e66e8a463 100644 --- a/tensorflow/core/grappler/costs/virtual_scheduler.h +++ b/tensorflow/core/grappler/costs/virtual_scheduler.h @@ -114,6 +114,7 @@ struct DeviceState { DeviceState() { device_costs = Costs::ZeroCosts(); + device_costs.num_ops_total = 0; memory_usage = 0; max_memory_usage = 0; } diff --git a/tensorflow/core/grappler/costs/virtual_scheduler_test.cc b/tensorflow/core/grappler/costs/virtual_scheduler_test.cc index f9154e42f9..b1373d8317 100644 --- a/tensorflow/core/grappler/costs/virtual_scheduler_test.cc +++ b/tensorflow/core/grappler/costs/virtual_scheduler_test.cc @@ -942,7 +942,6 @@ versions { // target_node. std::unordered_map RunScheduler( const string& target_node) { - Costs zero_costs = Costs::ZeroCosts(); std::unordered_map ops_executed; bool more_nodes = true; do { @@ -1632,6 +1631,9 @@ TEST_F(VirtualSchedulerTest, SummaryCostTest) { // Misc - 5 * 1us // Total: 13000005 EXPECT_EQ(13000005, c.execution_time.asMicroSeconds().count()); + EXPECT_EQ(grappler_item_->graph.node_size(), c.num_ops_total); + EXPECT_FALSE(c.inaccurate); + EXPECT_EQ(0, c.num_ops_with_unknown_shapes); } // Like the above SummaryCostTest, but makes sure the stepstats timeline is @@ -1645,6 +1647,9 @@ TEST_F(VirtualSchedulerTest, SummaryCostStepStatsTest) { Costs c = scheduler_->Summary(&metadata); StepStats stepstats = metadata.step_stats(); EXPECT_EQ(13000005, c.execution_time.asMicroSeconds().count()); + EXPECT_EQ(grappler_item_->graph.node_size(), c.num_ops_total); + EXPECT_FALSE(c.inaccurate); + EXPECT_EQ(0, c.num_ops_with_unknown_shapes); // Should only be 1 device! EXPECT_EQ(1, stepstats.dev_stats().size()); -- GitLab From 07e33d027f65c0c3e301ba9befbe82fc78cb3fa6 Mon Sep 17 00:00:00 2001 From: Dimitris Vardoulakis Date: Fri, 10 Aug 2018 15:20:12 -0700 Subject: [PATCH 364/437] Lift the restriction in the docs that while loops can't be nested. PiperOrigin-RevId: 208276989 --- tensorflow/docs_src/performance/xla/operation_semantics.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/tensorflow/docs_src/performance/xla/operation_semantics.md b/tensorflow/docs_src/performance/xla/operation_semantics.md index bd7b0f7048..e24a7cda73 100644 --- a/tensorflow/docs_src/performance/xla/operation_semantics.md +++ b/tensorflow/docs_src/performance/xla/operation_semantics.md @@ -2385,8 +2385,6 @@ restrictions listed below. last execution of the `body`. * The shape of the type `T` is statically determined and must be the same across all iterations. -* `While` nodes are not allowed to be nested. (This restriction may be lifted - in the future on some targets.) The T parameters of the computations are initialized with the `init` value in the first iteration and are automatically updated to the new result from `body` -- GitLab From 274e784585460a74b28297dc1e2febfb262457dd Mon Sep 17 00:00:00 2001 From: Akshay Modi Date: Fri, 10 Aug 2018 15:21:30 -0700 Subject: [PATCH 365/437] Add tests for remote eager execution. PiperOrigin-RevId: 208277185 --- tensorflow/contrib/eager/python/BUILD | 14 ++ .../contrib/eager/python/remote_test.py | 178 ++++++++++++++++++ 2 files changed, 192 insertions(+) create mode 100644 tensorflow/contrib/eager/python/remote_test.py diff --git a/tensorflow/contrib/eager/python/BUILD b/tensorflow/contrib/eager/python/BUILD index 48b6f4acb2..f7933639a0 100644 --- a/tensorflow/contrib/eager/python/BUILD +++ b/tensorflow/contrib/eager/python/BUILD @@ -223,3 +223,17 @@ py_test( "//tensorflow/python/eager:test", ], ) + +py_test( + name = "remote_test", + srcs = ["remote_test.py"], + srcs_version = "PY2AND3", + deps = [ + "//tensorflow/contrib/eager/python:tfe", + "//tensorflow/python:array_ops", + "//tensorflow/python:client", + "//tensorflow/python:framework", + "//tensorflow/python:math_ops", + "//tensorflow/python/eager:function", + ], +) diff --git a/tensorflow/contrib/eager/python/remote_test.py b/tensorflow/contrib/eager/python/remote_test.py new file mode 100644 index 0000000000..76f48eeb1c --- /dev/null +++ b/tensorflow/contrib/eager/python/remote_test.py @@ -0,0 +1,178 @@ +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== +"""Tests for remote eager execution.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import functools +import os + +import numpy as np + +from tensorflow.core.protobuf import cluster_pb2 +from tensorflow.core.protobuf import tensorflow_server_pb2 +from tensorflow.python.eager import backprop +from tensorflow.python.eager import context +from tensorflow.python.eager import function +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 resource_variable_ops +from tensorflow.python.platform import test +from tensorflow.python.training import server_lib + +JOB_NAME = "remote_device" +ALT_JOB_NAME = "alt_remote_device" + + +def run_sync_and_async(f): + """Execute all test methods in the given class in sync and async modes.""" + + @functools.wraps(f) + def decorator(self, *args, **kwargs): + with context.execution_mode(context.ASYNC): + f(self, *args, **kwargs) + + with context.execution_mode(context.SYNC): + f(self, *args, **kwargs) + + return decorator + + +def get_server_def(job_name, local_server_port, remote_server_addresses, + task_index): + """Returns a server def with a single job + multiple tasks.""" + cluster_def = cluster_pb2.ClusterDef() + job_def = cluster_def.job.add() + job_def.name = job_name + job_def.tasks[0] = "localhost:%d" % local_server_port + + for i, remote_server_address in enumerate(remote_server_addresses, start=1): + job_def.tasks[i] = remote_server_address + + server_def = tensorflow_server_pb2.ServerDef( + cluster=cluster_def, + job_name=job_name, + task_index=task_index, + protocol="grpc") + + return server_def + + +class RemoteExecutionTest(test.TestCase): + + def __init__(self, methodName="runTest"): # pylint: disable=invalid-name + super(RemoteExecutionTest, self).__init__(methodName) + self._cached_server1 = server_lib.Server.create_local_server() + self._cached_server2 = server_lib.Server.create_local_server() + + os.environ["TF_EAGER_REMOTE_USE_SEND_TENSOR_RPC"] = "1" + + self._cached_server1_target = self._cached_server1.target[len("grpc://"):] + self._cached_server2_target = self._cached_server2.target[len("grpc://"):] + + # Start the local server. + context.set_server_def( + server_def=get_server_def( + JOB_NAME, + local_server_port=0, + remote_server_addresses=[ + self._cached_server1_target, self._cached_server2_target + ], + task_index=0)) + + @run_sync_and_async + def testDefunMatmul(self): + """Basic remote eager execution with defun.""" + + mm_defun = function.defun(math_ops.matmul) + with ops.device("job:%s/replica:0/task:1/device:CPU:0" % JOB_NAME): + x1 = array_ops.ones([2, 2]) + with ops.device("job:%s/replica:0/task:2/device:CPU:0" % JOB_NAME): + x2 = array_ops.ones([2, 2]) + y = mm_defun(x1, x2) + np.testing.assert_array_equal([[2, 2], [2, 2]], y.numpy()) + + @run_sync_and_async + def testSimpleMatmul(self): + """Basic remote eager execution.""" + + with ops.device("job:%s/replica:0/task:1/device:CPU:0" % JOB_NAME): + x1 = array_ops.ones([2, 2]) + with ops.device("job:%s/replica:0/task:2/device:CPU:0" % JOB_NAME): + x2 = array_ops.ones([2, 2]) + y = math_ops.matmul(x1, x2) + np.testing.assert_array_equal([[2, 2], [2, 2]], y.numpy()) + + @run_sync_and_async + def testSimpleWeightRead(self): + """Basic remote eager weight read.""" + + with ops.device("job:%s/replica:0/task:1/device:CPU:0" % JOB_NAME): + w = resource_variable_ops.ResourceVariable([[2.0]]) + loss = w * w + np.testing.assert_array_equal([[4.0]], loss.numpy()) + + @run_sync_and_async + def testTapeWeightRead(self): + """Remote eager weight read in a tape.""" + + with ops.device("job:%s/replica:0/task:1/device:CPU:0" % JOB_NAME): + w = resource_variable_ops.ResourceVariable([[3.0]]) + with backprop.GradientTape() as tape: + loss = w * w + + grad = tape.gradient(loss, w) + np.testing.assert_array_equal([[9.0]], loss.numpy()) + np.testing.assert_array_equal([[6.0]], grad.numpy()) + + @run_sync_and_async + def testServerDefChanged(self): + """Update server def, and run ops on new cluster.""" + context.set_server_def( + server_def=get_server_def( + ALT_JOB_NAME, + local_server_port=0, + remote_server_addresses=[ + self._cached_server1_target, self._cached_server2_target + ], + task_index=0)) + + with ops.device("job:%s/replica:0/task:1/device:CPU:0" % ALT_JOB_NAME): + x1 = array_ops.ones([2, 2]) + y = math_ops.matmul(x1, x1) + np.testing.assert_array_equal([[2, 2], [2, 2]], y.numpy()) + + # Set the server def back to JOB_NAME + context.set_server_def( + server_def=get_server_def( + JOB_NAME, + local_server_port=0, + remote_server_addresses=[ + self._cached_server1_target, self._cached_server2_target + ], + task_index=0)) + + with ops.device("job:%s/replica:0/task:1/device:CPU:0" % JOB_NAME): + x1 = array_ops.ones([2, 2]) + y = math_ops.matmul(x1, x1) + np.testing.assert_array_equal([[2, 2], [2, 2]], y.numpy()) + + +if __name__ == "__main__": + ops.enable_eager_execution() + test.main() -- GitLab From cb372f7d165abb3ac714d3420a00048028704a43 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Fri, 10 Aug 2018 15:25:02 -0700 Subject: [PATCH 366/437] Correct a mistake in the lgamma documentation The lower regularized incomplete Gamma function as defined in the documentation is P(a, x) but the heading for the function is Q(a, x). This is incorrect, Q(a, x) refers to the upper regularized incomplete Gamma function. PiperOrigin-RevId: 208277703 --- tensorflow/core/api_def/base_api/api_def_Igamma.pbtxt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/core/api_def/base_api/api_def_Igamma.pbtxt b/tensorflow/core/api_def/base_api/api_def_Igamma.pbtxt index e7bc5ddae2..40d7d371ca 100644 --- a/tensorflow/core/api_def/base_api/api_def_Igamma.pbtxt +++ b/tensorflow/core/api_def/base_api/api_def_Igamma.pbtxt @@ -1,6 +1,6 @@ op { graph_op_name: "Igamma" - summary: "Compute the lower regularized incomplete Gamma function `Q(a, x)`." + summary: "Compute the lower regularized incomplete Gamma function `P(a, x)`." description: < Date: Fri, 10 Aug 2018 15:31:00 -0700 Subject: [PATCH 367/437] Add support for the new metrics in Keras. - Add support for stateful metrics, weighted metrics, metric masking in eager mode. - Updated masking logic for loss and metrics. (similar to weights in cl/207311700) - Add weighted_metrics to save and load model. - Add Categorical accuracy metric. - Migrating #21071 PiperOrigin-RevId: 208278596 --- tensorflow/python/estimator/keras.py | 2 +- tensorflow/python/keras/callbacks.py | 11 +- tensorflow/python/keras/engine/saving.py | 4 + tensorflow/python/keras/engine/saving_test.py | 44 ++- .../python/keras/engine/sequential_test.py | 15 +- tensorflow/python/keras/engine/training.py | 258 ++++++++++++---- .../python/keras/engine/training_eager.py | 136 +++++---- .../keras/engine/training_eager_test.py | 9 +- .../python/keras/engine/training_generator.py | 3 +- .../python/keras/engine/training_test.py | 283 ++++++++++++------ .../python/keras/engine/training_utils.py | 89 ++---- tensorflow/python/keras/metrics.py | 84 ++++-- tensorflow/python/keras/metrics_test.py | 24 ++ .../python/keras/model_subclassing_test.py | 7 +- 14 files changed, 646 insertions(+), 323 deletions(-) diff --git a/tensorflow/python/estimator/keras.py b/tensorflow/python/estimator/keras.py index c91204a35f..a5f07fea3b 100644 --- a/tensorflow/python/estimator/keras.py +++ b/tensorflow/python/estimator/keras.py @@ -396,7 +396,7 @@ def _create_keras_model_fn(keras_model, custom_objects=None): loss = model.total_loss if model.metrics: - # TODO(fchollet): support stateful metrics + # TODO(psv/fchollet): support stateful metrics eval_metric_ops = {} # When each metric maps to an output if isinstance(model.metrics, dict): diff --git a/tensorflow/python/keras/callbacks.py b/tensorflow/python/keras/callbacks.py index 3e112b3132..f2feeb85a1 100644 --- a/tensorflow/python/keras/callbacks.py +++ b/tensorflow/python/keras/callbacks.py @@ -94,9 +94,14 @@ def configure_callbacks(callbacks, # Add additional callbacks model.history = History() - callbacks = [BaseLogger()] + (callbacks or []) + [model.history] + stateful_metric_names = None + if hasattr(model, 'stateful_metric_names'): + stateful_metric_names = model.stateful_metric_names + callbacks = [BaseLogger(stateful_metrics=stateful_metric_names) + ] + (callbacks or []) + [model.history] if verbose: - callbacks.append(ProgbarLogger(count_mode)) + callbacks.append( + ProgbarLogger(count_mode, stateful_metrics=stateful_metric_names)) callback_list = CallbackList(callbacks) # Set callback model @@ -110,6 +115,8 @@ def configure_callbacks(callbacks, # Set callback parameters callback_metrics = [] + # When we have deferred build scenario with iterator input, we will compile + # when we standardize first batch of data. if model._is_compiled: # pylint: disable=protected-access callback_metrics = copy.copy(model.metrics_names) if do_validation: diff --git a/tensorflow/python/keras/engine/saving.py b/tensorflow/python/keras/engine/saving.py index d5ccd44604..a2eed7cb46 100644 --- a/tensorflow/python/keras/engine/saving.py +++ b/tensorflow/python/keras/engine/saving.py @@ -127,6 +127,7 @@ def save_model(model, filepath, overwrite=True, include_optimizer=True): }, 'loss': model.loss, 'metrics': model.metrics, + 'weighted_metrics': model.weighted_metrics, 'sample_weight_mode': model.sample_weight_mode, 'loss_weights': model.loss_weights, }, @@ -246,6 +247,8 @@ def load_model(filepath, custom_objects=None, compile=True): # pylint: disable= # Recover loss functions and metrics. loss = convert_custom_objects(training_config['loss']) metrics = convert_custom_objects(training_config['metrics']) + weighted_metrics = convert_custom_objects( + training_config['weighted_metrics']) sample_weight_mode = training_config['sample_weight_mode'] loss_weights = training_config['loss_weights'] @@ -254,6 +257,7 @@ def load_model(filepath, custom_objects=None, compile=True): # pylint: disable= optimizer=optimizer, loss=loss, metrics=metrics, + weighted_metrics=weighted_metrics, loss_weights=loss_weights, sample_weight_mode=sample_weight_mode) diff --git a/tensorflow/python/keras/engine/saving_test.py b/tensorflow/python/keras/engine/saving_test.py index cf4c7deb17..b7c2e9cb53 100644 --- a/tensorflow/python/keras/engine/saving_test.py +++ b/tensorflow/python/keras/engine/saving_test.py @@ -338,10 +338,18 @@ class TestWholeModelSaving(test.TestCase): model.add(keras.layers.Dense(2, input_shape=(3,))) model.add(keras.layers.RepeatVector(3)) model.add(keras.layers.TimeDistributed(keras.layers.Dense(3))) - model.compile(loss=keras.losses.MSE, - optimizer=keras.optimizers.RMSprop(lr=0.0001), - metrics=[keras.metrics.categorical_accuracy], - sample_weight_mode='temporal') + model.compile( + loss=keras.losses.MSE, + optimizer=keras.optimizers.RMSprop(lr=0.0001), + metrics=[ + keras.metrics.categorical_accuracy, + keras.metrics.CategoricalAccuracy() + ], + weighted_metrics=[ + keras.metrics.categorical_accuracy, + keras.metrics.CategoricalAccuracy() + ], + sample_weight_mode='temporal') x = np.random.random((1, 3)) y = np.random.random((1, 3, 3)) model.train_on_batch(x, y) @@ -436,9 +444,17 @@ class TestWholeModelSaving(test.TestCase): output = keras.layers.Dense(3)(x) model = keras.models.Model(inputs, output) - model.compile(loss=keras.losses.MSE, - optimizer=keras.optimizers.RMSprop(lr=0.0001), - metrics=[keras.metrics.categorical_accuracy]) + model.compile( + loss=keras.losses.MSE, + optimizer=keras.optimizers.RMSprop(lr=0.0001), + metrics=[ + keras.metrics.categorical_accuracy, + keras.metrics.CategoricalAccuracy() + ], + weighted_metrics=[ + keras.metrics.categorical_accuracy, + keras.metrics.CategoricalAccuracy() + ]) x = np.random.random((1, 3)) y = np.random.random((1, 3)) model.train_on_batch(x, y) @@ -624,9 +640,13 @@ class TestWholeModelSaving(test.TestCase): outputs = keras.layers.Dense(3)(x) model = keras.Model(inputs, outputs) - model.compile(loss=keras.losses.MSE, - optimizer=keras.optimizers.Adam(), - metrics=[keras.metrics.categorical_accuracy]) + model.compile( + loss=keras.losses.MSE, + optimizer=keras.optimizers.Adam(), + metrics=[ + keras.metrics.categorical_accuracy, + keras.metrics.CategoricalAccuracy() + ]) x = np.random.random((1, 3)) y = np.random.random((1, 3)) model.train_on_batch(x, y) @@ -745,7 +765,7 @@ class TestWeightSavingAndLoadingTFFormat(test.TestCase): model.compile( loss='mse', optimizer=training_module.RMSPropOptimizer(0.1), - metrics=['acc']) + metrics=['acc', keras.metrics.CategoricalAccuracy()]) temp_dir = self.get_temp_dir() prefix = os.path.join(temp_dir, 'ckpt') train_x = np.random.random((3, 2)) @@ -782,7 +802,7 @@ class TestWeightSavingAndLoadingTFFormat(test.TestCase): load_model.compile( loss='mse', optimizer=training_module.RMSPropOptimizer(0.1), - metrics=['acc']) + metrics=['acc', keras.metrics.CategoricalAccuracy()]) load_model.train_on_batch(train_x, train_y) self.assertAllClose(ref_y_after_train, self.evaluate(load_model(x))) diff --git a/tensorflow/python/keras/engine/sequential_test.py b/tensorflow/python/keras/engine/sequential_test.py index 51db7ded1d..3f8e120df0 100644 --- a/tensorflow/python/keras/engine/sequential_test.py +++ b/tensorflow/python/keras/engine/sequential_test.py @@ -95,7 +95,10 @@ class TestSequential(test.TestCase, parameterized.TestCase): num_classes = 2 model = _get_small_mlp(num_hidden, num_classes) - model.compile(loss='mse', optimizer=rmsprop.RMSPropOptimizer(1e-3)) + model.compile( + loss='mse', + optimizer=rmsprop.RMSPropOptimizer(1e-3), + metrics=[keras.metrics.CategoricalAccuracy()]) self.assertEqual(len(model.layers), 2) self.assertEqual(len(model.weights), 0) self.assertFalse(model.built) @@ -116,7 +119,10 @@ class TestSequential(test.TestCase, parameterized.TestCase): steps_per_epoch = 10 model = _get_small_mlp(num_hidden, num_classes) - model.compile(loss='mse', optimizer=rmsprop.RMSPropOptimizer(1e-3)) + model.compile( + loss='mse', + optimizer=rmsprop.RMSPropOptimizer(1e-3), + metrics=[keras.metrics.CategoricalAccuracy()]) self.assertEqual(len(model.layers), 2) self.assertEqual(len(model.weights), 0) self.assertFalse(model.built) @@ -257,7 +263,10 @@ class TestSequential(test.TestCase, parameterized.TestCase): num_classes = 2 model = _get_small_mlp(num_hidden, num_classes) - model.compile(loss='mse', optimizer=rmsprop.RMSPropOptimizer(1e-3)) + model.compile( + loss='mse', + optimizer=rmsprop.RMSPropOptimizer(1e-3), + metrics=[keras.metrics.CategoricalAccuracy()]) self.assertFalse(model.built) x = np.random.random((batch_size, input_dim)) diff --git a/tensorflow/python/keras/engine/training.py b/tensorflow/python/keras/engine/training.py index 28ced47b0f..7b974cab63 100644 --- a/tensorflow/python/keras/engine/training.py +++ b/tensorflow/python/keras/engine/training.py @@ -29,6 +29,7 @@ from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_util from tensorflow.python.keras import backend as K from tensorflow.python.keras import losses +from tensorflow.python.keras import metrics as metrics_module from tensorflow.python.keras import optimizers from tensorflow.python.keras.engine import base_layer from tensorflow.python.keras.engine import distributed_training_utils @@ -39,6 +40,8 @@ from tensorflow.python.keras.engine import training_generator from tensorflow.python.keras.engine import training_utils from tensorflow.python.keras.engine.network import Network from tensorflow.python.keras.utils.generic_utils import slice_arrays +from tensorflow.python.ops import math_ops +from tensorflow.python.ops import weights_broadcast_ops from tensorflow.python.platform import tf_logging as logging from tensorflow.python.training import optimizer as tf_optimizer_module from tensorflow.python.training.checkpointable import base as checkpointable @@ -138,6 +141,167 @@ class Model(Network): if i not in skip_target_weighing_indices ] + def _get_metric_name(self, metric, output_index, weighted=False): + """Returns the metric name corresponding to the given metric input. + + Arguments: + metric: Metric function name or reference. + output_index: Index of the current output. + weighted: Boolean indicating if the given metric is weighted. + + Returns: + A metric name. + """ + metric_name_prefix = 'weighted_' if weighted else '' + if metric in ('accuracy', 'acc', 'crossentropy', 'ce'): + if metric in ('accuracy', 'acc'): + suffix = 'acc' + elif metric in ('crossentropy', 'ce'): + suffix = 'ce' + else: + metric_fn = metrics_module.get(metric) + # Get metric name as string + if hasattr(metric_fn, 'name'): + suffix = metric_fn.name + else: + suffix = metric_fn.__name__ + metric_name = metric_name_prefix + suffix + + if len(self.output_names) > 1: + metric_name = '%s_%s' % (self.output_names[output_index], metric_name) + j = 1 + base_metric_name = metric_name + while metric_name in self.metrics_names: + metric_name = '%s_%d' % (base_metric_name, j) + j += 1 + + return metric_name + + def _handle_per_output_metrics(self, + metrics, + y_true, + y_pred, + output_index, + output_shape, + loss_fn, + mask, + weights=None): + """Calls metric functions and sets metric attributes for a single output. + + Arguments: + metrics: List of metrics. + y_true: Target output. + y_pred: Predicted output. + output_index: Index of the current output. + output_shape: Shape of the current output. + loss_fn: Loss function corresponding to the current output. + mask: Computed mask value for the current output. + weights: Weights to be applied on the current output. + + Returns: + A list of metric result tensors. + """ + metric_results = [] + for metric in metrics: + metric_fn = training_utils.get_metric_function( + metric, output_shape=output_shape, loss_fn=loss_fn) + metric_name = self._get_metric_name( + metric, output_index, weighted=weights is not None) + + with K.name_scope(metric_name): + # If both outputs and targets are available, call the metric function. + if y_true is not None and y_pred is not None: + if isinstance(metric_fn, metrics_module.Metric): + # Call the stateful metric function. + if mask is not None: + mask = math_ops.cast(mask, y_pred.dtype) + # Update weights with mask. + if weights is None: + weights = mask + else: + # Update shape of weights if possible before adding mask. + # Update dimensions of weights to match with mask if possible. + mask, _, weights = metrics_module.squeeze_or_expand_dimensions( + mask, None, weights) + try: + # Broadcast weights if possible. + weights = weights_broadcast_ops.broadcast_weights( + weights, mask) + except ValueError: + pass + # TODO(psv): Handle case when mask and weight shapes are not + # compatible. + weights *= mask + + metric_result = metric_fn(y_true, y_pred, weights) + else: + # Call the stateless metric function. + weighted_metric_fn = training_utils.weighted_masked_objective( + metric_fn) + metric_result = weighted_metric_fn( + y_true, y_pred, weights=weights, mask=mask) + + if not context.executing_eagerly(): + # Keep track of metric result tensor. + self.metrics_tensors.append(metric_result) + metric_results.append(metric_result) + + # Keep track of metric name. + self.metrics_names.append(metric_name) + + # Keep track of stateful metric attributes (name and metric function). + if isinstance(metric_fn, base_layer.Layer) and metric_fn.stateful: + self.stateful_metric_names.append(metric_name) + self.stateful_metric_functions.append(metric_fn) + if not context.executing_eagerly(): + # Keep track of updates created by stateful metrics. + self.metrics_updates += metric_fn.updates + return metric_results + + def _handle_metrics(self, + outputs, + skip_target_indices=None, + targets=None, + sample_weights=None, + masks=None): + """Handles calling metric functions and setting model metric attributes. + + Arguments: + outputs: List of outputs (predictions). + skip_target_indices: Optional. List of target ids to skip. + targets: List of targets. + sample_weights: Optional list of sample weight arrays. + masks: List of computed output mask values. + + Returns: + A list of metric result tensors. + """ + skip_target_indices = skip_target_indices or [] + metric_results = [] + with K.name_scope('metrics'): + for i in range(len(outputs)): + if i in skip_target_indices: + continue + output = outputs[i] if outputs else None + target = targets[i] if targets else None + output_shape = None if output is None else output.get_shape().as_list() + output_mask = masks[i] if masks else None + metric_results.extend( + self._handle_per_output_metrics( + self.nested_metrics[i], target, output, i, output_shape, + self.loss_functions[i], output_mask)) + metric_results.extend( + self._handle_per_output_metrics( + self.nested_weighted_metrics[i], + target, + output, + i, + output_shape, + self.loss_functions[i], + output_mask, + weights=sample_weights[i])) + return metric_results + @checkpointable.no_automatic_dependency_tracking def compile(self, optimizer, @@ -233,8 +397,6 @@ class Model(Network): self.metrics = metrics or [] self.loss_weights = loss_weights self.sample_weight_mode = sample_weight_mode - if context.executing_eagerly() and weighted_metrics is not None: - raise ValueError('weighted_metrics is not supported in Eager mode.') self.weighted_metrics = weighted_metrics if context.executing_eagerly() and target_tensors is not None: raise ValueError('target_tensors is not supported in Eager mode.') @@ -337,6 +499,20 @@ class Model(Network): str(loss_weights) + ' - expected a list of dicts.') self.loss_weights_list = loss_weights_list + # Initialize model metric attributes. + self.metrics_names = ['loss'] + self.metrics_tensors = [] + self.metrics_updates = [] + self.stateful_metric_names = [] + self.stateful_metric_functions = [] + + # Nested metrics is a list of list of metrics. + # One list per output of the model. + self.nested_metrics = training_utils.collect_metrics( + metrics, self.output_names) + self.nested_weighted_metrics = training_utils.collect_metrics( + weighted_metrics, self.output_names) + # Initialization for Eager mode execution. if context.executing_eagerly(): # Prepare sample weights. @@ -347,19 +523,16 @@ class Model(Network): raise ValueError('target_tensors are not currently supported in Eager ' 'mode.') self.total_loss = None - self.metrics_tensors = [] - self.metrics_names = ['loss'] for i in range(len(self.outputs)): if len(self.outputs) > 1: self.metrics_names.append(self.output_names[i] + '_loss') - self.nested_metrics = training_utils.collect_metrics(metrics, - self.output_names) - # TODO(fchollet): support stateful metrics in eager execution. - self.stateful_metric_functions = [] - self.stateful_metric_names = [] - - with K.name_scope('metrics'): - training_utils.populate_metric_names(self) + + # Set metric attributes on model. + self._handle_metrics( + self.outputs, + skip_target_indices=skip_target_indices, + sample_weights=self.sample_weights) + self.targets = [] for i in range(len(self.outputs)): self._feed_output_names.append(self.output_names[i]) @@ -422,11 +595,6 @@ class Model(Network): self._set_sample_weight_attributes(sample_weight_mode, skip_target_weighing_indices) - # Prepare metrics. - self.weighted_metrics = weighted_metrics - self.metrics_names = ['loss'] - self.metrics_tensors = [] - # Compute total loss. total_loss = None with K.name_scope('loss'): @@ -460,55 +628,13 @@ class Model(Network): for loss_tensor in self.losses: total_loss += loss_tensor - # List of same size as output_names. - # contains tuples (metrics for output, names of metrics). - nested_metrics = training_utils.collect_metrics(metrics, self.output_names) - nested_weighted_metrics = training_utils.collect_metrics(weighted_metrics, - self.output_names) - self.metrics_updates = [] - self.stateful_metric_names = [] - self.stateful_metric_functions = [] - with K.name_scope('metrics'): - for i in range(len(self.outputs)): - if i in skip_target_indices: - continue - - y_true = self.targets[i] - y_pred = self.outputs[i] - weights = self.sample_weights[i] - output_metrics = nested_metrics[i] - output_weighted_metrics = nested_weighted_metrics[i] - output_shape = self.outputs[i].get_shape().as_list() - loss_fn = self.loss_functions[i] - - def handle_metrics(metrics, output_shape, loss_fn, weights=None): - """Invokes metric functions for the output.""" - - for metric in metrics: - metric_fn = training_utils.get_metric_function( - metric, output_shape=output_shape, loss_fn=loss_fn) - metric_name = training_utils.get_metric_name( - metric, weighted=weights is not None) - - with K.name_scope(metric_name): - weighted_metric_fn = training_utils.weighted_masked_objective( - metric_fn) - metric_result = weighted_metric_fn( - y_true, y_pred, weights=weights, mask=masks[i]) # pylint: disable=undefined-loop-variable - - metric_name = training_utils.add_metric_name(self, metric_name, i) # pylint: disable=undefined-loop-variable - self.metrics_tensors.append(metric_result) - - # Keep track of state updates created by - # stateful metrics (i.e. metrics layers). - if isinstance(metric_fn, base_layer.Layer) and metric_fn.stateful: - self.stateful_metric_names.append(metric_name) - self.stateful_metric_functions.append(metric_fn) - self.metrics_updates += metric_fn.updates - - handle_metrics(output_metrics, output_shape, loss_fn) - handle_metrics( - output_weighted_metrics, output_shape, loss_fn, weights=weights) + # Invoke metric functions for all the outputs. + self._handle_metrics( + self.outputs, + masks=masks, + targets=self.targets, + skip_target_indices=skip_target_indices, + sample_weights=self.sample_weights) # Prepare gradient updates and state updates. self.total_loss = total_loss diff --git a/tensorflow/python/keras/engine/training_eager.py b/tensorflow/python/keras/engine/training_eager.py index 965a62ffa3..1e377149b6 100644 --- a/tensorflow/python/keras/engine/training_eager.py +++ b/tensorflow/python/keras/engine/training_eager.py @@ -41,39 +41,25 @@ def _eager_loss_fn(outputs, targets, loss_fn, output_name): return loss -def _eager_metrics_fn(model, outputs, targets): +def _eager_metrics_fn(model, outputs, targets, sample_weights=None, masks=None): """Calculates the metrics for each output of the given model. Arguments: model: The model on which metrics are being calculated. outputs: The outputs of the given model. targets: The predictions or targets of the given model. + sample_weights: Optional list of sample weights for each output. + masks: Optional list of masks for each output. Returns: Returns the metric results for each output of the model. """ - metric_results = [] - if not isinstance(outputs, list): - outputs = [outputs] - - if not isinstance(targets, list): - targets = [targets] - - for i in range(len(model.outputs)): - output_metrics = model.nested_metrics[i] - for nested_output_metric in output_metrics: - metric_fn = training_utils.get_metric_function( - nested_output_metric, backend.int_shape(model.outputs[i]), - model.loss_functions[i]) - # weighted metrics are not supported in eager mode - metric_name = training_utils.get_metric_name( - nested_output_metric, weighted=False) - - with backend.name_scope(metric_name): - metric_result = metric_fn(targets[i], outputs[i]) - metric_results.append(backend.mean(metric_result)) - - return metric_results + outputs = generic_utils.to_list(outputs) + targets = generic_utils.to_list(targets) + # TODO(psv): Consider supporting skip target indices in eager mode? + metric_results = model._handle_metrics( + outputs, targets=targets, sample_weights=sample_weights, masks=masks) + return [backend.mean(t) for t in metric_results] def _model_loss(model, inputs, targets, sample_weights=None, training=False): @@ -87,9 +73,10 @@ def _model_loss(model, inputs, targets, sample_weights=None, training=False): training: Whether the model should be run in inference or training mode. Returns: - Returns the model output, total loss and loss value calculated using the - specified loss function. The total loss includes regularization losses and - applies masking and sample weighting to the loss value. + Returns the model output, total loss, loss value calculated using the + specified loss function and masks for each output. The total loss includes + regularization losses and applies masking and sample weighting + to the loss value. """ total_loss = 0 kwargs = {} @@ -146,7 +133,7 @@ def _model_loss(model, inputs, targets, sample_weights=None, training=False): if custom_losses: total_loss += sum(custom_losses) - return outs, total_loss, loss_metrics + return outs, total_loss, loss_metrics, masks def iterator_fit_loop(model, @@ -235,6 +222,15 @@ def iterator_fit_loop(model, if val is not None else None for val in sample_weights ] + # Set stateful_metrics in callbacks. We do not do this before the + # `steps_per_epoch` loop because model will be compiled only in the first + # iteration of this loop in the deferred build scenario. + if step_index == 0: + for cbk in callbacks: + if (isinstance(cbk, cbks.BaseLogger) or + isinstance(cbk, cbks.ProgbarLogger)): + cbk.stateful_metrics = model.stateful_metric_names + if step_index == 0 and not callbacks.params['metrics']: callback_metrics = copy.copy(model.metrics_names) if do_validation: @@ -250,16 +246,16 @@ def iterator_fit_loop(model, }) # Train model. - outs, loss, loss_metrics = _process_single_batch( + outs, loss, loss_metrics, masks = _process_single_batch( model, x, y, sample_weights=sample_weights, training=True) - if not isinstance(outs, list): - outs = [outs] + outs = generic_utils.to_list(outs) # Calculate metrics. for l, o in zip(model.metrics_names, outs): batch_logs[l] = o # Required for eager execution - metrics_results = _eager_metrics_fn(model, outs, y) + metrics_results = _eager_metrics_fn( + model, outs, y, sample_weights=sample_weights, masks=masks) batch_logs['loss'] = tensor_util.constant_value(backend.mean(loss)) for k, v in zip(model.metrics_names, @@ -346,10 +342,25 @@ def iterator_test_loop(model, inputs, steps, verbose=0): if val is not None else None for val in sample_weights ] + if step_index == 0: + # Get stateful metrics indices. We do not do this before the `steps` loop + # because model will be compiled only in the first iteration of this loop + # in the deferred build scenario. + if hasattr(model, 'metrics'): + for m in model.stateful_metric_functions: + m.reset_states() + stateful_metric_indices = [ + i for i, name in enumerate(model.metrics_names) + if str(name) in model.stateful_metric_names + ] + else: + stateful_metric_indices = [] + # Calculate model output, loss values. - loss_outs, loss, loss_metrics = _model_loss( + loss_outs, loss, loss_metrics, masks = _model_loss( model, x, y, sample_weights=sample_weights, training=False) - metrics_results = _eager_metrics_fn(model, loss_outs, y) + metrics_results = _eager_metrics_fn( + model, loss_outs, y, sample_weights=sample_weights, masks=masks) batch_outs = [] for _, v in zip(model.metrics_names, [backend.mean(loss)] + loss_metrics + metrics_results): @@ -368,7 +379,10 @@ def iterator_test_loop(model, inputs, steps, verbose=0): for _ in enumerate(batch_outs): outs.append(0.) for i, batch_out in enumerate(batch_outs): - outs[i] += batch_out * step_size + if i in stateful_metric_indices: + outs[i] = batch_out + else: + outs[i] += batch_out * step_size # Calculate sample size. num_samples += step_size @@ -376,7 +390,8 @@ def iterator_test_loop(model, inputs, steps, verbose=0): progbar.update(step_index + 1) for i in range(len(outs)): - outs[i] /= num_samples + if i not in stateful_metric_indices: + outs[i] /= num_samples if len(outs) == 1: return outs[0] return outs @@ -473,16 +488,20 @@ def _process_single_batch(model, set this to False. Returns: - output of the model, total loss and the loss associated with each output. + output of the model, total loss, the loss and the mask + associated with each output. Raises: ValueError: If the model has no loss to optimize. """ with backend.learning_phase_scope(1 if training else 0): with GradientTape() as tape: - outs, loss, loss_metrics = _model_loss(model, inputs, targets, - sample_weights=sample_weights, - training=training) + outs, loss, loss_metrics, masks = _model_loss( + model, + inputs, + targets, + sample_weights=sample_weights, + training=training) if loss is None: raise ValueError('The model cannot be run ' 'because it has no loss to optimize.') @@ -495,7 +514,7 @@ def _process_single_batch(model, grads = tape.gradient(loss, model._collected_trainable_weights) model.optimizer.apply_gradients(zip(grads, model._collected_trainable_weights)) - return outs, loss, loss_metrics + return outs, loss, loss_metrics, masks def train_on_batch(model, inputs, targets, sample_weights=None): @@ -526,14 +545,18 @@ def train_on_batch(model, inputs, targets, sample_weights=None): if val is not None else None for val in sample_weights ] - outs, loss, _ = _process_single_batch( + outs, loss, loss_metrics, masks = _process_single_batch( model, inputs, targets, sample_weights=sample_weights, training=True) if not isinstance(outs, list): outs = [outs] - metrics_results = _eager_metrics_fn(model, outs, targets) - if not isinstance(loss, list): - loss = [loss] - return loss + metrics_results + metrics_results = _eager_metrics_fn( + model, outs, targets, sample_weights=sample_weights, masks=masks) + loss = generic_utils.to_list(loss) + + return [ + tensor_util.constant_value(v) + for v in loss + loss_metrics + metrics_results + ] def test_on_batch(model, inputs, targets, sample_weights=None): @@ -563,14 +586,18 @@ def test_on_batch(model, inputs, targets, sample_weights=None): ops.convert_to_tensor(val, dtype=backend.floatx()) if val is not None else None for val in sample_weights ] - outs, loss, loss_metrics = _model_loss( + outs, loss, loss_metrics, masks = _model_loss( model, inputs, targets, sample_weights=sample_weights, training=False) if not isinstance(outs, list): outs = [outs] - metrics_results = _eager_metrics_fn(model, outs, targets) - if not isinstance(loss, list): - loss = [loss] - return loss + loss_metrics + metrics_results + metrics_results = _eager_metrics_fn( + model, outs, targets, sample_weights=sample_weights, masks=masks) + loss = generic_utils.to_list(loss) + + return [ + tensor_util.constant_value(v) + for v in loss + loss_metrics + metrics_results + ] def fit_loop(model, @@ -648,6 +675,10 @@ def fit_loop(model, callbacks.on_train_begin() for epoch in range(initial_epoch, epochs): + if model._is_compiled: # Model may not be compiled the first time. + # Reset stateful metrics + for m in model.stateful_metric_functions: + m.reset_states() callbacks.on_epoch_begin(epoch) epoch_logs = {} iterator_fit_loop( @@ -706,10 +737,7 @@ def test_loop(model, inputs, targets, return iterator_test_loop(model, inputs, steps, verbose=verbose) -def predict_loop(model, inputs, - batch_size=32, - verbose=0, - steps=None): +def predict_loop(model, inputs, batch_size=32, verbose=0, steps=None): """Predict function for eager execution. Arguments: diff --git a/tensorflow/python/keras/engine/training_eager_test.py b/tensorflow/python/keras/engine/training_eager_test.py index 56f321732f..db7ccb181f 100644 --- a/tensorflow/python/keras/engine/training_eager_test.py +++ b/tensorflow/python/keras/engine/training_eager_test.py @@ -24,6 +24,7 @@ from tensorflow.python.data.ops import dataset_ops from tensorflow.python import keras from tensorflow.python.framework import ops from tensorflow.python.framework import test_util as tf_test_util +from tensorflow.python.keras import metrics as metrics_module from tensorflow.python.platform import test from tensorflow.python.training.rmsprop import RMSPropOptimizer @@ -44,7 +45,7 @@ class TrainingTest(test.TestCase): optimizer = RMSPropOptimizer(learning_rate=0.001) loss = 'mse' loss_weights = [1., 0.5] - metrics = ['mae'] + metrics = ['mae', metrics_module.CategoricalAccuracy()] model.compile( optimizer, loss, @@ -109,7 +110,7 @@ class TrainingTest(test.TestCase): optimizer = RMSPropOptimizer(learning_rate=0.001) loss = 'mse' - metrics = ['mae'] + metrics = ['mae', metrics_module.CategoricalAccuracy()] model.compile(optimizer, loss, metrics=metrics) inputs = keras.backend.zeros(shape=(10, 3)) @@ -128,7 +129,9 @@ class TrainingTest(test.TestCase): model = keras.Sequential() model.add(keras.layers.Dense(4, input_shape=(3,))) optimizer = RMSPropOptimizer(learning_rate=0.001) - model.compile(optimizer, 'mse', metrics=['mae']) + model.compile( + optimizer, 'mse', metrics=['mae', + metrics_module.CategoricalAccuracy()]) x = np.random.random((10, 3)) y = np.random.random((10, 4)) diff --git a/tensorflow/python/keras/engine/training_generator.py b/tensorflow/python/keras/engine/training_generator.py index a7fd440e86..413c1f4fba 100644 --- a/tensorflow/python/keras/engine/training_generator.py +++ b/tensorflow/python/keras/engine/training_generator.py @@ -233,7 +233,6 @@ def evaluate_generator(model, use_multiprocessing=False, verbose=0): """See docstring for `Model.evaluate_generator`.""" - stateful_metric_indices = [] if hasattr(model, 'metrics'): for m in model.stateful_metric_functions: m.reset_states() @@ -331,7 +330,7 @@ def evaluate_generator(model, averages.append( np.average([out[i] for out in all_outs], weights=batch_sizes)) else: - averages.append(float(all_outs[-1][i])) + averages.append(np.float64(all_outs[-1][i])) return averages diff --git a/tensorflow/python/keras/engine/training_test.py b/tensorflow/python/keras/engine/training_test.py index 0e10eba4c6..15e7d725de 100644 --- a/tensorflow/python/keras/engine/training_test.py +++ b/tensorflow/python/keras/engine/training_test.py @@ -30,6 +30,7 @@ from tensorflow.python.eager import context from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_shape from tensorflow.python.framework import test_util as tf_test_util +from tensorflow.python.keras import metrics as metrics_module from tensorflow.python.keras import testing_utils from tensorflow.python.keras.engine.training_utils import weighted_masked_objective from tensorflow.python.keras.utils.generic_utils import slice_arrays @@ -62,8 +63,11 @@ class TrainingTest(test.TestCase): optimizer = RMSPropOptimizer(learning_rate=0.001) loss = 'mse' loss_weights = [1., 0.5] - metrics = ['mae'] - model.compile(optimizer, loss, metrics=metrics, loss_weights=loss_weights) + model.compile( + optimizer, + loss, + metrics=[metrics_module.CategoricalAccuracy(), 'mae'], + loss_weights=loss_weights) input_a_np = np.random.random((10, 3)) input_b_np = np.random.random((10, 3)) @@ -178,8 +182,10 @@ class TrainingTest(test.TestCase): # Test with lists for loss, metrics loss = ['mae', 'mse'] - metrics = ['acc', 'mae'] - model.compile(optimizer, loss, metrics=metrics) + model.compile( + optimizer, + loss, + metrics=[metrics_module.CategoricalAccuracy(), 'mae']) model.fit( [input_a_np, input_b_np], [output_d_np, output_e_np], epochs=1, @@ -189,7 +195,10 @@ class TrainingTest(test.TestCase): # Test with dictionaries for loss, metrics, loss weights loss = {'dense': 'mse', 'dropout': 'mae'} loss_weights = {'dense': 1., 'dropout': 0.5} - metrics = {'dense': 'mse', 'dropout': 'mae'} + metrics = { + 'dense': 'mse', + 'dropout': metrics_module.CategoricalAccuracy() + } model.compile(optimizer, loss, metrics=metrics, loss_weights=loss_weights) model.fit( [input_a_np, input_b_np], [output_d_np, output_e_np], @@ -258,11 +267,10 @@ class TrainingTest(test.TestCase): optimizer = RMSPropOptimizer(learning_rate=0.001) loss = 'mse' loss_weights = [1., 0.5] - metrics = ['mae'] model.compile( optimizer, loss, - metrics=metrics, + metrics=['mae', metrics_module.CategoricalAccuracy()], loss_weights=loss_weights, sample_weight_mode=None) @@ -277,20 +285,20 @@ class TrainingTest(test.TestCase): [input_a_np, input_b_np], [output_d_np, output_e_np], batch_size=5, verbose=0) - self.assertEqual(len(out), 5) + self.assertEqual(len(out), 7) out = model.evaluate( [input_a_np, input_b_np], [output_d_np, output_e_np], batch_size=5, verbose=1) - self.assertEqual(len(out), 5) + self.assertEqual(len(out), 7) out = model.evaluate( [input_a_np, input_b_np], [output_d_np, output_e_np], batch_size=5, verbose=2) - self.assertEqual(len(out), 5) + self.assertEqual(len(out), 7) out = model.test_on_batch([input_a_np, input_b_np], [output_d_np, output_e_np]) - self.assertEqual(len(out), 5) + self.assertEqual(len(out), 7) # Test evaluate with dictionary inputs model.evaluate( @@ -326,7 +334,7 @@ class TrainingTest(test.TestCase): self.assertEqual(len(out), 2) @tf_test_util.run_in_graph_and_eager_modes - def test_invalid_loss_or_metrics(self): + def test_invalid_loss(self): num_classes = 5 train_samples = 1000 test_samples = 1000 @@ -350,10 +358,6 @@ class TrainingTest(test.TestCase): with self.assertRaises(ValueError): model.fit(x_train, np.concatenate([y_train, y_train], axis=-1)) - with self.assertRaises(TypeError): - model.compile( - optimizer, loss='categorical_crossentropy', metrics=set(0)) - if not context.executing_eagerly(): # TODO(psv): Investigate these use cases in eager mode. with self.assertRaises(ValueError): @@ -379,7 +383,11 @@ class TrainingTest(test.TestCase): out2 = keras.layers.Dense(4, name='dense_1')(in2) model = keras.Model([in1, in2], [out1, out2]) model.predict(test_inputs, batch_size=2) - model.compile('rmsprop', 'mse') + optimizer = RMSPropOptimizer(learning_rate=0.001) + model.compile( + optimizer, + 'mse', + metrics=['mae', metrics_module.CategoricalAccuracy()]) model.fit(test_inputs, test_outputs, epochs=1, batch_size=2, validation_split=0.5) model.evaluate(test_inputs, test_outputs, batch_size=2) @@ -422,22 +430,24 @@ class TrainingTest(test.TestCase): x2 = model.predict(val_a) self.assertAllClose(x1, x2, atol=1e-7) + @tf_test_util.run_in_graph_and_eager_modes def test_compile_warning_for_loss_missing_output(self): with self.test_session(): inp = keras.layers.Input(shape=(16,), name='input_a') out_1 = keras.layers.Dense(8, name='dense_1')(inp) out_2 = keras.layers.Dense(3, activation='softmax', name='dense_2')(out_1) model = keras.models.Model(inputs=[inp], outputs=[out_1, out_2]) + optimizer = RMSPropOptimizer(learning_rate=0.001) with test.mock.patch.object(logging, 'warning') as mock_log: model.compile( + optimizer, loss={ 'dense_2': 'categorical_crossentropy', }, - optimizer='rmsprop', metrics={ 'dense_2': 'categorical_accuracy', - 'dense_1': 'categorical_accuracy', + 'dense_1': metrics_module.CategoricalAccuracy(), }) msg = ('Output "dense_1" missing from loss dictionary. We assume this ' 'was done on purpose. The fit and evaluate APIs will not be ' @@ -466,6 +476,8 @@ class LossWeightingTest(test.TestCase): model.add(keras.layers.Activation('softmax')) model.compile( loss='categorical_crossentropy', + metrics=['acc'], + weighted_metrics=['mae'], optimizer=RMSPropOptimizer(learning_rate=learning_rate)) np.random.seed(1337) @@ -516,7 +528,7 @@ class LossWeightingTest(test.TestCase): ref_score = model.evaluate(x_test, y_test, verbose=0) score = model.evaluate( x_test[test_ids, :], y_test[test_ids, :], verbose=0) - self.assertLess(score, ref_score) + self.assertLess(score[0], ref_score[0]) @tf_test_util.run_in_graph_and_eager_modes def test_sample_weights(self): @@ -537,6 +549,8 @@ class LossWeightingTest(test.TestCase): model.add(keras.layers.Activation('softmax')) model.compile( RMSPropOptimizer(learning_rate=learning_rate), + metrics=['acc'], + weighted_metrics=['mae'], loss='categorical_crossentropy') np.random.seed(43) @@ -583,7 +597,7 @@ class LossWeightingTest(test.TestCase): if not context.executing_eagerly(): score = model.evaluate( x_test[test_ids, :], y_test[test_ids, :], verbose=0) - self.assertLess(score, ref_score) + self.assertLess(score[0], ref_score[0]) @tf_test_util.run_in_graph_and_eager_modes def test_temporal_sample_weights(self): @@ -641,6 +655,8 @@ class LossWeightingTest(test.TestCase): model.compile( RMSPropOptimizer(learning_rate=learning_rate), loss='binary_crossentropy', + metrics=['acc'], + weighted_metrics=['mae'], sample_weight_mode='temporal') model.fit( @@ -671,7 +687,7 @@ class LossWeightingTest(test.TestCase): if not context.executing_eagerly(): score = model.evaluate( temporal_x_test[test_ids], temporal_y_test[test_ids], verbose=0) - self.assertLess(score, ref_score) + self.assertLess(score[0], ref_score[0]) @tf_test_util.run_in_graph_and_eager_modes def test_class_weight_invalid_use_case(self): @@ -1066,7 +1082,10 @@ class TestGeneratorMethods(test.TestCase): x = keras.Input((2,)) y = keras.layers.Dense(1)(x) fn_model = keras.models.Model(x, y) - fn_model.compile(loss='mse', optimizer='sgd') + fn_model.compile( + loss='mse', + optimizer='sgd', + metrics=['mae', metrics_module.CategoricalAccuracy()]) seq_model = keras.models.Sequential() seq_model.add(keras.layers.Dense(1, input_shape=(2,))) @@ -1148,7 +1167,10 @@ class TestGeneratorMethods(test.TestCase): with self.test_session(): model = keras.models.Sequential() model.add(keras.layers.Dense(1, input_shape=(2,))) - model.compile(loss='mse', optimizer='sgd') + model.compile( + loss='mse', + optimizer='sgd', + metrics=['mae', metrics_module.CategoricalAccuracy()]) model.fit_generator(custom_generator(), steps_per_epoch=5, @@ -1300,10 +1322,12 @@ class TestTrainingWithDataTensors(test.TestCase): y = keras.layers.Dense(4, name='dense')(x) model = keras.Model(x, y) - optimizer = 'rmsprop' + optimizer = RMSPropOptimizer(learning_rate=0.001) loss = 'mse' - metrics = ['mae'] - model.compile(optimizer, loss, metrics=metrics) + model.compile( + optimizer, + loss, + metrics=['mae', metrics_module.CategoricalAccuracy()]) inputs = keras.backend.zeros(shape=(10, 3)) targets = keras.backend.zeros(shape=(10, 4)) @@ -1347,8 +1371,11 @@ class TestTrainingWithDataTensors(test.TestCase): optimizer = 'rmsprop' loss = 'mse' loss_weights = [1., 0.5] - metrics = ['mae'] - model.compile(optimizer, loss, metrics=metrics, loss_weights=loss_weights) + model.compile( + optimizer, + loss, + metrics=['mae', metrics_module.CategoricalAccuracy()], + loss_weights=loss_weights) input_a_tf = keras.backend.zeros(shape=(10, 3)) input_b_tf = keras.backend.zeros(shape=(10, 3)) @@ -1786,8 +1813,11 @@ class TestTrainingWithDataTensors(test.TestCase): model.train_on_batch(input_val, None) # test with sample weights - model.compile(optimizer='rmsprop', loss='mse', - target_tensors=[target_a, target_b]) + model.compile( + optimizer='rmsprop', + loss='mse', + metrics=['mae', metrics_module.CategoricalAccuracy()], + target_tensors=[target_a, target_b]) model.train_on_batch(input_val, None, sample_weight={'dense_a': np.random.random((10,))}) @@ -1851,30 +1881,6 @@ class TestTrainingWithDataTensors(test.TestCase): model.train_on_batch([input_a_np, input_b_np], [output_a_np, output_b_np]) - @tf_test_util.run_in_graph_and_eager_modes - def test_metric_names_are_identical_in_graph_and_eager(self): - a = keras.layers.Input(shape=(3,), name='input_a') - b = keras.layers.Input(shape=(3,), name='input_b') - - dense = keras.layers.Dense(4, name='dense') - c = dense(a) - d = dense(b) - e = keras.layers.Dropout(0.5, name='dropout')(c) - - model = keras.models.Model([a, b], [d, e]) - - optimizer = RMSPropOptimizer(learning_rate=0.001) - loss = 'mse' - loss_weights = [1., 0.5] - metrics = ['mae', 'acc'] - model.compile(optimizer, loss, metrics=metrics, loss_weights=loss_weights) - reference_metric_names = ['loss', 'dense_loss', 'dropout_loss', - 'dense_mean_absolute_error', - 'dense_acc', - 'dropout_mean_absolute_error', - 'dropout_acc'] - self.assertEqual(reference_metric_names, model.metrics_names) - class TestTrainingWithDatasetIterators(test.TestCase): @@ -1887,7 +1893,7 @@ class TestTrainingWithDatasetIterators(test.TestCase): optimizer = RMSPropOptimizer(learning_rate=0.001) loss = 'mse' - metrics = ['mae'] + metrics = ['mae', metrics_module.CategoricalAccuracy()] model.compile(optimizer, loss, metrics=metrics) inputs = np.zeros((10, 3)) @@ -1944,6 +1950,7 @@ class TestTrainingWithDatasetIterators(test.TestCase): 'you should specify the `steps` argument'): model.predict(iterator, verbose=0) + @tf_test_util.run_in_graph_and_eager_modes def test_get_next_op_created_once(self): with self.test_session(): x = keras.layers.Input(shape=(3,), name='input') @@ -1996,6 +2003,7 @@ class TestTrainingWithDatasetIterators(test.TestCase): class TestTrainingWithDataset(test.TestCase): + @tf_test_util.run_in_graph_and_eager_modes def test_calling_model_on_same_dataset(self): with self.test_session(): x = keras.layers.Input(shape=(3,), name='input') @@ -2031,7 +2039,7 @@ class TestTrainingWithDataset(test.TestCase): optimizer = RMSPropOptimizer(learning_rate=0.001) loss = 'mse' - metrics = ['mae'] + metrics = ['mae', metrics_module.CategoricalAccuracy()] model.compile(optimizer, loss, metrics=metrics) inputs = np.zeros((10, 3)) @@ -2121,6 +2129,28 @@ class TestTrainingWithDataset(test.TestCase): class TestTrainingWithMetrics(test.TestCase): """Training tests related to metrics.""" + @tf_test_util.run_in_graph_and_eager_modes + def test_metrics_names(self): + a = keras.layers.Input(shape=(3,), name='input_a') + b = keras.layers.Input(shape=(3,), name='input_b') + + dense = keras.layers.Dense(4, name='dense') + c = dense(a) + d = dense(b) + e = keras.layers.Dropout(0.5, name='dropout')(c) + + model = keras.models.Model([a, b], [d, e]) + + optimizer = RMSPropOptimizer(learning_rate=0.001) + metrics = ['mse', metrics_module.BinaryAccuracy()] + model.compile(optimizer, loss='mae', metrics=metrics) + reference_metric_names = [ + 'loss', 'dense_loss', 'dropout_loss', 'dense_mean_squared_error', + 'dense_binary_accuracy', 'dropout_mean_squared_error', + 'dropout_binary_accuracy' + ] + self.assertEqual(reference_metric_names, model.metrics_names) + @tf_test_util.run_in_graph_and_eager_modes def test_metrics_correctness(self): with self.test_session(): @@ -2133,7 +2163,7 @@ class TestTrainingWithMetrics(test.TestCase): 1, activation='sigmoid', kernel_initializer='ones')) model.compile( loss='mae', - metrics=['accuracy'], + metrics=['accuracy', metrics_module.BinaryAccuracy()], optimizer=RMSPropOptimizer(learning_rate=0.001)) # verify correctness of stateful and stateless metrics. @@ -2141,41 +2171,48 @@ class TestTrainingWithMetrics(test.TestCase): y = np.ones((100, 1)) outs = model.evaluate(x, y) self.assertEqual(outs[1], 1.) + self.assertEqual(outs[2], 1.) y = np.zeros((100, 1)) outs = model.evaluate(x, y) self.assertEqual(outs[1], 0.) + self.assertEqual(outs[2], 0.) @tf_test_util.run_in_graph_and_eager_modes def test_metrics_correctness_with_iterator(self): - model = keras.Sequential() - model.add( - keras.layers.Dense( - 8, activation='relu', input_dim=4, kernel_initializer='ones')) - model.add( - keras.layers.Dense(1, activation='sigmoid', kernel_initializer='ones')) - model.compile( - loss='binary_crossentropy', - metrics=['accuracy'], - optimizer=RMSPropOptimizer(learning_rate=0.001)) - - np.random.seed(123) - x = np.random.randint(10, size=(100, 4)).astype(np.float32) - y = np.random.randint(2, size=(100, 1)).astype(np.float32) - dataset = dataset_ops.Dataset.from_tensor_slices((x, y)) - dataset = dataset.batch(10) - iterator = dataset.make_one_shot_iterator() - outs = model.evaluate(iterator, steps=10) - self.assertEqual(np.around(outs[1], decimals=1), 0.5) - - y = np.zeros((100, 1), dtype=np.float32) - dataset = dataset_ops.Dataset.from_tensor_slices((x, y)) - dataset = dataset.repeat(100) - dataset = dataset.batch(10) - iterator = dataset.make_one_shot_iterator() - outs = model.evaluate(iterator, steps=10) - self.assertEqual(outs[1], 0.) + with self.test_session(): + model = keras.Sequential() + model.add( + keras.layers.Dense( + 8, activation='relu', input_dim=4, kernel_initializer='ones')) + model.add( + keras.layers.Dense( + 1, activation='sigmoid', kernel_initializer='ones')) + model.compile( + loss='binary_crossentropy', + metrics=['accuracy', metrics_module.BinaryAccuracy()], + optimizer=RMSPropOptimizer(learning_rate=0.001)) + + np.random.seed(123) + x = np.random.randint(10, size=(100, 4)).astype(np.float32) + y = np.random.randint(2, size=(100, 1)).astype(np.float32) + dataset = dataset_ops.Dataset.from_tensor_slices((x, y)) + dataset = dataset.batch(10) + iterator = dataset.make_one_shot_iterator() + outs = model.evaluate(iterator, steps=10) + self.assertEqual(np.around(outs[1], decimals=1), 0.5) + self.assertEqual(np.around(outs[2], decimals=1), 0.5) + y = np.zeros((100, 1), dtype=np.float32) + dataset = dataset_ops.Dataset.from_tensor_slices((x, y)) + dataset = dataset.repeat(100) + dataset = dataset.batch(10) + iterator = dataset.make_one_shot_iterator() + outs = model.evaluate(iterator, steps=10) + self.assertEqual(outs[1], 0.) + self.assertEqual(outs[2], 0.) + + @tf_test_util.run_in_graph_and_eager_modes def test_metrics_correctness_with_weighted_metrics(self): with self.test_session(): np.random.seed(1337) @@ -2189,19 +2226,87 @@ class TestTrainingWithMetrics(test.TestCase): RMSPropOptimizer(learning_rate=0.001), loss='mse', sample_weight_mode='temporal', - weighted_metrics=['accuracy']) + weighted_metrics=['accuracy', + metrics_module.BinaryAccuracy()]) y = np.array([[[1.], [1.]], [[1.], [1.]]]) outs = model.evaluate(x, y) - self.assertEqual(outs, [0.5, 0.5]) + self.assertEqual(outs, [0.5, 0.5, 0.5]) w = np.array([[0., 0.], [0., 0.]]) outs = model.evaluate(x, y, sample_weight=w) - self.assertEqual(outs, [0., 0.]) + self.assertEqual(outs, [0., 0., 0.]) w = np.array([[3., 4.], [1., 2.]]) outs = model.evaluate(x, y, sample_weight=w) - self.assertArrayNear(outs, [0.3, 0.7], .001) + self.assertArrayNear(outs, [0.3, 0.7, 0.7], .001) + + @tf_test_util.run_in_graph_and_eager_modes + def test_metric_state_reset_between_fit_and_evaluate(self): + with self.test_session(): + model = keras.Sequential() + model.add(keras.layers.Dense(3, activation='relu', input_dim=4)) + model.add(keras.layers.Dense(1, activation='sigmoid')) + acc_obj = metrics_module.BinaryAccuracy() + model.compile( + loss='mae', + metrics=[acc_obj], + optimizer=RMSPropOptimizer(learning_rate=0.001)) + + x_train = np.random.random((100, 4)) + y_train = np.random.random((100, 1)) + model.fit(x_train, y_train, batch_size=5, epochs=2) + self.assertEqual(self.evaluate(acc_obj.count), 100) + + x_test = np.random.random((10, 4)) + y_test = np.random.random((10, 1)) + model.evaluate(x_test, y_test, batch_size=5) + self.assertEqual(self.evaluate(acc_obj.count), 10) + + @tf_test_util.run_in_graph_and_eager_modes + def test_invalid_metrics(self): + num_classes = 5 + input_dim = 5 + + with self.test_session(): + model = keras.models.Sequential() + model.add( + keras.layers.Dense(10, activation='relu', input_shape=(input_dim,))) + model.add(keras.layers.Dense(num_classes, activation='softmax')) + + with self.assertRaisesRegexp( + TypeError, 'Type of `metrics` argument not understood. ' + 'Expected a list or dictionary, found: '): + model.compile( + RMSPropOptimizer(learning_rate=0.001), + loss='categorical_crossentropy', + metrics=metrics_module.CategoricalAccuracy()) + + @tf_test_util.run_in_graph_and_eager_modes + def test_metrics_masking(self): + with self.test_session(): + np.random.seed(1337) + model = keras.models.Sequential() + model.add(keras.layers.Masking(mask_value=0, input_shape=(2, 1))) + model.add( + keras.layers.TimeDistributed( + keras.layers.Dense(1, kernel_initializer='ones'))) + model.compile( + RMSPropOptimizer(learning_rate=0.001), + loss='mse', + weighted_metrics=['accuracy', + metrics_module.BinaryAccuracy()]) + + # verify that masking is applied for stateless and stateful metrics. + x = np.array([[[1], [1]], [[1], [1]], [[0], [0]]]) + y = np.array([[[1], [1]], [[0], [1]], [[1], [1]]]) + scores = model.train_on_batch(x, y) + self.assertArrayNear(scores, [0.25, 0.75, 0.75], 0.1) + + # verify that masking is combined with sample weights. + w = np.array([3, 2, 4]) + scores = model.train_on_batch(x, y, sample_weight=w) + self.assertArrayNear(scores, [0.2, 0.8, 0.8], 0.1) if __name__ == '__main__': diff --git a/tensorflow/python/keras/engine/training_utils.py b/tensorflow/python/keras/engine/training_utils.py index 38b64e69ec..f94697c913 100644 --- a/tensorflow/python/keras/engine/training_utils.py +++ b/tensorflow/python/keras/engine/training_utils.py @@ -570,13 +570,24 @@ def weighted_masked_objective(fn): # score_array has ndim >= 2 score_array = fn(y_true, y_pred) if mask is not None: - # Cast the mask to floatX to avoid float64 upcasting in theano - mask = math_ops.cast(mask, K.floatx()) - # mask should have the same shape as score_array - score_array *= mask - # the loss per batch should be proportional - # to the number of unmasked samples. - score_array /= K.mean(mask) + mask = math_ops.cast(mask, y_pred.dtype) + # Update weights with mask. + if weights is None: + weights = mask + else: + # Update shape of weights if possible before adding mask. + # Update dimensions of weights to match with mask if possible. + mask, _, weights = metrics_module.squeeze_or_expand_dimensions( + mask, None, weights) + try: + # Broadcast weights if possible. + weights = weights_broadcast_ops.broadcast_weights(weights, mask) + weights *= mask + except ValueError: + score_array *= mask + score_array /= K.mean(mask) + # TODO(psv): Handle case when mask and weight shapes are not + # compatible. # Apply sample weighting. if weights is not None: @@ -709,43 +720,6 @@ def has_tensors(ls): return tensor_util.is_tensor(ls) -def populate_metric_names(model): - for i in range(len(model.outputs)): - metrics = model.nested_metrics[i] - for metric in metrics: - base_metric_name = get_metric_name(metric) - add_metric_name(model, base_metric_name, i) - - -def get_metric_name(metric, weighted=False): - """Returns the metric name corresponding to the given metric input. - - Arguments: - metric: Metric function name or reference. - weighted: Boolean indicating if the given metric is weighted. - - Returns: - a metric name. - """ - metric_name_prefix = 'weighted_' if weighted else '' - if metric in ('accuracy', 'acc', 'crossentropy', 'ce'): - if metric in ('accuracy', 'acc'): - suffix = 'acc' - elif metric in ('crossentropy', 'ce'): - suffix = 'ce' - metric_name = metric_name_prefix + suffix - else: - metric_fn = metrics_module.get(metric) - # Get metric name as string - if hasattr(metric_fn, 'name'): - metric_name = metric_fn.name - else: - metric_name = metric_fn.__name__ - metric_name = metric_name_prefix + metric_name - - return metric_name - - def get_metric_function(metric, output_shape=None, loss_fn=None): """Returns the metric function corresponding to the given metric input. @@ -776,33 +750,6 @@ def get_metric_function(metric, output_shape=None, loss_fn=None): return metrics_module.get(metric) -def add_metric_name(model, metric_name, index): - """Makes the metric name unique and adds it to the model's metric name list. - - If there are multiple outputs for which the metrics are calculated, the - metric names have to be made unique by appending an integer. - - Arguments: - model: Model to which we are adding metric names. - metric_name: Metric name that corresponds to the metric specified by the - user. For example: 'acc' - index: The index of the model output for which the metric name is being - added. - - Returns: - string, name of the model's unique metric name - """ - if len(model.output_names) > 1: - metric_name = '%s_%s' % (model.output_names[index], metric_name) - j = 1 - base_metric_name = metric_name - while metric_name in model.metrics_names: - metric_name = '%s_%d' % (base_metric_name, j) - j += 1 - model.metrics_names.append(metric_name) - return metric_name - - def validate_iterator_input(x, y, sample_weight, validation_split=None): """Validates user input arguments when a dataset iterator is passed. diff --git a/tensorflow/python/keras/metrics.py b/tensorflow/python/keras/metrics.py index b18f12612a..2dde9ee41f 100644 --- a/tensorflow/python/keras/metrics.py +++ b/tensorflow/python/keras/metrics.py @@ -68,25 +68,19 @@ def check_is_tensor_or_operation(x, name): def update_state_wrapper(update_state_fn): - """Decorator to wrap metric `update_state()` with `defun()`, `add_update()`. + """Decorator to wrap metric `update_state()` with `add_update()`. Args: update_state_fn: function that accumulates metric statistics. Returns: - If eager execution is enabled, returns None. - If graph execution is enabled, returns an update op. This op should be - executed to update the metric state with the given inputs. + Decorated function that wraps `update_state_fn()` with `add_update()`. """ def decorated(metric_obj, *args, **kwargs): - """Decorated function with `defun()` and `add_update()`.""" + """Decorated function with `add_update()`.""" - # Converting update_state_fn() into a graph function, so that - # we can return a single op that performs all of the variable updates. - # Assigning to a different method name to avoid reference cycle. - defuned_update_state_fn = function.defun(update_state_fn) - update_op = defuned_update_state_fn(*args, **kwargs) + update_op = update_state_fn(*args, **kwargs) if update_op is not None: # update_op will be None in eager execution. metric_obj.add_update(update_op, inputs=True) check_is_tensor_or_operation( @@ -111,7 +105,8 @@ def result_wrapper(result_fn): result_fn: function that computes the metric result. Returns: - The metric result tensor. + Decorated function that wraps `result_fn()` in distribution strategy + `merge_call()`. """ def decorated(metric_obj, *args): @@ -255,6 +250,28 @@ class Metric(Layer): print('Final result: ', sess.run(m.result())) ``` + Usage with tf.keras API: + + ```python + model = tf.keras.Sequential() + model.add(tf.keras.layers.Dense(64, activation='relu')) + model.add(tf.keras.layers.Dense(64, activation='relu')) + model.add(tf.keras.layers.Dense(10, activation='softmax')) + + model.compile(optimizer=tf.train.RMSPropOptimizer(0.01), + loss=tf.keras.losses.categorical_crossentropy, + metrics=[tf.keras.metrics.CategoricalAccuracy()]) + + data = np.random.random((1000, 32)) + labels = np.random.random((1000, 10)) + + dataset = tf.data.Dataset.from_tensor_slices((data, labels)) + dataset = dataset.batch(32) + dataset = dataset.repeat() + + model.fit(dataset, epochs=10, steps_per_epoch=30) + ``` + To be implemented by subclasses: * `__init__()`: All state variables should be created in this method by calling `self.add_weight()` like: `self.var = self.add_weight(...)` @@ -267,7 +284,7 @@ class Metric(Layer): ``` class BinaryTruePositives(Metric): - def __init__(self, name='binary-true-positives', dtype=None): + def __init__(self, name='binary_true_positives', dtype=None): super(BinaryTruePositives, self).__init__(name=name, dtype=dtype) self.true_positives = self.add_weight( 'true_positives', initializer=init_ops.zeros_initializer) @@ -299,9 +316,14 @@ class Metric(Layer): self._dtype = K.floatx() if dtype is None else dtypes.as_dtype(dtype).name def __new__(cls, *args, **kwargs): - obj = super(Metric, cls).__new__(cls, *args, **kwargs) + obj = super(Metric, cls).__new__(cls) + # TODO(psv): Fix reference cycle issue here. + + # Converting update_state_fn() into a graph function, so that + # we can return a single op that performs all of the variable updates. + defuned_update_state_fn = function.defun(obj.update_state) obj.update_state = types.MethodType( - update_state_wrapper(obj.update_state), obj) + update_state_wrapper(defuned_update_state_fn), obj) obj.result = types.MethodType(result_wrapper(obj.result), obj) return obj @@ -359,6 +381,12 @@ class Metric(Layer): """ NotImplementedError('Must be implemented in subclasses.') + @classmethod + def from_config(cls, config): + if 'trainable' in config: + config.pop('trainable') + return cls(**config) + ### For use by subclasses ### def add_weight(self, name, @@ -502,7 +530,7 @@ class BinaryAccuracy(MeanMetricWrapper): Use `sample_weight` of 0 to mask values. """ - def __init__(self, name='binary-accuracy', dtype=None, threshold=0.5): + def __init__(self, name='binary_accuracy', dtype=None, threshold=0.5): """Creates a `BinaryAccuracy` instance. Args: @@ -515,6 +543,29 @@ class BinaryAccuracy(MeanMetricWrapper): binary_accuracy, name, dtype=dtype, threshold=threshold) +class CategoricalAccuracy(MeanMetricWrapper): + """Calculates how often predictions matches labels. + + This metric creates two local variables, `total` and `count` that are used to + compute the frequency with which `y_pred` matches `y_true`. This frequency is + ultimately returned as `categorical accuracy`: an idempotent operation that + simply divides `total` by `count`. + + If `sample_weight` is `None`, weights default to 1. + Use `sample_weight` of 0 to mask values. + """ + + def __init__(self, name='categorical_accuracy', dtype=None): + """Creates a `CategoricalAccuracy` instance. + + Args: + name: (Optional) string name of the metric instance. + dtype: (Optional) data type of the metric result. + """ + super(CategoricalAccuracy, self).__init__( + categorical_accuracy, name, dtype=dtype) + + @tf_export('keras.metrics.binary_accuracy') def binary_accuracy(y_true, y_pred, threshold=0.5): threshold = math_ops.cast(threshold, y_pred.dtype) @@ -578,8 +629,7 @@ def deserialize(config, custom_objects=None): @tf_export('keras.metrics.get') def get(identifier): if isinstance(identifier, dict): - config = {'class_name': str(identifier), 'config': {}} - return deserialize(config) + return deserialize(identifier) elif isinstance(identifier, six.string_types): return deserialize(str(identifier)) elif callable(identifier): diff --git a/tensorflow/python/keras/metrics_test.py b/tensorflow/python/keras/metrics_test.py index 49f3ae40d9..2ac74219d4 100644 --- a/tensorflow/python/keras/metrics_test.py +++ b/tensorflow/python/keras/metrics_test.py @@ -362,6 +362,30 @@ class KerasMetricsTest(test.TestCase): result = self.evaluate(result_t) self.assertAlmostEqual(result, 0.5, 2) + @test_util.run_in_graph_and_eager_modes + def test_categorical_accuracy(self): + acc_obj = metrics.CategoricalAccuracy(name='my acc') + + # check config + self.assertEqual(acc_obj.name, 'my acc') + self.assertTrue(acc_obj.stateful) + self.assertEqual(len(acc_obj.variables), 2) + self.assertEqual(acc_obj.dtype, dtypes.float32) + self.evaluate(variables.global_variables_initializer()) + + # verify that correct value is returned + update_op = acc_obj.update_state([[0, 0, 1], [0, 1, 0]], + [[0.1, 0.1, 0.8], [0.05, 0.95, 0]]) + self.evaluate(update_op) + result = self.evaluate(acc_obj.result()) + self.assertEqual(result, 1) # 2/2 + + # check with sample_weight + result_t = acc_obj([[0, 0, 1], [0, 1, 0]], + [[0.1, 0.1, 0.8], [0.05, 0, 0.95]], [[0.5], [0.2]]) + result = self.evaluate(result_t) + self.assertAlmostEqual(result, 0.93, 2) # 2.5/2.7 + @test_util.run_in_graph_and_eager_modes def test_invalid_result(self): diff --git a/tensorflow/python/keras/model_subclassing_test.py b/tensorflow/python/keras/model_subclassing_test.py index 6cbea45bd5..71c1987cee 100644 --- a/tensorflow/python/keras/model_subclassing_test.py +++ b/tensorflow/python/keras/model_subclassing_test.py @@ -425,9 +425,10 @@ class ModelSubclassingTest(test.TestCase): model = SimpleTestModel(num_classes=num_classes, use_dp=True, use_bn=True) - model.compile(loss='mse', - optimizer=RMSPropOptimizer(learning_rate=0.001), - metrics=['acc']) + model.compile( + loss='mse', + optimizer=RMSPropOptimizer(learning_rate=0.001), + metrics=['acc', keras.metrics.CategoricalAccuracy()]) x = np.ones((num_samples, input_dim)) y = np.zeros((num_samples, num_classes)) -- GitLab From 8d532ac40f4db7f5293610fd3c6e92a3f7409b76 Mon Sep 17 00:00:00 2001 From: Jiri Simsa Date: Fri, 10 Aug 2018 15:57:45 -0700 Subject: [PATCH 368/437] [tf.data] Optimization checkpointing improvements. This CL: - changes the `OptimizeDataset` checkpointing logic to checkpoint the optimized dataset (as opposed to the original dataset + the optimizations, re-running optimization every time a checkpoint is restored) - replaces `OpKernelContext` with newly introduced `SerializationContext` in the signature of `AsGraphDefInternal` to reduce the scope of the context and also simplify the logic for overriding the `FunctionLibraryDefinition` when optimizations take place PiperOrigin-RevId: 208282562 --- .../data/kernels/assert_next_dataset_op.cc | 3 +- .../contrib/data/kernels/csv_dataset_op.cc | 3 +- .../kernels/directed_interleave_dataset_op.cc | 3 +- .../data/kernels/ignore_errors_dataset_op.cc | 3 +- .../data/kernels/threadpool_dataset_op.cc | 3 +- .../contrib/data/kernels/unique_dataset_op.cc | 3 +- .../kafka/kernels/kafka_dataset_ops.cc | 3 +- .../kinesis/kernels/kinesis_dataset_ops.cc | 3 +- tensorflow/core/framework/dataset.cc | 26 +++--- tensorflow/core/framework/dataset.h | 83 +++++++++++-------- .../core/kernels/data/batch_dataset_op.cc | 3 +- .../core/kernels/data/cache_dataset_ops.cc | 6 +- .../kernels/data/concatenate_dataset_op.cc | 3 +- tensorflow/core/kernels/data/dataset_ops.cc | 6 +- .../data/dense_to_sparse_batch_dataset_op.cc | 3 +- .../data/filter_by_component_dataset_op.cc | 3 +- .../core/kernels/data/filter_dataset_op.cc | 5 +- .../core/kernels/data/flat_map_dataset_op.cc | 5 +- .../data/group_by_reducer_dataset_op.cc | 12 +-- .../data/group_by_window_dataset_op.cc | 10 ++- .../kernels/data/interleave_dataset_op.cc | 5 +- tensorflow/core/kernels/data/iterator_ops.cc | 7 +- .../kernels/data/map_and_batch_dataset_op.cc | 5 +- .../core/kernels/data/map_dataset_op.cc | 5 +- .../core/kernels/data/optimize_dataset_op.cc | 25 +++--- .../kernels/data/padded_batch_dataset_op.cc | 3 +- .../data/parallel_interleave_dataset_op.cc | 6 +- .../kernels/data/parallel_map_dataset_op.cc | 5 +- .../core/kernels/data/prefetch_dataset_op.cc | 3 +- .../core/kernels/data/random_dataset_op.cc | 3 +- .../core/kernels/data/range_dataset_op.cc | 3 +- .../core/kernels/data/reader_dataset_ops.cc | 9 +- .../core/kernels/data/repeat_dataset_op.cc | 3 +- .../core/kernels/data/scan_dataset_op.cc | 5 +- .../core/kernels/data/shuffle_dataset_op.cc | 9 +- .../core/kernels/data/skip_dataset_op.cc | 3 +- .../core/kernels/data/slide_dataset_op.cc | 3 +- .../data/sparse_tensor_slice_dataset_op.cc | 3 +- .../core/kernels/data/sql_dataset_ops.cc | 3 +- .../data/stats_aggregator_dataset_op.cc | 8 -- .../core/kernels/data/stats_dataset_ops.cc | 9 +- .../core/kernels/data/take_dataset_op.cc | 3 +- .../core/kernels/data/tensor_dataset_op.cc | 3 +- .../kernels/data/tensor_queue_dataset_op.cc | 3 +- .../kernels/data/tensor_slice_dataset_op.cc | 3 +- .../core/kernels/data/unbatch_dataset_op.cc | 3 +- .../core/kernels/data/window_dataset_op.cc | 3 +- .../core/kernels/data/zip_dataset_op.cc | 3 +- 48 files changed, 203 insertions(+), 132 deletions(-) diff --git a/tensorflow/contrib/data/kernels/assert_next_dataset_op.cc b/tensorflow/contrib/data/kernels/assert_next_dataset_op.cc index 3c9858e5e5..bff6301250 100644 --- a/tensorflow/contrib/data/kernels/assert_next_dataset_op.cc +++ b/tensorflow/contrib/data/kernels/assert_next_dataset_op.cc @@ -76,7 +76,8 @@ class AssertNextDatasetOp : public UnaryDatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); diff --git a/tensorflow/contrib/data/kernels/csv_dataset_op.cc b/tensorflow/contrib/data/kernels/csv_dataset_op.cc index f7e3ed886c..51e1b9aa65 100644 --- a/tensorflow/contrib/data/kernels/csv_dataset_op.cc +++ b/tensorflow/contrib/data/kernels/csv_dataset_op.cc @@ -168,7 +168,8 @@ class CSVDatasetOp : public DatasetOpKernel { string DebugString() const override { return "CSVDatasetOp::Dataset"; } protected: - Status AsGraphDefInternal(DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* filenames = nullptr; Node* compression_type = nullptr; diff --git a/tensorflow/contrib/data/kernels/directed_interleave_dataset_op.cc b/tensorflow/contrib/data/kernels/directed_interleave_dataset_op.cc index 62e3d0d309..b9306f611b 100644 --- a/tensorflow/contrib/data/kernels/directed_interleave_dataset_op.cc +++ b/tensorflow/contrib/data/kernels/directed_interleave_dataset_op.cc @@ -110,7 +110,8 @@ class DirectedInterleaveDatasetOp : public DatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* selector_input_node; TF_RETURN_IF_ERROR( diff --git a/tensorflow/contrib/data/kernels/ignore_errors_dataset_op.cc b/tensorflow/contrib/data/kernels/ignore_errors_dataset_op.cc index e5bf6fd951..d77beb8e10 100644 --- a/tensorflow/contrib/data/kernels/ignore_errors_dataset_op.cc +++ b/tensorflow/contrib/data/kernels/ignore_errors_dataset_op.cc @@ -62,7 +62,8 @@ class IgnoreErrorsDatasetOp : public UnaryDatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); diff --git a/tensorflow/contrib/data/kernels/threadpool_dataset_op.cc b/tensorflow/contrib/data/kernels/threadpool_dataset_op.cc index 141706f393..4dc69dc2ef 100644 --- a/tensorflow/contrib/data/kernels/threadpool_dataset_op.cc +++ b/tensorflow/contrib/data/kernels/threadpool_dataset_op.cc @@ -162,7 +162,8 @@ class ThreadPoolDatasetOp : public UnaryDatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { return errors::Unimplemented( "Cannot currently serialize the thread pool for a " diff --git a/tensorflow/contrib/data/kernels/unique_dataset_op.cc b/tensorflow/contrib/data/kernels/unique_dataset_op.cc index 406f9c57f7..f6bfc982e9 100644 --- a/tensorflow/contrib/data/kernels/unique_dataset_op.cc +++ b/tensorflow/contrib/data/kernels/unique_dataset_op.cc @@ -75,7 +75,8 @@ class UniqueDatasetOp : public UnaryDatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); diff --git a/tensorflow/contrib/kafka/kernels/kafka_dataset_ops.cc b/tensorflow/contrib/kafka/kernels/kafka_dataset_ops.cc index 588e456bd6..92ae79d3c7 100644 --- a/tensorflow/contrib/kafka/kernels/kafka_dataset_ops.cc +++ b/tensorflow/contrib/kafka/kernels/kafka_dataset_ops.cc @@ -84,7 +84,8 @@ class KafkaDatasetOp : public DatasetOpKernel { string DebugString() const override { return "KafkaDatasetOp::Dataset"; } protected: - Status AsGraphDefInternal(DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* topics = nullptr; TF_RETURN_IF_ERROR(b->AddVector(topics_, &topics)); diff --git a/tensorflow/contrib/kinesis/kernels/kinesis_dataset_ops.cc b/tensorflow/contrib/kinesis/kernels/kinesis_dataset_ops.cc index 3212279c4c..7b28bb5e4d 100644 --- a/tensorflow/contrib/kinesis/kernels/kinesis_dataset_ops.cc +++ b/tensorflow/contrib/kinesis/kernels/kinesis_dataset_ops.cc @@ -194,7 +194,8 @@ class KinesisDatasetOp : public DatasetOpKernel { string DebugString() const override { return "KinesisDatasetOp::Dataset"; } protected: - Status AsGraphDefInternal(DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* stream = nullptr; TF_RETURN_IF_ERROR(b->AddScalar(stream_, &stream)); diff --git a/tensorflow/core/framework/dataset.cc b/tensorflow/core/framework/dataset.cc index 6510f81ab7..e886ef7b8e 100644 --- a/tensorflow/core/framework/dataset.cc +++ b/tensorflow/core/framework/dataset.cc @@ -134,24 +134,22 @@ Status GraphDefBuilderWrapper::AddDataset( return Status::OK(); } -Status GraphDefBuilderWrapper::AddFunction(OpKernelContext* ctx, - const string& function_name) { +Status GraphDefBuilderWrapper::AddFunction( + const FunctionLibraryDefinition& flib_def, const string& function_name) { if (b_->HasFunction(function_name)) { - LOG(INFO) << "Function with name " << function_name << "already exists in" - << " the graph. It will not be added again."; + VLOG(1) << "Function with name " << function_name << "already exists in" + << " the graph. It will not be added again."; return Status::OK(); } - TF_RETURN_IF_ERROR(EnsureFunctionIsStateless(ctx, function_name)); - const FunctionLibraryDefinition* flib_def = - ctx->function_library()->GetFunctionLibraryDefinition(); - const FunctionDef* f_def = flib_def->Find(function_name); + TF_RETURN_IF_ERROR(EnsureFunctionIsStateless(flib_def, function_name)); + const FunctionDef* f_def = flib_def.Find(function_name); if (f_def == nullptr) { return errors::InvalidArgument("Unable to find FunctionDef for ", function_name, " in the registry."); } FunctionDefLibrary def; *def.add_function() = *f_def; - const string gradient_func = flib_def->FindGradient(function_name); + const string gradient_func = flib_def.FindGradient(function_name); if (!gradient_func.empty()) { GradientDef* g_def = def.add_gradient(); g_def->set_function_name(function_name); @@ -162,19 +160,19 @@ Status GraphDefBuilderWrapper::AddFunction(OpKernelContext* ctx, // Recursively add functions in inputs of function_name. for (const NodeDef& node_def : f_def->node_def()) { const OpRegistrationData* op_reg_data = nullptr; - TF_RETURN_IF_ERROR(flib_def->LookUp(node_def.op(), &op_reg_data)); + TF_RETURN_IF_ERROR(flib_def.LookUp(node_def.op(), &op_reg_data)); if (op_reg_data->is_function_op) { - TF_RETURN_IF_ERROR(AddFunction(ctx, op_reg_data->op_def.name())); + TF_RETURN_IF_ERROR(AddFunction(flib_def, op_reg_data->op_def.name())); } // Recursively add functions in attrs of this NodeDef. for (const auto& pair : node_def.attr()) { - TF_RETURN_IF_ERROR(AddAttrFunctions(pair.second, ctx)); + TF_RETURN_IF_ERROR(AddAttrFunctions(pair.second, flib_def)); } } // Recursively add functions in attrs of function_name. for (auto iter = f_def->attr().begin(); iter != f_def->attr().end(); iter++) { - TF_RETURN_IF_ERROR(AddAttrFunctions(iter->second, ctx)); + TF_RETURN_IF_ERROR(AddAttrFunctions(iter->second, flib_def)); } return Status::OK(); } @@ -196,7 +194,7 @@ bool GraphDefBuilderWrapper::HasAttr(const string& op_type_name, return HasAttr(op_def, attr_name); } -Status GraphDatasetBase::Serialize(OpKernelContext* ctx, +Status GraphDatasetBase::Serialize(SerializationContext* ctx, string* serialized_graph_def, string* output_node) const { GraphDefBuilder b; diff --git a/tensorflow/core/framework/dataset.h b/tensorflow/core/framework/dataset.h index 0e3d5adecd..66e836f9a6 100644 --- a/tensorflow/core/framework/dataset.h +++ b/tensorflow/core/framework/dataset.h @@ -157,7 +157,8 @@ class GraphDefBuilderWrapper { // name `function_name` is not found in the FunctionLibraryDefinition, returns // an InvalidArgumentError. If the function with name `function_name` or any // of its dependent functions are stateful, returns an InvalidArgument error. - Status AddFunction(OpKernelContext* ctx, const string& function_name); + Status AddFunction(const FunctionLibraryDefinition& flib_def, + const string& function_name); template void BuildAttrValue(const T& value, AttrValue* attr) { @@ -167,18 +168,16 @@ class GraphDefBuilderWrapper { private: void AddTensorInternal(const Tensor& val, Node** output); - Status EnsureFunctionIsStateless(OpKernelContext* ctx, + Status EnsureFunctionIsStateless(const FunctionLibraryDefinition& flib_def, const string& function_name) const { - const FunctionLibraryDefinition* lib_def = - ctx->function_library()->GetFunctionLibraryDefinition(); - const FunctionDef* function_def = lib_def->Find(function_name); + const FunctionDef* function_def = flib_def.Find(function_name); if (!function_def) { return errors::InvalidArgument("Unable to find FunctionDef for ", function_name, " in registry."); } for (const NodeDef& node_def : function_def->node_def()) { const OpDef* op_def; - TF_RETURN_IF_ERROR(lib_def->LookUpOpDef(node_def.op(), &op_def)); + TF_RETURN_IF_ERROR(flib_def.LookUpOpDef(node_def.op(), &op_def)); // TODO(b/65524810): Hack to allow functions to capture Dataset op // nodes needed for FlatMap. Currently, source datasets nodes have been // marked stateful to avoid constant folding since we do not have a @@ -220,12 +219,13 @@ class GraphDefBuilderWrapper { return false; } - Status AddAttrFunctions(const AttrValue& attr_value, OpKernelContext* ctx) { + Status AddAttrFunctions(const AttrValue& attr_value, + const FunctionLibraryDefinition& flib_def) { if (attr_value.has_func()) { - TF_RETURN_IF_ERROR(AddFunction(ctx, attr_value.func().name())); + TF_RETURN_IF_ERROR(AddFunction(flib_def, attr_value.func().name())); } else if (attr_value.has_list()) { for (const NameAttrList& name_attr_list : attr_value.list().func()) { - TF_RETURN_IF_ERROR(AddFunction(ctx, name_attr_list.name())); + TF_RETURN_IF_ERROR(AddFunction(flib_def, name_attr_list.name())); } } return Status::OK(); @@ -236,21 +236,17 @@ class GraphDefBuilderWrapper { class StatsAggregator; -// A cut-down version of OpKernelContext for running computations in -// iterators. Note that we cannot simply use OpKernelContext here -// because we might run computation in an iterator whose lifetime is -// not nested within the lifetime of a single OpKernelContext -// (e.g. asynchronous prefetching). +// A cut-down version of `OpKernelContext` for running computations in +// iterators. Note that we cannot simply use `OpKernelContext` here because we +// might run computation in an iterator whose lifetime is not nested within the +// lifetime of a single `OpKernelContext` (e.g. asynchronous prefetching). // -// TODO(mrry): We will probably need to support more of -// OpKernelContext here. For example, should allocation be handled by -// the IteratorContext? -// TODO(mrry): We're making some daring assumptions about the lifetime -// of the runner passed in here. A runner will be deleted when the original -// step ends, but all existing runners only close over session-lifetime (or -// longer-lived) state, so we can make a copy of the function. There's nothing -// in the definition of the API from which we took the runner to guarantee that -// what we are doing is safe. We should formalize the properties here. +// TODO(mrry): We're making some daring assumptions about the lifetime of the +// runner passed in here. A runner will be deleted when the original step ends, +// but all existing runners only close over session-lifetime (or longer-lived) +// state, so we can make a copy of the function. There's nothing in the +// definition of the API from which we took the runner to guarantee that what we +// are doing is safe. We should formalize the properties here. class IteratorContext { public: struct Params { @@ -318,6 +314,23 @@ class IteratorContext { Params params_; }; +// Aggregates runtime support needed for dataset and iterator serialization. +class SerializationContext { + public: + struct Params { + const FunctionLibraryDefinition* flib_def; // Not owned. + }; + + explicit SerializationContext(Params params) : params_(std::move(params)) {} + + const FunctionLibraryDefinition& flib_def() { return *params_.flib_def; } + + private: + Params params_; + + TF_DISALLOW_COPY_AND_ASSIGN(SerializationContext); +}; + // Represents the current position in a range of outputs, where the // range of outputs is typically represented by an `DatasetBase`, // defined below. @@ -357,7 +370,7 @@ class IteratorBase { virtual Status Initialize(IteratorContext* ctx) { return Status::OK(); } // Saves the state of this iterator. - virtual Status Save(OpKernelContext* ctx, IteratorStateWriter* writer) { + virtual Status Save(SerializationContext* ctx, IteratorStateWriter* writer) { return SaveInternal(writer); } @@ -427,8 +440,10 @@ class DatasetBase : public core::RefCounted { virtual string DebugString() const = 0; // Serializes the dataset and writes it to the `writer`. - virtual Status Save(OpKernelContext* ctx, IteratorStateWriter* writer) const { - return errors::Unimplemented("DatasetBase::Save"); + virtual Status Save(SerializationContext* ctx, + IteratorStateWriter* writer) const { + return errors::Unimplemented("%s does not support serialization", + DebugString()); } protected: @@ -439,13 +454,14 @@ class DatasetBase : public core::RefCounted { class DatasetGraphDefBuilder : public GraphDefBuilderWrapper { public: DatasetGraphDefBuilder(GraphDefBuilder* b) : GraphDefBuilderWrapper(b) {} - Status AddInputDataset(OpKernelContext* ctx, const DatasetBase* dataset, - Node** output) { + Status AddInputDataset(SerializationContext* ctx, + const DatasetBase* dataset, Node** output) { return dataset->AsGraphDefInternal(ctx, this, output); } }; - virtual Status AsGraphDefInternal(OpKernelContext* ctx, + // TODO(jsimsa): Consolidate overloading into a single method. + virtual Status AsGraphDefInternal(SerializationContext* ctx, DatasetGraphDefBuilder* b, Node** node) const { return AsGraphDefInternal(b, node); @@ -453,7 +469,8 @@ class DatasetBase : public core::RefCounted { virtual Status AsGraphDefInternal(DatasetGraphDefBuilder* b, Node** node) const { - return errors::Unimplemented("AsGraphDefInternal"); + return errors::Unimplemented("%s does not support serialization", + DebugString()); } virtual std::unique_ptr MakeIteratorInternal( @@ -470,7 +487,7 @@ class GraphDatasetBase : public DatasetBase { const string op_name() const { return op_name_; } - Status Save(OpKernelContext* ctx, + Status Save(SerializationContext* ctx, IteratorStateWriter* writer) const override { string serialized_graph_def; string output_node; @@ -490,7 +507,7 @@ class GraphDatasetBase : public DatasetBase { TF_EXPORT static const char kDatasetGraphOutputNodeKey[]; private: - Status Serialize(OpKernelContext* ctx, string* serialized_graph_def, + Status Serialize(SerializationContext* ctx, string* serialized_graph_def, string* output_node) const; const string op_name_; @@ -539,7 +556,7 @@ class DatasetBaseIterator : public IteratorBase { return s; } - Status Save(OpKernelContext* ctx, IteratorStateWriter* writer) final { + Status Save(SerializationContext* ctx, IteratorStateWriter* writer) final { TF_RETURN_IF_ERROR(params_.dataset->Save(ctx, writer)); return IteratorBase::Save(ctx, writer); } diff --git a/tensorflow/core/kernels/data/batch_dataset_op.cc b/tensorflow/core/kernels/data/batch_dataset_op.cc index 2ee4548621..5295c9d2a6 100644 --- a/tensorflow/core/kernels/data/batch_dataset_op.cc +++ b/tensorflow/core/kernels/data/batch_dataset_op.cc @@ -96,7 +96,8 @@ class BatchDatasetOp : public UnaryDatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); diff --git a/tensorflow/core/kernels/data/cache_dataset_ops.cc b/tensorflow/core/kernels/data/cache_dataset_ops.cc index 4f23d07aae..3762e403a9 100644 --- a/tensorflow/core/kernels/data/cache_dataset_ops.cc +++ b/tensorflow/core/kernels/data/cache_dataset_ops.cc @@ -85,7 +85,8 @@ class CacheDatasetOp : public UnaryDatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph)); @@ -566,7 +567,8 @@ class CacheDatasetOp : public UnaryDatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_node = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_node)); diff --git a/tensorflow/core/kernels/data/concatenate_dataset_op.cc b/tensorflow/core/kernels/data/concatenate_dataset_op.cc index 98282d74a9..6393005cdc 100644 --- a/tensorflow/core/kernels/data/concatenate_dataset_op.cc +++ b/tensorflow/core/kernels/data/concatenate_dataset_op.cc @@ -80,7 +80,8 @@ class ConcatenateDatasetOp : public BinaryDatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph)); diff --git a/tensorflow/core/kernels/data/dataset_ops.cc b/tensorflow/core/kernels/data/dataset_ops.cc index d15cdf215e..c71d027f23 100644 --- a/tensorflow/core/kernels/data/dataset_ops.cc +++ b/tensorflow/core/kernels/data/dataset_ops.cc @@ -32,7 +32,11 @@ class DatasetToGraphOp : public OpKernel { GraphDefBuilder b; DatasetBase::DatasetGraphDefBuilder db(&b); Node* input_node = nullptr; - OP_REQUIRES_OK(ctx, db.AddInputDataset(ctx, dataset, &input_node)); + SerializationContext::Params params; + params.flib_def = ctx->function_library()->GetFunctionLibraryDefinition(); + SerializationContext serialization_ctx(params); + OP_REQUIRES_OK( + ctx, db.AddInputDataset(&serialization_ctx, dataset, &input_node)); GraphDef graph_def; OP_REQUIRES_OK(ctx, b.ToGraphDef(&graph_def)); Tensor* result; diff --git a/tensorflow/core/kernels/data/dense_to_sparse_batch_dataset_op.cc b/tensorflow/core/kernels/data/dense_to_sparse_batch_dataset_op.cc index 77a04ef3f1..9105587cf4 100644 --- a/tensorflow/core/kernels/data/dense_to_sparse_batch_dataset_op.cc +++ b/tensorflow/core/kernels/data/dense_to_sparse_batch_dataset_op.cc @@ -115,7 +115,8 @@ class DenseToSparseBatchDatasetOp : public UnaryDatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_node; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_node)); diff --git a/tensorflow/core/kernels/data/filter_by_component_dataset_op.cc b/tensorflow/core/kernels/data/filter_by_component_dataset_op.cc index 2f6479de16..4b6d808af0 100644 --- a/tensorflow/core/kernels/data/filter_by_component_dataset_op.cc +++ b/tensorflow/core/kernels/data/filter_by_component_dataset_op.cc @@ -80,7 +80,8 @@ class FilterByLastComponentDatasetOp : public UnaryDatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); diff --git a/tensorflow/core/kernels/data/filter_dataset_op.cc b/tensorflow/core/kernels/data/filter_dataset_op.cc index aebc2f065f..b11d7cf2ef 100644 --- a/tensorflow/core/kernels/data/filter_dataset_op.cc +++ b/tensorflow/core/kernels/data/filter_dataset_op.cc @@ -109,9 +109,10 @@ class FilterDatasetOp : public UnaryDatasetOpKernel { string DebugString() const override { return "FilterDatasetOp::Dataset"; } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { - TF_RETURN_IF_ERROR(b->AddFunction(ctx, func_.name())); + TF_RETURN_IF_ERROR(b->AddFunction(ctx->flib_def(), func_.name())); Node* input_graph_node; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); diff --git a/tensorflow/core/kernels/data/flat_map_dataset_op.cc b/tensorflow/core/kernels/data/flat_map_dataset_op.cc index aae3f19c0d..3419eed6c6 100644 --- a/tensorflow/core/kernels/data/flat_map_dataset_op.cc +++ b/tensorflow/core/kernels/data/flat_map_dataset_op.cc @@ -91,9 +91,10 @@ class FlatMapDatasetOp : public UnaryDatasetOpKernel { string DebugString() const override { return "FlatMapDatasetOp::Dataset"; } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { - TF_RETURN_IF_ERROR(b->AddFunction(ctx, func_.name())); + TF_RETURN_IF_ERROR(b->AddFunction(ctx->flib_def(), func_.name())); Node* input_graph_node = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); diff --git a/tensorflow/core/kernels/data/group_by_reducer_dataset_op.cc b/tensorflow/core/kernels/data/group_by_reducer_dataset_op.cc index f245fc402d..bcf0adacc7 100644 --- a/tensorflow/core/kernels/data/group_by_reducer_dataset_op.cc +++ b/tensorflow/core/kernels/data/group_by_reducer_dataset_op.cc @@ -106,12 +106,14 @@ class GroupByReducerDatasetOp : public UnaryDatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { - TF_RETURN_IF_ERROR(b->AddFunction(ctx, key_func().name())); - TF_RETURN_IF_ERROR(b->AddFunction(ctx, init_func().name())); - TF_RETURN_IF_ERROR(b->AddFunction(ctx, reduce_func().name())); - TF_RETURN_IF_ERROR(b->AddFunction(ctx, finalize_func().name())); + TF_RETURN_IF_ERROR(b->AddFunction(ctx->flib_def(), key_func().name())); + TF_RETURN_IF_ERROR(b->AddFunction(ctx->flib_def(), init_func().name())); + TF_RETURN_IF_ERROR(b->AddFunction(ctx->flib_def(), reduce_func().name())); + TF_RETURN_IF_ERROR( + b->AddFunction(ctx->flib_def(), finalize_func().name())); Node* input_graph_node = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); diff --git a/tensorflow/core/kernels/data/group_by_window_dataset_op.cc b/tensorflow/core/kernels/data/group_by_window_dataset_op.cc index f6664fc5fb..683a50e71c 100644 --- a/tensorflow/core/kernels/data/group_by_window_dataset_op.cc +++ b/tensorflow/core/kernels/data/group_by_window_dataset_op.cc @@ -136,11 +136,13 @@ class GroupByWindowDatasetOp : public UnaryDatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { - TF_RETURN_IF_ERROR(b->AddFunction(ctx, key_func_.name())); - TF_RETURN_IF_ERROR(b->AddFunction(ctx, reduce_func_.name())); - TF_RETURN_IF_ERROR(b->AddFunction(ctx, window_size_func_.name())); + TF_RETURN_IF_ERROR(b->AddFunction(ctx->flib_def(), key_func_.name())); + TF_RETURN_IF_ERROR(b->AddFunction(ctx->flib_def(), reduce_func_.name())); + TF_RETURN_IF_ERROR( + b->AddFunction(ctx->flib_def(), window_size_func_.name())); Node* input_graph_node = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); diff --git a/tensorflow/core/kernels/data/interleave_dataset_op.cc b/tensorflow/core/kernels/data/interleave_dataset_op.cc index 20096a6590..8fee29d4d0 100644 --- a/tensorflow/core/kernels/data/interleave_dataset_op.cc +++ b/tensorflow/core/kernels/data/interleave_dataset_op.cc @@ -114,9 +114,10 @@ class InterleaveDatasetOp : public UnaryDatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { - TF_RETURN_IF_ERROR(b->AddFunction(ctx, func_.name())); + TF_RETURN_IF_ERROR(b->AddFunction(ctx->flib_def(), func_.name())); Node* input_node; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_node)); Node* cycle_length_node; diff --git a/tensorflow/core/kernels/data/iterator_ops.cc b/tensorflow/core/kernels/data/iterator_ops.cc index e2df14337c..da9d29dd76 100644 --- a/tensorflow/core/kernels/data/iterator_ops.cc +++ b/tensorflow/core/kernels/data/iterator_ops.cc @@ -116,7 +116,7 @@ class IteratorResource : public ResourceBase { } } - Status Save(OpKernelContext* ctx, IteratorStateWriter* writer) { + Status Save(SerializationContext* ctx, IteratorStateWriter* writer) { std::shared_ptr captured_iterator(iterator_); if (captured_iterator) { return captured_iterator->Save(ctx, writer); @@ -386,10 +386,13 @@ class IteratorStateVariant { // that it can be written on the next call to Encode(). Status InitializeFromIterator(OpKernelContext* ctx, IteratorResource* iterator_resource) { + SerializationContext::Params params; + params.flib_def = ctx->function_library()->GetFunctionLibraryDefinition(); + SerializationContext serialization_ctx(params); data_.reset(new VariantTensorData()); data_->set_type_name(TypeName()); VariantTensorDataWriter writer(data_.get()); - TF_RETURN_IF_ERROR(iterator_resource->Save(ctx, &writer)); + TF_RETURN_IF_ERROR(iterator_resource->Save(&serialization_ctx, &writer)); TF_RETURN_IF_ERROR(writer.Flush()); return Status::OK(); } diff --git a/tensorflow/core/kernels/data/map_and_batch_dataset_op.cc b/tensorflow/core/kernels/data/map_and_batch_dataset_op.cc index e0f164e784..51a7fd23a8 100644 --- a/tensorflow/core/kernels/data/map_and_batch_dataset_op.cc +++ b/tensorflow/core/kernels/data/map_and_batch_dataset_op.cc @@ -144,9 +144,10 @@ class MapAndBatchDatasetOp : public UnaryDatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { - TF_RETURN_IF_ERROR(b->AddFunction(ctx, map_fn_.name())); + TF_RETURN_IF_ERROR(b->AddFunction(ctx->flib_def(), map_fn_.name())); Node* input_graph_node = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); Node* batch_size_node; diff --git a/tensorflow/core/kernels/data/map_dataset_op.cc b/tensorflow/core/kernels/data/map_dataset_op.cc index 852c942e99..ec9e12453b 100644 --- a/tensorflow/core/kernels/data/map_dataset_op.cc +++ b/tensorflow/core/kernels/data/map_dataset_op.cc @@ -89,9 +89,10 @@ class MapDatasetOp : public UnaryDatasetOpKernel { string DebugString() const override { return "MapDatasetOp::Dataset"; } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { - TF_RETURN_IF_ERROR(b->AddFunction(ctx, func_.name())); + TF_RETURN_IF_ERROR(b->AddFunction(ctx->flib_def(), func_.name())); Node* input_graph_node = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); diff --git a/tensorflow/core/kernels/data/optimize_dataset_op.cc b/tensorflow/core/kernels/data/optimize_dataset_op.cc index 14a0aa7844..8add049123 100644 --- a/tensorflow/core/kernels/data/optimize_dataset_op.cc +++ b/tensorflow/core/kernels/data/optimize_dataset_op.cc @@ -80,15 +80,22 @@ class OptimizeDatasetOp : public UnaryDatasetOpKernel { std::unique_ptr MakeIteratorInternal( const string& prefix) const override { - return std::unique_ptr( - new Iterator({this, strings::StrCat(prefix, "::Optimize")})); + // We do not add a token for the optimization dataset to the prefix. The + // prefix is used to identify checkpoint elements and since the + // optimization dataset is excluded from the checkpoint, adding a token + // here would result in invalid checkpoint identifiers. + return std::unique_ptr(new Iterator({this, prefix})); } Status Optimize(OpKernelContext* ctx) { GraphDefBuilder b; DatasetGraphDefBuilder db(&b); Node* input_node = nullptr; - TF_RETURN_IF_ERROR(db.AddInputDataset(ctx, input_, &input_node)); + SerializationContext::Params params; + params.flib_def = ctx->function_library()->GetFunctionLibraryDefinition(); + SerializationContext serialization_ctx(params); + TF_RETURN_IF_ERROR( + db.AddInputDataset(&serialization_ctx, input_, &input_node)); string output_node = input_node->name(); GraphDef graph_def; TF_RETURN_IF_ERROR(b.ToGraphDef(&graph_def)); @@ -119,14 +126,12 @@ class OptimizeDatasetOp : public UnaryDatasetOpKernel { string DebugString() const override { return "OptimizeDatasetOp::Dataset"; } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { - Node* input_graph_node = nullptr; - TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); - Node* optimizations_node = nullptr; - TF_RETURN_IF_ERROR(b->AddVector(optimizations_, &optimizations_node)); - TF_RETURN_IF_ERROR( - b->AddDataset(this, {input_graph_node, optimizations_node}, output)); + // We only serialize the optimized dataset to avoid re-running + // optimizations when the input pipeline is restored from a checkpoint. + TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, optimized_input_, output)); return Status::OK(); } diff --git a/tensorflow/core/kernels/data/padded_batch_dataset_op.cc b/tensorflow/core/kernels/data/padded_batch_dataset_op.cc index dd4b0f9f4c..755d46dac2 100644 --- a/tensorflow/core/kernels/data/padded_batch_dataset_op.cc +++ b/tensorflow/core/kernels/data/padded_batch_dataset_op.cc @@ -153,7 +153,8 @@ class PaddedBatchDatasetOp : public UnaryDatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); diff --git a/tensorflow/core/kernels/data/parallel_interleave_dataset_op.cc b/tensorflow/core/kernels/data/parallel_interleave_dataset_op.cc index 1995708732..d2b83f9eab 100644 --- a/tensorflow/core/kernels/data/parallel_interleave_dataset_op.cc +++ b/tensorflow/core/kernels/data/parallel_interleave_dataset_op.cc @@ -134,9 +134,11 @@ class ParallelInterleaveDatasetOp : public UnaryDatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { - TF_RETURN_IF_ERROR(b->AddFunction(ctx, interleave_func_.name())); + TF_RETURN_IF_ERROR( + b->AddFunction(ctx->flib_def(), interleave_func_.name())); Node* input_node; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_node)); Node* cycle_length_node; diff --git a/tensorflow/core/kernels/data/parallel_map_dataset_op.cc b/tensorflow/core/kernels/data/parallel_map_dataset_op.cc index 2cbdde01ec..c56a7ea808 100644 --- a/tensorflow/core/kernels/data/parallel_map_dataset_op.cc +++ b/tensorflow/core/kernels/data/parallel_map_dataset_op.cc @@ -113,7 +113,8 @@ class ParallelMapDatasetOp : public UnaryDatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { // Input: input_dataset Node* input_graph_node = nullptr; @@ -137,7 +138,7 @@ class ParallelMapDatasetOp : public UnaryDatasetOpKernel { b->AddScalar(num_parallel_calls_, &num_parallel_calls)); // Attr: f - TF_RETURN_IF_ERROR(b->AddFunction(ctx, func_.name())); + TF_RETURN_IF_ERROR(b->AddFunction(ctx->flib_def(), func_.name())); AttrValue f; b->BuildAttrValue(func_, &f); diff --git a/tensorflow/core/kernels/data/prefetch_dataset_op.cc b/tensorflow/core/kernels/data/prefetch_dataset_op.cc index ccdb7c1479..20148a4378 100644 --- a/tensorflow/core/kernels/data/prefetch_dataset_op.cc +++ b/tensorflow/core/kernels/data/prefetch_dataset_op.cc @@ -51,7 +51,8 @@ class PrefetchDatasetOp::Dataset : public GraphDatasetBase { string DebugString() const override { return "PrefetchDatasetOp::Dataset"; } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); diff --git a/tensorflow/core/kernels/data/random_dataset_op.cc b/tensorflow/core/kernels/data/random_dataset_op.cc index ff166c3be7..7e48428b3f 100644 --- a/tensorflow/core/kernels/data/random_dataset_op.cc +++ b/tensorflow/core/kernels/data/random_dataset_op.cc @@ -77,7 +77,8 @@ class RandomDatasetOp : public DatasetOpKernel { } protected: - Status AsGraphDefInternal(DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* seed = nullptr; Node* seed2 = nullptr; diff --git a/tensorflow/core/kernels/data/range_dataset_op.cc b/tensorflow/core/kernels/data/range_dataset_op.cc index 0b5c814767..50bd3dac4e 100644 --- a/tensorflow/core/kernels/data/range_dataset_op.cc +++ b/tensorflow/core/kernels/data/range_dataset_op.cc @@ -71,7 +71,8 @@ class RangeDatasetOp : public DatasetOpKernel { } protected: - Status AsGraphDefInternal(DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* start = nullptr; Node* stop = nullptr; diff --git a/tensorflow/core/kernels/data/reader_dataset_ops.cc b/tensorflow/core/kernels/data/reader_dataset_ops.cc index 29654b9bca..6a71a7af1d 100644 --- a/tensorflow/core/kernels/data/reader_dataset_ops.cc +++ b/tensorflow/core/kernels/data/reader_dataset_ops.cc @@ -109,7 +109,8 @@ class TextLineDatasetOp : public DatasetOpKernel { string DebugString() const override { return "TextLineDatasetOp::Dataset"; } protected: - Status AsGraphDefInternal(DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* filenames = nullptr; Node* compression_type = nullptr; @@ -345,7 +346,8 @@ class FixedLengthRecordDatasetOp : public DatasetOpKernel { } protected: - Status AsGraphDefInternal(DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* filenames = nullptr; Node* header_bytes = nullptr; @@ -563,7 +565,8 @@ class TFRecordDatasetOp : public DatasetOpKernel { string DebugString() const override { return "TFRecordDatasetOp::Dataset"; } protected: - Status AsGraphDefInternal(DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* filenames = nullptr; TF_RETURN_IF_ERROR(b->AddVector(filenames_, &filenames)); diff --git a/tensorflow/core/kernels/data/repeat_dataset_op.cc b/tensorflow/core/kernels/data/repeat_dataset_op.cc index 002b0ee596..093ea563b4 100644 --- a/tensorflow/core/kernels/data/repeat_dataset_op.cc +++ b/tensorflow/core/kernels/data/repeat_dataset_op.cc @@ -72,7 +72,8 @@ class RepeatDatasetOp : public UnaryDatasetOpKernel { string DebugString() const override { return "RepeatDatasetOp::Dataset"; } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); diff --git a/tensorflow/core/kernels/data/scan_dataset_op.cc b/tensorflow/core/kernels/data/scan_dataset_op.cc index b0874a5509..7c59874d96 100644 --- a/tensorflow/core/kernels/data/scan_dataset_op.cc +++ b/tensorflow/core/kernels/data/scan_dataset_op.cc @@ -106,9 +106,10 @@ class ScanDatasetOp : public UnaryDatasetOpKernel { string DebugString() const override { return "ScanDatasetOp::Dataset"; } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { - TF_RETURN_IF_ERROR(b->AddFunction(ctx, func_.name())); + TF_RETURN_IF_ERROR(b->AddFunction(ctx->flib_def(), func_.name())); Node* input_node; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_node)); std::vector initial_state_nodes; diff --git a/tensorflow/core/kernels/data/shuffle_dataset_op.cc b/tensorflow/core/kernels/data/shuffle_dataset_op.cc index caf1e2af3f..603c3feb79 100644 --- a/tensorflow/core/kernels/data/shuffle_dataset_op.cc +++ b/tensorflow/core/kernels/data/shuffle_dataset_op.cc @@ -429,7 +429,8 @@ class ShuffleDatasetOp : public ShuffleDatasetOpBase { } }; - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { mutex_lock l(mu_); Node* input_graph_node = nullptr; @@ -499,7 +500,8 @@ class ShuffleDatasetOp : public ShuffleDatasetOpBase { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); @@ -584,7 +586,8 @@ class ShuffleAndRepeatDatasetOp : public ShuffleDatasetOpBase { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); diff --git a/tensorflow/core/kernels/data/skip_dataset_op.cc b/tensorflow/core/kernels/data/skip_dataset_op.cc index 2da496c423..61db6a0a54 100644 --- a/tensorflow/core/kernels/data/skip_dataset_op.cc +++ b/tensorflow/core/kernels/data/skip_dataset_op.cc @@ -68,7 +68,8 @@ class SkipDatasetOp : public UnaryDatasetOpKernel { string DebugString() const override { return "SkipDatasetOp::Dataset"; } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); diff --git a/tensorflow/core/kernels/data/slide_dataset_op.cc b/tensorflow/core/kernels/data/slide_dataset_op.cc index 6c0384a537..fd8c5ccd92 100644 --- a/tensorflow/core/kernels/data/slide_dataset_op.cc +++ b/tensorflow/core/kernels/data/slide_dataset_op.cc @@ -104,7 +104,8 @@ class SlideDatasetOp : public UnaryDatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); diff --git a/tensorflow/core/kernels/data/sparse_tensor_slice_dataset_op.cc b/tensorflow/core/kernels/data/sparse_tensor_slice_dataset_op.cc index b5dff48d2d..9bb86e76a2 100644 --- a/tensorflow/core/kernels/data/sparse_tensor_slice_dataset_op.cc +++ b/tensorflow/core/kernels/data/sparse_tensor_slice_dataset_op.cc @@ -55,7 +55,8 @@ class Dataset : public GraphDatasetBase { } protected: - Status AsGraphDefInternal(DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* indices_node; TF_RETURN_IF_ERROR(b->AddTensor(sparse_tensor_.indices(), &indices_node)); diff --git a/tensorflow/core/kernels/data/sql_dataset_ops.cc b/tensorflow/core/kernels/data/sql_dataset_ops.cc index 16652e792c..9b0190e3fc 100644 --- a/tensorflow/core/kernels/data/sql_dataset_ops.cc +++ b/tensorflow/core/kernels/data/sql_dataset_ops.cc @@ -105,7 +105,8 @@ class SqlDatasetOp : public DatasetOpKernel { string DebugString() const override { return "SqlDatasetOp::Dataset"; } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* driver_name_node; TF_RETURN_IF_ERROR(b->AddScalar(driver_name_, &driver_name_node)); diff --git a/tensorflow/core/kernels/data/stats_aggregator_dataset_op.cc b/tensorflow/core/kernels/data/stats_aggregator_dataset_op.cc index 61a1937e4c..8465a1d2c0 100644 --- a/tensorflow/core/kernels/data/stats_aggregator_dataset_op.cc +++ b/tensorflow/core/kernels/data/stats_aggregator_dataset_op.cc @@ -70,14 +70,6 @@ class SetStatsAggregatorDatasetOp : public UnaryDatasetOpKernel { return "SetStatsAggregatorDatasetOp::Dataset"; } - protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, - Node** output) const override { - return errors::Unimplemented( - "Cannot currently serialize the `stats_aggregator` for a " - "SetStatsAggregatorDataset."); - } - private: class Iterator : public DatasetIterator { public: diff --git a/tensorflow/core/kernels/data/stats_dataset_ops.cc b/tensorflow/core/kernels/data/stats_dataset_ops.cc index ba5ed39d83..85fed31773 100644 --- a/tensorflow/core/kernels/data/stats_dataset_ops.cc +++ b/tensorflow/core/kernels/data/stats_dataset_ops.cc @@ -76,7 +76,8 @@ class LatencyStatsDatasetOp : public UnaryDatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_node; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_node)); @@ -175,7 +176,8 @@ class BytesProducedStatsDatasetOp : public UnaryDatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_node; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_node)); @@ -280,7 +282,8 @@ class FeatureStatsDatasetOp : public UnaryDatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_node; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_node)); diff --git a/tensorflow/core/kernels/data/take_dataset_op.cc b/tensorflow/core/kernels/data/take_dataset_op.cc index 0114629ef6..d4a3c7a978 100644 --- a/tensorflow/core/kernels/data/take_dataset_op.cc +++ b/tensorflow/core/kernels/data/take_dataset_op.cc @@ -69,7 +69,8 @@ class TakeDatasetOp : public UnaryDatasetOpKernel { string DebugString() const override { return "TakeDatasetOp::Dataset"; } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); diff --git a/tensorflow/core/kernels/data/tensor_dataset_op.cc b/tensorflow/core/kernels/data/tensor_dataset_op.cc index 36fc434d8f..ac2015c865 100644 --- a/tensorflow/core/kernels/data/tensor_dataset_op.cc +++ b/tensorflow/core/kernels/data/tensor_dataset_op.cc @@ -67,7 +67,8 @@ class TensorDatasetOp : public DatasetOpKernel { string DebugString() const override { return "TensorDatasetOp::Dataset"; } protected: - Status AsGraphDefInternal(DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { std::vector components; components.reserve(tensors_.size()); diff --git a/tensorflow/core/kernels/data/tensor_queue_dataset_op.cc b/tensorflow/core/kernels/data/tensor_queue_dataset_op.cc index d728f1ab14..ea472e2b79 100644 --- a/tensorflow/core/kernels/data/tensor_queue_dataset_op.cc +++ b/tensorflow/core/kernels/data/tensor_queue_dataset_op.cc @@ -99,7 +99,8 @@ class PrependFromQueueAndPaddedBatchDataset : public GraphDatasetBase { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph)); diff --git a/tensorflow/core/kernels/data/tensor_slice_dataset_op.cc b/tensorflow/core/kernels/data/tensor_slice_dataset_op.cc index 68ce324081..8f18d38f83 100644 --- a/tensorflow/core/kernels/data/tensor_slice_dataset_op.cc +++ b/tensorflow/core/kernels/data/tensor_slice_dataset_op.cc @@ -86,7 +86,8 @@ class TensorSliceDatasetOp : public DatasetOpKernel { } protected: - Status AsGraphDefInternal(DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { std::vector components; components.reserve(tensors_.size()); diff --git a/tensorflow/core/kernels/data/unbatch_dataset_op.cc b/tensorflow/core/kernels/data/unbatch_dataset_op.cc index 692b5d8819..02c3c5315a 100644 --- a/tensorflow/core/kernels/data/unbatch_dataset_op.cc +++ b/tensorflow/core/kernels/data/unbatch_dataset_op.cc @@ -65,7 +65,8 @@ class UnbatchDatasetOp : public UnaryDatasetOpKernel { string DebugString() const override { return "UnbatchDatasetOp::Dataset"; } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); diff --git a/tensorflow/core/kernels/data/window_dataset_op.cc b/tensorflow/core/kernels/data/window_dataset_op.cc index c87214b3ef..f9fd5b5a83 100644 --- a/tensorflow/core/kernels/data/window_dataset_op.cc +++ b/tensorflow/core/kernels/data/window_dataset_op.cc @@ -74,7 +74,8 @@ class WindowDatasetOp : public UnaryDatasetOpKernel { } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* input_graph_node = nullptr; TF_RETURN_IF_ERROR(b->AddInputDataset(ctx, input_, &input_graph_node)); diff --git a/tensorflow/core/kernels/data/zip_dataset_op.cc b/tensorflow/core/kernels/data/zip_dataset_op.cc index 8cc21cd2bc..63e9b99d4b 100644 --- a/tensorflow/core/kernels/data/zip_dataset_op.cc +++ b/tensorflow/core/kernels/data/zip_dataset_op.cc @@ -77,7 +77,8 @@ class ZipDatasetOp : public DatasetOpKernel { string DebugString() const override { return "ZipDatasetOp::Dataset"; } protected: - Status AsGraphDefInternal(OpKernelContext* ctx, DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { std::vector input_graph_nodes; input_graph_nodes.reserve(inputs_.size()); -- GitLab From f51fc5f89a3fa934e078b35d50b26625a9ff42cf Mon Sep 17 00:00:00 2001 From: Sanjoy Das Date: Fri, 10 Aug 2018 16:02:52 -0700 Subject: [PATCH 369/437] Introduce and use a BufferInfo class. The BufferInfo represents information about buffer assignment in XlaCompiledCpuFunction. Arg sizes and temp sizes are now derived from BufferInfo instead of being discrete sources of information. Also made StaticData() private, tfcompile clients should not need to access it directly. PiperOrigin-RevId: 208283305 --- tensorflow/compiler/aot/BUILD | 1 + tensorflow/compiler/aot/codegen.cc | 169 +++++++++++------- tensorflow/compiler/aot/codegen_test.cc | 12 +- tensorflow/compiler/aot/codegen_test_h.golden | 58 +++--- tensorflow/compiler/aot/test.cc | 12 +- tensorflow/compiler/tf2xla/BUILD | 5 + .../compiler/tf2xla/cpu_function_runtime.cc | 30 ++-- .../compiler/tf2xla/cpu_function_runtime.h | 133 ++++++++++++-- .../tf2xla/cpu_function_runtime_test.cc | 72 ++++++-- .../tf2xla/xla_compiled_cpu_function.cc | 63 +++---- .../tf2xla/xla_compiled_cpu_function.h | 137 ++++++++++---- .../tf2xla/xla_jit_compiled_cpu_function.cc | 80 +++------ .../tf2xla/xla_jit_compiled_cpu_function.h | 8 +- tensorflow/compiler/xla/service/compiler.h | 5 - tensorflow/compiler/xla/service/cpu/BUILD | 13 ++ .../xla/service/cpu/buffer_info_util.cc | 57 ++++++ .../xla/service/cpu/buffer_info_util.h | 42 +++++ .../compiler/xla/service/cpu/cpu_compiler.cc | 37 +--- .../compiler/xla/service/cpu/cpu_compiler.h | 17 +- .../xla/tests/local_client_aot_test_helper.cc | 8 +- 20 files changed, 655 insertions(+), 304 deletions(-) create mode 100644 tensorflow/compiler/xla/service/cpu/buffer_info_util.cc create mode 100644 tensorflow/compiler/xla/service/cpu/buffer_info_util.h diff --git a/tensorflow/compiler/aot/BUILD b/tensorflow/compiler/aot/BUILD index d2f803bd18..1899a32e4d 100644 --- a/tensorflow/compiler/aot/BUILD +++ b/tensorflow/compiler/aot/BUILD @@ -48,6 +48,7 @@ cc_library( "//tensorflow/compiler/xla/client:compile_only_client", "//tensorflow/compiler/xla/client:xla_computation", "//tensorflow/compiler/xla/service:compiler", + "//tensorflow/compiler/xla/service/cpu:buffer_info_util", "//tensorflow/compiler/xla/service/cpu:cpu_compiler", "//tensorflow/core:core_cpu_internal", "//tensorflow/core:framework_internal", diff --git a/tensorflow/compiler/aot/codegen.cc b/tensorflow/compiler/aot/codegen.cc index 8dbe1e11b7..89fefdad54 100644 --- a/tensorflow/compiler/aot/codegen.cc +++ b/tensorflow/compiler/aot/codegen.cc @@ -24,6 +24,7 @@ limitations under the License. #include "tensorflow/compiler/tf2xla/str_util.h" #include "tensorflow/compiler/tf2xla/tf2xla_util.h" #include "tensorflow/compiler/xla/service/compiler.h" +#include "tensorflow/compiler/xla/service/cpu/buffer_info_util.h" #include "tensorflow/compiler/xla/shape_util.h" #include "tensorflow/compiler/xla/xla_data.pb.h" #include "tensorflow/core/lib/core/errors.h" @@ -36,6 +37,8 @@ namespace tfcompile { namespace { +using BufferInfo = cpu_function_runtime::BufferInfo; + bool IsAlpha(char c) { return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'); } @@ -85,27 +88,36 @@ Status XLATypeToCpp(xla::PrimitiveType type, string* str) { return Status::OK(); } -// total_buffer_bytes returns the sum of each size in `sizes`, skipping -1 -// values. There are `n` entries in `sizes`. -size_t total_buffer_bytes(const intptr_t* sizes, size_t n) { - size_t total = 0; - for (size_t i = 0; i < n; ++i) { - if (sizes[i] != -1) { - total += sizes[i]; - } - } - return total; +// Returns the sum of the size of each buffer in `buffer_infos`. +size_t TotalBufferBytes(const std::vector& buffer_infos) { + return std::accumulate(buffer_infos.begin(), buffer_infos.end(), size_t{0}, + [](size_t size, const BufferInfo& buffer_info) { + return size + buffer_info.size(); + }); } -// Fills in arg_sizes with the byte size of each positional arg. -Status ComputeArgSizes(const CompileResult& compile_result, - std::vector* arg_sizes) { - const xla::ProgramShape& ps = compile_result.program_shape; - for (int i = 0; i < ps.parameters_size(); ++i) { - arg_sizes->push_back(xla::ShapeUtil::ByteSizeOf( - ps.parameters(i), compile_result.pointer_size)); - } - return Status::OK(); +// Returns a vector of BufferInfo instances in `buffer_infos` that are entry +// parameter buffers. +std::vector ExtractEntryParamBufferInfos( + const std::vector& buffer_infos) { + std::vector result; + std::copy_if(buffer_infos.begin(), buffer_infos.end(), + std::back_inserter(result), [](const BufferInfo& buffer_info) { + return buffer_info.is_entry_parameter(); + }); + return result; +} + +// Returns a vector of BufferInfo instances in `buffer_infos` that are temp +// buffers. +std::vector ExtractTempBufferInfos( + const std::vector& buffer_infos) { + std::vector result; + std::copy_if(buffer_infos.begin(), buffer_infos.end(), + std::back_inserter(result), [](const BufferInfo& buffer_info) { + return buffer_info.is_temp_buffer(); + }); + return result; } // Add (from,to) rewrite pairs based on the given shape. These rewrite pairs @@ -278,6 +290,25 @@ Status ValidateFeedFetchCppNames(const tf2xla::Config& config) { return Status::OK(); } +// Returns a list of C++ expressions that, when executed, will construct the +// BufferInfo instances in `buffer_infos`. +std::vector BufferInfosToCppExpression( + const std::vector& buffer_infos) { + std::vector buffer_infos_as_strings; + std::transform(buffer_infos.begin(), buffer_infos.end(), + std::back_inserter(buffer_infos_as_strings), + [](const BufferInfo& buffer_info) { + std::pair encoded = buffer_info.Encode(); + string encoded_second_as_str = + encoded.second == ~0ULL + ? "~0ULL" + : strings::StrCat(encoded.second, "ULL"); + return strings::StrCat( + "::tensorflow::cpu_function_runtime::BufferInfo({", + encoded.first, "ULL, ", encoded_second_as_str, "})"); + }); + return buffer_infos_as_strings; +} } // namespace Status GenerateHeader(const CodegenOpts& opts, const tf2xla::Config& config, @@ -286,29 +317,35 @@ Status GenerateHeader(const CodegenOpts& opts, const tf2xla::Config& config, TF_RETURN_IF_ERROR(ValidateConfig(config)); TF_RETURN_IF_ERROR(ValidateFeedFetchCppNames(config)); const int64 result_index = compile_result.aot->result_buffer_index(); - const xla::BufferSizes& temp_sizes = compile_result.aot->buffer_sizes(); - if (result_index < 0 || result_index >= temp_sizes.size()) { + const std::vector& buffer_infos = + compile_result.aot->buffer_infos(); + const std::vector arg_index_table = + ::xla::cpu::CreateArgIndexTableFromBufferInfos(buffer_infos); + std::vector buffer_infos_as_strings = + BufferInfosToCppExpression(buffer_infos); + if (result_index < 0 || result_index >= buffer_infos.size()) { return errors::InvalidArgument("result index: ", result_index, " is outside the range of temp sizes: [0,", - temp_sizes.size(), ")"); + buffer_infos.size(), ")"); } // Compute sizes and generate methods. - std::vector arg_sizes; - TF_RETURN_IF_ERROR(ComputeArgSizes(compile_result, &arg_sizes)); + std::vector buffer_infos_for_args = + ExtractEntryParamBufferInfos(buffer_infos); + std::vector buffer_infos_for_temps = + ExtractTempBufferInfos(buffer_infos); const xla::ProgramShape& ps = compile_result.program_shape; string methods_arg, methods_result; TF_RETURN_IF_ERROR(GenArgMethods(config, ps, compile_result, &methods_arg)); TF_RETURN_IF_ERROR(GenResultMethods(config, ps, &methods_result)); - const std::vector iarg(arg_sizes.begin(), arg_sizes.end()); - const std::vector itemp(temp_sizes.begin(), temp_sizes.end()); - const size_t arg_bytes_aligned = - cpu_function_runtime::AlignedBufferBytes(iarg.data(), iarg.size()); - const size_t arg_bytes_total = total_buffer_bytes(iarg.data(), iarg.size()); - const size_t temp_bytes_aligned = - cpu_function_runtime::AlignedBufferBytes(itemp.data(), itemp.size()); - const size_t temp_bytes_total = - total_buffer_bytes(itemp.data(), itemp.size()); + const size_t arg_bytes_aligned = cpu_function_runtime::AlignedBufferBytes( + buffer_infos_for_args.data(), buffer_infos_for_args.size(), + /*allocate_entry_params=*/true); + const size_t arg_bytes_total = TotalBufferBytes(buffer_infos_for_args); + const size_t temp_bytes_aligned = cpu_function_runtime::AlignedBufferBytes( + buffer_infos_for_temps.data(), buffer_infos_for_temps.size(), + /*allocate_entry_params=*/true); + const size_t temp_bytes_total = TotalBufferBytes(buffer_infos_for_temps); // Create rewrite strings for namespace start and end. string ns_start; @@ -343,8 +380,8 @@ Status GenerateHeader(const CodegenOpts& opts, const tf2xla::Config& config, // calling HloProfilePrinter::profile_counters_size. const string assign_profile_counters_size = opts.gen_hlo_profile_printer_data - ? "data->profile_counters_size = " - "data->hlo_profile_printer_data->profile_counters_size();" + ? "data->set_profile_counters_size(" + "data->hlo_profile_printer_data()->profile_counters_size());" : ""; // Use a poor-man's text templating mechanism; first populate the full header @@ -414,9 +451,8 @@ class {{CLASS}} : public tensorflow::XlaCompiledCpuFunction { static constexpr size_t kNumArgs = {{ARG_NUM}}; // Byte size of each argument buffer. There are kNumArgs entries. - static const intptr_t* ArgSizes() { - static constexpr intptr_t kArgSizes[kNumArgs] = {{{ARG_SIZES}}}; - return kArgSizes; + static const ::tensorflow::int64 ArgSize(::tensorflow::int32 index) { + return BufferInfos()[ArgIndexToBufferIndex()[index]].size(); } // Returns static data used to create an XlaCompiledCpuFunction. @@ -424,17 +460,17 @@ class {{CLASS}} : public tensorflow::XlaCompiledCpuFunction { static XlaCompiledCpuFunction::StaticData* kStaticData = [](){ XlaCompiledCpuFunction::StaticData* data = new XlaCompiledCpuFunction::StaticData; - data->raw_function = {{ENTRY}}; - data->arg_sizes = ArgSizes(); - data->num_args = kNumArgs; - data->temp_sizes = TempSizes(); - data->num_temps = kNumTemps; - data->result_index = kResultIndex; - data->arg_names = StaticArgNames(); - data->result_names = StaticResultNames(); - data->program_shape = StaticProgramShape(); - data->hlo_profile_printer_data = StaticHloProfilePrinterData(); - {{ASSIGN_PROFILE_COUNTERS_SIZE}} + data->set_raw_function({{ENTRY}}); + data->set_buffer_infos(BufferInfos()); + data->set_num_buffers(kNumBuffers); + data->set_arg_index_table(ArgIndexToBufferIndex()); + data->set_num_args(kNumArgs); + data->set_result_index(kResultIndex); + data->set_arg_names(StaticArgNames()); + data->set_result_names(StaticResultNames()); + data->set_program_shape(StaticProgramShape()); + data->set_hlo_profile_printer_data(StaticHloProfilePrinterData()); +{{ASSIGN_PROFILE_COUNTERS_SIZE}} return data; }(); return *kStaticData; @@ -482,17 +518,27 @@ class {{CLASS}} : public tensorflow::XlaCompiledCpuFunction { {{METHODS_RESULT}} private: - // Number of result and temporary buffers for the compiled computation. - static constexpr size_t kNumTemps = {{TEMP_NUM}}; - // The 0-based index of the result tuple in the temporary buffers. - static constexpr size_t kResultIndex = {{RESULT_INDEX}}; + // Number of buffers for the compiled computation. + static constexpr size_t kNumBuffers = {{NUM_BUFFERS}}; - // Byte size of each result / temporary buffer. There are kNumTemps entries. - static const intptr_t* TempSizes() { - static constexpr intptr_t kTempSizes[kNumTemps] = {{{TEMP_SIZES}}}; - return kTempSizes; + static const ::tensorflow::cpu_function_runtime::BufferInfo* BufferInfos() { + static const ::tensorflow::cpu_function_runtime::BufferInfo + kBufferInfos[kNumBuffers] = { +{{BUFFER_INFOS_AS_STRING}} + }; + return kBufferInfos; } + static const ::tensorflow::int32* ArgIndexToBufferIndex() { + static constexpr ::tensorflow::int32 kArgIndexToBufferIndex[kNumArgs] = { +{{ARG_INDEX_TABLE}} + }; + return kArgIndexToBufferIndex; + } + + // The 0-based index of the result tuple in the temporary buffers. + static constexpr size_t kResultIndex = {{RESULT_INDEX}}; + // Array of names of each positional argument, terminated by nullptr. static const char** StaticArgNames() {{ARG_NAMES_CODE}} @@ -523,8 +569,8 @@ class {{CLASS}} : public tensorflow::XlaCompiledCpuFunction { {"{{ARG_BYTES_ALIGNED}}", strings::StrCat(arg_bytes_aligned)}, {"{{ARG_BYTES_TOTAL}}", strings::StrCat(arg_bytes_total)}, {"{{ARG_NAMES_CODE}}", arg_names_code}, - {"{{ARG_NUM}}", strings::StrCat(arg_sizes.size())}, - {"{{ARG_SIZES}}", str_util::Join(arg_sizes, ", ")}, + {"{{ARG_NUM}}", strings::StrCat(arg_index_table.size())}, + {"{{ARG_INDEX_TABLE}}", str_util::Join(arg_index_table, ", ")}, {"{{ASSIGN_PROFILE_COUNTERS_SIZE}}", assign_profile_counters_size}, {"{{CLASS}}", opts.class_name}, {"{{DECLS_FROM_OBJ_FILE}}", @@ -546,8 +592,9 @@ class {{CLASS}} : public tensorflow::XlaCompiledCpuFunction { {"{{RESULT_NAMES_CODE}}", result_names_code}, {"{{TEMP_BYTES_ALIGNED}}", strings::StrCat(temp_bytes_aligned)}, {"{{TEMP_BYTES_TOTAL}}", strings::StrCat(temp_bytes_total)}, - {"{{TEMP_NUM}}", strings::StrCat(temp_sizes.size())}, - {"{{TEMP_SIZES}}", str_util::Join(temp_sizes, ", ")}}; + {"{{NUM_BUFFERS}}", strings::StrCat(buffer_infos.size())}, + {"{{BUFFER_INFOS_AS_STRING}}", + str_util::Join(buffer_infos_as_strings, ",\n")}}; str_util::ReplaceAllPairs(header, rewrites); return Status::OK(); } diff --git a/tensorflow/compiler/aot/codegen_test.cc b/tensorflow/compiler/aot/codegen_test.cc index 29bc9c13b8..60d59ae996 100644 --- a/tensorflow/compiler/aot/codegen_test.cc +++ b/tensorflow/compiler/aot/codegen_test.cc @@ -32,6 +32,8 @@ namespace tensorflow { namespace tfcompile { namespace { +using ::tensorflow::cpu_function_runtime::BufferInfo; + void ExpectErrorContains(const Status& status, StringPiece str) { EXPECT_NE(Status::OK(), status); EXPECT_TRUE(str_util::StrContains(status.error_message(), str)) @@ -171,8 +173,14 @@ TEST(CodegenTest, Golden) { fetch->mutable_id()->set_node_name("fetch0"); fetch->set_name("myfetch"); CompileResult compile_result; - compile_result.aot.reset( - new xla::cpu::CpuAotCompilationResult({}, {1, -1, 2, -1, 3, 120}, 5, {})); + compile_result.aot.reset(new xla::cpu::CpuAotCompilationResult( + {}, + {BufferInfo::MakeTempBuffer(1), + BufferInfo::MakeEntryParameter(/*size=*/8, /*param_number=*/0), + BufferInfo::MakeTempBuffer(2), + BufferInfo::MakeEntryParameter(/*size=*/96, /*param_number=*/1), + BufferInfo::MakeTempBuffer(3), BufferInfo::MakeTempBuffer(120)}, + 5, {})); compile_result.program_shape = xla::ShapeUtil::MakeProgramShape( { xla::ShapeUtil::MakeShape(xla::F32, {1, 2}), diff --git a/tensorflow/compiler/aot/codegen_test_h.golden b/tensorflow/compiler/aot/codegen_test_h.golden index 6641d45e83..e4d8a02877 100644 --- a/tensorflow/compiler/aot/codegen_test_h.golden +++ b/tensorflow/compiler/aot/codegen_test_h.golden @@ -65,9 +65,8 @@ class MyClass : public tensorflow::XlaCompiledCpuFunction { static constexpr size_t kNumArgs = 2; // Byte size of each argument buffer. There are kNumArgs entries. - static const intptr_t* ArgSizes() { - static constexpr intptr_t kArgSizes[kNumArgs] = {8, 96}; - return kArgSizes; + static const ::tensorflow::int64 ArgSize(::tensorflow::int32 index) { + return BufferInfos()[ArgIndexToBufferIndex()[index]].size(); } // Returns static data used to create an XlaCompiledCpuFunction. @@ -75,17 +74,17 @@ class MyClass : public tensorflow::XlaCompiledCpuFunction { static XlaCompiledCpuFunction::StaticData* kStaticData = [](){ XlaCompiledCpuFunction::StaticData* data = new XlaCompiledCpuFunction::StaticData; - data->raw_function = entry_point; - data->arg_sizes = ArgSizes(); - data->num_args = kNumArgs; - data->temp_sizes = TempSizes(); - data->num_temps = kNumTemps; - data->result_index = kResultIndex; - data->arg_names = StaticArgNames(); - data->result_names = StaticResultNames(); - data->program_shape = StaticProgramShape(); - data->hlo_profile_printer_data = StaticHloProfilePrinterData(); - + data->set_raw_function(entry_point); + data->set_buffer_infos(BufferInfos()); + data->set_num_buffers(kNumBuffers); + data->set_arg_index_table(ArgIndexToBufferIndex()); + data->set_num_args(kNumArgs); + data->set_result_index(kResultIndex); + data->set_arg_names(StaticArgNames()); + data->set_result_names(StaticResultNames()); + data->set_program_shape(StaticProgramShape()); + data->set_hlo_profile_printer_data(StaticHloProfilePrinterData()); + return data; }(); return *kStaticData; @@ -215,17 +214,32 @@ class MyClass : public tensorflow::XlaCompiledCpuFunction { } private: - // Number of result and temporary buffers for the compiled computation. - static constexpr size_t kNumTemps = 6; - // The 0-based index of the result tuple in the temporary buffers. - static constexpr size_t kResultIndex = 5; + // Number of buffers for the compiled computation. + static constexpr size_t kNumBuffers = 6; + + static const ::tensorflow::cpu_function_runtime::BufferInfo* BufferInfos() { + static const ::tensorflow::cpu_function_runtime::BufferInfo + kBufferInfos[kNumBuffers] = { +::tensorflow::cpu_function_runtime::BufferInfo({5ULL, ~0ULL}), +::tensorflow::cpu_function_runtime::BufferInfo({34ULL, 0ULL}), +::tensorflow::cpu_function_runtime::BufferInfo({9ULL, ~0ULL}), +::tensorflow::cpu_function_runtime::BufferInfo({386ULL, 1ULL}), +::tensorflow::cpu_function_runtime::BufferInfo({13ULL, ~0ULL}), +::tensorflow::cpu_function_runtime::BufferInfo({481ULL, ~0ULL}) + }; + return kBufferInfos; + } - // Byte size of each result / temporary buffer. There are kNumTemps entries. - static const intptr_t* TempSizes() { - static constexpr intptr_t kTempSizes[kNumTemps] = {1, -1, 2, -1, 3, 120}; - return kTempSizes; + static const ::tensorflow::int32* ArgIndexToBufferIndex() { + static constexpr ::tensorflow::int32 kArgIndexToBufferIndex[kNumArgs] = { +1, 3 + }; + return kArgIndexToBufferIndex; } + // The 0-based index of the result tuple in the temporary buffers. + static constexpr size_t kResultIndex = 5; + // Array of names of each positional argument, terminated by nullptr. static const char** StaticArgNames() { static const char* kNames[] = {"myfeed", nullptr}; diff --git a/tensorflow/compiler/aot/test.cc b/tensorflow/compiler/aot/test.cc index 6b098049cb..df966767b3 100644 --- a/tensorflow/compiler/aot/test.cc +++ b/tensorflow/compiler/aot/test.cc @@ -51,11 +51,9 @@ namespace tensorflow { namespace tfcompile { namespace { -void zero_buffers(void** bufs, const intptr_t* sizes, size_t n) { - for (int i = 0; i < n; ++i) { - if (sizes[i] != -1) { - memset(bufs[i], 0, sizes[i]); - } +void zero_buffers(void** bufs, const XlaCompiledCpuFunction& computation) { + for (int i = 0; i < computation.num_args(); ++i) { + memset(bufs[i], 0, computation.arg_size(i)); } } @@ -66,7 +64,7 @@ TEST(TEST_NAME, NoCrash) { CPP_CLASS computation; computation.set_thread_pool(&device); - zero_buffers(computation.args(), CPP_CLASS::ArgSizes(), CPP_CLASS::kNumArgs); + zero_buffers(computation.args(), computation); EXPECT_TRUE(computation.Run()); } @@ -80,7 +78,7 @@ void BM_NAME(int iters) { CPP_CLASS computation; computation.set_thread_pool(&device); - zero_buffers(computation.args(), CPP_CLASS::ArgSizes(), CPP_CLASS::kNumArgs); + zero_buffers(computation.args(), computation); testing::StartTiming(); while (--iters) { diff --git a/tensorflow/compiler/tf2xla/BUILD b/tensorflow/compiler/tf2xla/BUILD index 61759fd276..fda32c8a1c 100644 --- a/tensorflow/compiler/tf2xla/BUILD +++ b/tensorflow/compiler/tf2xla/BUILD @@ -95,6 +95,10 @@ cc_library( name = "cpu_function_runtime", srcs = ["cpu_function_runtime.cc"], hdrs = ["cpu_function_runtime.h"], + visibility = [ + "//tensorflow/compiler/aot:__pkg__", + "//tensorflow/compiler/xla/service/cpu:__pkg__", + ], deps = [ # Keep dependencies to a minimum here; this library is used in every AOT # binary produced by tfcompile. @@ -144,6 +148,7 @@ cc_library( "//tensorflow/compiler/xla/client:local_client", "//tensorflow/compiler/xla/client:xla_computation", "//tensorflow/compiler/xla/service:cpu_plugin", + "//tensorflow/compiler/xla/service/cpu:buffer_info_util", "//tensorflow/compiler/xla/service/cpu:cpu_executable", "//tensorflow/core:lib", "//tensorflow/core:protos_all_cc", diff --git a/tensorflow/compiler/tf2xla/cpu_function_runtime.cc b/tensorflow/compiler/tf2xla/cpu_function_runtime.cc index 2ffad2af8c..fcc4095e39 100644 --- a/tensorflow/compiler/tf2xla/cpu_function_runtime.cc +++ b/tensorflow/compiler/tf2xla/cpu_function_runtime.cc @@ -55,19 +55,26 @@ size_t align_to(size_t n, size_t align) { } // namespace namespace cpu_function_runtime { -size_t AlignedBufferBytes(const intptr_t* sizes, size_t n) { +size_t AlignedBufferBytes(const BufferInfo* buffer_infos, size_t n, + bool allocate_entry_params) { size_t total = 0; for (size_t i = 0; i < n; ++i) { - if (sizes[i] > 0) { - total += align_to(sizes[i], kAlign); + bool should_allocate = + buffer_infos[i].is_temp_buffer() || + (buffer_infos[i].is_entry_parameter() && allocate_entry_params); + + if (should_allocate) { + total += align_to(buffer_infos[i].size(), kAlign); } } return total; } -void* MallocContiguousBuffers(const intptr_t* sizes, size_t n, void** bufs, +void* MallocContiguousBuffers(const BufferInfo* buffer_infos, size_t n, + bool allocate_entry_params, void** bufs, bool annotate_initialized) { - const size_t total = AlignedBufferBytes(sizes, n); + const size_t total = + AlignedBufferBytes(buffer_infos, n, allocate_entry_params); void* contiguous = nullptr; if (total > 0) { contiguous = aligned_malloc(total, kAlign); @@ -79,13 +86,14 @@ void* MallocContiguousBuffers(const intptr_t* sizes, size_t n, void** bufs, } uintptr_t pos = reinterpret_cast(contiguous); for (size_t i = 0; i < n; ++i) { - if (sizes[i] < 0) { - // bufs[i] is either a constant, an entry parameter or a thread local - // allocation. - bufs[i] = nullptr; - } else { + bool should_allocate = + buffer_infos[i].is_temp_buffer() || + (buffer_infos[i].is_entry_parameter() && allocate_entry_params); + if (should_allocate) { bufs[i] = reinterpret_cast(pos); - pos += align_to(sizes[i], kAlign); + pos += align_to(buffer_infos[i].size(), kAlign); + } else { + bufs[i] = nullptr; } } return contiguous; diff --git a/tensorflow/compiler/tf2xla/cpu_function_runtime.h b/tensorflow/compiler/tf2xla/cpu_function_runtime.h index c7b4559c65..dfc1e8b8ae 100644 --- a/tensorflow/compiler/tf2xla/cpu_function_runtime.h +++ b/tensorflow/compiler/tf2xla/cpu_function_runtime.h @@ -18,29 +18,142 @@ limitations under the License. #include "tensorflow/core/platform/types.h" +#include + namespace tensorflow { namespace cpu_function_runtime { +// Stores information about one buffer used by an XLA:CPU compiled function. +// These buffers are used for holding inputs to the computation, outputs from +// the computation and as temporary scratch space. +class BufferInfo { + public: + // Creates a BufferInfo from a serialized encoding generated by `Encode`. + explicit BufferInfo(std::pair encoding) + : entry_param_number_(encoding.second) { + Kind kind; + uint64 size; + Unpack(encoding.first, &kind, &size); + kind_ = kind; + size_ = size; + } + + // Returns true if this buffer stores a constant. These never need to be + // allocated by the runtime. + bool is_constant() const { return kind() == Kind::kConstant; } + + // Returns true if this buffer stores an entry parameter. These may or may + // not need to be allocated by the runtime, depending on + // XlaCompiledCpuFunction::AllocMode. + bool is_entry_parameter() const { return kind() == Kind::kEntryParameter; } + + // Returns the entry parameter number of this buffer. + uint64 entry_parameter_number() const { + assert(is_entry_parameter()); + return entry_param_number_; + } + + // Returns true if this buffer is temporary scratch space required by the XLA + // computations. These are always allocated by the runtime. + bool is_temp_buffer() const { return kind() == Kind::kTempBuffer; } + + // Returns true if this buffer is allocated on the C stack or into registers. + // These buffers are never allocated by the runtime. + bool is_on_stack_buffer() const { return kind() == Kind::kOnStackBuffer; } + + // Returns the size for this buffer. + uint64 size() const { return size_; } + + // Encodes this BufferInfo into two 64 bit integers that can be used to + // reconstruct the BufferInfo later using the constructor. We need this + // because we use BufferInfo in places where using protocol buffers would + // negatively impact binary size. + std::pair Encode() const { + static_assert(sizeof(*this) == 16, ""); + uint64 upper = Pack(kind(), size_); + uint64 lower = entry_param_number_; + return {upper, lower}; + } + + bool operator==(const BufferInfo& buffer_info) const { + if (kind() != buffer_info.kind() || size() != buffer_info.size()) { + return false; + } + return !is_entry_parameter() || + entry_parameter_number() == buffer_info.entry_parameter_number(); + } + + // Factory methods: + + static BufferInfo MakeTempBuffer(uint64 size) { + return BufferInfo(Kind::kTempBuffer, /*size=*/size, + /*entry_param_number=*/-1); + } + static BufferInfo MakeConstant(uint64 size) { + return BufferInfo(Kind::kConstant, /*size=*/size, + /*entry_param_number=*/-1); + } + static BufferInfo MakeEntryParameter(uint64 size, uint64 param_number) { + return BufferInfo(Kind::kEntryParameter, /*size=*/size, + /*entry_param_number=*/param_number); + } + static BufferInfo MakeOnStackBuffer(uint64 size) { + return BufferInfo(Kind::kOnStackBuffer, /*size=*/size, + /*entry_param_number=*/-1); + } + + private: + BufferInfo() = default; + + enum class Kind : unsigned { + kConstant, + kTempBuffer, + kEntryParameter, + kOnStackBuffer + }; + + Kind kind() const { return static_cast(kind_); } + + explicit BufferInfo(Kind kind, uint64 size, uint64 entry_param_number) + : kind_(kind), size_(size), entry_param_number_(entry_param_number) {} + + static uint64 Pack(Kind kind, uint64 size) { + return (static_cast(size) << 2) | static_cast(kind); + } + + static void Unpack(uint64 packed, Kind* kind, uint64* size) { + *size = packed >> 2; + *kind = static_cast((packed << 62) >> 62); + } + + Kind kind_ : 2; + uint64 size_ : 62; + int64 entry_param_number_; +}; // Align to 64-bytes, to mimic tensorflow::Allocator::kAllocatorAlignment. constexpr size_t kAlign = 64; -// AlignedBufferBytes returns the sum of each size in `sizes`, skipping -1 -// values. There are `n` entries in `sizes`. Each buffer is aligned to -// kAlign byte boundaries. -size_t AlignedBufferBytes(const intptr_t* sizes, size_t n); +// AlignedBufferBytes returns the sum of the size of each buffer in +// `buffer_infos`, skipping constants, on-stack buffers and, if +// allocate_entry_params is false, entry parameters. There are `n` entries in +// `buffer_infos`. Each buffer is aligned to kAlign byte boundaries. +size_t AlignedBufferBytes(const BufferInfo* buffer_infos, size_t n, + bool allocate_entry_params); // MallocContiguousBuffers allocates buffers for use by the entry point -// generated by tfcompile. `sizes` is an array of byte sizes for each buffer, -// where -1 causes the buffer pointer to be nullptr. There are `n` entries in -// `sizes`. If `annotate_initialized` is set, the allocated memory will be -// annotated as having been initialized - this is useful when allocating -// temporary buffers. +// generated by tfcompile. There are `n` entries in `buffer_infos`. If +// `annotate_initialized` is set, the allocated memory will be annotated as +// having been initialized - this is useful when allocating temporary buffers. +// If allocate_entry_params is true then allocates temp buffers and entry +// parameters, otherwise allocated only temp buffers. Slots in `bufs` +// corresponding to unallocated buffers are set to nullptr. // // A single contiguous block of memory is allocated, and portions of it are // parceled out into `bufs`, which must have space for `n` entries. Returns // the head of the allocated contiguous block, which should be passed to // FreeContiguous when the buffers are no longer in use. -void* MallocContiguousBuffers(const intptr_t* sizes, size_t n, void** bufs, +void* MallocContiguousBuffers(const BufferInfo* buffer_infos, size_t n, + bool allocate_entry_params, void** bufs, bool annotate_initialized); // FreeContiguous frees the contiguous block of memory allocated by diff --git a/tensorflow/compiler/tf2xla/cpu_function_runtime_test.cc b/tensorflow/compiler/tf2xla/cpu_function_runtime_test.cc index f4f27a1562..8ca628c4eb 100644 --- a/tensorflow/compiler/tf2xla/cpu_function_runtime_test.cc +++ b/tensorflow/compiler/tf2xla/cpu_function_runtime_test.cc @@ -21,6 +21,8 @@ limitations under the License. namespace tensorflow { namespace { +using cpu_function_runtime::BufferInfo; + TEST(XlaCompiledCpuFunctionTest, AlignmentValue) { // We've chosen 64 byte alignment for the tfcompile runtime to mimic the // regular tensorflow allocator, which was chosen to play nicely with Eigen. @@ -30,20 +32,51 @@ TEST(XlaCompiledCpuFunctionTest, AlignmentValue) { EXPECT_EQ(cpu_function_runtime::kAlign, Allocator::kAllocatorAlignment); } +std::vector SizesToBufferInfos(const intptr_t* sizes, size_t n) { + std::vector buffer_infos; + std::transform(sizes, sizes + n, std::back_inserter(buffer_infos), + [&](intptr_t size) { + if (size == -1) { + // Use a dummy on-stack buffer allocation to indicat the + // the current slot does not need an allocation. + int64 on_stack_buffer_size = 4; + return BufferInfo::MakeOnStackBuffer(on_stack_buffer_size); + } + return BufferInfo::MakeTempBuffer(size); + }); + return buffer_infos; +} + +// Simple wrappers to make writing tests more ergonomic. + +size_t AlignedBufferBytesFromSizes(const intptr_t* sizes, size_t n) { + std::vector buffer_infos = SizesToBufferInfos(sizes, n); + return AlignedBufferBytes(buffer_infos.data(), n, + /*allocate_entry_params=*/false); +} + +void* MallocContiguousBuffersFromSizes(const intptr_t* sizes, size_t n, + void** bufs, bool annotate_initialized) { + std::vector buffer_infos = SizesToBufferInfos(sizes, n); + return MallocContiguousBuffers(buffer_infos.data(), n, + /*allocate_entry_params=*/false, bufs, + annotate_initialized); +} + TEST(XlaCompiledCpuFunctionTest, AlignedBufferBytes) { - EXPECT_EQ(cpu_function_runtime::AlignedBufferBytes(nullptr, 0), 0); + EXPECT_EQ(AlignedBufferBytesFromSizes(nullptr, 0), 0); static constexpr intptr_t sizesA[1] = {-1}; - EXPECT_EQ(cpu_function_runtime::AlignedBufferBytes(sizesA, 1), 0); + EXPECT_EQ(AlignedBufferBytesFromSizes(sizesA, 1), 0); static constexpr intptr_t sizesB[1] = {3}; - EXPECT_EQ(cpu_function_runtime::AlignedBufferBytes(sizesB, 1), 64); + EXPECT_EQ(AlignedBufferBytesFromSizes(sizesB, 1), 64); static constexpr intptr_t sizesC[1] = {32}; - EXPECT_EQ(cpu_function_runtime::AlignedBufferBytes(sizesC, 1), 64); + EXPECT_EQ(AlignedBufferBytesFromSizes(sizesC, 1), 64); static constexpr intptr_t sizesD[7] = {1, -1, 32, -1, 64, 2, 3}; - EXPECT_EQ(cpu_function_runtime::AlignedBufferBytes(sizesD, 7), 320); + EXPECT_EQ(AlignedBufferBytesFromSizes(sizesD, 7), 320); } void* add_ptr(void* base, uintptr_t delta) { @@ -56,15 +89,14 @@ void* add_ptr(void* base, uintptr_t delta) { // free. We also check the contiguous property. TEST(XlaCompiledCpuFunctionTest, MallocFreeContiguousBuffers) { // Test empty sizes. - void* base = - cpu_function_runtime::MallocContiguousBuffers(nullptr, 0, nullptr, false); + void* base = MallocContiguousBuffersFromSizes(nullptr, 0, nullptr, false); EXPECT_EQ(base, nullptr); cpu_function_runtime::FreeContiguous(base); // Test non-empty sizes with 0 sum. static constexpr intptr_t sizesA[1] = {-1}; void* bufA[1]; - base = cpu_function_runtime::MallocContiguousBuffers(sizesA, 1, bufA, false); + base = MallocContiguousBuffersFromSizes(sizesA, 1, bufA, false); EXPECT_EQ(base, nullptr); EXPECT_EQ(bufA[0], nullptr); cpu_function_runtime::FreeContiguous(base); @@ -72,7 +104,7 @@ TEST(XlaCompiledCpuFunctionTest, MallocFreeContiguousBuffers) { // Test non-empty sizes with non-0 sum. static constexpr intptr_t sizesB[1] = {3}; void* bufB[1]; - base = cpu_function_runtime::MallocContiguousBuffers(sizesB, 1, bufB, false); + base = MallocContiguousBuffersFromSizes(sizesB, 1, bufB, false); EXPECT_NE(base, nullptr); EXPECT_EQ(bufB[0], add_ptr(base, 0)); char* bufB0_bytes = static_cast(bufB[0]); @@ -84,7 +116,7 @@ TEST(XlaCompiledCpuFunctionTest, MallocFreeContiguousBuffers) { // Test non-empty sizes with non-0 sum, and annotate_initialized. static constexpr intptr_t sizesC[1] = {3}; void* bufC[1]; - base = cpu_function_runtime::MallocContiguousBuffers(sizesC, 1, bufC, true); + base = MallocContiguousBuffersFromSizes(sizesC, 1, bufC, true); EXPECT_NE(base, nullptr); EXPECT_EQ(bufC[0], add_ptr(base, 0)); char* bufC0_bytes = static_cast(bufC[0]); @@ -96,7 +128,7 @@ TEST(XlaCompiledCpuFunctionTest, MallocFreeContiguousBuffers) { // Test mixed sizes. static constexpr intptr_t sizesD[7] = {1, -1, 32, -1, 64, 2, 3}; void* bufD[7]; - base = cpu_function_runtime::MallocContiguousBuffers(sizesD, 7, bufD, false); + base = MallocContiguousBuffersFromSizes(sizesD, 7, bufD, false); EXPECT_NE(base, nullptr); EXPECT_EQ(bufD[0], add_ptr(base, 0)); EXPECT_EQ(bufD[1], nullptr); @@ -117,5 +149,23 @@ TEST(XlaCompiledCpuFunctionTest, MallocFreeContiguousBuffers) { cpu_function_runtime::FreeContiguous(base); } +void CheckRoundTripIsOk(const BufferInfo& buffer_info) { + BufferInfo round_trip(buffer_info.Encode()); + ASSERT_EQ(round_trip, buffer_info); +} + +TEST(XlaCompiledCpuFunctionTest, BufferInfoTest) { + CheckRoundTripIsOk(BufferInfo::MakeTempBuffer(0)); + CheckRoundTripIsOk(BufferInfo::MakeTempBuffer(4)); + CheckRoundTripIsOk(BufferInfo::MakeOnStackBuffer(0)); + CheckRoundTripIsOk(BufferInfo::MakeOnStackBuffer(4)); + CheckRoundTripIsOk(BufferInfo::MakeConstant(0)); + CheckRoundTripIsOk(BufferInfo::MakeConstant(4)); + CheckRoundTripIsOk( + BufferInfo::MakeEntryParameter(/*size=*/0, /*param_number=*/4)); + CheckRoundTripIsOk( + BufferInfo::MakeEntryParameter(/*size=*/4, /*param_number=*/0)); +} + } // namespace } // namespace tensorflow diff --git a/tensorflow/compiler/tf2xla/xla_compiled_cpu_function.cc b/tensorflow/compiler/tf2xla/xla_compiled_cpu_function.cc index 334459138b..09c5d1dd19 100644 --- a/tensorflow/compiler/tf2xla/xla_compiled_cpu_function.cc +++ b/tensorflow/compiler/tf2xla/xla_compiled_cpu_function.cc @@ -14,7 +14,6 @@ limitations under the License. ==============================================================================*/ #include "tensorflow/compiler/tf2xla/xla_compiled_cpu_function.h" -#include "tensorflow/compiler/tf2xla/cpu_function_runtime.h" #include @@ -22,61 +21,55 @@ namespace tensorflow { XlaCompiledCpuFunction::XlaCompiledCpuFunction(const StaticData& static_data, AllocMode alloc_mode) - : raw_function_(static_data.raw_function), - result_index_(static_data.result_index), - args_(new void*[static_data.num_args]), - temps_(new void*[static_data.num_temps]), - arg_index_to_temp_index_(new int32[static_data.num_args]), - num_args_(static_data.num_args), - arg_names_(static_data.arg_names), - result_names_(static_data.result_names), - program_shape_(static_data.program_shape), - hlo_profile_printer_data_(static_data.hlo_profile_printer_data) { + : raw_function_(static_data.raw_function_), + result_index_(static_data.result_index_), + args_(new void*[static_data.num_args_]), + buffer_table_(new void*[static_data.num_buffers_]), + buffer_infos_(static_data.buffer_infos_), + arg_index_table_(static_data.arg_index_table_), + num_args_(static_data.num_args_), + arg_names_(static_data.arg_names_), + result_names_(static_data.result_names_), + program_shape_(static_data.program_shape_), + hlo_profile_printer_data_(static_data.hlo_profile_printer_data_) { + bool allocate_entry_params = + alloc_mode == AllocMode::ARGS_RESULTS_PROFILES_AND_TEMPS; // Allocate arg and temp buffers. - if (alloc_mode == AllocMode::ARGS_RESULTS_PROFILES_AND_TEMPS) { - alloc_args_ = cpu_function_runtime::MallocContiguousBuffers( - static_data.arg_sizes, static_data.num_args, args_, - /*annotate_initialized=*/false); - } - alloc_temps_ = cpu_function_runtime::MallocContiguousBuffers( - static_data.temp_sizes, static_data.num_temps, temps_, + alloc_buffer_table_ = cpu_function_runtime::MallocContiguousBuffers( + static_data.buffer_infos_, static_data.num_buffers_, + /*allocate_entry_params=*/allocate_entry_params, buffer_table_, /*annotate_initialized=*/true); - - for (int i = 0; i < static_data.num_temps; i++) { - if (static_data.temp_sizes[i] < -1) { - int32 param_number = -(static_data.temp_sizes[i] + 2); - arg_index_to_temp_index_[param_number] = i; + if (allocate_entry_params) { + for (int32 i = 0; i < num_args_; i++) { + args_[i] = buffer_table_[arg_index_table_[i]]; } } - // If Hlo profiling is enabled the generated code expects an appropriately // sized buffer to be passed in as the last argument. If Hlo profiling is // disabled the last function argument is still present in the function // signature, but it is ignored by the generated code and we pass in null for // it. if (hlo_profiling_enabled()) { - profile_counters_ = new int64[static_data.profile_counters_size](); + profile_counters_ = new int64[static_data.profile_counters_size_](); } } bool XlaCompiledCpuFunction::Run() { - // Propagate pointers to the argument buffers into the temps array. Code - // generated by XLA discovers the incoming argument pointers from the temps - // array. + // Propagate pointers to the argument buffers into the buffer table. Code + // generated by XLA discovers the incoming argument pointers from the buffer + // table. for (int32 i = 0; i < num_args_; i++) { - temps_[arg_index_to_temp_index_[i]] = args_[i]; + buffer_table_[arg_index_table_[i]] = args_[i]; } - raw_function_(temps_[result_index_], &run_options_, nullptr, temps_, - profile_counters_); + raw_function_(buffer_table_[result_index_], &run_options_, nullptr, + buffer_table_, profile_counters_); return true; } XlaCompiledCpuFunction::~XlaCompiledCpuFunction() { - cpu_function_runtime::FreeContiguous(alloc_args_); - cpu_function_runtime::FreeContiguous(alloc_temps_); + cpu_function_runtime::FreeContiguous(alloc_buffer_table_); delete[] args_; - delete[] temps_; - delete[] arg_index_to_temp_index_; + delete[] buffer_table_; delete[] profile_counters_; } diff --git a/tensorflow/compiler/tf2xla/xla_compiled_cpu_function.h b/tensorflow/compiler/tf2xla/xla_compiled_cpu_function.h index 27cfb354bf..7dd8c24eb7 100644 --- a/tensorflow/compiler/tf2xla/xla_compiled_cpu_function.h +++ b/tensorflow/compiler/tf2xla/xla_compiled_cpu_function.h @@ -19,6 +19,7 @@ limitations under the License. #include #include +#include "tensorflow/compiler/tf2xla/cpu_function_runtime.h" #include "tensorflow/compiler/xla/executable_run_options.h" #include "tensorflow/core/platform/types.h" @@ -56,46 +57,85 @@ class XlaCompiledCpuFunction { // StaticData represents the state necessary to run an XLA-compiled // function. For JIT this is backed by data in XlaJitCompiledCpuFunction; for // AOT this is backed by data compiled into the object file. - struct StaticData { + // + // The contents of StaticData are XLA-internal implementation details and + // should not be relied on by clients. + // + // TODO(sanjoy): Come up with a cleaner way to express the contraint we want + // here: generated XlaCompiledCpuFunction subclasses should be able to create + // instances of StaticData but only XlaCompiledCpuFunction should be able to + // read from StaticData instances. + class StaticData { + public: + void set_raw_function(RawFunction raw_function) { + raw_function_ = raw_function; + } + void set_buffer_infos( + const cpu_function_runtime::BufferInfo* buffer_infos) { + buffer_infos_ = buffer_infos; + } + void set_num_buffers(size_t num_buffers) { num_buffers_ = num_buffers; } + void set_arg_index_table(const int32* arg_index_table) { + arg_index_table_ = arg_index_table; + } + void set_num_args(int64 num_args) { num_args_ = num_args; } + void set_result_index(size_t result_index) { result_index_ = result_index; } + void set_arg_names(const char** arg_names) { arg_names_ = arg_names; } + void set_result_names(const char** result_names) { + result_names_ = result_names; + } + void set_program_shape(const xla::ProgramShape* program_shape) { + program_shape_ = program_shape; + } + const xla::HloProfilePrinterData* hlo_profile_printer_data() const { + return hlo_profile_printer_data_; + } + void set_hlo_profile_printer_data( + const xla::HloProfilePrinterData* hlo_profile_printer_data) { + hlo_profile_printer_data_ = hlo_profile_printer_data; + } + void set_profile_counters_size(int64 profile_counters_size) { + profile_counters_size_ = profile_counters_size; + } + + private: // The raw function to call. - RawFunction raw_function; - - // Cardinality and size of arg buffers. - const intptr_t* arg_sizes = nullptr; - size_t num_args = 0; - - // Cardinality and size of temp buffers. - // - // If temp_sizes[i] >= 0 then the i'th temp is a regular temporary buffer. - // - // If temp_sizes[i] == -1 then the i'th temp is a constant buffer. The - // corresponding entry in the temp buffer array needs to be set to null. - // - // If temp_sizes[i] < -1 then the i'th temp is the entry parameter - // -(temp_sizes[i] + 2). - const intptr_t* temp_sizes = nullptr; - size_t num_temps = 0; + RawFunction raw_function_; + + // Contains information about the buffers used by the XLA computation. + const cpu_function_runtime::BufferInfo* buffer_infos_ = nullptr; + size_t num_buffers_ = 0; + + // Entry parameter i is described by + // buffer_infos[arg_index_table[i]]. + const int32* arg_index_table_ = nullptr; + + // There are num_args entry parameters. + int64 num_args_ = 0; // The 0-based index of the result tuple, in the temp buffers. - size_t result_index = 0; + size_t result_index_ = 0; // [Optional] Arrays of arg and result names. These are arrays of C-style // strings, where the array is terminated by nullptr. - const char** arg_names = nullptr; - const char** result_names = nullptr; + const char** arg_names_ = nullptr; + const char** result_names_ = nullptr; // [Optional] Arg and result shapes. - const xla::ProgramShape* program_shape = nullptr; + const xla::ProgramShape* program_shape_ = nullptr; // [Optional] Profile printer data. Null if profiling is disabled. - const xla::HloProfilePrinterData* hlo_profile_printer_data = nullptr; + const xla::HloProfilePrinterData* hlo_profile_printer_data_ = nullptr; // [Optional] The number of profile counters expected in the profile counter // buffer by the generated code and hlo_profile_printer. 0 if profiling is // disabled. This information is already present in // hlo_profile_printer_data but xla::HloProfilePrinterData is forward // declared so we don't have access to that information here. - int64 profile_counters_size = 0; + int64 profile_counters_size_ = 0; + + // Only XlaCompiledCpuFunction is allowed to read the above fields. + friend class XlaCompiledCpuFunction; }; // AllocMode controls the buffer allocation mode. @@ -137,6 +177,9 @@ class XlaCompiledCpuFunction { // Returns the underlying array of argument buffers, where args()[I] is the // buffer for the positional argument at index I. + // + // TODO(sanjoy): We should retire this in favor of explicit accessors. That + // would let us elide the args_ array. void** args() { return args_; } const void* const* args() const { return args_; } @@ -144,6 +187,18 @@ class XlaCompiledCpuFunction { void* arg_data(size_t index) { return args_[index]; } const void* arg_data(size_t index) const { return args_[index]; } + int num_args() const { return num_args_; } + + // Returns the size of entry parameter `idx`. + // + // There is a static version of this method on tfcompile generated subclasses + // of XlaCompiledCpuFunction, but try to prefer this when possible since it + // works both for XlaJitCompiledCpuFunction and AOT compiled subclasses. + int arg_size(int idx) const { + assert(idx < num_args()); + return buffer_infos_[arg_index_table_[idx]].size(); + } + // Sets the buffer for the positional argument at the given `index` to `data`. // Must be called before Run to have an effect. May be called under any // AllocMode; if the AllocMode is RESULTS_AND_TEMPS_ONLY, this method must be @@ -165,9 +220,9 @@ class XlaCompiledCpuFunction { // Returns the underlying array of result buffers, where results()[I] is the // buffer for the positional result at index I. - void** results() { return static_cast(temps_[result_index_]); } + void** results() { return static_cast(buffer_table_[result_index_]); } const void* const* results() const { - return static_cast(temps_[result_index_]); + return static_cast(buffer_table_[result_index_]); } // Profile counters for this XLA computation. @@ -225,25 +280,31 @@ class XlaCompiledCpuFunction { const RawFunction raw_function_; const size_t result_index_; - // Arrays of argument and temp buffers; entries in args_ may be overwritten by - // the user. - void** args_ = nullptr; - void** temps_ = nullptr; + // Array of argument buffers; entries in args_ may be overwritten by the user. + void** const args_; + + // Array containing pointers to argument and temp buffers (slots corresponding + // to constant and on-stack buffers are null). + void** const buffer_table_; + + // Describes the buffers used by the XLA computation. + const cpu_function_runtime::BufferInfo* const buffer_infos_; - // Argument i needs to be placed in temps_[arg_index_to_temp_index_[i]] for - // XLA generated code to be able to find it. + // Argument i needs to be placed in buffer_table_[arg_index_to_temp_index_[i]] + // for XLA generated code to be able to find it. // // For now we need to keep around the args_ array because there is code that // depends on args() returning a void**. However, in the future we may remove - // args_ in favor of using temps_ as the sole storage for the arguments. - int32* arg_index_to_temp_index_; + // args_ in favor of using buffer_table_ as the sole storage for the + // arguments. + const int32* const arg_index_table_; // The number of incoming arguments. - int32 num_args_; + const int32 num_args_; - // Backing memory for individual arg and temp buffers. - void* alloc_args_ = nullptr; - void* alloc_temps_ = nullptr; + // Backing memory for buffer_table_ and args_, the latter depending on + // AllocMode. + void* alloc_buffer_table_ = nullptr; // Backing memory for profiling counters. int64* profile_counters_ = nullptr; diff --git a/tensorflow/compiler/tf2xla/xla_jit_compiled_cpu_function.cc b/tensorflow/compiler/tf2xla/xla_jit_compiled_cpu_function.cc index 114a9241bd..86a78ee429 100644 --- a/tensorflow/compiler/tf2xla/xla_jit_compiled_cpu_function.cc +++ b/tensorflow/compiler/tf2xla/xla_jit_compiled_cpu_function.cc @@ -24,6 +24,7 @@ limitations under the License. #include "tensorflow/compiler/xla/client/client_library.h" #include "tensorflow/compiler/xla/client/local_client.h" #include "tensorflow/compiler/xla/client/xla_computation.h" +#include "tensorflow/compiler/xla/service/cpu/buffer_info_util.h" #include "tensorflow/compiler/xla/service/cpu/cpu_executable.h" #include "tensorflow/compiler/xla/shape_util.h" #include "tensorflow/compiler/xla/xla_data.pb.h" @@ -35,45 +36,6 @@ limitations under the License. namespace tensorflow { namespace { - -// Returns a vector of positional argument buffer sizes. -xla::StatusOr> ComputeArgSizes( - const xla::ProgramShape& program_shape) { - std::vector arg_sizes; - const size_t num_args = program_shape.parameters_size(); - arg_sizes.reserve(num_args); - for (int i = 0; i < num_args; ++i) { - const xla::Shape& arg_shape = program_shape.parameters(i); - constexpr size_t kPointerSize = sizeof(void*); - arg_sizes.push_back(xla::ShapeUtil::ByteSizeOf(arg_shape, kPointerSize)); - } - return std::move(arg_sizes); -} - -// Returns a vector of positional temporary buffer sizes. -xla::StatusOr> ComputeTempSizes( - const xla::BufferAssignment& buffer_assignment) { - const std::vector& allocations = - buffer_assignment.Allocations(); - std::vector temp_sizes; - temp_sizes.reserve(allocations.size()); - for (const xla::BufferAllocation& allocation : allocations) { - if (allocation.is_constant() || allocation.is_thread_local()) { - // Constants are lowered to globals. Thread locals are lowered to - // allocas. - temp_sizes.push_back(-1); - } else if (allocation.is_entry_computation_parameter()) { - // Entry computation parameters need some preprocessing in - // XlaCompiledCpuFunction::Run. See the comment on - // XlaCompiledCpuFunction::StaticData::temp_sizes. - temp_sizes.push_back(-allocation.parameter_number() - 2); - } else { - temp_sizes.push_back(allocation.size()); - } - } - return std::move(temp_sizes); -} - // Returns the index of the result in the temp buffers. xla::StatusOr ComputeResultIndex( const xla::BufferAssignment& buffer_assignment) { @@ -157,11 +119,11 @@ XlaJitCompiledCpuFunction::Compile( const xla::BufferAssignment& buffer_assignment = cpu_executable->buffer_assignment(); - // Compute buffer sizes and the result index, needed to run the raw function. - TF_ASSIGN_OR_RETURN(std::vector arg_sizes, - ComputeArgSizes(*program_shape)); - TF_ASSIGN_OR_RETURN(std::vector temp_sizes, - ComputeTempSizes(buffer_assignment)); + // Compute buffer infos and the result index, needed to run the raw function. + std::vector buffer_infos = + xla::cpu::CreateBufferInfosFromBufferAssignment(buffer_assignment); + std::vector arg_index_table = + xla::cpu::CreateArgIndexTableFromBufferInfos(buffer_infos); TF_ASSIGN_OR_RETURN(size_t result_index, ComputeResultIndex(buffer_assignment)); @@ -169,28 +131,28 @@ XlaJitCompiledCpuFunction::Compile( new XlaJitCompiledCpuFunction); XlaJitCompiledCpuFunction* jit = jit_unique_ptr.get(); jit->executable_ = std::move(executable); - jit->arg_sizes_ = std::move(arg_sizes); - jit->temp_sizes_ = std::move(temp_sizes); + jit->buffer_infos_ = std::move(buffer_infos); + jit->arg_index_table_ = std::move(arg_index_table); jit->program_shape_ = std::move(program_shape); - jit->static_data_.raw_function = std::move(raw_function); - jit->static_data_.arg_sizes = jit->arg_sizes_.data(); - jit->static_data_.num_args = jit->arg_sizes_.size(); - jit->static_data_.temp_sizes = jit->temp_sizes_.data(); - jit->static_data_.num_temps = jit->temp_sizes_.size(); - jit->static_data_.result_index = result_index; + jit->static_data_.set_raw_function(raw_function); + jit->static_data_.set_buffer_infos(jit->buffer_infos_.data()); + jit->static_data_.set_num_buffers(jit->buffer_infos_.size()); + jit->static_data_.set_arg_index_table(jit->arg_index_table_.data()); + jit->static_data_.set_num_args(jit->arg_index_table_.size()); + jit->static_data_.set_result_index(result_index); // Optional metadata is collected and set below. CollectNames(config.feed(), &jit->nonempty_arg_names_, &jit->arg_names_); CollectNames(config.fetch(), &jit->nonempty_result_names_, &jit->result_names_); - jit->static_data_.arg_names = jit->arg_names_.data(); - jit->static_data_.result_names = jit->result_names_.data(); - jit->static_data_.program_shape = jit->program_shape_.get(); + jit->static_data_.set_arg_names(jit->arg_names_.data()); + jit->static_data_.set_result_names(jit->result_names_.data()); + jit->static_data_.set_program_shape(jit->program_shape_.get()); if (cpu_executable->hlo_profiling_enabled()) { - jit->static_data_.hlo_profile_printer_data = - &cpu_executable->hlo_profile_printer_data(); - jit->static_data_.profile_counters_size = - cpu_executable->hlo_profile_printer_data().profile_counters_size(); + jit->static_data_.set_hlo_profile_printer_data( + &cpu_executable->hlo_profile_printer_data()); + jit->static_data_.set_profile_counters_size( + cpu_executable->hlo_profile_printer_data().profile_counters_size()); } return std::move(jit_unique_ptr); diff --git a/tensorflow/compiler/tf2xla/xla_jit_compiled_cpu_function.h b/tensorflow/compiler/tf2xla/xla_jit_compiled_cpu_function.h index af307ae4ef..d3c8f22a80 100644 --- a/tensorflow/compiler/tf2xla/xla_jit_compiled_cpu_function.h +++ b/tensorflow/compiler/tf2xla/xla_jit_compiled_cpu_function.h @@ -66,9 +66,11 @@ class XlaJitCompiledCpuFunction { // The static data is backed by the rest of the state in this class. XlaCompiledCpuFunction::StaticData static_data_; - // The backing arrays of arg and temp buffer sizes. - std::vector arg_sizes_; - std::vector temp_sizes_; + // The backing array for buffer infos. + std::vector buffer_infos_; + + // The backing array for the arg index table. + std::vector arg_index_table_; // The backing arrays of arg and result names. We hold the actual strings in // nonempty_*_names_, and hold arrays of pointers in *_names_ for the static diff --git a/tensorflow/compiler/xla/service/compiler.h b/tensorflow/compiler/xla/service/compiler.h index 99abb9bae3..34f7fe12ca 100644 --- a/tensorflow/compiler/xla/service/compiler.h +++ b/tensorflow/compiler/xla/service/compiler.h @@ -48,11 +48,6 @@ namespace xla { // compuation. using ObjectFileData = std::vector; -// Contains the buffer sizes information needed to allocate buffers to execute -// an ahead-of-time computation. Entries which contain -1 designate a parameter -// which should be skipped over during allocation. -using BufferSizes = std::vector; - // Abstract superclass describing the result of an ahead-of-time compilation. class AotCompilationResult { public: diff --git a/tensorflow/compiler/xla/service/cpu/BUILD b/tensorflow/compiler/xla/service/cpu/BUILD index 504b61d134..3efe3e2f93 100644 --- a/tensorflow/compiler/xla/service/cpu/BUILD +++ b/tensorflow/compiler/xla/service/cpu/BUILD @@ -54,12 +54,24 @@ cc_library( alwayslink = True, # Contains per-platform transfer manager registration ) +cc_library( + name = "buffer_info_util", + srcs = ["buffer_info_util.cc"], + hdrs = ["buffer_info_util.h"], + deps = [ + "//tensorflow/compiler/tf2xla:cpu_function_runtime", + "//tensorflow/compiler/xla/service:buffer_assignment", + "//tensorflow/core:lib", + ], +) + cc_library( name = "cpu_compiler", srcs = ["cpu_compiler.cc"], hdrs = ["cpu_compiler.h"], deps = [ ":compiler_functor", + ":buffer_info_util", ":conv_canonicalization", ":cpu_copy_insertion", ":cpu_executable", @@ -73,6 +85,7 @@ cc_library( ":ir_emitter", ":parallel_task_assignment", ":simple_orc_jit", + "//tensorflow/compiler/tf2xla:cpu_function_runtime", "//tensorflow/compiler/xla:literal", "//tensorflow/compiler/xla:protobuf_util", "//tensorflow/compiler/xla:status_macros", diff --git a/tensorflow/compiler/xla/service/cpu/buffer_info_util.cc b/tensorflow/compiler/xla/service/cpu/buffer_info_util.cc new file mode 100644 index 0000000000..408fe0f5bf --- /dev/null +++ b/tensorflow/compiler/xla/service/cpu/buffer_info_util.cc @@ -0,0 +1,57 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#include "tensorflow/compiler/xla/service/cpu/buffer_info_util.h" + +namespace xla { +namespace cpu { + +using BufferInfo = ::tensorflow::cpu_function_runtime::BufferInfo; + +std::vector CreateBufferInfosFromBufferAssignment( + const BufferAssignment& buffer_assignment) { + std::vector buffer_infos; + for (const BufferAllocation& allocation : buffer_assignment.Allocations()) { + if (allocation.is_thread_local()) { + buffer_infos.push_back(BufferInfo::MakeOnStackBuffer(allocation.size())); + } else if (allocation.is_constant()) { + buffer_infos.push_back(BufferInfo::MakeConstant(allocation.size())); + } else if (allocation.is_entry_computation_parameter()) { + buffer_infos.push_back(BufferInfo::MakeEntryParameter( + /*size=*/allocation.size(), + /*param_number=*/allocation.parameter_number())); + } else { + buffer_infos.push_back(BufferInfo::MakeTempBuffer(allocation.size())); + } + } + return buffer_infos; +} + +std::vector CreateArgIndexTableFromBufferInfos( + tensorflow::gtl::ArraySlice buffer_infos) { + std::vector result; + for (int64 i = 0; i < buffer_infos.size(); i++) { + if (buffer_infos[i].is_entry_parameter()) { + if (buffer_infos[i].entry_parameter_number() >= result.size()) { + result.resize(buffer_infos[i].entry_parameter_number() + 1); + } + result[buffer_infos[i].entry_parameter_number()] = i; + } + } + return result; +} + +} // namespace cpu +} // namespace xla diff --git a/tensorflow/compiler/xla/service/cpu/buffer_info_util.h b/tensorflow/compiler/xla/service/cpu/buffer_info_util.h new file mode 100644 index 0000000000..05de70c726 --- /dev/null +++ b/tensorflow/compiler/xla/service/cpu/buffer_info_util.h @@ -0,0 +1,42 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_COMPILER_XLA_SERVICE_CPU_BUFFER_INFO_UTIL_H_ +#define TENSORFLOW_COMPILER_XLA_SERVICE_CPU_BUFFER_INFO_UTIL_H_ + +#include "tensorflow/compiler/tf2xla/cpu_function_runtime.h" +#include "tensorflow/compiler/xla/service/buffer_assignment.h" +#include "tensorflow/core/lib/gtl/array_slice.h" + +namespace xla { +namespace cpu { +// Creates and returns a list of BufferInfo instances containing relevant +// information from `buffer_assignment`. +std::vector<::tensorflow::cpu_function_runtime::BufferInfo> +CreateBufferInfosFromBufferAssignment( + const BufferAssignment& buffer_assignment); + +// Creates and returns a table containing the mapping from entry computation +// parameters to buffer allocation indices. +// +// If this function returns V then entry parameter i has buffer allocation index +// V[i]. +std::vector CreateArgIndexTableFromBufferInfos( + tensorflow::gtl::ArraySlice<::tensorflow::cpu_function_runtime::BufferInfo> + buffer_infos); +} // namespace cpu +} // namespace xla + +#endif // TENSORFLOW_COMPILER_XLA_SERVICE_CPU_BUFFER_INFO_UTIL_H_ diff --git a/tensorflow/compiler/xla/service/cpu/cpu_compiler.cc b/tensorflow/compiler/xla/service/cpu/cpu_compiler.cc index 8cbe9a1b0d..2df959c4dc 100644 --- a/tensorflow/compiler/xla/service/cpu/cpu_compiler.cc +++ b/tensorflow/compiler/xla/service/cpu/cpu_compiler.cc @@ -50,6 +50,7 @@ limitations under the License. #include "tensorflow/compiler/xla/service/buffer_liveness.h" #include "tensorflow/compiler/xla/service/call_inliner.h" #include "tensorflow/compiler/xla/service/conditional_simplifier.h" +#include "tensorflow/compiler/xla/service/cpu/buffer_info_util.h" #include "tensorflow/compiler/xla/service/cpu/compiler_functor.h" #include "tensorflow/compiler/xla/service/cpu/conv_canonicalization.h" #include "tensorflow/compiler/xla/service/cpu/cpu_copy_insertion.h" @@ -103,6 +104,7 @@ limitations under the License. namespace xla { namespace cpu { +using BufferInfo = ::tensorflow::cpu_function_runtime::BufferInfo; CpuAotCompilationOptions::CpuAotCompilationOptions( string triple, string cpu_name, string features, string entry_point_name, @@ -120,11 +122,11 @@ se::Platform::Id CpuAotCompilationOptions::PlatformId() const { } CpuAotCompilationResult::CpuAotCompilationResult( - ObjectFileData object_file_data, BufferSizes buffer_sizes, + ObjectFileData object_file_data, std::vector buffer_infos, int64 result_buffer_index, std::unique_ptr hlo_profile_printer_data) : object_file_data_(std::move(object_file_data)), - buffer_sizes_(std::move(buffer_sizes)), + buffer_infos_(std::move(buffer_infos)), result_buffer_index_(result_buffer_index), hlo_profile_printer_data_(std::move(hlo_profile_printer_data)) {} @@ -838,39 +840,14 @@ CpuCompiler::CompileAheadOfTime(std::vector> modules, ObjectFileData object_file_data(object_file->getBufferStart(), object_file->getBufferEnd()); - BufferSizes buffer_sizes; - for (const BufferAllocation& allocation : assignment->Allocations()) { - // Callers don't need to allocate anything for thread-local temporary - // buffers. They are lowered to allocas. - if (allocation.is_thread_local()) { - buffer_sizes.push_back(-1); - continue; - } - - // Callers don't need to allocate anything for constant buffers. They are - // lowered to globals. - if (allocation.is_constant()) { - buffer_sizes.push_back(-1); - continue; - } - - // Callers don't need to allocate anything for entry computation buffers, - // but they do need to stash the pointer to the entry computation buffer - // in the temp buffer table. See the comment on - // XlaCompiledCpuFunction::StaticData::temp_sizes. - if (allocation.is_entry_computation_parameter()) { - buffer_sizes.push_back(-allocation.parameter_number() - 2); - continue; - } - - buffer_sizes.push_back(allocation.size()); - } + std::vector buffer_infos = + CreateBufferInfosFromBufferAssignment(*assignment); TF_ASSIGN_OR_RETURN(const BufferAllocation::Slice result_slice, assignment->GetUniqueTopLevelOutputSlice()); results.emplace_back(MakeUnique( - std::move(object_file_data), std::move(buffer_sizes), + std::move(object_file_data), std::move(buffer_infos), result_slice.index(), std::move(hlo_profile_printer_data))); } diff --git a/tensorflow/compiler/xla/service/cpu/cpu_compiler.h b/tensorflow/compiler/xla/service/cpu/cpu_compiler.h index e56f9f0113..04e1c48872 100644 --- a/tensorflow/compiler/xla/service/cpu/cpu_compiler.h +++ b/tensorflow/compiler/xla/service/cpu/cpu_compiler.h @@ -19,6 +19,7 @@ limitations under the License. #include #include "llvm/Target/TargetMachine.h" +#include "tensorflow/compiler/tf2xla/cpu_function_runtime.h" #include "tensorflow/compiler/xla/service/executable.h" #include "tensorflow/compiler/xla/service/hlo_module.h" #include "tensorflow/compiler/xla/service/llvm_compiler.h" @@ -78,7 +79,8 @@ class CpuAotCompilationOptions : public AotCompilationOptions { class CpuAotCompilationResult : public AotCompilationResult { public: CpuAotCompilationResult( - ObjectFileData object_file_data, BufferSizes buffer_sizes, + ObjectFileData object_file_data, + std::vector<::tensorflow::cpu_function_runtime::BufferInfo> buffer_infos, int64 result_buffer_index, std::unique_ptr hlo_profile_printer_data); ~CpuAotCompilationResult(); @@ -88,17 +90,20 @@ class CpuAotCompilationResult : public AotCompilationResult { } const ObjectFileData& object_file_data() const { return object_file_data_; } - const BufferSizes& buffer_sizes() const { return buffer_sizes_; } + const std::vector<::tensorflow::cpu_function_runtime::BufferInfo>& + buffer_infos() const { + return buffer_infos_; + } int64 result_buffer_index() const { return result_buffer_index_; } private: // Contains the compiled computation: an object file. const ObjectFileData object_file_data_; - // The list of buffer sizes which should be allocated in order to execute the - // compiled computation. These buffers are used for temporary buffers used - // ephemerally during computation as well as the output result. - const BufferSizes buffer_sizes_; + // A list of BufferInfo objects describing the buffers used by the XLA + // computation. + const std::vector<::tensorflow::cpu_function_runtime::BufferInfo> + buffer_infos_; // Contains which buffer index into |buffer_sizes| was designated to the // result of the computation. This buffer should be passed into the output diff --git a/tensorflow/compiler/xla/tests/local_client_aot_test_helper.cc b/tensorflow/compiler/xla/tests/local_client_aot_test_helper.cc index e310966d8b..60eb21aafd 100644 --- a/tensorflow/compiler/xla/tests/local_client_aot_test_helper.cc +++ b/tensorflow/compiler/xla/tests/local_client_aot_test_helper.cc @@ -92,10 +92,10 @@ int main(int argc, char** argv) { // It's lame to hard-code the buffer assignments, but we need // local_client_aot_test.cc to be able to easily invoke the function. CHECK_EQ(result->result_buffer_index(), 1); - CHECK_EQ(result->buffer_sizes().size(), 3); - CHECK_EQ(result->buffer_sizes()[0], -2); // param buffer - CHECK_EQ(result->buffer_sizes()[1], sizeof(float)); // result buffer - CHECK_EQ(result->buffer_sizes()[2], -1); // const buffer + CHECK_EQ(result->buffer_infos().size(), 3); + CHECK(result->buffer_infos()[0].is_entry_parameter()); // param buffer + CHECK_EQ(result->buffer_infos()[1].size(), sizeof(float)); // result buffer + CHECK(result->buffer_infos()[2].is_constant()); // const buffer if (triple.isOSBinFormatELF()) { // Check the ELF magic. CHECK_EQ(result->object_file_data()[0], 0x7F); -- GitLab From be3f9abf85cb8f0a80aa034ec8bfb6b5844fd3e6 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Fri, 10 Aug 2018 16:03:14 -0700 Subject: [PATCH 370/437] Internal change. PiperOrigin-RevId: 208283367 --- tensorflow/tensorflow.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl index 39db840884..ca9c0d0aae 100644 --- a/tensorflow/tensorflow.bzl +++ b/tensorflow/tensorflow.bzl @@ -27,7 +27,7 @@ load( ) load( "//third_party/mkl_dnn:build_defs.bzl", - "if_mkl_open_source_only", + "if_mkl_open_source_only" ) def register_extension_info(**kwargs): pass -- GitLab From bdc3b303f1ba5b22cac1df0b605ad0e0c45421f1 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Fri, 10 Aug 2018 16:03:54 -0700 Subject: [PATCH 371/437] Use shared memory for NNAPI input and output. PiperOrigin-RevId: 208283489 --- .../lite/delegates/nnapi/nnapi_delegate.cc | 81 ++++++++++++++++++- .../contrib/lite/nnapi/NeuralNetworksShim.h | 13 +++ 2 files changed, 90 insertions(+), 4 deletions(-) diff --git a/tensorflow/contrib/lite/delegates/nnapi/nnapi_delegate.cc b/tensorflow/contrib/lite/delegates/nnapi/nnapi_delegate.cc index 17fa120cf9..e6cc3dd99c 100644 --- a/tensorflow/contrib/lite/delegates/nnapi/nnapi_delegate.cc +++ b/tensorflow/contrib/lite/delegates/nnapi/nnapi_delegate.cc @@ -27,7 +27,9 @@ limitations under the License. #include "tensorflow/contrib/lite/nnapi/NeuralNetworksShim.h" #ifdef __ANDROID__ +#include #include +#include #endif namespace tflite { @@ -80,6 +82,44 @@ struct NNFreeCompilation { } }; +// Manage NNAPI shared memory handle +class NNMemory { + public: + NNMemory(const char* name, size_t size) { +#ifdef __ANDROID__ + byte_size_ = size; + fd_ = ASharedMemory_create(name, size); + data_ptr_ = reinterpret_cast( + mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd_, 0)); + ANeuralNetworksMemory_createFromFd(size, PROT_READ | PROT_WRITE, fd_, 0, + &nn_memory_handle_); +#endif + } + + ~NNMemory() { +#ifdef __ANDROID__ + if (data_ptr_) { + munmap(data_ptr_, byte_size_); + } + if (nn_memory_handle_) { + ANeuralNetworksMemory_free(nn_memory_handle_); + } + if (fd_ > 0) close(fd_); +#endif + } + + ANeuralNetworksMemory* get_handle() { return nn_memory_handle_; } + uint8_t* get_data_ptr() { return data_ptr_; } + + private: +#ifdef __ANDROID__ + int fd_ = 0; + size_t byte_size_ = 0; +#endif + uint8_t* data_ptr_ = nullptr; + ANeuralNetworksMemory* nn_memory_handle_ = nullptr; +}; // namespace + // Track tensor indices to NN API tensor indices mapping. class OperandMapping { public: @@ -911,6 +951,8 @@ class NNAPIDelegateKernel { // absolute indices but NN api indices inputs by relative indices. int relative_input_index = 0; int num_optional_tensors = 0; + + size_t input_offset = 0; for (auto absolute_input_index : TfLiteIntArrayView(node->inputs)) { if (absolute_input_index == kOptionalTensor) { num_optional_tensors++; @@ -920,20 +962,28 @@ class NNAPIDelegateKernel { // TODO(miaowang): make sure the delegation works with dequantized weights // as intermediate tensors. if (tensor->allocation_type != kTfLiteMmapRo) { - CHECK_NN(context, ANeuralNetworksExecution_setInput( + // copy data to pre-allocated shared memory. + memcpy(nn_input_memory_->get_data_ptr() + input_offset, + tensor->data.raw, tensor->bytes); + CHECK_NN(context, ANeuralNetworksExecution_setInputFromMemory( execution, relative_input_index, nullptr, - tensor->data.raw, tensor->bytes)); + nn_input_memory_->get_handle(), input_offset, + tensor->bytes)); + input_offset += tensor->bytes; relative_input_index++; } } // Set the output tensor buffers. int relative_output_index = 0; + size_t output_offset = 0; for (auto output_index : TfLiteIntArrayView(node->outputs)) { TfLiteTensor* tensor = &context->tensors[output_index]; - CHECK_NN(context, ANeuralNetworksExecution_setOutput( + CHECK_NN(context, ANeuralNetworksExecution_setOutputFromMemory( execution, relative_output_index, nullptr, - tensor->data.raw, tensor->bytes)); + nn_output_memory_->get_handle(), output_offset, + tensor->bytes)); + output_offset += tensor->bytes; relative_output_index++; } @@ -957,6 +1007,15 @@ class NNAPIDelegateKernel { ANeuralNetworksEvent_free(event); ANeuralNetworksExecution_free(execution); + // copy results from shared memory to the destination. + output_offset = 0; + for (auto output_index : TfLiteIntArrayView(node->outputs)) { + TfLiteTensor* tensor = &context->tensors[output_index]; + memcpy(tensor->data.raw, + nn_output_memory_->get_data_ptr() + output_offset, tensor->bytes); + output_offset += tensor->bytes; + } + return kTfLiteOk; } @@ -974,6 +1033,9 @@ class NNAPIDelegateKernel { std::vector model_state_inputs_; std::vector model_state_tfl_outputs_; + std::unique_ptr nn_input_memory_; + std::unique_ptr nn_output_memory_; + TfLiteStatus AddOpsAndTensors(TfLiteContext* context) { // The operand builder allows creating a single op. We create it at this // reduced power position rather than in the for loop to avoid reallocating @@ -1024,21 +1086,27 @@ class NNAPIDelegateKernel { inputs.reserve(input_tensors->size); std::vector outputs; outputs.reserve(output_tensors->size); + + size_t total_input_byte_size = 0; // Make the TensorFlow lite inputs and outputs to ann_indices. for (int i : TfLiteIntArrayView(input_tensors)) { // Constant tensors are not NNAPI inputs. if (i != kOptionalTensor && context->tensors[i].allocation_type != kTfLiteMmapRo) { inputs.push_back(operand_mapping_.lite_index_to_ann(i)); + total_input_byte_size += context->tensors[i].bytes; } } + // Add state input tensors as model inputs for (int i : model_state_inputs_) { inputs.push_back(i); } + size_t total_output_byte_size = 0; for (int i : TfLiteIntArrayView(output_tensors)) { outputs.push_back(operand_mapping_.lite_index_to_ann(i)); + total_output_byte_size += context->tensors[i].bytes; } // Tell ANN to declare inputs/outputs @@ -1048,6 +1116,11 @@ class NNAPIDelegateKernel { // Finalize the model CHECK_NN(context, ANeuralNetworksModel_finish(nn_model_.get())); + // Create shared memory pool for inputs and outputs. + nn_input_memory_.reset(new NNMemory("input_pool", total_input_byte_size)); + nn_output_memory_.reset( + new NNMemory("output_pool", total_output_byte_size)); + return kTfLiteOk; } }; diff --git a/tensorflow/contrib/lite/nnapi/NeuralNetworksShim.h b/tensorflow/contrib/lite/nnapi/NeuralNetworksShim.h index becd1f615f..42b8163445 100644 --- a/tensorflow/contrib/lite/nnapi/NeuralNetworksShim.h +++ b/tensorflow/contrib/lite/nnapi/NeuralNetworksShim.h @@ -44,6 +44,19 @@ inline void* loadLibrary(const char* name) { return handle; } +typedef int (*ASharedMemory_create_fn)(const char* name, size_t size); + +// ASharedMemory_create was added in Android 8.0, so safe to use with NNAPI +// which was added in 8.1. +inline int ASharedMemory_create(const char* name, size_t size) { + static void* handle = loadLibrary("libandroid.so"); + static ASharedMemory_create_fn fn = + handle != nullptr ? reinterpret_cast( + dlsym(handle, "ASharedMemory_create")) + : nullptr; + return fn(name, size); +} + inline void* getLibraryHandle() { static void* handle = loadLibrary("libneuralnetworks.so"); return handle; -- GitLab From 831e7ba618618ba4b5ebcbe2b51077b0e6b247bc Mon Sep 17 00:00:00 2001 From: Clayne Robison Date: Fri, 10 Aug 2018 16:18:13 -0700 Subject: [PATCH 372/437] [Intel MKL] Adding keras pip packages to container builds. --- tensorflow/tools/docker/Dockerfile.devel-mkl | 1 + 1 file changed, 1 insertion(+) diff --git a/tensorflow/tools/docker/Dockerfile.devel-mkl b/tensorflow/tools/docker/Dockerfile.devel-mkl index f0c7118ecb..01d7adf1ee 100755 --- a/tensorflow/tools/docker/Dockerfile.devel-mkl +++ b/tensorflow/tools/docker/Dockerfile.devel-mkl @@ -47,6 +47,7 @@ RUN ${PIP} --no-cache-dir install \ scipy \ sklearn \ pandas \ + keras_applications \ && \ ${PYTHON} -m ipykernel.kernelspec -- GitLab From d63ba5d0f95efb984fdb304db4f2360f25f5a737 Mon Sep 17 00:00:00 2001 From: Tim Shen Date: Fri, 10 Aug 2018 16:51:32 -0700 Subject: [PATCH 373/437] Propagate file-related error messages to the screen. PiperOrigin-RevId: 208290419 --- tensorflow/compiler/xla/tools/replay_computation.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tensorflow/compiler/xla/tools/replay_computation.cc b/tensorflow/compiler/xla/tools/replay_computation.cc index be4cf4318b..b4774233e5 100644 --- a/tensorflow/compiler/xla/tools/replay_computation.cc +++ b/tensorflow/compiler/xla/tools/replay_computation.cc @@ -223,9 +223,13 @@ StatusOr ParseInputFile(const string& filename, const Options& opts) { tensorflow::Env* env = tensorflow::Env::Default(); HloSnapshot snapshot; - if (tensorflow::ReadBinaryProto(env, filename, &snapshot).ok()) { + auto s = tensorflow::ReadBinaryProto(env, filename, &snapshot); + if (s.ok()) { return snapshot; } + if (s.code() == tensorflow::error::NOT_FOUND) { + return s; + } CHECK(opts.use_fake_data) << "Without --use_fake_data, you must pass an HloSnapshot -- HloProto " "and textual HLO don't carry real data."; @@ -258,6 +262,9 @@ int RealMain(tensorflow::gtl::ArraySlice args, const Options& opts) { StatusOr maybe_snapshot = ParseInputFile(arg, opts); if (maybe_snapshot.ok()) { snapshots.push_back(std::move(maybe_snapshot).ValueOrDie()); + } else { + LOG(ERROR) << "Can't handle file " << arg << ": " + << maybe_snapshot.status(); } } -- GitLab From 440d1f9ba06ffa1220a63059afa0ad7bd0e8357e Mon Sep 17 00:00:00 2001 From: Mark Daoust Date: Fri, 10 Aug 2018 16:54:08 -0700 Subject: [PATCH 374/437] delete debug print PiperOrigin-RevId: 208290761 --- tensorflow/tools/docs/doc_generator_visitor.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tensorflow/tools/docs/doc_generator_visitor.py b/tensorflow/tools/docs/doc_generator_visitor.py index e5eaf8cc05..a66f3e4493 100644 --- a/tensorflow/tools/docs/doc_generator_visitor.py +++ b/tensorflow/tools/docs/doc_generator_visitor.py @@ -269,7 +269,6 @@ class DocGeneratorVisitor(object): # Choose the master name with a lexical sort on the tuples returned by # by _score_name. master_name = min(names, key=self._score_name) - print(names, master_name) duplicates[master_name] = names for name in names: -- GitLab From 6c08c6c22a7ccd3adad28fb76269122ab0a1fcaa Mon Sep 17 00:00:00 2001 From: Priya Gupta Date: Fri, 10 Aug 2018 16:59:26 -0700 Subject: [PATCH 375/437] Update minimize loss test to use new API run_steps_on_dataset. Update Step API to also use the new API. PiperOrigin-RevId: 208291393 --- tensorflow/contrib/distribute/python/BUILD | 22 +- .../contrib/distribute/python/combinations.py | 6 +- .../distribute/python/minimize_loss_test.py | 309 +++++++++++++----- .../distribute/python/single_loss_example.py | 10 +- .../contrib/distribute/python/step_fn.py | 67 ++-- .../contrib/distribute/python/step_fn_test.py | 17 +- tensorflow/python/training/optimizer.py | 6 +- 7 files changed, 298 insertions(+), 139 deletions(-) diff --git a/tensorflow/contrib/distribute/python/BUILD b/tensorflow/contrib/distribute/python/BUILD index deb5051435..40a1c1707c 100644 --- a/tensorflow/contrib/distribute/python/BUILD +++ b/tensorflow/contrib/distribute/python/BUILD @@ -466,17 +466,27 @@ py_library( ], ) -cuda_py_test( - name = "step_fn_test", +py_library( + name = "step_fn_test_lib", + testonly = 1, srcs = ["step_fn_test.py"], - additional_deps = [ - ":single_loss_example", + deps = [ ":combinations", - "@absl_py//absl/testing:parameterized", - "//third_party/py/numpy", + ":single_loss_example", + "//tensorflow/contrib/tpu:tpu_lib", "//tensorflow/python:variables", "//tensorflow/python/eager:context", "//tensorflow/python/eager:test", + "//third_party/py/numpy", + "@absl_py//absl/testing:parameterized", + ], +) + +cuda_py_test( + name = "step_fn_test", + srcs = ["step_fn_test.py"], + additional_deps = [ + ":step_fn_test_lib", ], tags = [ "multi_and_single_gpu", diff --git a/tensorflow/contrib/distribute/python/combinations.py b/tensorflow/contrib/distribute/python/combinations.py index 120349481f..e676536d87 100644 --- a/tensorflow/contrib/distribute/python/combinations.py +++ b/tensorflow/contrib/distribute/python/combinations.py @@ -373,12 +373,14 @@ adam_optimizer_v1_fn = NamedObject( "AdamV1", lambda: adam.AdamOptimizer(0.2, epsilon=1)) gradient_descent_optimizer_v1_fn = NamedObject( "GradientDescentV1", lambda: gradient_descent.GradientDescentOptimizer(0.2)) +optimizers_v1 = [adam_optimizer_v1_fn, gradient_descent_optimizer_v1_fn] adam_optimizer_v2_fn = NamedObject( "AdamV2", lambda: adam_v2.AdamOptimizer(0.2, epsilon=1)) gradient_descent_optimizer_v2_fn = NamedObject( "GradientDescentV2", lambda: gradient_descent_v2.GradientDescentOptimizer(0.2)) +optimizers_v2 = [adam_optimizer_v2_fn, gradient_descent_optimizer_v2_fn] graph_and_eager_modes = ["graph", "eager"] @@ -390,7 +392,7 @@ def distributions_and_v1_optimizers(): one_device_strategy, mirrored_strategy_with_gpu_and_cpu, mirrored_strategy_with_two_gpus ], - optimizer_fn=[adam_optimizer_v1_fn, gradient_descent_optimizer_v1_fn]) + optimizer_fn=optimizers_v1) def distributions_and_v2_optimizers(): @@ -400,4 +402,4 @@ def distributions_and_v2_optimizers(): one_device_strategy, mirrored_strategy_with_gpu_and_cpu, mirrored_strategy_with_two_gpus ], - optimizer_fn=[adam_optimizer_v2_fn, gradient_descent_optimizer_v2_fn]) + optimizer_fn=optimizers_v2) diff --git a/tensorflow/contrib/distribute/python/minimize_loss_test.py b/tensorflow/contrib/distribute/python/minimize_loss_test.py index aeeb9553e6..aa7a61bb3b 100644 --- a/tensorflow/contrib/distribute/python/minimize_loss_test.py +++ b/tensorflow/contrib/distribute/python/minimize_loss_test.py @@ -25,11 +25,13 @@ from tensorflow.contrib.distribute.python import combinations from tensorflow.contrib.distribute.python import mirrored_strategy from tensorflow.contrib.distribute.python.single_loss_example import batchnorm_example from tensorflow.contrib.distribute.python.single_loss_example import minimize_loss_example -from tensorflow.contrib.tpu.python.tpu import tpu from tensorflow.python.data.ops import dataset_ops from tensorflow.python.eager import context from tensorflow.python.eager import test +from tensorflow.python.framework import constant_op from tensorflow.python.framework import ops +from tensorflow.python.layers import core +from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import variable_scope @@ -43,32 +45,60 @@ class MinimizeLossStepTest(test.TestCase, parameterized.TestCase): combinations.times( combinations.distributions_and_v1_optimizers(), combinations.combine(mode=["graph"], use_callable_loss=[True, False]) - + combinations.combine(mode=["eager"], use_callable_loss=[True]), - combinations.combine(is_tpu=[False])) + combinations.combine( - distribution=[combinations.tpu_strategy], - optimizer_fn=[ - combinations.adam_optimizer_v1_fn, - # TODO(isaprykin): Make Adam v2 work with while_loops - # and TPUs. - ], - mode=["graph"], - use_callable_loss=[False], - is_tpu=[True])) - def testTrainNetwork(self, distribution, optimizer_fn, use_callable_loss, - is_tpu): - # TODO(priyag): Remove this once the step TPU Strategy is stable. - if is_tpu: - self.skipTest("TPU tests are WIP.") + + combinations.combine(mode=["eager"], use_callable_loss=[True])) + + combinations.combine( + distribution=[combinations.tpu_strategy], + optimizer_fn=combinations.optimizers_v1, + mode=["graph"], + use_callable_loss=[True, False])) + def testTrainNetwork(self, distribution, optimizer_fn, use_callable_loss): + with distribution.scope(): + model_fn, dataset_fn, layer = minimize_loss_example( + optimizer_fn, use_bias=True, use_callable_loss=use_callable_loss) + + def step_fn(ctx, inputs): + del ctx # Unused + return distribution.group( + distribution.call_for_each_tower( + model_fn, inputs, run_concurrently=layer.built)) + + iterator = distribution.distribute_dataset( + dataset_fn).make_one_shot_iterator() + + def run_step(): + return distribution.run_steps_on_dataset( + step_fn, iterator, iterations=2).run_op + + self.evaluate(distribution.initialize()) + if not context.executing_eagerly(): + with self.test_session() as sess: + run_step = sess.make_callable(run_step()) + self.evaluate(variables_lib.global_variables_initializer()) + + weights, biases = [], [] + for _ in range(5): + run_step() + weights.append(self.evaluate(layer.kernel)) + biases.append(self.evaluate(layer.bias)) + + self.evaluate(distribution.finalize()) + + error = abs(numpy.add(numpy.squeeze(weights), numpy.squeeze(biases)) - 1) + is_not_increasing = all(y <= x for x, y in zip(error, error[1:])) + self.assertTrue(is_not_increasing) + + @combinations.generate( + combinations.times( + combinations.distributions_and_v1_optimizers(), + combinations.combine(mode=["graph"], use_callable_loss=[True, False]) + + combinations.combine(mode=["eager"], use_callable_loss=[True]))) + def testTrainNetworkByCallForEachTower(self, distribution, optimizer_fn, + use_callable_loss): with distribution.scope(): model_fn, dataset_fn, layer = minimize_loss_example( optimizer_fn, use_bias=True, use_callable_loss=use_callable_loss) - # TODO(isaprykin): Eliminate `is_tpu`. Probably add a - # `DistributionStrategy.create_monitor` so that each DistributionStrategy - # could influence its training loop. That method would return an instance - # of Monitor. TPUMonitor would execute tpu.initialize_system() and - # tpu.shutdown_system(). iterator = distribution.distribute_dataset( dataset_fn).make_one_shot_iterator() @@ -79,8 +109,6 @@ class MinimizeLossStepTest(test.TestCase, parameterized.TestCase): if not context.executing_eagerly(): with self.test_session() as sess: - if is_tpu: - sess.run(tpu.initialize_system()) run_step = sess.make_callable(run_step()) self.evaluate(variables_lib.global_variables_initializer()) @@ -91,10 +119,6 @@ class MinimizeLossStepTest(test.TestCase, parameterized.TestCase): weights.append(self.evaluate(layer.kernel)) biases.append(self.evaluate(layer.bias)) - if is_tpu: - with self.test_session() as sess: - sess.run(tpu.shutdown_system()) - error = abs(numpy.add(numpy.squeeze(weights), numpy.squeeze(biases)) - 1) is_not_increasing = all(y <= x for x, y in zip(error, error[1:])) self.assertTrue(is_not_increasing) @@ -103,22 +127,12 @@ class MinimizeLossStepTest(test.TestCase, parameterized.TestCase): combinations.times( combinations.distributions_and_v1_optimizers() + combinations.distributions_and_v2_optimizers(), - combinations.combine(mode=["graph", "eager"], is_tpu=[False])) + + combinations.combine(mode=["graph", "eager"])) + combinations.combine( distribution=[combinations.tpu_strategy], - optimizer_fn=[ - combinations.adam_optimizer_v1_fn, - combinations.gradient_descent_optimizer_v1_fn, - combinations.gradient_descent_optimizer_v2_fn, - ], - mode=["graph"], - is_tpu=[True])) - - def testOptimizerInsideModelFn(self, distribution, optimizer_fn, is_tpu): - # TODO(priyag): Remove this once the step TPU Strategy is stable. - if is_tpu: - self.skipTest("TPU tests are WIP.") - + optimizer_fn=combinations.optimizers_v1+combinations.optimizers_v2, + mode=["graph"])) + def testOptimizerInsideModelFn(self, distribution, optimizer_fn): created_variables = [] trainable_variables = [] @@ -139,26 +153,28 @@ class MinimizeLossStepTest(test.TestCase, parameterized.TestCase): use_callable_loss=True, create_optimizer_inside_model_fn=True) + def step_fn(ctx, inputs): + del ctx # Unused + return distribution.group( + distribution.call_for_each_tower( + model_fn, inputs, run_concurrently=layer.built)) + iterator = distribution.distribute_dataset( dataset_fn).make_one_shot_iterator() def run_step(): - return distribution.group( - distribution.call_for_each_tower( - model_fn, iterator.get_next(), run_concurrently=layer.built)) + return distribution.run_steps_on_dataset( + step_fn, iterator, iterations=1).run_op + self.evaluate(distribution.initialize()) if not context.executing_eagerly(): with self.test_session() as sess: - if is_tpu: - sess.run(tpu.initialize_system()) run_step = sess.make_callable(run_step()) - self.evaluate(variables_lib.global_variables_initializer()) + self.evaluate(variables_lib.global_variables_initializer()) run_step() - if is_tpu: - with self.test_session() as sess: - sess.run(tpu.shutdown_system()) + self.evaluate(distribution.finalize()) def get_expected_variables(optimizer_fn, num_parameter_devices): variables_map = { @@ -189,27 +205,17 @@ class MinimizeLossStepTest(test.TestCase, parameterized.TestCase): combinations.distributions_and_v1_optimizers(), combinations.combine( mode=["graph", "eager"], - is_tpu=[False], # TODO(isaprykin): Allow False here. Currently subsequent # towers will re-execute UPDATE_OPS of previous towers. update_ops_in_cross_tower_mode=[True])) + combinations.combine( distribution=[combinations.tpu_strategy], - optimizer_fn=[ - combinations.gradient_descent_optimizer_v1_fn, - combinations.gradient_descent_optimizer_v2_fn - ], + optimizer_fn=combinations.optimizers_v1, mode=["graph"], - is_tpu=[True], update_ops_in_cross_tower_mode=[False]))) def testTrainNetworkWithBatchNorm(self, distribution, optimizer_fn, momentum, - renorm, is_tpu, - update_ops_in_cross_tower_mode): + renorm, update_ops_in_cross_tower_mode): """Verifies that moving mean updates are reduced across towers.""" - # TODO(priyag): Remove this once the step TPU Strategy is stable. - if is_tpu: - self.skipTest("TPU tests are WIP.") - with distribution.scope(): num_towers = len(distribution.worker_devices) model_fn, dataset_fn, batchnorm = batchnorm_example( @@ -224,24 +230,28 @@ class MinimizeLossStepTest(test.TestCase, parameterized.TestCase): # this test relies on specific input being on each device. if isinstance(distribution, mirrored_strategy.MirroredStrategy): self.assertFalse(distribution._prefetch_on_device) - iterator = distribution.distribute_dataset( - dataset_fn).make_one_shot_iterator() - def run_step(): + def step_fn(ctx, inputs): + del ctx # Unused fetches = distribution.unwrap( distribution.call_for_each_tower( - model_fn, iterator.get_next(), - run_concurrently=batchnorm.built)) + model_fn, inputs, run_concurrently=batchnorm.built)) if update_ops_in_cross_tower_mode: fetches += ops.get_collection(ops.GraphKeys.UPDATE_OPS) return control_flow_ops.group(fetches) + iterator = distribution.distribute_dataset( + dataset_fn).make_one_shot_iterator() + + def run_step(): + return distribution.run_steps_on_dataset( + step_fn, iterator, iterations=1).run_op + + self.evaluate(distribution.initialize()) if not context.executing_eagerly(): with self.test_session() as sess: - if is_tpu: - sess.run(tpu.initialize_system()) run_step = sess.make_callable(run_step()) - self.evaluate(variables_lib.global_variables_initializer()) + self.evaluate(variables_lib.global_variables_initializer()) expected_moving_means = [0.] * 8 @@ -263,9 +273,7 @@ class MinimizeLossStepTest(test.TestCase, parameterized.TestCase): expected_moving_mean - averaged_batch_mean(i)) * (1.0 - momentum)) self.assertNear(expected_moving_means[i], moving_means[i], 0.0001) - if is_tpu: - with self.test_session() as sess: - sess.run(tpu.shutdown_system()) + self.evaluate(distribution.finalize()) @combinations.generate( combinations.times( @@ -285,22 +293,16 @@ class MinimizeLossStepTest(test.TestCase, parameterized.TestCase): combinations.one_device_strategy, combinations.mirrored_strategy_with_gpu_and_cpu, combinations.mirrored_strategy_with_two_gpus - ], - is_tpu=[False]), + ]), combinations.combine( mode=["graph"], use_callable_loss=[True, False]) + combinations.combine(mode=["eager"], use_callable_loss=[True])) + combinations.combine( distribution=[combinations.tpu_strategy], - is_tpu=[True], mode=["graph"], use_callable_loss=[True, False]))) def testMeanVsSum(self, distribution, optimizer_fn, loss_reduction, - use_callable_loss, is_tpu): - # TODO(priyag): Remove this once the step TPU Strategy is stable. - if is_tpu: - self.skipTest("TPU tests are WIP.") - + use_callable_loss): with distribution.scope(): all_vars = [] @@ -326,20 +328,25 @@ class MinimizeLossStepTest(test.TestCase, parameterized.TestCase): labels = dataset_ops.Dataset.from_tensors([[6.], [21.]]) return dataset_ops.Dataset.zip((features, labels)).repeat() + def step_fn(ctx, inputs): + del ctx # Unused + x, y = inputs + return distribution.group( + distribution.call_for_each_tower( + model_fn, x, y, run_concurrently=False)) + iterator = distribution.distribute_dataset( dataset_fn).make_one_shot_iterator() def run_step(): - return distribution.group( - distribution.call_for_each_tower( - model_fn, *iterator.get_next(), run_concurrently=False)) + return distribution.run_steps_on_dataset( + step_fn, iterator, iterations=1).run_op + self.evaluate(distribution.initialize()) if not context.executing_eagerly(): with self.test_session() as sess: - if is_tpu: - sess.run(tpu.initialize_system()) run_step = sess.make_callable(run_step()) - self.evaluate(variables_lib.global_variables_initializer()) + self.evaluate(variables_lib.global_variables_initializer()) run_step() @@ -369,10 +376,132 @@ class MinimizeLossStepTest(test.TestCase, parameterized.TestCase): # One of the mean loss reductions. self.assertNear(weight, 2 + 10.6, 0.0001) - if is_tpu: + self.evaluate(distribution.finalize()) + + @combinations.generate( + combinations.times( + combinations.distributions_and_v1_optimizers(), + combinations.combine(mode=["graph", "eager"]), + combinations.combine(is_tpu=[False])) + + combinations.combine( + distribution=[combinations.tpu_strategy], + optimizer_fn=combinations.optimizers_v1, + mode=["graph"], + is_tpu=[True])) + def testRunStepsWithOutputContext(self, distribution, optimizer_fn, is_tpu): + with distribution.scope(): + def dataset_fn(): + dataset = dataset_ops.Dataset.from_tensors([[1.]]).repeat() + # TODO(priyag): batch with drop_remainder=True causes shapes to be + # fully defined for TPU. Remove this when XLA supports dynamic shapes. + return dataset.batch(batch_size=1, drop_remainder=True) + + optimizer = optimizer_fn() + layer = core.Dense(1, use_bias=True) + + key1 = "foo" + value1 = "bar" + + def model_fn(output_context, x): + """A very simple model written by the user.""" + def loss_fn(): + y = array_ops.reshape(layer(x), []) - constant_op.constant(1.) + return y * y + + train_op = optimizer.minimize(loss_fn) + loss = loss_fn() + output_context.set_last_step_output( + name="tower_loss_agg", + output=loss, + aggregation=variables_lib.VariableAggregation.MEAN) + output_context.set_non_tensor_output(key1, value1) + return (train_op, loss) + + def step_fn(output_context, inputs): + (train_op, loss) = distribution.call_for_each_tower( + model_fn, output_context, inputs, run_concurrently=False) + output_context.set_last_step_output( + name="cross_tower_loss_agg", + output=loss, + aggregation=variables_lib.VariableAggregation.MEAN) + output_context.set_last_step_output( + name="cross_tower_loss_noagg", + output=loss) + return distribution.group(train_op) + + iterator = distribution.distribute_dataset( + dataset_fn).make_one_shot_iterator() + + def run_step(): + initial_loss = lambda: constant_op.constant(1e7) + # Initial values corresponding to aggregated losses are just single + # tensors. But for non aggregated losses, we need to have initial + # values that are of the same structure as non reduced losses. In + # MirroredStrategy, this will be a list of losses, in TPUStrategy + # it will be single tensor. Using `broadcast` followed by `unwrap` + # gives us the desired initial value structure. + initial_loop_values = { + "tower_loss_agg": initial_loss(), + "cross_tower_loss_agg": initial_loss(), + "cross_tower_loss_noagg": + distribution.unwrap(distribution.broadcast(initial_loss())) + } + ctx = distribution.run_steps_on_dataset( + step_fn, iterator, iterations=2, + initial_loop_values=initial_loop_values) + + self.assertEqual({key1: [value1]}, ctx.non_tensor_outputs) + self._verify_loss_output( + initial_loss(), + loss_output=ctx.last_step_outputs["tower_loss_agg"], + aggregated=True, distribution=distribution) + self._verify_loss_output( + initial_loss(), + loss_output=ctx.last_step_outputs["cross_tower_loss_agg"], + aggregated=True, distribution=distribution) + self._verify_loss_output( + initial_loss(), + loss_output=ctx.last_step_outputs["cross_tower_loss_noagg"], + aggregated=False, distribution=distribution) + return (ctx.run_op, ctx.last_step_outputs["tower_loss_agg"]) + + self.evaluate(distribution.initialize()) + if not context.executing_eagerly(): with self.test_session() as sess: - sess.run(tpu.shutdown_system()) + run_step = sess.make_callable(run_step()) + self.evaluate(variables_lib.global_variables_initializer()) + + weights, biases, losses = [], [], [] + for _ in range(5): + _, loss = run_step() + losses.append(loss) + weights.append(self.evaluate(layer.kernel)) + biases.append(self.evaluate(layer.bias)) + self.evaluate(distribution.finalize()) + + loss_is_not_increasing = all(y <= x for x, y in zip(losses, losses[1:])) + self.assertTrue(loss_is_not_increasing) + + error = abs( + numpy.add(numpy.squeeze(weights), numpy.squeeze(biases)) - 1) + error_is_not_increasing = all(y <= x for x, y in zip(error, error[1:])) + self.assertTrue(error_is_not_increasing) + + def _verify_loss_output(self, initial_loss, loss_output, aggregated, + distribution): + if not aggregated: + self.assertEqual(distribution.num_towers, + len(distribution.unwrap(loss_output))) + loss_output = distribution.reduce( + aggregation=variables_lib.VariableAggregation.MEAN, + value=loss_output, destinations="/device:CPU:0") + + unwrapped_output = distribution.unwrap(loss_output) + self.assertEqual(1, len(unwrapped_output)) + loss_tensor = unwrapped_output[0] + self.assertEqual(initial_loss.dtype, loss_tensor.dtype) + self.assertEqual(initial_loss.shape, loss_tensor.shape) if __name__ == "__main__": test.main() diff --git a/tensorflow/contrib/distribute/python/single_loss_example.py b/tensorflow/contrib/distribute/python/single_loss_example.py index d1fdb3279c..5aa19cf6a9 100644 --- a/tensorflow/contrib/distribute/python/single_loss_example.py +++ b/tensorflow/contrib/distribute/python/single_loss_example.py @@ -29,7 +29,8 @@ from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops -def single_loss_example(optimizer_fn, distribution, use_bias=False): +def single_loss_example(optimizer_fn, distribution, use_bias=False, + iterations_per_step=1): """Build a very simple network to use in tests and examples.""" def dataset_fn(): @@ -38,12 +39,13 @@ def single_loss_example(optimizer_fn, distribution, use_bias=False): optimizer = optimizer_fn() layer = core.Dense(1, use_bias=use_bias) - def loss_fn(x): + def loss_fn(ctx, x): + del ctx y = array_ops.reshape(layer(x), []) - constant_op.constant(1.) return y * y - single_loss_step = step_fn.StandardSingleLossStep(dataset_fn, loss_fn, - optimizer, distribution) + single_loss_step = step_fn.StandardSingleLossStep( + dataset_fn, loss_fn, optimizer, distribution, iterations_per_step) # Layer is returned for inspecting the kernels in tests. return single_loss_step, layer diff --git a/tensorflow/contrib/distribute/python/step_fn.py b/tensorflow/contrib/distribute/python/step_fn.py index d1910622b3..d3611570b4 100644 --- a/tensorflow/contrib/distribute/python/step_fn.py +++ b/tensorflow/contrib/distribute/python/step_fn.py @@ -34,15 +34,9 @@ class Step(object): def __call__(self): """Perform one step of this training algorithm.""" - return self.step(self.inputs()) - - def inputs(self): - """For the generating the input to be passed to `step()`.""" raise NotImplementedError("must be implemented in descendants") - def step(self, inputs): - """Perform the main computation of this training algorithm.""" - raise NotImplementedError("must be implemented in descendants") + # TODO(priyag): Add an method to access initialization and finalize ops. class StandardInputStep(Step): @@ -54,12 +48,9 @@ class StandardInputStep(Step): """ def __init__(self, dataset_fn, distribution): - Step.__init__(self, distribution) - self._distributed_input = distribution.distribute_dataset( - dataset_fn).make_one_shot_iterator() - - def inputs(self): - return self._distributed_input.get_next() + super(StandardInputStep, self).__init__(distribution) + self._distributed_input = distribution.distribute_dataset(dataset_fn) + self._iterator = self._distributed_input.make_one_shot_iterator() class StandardSingleLossStep(StandardInputStep): @@ -69,8 +60,8 @@ class StandardSingleLossStep(StandardInputStep): ```python ... - step = step_fn.StandardSingleLossStep(dataset, loss_fn, optimizer) - step.initialize(distribution) + step = step_fn.StandardSingleLossStep( + dataset, loss_fn, optimizer, distribution) # Run a single training step on a given DistributionStrategy: step(distribution) @@ -80,27 +71,43 @@ class StandardSingleLossStep(StandardInputStep): Args: dataset_fn: a function that returns a tf.data Dataset that produces the input for the model. - loss_fn: a function that returns loss. + loss_fn: a function that takes a context and inputs as arguments. It returns + the loss for those inputs. `context` is an instance of + `values.MultiStepContext` that will be passed when `loss_fn` is run. + `context` can be used to specify the outputs to be returned from + `loss_fn`, among other things. optimizer: an optimizer that implements an update rule. distribution: a `DistributionStrategy` object. """ - def __init__(self, dataset_fn, loss_fn, optimizer, distribution): - StandardInputStep.__init__(self, dataset_fn, distribution) + def __init__(self, dataset_fn, loss_fn, optimizer, distribution, + iterations_per_step=1): + super(StandardSingleLossStep, self).__init__(dataset_fn, distribution) self._loss_fn = loss_fn self._optimizer = optimizer self._is_run_concurrently = False + self._iterations_per_step = iterations_per_step - def step(self, inputs): + def __call__(self): with self._distribution.scope(): - gradients_fn = backprop.implicit_grad(self._loss_fn) - gradients_fn = optimizer_lib.get_filtered_grad_fn(gradients_fn) - - grads_and_vars = self.distribution.call_for_each_tower( - gradients_fn, inputs, run_concurrently=self._is_run_concurrently) - # If threads use layers, then we need to run the first step sequentially, - # so that layers.build() is not executed in parallel. Otherwise, multiple - # sets of mirrored variables are going to be created. - self._is_run_concurrently = True - return self._optimizer._distributed_apply( # pylint: disable=protected-access - self.distribution, grads_and_vars) + def step_fn(ctx, inputs): + """Function to run one iteration with one input.""" + gradients_fn = backprop.implicit_grad(self._loss_fn) + gradients_fn = optimizer_lib.get_filtered_grad_fn(gradients_fn) + + grads_and_vars = self.distribution.call_for_each_tower( + gradients_fn, + ctx, inputs, + run_concurrently=self._is_run_concurrently) + # If threads use layers, then we need to run the first step + # sequentially, so that layers.build() is not executed in parallel. + # Otherwise, multiple sets of mirrored variables are going to be + # created. + self._is_run_concurrently = True + return self._optimizer._distributed_apply( # pylint: disable=protected-access + self.distribution, grads_and_vars) + + # TODO(priyag): Return the outputs, context, etc as well. + ctx = self.distribution.run_steps_on_dataset( + step_fn, self._iterator, self._iterations_per_step) + return ctx.run_op diff --git a/tensorflow/contrib/distribute/python/step_fn_test.py b/tensorflow/contrib/distribute/python/step_fn_test.py index 2ee94d8f70..8605ab1f7d 100644 --- a/tensorflow/contrib/distribute/python/step_fn_test.py +++ b/tensorflow/contrib/distribute/python/step_fn_test.py @@ -33,12 +33,19 @@ class SingleLossStepTest(test.TestCase, parameterized.TestCase): @combinations.generate( combinations.times( combinations.distributions_and_v1_optimizers(), - combinations.combine(mode=combinations.graph_and_eager_modes))) - def testTrainNetwork(self, distribution, optimizer_fn): + combinations.combine(mode=combinations.graph_and_eager_modes), + combinations.combine(is_tpu=[False])) + + combinations.combine( + distribution=[combinations.tpu_strategy], + optimizer_fn=combinations.optimizers_v1, + mode=["graph"], + is_tpu=[True])) + def testTrainNetwork(self, distribution, optimizer_fn, is_tpu): with distribution.scope(): single_loss_step, layer = single_loss_example( - optimizer_fn, distribution, use_bias=True) + optimizer_fn, distribution, use_bias=True, iterations_per_step=2) + self.evaluate(distribution.initialize()) if context.executing_eagerly(): run_step = single_loss_step else: @@ -47,12 +54,14 @@ class SingleLossStepTest(test.TestCase, parameterized.TestCase): self.evaluate(variables.global_variables_initializer()) weights, biases = [], [] - for _ in range(10): + for _ in range(5): run_step() weights.append(self.evaluate(layer.kernel)) biases.append(self.evaluate(layer.bias)) + self.evaluate(distribution.finalize()) + error = abs(numpy.add(numpy.squeeze(weights), numpy.squeeze(biases)) - 1) is_not_increasing = all(y <= x for x, y in zip(error, error[1:])) self.assertTrue(is_not_increasing) diff --git a/tensorflow/python/training/optimizer.py b/tensorflow/python/training/optimizer.py index f75db08059..6d95b144d5 100644 --- a/tensorflow/python/training/optimizer.py +++ b/tensorflow/python/training/optimizer.py @@ -51,8 +51,8 @@ def get_filtered_grad_fn(grad_fn): # those variables are accessed in another thread during the gradient # computation. To get a consistent set of variables, we filter out # those with `None` gradients. - def filtered_grad_fn(x=None): - return [(g, v) for g, v in grad_fn(x) if g is not None] + def filtered_grad_fn(*args, **kwargs): + return [(g, v) for g, v in grad_fn(*args, **kwargs) if g is not None] return filtered_grad_fn @@ -555,7 +555,7 @@ class Optimizer( # always calling _distributed_apply(), using the default distribution # as needed. if distribute_lib.has_distribution_strategy(): - grads_and_vars = get_filtered_grad_fn(lambda _: grads_and_vars)() + grads_and_vars = get_filtered_grad_fn(lambda: grads_and_vars)() return distribute_lib.get_tower_context().merge_call( self._distributed_apply, grads_and_vars, global_step, name) -- GitLab From 12eb80cb9b4b51631a7cdfc9fce476a8b2ea225b Mon Sep 17 00:00:00 2001 From: Rohan Jain Date: Fri, 10 Aug 2018 17:05:25 -0700 Subject: [PATCH 376/437] Speeding up MultiDeviceIterator by more efficient locking. We create a background thread that tries to keep a host side buffer for each device full. When a GetNext request comes in, we return from the buffer if available or else we schedule a callback to be called when the background thread eventually fetches an element for it. PiperOrigin-RevId: 208292329 --- .../data/kernels/prefetching_kernels.cc | 356 +++++++++++++----- tensorflow/contrib/data/ops/dataset_ops.cc | 2 + .../kernel_tests/prefetching_ops_test.py | 4 +- .../data/python/ops/prefetching_ops.py | 5 +- 4 files changed, 271 insertions(+), 96 deletions(-) diff --git a/tensorflow/contrib/data/kernels/prefetching_kernels.cc b/tensorflow/contrib/data/kernels/prefetching_kernels.cc index 32f03ca683..13bcd77b4a 100644 --- a/tensorflow/contrib/data/kernels/prefetching_kernels.cc +++ b/tensorflow/contrib/data/kernels/prefetching_kernels.cc @@ -526,6 +526,15 @@ string SanitizeThreadSuffix(string suffix) { return clean; } +struct HostBufferElement { + Status status; + bool end_of_sequence; + std::vector value; +}; + +using MultiDeviceIteratorCallback = + std::function; + class MultiDeviceIterator : public ResourceBase { public: MultiDeviceIterator(const DataTypeVector& output_types, @@ -539,83 +548,45 @@ class MultiDeviceIterator : public ResourceBase { devices_(devices), flib_def_(std::move(flib_def)), pflr_(std::move(pflr)), - lib_(lib) { - buffer_.resize(devices_.size()); - } + lib_(lib) {} string DebugString() override { - return strings::StrCat("MultiDeviceIterator"); + return strings::StrCat("MultiDeviceIterator for ", devices_.size(), + " devices"); } - Status Init(std::unique_ptr iterator, int64* incarnation_id) { - mutex_lock l(mu_); + Status Init(std::unique_ptr iterator, int64 max_buffer_size, + int64* incarnation_id) { if (iterator) { TF_RETURN_IF_ERROR( VerifyTypesMatch(output_types_, iterator->output_dtypes())); TF_RETURN_IF_ERROR( VerifyShapesCompatible(output_shapes_, iterator->output_shapes())); } - host_iterator_.reset(iterator.release()); - incarnation_id_++; + + mutex_lock l(mu_); + if (multi_device_buffer_) { + multi_device_buffer_->Reset(); + } + + ++incarnation_id_; *incarnation_id = incarnation_id_; - max_buffer_size_ = 0; - num_elements_ = 0; - buffer_.clear(); - buffer_.resize(devices_.size()); + + multi_device_buffer_.reset( + new MultiDeviceBuffer(devices_.size(), max_buffer_size, incarnation_id_, + std::move(iterator))); return Status::OK(); } - Status GetNextFromShard(IteratorContext* ctx, int shard_num, - int64 incarnation_id, - std::vector* out_tensors, - bool* end_of_sequence) { - // TODO(rohanj): This might potentially strand elements in other shards. - // Opportunity to do smarter locking semantics. - mutex_lock l(mu_); - // Make sure we're in the right incarnation. - if (incarnation_id != incarnation_id_) { - return errors::InvalidArgument( - "Current incarnation: ", incarnation_id_, - "; Supplied incarnation: ", incarnation_id); - } - // Then look it up in the buffer. - if (!buffer_[shard_num].empty()) { - const HostBufferElement& elem = buffer_[shard_num].front(); - *out_tensors = elem.value; - *end_of_sequence = elem.end_of_sequence; - Status s = elem.status; - buffer_[shard_num].pop_front(); - return s; - } - std::shared_ptr captured_iterator(host_iterator_); - if (captured_iterator) { - if (lib_ != nullptr) { - ctx->set_lib(lib_); - } - while (true) { - HostBufferElement elem; - elem.status = - captured_iterator->GetNext(ctx, &elem.value, &elem.end_of_sequence); - int buffer_index = num_elements_ % devices_.size(); - num_elements_++; - if (buffer_index == shard_num) { - out_tensors->swap(elem.value); - *end_of_sequence = elem.end_of_sequence; - return elem.status; - } else { - buffer_[buffer_index].push_back(std::move(elem)); - // TODO(rohanj): Put an upper bound to buffer size. - if (buffer_[buffer_index].size() > max_buffer_size_) { - max_buffer_size_ = buffer_[buffer_index].size(); - VLOG(1) << "MultiDeviceIterator: Max buffer size increased to: " - << max_buffer_size_; - } - } - } - } else { - return errors::FailedPrecondition("Iterator not initialized"); + void GetNextFromShard(IteratorContext* ctx, int shard_num, + int64 incarnation_id, + MultiDeviceIteratorCallback callback) { + if (lib_ != nullptr) { + ctx->set_lib(lib_); } - return Status::OK(); + tf_shared_lock l(mu_); + multi_device_buffer_->GetNextFromShard(ctx, shard_num, incarnation_id, + std::move(callback)); } const DataTypeVector& output_types() const { return output_types_; } @@ -630,25 +601,218 @@ class MultiDeviceIterator : public ResourceBase { } private: - struct HostBufferElement { - Status status; - bool end_of_sequence; - std::vector value; + // A private class that uses a background thread to keep a per device buffer + // full. + class MultiDeviceBuffer { + public: + MultiDeviceBuffer(size_t size, int64 max_buffer_size, int64 incarnation_id, + std::unique_ptr host_iterator) + : buffer_(size), + size_(size), + max_buffer_size_(max_buffer_size), + incarnation_id_(incarnation_id), + host_iterator_(std::move(host_iterator)) {} + + ~MultiDeviceBuffer() { Reset(); } + + void Reset() LOCKS_EXCLUDED(mu_) { + { + mutex_lock l(mu_); + if (background_thread_finished_) { + return; + } + + cancelled_ = true; + // Wake up the background thread. + for (int i = 0; i < size_; ++i) { + buffer_[i].cond_var.notify_all(); + } + + // Make sure background thread has finished first. + while (!background_thread_finished_) { + shutdown_cond_var_.wait(l); + } + } + RunPendingCallbacks(); + } + + void GetNextFromShard(IteratorContext* ctx, int shard_num, + int64 incarnation_id, + MultiDeviceIteratorCallback callback) { + HostBufferElement elem; + if (incarnation_id_ != incarnation_id) { + elem.status = errors::InvalidArgument("Invalid incarnation id"); + callback(elem); + return; + } + + bool produced_output = false; + { + mutex_lock l(mu_); + if (cancelled_) { + elem.status = errors::Cancelled("Cancelled Multidevice iterator"); + callback(elem); + return; + } + + EnsureBackgroundThreadStarted(ctx); + + if (!buffer_[shard_num].data.empty()) { + produced_output = true; + std::swap(elem, buffer_[shard_num].data.front()); + buffer_[shard_num].data.pop_front(); + // Wake up background thread if it is blocked on this element. + if (buffer_[shard_num].data.size() == max_buffer_size_ - 1) { + buffer_[shard_num].cond_var.notify_all(); + } + } else { + if (background_thread_finished_) { + produced_output = true; + elem.end_of_sequence = true; + } else { + buffer_[shard_num].callbacks.push_back(std::move(callback)); + callback = nullptr; + } + } + } + + if (produced_output) { + callback(elem); + } + } + + private: + void EnsureBackgroundThreadStarted(IteratorContext* ctx) + EXCLUSIVE_LOCKS_REQUIRED(mu_) { + if (!background_thread_) { + background_thread_.reset(ctx->env()->StartThread( + {}, "multi_device_iterator_background_thread", + std::bind(&MultiDeviceIterator::MultiDeviceBuffer::BackgroundThread, + this, new IteratorContext(*ctx)))); + } + } + + void RunPendingCallbacks() LOCKS_EXCLUDED(mu_) { + // Run all remaining callbacks. + std::vector cancellation_callbacks; + std::vector cancellation_elements; + { + mutex_lock l(mu_); + + for (int i = 0; i < size_; ++i) { + while (!buffer_[i].callbacks.empty()) { + if (buffer_[i].data.empty()) { + HostBufferElement elem; + elem.status = + errors::Cancelled("Cancelled and buffer not filled."); + cancellation_elements.push_back(std::move(elem)); + } else { + cancellation_elements.push_back( + std::move(buffer_[i].data.front())); + buffer_[i].data.pop_front(); + } + cancellation_callbacks.push_back( + std::move(buffer_[i].callbacks.front())); + buffer_[i].callbacks.pop_front(); + } + } + } + for (int i = 0; i < cancellation_callbacks.size(); ++i) { + cancellation_callbacks[i](cancellation_elements[i]); + } + } + + void BackgroundThread(IteratorContext* ctx) { + std::unique_ptr cleanup(ctx); + int shard_to_fetch = 0; + while (true) { + HostBufferElement elem; + MultiDeviceIteratorCallback callback = nullptr; + bool end_of_iterator = false; + + { + mutex_lock l(mu_); + while (!cancelled_ && + buffer_[shard_to_fetch].data.size() >= max_buffer_size_) { + buffer_[shard_to_fetch].cond_var.wait(l); + } + + if (cancelled_) { + background_thread_finished_ = true; + shutdown_cond_var_.notify_all(); + return; + } + } + + elem.status = + host_iterator_->GetNext(ctx, &elem.value, &elem.end_of_sequence); + + if (elem.status.ok() && elem.end_of_sequence) { + end_of_iterator = true; + } + + { + mutex_lock l(mu_); + // Try to find a callback, else just push stuff into buffer. + if (!buffer_[shard_to_fetch].callbacks.empty()) { + callback = buffer_[shard_to_fetch].callbacks.front(); + buffer_[shard_to_fetch].callbacks.pop_front(); + } else { + buffer_[shard_to_fetch].data.push_back(std::move(elem)); + elem = HostBufferElement(); + } + } + + if (callback) { + (*ctx->runner())(std::bind(std::move(callback), std::move(elem))); + } + + // Finish off the thread if we reach the end of the iterator. Runs + // pending callbacks. + if (end_of_iterator) { + { + mutex_lock l(mu_); + background_thread_finished_ = true; + shutdown_cond_var_.notify_all(); + } + RunPendingCallbacks(); + return; + } + shard_to_fetch = (shard_to_fetch + 1) % size_; + } + } + + struct HostBuffer { + condition_variable cond_var; + std::deque data; + std::deque callbacks; + }; + + mutex mu_; + std::unique_ptr background_thread_ GUARDED_BY(mu_); + bool background_thread_finished_ GUARDED_BY(mu_) = false; + bool cancelled_ GUARDED_BY(mu_) = false; + condition_variable shutdown_cond_var_ GUARDED_BY(mu_); + + std::vector buffer_; + + const size_t size_; + const int64 max_buffer_size_; + const int64 incarnation_id_; + const std::unique_ptr host_iterator_; }; mutex mu_; const DataTypeVector output_types_; const std::vector output_shapes_; const std::vector devices_; - int64 num_elements_ GUARDED_BY(mu_) = 0; - int64 max_buffer_size_ GUARDED_BY(mu_) = 0; - int64 incarnation_id_ GUARDED_BY(mu_) = 0; - std::vector> buffer_ GUARDED_BY(mu_); - std::unique_ptr flib_def_; - std::unique_ptr pflr_; - FunctionLibraryRuntime* lib_ = nullptr; // not owned. - std::shared_ptr host_iterator_; + const std::unique_ptr flib_def_; + const std::unique_ptr pflr_; + FunctionLibraryRuntime* const lib_ = nullptr; // not owned. std::shared_ptr lib_def_ GUARDED_BY(mu_); + + int64 incarnation_id_ GUARDED_BY(mu_) = 0; + std::unique_ptr multi_device_buffer_ GUARDED_BY(mu_); }; // Just creates a MultiDeviceIterator and returns it. @@ -754,6 +918,10 @@ class MultiDeviceIteratorInitOp : public OpKernel { : OpKernel(ctx) {} void Compute(OpKernelContext* ctx) override { + const Tensor* tensor_max_buffer_size; + OP_REQUIRES_OK(ctx, ctx->input("max_buffer_size", &tensor_max_buffer_size)); + int64 max_buffer_size = tensor_max_buffer_size->scalar()(); + DatasetBase* dataset; OP_REQUIRES_OK(ctx, GetDatasetFromVariantTensor(ctx->input(0), &dataset)); MultiDeviceIterator* resource; @@ -766,7 +934,8 @@ class MultiDeviceIteratorInitOp : public OpKernel { OP_REQUIRES_OK(ctx, dataset->MakeIterator(&iter_ctx, "Iterator", &iterator)); int64 incarnation_id; - OP_REQUIRES_OK(ctx, resource->Init(std::move(iterator), &incarnation_id)); + OP_REQUIRES_OK(ctx, resource->Init(std::move(iterator), max_buffer_size, + &incarnation_id)); Tensor tensor_incarnation_id(DT_INT64, TensorShape({})); tensor_incarnation_id.scalar()() = incarnation_id; OP_REQUIRES_OK(ctx, @@ -804,9 +973,6 @@ class MultiDeviceIteratorGetNextFromShardOp : public AsyncOpKernel { ctx, LookupResource(ctx, HandleFromInput(ctx, 0), &iterator), done); thread_pool_->Schedule(std::bind( [ctx, iterator, shard_num, incarnation_id](DoneCallback done) { - std::vector components; - bool end_of_sequence = false; - IteratorContext::Params params; params.env = ctx->env(); params.runner = *(ctx->runner()); @@ -817,22 +983,26 @@ class MultiDeviceIteratorGetNextFromShardOp : public AsyncOpKernel { }; IteratorContext iter_ctx(std::move(params)); - Status s = - iterator->GetNextFromShard(&iter_ctx, shard_num, incarnation_id, - &components, &end_of_sequence); - iterator->Unref(); + MultiDeviceIteratorCallback callback = std::bind( + [ctx](const HostBufferElement& elem, DoneCallback done) { + // iterator->Unref(); + Status s = elem.status; + if (!s.ok()) { + ctx->SetStatus(s); + } else if (elem.end_of_sequence) { + ctx->SetStatus(errors::OutOfRange("End of sequence")); + } else { + for (int i = 0; i < elem.value.size(); ++i) { + ctx->set_output(i, elem.value[i]); + } + } + done(); + }, + std::placeholders::_1, std::move(done)); - if (!s.ok()) { - ctx->SetStatus(s); - } else if (end_of_sequence) { - ctx->SetStatus(errors::OutOfRange("End of sequence")); - } else { - for (int i = 0; i < components.size(); ++i) { - // TODO(mrry): Check that the shapes match the shape attrs. - ctx->set_output(i, components[i]); - } - } - done(); + iterator->GetNextFromShard(&iter_ctx, shard_num, incarnation_id, + callback); + iterator->Unref(); }, std::move(done))); } diff --git a/tensorflow/contrib/data/ops/dataset_ops.cc b/tensorflow/contrib/data/ops/dataset_ops.cc index 66a7c7fdcd..cc5e250ea1 100644 --- a/tensorflow/contrib/data/ops/dataset_ops.cc +++ b/tensorflow/contrib/data/ops/dataset_ops.cc @@ -168,9 +168,11 @@ output_shapes: The list of shapes being produced. REGISTER_OP("MultiDeviceIteratorInit") .Input("dataset: variant") .Input("multi_device_iterator: resource") + .Input("max_buffer_size: int64") .Output("incarnation_id: int64") .Doc(R"doc( Initializes the multi device iterator with the given dataset. +max_buffer_size: The maximum size of the host side per device buffer to keep. incarnation_id: An int64 indicating which incarnation of the MultiDeviceIterator is running. dataset: Dataset to be iterated upon. diff --git a/tensorflow/contrib/data/python/kernel_tests/prefetching_ops_test.py b/tensorflow/contrib/data/python/kernel_tests/prefetching_ops_test.py index d66305d732..361fe0dd39 100644 --- a/tensorflow/contrib/data/python/kernel_tests/prefetching_ops_test.py +++ b/tensorflow/contrib/data/python/kernel_tests/prefetching_ops_test.py @@ -1021,7 +1021,7 @@ class MultiDeviceIteratorTest(test.TestCase): def testUneven(self): dataset = dataset_ops.Dataset.range(10) multi_device_iterator = prefetching_ops.MultiDeviceIterator( - dataset, ["/cpu:1", "/cpu:2"]) + dataset, ["/cpu:1", "/cpu:2"], max_buffer_size=4) elem_on_1, elem_on_2 = multi_device_iterator.get_next() config = config_pb2.ConfigProto(device_count={"CPU": 3}) @@ -1079,7 +1079,7 @@ class MultiDeviceIteratorTest(test.TestCase): with compat.forward_compatibility_horizon(2018, 8, 4): dataset = dataset_ops.Dataset.range(10) multi_device_iterator = prefetching_ops.MultiDeviceIterator( - dataset, ["/cpu:1", "/gpu:0"]) + dataset, ["/cpu:1", "/gpu:0"], max_buffer_size=4) elem_on_1, elem_on_2 = multi_device_iterator.get_next() config = config_pb2.ConfigProto(device_count={"CPU": 2, "GPU": 1}) diff --git a/tensorflow/contrib/data/python/ops/prefetching_ops.py b/tensorflow/contrib/data/python/ops/prefetching_ops.py index be6fb69fee..5222011d04 100644 --- a/tensorflow/contrib/data/python/ops/prefetching_ops.py +++ b/tensorflow/contrib/data/python/ops/prefetching_ops.py @@ -631,6 +631,7 @@ class MultiDeviceIterator(object): def __init__(self, dataset, devices, + max_buffer_size=1, prefetch_buffer_size=1, source_device="/cpu:0"): """Constructs a MultiDeviceIterator. @@ -638,6 +639,7 @@ class MultiDeviceIterator(object): Args: dataset: The input dataset to be iterated over. devices: The list of devices to fetch data to. + max_buffer_size: Maximum size of the host side per device buffer to keep. prefetch_buffer_size: if > 1, then we setup a buffer on each device to prefetch into. source_device: The host device to place the `dataset` on. @@ -668,7 +670,8 @@ class MultiDeviceIterator(object): # iterators and the multi-device iterator. self._incarnation_id = gen_dataset_ops.multi_device_iterator_init( self._dataset._as_variant_tensor(), # pylint: disable=protected-access - self._multi_device_iterator_resource) + self._multi_device_iterator_resource, + max_buffer_size=max_buffer_size) # TODO(rohanj): Explore the possibility of the MultiDeviceIterator to # initialize the device side of the pipeline. This would allow the -- GitLab From 58e3969856680fae28905a0fd553271e70f282f3 Mon Sep 17 00:00:00 2001 From: Anna R Date: Fri, 10 Aug 2018 17:12:00 -0700 Subject: [PATCH 377/437] Internal change. PiperOrigin-RevId: 208293192 --- tensorflow/contrib/seq2seq/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/contrib/seq2seq/BUILD b/tensorflow/contrib/seq2seq/BUILD index 1a1591d798..18b56cd219 100644 --- a/tensorflow/contrib/seq2seq/BUILD +++ b/tensorflow/contrib/seq2seq/BUILD @@ -177,7 +177,7 @@ cuda_py_test( cuda_py_test( name = "beam_search_decoder_test", - size = "small", + size = "medium", srcs = ["python/kernel_tests/beam_search_decoder_test.py"], additional_deps = [ ":seq2seq_py", -- GitLab From 20498a56f274ccb7c00901fe3ae26be1df9585b3 Mon Sep 17 00:00:00 2001 From: Anna R Date: Fri, 10 Aug 2018 17:20:33 -0700 Subject: [PATCH 378/437] Internal change. PiperOrigin-RevId: 208294163 --- tensorflow/contrib/autograph/pyct/testing/BUILD | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tensorflow/contrib/autograph/pyct/testing/BUILD b/tensorflow/contrib/autograph/pyct/testing/BUILD index 957db356f7..9ef1ac9663 100644 --- a/tensorflow/contrib/autograph/pyct/testing/BUILD +++ b/tensorflow/contrib/autograph/pyct/testing/BUILD @@ -33,7 +33,10 @@ py_test( size = "large", srcs = ["codegen_test.py"], srcs_version = "PY2AND3", - tags = ["no_windows"], + tags = [ + "no_windows", + "nomsan", + ], deps = [ ":testing", "//tensorflow/contrib/autograph/pyct", -- GitLab From 8cfc0a152c4022b17d7d9b286c4cff726f78f7fd Mon Sep 17 00:00:00 2001 From: Shashi Shekhar Date: Fri, 10 Aug 2018 17:23:39 -0700 Subject: [PATCH 379/437] Add an Android target for whole_file_reader ops. PiperOrigin-RevId: 208294588 --- tensorflow/core/kernels/BUILD | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tensorflow/core/kernels/BUILD b/tensorflow/core/kernels/BUILD index d142e36772..202fee8232 100644 --- a/tensorflow/core/kernels/BUILD +++ b/tensorflow/core/kernels/BUILD @@ -5381,6 +5381,18 @@ cc_library( alwayslink = 1, ) +cc_library( + name = "android_whole_file_read_ops", + srcs = if_android(["whole_file_read_ops.cc"]), + copts = tf_copts(), + linkopts = ["-ldl"], + visibility = ["//visibility:public"], + deps = [ + "//tensorflow/core:android_tensorflow_lib_lite", + ], + alwayslink = 1, +) + # Quantization-specific OpKernels tf_kernel_library( -- GitLab From 3e2e407c49aa14b525ff6c37538ea4506a152798 Mon Sep 17 00:00:00 2001 From: Allen Lavoie Date: Fri, 10 Aug 2018 17:46:09 -0700 Subject: [PATCH 380/437] TFTS: de-flake ar_model_test PiperOrigin-RevId: 208297005 --- .../contrib/timeseries/python/timeseries/ar_model_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/contrib/timeseries/python/timeseries/ar_model_test.py b/tensorflow/contrib/timeseries/python/timeseries/ar_model_test.py index 63f5d3568b..5eb4deefb9 100644 --- a/tensorflow/contrib/timeseries/python/timeseries/ar_model_test.py +++ b/tensorflow/contrib/timeseries/python/timeseries/ar_model_test.py @@ -195,7 +195,7 @@ class ARModelTest(test.TestCase): self.train_helper(input_window_size=10, loss=ar_model.ARModel.NORMAL_LIKELIHOOD_LOSS, train_steps=300, - max_loss=1.5, + max_loss=2.5, anomaly_distribution=None) def test_autoregression_normal_multiple_periods(self): -- GitLab From a7f95b9580b224e520c30b14c121d1707cbc0ece Mon Sep 17 00:00:00 2001 From: "William D. Irons" Date: Fri, 10 Aug 2018 22:05:41 -0500 Subject: [PATCH 381/437] Updates for code review comments --- .../tools/ci_build/Dockerfile.gpu.ppc64le | 2 +- .../ci_build/install/install_hdf5_ppc64le.sh | 9 ++-- .../ci_build/linux/ppc64le/cpu/run_cc_core.sh | 38 ---------------- .../cpu/{run_py2_core.sh => run_py2.sh} | 4 +- .../cpu/{run_py3_core.sh => run_py3.sh} | 4 +- .../linux/ppc64le/cpu/run_py3_contrib.sh | 37 ---------------- .../gpu/{run_py2_core.sh => run_py2.sh} | 6 +-- .../gpu/{run_cc_core.sh => run_py3.sh} | 6 +-- .../linux/ppc64le/gpu/run_py3_core.sh | 44 ------------------- 9 files changed, 14 insertions(+), 136 deletions(-) delete mode 100755 tensorflow/tools/ci_build/linux/ppc64le/cpu/run_cc_core.sh rename tensorflow/tools/ci_build/linux/ppc64le/cpu/{run_py2_core.sh => run_py2.sh} (92%) rename tensorflow/tools/ci_build/linux/ppc64le/cpu/{run_py3_core.sh => run_py3.sh} (92%) delete mode 100755 tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_contrib.sh rename tensorflow/tools/ci_build/linux/ppc64le/gpu/{run_py2_core.sh => run_py2.sh} (85%) rename tensorflow/tools/ci_build/linux/ppc64le/gpu/{run_cc_core.sh => run_py3.sh} (85%) delete mode 100755 tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh diff --git a/tensorflow/tools/ci_build/Dockerfile.gpu.ppc64le b/tensorflow/tools/ci_build/Dockerfile.gpu.ppc64le index a99d2c1af2..e026edb6bb 100644 --- a/tensorflow/tools/ci_build/Dockerfile.gpu.ppc64le +++ b/tensorflow/tools/ci_build/Dockerfile.gpu.ppc64le @@ -27,5 +27,5 @@ ENV LD_LIBRARY_PATH /usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH ENV TF_NEED_CUDA 1 ENV TF_CUDA_COMPUTE_CAPABILITIES 3.0 -#TODO get NCCL 2 in the docker image +# TODO get NCCL 2 in the docker image ENV TF_NCCL_VERSION 1 diff --git a/tensorflow/tools/ci_build/install/install_hdf5_ppc64le.sh b/tensorflow/tools/ci_build/install/install_hdf5_ppc64le.sh index 2fc3012b64..4989d986b8 100755 --- a/tensorflow/tools/ci_build/install/install_hdf5_ppc64le.sh +++ b/tensorflow/tools/ci_build/install/install_hdf5_ppc64le.sh @@ -24,10 +24,7 @@ apt-get install -y libhdf5-dev ln -s /usr/lib/powerpc64le-linux-gnu/libhdf5_serial.so /usr/lib/powerpc64le-linux-gnu/libhdf5.so ln -s /usr/lib/powerpc64le-linux-gnu/libhdf5_serial_hl.so /usr/lib/powerpc64le-linux-gnu/libhdf5_hl.so -#Install pip here because h5py seg faults with python3 when installed via easy_install -easy_install -U pip==9.0.3 -easy_install3 -U pip==9.0.3 - +#pip is not installed yet, so use easy_install #CPATH is the location of hdf5.h -CPATH=/usr/include/hdf5/serial/ pip2 install --upgrade h5py -CPATH=/usr/include/hdf5/serial/ pip3 install --upgrade h5py +CPATH=/usr/include/hdf5/serial/ easy_install -U h5py +CPATH=/usr/include/hdf5/serial/ easy_install3 -U h5py diff --git a/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_cc_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_cc_core.sh deleted file mode 100755 index 945f072a51..0000000000 --- a/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_cc_core.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2018 The TensorFlow Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ============================================================================== - -set -e -set -x - -N_JOBS=$(grep -c ^processor /proc/cpuinfo) - -echo "" -echo "Bazel will use ${N_JOBS} concurrent job(s)." -echo "" - -# Run configure. -export TF_NEED_CUDA=0 -export CC_OPT_FLAGS='-mcpu=power8 -mtune=power8' -# Only running cc tests, python version does not matter. -export PYTHON_BIN_PATH=`which python` -yes "" | $PYTHON_BIN_PATH configure.py - -# Run bazel test command. Double test timeouts to avoid flakes. -bazel test --test_tag_filters=-no_oss,-gpu,-benchmark-test --test_lang_filters=cc,java -k \ - --jobs=${N_JOBS} --test_timeout 300,450,1200,3600 --config=opt \ - --test_output=errors --test_size_filters=small,medium -- \ - //tensorflow/... -//tensorflow/compiler/... -//tensorflow/contrib/... diff --git a/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py2_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py2.sh similarity index 92% rename from tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py2_core.sh rename to tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py2.sh index aeb8c2ba99..e13de35061 100755 --- a/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py2_core.sh +++ b/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py2.sh @@ -31,7 +31,7 @@ export PYTHON_BIN_PATH=`which python2` yes "" | $PYTHON_BIN_PATH configure.py # Run bazel test command. Double test timeouts to avoid flakes. -bazel test --test_tag_filters=-no_oss,-oss_serial,-gpu,-benchmark-test --test_lang_filters=py -k \ +bazel test --test_tag_filters=-no_oss,-oss_serial,-gpu,-benchmark-test -k \ --jobs=${N_JOBS} --test_timeout 300,450,1200,3600 --build_tests_only --config=opt \ --test_output=errors --test_size_filters=small,medium -- \ - //tensorflow/... -//tensorflow/compiler/... -//tensorflow/contrib/... + //tensorflow/... -//tensorflow/compiler/... diff --git a/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3.sh similarity index 92% rename from tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_core.sh rename to tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3.sh index c2916bc2b8..a04ac158f5 100755 --- a/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_core.sh +++ b/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3.sh @@ -31,7 +31,7 @@ export PYTHON_BIN_PATH=`which python3` yes "" | $PYTHON_BIN_PATH configure.py # Run bazel test command. Double test timeouts to avoid flakes. -bazel test --test_tag_filters=-no_oss,-oss_serial,-gpu,-benchmark-test --test_lang_filters=py -k \ +bazel test --test_tag_filters=-no_oss,-oss_serial,-gpu,-benchmark-test -k \ --jobs=${N_JOBS} --test_timeout 300,450,1200,3600 --build_tests_only --config=opt \ --test_output=errors --test_size_filters=small,medium -- \ - //tensorflow/... -//tensorflow/compiler/... -//tensorflow/contrib/... + //tensorflow/... -//tensorflow/compiler/... diff --git a/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_contrib.sh b/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_contrib.sh deleted file mode 100755 index 9983f6a7c7..0000000000 --- a/tensorflow/tools/ci_build/linux/ppc64le/cpu/run_py3_contrib.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2018 The TensorFlow Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ============================================================================== - -set -e -set -x - -N_JOBS=$(grep -c ^processor /proc/cpuinfo) - -echo "" -echo "Bazel will use ${N_JOBS} concurrent job(s)." -echo "" - -# Run configure. -export TF_NEED_CUDA=0 -export CC_OPT_FLAGS='-mcpu=power8 -mtune=power8' -export PYTHON_BIN_PATH=`which python3` -yes "" | $PYTHON_BIN_PATH configure.py - -# Run bazel test command. Double test timeouts to avoid flakes. -bazel test --test_tag_filters=-no_oss,-oss_serial,-gpu,-benchmark-test -k \ - --jobs=${N_JOBS} --test_timeout 300,450,1200,3600 --config=opt \ - --test_size_filters=small,medium --test_output=errors -- \ - //tensorflow/contrib/... diff --git a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2.sh similarity index 85% rename from tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2_core.sh rename to tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2.sh index cc213a86bf..77286e8448 100755 --- a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2_core.sh +++ b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py2.sh @@ -37,8 +37,8 @@ yes "" | $PYTHON_BIN_PATH configure.py # Run bazel test command. Double test timeouts to avoid flakes. bazel test --config=cuda --test_tag_filters=-no_oss,-oss_serial,-no_gpu,-benchmark-test -k \ - --test_lang_filters=py --jobs=${N_JOBS} --test_timeout 300,450,1200,3600 \ - --build_tests_only --test_output=errors --local_test_jobs=${LT_JOBS} --config=opt \ + --jobs=${N_JOBS} --test_timeout 300,450,1200,3600 \ + --test_output=errors --local_test_jobs=${LT_JOBS} --build_tests_only --config=opt \ --test_size_filters=small,medium \ --run_under=//tensorflow/tools/ci_build/gpu_build:parallel_gpu_execute -- \ - //tensorflow/... -//tensorflow/compiler/... -//tensorflow/contrib/... + //tensorflow/... -//tensorflow/compiler/... diff --git a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_cc_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3.sh similarity index 85% rename from tensorflow/tools/ci_build/linux/ppc64le/gpu/run_cc_core.sh rename to tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3.sh index 68a9d0068b..17aa52ee6b 100755 --- a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_cc_core.sh +++ b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3.sh @@ -37,8 +37,8 @@ yes "" | $PYTHON_BIN_PATH configure.py # Run bazel test command. Double test timeouts to avoid flakes. bazel test --config=cuda --test_tag_filters=-no_oss,-oss_serial,-no_gpu,-benchmark-test -k \ - --test_lang_filters=cc --jobs=${N_JOBS} --test_timeout 300,450,1200,3600 \ - --build_tests_only --test_output=errors --local_test_jobs=${LT_JOBS} --config=opt \ + --jobs=${N_JOBS} --test_timeout 300,450,1200,3600 \ + --test_output=errors --local_test_jobs=${LT_JOBS} --build_tests_only --config=opt \ --test_size_filters=small,medium \ --run_under=//tensorflow/tools/ci_build/gpu_build:parallel_gpu_execute -- \ - //tensorflow/... -//tensorflow/compiler/... -//tensorflow/contrib/... + //tensorflow/... -//tensorflow/compiler/... diff --git a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh b/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh deleted file mode 100755 index 1b8d38f3cb..0000000000 --- a/tensorflow/tools/ci_build/linux/ppc64le/gpu/run_py3_core.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2018 The TensorFlow Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ============================================================================== - -set -e -set -x - -N_JOBS=$(grep -c ^processor /proc/cpuinfo) -LT_JOBS=$(nvidia-smi --query-gpu=gpu_name --format=csv,noheader | wc -l) - -echo "" -echo "Bazel will use ${N_JOBS} concurrent job(s)." -echo "Bazel will use ${LT_JOBS} local test job(s)." -echo "" - -# Run configure. -export PYTHON_BIN_PATH=`which python3` -export CC_OPT_FLAGS='-mcpu=power8 -mtune=power8' - -export TF_NEED_CUDA=1 -export TF_CUDA_COMPUTE_CAPABILITIES=3.7 - -yes "" | $PYTHON_BIN_PATH configure.py - -# Run bazel test command. Double test timeouts to avoid flakes. -bazel test --config=cuda --test_tag_filters=-no_oss,-oss_serial,-no_gpu,-benchmark-test -k \ - --test_lang_filters=py --jobs=${N_JOBS} --test_timeout 300,450,1200,3600 \ - --build_tests_only --test_output=errors --local_test_jobs=${LT_JOBS} --config=opt \ - --test_size_filters=small,medium \ - --run_under=//tensorflow/tools/ci_build/gpu_build:parallel_gpu_execute -- \ - //tensorflow/... -//tensorflow/compiler/... -//tensorflow/contrib/... -- GitLab From 84ee0e2a2554e9b9ccfbaf0db1e2db62dd52d8cc Mon Sep 17 00:00:00 2001 From: Sanjoy Das Date: Fri, 10 Aug 2018 21:00:14 -0700 Subject: [PATCH 382/437] Remove XlaCompiledCpuFunction::args() This lets us remove XlaCompiledCpuFunction::args_ and some awkwardness from XlaCompiledCpuFunction::Run. PiperOrigin-RevId: 208309249 --- tensorflow/compiler/aot/test.cc | 10 +-- .../compiler/aot/tests/tfcompile_test.cc | 66 +++++++++---------- .../tf2xla/xla_compiled_cpu_function.cc | 13 ---- .../tf2xla/xla_compiled_cpu_function.h | 23 +++---- 4 files changed, 47 insertions(+), 65 deletions(-) diff --git a/tensorflow/compiler/aot/test.cc b/tensorflow/compiler/aot/test.cc index df966767b3..5deb47d123 100644 --- a/tensorflow/compiler/aot/test.cc +++ b/tensorflow/compiler/aot/test.cc @@ -51,9 +51,9 @@ namespace tensorflow { namespace tfcompile { namespace { -void zero_buffers(void** bufs, const XlaCompiledCpuFunction& computation) { - for (int i = 0; i < computation.num_args(); ++i) { - memset(bufs[i], 0, computation.arg_size(i)); +void zero_buffers(XlaCompiledCpuFunction* computation) { + for (int i = 0; i < computation->num_args(); ++i) { + memset(computation->arg_data(i), 0, computation->arg_size(i)); } } @@ -64,7 +64,7 @@ TEST(TEST_NAME, NoCrash) { CPP_CLASS computation; computation.set_thread_pool(&device); - zero_buffers(computation.args(), computation); + zero_buffers(&computation); EXPECT_TRUE(computation.Run()); } @@ -78,7 +78,7 @@ void BM_NAME(int iters) { CPP_CLASS computation; computation.set_thread_pool(&device); - zero_buffers(computation.args(), computation); + zero_buffers(&computation); testing::StartTiming(); while (--iters) { diff --git a/tensorflow/compiler/aot/tests/tfcompile_test.cc b/tensorflow/compiler/aot/tests/tfcompile_test.cc index fee46280e9..0c0c676ece 100644 --- a/tensorflow/compiler/aot/tests/tfcompile_test.cc +++ b/tensorflow/compiler/aot/tests/tfcompile_test.cc @@ -44,8 +44,8 @@ using ::testing::IsSupersetOf; TEST(TFCompileTest, Add) { AddComp add; - EXPECT_EQ(add.arg0_data(), add.args()[0]); - EXPECT_EQ(add.arg1_data(), add.args()[1]); + EXPECT_EQ(add.arg0_data(), add.arg_data(0)); + EXPECT_EQ(add.arg1_data(), add.arg_data(1)); add.arg0() = 1; add.arg1() = 2; @@ -67,10 +67,10 @@ TEST(TFCompileTest, Add) { EXPECT_EQ(add_const.error_msg(), ""); EXPECT_EQ(add_const.arg0(), 123); EXPECT_EQ(add_const.arg0_data()[0], 123); - EXPECT_EQ(add_const.arg0_data(), add.args()[0]); + EXPECT_EQ(add_const.arg0_data(), add.arg_data(0)); EXPECT_EQ(add_const.arg1(), 456); EXPECT_EQ(add_const.arg1_data()[0], 456); - EXPECT_EQ(add_const.arg1_data(), add.args()[1]); + EXPECT_EQ(add_const.arg1_data(), add.arg_data(1)); EXPECT_EQ(add_const.result0(), 579); EXPECT_EQ(add_const.result0_data()[0], 579); EXPECT_EQ(add_const.result0_data(), add_const.results()[0]); @@ -85,8 +85,8 @@ TEST(TFCompileTest, Add_SetArg) { int32 arg_y = 32; add.set_arg0_data(&arg_x); add.set_arg1_data(&arg_y); - EXPECT_EQ(add.arg0_data(), add.args()[0]); - EXPECT_EQ(add.arg1_data(), add.args()[1]); + EXPECT_EQ(add.arg0_data(), add.arg_data(0)); + EXPECT_EQ(add.arg1_data(), add.arg_data(1)); EXPECT_TRUE(add.Run()); EXPECT_EQ(add.error_msg(), ""); @@ -97,7 +97,7 @@ TEST(TFCompileTest, Add_SetArg) { TEST(TFCompileTest, AddWithCkpt) { AddWithCkptComp add; - EXPECT_EQ(add.arg0_data(), add.args()[0]); + EXPECT_EQ(add.arg0_data(), add.arg_data(0)); add.arg0() = 1; EXPECT_TRUE(add.Run()); @@ -117,7 +117,7 @@ TEST(TFCompileTest, AddWithCkpt) { EXPECT_EQ(add_const.error_msg(), ""); EXPECT_EQ(add_const.arg0(), 111); EXPECT_EQ(add_const.arg0_data()[0], 111); - EXPECT_EQ(add_const.arg0_data(), add_const.args()[0]); + EXPECT_EQ(add_const.arg0_data(), add_const.arg_data(0)); EXPECT_EQ(add_const.result0(), 153); EXPECT_EQ(add_const.result0_data()[0], 153); EXPECT_EQ(add_const.result0_data(), add_const.results()[0]); @@ -125,7 +125,7 @@ TEST(TFCompileTest, AddWithCkpt) { TEST(TFCompileTest, AddWithCkptSaver) { AddWithCkptSaverComp add; - EXPECT_EQ(add.arg0_data(), add.args()[0]); + EXPECT_EQ(add.arg0_data(), add.arg_data(0)); add.arg0() = 1; EXPECT_TRUE(add.Run()); @@ -145,7 +145,7 @@ TEST(TFCompileTest, AddWithCkptSaver) { EXPECT_EQ(add_const.error_msg(), ""); EXPECT_EQ(add_const.arg0(), 111); EXPECT_EQ(add_const.arg0_data()[0], 111); - EXPECT_EQ(add_const.arg0_data(), add_const.args()[0]); + EXPECT_EQ(add_const.arg0_data(), add_const.arg_data(0)); EXPECT_EQ(add_const.result0(), 153); EXPECT_EQ(add_const.result0_data()[0], 153); EXPECT_EQ(add_const.result0_data(), add_const.results()[0]); @@ -153,9 +153,9 @@ TEST(TFCompileTest, AddWithCkptSaver) { TEST(TFCompileTest, Cond) { CondComp cond; - EXPECT_EQ(cond.arg0_data(), cond.args()[0]); - EXPECT_EQ(cond.arg1_data(), cond.args()[1]); - EXPECT_EQ(cond.arg2_data(), cond.args()[2]); + EXPECT_EQ(cond.arg0_data(), cond.arg_data(0)); + EXPECT_EQ(cond.arg1_data(), cond.arg_data(1)); + EXPECT_EQ(cond.arg2_data(), cond.arg_data(2)); cond.arg1() = 10; cond.arg2() = 20; { @@ -178,8 +178,8 @@ TEST(TFCompileTest, Cond) { TEST(TFCompileTest, Gather) { GatherComp gather; - EXPECT_EQ(gather.arg0_data(), gather.args()[0]); - EXPECT_EQ(gather.arg1_data(), gather.args()[1]); + EXPECT_EQ(gather.arg0_data(), gather.arg_data(0)); + EXPECT_EQ(gather.arg1_data(), gather.arg_data(1)); // Successful gather. { @@ -202,12 +202,12 @@ TEST(TFCompileTest, Gather) { EXPECT_EQ(gather_const.arg0(i), params[i]); EXPECT_EQ(gather_const.arg0_data()[i], params[i]); } - EXPECT_EQ(gather_const.arg0_data(), gather_const.args()[0]); + EXPECT_EQ(gather_const.arg0_data(), gather_const.arg_data(0)); for (int i = 0; i < 2; ++i) { EXPECT_EQ(gather_const.arg1(i), indices[i]); EXPECT_EQ(gather_const.arg1_data()[i], indices[i]); } - EXPECT_EQ(gather_const.arg1_data(), gather_const.args()[1]); + EXPECT_EQ(gather_const.arg1_data(), gather_const.arg_data(1)); for (int i = 0; i < 2; ++i) { EXPECT_EQ(gather_const.result0(i), results[i]); EXPECT_EQ(gather_const.result0_data()[i], results[i]); @@ -222,8 +222,8 @@ TEST(TFCompileTest, MatMul2) { foo::bar::MatMulComp matmul; matmul.set_thread_pool(&device); - EXPECT_EQ(matmul.arg0_data(), matmul.args()[0]); - EXPECT_EQ(matmul.arg1_data(), matmul.args()[1]); + EXPECT_EQ(matmul.arg0_data(), matmul.arg_data(0)); + EXPECT_EQ(matmul.arg1_data(), matmul.arg_data(1)); // Test using the argN() methods. { @@ -271,12 +271,12 @@ TEST(TFCompileTest, MatMul2) { EXPECT_EQ(matmul_const.arg0(i / 3, i % 3), args[i]); EXPECT_EQ(matmul_const.arg0_data()[i], args[i]); } - EXPECT_EQ(matmul_const.arg0_data(), matmul.args()[0]); + EXPECT_EQ(matmul_const.arg0_data(), matmul.arg_data(0)); for (int i = 0; i < 6; ++i) { EXPECT_EQ(matmul_const.arg1(i / 2, i % 2), args[i + 6]); EXPECT_EQ(matmul_const.arg1_data()[i], args[i + 6]); } - EXPECT_EQ(matmul_const.arg1_data(), matmul.args()[1]); + EXPECT_EQ(matmul_const.arg1_data(), matmul.arg_data(1)); for (int i = 0; i < 4; ++i) { EXPECT_EQ(matmul_const.result0(i / 2, i % 2), results[i]); EXPECT_EQ(matmul_const.result0_data()[i], results[i]); @@ -300,8 +300,8 @@ TEST(TFCompileTest, MatMul2_SetArg) { float arg1[3][2] = {{7, 8}, {9, 10}, {11, 12}}; matmul.set_arg0_data(&arg0); matmul.set_arg1_data(&arg1); - EXPECT_EQ(matmul.arg0_data(), matmul.args()[0]); - EXPECT_EQ(matmul.arg1_data(), matmul.args()[1]); + EXPECT_EQ(matmul.arg0_data(), matmul.arg_data(0)); + EXPECT_EQ(matmul.arg1_data(), matmul.arg_data(1)); EXPECT_TRUE(matmul.Run()); EXPECT_EQ(matmul.error_msg(), ""); @@ -319,8 +319,8 @@ TEST(TFCompileTest, MatMulAndAdd1) { MatMulAndAddComp muladd; muladd.set_thread_pool(&device); - EXPECT_EQ(muladd.arg0_data(), muladd.args()[0]); - EXPECT_EQ(muladd.arg1_data(), muladd.args()[1]); + EXPECT_EQ(muladd.arg0_data(), muladd.arg_data(0)); + EXPECT_EQ(muladd.arg1_data(), muladd.arg_data(1)); // Test methods with positional args and results. { @@ -346,12 +346,12 @@ TEST(TFCompileTest, MatMulAndAdd1) { EXPECT_EQ(muladd_const.arg0(i / 2, i % 2), args[i]); EXPECT_EQ(muladd_const.arg0_data()[i], args[i]); } - EXPECT_EQ(muladd_const.arg0_data(), muladd.args()[0]); + EXPECT_EQ(muladd_const.arg0_data(), muladd.arg_data(0)); for (int i = 0; i < 4; ++i) { EXPECT_EQ(muladd_const.arg1(i / 2, i % 2), args[i + 4]); EXPECT_EQ(muladd_const.arg1_data()[i], args[i + 4]); } - EXPECT_EQ(muladd_const.arg1_data(), muladd.args()[1]); + EXPECT_EQ(muladd_const.arg1_data(), muladd.arg_data(1)); for (int i = 0; i < 4; ++i) { EXPECT_EQ(muladd_const.result0(i / 2, i % 2), results0[i]); EXPECT_EQ(muladd_const.result0_data()[i], results0[i]); @@ -387,12 +387,12 @@ TEST(TFCompileTest, MatMulAndAdd1) { EXPECT_EQ(muladd_const.arg_x(i / 2, i % 2), args[i]); EXPECT_EQ(muladd_const.arg_x_data()[i], args[i]); } - EXPECT_EQ(muladd_const.arg_x_data(), muladd.args()[0]); + EXPECT_EQ(muladd_const.arg_x_data(), muladd.arg_data(0)); for (int i = 0; i < 4; ++i) { EXPECT_EQ(muladd_const.arg_y(i / 2, i % 2), args[i + 4]); EXPECT_EQ(muladd_const.arg_y_data()[i], args[i + 4]); } - EXPECT_EQ(muladd_const.arg_y_data(), muladd.args()[1]); + EXPECT_EQ(muladd_const.arg_y_data(), muladd.arg_data(1)); for (int i = 0; i < 4; ++i) { EXPECT_EQ(muladd_const.result_x_y_prod(i / 2, i % 2), results0[i]); EXPECT_EQ(muladd_const.result_x_y_prod_data()[i], results0[i]); @@ -407,8 +407,8 @@ TEST(TFCompileTest, MatMulAndAdd1) { TEST(TFCompileTest, Function) { // The function is equivalent to an addition FunctionComp add_fn; - EXPECT_EQ(add_fn.arg0_data(), add_fn.args()[0]); - EXPECT_EQ(add_fn.arg1_data(), add_fn.args()[1]); + EXPECT_EQ(add_fn.arg0_data(), add_fn.arg_data(0)); + EXPECT_EQ(add_fn.arg1_data(), add_fn.arg_data(1)); add_fn.arg0() = 1; add_fn.arg1() = 2; @@ -451,8 +451,8 @@ TEST(TFCompileTest, AssertEqAndReturnDiff) { // Assert is converted into a no-op in XLA, so there is no failure even if the // two args are different. AssertComp assert; - EXPECT_EQ(assert.arg0_data(), assert.args()[0]); - EXPECT_EQ(assert.arg1_data(), assert.args()[1]); + EXPECT_EQ(assert.arg0_data(), assert.arg_data(0)); + EXPECT_EQ(assert.arg1_data(), assert.arg_data(1)); assert.arg0() = 2; assert.arg1() = 1; diff --git a/tensorflow/compiler/tf2xla/xla_compiled_cpu_function.cc b/tensorflow/compiler/tf2xla/xla_compiled_cpu_function.cc index 09c5d1dd19..1f0f240135 100644 --- a/tensorflow/compiler/tf2xla/xla_compiled_cpu_function.cc +++ b/tensorflow/compiler/tf2xla/xla_compiled_cpu_function.cc @@ -23,7 +23,6 @@ XlaCompiledCpuFunction::XlaCompiledCpuFunction(const StaticData& static_data, AllocMode alloc_mode) : raw_function_(static_data.raw_function_), result_index_(static_data.result_index_), - args_(new void*[static_data.num_args_]), buffer_table_(new void*[static_data.num_buffers_]), buffer_infos_(static_data.buffer_infos_), arg_index_table_(static_data.arg_index_table_), @@ -39,11 +38,6 @@ XlaCompiledCpuFunction::XlaCompiledCpuFunction(const StaticData& static_data, static_data.buffer_infos_, static_data.num_buffers_, /*allocate_entry_params=*/allocate_entry_params, buffer_table_, /*annotate_initialized=*/true); - if (allocate_entry_params) { - for (int32 i = 0; i < num_args_; i++) { - args_[i] = buffer_table_[arg_index_table_[i]]; - } - } // If Hlo profiling is enabled the generated code expects an appropriately // sized buffer to be passed in as the last argument. If Hlo profiling is // disabled the last function argument is still present in the function @@ -55,12 +49,6 @@ XlaCompiledCpuFunction::XlaCompiledCpuFunction(const StaticData& static_data, } bool XlaCompiledCpuFunction::Run() { - // Propagate pointers to the argument buffers into the buffer table. Code - // generated by XLA discovers the incoming argument pointers from the buffer - // table. - for (int32 i = 0; i < num_args_; i++) { - buffer_table_[arg_index_table_[i]] = args_[i]; - } raw_function_(buffer_table_[result_index_], &run_options_, nullptr, buffer_table_, profile_counters_); return true; @@ -68,7 +56,6 @@ bool XlaCompiledCpuFunction::Run() { XlaCompiledCpuFunction::~XlaCompiledCpuFunction() { cpu_function_runtime::FreeContiguous(alloc_buffer_table_); - delete[] args_; delete[] buffer_table_; delete[] profile_counters_; } diff --git a/tensorflow/compiler/tf2xla/xla_compiled_cpu_function.h b/tensorflow/compiler/tf2xla/xla_compiled_cpu_function.h index 7dd8c24eb7..425e769346 100644 --- a/tensorflow/compiler/tf2xla/xla_compiled_cpu_function.h +++ b/tensorflow/compiler/tf2xla/xla_compiled_cpu_function.h @@ -175,17 +175,13 @@ class XlaCompiledCpuFunction { // ------------------------------ // Arg methods for managing input buffers. Buffers are in row-major order. - // Returns the underlying array of argument buffers, where args()[I] is the - // buffer for the positional argument at index I. - // - // TODO(sanjoy): We should retire this in favor of explicit accessors. That - // would let us elide the args_ array. - void** args() { return args_; } - const void* const* args() const { return args_; } - // Returns the buffer for the positional argument at the given `index`. - void* arg_data(size_t index) { return args_[index]; } - const void* arg_data(size_t index) const { return args_[index]; } + void* arg_data(size_t index) { + return buffer_table_[arg_index_table_[index]]; + } + const void* arg_data(size_t index) const { + return buffer_table_[arg_index_table_[index]]; + } int num_args() const { return num_args_; } @@ -210,7 +206,9 @@ class XlaCompiledCpuFunction { // // Aliasing of argument and result buffers is not allowed, and results in // undefined behavior. - void set_arg_data(size_t index, void* data) { args_[index] = data; } + void set_arg_data(size_t index, void* data) { + buffer_table_[arg_index_table_[index]] = data; + } // ------------------------------ // Result methods for managing output buffers. Buffers are in row-major order. @@ -280,9 +278,6 @@ class XlaCompiledCpuFunction { const RawFunction raw_function_; const size_t result_index_; - // Array of argument buffers; entries in args_ may be overwritten by the user. - void** const args_; - // Array containing pointers to argument and temp buffers (slots corresponding // to constant and on-stack buffers are null). void** const buffer_table_; -- GitLab From 054b3961f76a12bc8b722af708982949b4e951cf Mon Sep 17 00:00:00 2001 From: Sourabh Bajaj Date: Fri, 10 Aug 2018 21:30:58 -0700 Subject: [PATCH 383/437] Create new MultiStepStopHook for running mutiple steps per run when using TPU Distribution Strategy with Estimator. PiperOrigin-RevId: 208310915 --- .../contrib/distribute/python/combinations.py | 3 +- .../contrib/distribute/python/tpu_strategy.py | 10 +- tensorflow/python/estimator/estimator.py | 25 +++- tensorflow/python/estimator/estimator_test.py | 1 + .../training/basic_session_run_hooks.py | 117 ++++++++++++++++++ tensorflow/python/training/training.py | 1 + 6 files changed, 152 insertions(+), 5 deletions(-) diff --git a/tensorflow/contrib/distribute/python/combinations.py b/tensorflow/contrib/distribute/python/combinations.py index e676536d87..a1efbcaf9a 100644 --- a/tensorflow/contrib/distribute/python/combinations.py +++ b/tensorflow/contrib/distribute/python/combinations.py @@ -326,7 +326,8 @@ one_device_strategy = NamedDistribution( "OneDeviceCPU", lambda: one_device_lib.OneDeviceStrategy("/cpu:0"), required_gpus=None) tpu_strategy = NamedDistribution( - "TPU", lambda: tpu_lib.TPUStrategy(TPUClusterResolver("")), + "TPU", lambda: tpu_lib.TPUStrategy( + TPUClusterResolver(""), steps_per_run=5), required_tpu=True) # Note that we disable prefetching for testing since prefetching makes # the input non-deterministic. diff --git a/tensorflow/contrib/distribute/python/tpu_strategy.py b/tensorflow/contrib/distribute/python/tpu_strategy.py index 83af37fc81..b510fdb888 100644 --- a/tensorflow/contrib/distribute/python/tpu_strategy.py +++ b/tensorflow/contrib/distribute/python/tpu_strategy.py @@ -60,12 +60,17 @@ def get_tpu_system_metadata(tpu_cluster_resolver): class TPUStrategy(one_device_strategy.OneDeviceStrategy): """Experimental TPU distribution strategy implementation.""" - def __init__(self, tpu_cluster_resolver): + def __init__(self, tpu_cluster_resolver, steps_per_run): """Initializes the TPUStrategy object. Args: tpu_cluster_resolver: A tf.contrib.cluster_resolver.TPUClusterResolver, which provides information about the TPU cluster. + steps_per_run: Number of steps to run on device before returning to the + host. Note that this can have side-effects on performance, hooks, + metrics, summaries etc. + This parameter is only used when Distribution Strategy is used with + estimator or keras. """ # TODO(isaprykin): Generalize the defaults. They are currently tailored for # the unit test. @@ -76,6 +81,9 @@ class TPUStrategy(one_device_strategy.OneDeviceStrategy): # TODO(priyag): This should not be hardcoded here. self._host = '/device:CPU:0' + # TODO(sourabhbajaj): Remove this once performance of running one step + # at a time is comparable to multiple steps. + self.steps_per_run = steps_per_run def distribute_dataset(self, dataset_fn): # TODO(priyag): Perhaps distribute across cores here. diff --git a/tensorflow/python/estimator/estimator.py b/tensorflow/python/estimator/estimator.py index d6e407b958..b8cd55c806 100644 --- a/tensorflow/python/estimator/estimator.py +++ b/tensorflow/python/estimator/estimator.py @@ -53,6 +53,7 @@ from tensorflow.python.saved_model import builder as saved_model_builder from tensorflow.python.saved_model import utils_impl as saved_model_utils from tensorflow.python.summary import summary from tensorflow.python.summary.writer import writer_cache +from tensorflow.python.training import basic_session_run_hooks from tensorflow.python.training import checkpoint_management from tensorflow.python.training import device_setter from tensorflow.python.training import distribute as distribute_lib @@ -345,7 +346,23 @@ class Estimator(object): return self def _convert_train_steps_to_hooks(self, steps, max_steps): + """Create hooks to run correct number of steps in training. + + Args: + steps: number of steps to run during training. + max_steps: maximum number of steps to be run during training. It'll be + the maximum number of steps the model will train to after restoring + from checkpoint even across multiple estimator.train calls. + + Returns: + List of hooks to be passed to the estimator. + """ if steps is not None or max_steps is not None: + if self._train_distribution: + steps_per_run = getattr(self._train_distribution, 'steps_per_run', 1) + if steps_per_run > 1: + return [basic_session_run_hooks._MultiStepStopAtStepHook( # pylint: disable=protected-access + steps, max_steps, steps_per_run)] return [training.StopAtStepHook(steps, max_steps)] else: return [] @@ -1184,6 +1201,10 @@ class Estimator(object): worker_hooks = [] with ops.Graph().as_default() as g: + # We want to create the iterations variable outside the distribution scope + # as that is just stored on the host and mainly used to drive the loop + # and doesn't need to be a Mirrored/Device variable. + steps_per_run_variable = training.get_or_create_steps_per_run_variable() with self._train_distribution.scope(): random_seed.set_random_seed(self._config.tf_random_seed) @@ -1224,11 +1245,9 @@ class Estimator(object): return estimator_spec.train_op # Create new train_op post graph rewrites - # TODO(sourabhbajaj): Make sure train_steps and tpu_iterations - # work correctly. Currently hardcoded at 2 initial_training_loss = constant_op.constant(1e7) ctx = self._train_distribution.run_steps_on_dataset( - step_fn, iterator, iterations=2, + step_fn, iterator, iterations=steps_per_run_variable, initial_loop_values={'loss': initial_training_loss}) distributed_train_op = ctx.run_op tpu_result = ctx.last_step_outputs diff --git a/tensorflow/python/estimator/estimator_test.py b/tensorflow/python/estimator/estimator_test.py index d44774a45a..e3f22d9010 100644 --- a/tensorflow/python/estimator/estimator_test.py +++ b/tensorflow/python/estimator/estimator_test.py @@ -2683,6 +2683,7 @@ class EstimatorExportTest(test.TestCase): _, _ = features, labels my_int = variables.Variable(1, name='my_int', collections=[ops.GraphKeys.LOCAL_VARIABLES]) + _ = training.get_or_create_steps_per_run_variable() scores = constant_op.constant([3.]) with ops.control_dependencies([ variables.local_variables_initializer(), diff --git a/tensorflow/python/training/basic_session_run_hooks.py b/tensorflow/python/training/basic_session_run_hooks.py index 4e8e505549..76625624e4 100644 --- a/tensorflow/python/training/basic_session_run_hooks.py +++ b/tensorflow/python/training/basic_session_run_hooks.py @@ -28,9 +28,12 @@ from tensorflow.core.framework.summary_pb2 import Summary from tensorflow.core.protobuf import config_pb2 from tensorflow.core.util.event_pb2 import SessionLog from tensorflow.python.client import timeline +from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors from tensorflow.python.framework import meta_graph from tensorflow.python.framework import ops +from tensorflow.python.ops import init_ops +from tensorflow.python.ops import variable_scope from tensorflow.python.platform import gfile from tensorflow.python.platform import tf_logging as logging from tensorflow.python.training import session_run_hook @@ -40,6 +43,10 @@ from tensorflow.python.training.summary_io import SummaryWriterCache from tensorflow.python.util.tf_export import tf_export +_HOOKS = "hooks" +_STEPS_PER_RUN_VAR = "steps_per_run" + + class _HookTimer(object): """Base timer for determining when Hooks should trigger. @@ -255,6 +262,116 @@ class LoggingTensorHook(session_run_hook.SessionRunHook): self._log_tensors(values) +def get_or_create_steps_per_run_variable(): + """Gets or creates the steps_per_run variable. + + In Estimator, the user provided computation, the model_fn, is wrapped + inside a tf.while_loop for peak performance. The iterations of the loop are + specified by this variable, which adjusts its value on the CPU after each + device program execution and before the next execution. + + The purpose of using a variable, rather than a constant, is to allow + Estimator adapt the device training iterations according to the final steps + specified by users. For example, if the user sets the steps_per_run as + 4 and steps as 10 in Estimator.train(), the steps_per_run + variable will have the following value before each training run. + + - 1-st execution: steps_per_run = 4 + - 2-nd execution: steps_per_run = 4 + - 3-rd execution: steps_per_run = 2 + + As model_fn increases the global step once per train_op invocation, the global + step is 10 after all executions, matching the steps=10 inputs passed in by + users. + + Returns: + A TF non-trainable resource variable. + + Raises: + RuntimeError: If multi steps_per_run variables were found. + """ + graph = ops.get_default_graph() + collection_name = "{}_{}".format(_HOOKS, _STEPS_PER_RUN_VAR) + steps_per_run_vars = graph.get_collection(collection_name) + if len(steps_per_run_vars) == 1: + return steps_per_run_vars[0] + elif len(steps_per_run_vars) > 1: + raise RuntimeError("Multiple steps_per_run_var in collection.") + + with variable_scope.variable_scope(_HOOKS, reuse=variable_scope.AUTO_REUSE): + return variable_scope.get_variable( + _STEPS_PER_RUN_VAR, + initializer=init_ops.ones_initializer(), + shape=[], + dtype=dtypes.int32, + trainable=False, + collections=[collection_name, ops.GraphKeys.LOCAL_VARIABLES], + use_resource=True) + + +class _MultiStepStopAtStepHook(session_run_hook.SessionRunHook): + """Hook that requests stop at a specified step.""" + + def __init__(self, num_steps=None, last_step=None, steps_per_run=1): + """Initializes a `MultiStepStopAtStepHook`. + + This hook requests stop after either a number of steps have been + executed or a last step has been reached. Only one of the two options can be + specified. + + if `num_steps` is specified, it indicates the number of steps to execute + after `begin()` is called. If instead `last_step` is specified, it + indicates the last step we want to execute, as passed to the `after_run()` + call. + + In Estimator, the user provided computation, the model_fn, is wrapped + inside a tf.while_loop for peak performance. The steps_per_run variable + determines the number of iterations of the loop before returning to the CPU. + + Args: + num_steps: Number of steps to execute. + last_step: Step after which to stop. + steps_per_run: Number of steps executed per run call. + + Raises: + ValueError: If one of the arguments is invalid. + """ + if num_steps is None and last_step is None: + raise ValueError("One of num_steps or last_step must be specified.") + if num_steps is not None and last_step is not None: + raise ValueError("Only one of num_steps or last_step can be specified.") + if steps_per_run is None or steps_per_run < 1: + raise ValueError("steps_per_run should be greater than 0") + self._num_steps = num_steps + self._last_step = last_step + self._steps_per_run = steps_per_run + + def begin(self): + self._global_step_tensor = training_util.get_global_step() + if self._global_step_tensor is None: + raise RuntimeError("Global step should be created to use StopAtStepHook.") + self._steps_per_run_variable = get_or_create_steps_per_run_variable() + + def _update_steps_per_run_variable(self, global_step, session): + steps = min(self._last_step - global_step, self._steps_per_run) + self._steps_per_run_variable.load(steps, session=session) + + def after_create_session(self, session, coord): + global_step = session.run(self._global_step_tensor) + if self._last_step is None: + self._last_step = global_step + self._num_steps + self._update_steps_per_run_variable(global_step, session) + + def after_run(self, run_context, run_values): + # Global step cannot be retrieved via SessionRunArgs and before_run due to + # race condition in hook execution. + global_step = run_context.session.run(self._global_step_tensor) + if global_step >= self._last_step: + run_context.request_stop() + else: + self._update_steps_per_run_variable(global_step, run_context.session) + + @tf_export("train.StopAtStepHook") class StopAtStepHook(session_run_hook.SessionRunHook): """Hook that requests stop at a specified step.""" diff --git a/tensorflow/python/training/training.py b/tensorflow/python/training/training.py index 544010afbe..6f6305a505 100644 --- a/tensorflow/python/training/training.py +++ b/tensorflow/python/training/training.py @@ -53,6 +53,7 @@ from tensorflow.python.training import input as _input from tensorflow.python.training.input import * # pylint: disable=redefined-builtin # pylint: enable=wildcard-import +from tensorflow.python.training.basic_session_run_hooks import get_or_create_steps_per_run_variable from tensorflow.python.training.basic_session_run_hooks import SecondOrStepTimer from tensorflow.python.training.basic_session_run_hooks import LoggingTensorHook from tensorflow.python.training.basic_session_run_hooks import StopAtStepHook -- GitLab From f97e945914e83bed8cc2d51a27f1394719f0e7b0 Mon Sep 17 00:00:00 2001 From: Anjali Sridhar Date: Fri, 10 Aug 2018 22:13:08 -0700 Subject: [PATCH 384/437] Add validation support for tuples and dict values to be returned by the Dataset iterator when using DistributionStrategy in Keras. PiperOrigin-RevId: 208312889 --- .../contrib/distribute/python/keras_test.py | 41 ++++++++++++ .../engine/distributed_training_utils.py | 66 ++++++++++++------- tensorflow/python/keras/engine/training.py | 4 +- 3 files changed, 87 insertions(+), 24 deletions(-) diff --git a/tensorflow/contrib/distribute/python/keras_test.py b/tensorflow/contrib/distribute/python/keras_test.py index ec0ca6879c..4facd72d12 100644 --- a/tensorflow/contrib/distribute/python/keras_test.py +++ b/tensorflow/contrib/distribute/python/keras_test.py @@ -241,6 +241,47 @@ class TestWithDistributionStrategy(test.TestCase): validation_data=dataset, validation_steps=2) model.predict(dataset, steps=2) + def test_fit_with_tuple_and_dict_dataset_inputs(self): + with self.test_session(): + a = keras.layers.Input(shape=(3,), name='input_a') + b = keras.layers.Input(shape=(3,), name='input_b') + + dense = keras.layers.Dense(4, name='dense') + c = dense(a) + d = dense(b) + e = keras.layers.Dropout(0.5, name='dropout')(c) + + model = keras.models.Model([a, b], [d, e]) + + optimizer = gradient_descent.GradientDescentOptimizer(learning_rate=0.001) + loss = 'mse' + metrics = ['mae'] + strategy = mirrored_strategy.MirroredStrategy(['/device:GPU:0', + '/device:CPU:0']) + model.compile(optimizer, loss, metrics=metrics, distribute=strategy) + + input_a_np = np.random.random((10, 3)) + input_b_np = np.random.random((10, 3)) + output_d_np = np.random.random((10, 4)) + output_e_np = np.random.random((10, 4)) + + # Test with tuples + dataset_tuple = dataset_ops.Dataset.from_tensor_slices(( + (input_a_np, input_b_np), (output_d_np, output_e_np))) + dataset_tuple = dataset_tuple.repeat(100) + dataset_tuple = dataset_tuple.batch(10) + + model.fit(dataset_tuple, epochs=1, steps_per_epoch=2, verbose=1) + + # Test with dict + dataset_dict = dataset_ops.Dataset.from_tensor_slices(( + {'input_a': input_a_np, 'input_b': input_b_np}, + (output_d_np, output_e_np))) + dataset_dict = dataset_dict.repeat(100) + dataset_dict = dataset_dict.batch(10) + + model.fit(dataset_dict, epochs=1, steps_per_epoch=2, verbose=1) + def test_fit_eval_and_predict_methods_on_dataset(self): with self.test_session(): x = keras.layers.Input(shape=(3,), name='input') diff --git a/tensorflow/python/keras/engine/distributed_training_utils.py b/tensorflow/python/keras/engine/distributed_training_utils.py index c78e6fe9ec..fcb073322c 100644 --- a/tensorflow/python/keras/engine/distributed_training_utils.py +++ b/tensorflow/python/keras/engine/distributed_training_utils.py @@ -184,14 +184,16 @@ def validate_distributed_dataset_inputs(distribution_strategy, x, y): """Validate all the components of a DistributedValue Dataset input. Args: - distribution_strategy: The current DistributionStrategy using to call + distribution_strategy: The current DistributionStrategy used to call `fit`/`evaluate`. x: Input Dataset DistributedValue object. For example, when we use `MirroredStrategy` this is a PerDevice object with a tensor for each - device set in the dict. + device set in the dict. x can also be a tuple or dict. The keys of the + dict should match the names of the input layers of the model. y: Target Dataset DistributedValue object. For example, when we use `MirroredStrategy` this is a PerDevice object with a tensor for each - device set in the dict. + device set in the dict. y can also be a tuple or dict. The keys of the + dict should match the names of the output layers of the model. Returns: The unwrapped values list of the x and y DistributedValues inputs. @@ -206,30 +208,50 @@ def validate_distributed_dataset_inputs(distribution_strategy, x, y): # and targets to a model should be from a `tf.data.Dataset`. # If each element of x and y are not tensors, we cannot standardize and - # validate the input and targets.` - if not tensor_util.is_tensor(x): - raise ValueError('Dataset input to the model should be tensors instead they' - ' are of type {}'.format(type(x))) + # validate the input and targets. + x_values_list = validate_per_device_inputs(distribution_strategy, x) - if not tensor_util.is_tensor(y): - raise ValueError('Dataset input to the model should be tensors instead they' - ' are of type {}'.format(type(y))) + y_values_list = validate_per_device_inputs(distribution_strategy, y) - # At this point both x and y contain tensors in the `DistributedValues` - # structure. - x_values = distribution_strategy.unwrap(x) - y_values = distribution_strategy.unwrap(y) + # Return the unwrapped values to avoid calling `unwrap` a second time. + return x_values_list, y_values_list - # Validate that the shape and dtype of all the elements in x are the same. - validate_all_tensor_shapes(x, x_values) - validate_all_tensor_types(x, x_values) - # Similarly for y, we perform the same validation - validate_all_tensor_shapes(y, y_values) - validate_all_tensor_types(y, y_values) +def validate_per_device_inputs(distribution_strategy, x): + """Validates PerDevice dataset input list. - # Return the unwrapped values to avoid calling `unwrap` a second time. - return x_values, y_values + Args: + distribution_strategy: The current DistributionStrategy used to call + `fit`, `evaluate` and `predict`. + x: A list of PerDevice objects that represent the input or + target values. + + Returns: + List containing the first element of each of the PerDevice objects in + the input list. + + Raises: + ValueError: If any of the objects in the `per_device_list` is not a tensor. + + """ + # Convert the inputs and targets into a list of PerDevice objects. + per_device_list = nest.flatten(x) + x_values_list = [] + for x in per_device_list: + if not tensor_util.is_tensor(x): + raise ValueError('Dataset input to the model should be tensors instead ' + 'they are of type {}'.format(type(x))) + + # At this point both x and y contain tensors in the `DistributedValues` + # structure. + x_values = distribution_strategy.unwrap(x) + + # Validate that the shape and dtype of all the elements in x are the same. + validate_all_tensor_shapes(x, x_values) + validate_all_tensor_types(x, x_values) + + x_values_list.append(x_values[0]) + return x_values_list def validate_all_tensor_types(x, x_values): diff --git a/tensorflow/python/keras/engine/training.py b/tensorflow/python/keras/engine/training.py index 7b974cab63..f71388cadb 100644 --- a/tensorflow/python/keras/engine/training.py +++ b/tensorflow/python/keras/engine/training.py @@ -845,8 +845,8 @@ class Model(Network): x_values, y_values = distributed_training_utils.\ validate_distributed_dataset_inputs(self._distribution_strategy, x, y) - _, _, sample_weights = self._standardize_weights(x_values[0], - y_values[0], + _, _, sample_weights = self._standardize_weights(x_values, + y_values, sample_weight, class_weight, batch_size) -- GitLab From a8e78e2e617b6ca10f4878fe99fdf43ddedfa7c6 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Fri, 10 Aug 2018 22:34:17 -0700 Subject: [PATCH 385/437] Rename MKL-related feature macros. The existing feature macros are named INTEL_MKL to indicate that any flavor of MKL is available, INTEL_MKL_ML to indicate that *only* MKL-ML is available (i.e. MKL-DNN is not), and DO_NOT_USE_ML to indicate that *only* MKL-DNN is available (i.e. MKL-ML is not). This change renames INTEL_MKL_ML to INTEL_MKL_ML_ONLY and DO_NOT_USE_ML to INTEL_MKL_DNN_ONLY. The meanings of the macros have not changed. This change also adds a few sanity checks to mkl_util.h that ensures that the combination of INTEL_MKL, INTEL_MKL_ML_ONLY, and INTEL_MKL_DNN_ONLY is logically consistent: the *_ONLY macros may not both be defined, and if either of them is defined, bare INTEL_MKL must also be defined. PiperOrigin-RevId: 208313735 --- .../xla/service/cpu/runtime_matmul_mkl.cc | 2 +- .../core/common_runtime/mkl_cpu_allocator.h | 4 +- tensorflow/core/graph/mkl_layout_pass.cc | 6 +-- tensorflow/core/graph/mkl_layout_pass_test.cc | 6 +-- .../core/kernels/batch_matmul_op_complex.cc | 2 +- .../core/kernels/batch_matmul_op_real.cc | 2 +- tensorflow/core/kernels/matmul_op.cc | 4 +- tensorflow/core/kernels/mkl_aggregate_ops.cc | 7 ++- tensorflow/core/kernels/mkl_avgpooling_op.cc | 6 +-- .../core/kernels/mkl_batch_matmul_op.cc | 2 +- tensorflow/core/kernels/mkl_concat_op.cc | 7 ++- .../core/kernels/mkl_conv_grad_bias_ops.cc | 6 +-- .../core/kernels/mkl_conv_grad_filter_ops.cc | 9 ++-- .../core/kernels/mkl_conv_grad_input_ops.cc | 10 ++-- tensorflow/core/kernels/mkl_conv_ops.cc | 6 +-- tensorflow/core/kernels/mkl_conv_ops.h | 7 ++- .../core/kernels/mkl_fused_batch_norm_op.cc | 7 ++- tensorflow/core/kernels/mkl_identity_op.cc | 6 +-- .../core/kernels/mkl_input_conversion_op.cc | 4 +- tensorflow/core/kernels/mkl_lrn_op.cc | 6 +-- tensorflow/core/kernels/mkl_matmul_op.cc | 8 ++-- tensorflow/core/kernels/mkl_maxpooling_op.cc | 6 +-- .../core/kernels/mkl_pooling_ops_common.cc | 6 +-- .../core/kernels/mkl_pooling_ops_common.h | 8 ++-- tensorflow/core/kernels/mkl_relu_op.cc | 12 ++--- tensorflow/core/kernels/mkl_reshape_op.cc | 7 ++- tensorflow/core/kernels/mkl_softmax_op.cc | 4 +- tensorflow/core/kernels/mkl_tfconv_op.h | 6 +-- tensorflow/core/kernels/mkl_transpose_op.cc | 20 ++++---- tensorflow/core/ops/nn_ops.cc | 10 ++-- tensorflow/core/util/mkl_util.h | 48 +++++++++++-------- tensorflow/core/util/mkl_util_test.cc | 4 +- tensorflow/tensorflow.bzl | 2 +- 33 files changed, 125 insertions(+), 125 deletions(-) diff --git a/tensorflow/compiler/xla/service/cpu/runtime_matmul_mkl.cc b/tensorflow/compiler/xla/service/cpu/runtime_matmul_mkl.cc index 997fdd2ab3..8dc5f3c93b 100644 --- a/tensorflow/compiler/xla/service/cpu/runtime_matmul_mkl.cc +++ b/tensorflow/compiler/xla/service/cpu/runtime_matmul_mkl.cc @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -#if defined(INTEL_MKL) && !defined(DO_NOT_USE_ML) +#if defined(INTEL_MKL) && !defined(INTEL_MKL_DNN_ONLY) #include "tensorflow/compiler/xla/service/cpu/runtime_matmul_mkl.h" #include "third_party/intel_mkl_ml/include/mkl_cblas.h" #include "third_party/intel_mkl_ml/include/mkl_service.h" diff --git a/tensorflow/core/common_runtime/mkl_cpu_allocator.h b/tensorflow/core/common_runtime/mkl_cpu_allocator.h index 94e10dbfa2..99bd43e090 100644 --- a/tensorflow/core/common_runtime/mkl_cpu_allocator.h +++ b/tensorflow/core/common_runtime/mkl_cpu_allocator.h @@ -28,7 +28,7 @@ limitations under the License. #include "tensorflow/core/lib/strings/str_util.h" #include "tensorflow/core/platform/mem.h" -#ifndef DO_NOT_USE_ML +#ifndef INTEL_MKL_DNN_ONLY #include "i_malloc.h" #endif @@ -98,7 +98,7 @@ class MklCPUAllocator : public VisitableAllocator { VLOG(1) << "MklCPUAllocator: Setting max_mem_bytes: " << max_mem_bytes; allocator_ = new BFCAllocator(new MklSubAllocator, max_mem_bytes, kAllowGrowth, kName); -#ifndef DO_NOT_USE_ML +#ifndef INTEL_MKL_DNN_ONLY // For redirecting all allocations from MKL to this allocator // From: http://software.intel.com/en-us/node/528565 i_malloc = MallocHook; diff --git a/tensorflow/core/graph/mkl_layout_pass.cc b/tensorflow/core/graph/mkl_layout_pass.cc index c22e0a3872..5683944e46 100644 --- a/tensorflow/core/graph/mkl_layout_pass.cc +++ b/tensorflow/core/graph/mkl_layout_pass.cc @@ -43,7 +43,7 @@ limitations under the License. namespace tensorflow { -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY // This pass implements rewriting of graph to support following scenarios: // (A) Merging nodes in the graph @@ -2211,7 +2211,7 @@ Status MklLayoutRewritePass::Run(const GraphOptimizationPassOptions& options) { return Status::OK(); } -#else // INTEL_MKL_ML +#else // INTEL_MKL_ML_ONLY // This pass implements rewriting of graph to support following scenarios: // (A) Merging nodes in the graph @@ -4474,7 +4474,7 @@ Status MklLayoutRewritePass::Run(const GraphOptimizationPassOptions& options) { return Status::OK(); } -#endif // INTEL_MKL_ML +#endif // INTEL_MKL_ML_ONLY } // namespace tensorflow #endif diff --git a/tensorflow/core/graph/mkl_layout_pass_test.cc b/tensorflow/core/graph/mkl_layout_pass_test.cc index a41f5861af..e8bac847e5 100644 --- a/tensorflow/core/graph/mkl_layout_pass_test.cc +++ b/tensorflow/core/graph/mkl_layout_pass_test.cc @@ -37,7 +37,7 @@ limitations under the License. namespace tensorflow { -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY namespace { @@ -1898,7 +1898,7 @@ BENCHMARK(BM_MklLayoutRewritePass)->Arg(1000)->Arg(10000); } // namespace -#else // INTEL_MKL_ML +#else // INTEL_MKL_ML_ONLY // NOTE: Unit tests in this file rely on a topological sorted graph for // printing. But since sibling nodes of a node in the topologically sorted graph @@ -3582,7 +3582,7 @@ BENCHMARK(BM_MklLayoutRewritePass)->Arg(1000)->Arg(10000); } // namespace -#endif // INTEL_MKL_ML +#endif // INTEL_MKL_ML_ONLY } // namespace tensorflow diff --git a/tensorflow/core/kernels/batch_matmul_op_complex.cc b/tensorflow/core/kernels/batch_matmul_op_complex.cc index b77c80c01f..54c45bfe63 100644 --- a/tensorflow/core/kernels/batch_matmul_op_complex.cc +++ b/tensorflow/core/kernels/batch_matmul_op_complex.cc @@ -17,7 +17,7 @@ limitations under the License. namespace tensorflow { -#if !defined(INTEL_MKL) || defined(DO_NOT_USE_ML) +#if !defined(INTEL_MKL) || defined(INTEL_MKL_DNN_ONLY) TF_CALL_complex64(REGISTER_BATCH_MATMUL_CPU); TF_CALL_complex128(REGISTER_BATCH_MATMUL_CPU); #endif diff --git a/tensorflow/core/kernels/batch_matmul_op_real.cc b/tensorflow/core/kernels/batch_matmul_op_real.cc index aa7a2752e8..584b507c70 100644 --- a/tensorflow/core/kernels/batch_matmul_op_real.cc +++ b/tensorflow/core/kernels/batch_matmul_op_real.cc @@ -21,7 +21,7 @@ limitations under the License. namespace tensorflow { -#if !defined(INTEL_MKL) || defined(DO_NOT_USE_ML) +#if !defined(INTEL_MKL) || defined(INTEL_MKL_DNN_ONLY) TF_CALL_float(REGISTER_BATCH_MATMUL_CPU); TF_CALL_double(REGISTER_BATCH_MATMUL_CPU); #endif diff --git a/tensorflow/core/kernels/matmul_op.cc b/tensorflow/core/kernels/matmul_op.cc index 5d4737549b..79967aab38 100644 --- a/tensorflow/core/kernels/matmul_op.cc +++ b/tensorflow/core/kernels/matmul_op.cc @@ -598,11 +598,11 @@ TF_CALL_float(REGISTER_CPU_EIGEN); // to use only opensource MKL DNN then use default implementation for these // types otherwise use GEMM from MKL ML binary -#if defined(DO_NOT_USE_ML) +#if defined(INTEL_MKL_DNN_ONLY) TF_CALL_complex64(REGISTER_CPU); TF_CALL_complex128(REGISTER_CPU); TF_CALL_double(REGISTER_CPU); -#else // DO_NOT_USE_ML +#else // INTEL_MKL_DNN_ONLY TF_CALL_complex64(REGISTER_CPU_EIGEN); TF_CALL_complex128(REGISTER_CPU_EIGEN); TF_CALL_double(REGISTER_CPU_EIGEN); diff --git a/tensorflow/core/kernels/mkl_aggregate_ops.cc b/tensorflow/core/kernels/mkl_aggregate_ops.cc index 3d04aeeb3e..28edf51546 100644 --- a/tensorflow/core/kernels/mkl_aggregate_ops.cc +++ b/tensorflow/core/kernels/mkl_aggregate_ops.cc @@ -24,8 +24,7 @@ limitations under the License. #include "tensorflow/core/lib/gtl/inlined_vector.h" #include "tensorflow/core/platform/logging.h" - -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY #include "mkldnn.hpp" using mkldnn::stream; using mkldnn::sum; @@ -38,7 +37,7 @@ using mkldnn::sum; namespace tensorflow { typedef Eigen::ThreadPoolDevice CPUDevice; -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY template class MklAddNOp : public OpKernel { @@ -286,7 +285,7 @@ class MklAddNOp : public OpKernel { } MklAddNOpContext; }; -#else // INTEL_MKL_ML +#else // INTEL_MKL_ML_ONLY template class MklAddNOp : public OpKernel { public: diff --git a/tensorflow/core/kernels/mkl_avgpooling_op.cc b/tensorflow/core/kernels/mkl_avgpooling_op.cc index d3566c2e37..969baecc51 100644 --- a/tensorflow/core/kernels/mkl_avgpooling_op.cc +++ b/tensorflow/core/kernels/mkl_avgpooling_op.cc @@ -24,7 +24,7 @@ #include "tensorflow/core/kernels/mkl_pooling_ops_common.h" -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY #include "mkldnn.hpp" using mkldnn::algorithm; using mkldnn::engine; @@ -40,7 +40,7 @@ namespace tensorflow { typedef Eigen::ThreadPoolDevice CPUDevice; -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY template class MklAvgPoolingOp : public OpKernel { @@ -664,7 +664,7 @@ class MklAvgPoolingGradOp : public MklPoolingBackwardOpBase { } }; // MklAvgPoolingGradOp -#endif // INTEL_MKL_ML +#endif // INTEL_MKL_ML_ONLY REGISTER_KERNEL_BUILDER(Name("_MklAvgPool") .Device(DEVICE_CPU) diff --git a/tensorflow/core/kernels/mkl_batch_matmul_op.cc b/tensorflow/core/kernels/mkl_batch_matmul_op.cc index 45328b03d6..0841395dc3 100644 --- a/tensorflow/core/kernels/mkl_batch_matmul_op.cc +++ b/tensorflow/core/kernels/mkl_batch_matmul_op.cc @@ -25,7 +25,7 @@ limitations under the License. #define EIGEN_USE_THREADS -#if defined(INTEL_MKL) && !defined(DO_NOT_USE_ML) +#if defined(INTEL_MKL) && !defined(INTEL_MKL_DNN_ONLY) #include #include "mkl_cblas.h" #include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor" diff --git a/tensorflow/core/kernels/mkl_concat_op.cc b/tensorflow/core/kernels/mkl_concat_op.cc index d8efb1be3e..8ad7ebb51f 100644 --- a/tensorflow/core/kernels/mkl_concat_op.cc +++ b/tensorflow/core/kernels/mkl_concat_op.cc @@ -27,8 +27,7 @@ limitations under the License. #include "tensorflow/core/lib/core/status.h" #include "tensorflow/core/platform/types.h" - -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY #include "mkldnn.hpp" using mkldnn::concat; @@ -64,7 +63,7 @@ class EigenConcatBaseOp : public OpKernel { // we need to have empty Compute because Compute is pure virtual function. void Compute(OpKernelContext* c) {} -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY void Compute(OpKernelContext* c, const std::vector& values) { const Tensor* concat_dim_tensor; @@ -232,7 +231,7 @@ class EigenConcatBaseOp : public OpKernel { #endif }; -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY // -------------------------------------------------------------------------- // Mkl Concat Op diff --git a/tensorflow/core/kernels/mkl_conv_grad_bias_ops.cc b/tensorflow/core/kernels/mkl_conv_grad_bias_ops.cc index f857be6c32..7c687f6581 100644 --- a/tensorflow/core/kernels/mkl_conv_grad_bias_ops.cc +++ b/tensorflow/core/kernels/mkl_conv_grad_bias_ops.cc @@ -18,7 +18,7 @@ limitations under the License. // bias. #ifdef INTEL_MKL -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY #define USE_EIGEN_TENSOR #define EIGEN_USE_THREADS @@ -39,7 +39,7 @@ limitations under the License. #include "tensorflow/core/util/use_cudnn.h" #include "tensorflow/core/util/work_sharder.h" -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY #include "mkl_dnn.h" #include "mkl_dnn_types.h" #endif @@ -265,5 +265,5 @@ class MklConv2DCustomBackpropBiasOp : public OpKernel { TF_CALL_float(REGISTER_CPU_KERNELS); #undef REGISTER_CPU_KERNELS } /* namespace tensorflow */ -#endif /* INTEL_MKL_ML */ +#endif /* INTEL_MKL_ML_ONLY */ #endif /* INTEL_MKL */ diff --git a/tensorflow/core/kernels/mkl_conv_grad_filter_ops.cc b/tensorflow/core/kernels/mkl_conv_grad_filter_ops.cc index b73a119a88..50c25e1da7 100644 --- a/tensorflow/core/kernels/mkl_conv_grad_filter_ops.cc +++ b/tensorflow/core/kernels/mkl_conv_grad_filter_ops.cc @@ -38,8 +38,7 @@ limitations under the License. #include "tensorflow/core/util/use_cudnn.h" #include "tensorflow/core/util/work_sharder.h" - -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY #include "mkldnn.hpp" using mkldnn::convolution_backward_weights; @@ -56,7 +55,7 @@ using mkldnn::stream; namespace tensorflow { typedef Eigen::ThreadPoolDevice CPUDevice; -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY struct MklConvBwdFilterParams { memory::dims src_dims; @@ -358,7 +357,7 @@ class MklConv2DBwdFilterPrimitiveFactory : public MklPrimitiveFactory { #endif -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY template class MklConv2DCustomBackpropFilterOp : public OpKernel { @@ -1050,7 +1049,7 @@ class MklConv2DCustomBackpropFilterOp TF_CALL_float(REGISTER_MKL_FILTER_KERNELS); #undef REGISTER_MKL_FILTER_KERNELS -#endif // INTEL_MKL_ML +#endif // INTEL_MKL_ML_ONLY } // namespace tensorflow diff --git a/tensorflow/core/kernels/mkl_conv_grad_input_ops.cc b/tensorflow/core/kernels/mkl_conv_grad_input_ops.cc index 39498f1a80..38e014d68e 100644 --- a/tensorflow/core/kernels/mkl_conv_grad_input_ops.cc +++ b/tensorflow/core/kernels/mkl_conv_grad_input_ops.cc @@ -23,7 +23,7 @@ limitations under the License. #define EIGEN_USE_THREADS #include #include -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY #include "mkl_dnn.h" #include "mkl_dnn_types.h" #endif @@ -46,7 +46,7 @@ limitations under the License. #include "tensorflow/core/util/use_cudnn.h" #include "tensorflow/core/util/work_sharder.h" -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY #include "mkldnn.hpp" using mkldnn::convolution_backward_data; @@ -57,7 +57,7 @@ using mkldnn::stream; namespace tensorflow { typedef Eigen::ThreadPoolDevice CPUDevice; -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY /// utility classes enabling primitive reuse for backward conv2d ops. struct MklConvBwdInputParams { @@ -294,7 +294,7 @@ class MklConv2DBwdInputPrimitiveFactory : public MklPrimitiveFactory { #endif -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY template class MklConv2DCustomBackpropInputOp : public OpKernel { @@ -839,7 +839,7 @@ class MklConv2DCustomBackpropInputOp } }; -#endif // INTEL_MKL_ML +#endif // INTEL_MKL_ML_ONLY #define REGISTER_MKL_CPU_KERNELS(T) \ REGISTER_KERNEL_BUILDER(Name("_MklConv2DBackpropInput") \ diff --git a/tensorflow/core/kernels/mkl_conv_ops.cc b/tensorflow/core/kernels/mkl_conv_ops.cc index 62396eeb8b..bca1aa21a8 100644 --- a/tensorflow/core/kernels/mkl_conv_ops.cc +++ b/tensorflow/core/kernels/mkl_conv_ops.cc @@ -42,7 +42,7 @@ limitations under the License. #include "tensorflow/core/util/mkl_util.h" -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY #include "mkldnn.hpp" using mkldnn::prop_kind; @@ -57,7 +57,7 @@ using mkldnn::convolution_direct; namespace tensorflow { -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY // This structure aggregates multiple inputs to Conv2DFwd* methods. struct MklConvFwdParams { @@ -329,7 +329,7 @@ class MklConv2DFwdPrimitiveFactory : public MklPrimitiveFactory { typedef Eigen::ThreadPoolDevice CPUDevice; // For now, MKL-ML is default. So making MKL-DNN not a default choice. -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY template class MklConv2DOp : public OpKernel { public: diff --git a/tensorflow/core/kernels/mkl_conv_ops.h b/tensorflow/core/kernels/mkl_conv_ops.h index 3f154ff33b..838c06f49d 100644 --- a/tensorflow/core/kernels/mkl_conv_ops.h +++ b/tensorflow/core/kernels/mkl_conv_ops.h @@ -40,7 +40,7 @@ limitations under the License. #include "tensorflow/core/util/mkl_util.h" -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY #include "mkldnn.hpp" using mkldnn::prop_kind; @@ -52,7 +52,7 @@ using mkldnn::convolution_forward; namespace tensorflow { -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY class MklDnnConvUtil { protected: @@ -397,8 +397,7 @@ class MklConv2DBackpropCommonOp : public OpKernel { TensorFormat data_format_; // NCHW or NHWC }; -#endif // INTEL_MKL_ML - +#endif // INTEL_MKL_ML_ONLY ///////////////////////////////////////////////////////////////////// /// Dummy Mkl op that is just used for operators that are intermediate diff --git a/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc b/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc index aa572fb0a3..2ec6c8fa89 100644 --- a/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc +++ b/tensorflow/core/kernels/mkl_fused_batch_norm_op.cc @@ -21,8 +21,7 @@ limitations under the License. #include "tensorflow/core/framework/tensor_types.h" #include "tensorflow/core/util/tensor_format.h" - -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY #include "mkldnn.hpp" using mkldnn::batch_normalization_backward; using mkldnn::batch_normalization_forward; @@ -41,7 +40,7 @@ using mkldnn::use_scale_shift; namespace tensorflow { using CPUDevice = Eigen::ThreadPoolDevice; -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY template class MklFusedBatchNormOp : public OpKernel { @@ -684,7 +683,7 @@ class MklFusedBatchNormGradOp : public OpKernel { }; #endif -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY struct MklBatchNormFwdParams { memory::dims src_dims; diff --git a/tensorflow/core/kernels/mkl_identity_op.cc b/tensorflow/core/kernels/mkl_identity_op.cc index b02cc5384c..b57e816028 100644 --- a/tensorflow/core/kernels/mkl_identity_op.cc +++ b/tensorflow/core/kernels/mkl_identity_op.cc @@ -24,20 +24,20 @@ limitations under the License. #include "tensorflow/core/lib/core/status.h" #include "tensorflow/core/platform/logging.h" -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY #include "mkl_dnn.h" #include "mkl_dnn_types.h" #endif #include "tensorflow/core/util/mkl_util.h" -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY #include "mkldnn.hpp" #endif namespace tensorflow { typedef Eigen::ThreadPoolDevice CPUDevice; -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY template class MklIdentityOp : public OpKernel { diff --git a/tensorflow/core/kernels/mkl_input_conversion_op.cc b/tensorflow/core/kernels/mkl_input_conversion_op.cc index dc4da33a06..06ce820ae9 100644 --- a/tensorflow/core/kernels/mkl_input_conversion_op.cc +++ b/tensorflow/core/kernels/mkl_input_conversion_op.cc @@ -32,7 +32,7 @@ limitations under the License. #include "tensorflow/core/kernels/mkl_tfconv_op.h" #include "tensorflow/core/util/mkl_util.h" -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY #include "mkldnn.hpp" using mkldnn::stream; @@ -60,7 +60,7 @@ typedef Eigen::ThreadPoolDevice CPUDevice; // convert the TF format input to MKL format /////////////////////////////////////////////////////////// -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY template class MklInputConversionOp : public OpKernel { public: diff --git a/tensorflow/core/kernels/mkl_lrn_op.cc b/tensorflow/core/kernels/mkl_lrn_op.cc index 7966c271d5..22ff4cd80f 100644 --- a/tensorflow/core/kernels/mkl_lrn_op.cc +++ b/tensorflow/core/kernels/mkl_lrn_op.cc @@ -35,7 +35,7 @@ limitations under the License. #include "tensorflow/core/util/work_sharder.h" #endif -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY #include "mkldnn.hpp" using mkldnn::lrn_across_channels; using mkldnn::lrn_backward; @@ -69,7 +69,7 @@ void GetBandMatrix(int depth, int depth_radius, } // namespace -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY template class MklLRNOp : public OpKernel { @@ -1345,7 +1345,7 @@ class MklLRNGradOp : public OpKernel { float beta_; }; -#endif // INTEL_MKL_ML +#endif // INTEL_MKL_ML_ONLY #define REGISTER_MKL_LRN_CPU(T) \ REGISTER_KERNEL_BUILDER(Name("_MklLRN") \ diff --git a/tensorflow/core/kernels/mkl_matmul_op.cc b/tensorflow/core/kernels/mkl_matmul_op.cc index fd261433a0..077d62ce32 100644 --- a/tensorflow/core/kernels/mkl_matmul_op.cc +++ b/tensorflow/core/kernels/mkl_matmul_op.cc @@ -31,7 +31,7 @@ limitations under the License. #include "tensorflow/core/kernels/fill_functor.h" // This header file is part of MKL ML, need equivalent file in MKL DNN -#ifndef DO_NOT_USE_ML +#ifndef INTEL_MKL_DNN_ONLY #include "mkl_cblas.h" #else #include "mkldnn.h" @@ -155,7 +155,7 @@ class MklMatMulOp : public OpKernel { // 1.0 and 0.0 respectively. const float alpha = 1.0f; const float beta = 0.0f; -#if defined(DO_NOT_USE_ML) +#if defined(INTEL_MKL_DNN_ONLY) const char* const ftrans[] = {"N", "T", "C"}; int index_transa = transa ? 1 : 0; int index_transb = transb ? 1 : 0; @@ -173,7 +173,7 @@ class MklMatMulOp : public OpKernel { } // MKLDNN only supports SGEMM -#ifndef DO_NOT_USE_ML +#ifndef INTEL_MKL_DNN_ONLY // Matrix-Matrix Multiplication with FP64 tensors. For detailed info about // parameters, look at FP32 function description. @@ -229,7 +229,7 @@ class MklMatMulOp : public OpKernel { // additional types TF_CALL_float(REGISTER_CPU); -#ifndef DO_NOT_USE_ML +#ifndef INTEL_MKL_DNN_ONLY TF_CALL_double(REGISTER_CPU); TF_CALL_complex64(REGISTER_CPU); TF_CALL_complex128(REGISTER_CPU); diff --git a/tensorflow/core/kernels/mkl_maxpooling_op.cc b/tensorflow/core/kernels/mkl_maxpooling_op.cc index 0a2151566e..e149f003e5 100644 --- a/tensorflow/core/kernels/mkl_maxpooling_op.cc +++ b/tensorflow/core/kernels/mkl_maxpooling_op.cc @@ -22,7 +22,7 @@ limitations under the License. #include "tensorflow/core/util/mkl_util.h" #include "tensorflow/core/util/padding.h" -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY #include #include "mkldnn.hpp" using mkldnn::algorithm; @@ -40,7 +40,7 @@ namespace tensorflow { typedef Eigen::ThreadPoolDevice CPUDevice; // MKL-DNN is now default. MKL-ML must be specified explicitly. -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY // An implementation of MaxPooling (forward). template @@ -817,7 +817,7 @@ class MklMaxPoolingGradOp : public MklPoolingBackwardOpBase { } }; // MklMaxPoolingGradOp -#endif // INTEL_MKL_ML +#endif // INTEL_MKL_ML_ONLY REGISTER_KERNEL_BUILDER(Name("_MklMaxPool") .Device(DEVICE_CPU) diff --git a/tensorflow/core/kernels/mkl_pooling_ops_common.cc b/tensorflow/core/kernels/mkl_pooling_ops_common.cc index 915878d9ea..d7ad3f9dcd 100644 --- a/tensorflow/core/kernels/mkl_pooling_ops_common.cc +++ b/tensorflow/core/kernels/mkl_pooling_ops_common.cc @@ -223,7 +223,7 @@ void MklPoolParameters::Init(OpKernelContext* context, Init(context, ksize, stride, padding, data_format); } -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY // Initialization for MKL format void MklPoolParameters::Init(OpKernelContext* context, const std::vector& ksize, @@ -253,7 +253,7 @@ void MklPoolParameters::Init(OpKernelContext* context, Init(context, ksize, stride, padding, data_format); } -#endif // INTEL_MKL_ML +#endif // INTEL_MKL_ML_ONLY // Common Initialization for TensorFlow and MKL formats void MklPoolParameters::Init(OpKernelContext* context, const std::vector& ksize, @@ -288,7 +288,7 @@ void MklPoolParameters::Init(OpKernelContext* context, OP_REQUIRES_OK(context, GetWindowedOutputSizeVerbose( tensor_in_cols, window_cols, col_stride, padding, &out_width, &pad_left, &pad_right)); -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY // TF can work with int64, but mkldnn only supports int32 // Fail if the height or width are greater than MAX_INT diff --git a/tensorflow/core/kernels/mkl_pooling_ops_common.h b/tensorflow/core/kernels/mkl_pooling_ops_common.h index 3a3de1c58b..ec7af5092d 100644 --- a/tensorflow/core/kernels/mkl_pooling_ops_common.h +++ b/tensorflow/core/kernels/mkl_pooling_ops_common.h @@ -22,7 +22,7 @@ limitations under the License. #include "tensorflow/core/util/mkl_util.h" #include "tensorflow/core/util/padding.h" -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY #include "mkldnn.hpp" using mkldnn::memory; using mkldnn::pooling_backward; @@ -405,7 +405,7 @@ struct MklPoolParameters { void Init(OpKernelContext* context, const std::vector& ksize, const std::vector& stride, Padding padding, TensorFormat data_format, const TensorShape& tensor_in_shape); -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY void Init(OpKernelContext* context, const std::vector& ksize, const std::vector& stride, Padding padding, TensorFormat data_format, const MklShape* mkl_in_shape); @@ -422,7 +422,7 @@ struct MklPoolParameters { TensorFormat data_format); }; -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY template class MklPoolingOpBase : public OpKernel { @@ -674,7 +674,7 @@ class MklPoolingBackwardOpBase : public MklPoolingOpBase { return grad_reorder_needed ? target_diff_dst_md : original_input_grad_md; } }; -#endif // INTEL_MKL_ML +#endif // INTEL_MKL_ML_ONLY //------------------------------------------------------------------- // Utility functions diff --git a/tensorflow/core/kernels/mkl_relu_op.cc b/tensorflow/core/kernels/mkl_relu_op.cc index 78abbdb730..05034894e5 100644 --- a/tensorflow/core/kernels/mkl_relu_op.cc +++ b/tensorflow/core/kernels/mkl_relu_op.cc @@ -23,8 +23,7 @@ limitations under the License. #include "tensorflow/core/framework/tensor.h" #include "tensorflow/core/lib/core/errors.h" - -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY #include "mkldnn.hpp" using mkldnn::algorithm; @@ -58,7 +57,7 @@ struct MklReluHelpers { } }; -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY template class MklReluOp : public OpKernel { @@ -368,10 +367,7 @@ void MklReluGradOp::Compute(OpKernelContext* context) { mkl_context.MklCleanup(); } - - -#else // INTEL_MKL_ML - +#else // INTEL_MKL_ML_ONLY template class MklReluOpBase : public OpKernel { @@ -874,7 +870,7 @@ class MklTanhGradOp : public MklReluGradOpBase { MklReluGradOp); TF_CALL_float(REGISTER_RELU_MKL_SUPPORTED_KERNELS_TYPES); -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY // register dnn kernels for supported operations and supported types #define REGISTER_ELU_MKL_SUPPORTED_KERNELS_TYPES(type) \ diff --git a/tensorflow/core/kernels/mkl_reshape_op.cc b/tensorflow/core/kernels/mkl_reshape_op.cc index 9c536df215..d9a7893a53 100644 --- a/tensorflow/core/kernels/mkl_reshape_op.cc +++ b/tensorflow/core/kernels/mkl_reshape_op.cc @@ -24,8 +24,7 @@ limitations under the License. #include "tensorflow/core/lib/core/status.h" #include "tensorflow/core/platform/logging.h" - -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY #include "mkldnn.hpp" using mkldnn::stream; #else @@ -42,7 +41,7 @@ class MklReshapeOp : public OpKernel { public: explicit MklReshapeOp(OpKernelConstruction* context) : OpKernel(context) {} -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY void Compute(OpKernelContext* context) override { const Tensor& input = MklGetInput(context, 0); const Tensor& sizes = MklGetInput(context, 1); @@ -317,7 +316,7 @@ class MklReshapeOp : public OpKernel { } } -#endif // INTEL_MKL_ML +#endif // INTEL_MKL_ML_ONLY private: const int kInputSlotIdx = 0; diff --git a/tensorflow/core/kernels/mkl_softmax_op.cc b/tensorflow/core/kernels/mkl_softmax_op.cc index 638392954e..8bde966be9 100644 --- a/tensorflow/core/kernels/mkl_softmax_op.cc +++ b/tensorflow/core/kernels/mkl_softmax_op.cc @@ -15,7 +15,7 @@ limitations under the License. // See docs in ../ops/nn_ops.cc. #ifdef INTEL_MKL -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY #include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor" #include "tensorflow/core/framework/numeric_op.h" @@ -153,5 +153,5 @@ TF_CALL_float(REGISTER_SOFTMAX_MKL_SUPPORTED_KERNELS_TYPES); } // namespace tensorflow -#endif // INTEL_MKL_ML +#endif // INTEL_MKL_ML_ONLY #endif // INTEL_MKL diff --git a/tensorflow/core/kernels/mkl_tfconv_op.h b/tensorflow/core/kernels/mkl_tfconv_op.h index a9e92f6638..894c2e34e8 100644 --- a/tensorflow/core/kernels/mkl_tfconv_op.h +++ b/tensorflow/core/kernels/mkl_tfconv_op.h @@ -32,13 +32,13 @@ limitations under the License. #include "tensorflow/core/platform/macros.h" #include "tensorflow/core/util/tensor_format.h" -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY #include "mkl_dnn.h" #include "mkl_dnn_types.h" #endif #include "tensorflow/core/util/mkl_util.h" -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY using mkldnn::stream; #endif @@ -64,7 +64,7 @@ class MklToTfOp : public OpKernel { VLOG(1) << "MKLToTFConversion complete successfully."; } -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY static void ConvertMklToTf(OpKernel* op_kernel, OpKernelContext* context, string data_format_str, DataType op_data_type, bool has_avx512f, uint input_number) { diff --git a/tensorflow/core/kernels/mkl_transpose_op.cc b/tensorflow/core/kernels/mkl_transpose_op.cc index 109e634feb..6bbe271c54 100644 --- a/tensorflow/core/kernels/mkl_transpose_op.cc +++ b/tensorflow/core/kernels/mkl_transpose_op.cc @@ -18,14 +18,14 @@ limitations under the License. #if defined(INTEL_MKL) #define EIGEN_USE_THREADS -#if !defined(DO_NOT_USE_ML) +#if !defined(INTEL_MKL_DNN_ONLY) #include "mkl_trans.h" #endif #include "tensorflow/core/kernels/transpose_functor.h" #include "tensorflow/core/kernels/transpose_op.h" -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY #include "mkldnn.hpp" #include "tensorflow/core/util/mkl_util.h" @@ -50,7 +50,7 @@ namespace tensorflow { // REQUIRES: perm is a permutation. namespace { -#if !defined(DO_NOT_USE_ML) +#if !defined(INTEL_MKL_DNN_ONLY) template Status MKLTranspose2D(const char trans, const Tensor& in, Tensor* out); @@ -104,9 +104,9 @@ Status MKLTranspose2D(const char trans, const Tensor& in, static const char kMKLTranspose = 'T'; static const char kMKLConjugateTranspose = 'C'; -#endif // if !defined(DO_NOT_USE_ML) +#endif // if !defined(INTEL_MKL_DNN_ONLY) -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY // MKL-DNN based Transpose implementation template Status MKLTransposeND(OpKernelContext* ctx, const Tensor& in, Tensor* out, @@ -154,14 +154,14 @@ Status MKLTransposeND(OpKernelContext* context, const Tensor& in_tensor, return errors::Aborted("Operation received an exception:", error_msg); } } -#endif // #ifndef INTEL_MKL_ML +#endif // #ifndef INTEL_MKL_ML_ONLY } // namespace Status MklTransposeCpuOp::DoTranspose(OpKernelContext* ctx, const Tensor& in, gtl::ArraySlice perm, Tensor* out) { -#if !defined(DO_NOT_USE_ML) +#if !defined(INTEL_MKL_DNN_ONLY) if (in.dims() == 2) { if (perm[0] == 0 && perm[1] == 1) { return Status::OK(); @@ -181,7 +181,7 @@ Status MklTransposeCpuOp::DoTranspose(OpKernelContext* ctx, const Tensor& in, } #endif -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY // MKL-DNN has limit on the maximum number of dimensions in a tensor. // Fallback to Eigen for not supported cases. if (in.dims() <= TENSOR_MAX_DIMS) { @@ -206,7 +206,7 @@ Status MklConjugateTransposeCpuOp::DoTranspose(OpKernelContext* ctx, const Tensor& in, gtl::ArraySlice perm, Tensor* out) { -#if !defined(DO_NOT_USE_ML) +#if !defined(INTEL_MKL_DNN_ONLY) if (in.dims() == 2 && perm[0] == 1 && perm[1] == 0) { // TODO(rmlarsen): By setting lda and ldb, we could use the MKL kernels // for any transpose that can be reduced to swapping the last two @@ -227,7 +227,7 @@ Status MklConjugateTransposeCpuOp::DoTranspose(OpKernelContext* ctx, } #endif -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY // MKL-DNN has limit on the maximum number of dimensions in a tensor. // Fallback to Eigen for not supported cases. if (in.dims() <= TENSOR_MAX_DIMS) { diff --git a/tensorflow/core/ops/nn_ops.cc b/tensorflow/core/ops/nn_ops.cc index f947d4c30d..e0f25fb4ef 100644 --- a/tensorflow/core/ops/nn_ops.cc +++ b/tensorflow/core/ops/nn_ops.cc @@ -1687,7 +1687,7 @@ NOTE Do not invoke this operator directly in Python. Graph rewrite pass is expected to invoke these operators. )doc"); -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY REGISTER_OP("_MklConv2DWithBiasBackpropBias") .Input("out_backprop: T") .Input("mkl_out_backprop: uint8") @@ -1849,7 +1849,7 @@ REGISTER_OP("_MklMaxPool") .Input("input: T") .Input("mkl_input: uint8") .Output("output: T") -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY .Output("workspace: T") #else .Output("workspace: uint8") @@ -1875,7 +1875,7 @@ REGISTER_OP("_MklMaxPoolGrad") .Input("orig_input: T") .Input("orig_output: T") .Input("grad: T") -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY .Input("workspace: T") #else .Input("workspace: uint8") @@ -1947,7 +1947,7 @@ REGISTER_OP("_MklLRN") .Input("input: T") .Input("mkl_input: uint8") .Output("output: T") -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY .Output("workspace: T") #else .Output("workspace: uint8") @@ -1975,7 +1975,7 @@ REGISTER_OP("_MklLRNGrad") .Input("input_grads: T") .Input("input_image: T") .Input("output_image: T") -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY .Input("workspace: T") #else .Input("workspace: uint8") diff --git a/tensorflow/core/util/mkl_util.h b/tensorflow/core/util/mkl_util.h index a66b1215bd..159a787d05 100644 --- a/tensorflow/core/util/mkl_util.h +++ b/tensorflow/core/util/mkl_util.h @@ -22,7 +22,17 @@ limitations under the License. #include #include -#ifdef INTEL_MKL_ML +#if defined(INTEL_MKL_ML_ONLY) || defined(INTEL_MKL_DNN_ONLY) +#ifndef INTEL_MKL +#error "INTEL_MKL_{ML,DNN}_ONLY require INTEL_MKL" +#endif +#endif + +#if defined(INTEL_MKL_ML_ONLY) && defined(INTEL_MKL_DNN_ONLY) +#error "at most one of INTEL_MKL_ML_ONLY and INTEL_MKL_DNN_ONLY may be defined" +#endif + +#ifdef INTEL_MKL_ML_ONLY #include "mkl_dnn.h" #include "mkl_dnn_types.h" #include "mkl_service.h" @@ -40,7 +50,8 @@ limitations under the License. #include "tensorflow/core/platform/macros.h" #include "tensorflow/core/util/padding.h" #include "tensorflow/core/util/tensor_format.h" -#ifndef INTEL_MKL_ML + +#ifndef INTEL_MKL_ML_ONLY #include "mkldnn.hpp" #include "tensorflow/core/lib/core/stringpiece.h" @@ -76,7 +87,7 @@ typedef enum { Dim_I = 1 } MklDnnDims; -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY class MklShape { public: MklShape() {} @@ -670,14 +681,13 @@ class MklDnnShape { // List of MklShape objects. Used in Concat/Split layers. - -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY typedef std::vector MklDnnShapeList; #else typedef std::vector MklShapeList; #endif -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY // Check if all tensors specified by MklShapes are MKL tensors. inline bool AreAllMklTensors(const MklShapeList& shapes) { for (auto& s : shapes) { @@ -760,7 +770,7 @@ inline Tensor ConvertMklToTF(OpKernelContext* context, const Tensor& mkl_tensor, #endif // Get the MKL shape from the second string tensor -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY inline void GetMklShape(OpKernelContext* ctext, int n, MklShape* mklshape) { mklshape->DeSerializeMklShape( ctext->input(GetTensorMetaDataIndex(n, ctext->num_inputs())) @@ -795,7 +805,7 @@ inline void GetMklInputList(OpKernelContext* ctext, StringPiece name, ctext->input_list(name, input_tensors); } -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY inline void GetMklShapeList(OpKernelContext* ctext, StringPiece name, MklShapeList* mkl_shapes) { @@ -825,7 +835,7 @@ inline void GetMklShapeList(OpKernelContext* ctext, StringPiece name, #endif -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY /// Get shape of input tensor pointed by 'input_idx' in TensorShape format. /// If the input tensor is in MKL layout, then obtains TensorShape from /// MklShape. @@ -845,7 +855,7 @@ inline TensorShape GetTfShape(OpKernelContext* context, size_t input_idx) { } #endif -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY // Allocate the second output tensor that will contain // the MKL shape serialized inline void AllocateOutputSetMklShape(OpKernelContext* ctext, int n, @@ -878,7 +888,7 @@ inline void AllocateOutputSetMklShape(OpKernelContext* ctext, int n, } #endif -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY // Allocate the output tensor, create a second output tensor that will contain // the MKL shape serialized inline void AllocateOutputSetMklShape(OpKernelContext* ctext, int n, @@ -923,7 +933,7 @@ inline void AllocateOutputSetMklShape(OpKernelContext* ctext, int n, // Allocates a temp tensor and returns the data buffer for temporary storage. // Currently -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY template inline void AllocTmpBuffer(OpKernelContext* context, Tensor* tensor_out, const memory::primitive_desc& pd, void** buf_out) { @@ -972,7 +982,7 @@ inline void GetStridesFromSizes(TensorFormat data_format, size_t* strides, } } -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY inline void MklSizesToTFSizes(OpKernelContext* context, TensorFormat data_format_, const MklShape& mkl_shape, @@ -1016,7 +1026,7 @@ inline int32 GetMklTensorDimIndex(char dimension) { } } -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY inline int64 GetMklTensorDim(const MklShape& mkl_shape, char dimension) { int index = GetMklTensorDimIndex(dimension); CHECK(index >= 0 && index < mkl_shape.GetDimension()) @@ -1046,7 +1056,7 @@ inline void CopyMklTensorInToOut(OpKernelContext* context, int idx_in, context->set_output(idx_meta_out, meta_output); } -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY inline void CopyTfTensorInToOutWithShape(OpKernelContext* context, int idx_in, int idx_out, const TensorShape& shape) { @@ -1084,7 +1094,7 @@ inline void CopyTfTensorInToOutWithShape(OpKernelContext* context, int idx_in, } #endif -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY inline void ForwardTfTensorInToOut(OpKernelContext* context, int idx_in, int idx_out) { @@ -1142,7 +1152,7 @@ inline void ForwardMklTensorInToOut(OpKernelContext* context, int idx_in, } } -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY // Set a dummy MKLDNN shape (called when the output is in TF format) inline void SetDummyMklDnnShapeOutput(OpKernelContext* context, uint32 idx_data_out) { @@ -1186,7 +1196,7 @@ inline void ForwardMklMetaDataInToOut(OpKernelContext* context, } } -#ifdef INTEL_MKL_ML +#ifdef INTEL_MKL_ML_ONLY // Set a dummy MKL shape (called when the output is in TF format) inline void SetDummyMklShapeOutput(OpKernelContext* context, uint32 idx_data_out) { @@ -1303,7 +1313,7 @@ inline void MklNCHWToNHWC(const Tensor& input, Tensor** output) { #endif // ------------------------------------------------------------------- -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY /// Return MKL-DNN data type (memory::data_type) for input type T /// diff --git a/tensorflow/core/util/mkl_util_test.cc b/tensorflow/core/util/mkl_util_test.cc index cd1d0713ad..4f837f105d 100644 --- a/tensorflow/core/util/mkl_util_test.cc +++ b/tensorflow/core/util/mkl_util_test.cc @@ -22,7 +22,7 @@ limitations under the License. namespace tensorflow { namespace { -#ifndef INTEL_MKL_ML +#ifndef INTEL_MKL_ML_ONLY TEST(MklUtilTest, MklDnnTfShape) { auto cpu_engine = engine(engine::cpu, 0); @@ -84,7 +84,7 @@ TEST(MklUtilTest, MklDnnBlockedFormatTest) { EXPECT_EQ(b_md2.data.format, mkldnn_blocked); } -#endif // INTEL_MKL_ML +#endif // INTEL_MKL_ML_ONLY } // namespace } // namespace tensorflow diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl index ca9c0d0aae..30dc4313d0 100644 --- a/tensorflow/tensorflow.bzl +++ b/tensorflow/tensorflow.bzl @@ -230,7 +230,7 @@ def tf_copts(android_optimization_level_override="-O2", is_external=False): + if_cuda(["-DGOOGLE_CUDA=1"]) + if_tensorrt(["-DGOOGLE_TENSORRT=1"]) + if_mkl(["-DINTEL_MKL=1", "-DEIGEN_USE_VML"]) - + if_mkl_open_source_only(["-DDO_NOT_USE_ML"]) + + if_mkl_open_source_only(["-DINTEL_MKL_DNN_ONLY"]) + if_mkl_lnx_x64(["-fopenmp"]) + if_android_arm(["-mfpu=neon"]) + if_linux_x86_64(["-msse3"]) -- GitLab From 3b061fce8b9a1c867f2798d51b5375ea3a03b385 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Sat, 11 Aug 2018 02:02:02 -0700 Subject: [PATCH 386/437] compat: Update forward compatibility horizon to 2018-08-11 PiperOrigin-RevId: 208323893 --- tensorflow/python/compat/compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/python/compat/compat.py b/tensorflow/python/compat/compat.py index 42a2199305..f33e881d87 100644 --- a/tensorflow/python/compat/compat.py +++ b/tensorflow/python/compat/compat.py @@ -26,7 +26,7 @@ import datetime from tensorflow.python.util import tf_contextlib from tensorflow.python.util.tf_export import tf_export -_FORWARD_COMPATIBILITY_HORIZON = datetime.date(2018, 8, 10) +_FORWARD_COMPATIBILITY_HORIZON = datetime.date(2018, 8, 11) @tf_export("compat.forward_compatible") -- GitLab From d3b03f86d38ee8da9000f94344ef51b9ff76a790 Mon Sep 17 00:00:00 2001 From: Jacques Pienaar Date: Sat, 11 Aug 2018 09:36:49 -0700 Subject: [PATCH 387/437] Guard zeros by ZerosLikeOutsideLoop by pivot instead of switch. The constant should be dependent on the then/else edge of the switch instead of the switch. PiperOrigin-RevId: 208342636 --- tensorflow/python/kernel_tests/control_flow_ops_py_test.py | 3 ++- tensorflow/python/ops/control_flow_ops.py | 7 +++++-- 2 files changed, 7 insertions(+), 3 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 b567b71424..1a29d0816d 100644 --- a/tensorflow/python/kernel_tests/control_flow_ops_py_test.py +++ b/tensorflow/python/kernel_tests/control_flow_ops_py_test.py @@ -647,7 +647,8 @@ class ControlFlowTest(test.TestCase): # feeding into the fill is dominated by a Switch. zero = graph.get_operation_by_name("gradients/zeros/Const") self.assertEqual(len(zero.control_inputs), 1) - self.assertEqual(zero.control_inputs[0].type, "Switch") + self.assertEqual(zero.control_inputs[0].type, "Identity") + self.assertEqual(zero.control_inputs[0].inputs[0].op.type, "Switch") def testCondGrad_2(self): with self.test_session(): diff --git a/tensorflow/python/ops/control_flow_ops.py b/tensorflow/python/ops/control_flow_ops.py index 75d07454b3..f84ff4ddf0 100644 --- a/tensorflow/python/ops/control_flow_ops.py +++ b/tensorflow/python/ops/control_flow_ops.py @@ -1449,14 +1449,17 @@ def ZerosLikeOutsideLoop(op, index): pred = op_ctxt.pred branch = op_ctxt.branch switch_val = switch(op.inputs[0], pred)[1 - branch] + # A op is created along the branch taken as control dependencies are on + # the whole op and not on the tensor output. + pivot = array_ops.identity(switch_val) if val.dtype == dtypes.resource: - with ops.control_dependencies([switch_val]): + with ops.control_dependencies([pivot]): return array_ops.zeros( gen_resource_variable_ops.variable_shape(switch_val)) zeros_shape = array_ops.shape_internal(switch_val, optimize=False) # Ensure ops created within array_ops.zeros are dominated by switch in # cond context. - with ops.control_dependencies([switch_val]): + with ops.control_dependencies([pivot]): return array_ops.zeros(zeros_shape, dtype=val.dtype) else: return array_ops.zeros_like(val, optimize=False) -- GitLab From ebfa84016deceb3a1d01aabed292d369e5e872e4 Mon Sep 17 00:00:00 2001 From: Misha Brukman Date: Sat, 11 Aug 2018 13:57:17 -0700 Subject: [PATCH 388/437] Use the full product name: Google Cloud Bigtable PiperOrigin-RevId: 208352025 --- tensorflow/contrib/bigtable/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow/contrib/bigtable/README.md b/tensorflow/contrib/bigtable/README.md index 88a3909de4..b9abfa8295 100644 --- a/tensorflow/contrib/bigtable/README.md +++ b/tensorflow/contrib/bigtable/README.md @@ -1,4 +1,4 @@ -# Bigtable # +# Google Cloud Bigtable [Cloud Bigtable](https://cloud.google.com/bigtable/) is a high performance storage system that can store and serve training data. This contrib @@ -13,7 +13,7 @@ Bigtable at high speed, in particular to feed modern accelerators. For general-purpose Cloud Bigtable APIs, see the [official Cloud Bigtable client library documentation][clientdoc]. -[clientdoc]: https://cloud.google.com/bigtable/docs/reference/libraries +[clientdoc]: https://cloud.google.com/bigtable/docs/reference/libraries ## Sample Use -- GitLab From 2cbcc471d6340fac1ceca9b9559f62ec2d71a769 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Sat, 11 Aug 2018 15:17:30 -0700 Subject: [PATCH 389/437] Update ops-related pbtxt files. PiperOrigin-RevId: 208355476 --- .../core/ops/compat/ops_history.v1.pbtxt | 35 +++++++++++++++++++ tensorflow/core/ops/ops.pbtxt | 35 +++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/tensorflow/core/ops/compat/ops_history.v1.pbtxt b/tensorflow/core/ops/compat/ops_history.v1.pbtxt index bb48da86ca..44dddffd59 100644 --- a/tensorflow/core/ops/compat/ops_history.v1.pbtxt +++ b/tensorflow/core/ops/compat/ops_history.v1.pbtxt @@ -73390,6 +73390,41 @@ op { } } } +op { + name: "UnsafeDiv" + input_arg { + name: "x" + type_attr: "T" + } + input_arg { + name: "y" + type_attr: "T" + } + output_arg { + name: "z" + type_attr: "T" + } + attr { + name: "T" + type: "type" + allowed_values { + list { + type: DT_BFLOAT16 + type: DT_HALF + type: DT_FLOAT + type: DT_DOUBLE + type: DT_UINT8 + type: DT_INT8 + type: DT_UINT16 + type: DT_INT16 + type: DT_INT32 + type: DT_INT64 + type: DT_COMPLEX64 + type: DT_COMPLEX128 + } + } + } +} op { name: "UnsortedSegmentMax" input_arg { diff --git a/tensorflow/core/ops/ops.pbtxt b/tensorflow/core/ops/ops.pbtxt index 59ba1c5306..1fda569b8e 100644 --- a/tensorflow/core/ops/ops.pbtxt +++ b/tensorflow/core/ops/ops.pbtxt @@ -34933,6 +34933,41 @@ op { } } } +op { + name: "UnsafeDiv" + input_arg { + name: "x" + type_attr: "T" + } + input_arg { + name: "y" + type_attr: "T" + } + output_arg { + name: "z" + type_attr: "T" + } + attr { + name: "T" + type: "type" + allowed_values { + list { + type: DT_BFLOAT16 + type: DT_HALF + type: DT_FLOAT + type: DT_DOUBLE + type: DT_UINT8 + type: DT_INT8 + type: DT_UINT16 + type: DT_INT16 + type: DT_INT32 + type: DT_INT64 + type: DT_COMPLEX64 + type: DT_COMPLEX128 + } + } + } +} op { name: "UnsortedSegmentMax" input_arg { -- GitLab From d8802756db92bbf032c1d8ee6fbed1aaf873c8fa Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Sat, 11 Aug 2018 15:46:10 -0700 Subject: [PATCH 390/437] Go: Update generated wrapper functions for TensorFlow ops. PiperOrigin-RevId: 208356344 --- tensorflow/go/op/wrappers.go | 262 +++++++++++++++++------------------ 1 file changed, 131 insertions(+), 131 deletions(-) diff --git a/tensorflow/go/op/wrappers.go b/tensorflow/go/op/wrappers.go index 9015cd616c..3e0ea619e3 100644 --- a/tensorflow/go/op/wrappers.go +++ b/tensorflow/go/op/wrappers.go @@ -4037,64 +4037,76 @@ func SlideDataset(scope *Scope, input_dataset tf.Output, window_size tf.Output, return op.Output(0) } -// Computes the sum along sparse segments of a tensor divided by the sqrt of N. -// -// N is the size of the segment being reduced. -// -// Like `SparseSegmentSqrtN`, but allows missing ids in `segment_ids`. If an id is -// misisng, the `output` tensor at that position will be zeroed. -// -// Read @{$math_ops#Segmentation$the section on segmentation} for an explanation of -// segments. -// -// Arguments: -// -// indices: A 1-D tensor. Has same rank as `segment_ids`. -// segment_ids: A 1-D tensor. Values should be sorted and can be repeated. -// num_segments: Should equal the number of distinct segment IDs. +// FusedBatchNormAttr is an optional argument to FusedBatchNorm. +type FusedBatchNormAttr func(optionalAttr) + +// FusedBatchNormEpsilon sets the optional epsilon attribute to value. // -// Returns Has same shape as data, except for dimension 0 which -// has size `k`, the number of segments. -func SparseSegmentSqrtNWithNumSegments(scope *Scope, data tf.Output, indices tf.Output, segment_ids tf.Output, num_segments tf.Output) (output tf.Output) { - if scope.Err() != nil { - return - } - opspec := tf.OpSpec{ - Type: "SparseSegmentSqrtNWithNumSegments", - Input: []tf.Input{ - data, indices, segment_ids, num_segments, - }, +// value: A small float number added to the variance of x. +// If not specified, defaults to 0.0001 +func FusedBatchNormEpsilon(value float32) FusedBatchNormAttr { + return func(m optionalAttr) { + m["epsilon"] = value } - op := scope.AddOperation(opspec) - return op.Output(0) } -// Compute the upper regularized incomplete Gamma function `Q(a, x)`. -// -// The upper regularized incomplete Gamma function is defined as: +// FusedBatchNormDataFormat sets the optional data_format attribute to value. // -// \\(Q(a, x) = Gamma(a, x) / Gamma(a) = 1 - P(a, x)\\) +// value: The data format for x and y. Either "NHWC" (default) or "NCHW". +// If not specified, defaults to "NHWC" +func FusedBatchNormDataFormat(value string) FusedBatchNormAttr { + return func(m optionalAttr) { + m["data_format"] = value + } +} + +// FusedBatchNormIsTraining sets the optional is_training attribute to value. // -// where +// value: A bool value to indicate the operation is for training (default) +// or inference. +// If not specified, defaults to true +func FusedBatchNormIsTraining(value bool) FusedBatchNormAttr { + return func(m optionalAttr) { + m["is_training"] = value + } +} + +// Batch normalization. // -// \\(Gamma(a, x) = int_{x}^{\infty} t^{a-1} exp(-t) dt\\) +// Note that the size of 4D Tensors are defined by either "NHWC" or "NCHW". +// The size of 1D Tensors matches the dimension C of the 4D Tensors. // -// is the upper incomplete Gama function. +// Arguments: +// x: A 4D Tensor for input data. +// scale: A 1D Tensor for scaling factor, to scale the normalized x. +// offset: A 1D Tensor for offset, to shift to the normalized x. +// mean: A 1D Tensor for population mean. Used for inference only; +// must be empty for training. +// variance: A 1D Tensor for population variance. Used for inference only; +// must be empty for training. // -// Note, above `P(a, x)` (`Igamma`) is the lower regularized complete -// Gamma function. -func Igammac(scope *Scope, a tf.Output, x tf.Output) (z tf.Output) { +// Returns A 4D Tensor for output data.A 1D Tensor for the computed batch mean, to be used by TensorFlow +// to compute the running mean.A 1D Tensor for the computed batch variance, to be used by +// TensorFlow to compute the running variance.A 1D Tensor for the computed batch mean, to be reused +// in the gradient computation.A 1D Tensor for the computed batch variance (inverted variance +// in the cuDNN case), to be reused in the gradient computation. +func FusedBatchNorm(scope *Scope, x tf.Output, scale tf.Output, offset tf.Output, mean tf.Output, variance tf.Output, optional ...FusedBatchNormAttr) (y tf.Output, batch_mean tf.Output, batch_variance tf.Output, reserve_space_1 tf.Output, reserve_space_2 tf.Output) { if scope.Err() != nil { return } + attrs := map[string]interface{}{} + for _, a := range optional { + a(attrs) + } opspec := tf.OpSpec{ - Type: "Igammac", + Type: "FusedBatchNorm", Input: []tf.Input{ - a, x, + x, scale, offset, mean, variance, }, + Attrs: attrs, } op := scope.AddOperation(opspec) - return op.Output(0) + return op.Output(0), op.Output(1), op.Output(2), op.Output(3), op.Output(4) } // ApproximateEqualAttr is an optional argument to ApproximateEqual. @@ -13975,6 +13987,24 @@ func BoostedTreesPredict(scope *Scope, tree_ensemble_handle tf.Output, bucketize return op.Output(0) } +// Elementwise computes the bitwise OR of `x` and `y`. +// +// The result will have those bits set, that are set in `x`, `y` or both. The +// computation is performed on the underlying representations of `x` and `y`. +func BitwiseOr(scope *Scope, x tf.Output, y tf.Output) (z tf.Output) { + if scope.Err() != nil { + return + } + opspec := tf.OpSpec{ + Type: "BitwiseOr", + Input: []tf.Input{ + x, y, + }, + } + op := scope.AddOperation(opspec) + return op.Output(0) +} + // MatrixSolveLsAttr is an optional argument to MatrixSolveLs. type MatrixSolveLsAttr func(optionalAttr) @@ -14052,24 +14082,6 @@ func MatrixSolveLs(scope *Scope, matrix tf.Output, rhs tf.Output, l2_regularizer return op.Output(0) } -// Elementwise computes the bitwise OR of `x` and `y`. -// -// The result will have those bits set, that are set in `x`, `y` or both. The -// computation is performed on the underlying representations of `x` and `y`. -func BitwiseOr(scope *Scope, x tf.Output, y tf.Output) (z tf.Output) { - if scope.Err() != nil { - return - } - opspec := tf.OpSpec{ - Type: "BitwiseOr", - Input: []tf.Input{ - x, y, - }, - } - op := scope.AddOperation(opspec) - return op.Output(0) -} - // MaxPool3DAttr is an optional argument to MaxPool3D. type MaxPool3DAttr func(optionalAttr) @@ -16062,78 +16074,6 @@ func Sigmoid(scope *Scope, x tf.Output) (y tf.Output) { return op.Output(0) } -// FusedBatchNormAttr is an optional argument to FusedBatchNorm. -type FusedBatchNormAttr func(optionalAttr) - -// FusedBatchNormEpsilon sets the optional epsilon attribute to value. -// -// value: A small float number added to the variance of x. -// If not specified, defaults to 0.0001 -func FusedBatchNormEpsilon(value float32) FusedBatchNormAttr { - return func(m optionalAttr) { - m["epsilon"] = value - } -} - -// FusedBatchNormDataFormat sets the optional data_format attribute to value. -// -// value: The data format for x and y. Either "NHWC" (default) or "NCHW". -// If not specified, defaults to "NHWC" -func FusedBatchNormDataFormat(value string) FusedBatchNormAttr { - return func(m optionalAttr) { - m["data_format"] = value - } -} - -// FusedBatchNormIsTraining sets the optional is_training attribute to value. -// -// value: A bool value to indicate the operation is for training (default) -// or inference. -// If not specified, defaults to true -func FusedBatchNormIsTraining(value bool) FusedBatchNormAttr { - return func(m optionalAttr) { - m["is_training"] = value - } -} - -// Batch normalization. -// -// Note that the size of 4D Tensors are defined by either "NHWC" or "NCHW". -// The size of 1D Tensors matches the dimension C of the 4D Tensors. -// -// Arguments: -// x: A 4D Tensor for input data. -// scale: A 1D Tensor for scaling factor, to scale the normalized x. -// offset: A 1D Tensor for offset, to shift to the normalized x. -// mean: A 1D Tensor for population mean. Used for inference only; -// must be empty for training. -// variance: A 1D Tensor for population variance. Used for inference only; -// must be empty for training. -// -// Returns A 4D Tensor for output data.A 1D Tensor for the computed batch mean, to be used by TensorFlow -// to compute the running mean.A 1D Tensor for the computed batch variance, to be used by -// TensorFlow to compute the running variance.A 1D Tensor for the computed batch mean, to be reused -// in the gradient computation.A 1D Tensor for the computed batch variance (inverted variance -// in the cuDNN case), to be reused in the gradient computation. -func FusedBatchNorm(scope *Scope, x tf.Output, scale tf.Output, offset tf.Output, mean tf.Output, variance tf.Output, optional ...FusedBatchNormAttr) (y tf.Output, batch_mean tf.Output, batch_variance tf.Output, reserve_space_1 tf.Output, reserve_space_2 tf.Output) { - if scope.Err() != nil { - return - } - attrs := map[string]interface{}{} - for _, a := range optional { - a(attrs) - } - opspec := tf.OpSpec{ - Type: "FusedBatchNorm", - Input: []tf.Input{ - x, scale, offset, mean, variance, - }, - Attrs: attrs, - } - op := scope.AddOperation(opspec) - return op.Output(0), op.Output(1), op.Output(2), op.Output(3), op.Output(4) -} - // RandomStandardNormalAttr is an optional argument to RandomStandardNormal. type RandomStandardNormalAttr func(optionalAttr) @@ -20608,6 +20548,66 @@ func RandomUniformInt(scope *Scope, shape tf.Output, minval tf.Output, maxval tf return op.Output(0) } +// Compute the upper regularized incomplete Gamma function `Q(a, x)`. +// +// The upper regularized incomplete Gamma function is defined as: +// +// \\(Q(a, x) = Gamma(a, x) / Gamma(a) = 1 - P(a, x)\\) +// +// where +// +// \\(Gamma(a, x) = int_{x}^{\infty} t^{a-1} exp(-t) dt\\) +// +// is the upper incomplete Gama function. +// +// Note, above `P(a, x)` (`Igamma`) is the lower regularized complete +// Gamma function. +func Igammac(scope *Scope, a tf.Output, x tf.Output) (z tf.Output) { + if scope.Err() != nil { + return + } + opspec := tf.OpSpec{ + Type: "Igammac", + Input: []tf.Input{ + a, x, + }, + } + op := scope.AddOperation(opspec) + return op.Output(0) +} + +// Computes the sum along sparse segments of a tensor divided by the sqrt of N. +// +// N is the size of the segment being reduced. +// +// Like `SparseSegmentSqrtN`, but allows missing ids in `segment_ids`. If an id is +// misisng, the `output` tensor at that position will be zeroed. +// +// Read @{$math_ops#Segmentation$the section on segmentation} for an explanation of +// segments. +// +// Arguments: +// +// indices: A 1-D tensor. Has same rank as `segment_ids`. +// segment_ids: A 1-D tensor. Values should be sorted and can be repeated. +// num_segments: Should equal the number of distinct segment IDs. +// +// Returns Has same shape as data, except for dimension 0 which +// has size `k`, the number of segments. +func SparseSegmentSqrtNWithNumSegments(scope *Scope, data tf.Output, indices tf.Output, segment_ids tf.Output, num_segments tf.Output) (output tf.Output) { + if scope.Err() != nil { + return + } + opspec := tf.OpSpec{ + Type: "SparseSegmentSqrtNWithNumSegments", + Input: []tf.Input{ + data, indices, segment_ids, num_segments, + }, + } + op := scope.AddOperation(opspec) + return op.Output(0) +} + // Computes gradients for SparseSegmentSqrtN. // // Returns tensor "output" with same shape as grad, except for dimension 0 whose -- GitLab From b416db37a20aa1945f928a2c253ae0a8a139c20f Mon Sep 17 00:00:00 2001 From: Yash Katariya Date: Sat, 11 Aug 2018 22:49:07 -0400 Subject: [PATCH 391/437] Replacing tf.contrib.data.batch_and_drop_remainder by batch(..., drop_remainder=True). Also checkpointing at (epoch + 1) % x while saving the model to consider the last epoch's variables. --- .../eager/python/examples/generative_examples/dcgan.ipynb | 2 +- .../examples/generative_examples/text_generation.ipynb | 7 ++++--- .../examples/nmt_with_attention/nmt_with_attention.ipynb | 4 ++-- .../eager/python/examples/pix2pix/pix2pix_eager.ipynb | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tensorflow/contrib/eager/python/examples/generative_examples/dcgan.ipynb b/tensorflow/contrib/eager/python/examples/generative_examples/dcgan.ipynb index 975105a179..5621d6a358 100644 --- a/tensorflow/contrib/eager/python/examples/generative_examples/dcgan.ipynb +++ b/tensorflow/contrib/eager/python/examples/generative_examples/dcgan.ipynb @@ -495,7 +495,7 @@ " random_vector_for_generation)\n", " \n", " # saving (checkpoint) the model every 15 epochs\n", - " if epoch % 15 == 0:\n", + " if (epoch + 1) % 15 == 0:\n", " checkpoint.save(file_prefix = checkpoint_prefix)\n", " \n", " print ('Time taken for epoch {} is {} sec'.format(epoch + 1,\n", diff --git a/tensorflow/contrib/eager/python/examples/generative_examples/text_generation.ipynb b/tensorflow/contrib/eager/python/examples/generative_examples/text_generation.ipynb index 78a711548d..8c1d6480e7 100644 --- a/tensorflow/contrib/eager/python/examples/generative_examples/text_generation.ipynb +++ b/tensorflow/contrib/eager/python/examples/generative_examples/text_generation.ipynb @@ -132,6 +132,7 @@ "tf.enable_eager_execution()\n", "\n", "import numpy as np\n", + "import os\n", "import re\n", "import random\n", "import unidecode\n", @@ -313,7 +314,7 @@ "outputs": [], "source": [ "dataset = tf.data.Dataset.from_tensor_slices((input_text, target_text)).shuffle(BUFFER_SIZE)\n", - "dataset = dataset.apply(tf.contrib.data.batch_and_drop_remainder(BATCH_SIZE))" + "dataset = dataset.batch(BATCH_SIZE, drop_remainder=True)" ] }, { @@ -493,7 +494,7 @@ "source": [ "# Training step\n", "\n", - "EPOCHS = 30\n", + "EPOCHS = 20\n", "\n", "for epoch in range(EPOCHS):\n", " start = time.time()\n", @@ -520,7 +521,7 @@ " batch,\n", " loss))\n", " # saving (checkpoint) the model every 5 epochs\n", - " if epoch % 5 == 0:\n", + " if (epoch + 1) % 5 == 0:\n", " checkpoint.save(file_prefix = checkpoint_prefix)\n", "\n", " print ('Epoch {} Loss {:.4f}'.format(epoch+1, loss))\n", diff --git a/tensorflow/contrib/eager/python/examples/nmt_with_attention/nmt_with_attention.ipynb b/tensorflow/contrib/eager/python/examples/nmt_with_attention/nmt_with_attention.ipynb index 1d07721e3b..08d8364978 100644 --- a/tensorflow/contrib/eager/python/examples/nmt_with_attention/nmt_with_attention.ipynb +++ b/tensorflow/contrib/eager/python/examples/nmt_with_attention/nmt_with_attention.ipynb @@ -319,7 +319,7 @@ "vocab_tar_size = len(targ_lang.word2idx)\n", "\n", "dataset = tf.data.Dataset.from_tensor_slices((input_tensor_train, target_tensor_train)).shuffle(BUFFER_SIZE)\n", - "dataset = dataset.apply(tf.contrib.data.batch_and_drop_remainder(BATCH_SIZE))" + "dataset = dataset.batch(BATCH_SIZE, drop_remainder=True)" ] }, { @@ -619,7 +619,7 @@ " batch,\n", " batch_loss.numpy()))\n", " # saving (checkpoint) the model every 2 epochs\n", - " if epoch % 2 == 0:\n", + " if (epoch + 1) % 2 == 0:\n", " checkpoint.save(file_prefix = checkpoint_prefix)\n", " \n", " print('Epoch {} Loss {:.4f}'.format(epoch + 1,\n", diff --git a/tensorflow/contrib/eager/python/examples/pix2pix/pix2pix_eager.ipynb b/tensorflow/contrib/eager/python/examples/pix2pix/pix2pix_eager.ipynb index acc0f5b653..ee25d25b52 100644 --- a/tensorflow/contrib/eager/python/examples/pix2pix/pix2pix_eager.ipynb +++ b/tensorflow/contrib/eager/python/examples/pix2pix/pix2pix_eager.ipynb @@ -701,7 +701,7 @@ " generate_images(generator, inp, tar)\n", " \n", " # saving (checkpoint) the model every 20 epochs\n", - " if epoch % 20 == 0:\n", + " if (epoch + 1) % 20 == 0:\n", " checkpoint.save(file_prefix = checkpoint_prefix)\n", "\n", " print ('Time taken for epoch {} is {} sec\\n'.format(epoch + 1,\n", -- GitLab From 27208e2d8cf126eb4282e19a859eb6bd21ecc190 Mon Sep 17 00:00:00 2001 From: Yash Katariya Date: Sat, 11 Aug 2018 23:00:41 -0400 Subject: [PATCH 392/437] correcting the indentation --- .../python/examples/generative_examples/text_generation.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/contrib/eager/python/examples/generative_examples/text_generation.ipynb b/tensorflow/contrib/eager/python/examples/generative_examples/text_generation.ipynb index 8c1d6480e7..027097908f 100644 --- a/tensorflow/contrib/eager/python/examples/generative_examples/text_generation.ipynb +++ b/tensorflow/contrib/eager/python/examples/generative_examples/text_generation.ipynb @@ -132,7 +132,7 @@ "tf.enable_eager_execution()\n", "\n", "import numpy as np\n", - "import os\n", + "import os\n", "import re\n", "import random\n", "import unidecode\n", -- GitLab From 3021cfae28bc7ae46fd903398f25bb4f0fa4e317 Mon Sep 17 00:00:00 2001 From: Anna R Date: Sun, 12 Aug 2018 01:21:32 -0700 Subject: [PATCH 393/437] Automated rollback of commit af25771f4418db658ad4b40a635ea5f2a4c2bbe6. Revert #21097. PiperOrigin-RevId: 208378106 --- tensorflow/contrib/makefile/download_dependencies.sh | 4 +--- tensorflow/workspace.bzl | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/tensorflow/contrib/makefile/download_dependencies.sh b/tensorflow/contrib/makefile/download_dependencies.sh index dc9b17a627..448ae6d22e 100755 --- a/tensorflow/contrib/makefile/download_dependencies.sh +++ b/tensorflow/contrib/makefile/download_dependencies.sh @@ -35,9 +35,7 @@ NSYNC_URL="$(grep -o 'https://mirror.bazel.build/github.com/google/nsync/.*tar\. # process. For now we're hardcoding to the version which is used by # TensorFlow 1.9. PROTOBUF_URL="https://mirror.bazel.build/github.com/google/protobuf/archive/396336eb961b75f03b25824fe86cf6490fb75e3a.tar.gz" -# TODO (yongtang): Replace the following with 'https://mirror.bazel.build/github.com/google/re2/.*tar\.gz' once -# the archive has been propagated in mirror.bazel.build. -RE2_URL="$(grep -o 'https://github.com/google/re2/.*tar\.gz' "${BZL_FILE_PATH}" | head -n1)" +RE2_URL="$(grep -o 'https://mirror.bazel.build/github.com/google/re2/.*tar\.gz' "${BZL_FILE_PATH}" | head -n1)" FFT2D_URL="$(grep -o 'http.*fft\.tgz' "${BZL_FILE_PATH}" | grep -v bazel-mirror | head -n1)" DOUBLE_CONVERSION_URL="$(grep -o "https.*google/double-conversion.*\.zip" "${BZL_FILE_PATH}" | head -n1)" ABSL_URL="$(grep -o 'https://github.com/abseil/abseil-cpp/.*tar.gz' "${BZL_FILE_PATH}" | head -n1)" diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl index 217910c04f..c21e5ebc9e 100644 --- a/tensorflow/workspace.bzl +++ b/tensorflow/workspace.bzl @@ -157,11 +157,11 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""): tf_http_archive( name = "com_googlesource_code_re2", urls = [ - "https://mirror.bazel.build/github.com/google/re2/archive/2018-07-01.tar.gz", - "https://github.com/google/re2/archive/2018-07-01.tar.gz", + "https://mirror.bazel.build/github.com/google/re2/archive/2018-04-01.tar.gz", + "https://github.com/google/re2/archive/2018-04-01.tar.gz", ], - sha256 = "803c7811146edeef8f91064de37c6f19136ff01a2a8cdb3230e940b2fd9f07fe", - strip_prefix = "re2-2018-07-01", + sha256 = "2f945446b71336e7f5a2bcace1abcf0b23fbba368266c6a1be33de3de3b3c912", + strip_prefix = "re2-2018-04-01", system_build_file = clean_dep("//third_party/systemlibs:re2.BUILD"), ) -- GitLab From 1a22b0b982fa1a953651b98af8f3cd30542048fd Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Sun, 12 Aug 2018 02:01:23 -0700 Subject: [PATCH 394/437] compat: Update forward compatibility horizon to 2018-08-12 PiperOrigin-RevId: 208379916 --- tensorflow/python/compat/compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/python/compat/compat.py b/tensorflow/python/compat/compat.py index f33e881d87..42f96a002a 100644 --- a/tensorflow/python/compat/compat.py +++ b/tensorflow/python/compat/compat.py @@ -26,7 +26,7 @@ import datetime from tensorflow.python.util import tf_contextlib from tensorflow.python.util.tf_export import tf_export -_FORWARD_COMPATIBILITY_HORIZON = datetime.date(2018, 8, 11) +_FORWARD_COMPATIBILITY_HORIZON = datetime.date(2018, 8, 12) @tf_export("compat.forward_compatible") -- GitLab From a170aef5b6703ec7d4819aaadc4bcd9c8f6cb017 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: Sun, 12 Aug 2018 17:59:10 +0800 Subject: [PATCH 395/437] CLN: revise codes --- tensorflow/python/kernel_tests/clip_ops_test.py | 8 ++++++-- tensorflow/python/ops/clip_ops.py | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tensorflow/python/kernel_tests/clip_ops_test.py b/tensorflow/python/kernel_tests/clip_ops_test.py index 0de953f465..400d38b936 100644 --- a/tensorflow/python/kernel_tests/clip_ops_test.py +++ b/tensorflow/python/kernel_tests/clip_ops_test.py @@ -377,9 +377,13 @@ class ClipTest(test.TestCase): x1 = constant_op.constant([1.0, -2.0]) clip_norm = 6.0 - _, norm = clip_ops.clip_by_global_norm([x0, x1], clip_norm) - with self.assertRaisesRegexp(errors.InvalidArgumentError, "use_norm"): + ans, norm = clip_ops.clip_by_global_norm([x0, x1], clip_norm) + with self.assertRaisesRegexp(errors.InvalidArgumentError, "global norm"): norm.eval() + with self.assertRaisesRegexp(errors.InvalidArgumentError, "global norm"): + ans[0].eval() + with self.assertRaisesRegexp(errors.InvalidArgumentError, "global norm"): + ans[1].eval() def testClipByAverageNormClipped(self): # Norm clipping when average clip_norm < 0.83333333 diff --git a/tensorflow/python/ops/clip_ops.py b/tensorflow/python/ops/clip_ops.py index 110d6063bc..f29dce73e7 100644 --- a/tensorflow/python/ops/clip_ops.py +++ b/tensorflow/python/ops/clip_ops.py @@ -55,7 +55,7 @@ def clip_by_value(t, clip_value_min, clip_value_max, A clipped `Tensor`. Raises: - ValueError: if the clip tensors would trigger array broadcasting + ValueError: If the clip tensors would trigger array broadcasting that would make the returned tensor larger than the input. """ with ops.name_scope(name, "clip_by_value", @@ -244,7 +244,7 @@ def clip_by_global_norm(t_list, clip_norm, use_norm=None, name=None): Raises: TypeError: If `t_list` is not a sequence. - InvalidArgumentError: if `use_norm` is not finite. + InvalidArgumentError: If global norm is not finite. """ if (not isinstance(t_list, collections.Sequence) or isinstance(t_list, six.string_types)): @@ -253,7 +253,7 @@ def clip_by_global_norm(t_list, clip_norm, use_norm=None, name=None): if use_norm is None: use_norm = global_norm(t_list, name) use_norm = numerics.verify_tensor_all_finite(use_norm, - "use_norm must be finite.") + "Found Inf or NaN global norm.") with ops.name_scope(name, "clip_by_global_norm", t_list + [clip_norm]) as name: -- GitLab From f2d51d5a13db2455007a56d3273091e30fd9b42d Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Mon, 13 Aug 2018 02:00:58 -0700 Subject: [PATCH 396/437] compat: Update forward compatibility horizon to 2018-08-13 PiperOrigin-RevId: 208446011 --- tensorflow/python/compat/compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/python/compat/compat.py b/tensorflow/python/compat/compat.py index 42f96a002a..c2cfbf5f66 100644 --- a/tensorflow/python/compat/compat.py +++ b/tensorflow/python/compat/compat.py @@ -26,7 +26,7 @@ import datetime from tensorflow.python.util import tf_contextlib from tensorflow.python.util.tf_export import tf_export -_FORWARD_COMPATIBILITY_HORIZON = datetime.date(2018, 8, 12) +_FORWARD_COMPATIBILITY_HORIZON = datetime.date(2018, 8, 13) @tf_export("compat.forward_compatible") -- GitLab From 4dc13f1aa7bdfb9fc21fc0fc4961c69cb8cb1d20 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Mon, 13 Aug 2018 02:09:37 -0700 Subject: [PATCH 397/437] Add documentation for TensorFlow Windows build with Bazel PiperOrigin-RevId: 208447033 --- .../install/install_sources_windows.md | 320 ++++++++++++++++++ .../docs_src/install/install_windows.md | 2 + tensorflow/docs_src/install/leftnav_files | 1 + 3 files changed, 323 insertions(+) create mode 100644 tensorflow/docs_src/install/install_sources_windows.md diff --git a/tensorflow/docs_src/install/install_sources_windows.md b/tensorflow/docs_src/install/install_sources_windows.md new file mode 100644 index 0000000000..a1da122317 --- /dev/null +++ b/tensorflow/docs_src/install/install_sources_windows.md @@ -0,0 +1,320 @@ +# Install TensorFlow from Sources on Windows + +This guide explains how to build TensorFlow sources into a TensorFlow binary and +how to install that TensorFlow binary on Windows. + +## Determine which TensorFlow to install + +You must choose one of the following types of TensorFlow to build and install: + +* **TensorFlow with CPU support only**. If your system does not have a NVIDIA® + GPU, build and install this version. Note that this version of TensorFlow is + typically easier to build and install, so even if you have an NVIDIA GPU, we + recommend building and installing this version first. +* **TensorFlow with GPU support**. TensorFlow programs typically run + significantly faster on a GPU than on a CPU. Therefore, if your system has a + NVIDIA GPU and you need to run performance-critical applications, you should + ultimately build and install this version. Beyond the NVIDIA GPU itself, + your system must also fulfill the NVIDIA software requirements described in + the following document: + + * [Installing TensorFlow on Windows](install_windows.md#NVIDIARequirements) + +## Prepare environment for Windows + +Before building TensorFlow on Windows, install the following build tools on your +system: + +* [MSYS2](#InstallMSYS2) +* [Visual C++ build tools](#InstallVCBuildTools) +* [Bazel for Windows](#InstallBazel) +* [TensorFlow Python dependencies](#InstallPython) +* [optionally, NVIDIA packages to support TensorFlow for GPU](#InstallCUDA) + + + +### Install MSYS2 + +Bash bin tools are used in TensorFlow Bazel build, you can install them through [MSYS2](https://www.msys2.org/). + +Assume you installed MSYS2 at `C:\msys64`, add `C:\msys64\usr\bin` to your `%PATH%` environment variable. + +To install necessary bash bin tools, issue the following command under `cmd.exe`: + +
+C:\> pacman -S git patch unzip
+
+ + + +### Install Visual C++ Build Tools 2015 + +To build TensorFlow, you need to install Visual C++ build tools 2015. It is a part of Visual Studio 2015. +But you can install it separately by the following way: + + * Open the [official downloand page](https://visualstudio.microsoft.com/vs/older-downloads/). + * Go to Redistributables and Build Tools section. + * Find Microsoft Build Tools 2015 Update 3 and click download. + * Run the installer. + +It's possible to build TensorFlow with newer version of Visual C++ build tools, +but we only test against Visual Studio 2015 Update 3. + + + +### Install Bazel + +If bazel is not installed on your system, install it now by following +[these instructions](https://docs.bazel.build/versions/master/install-windows.html). +It is recommended to use a Bazel version >= `0.15.0`. + +Add the directory where you installed Bazel to your `%PATH%` environment variable. + + + +### Install TensorFlow Python dependencies + +If you don't have Python 3.5 or Python 3.6 installed, install it now: + + * [Python 3.5.x 64-bit from python.org](https://www.python.org/downloads/release/python-352/) + * [Python 3.6.x 64-bit from python.org](https://www.python.org/downloads/release/python-362/) + +To build and install TensorFlow, you must install the following python packages: + +* `six`, which provides simple utilities for wrapping over differences between + Python 2 and Python 3. +* `numpy`, which is a numerical processing package that TensorFlow requires. +* `wheel`, which enables you to manage Python compressed packages in the wheel + (.whl) format. +* `keras_applications`, the applications module of the Keras deep learning library. +* `keras_preprocessing`, the data preprocessing and data augmentation module + of the Keras deep learning library. + +Assume you already have `pip3` in `%PATH%`, issue the following command: + +
+C:\> pip3 install six numpy wheel
+C:\> pip3 install keras_applications==1.0.4 --no-deps
+C:\> pip3 install keras_preprocessing==1.0.2 --no-deps
+
+ + + +### Optional: install TensorFlow for GPU prerequisites + +If you are building TensorFlow without GPU support, skip this section. + +The following NVIDIA® _hardware_ must be installed on your system: + +* GPU card with CUDA Compute Capability 3.5 or higher. See + [NVIDIA documentation](https://developer.nvidia.com/cuda-gpus) for a list of + supported GPU cards. + +The following NVIDIA® _software_ must be installed on your system: + +* [GPU drivers](http://nvidia.com/driver). CUDA 9.0 requires 384.x or higher. +* [CUDA Toolkit](http://nvidia.com/cuda) (>= 8.0). We recommend version 9.0. +* [cuDNN SDK](http://developer.nvidia.com/cudnn) (>= 6.0). We recommend + version 7.1.x. +* [CUPTI](http://docs.nvidia.com/cuda/cupti/) ships with the CUDA Toolkit, but + you also need to append its path to `%PATH%` environment + variable. + +Assume you have CUDA Toolkit installed at `C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0` +and cuDNN at `C:\tools\cuda`, issue the following commands. + +
+C:\> SET PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin;%PATH%
+C:\> SET PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\extras\CUPTI\libx64;%PATH%
+C:\> SET PATH=C:\tools\cuda\bin;%PATH%
+
+ +## Clone the TensorFlow repository + +Now you need to clone **the latest** TensorFlow repository, +thanks to MSYS2 we already have `git` avaiable, issue the following command: + +
C:\> git clone https://github.com/tensorflow/tensorflow.git 
+ +The preceding git clone command creates a subdirectory named +`tensorflow`. After cloning, you may optionally build a **specific branch** +(such as a release branch) by invoking the following commands: + +
+C:\> cd tensorflow
+C:\> git checkout Branch # where Branch is the desired branch
+
+ +For example, to work with the `r1.11` release instead of the master release, +issue the following command: + +
C:\> git checkout r1.11
+ +Next, you must now configure the installation. + +## Configure the installation + +The root of the source tree contains a python script named configure.py. +This script asks you to identify the pathname of all relevant TensorFlow +dependencies and specify other build configuration options such as compiler +flags. You must run this script *prior* to creating the pip package and +installing TensorFlow. + +If you wish to build TensorFlow with GPU, `configure.py` will ask you to specify +the version numbers of CUDA and cuDNN. If several versions of CUDA or cuDNN are +installed on your system, explicitly select the desired version instead of +relying on the default. + +One of the questions that `configure.py` will ask is as follows: + +
+Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is /arch:AVX]:
+
+ +Here is an example execution of the `configure.py` script. Note that your own input +will likely differ from our sample input: + +
+C:\> cd tensorflow  # cd to the top-level directory created
+C:\tensorflow> python ./configure.py
+Starting local Bazel server and connecting to it...
+................
+You have bazel 0.15.0 installed.
+Please specify the location of python. [Default is C:\python36\python.exe]: 
+
+Found possible Python library paths:
+  C:\python36\lib\site-packages
+Please input the desired Python library path to use.  Default is [C:\python36\lib\site-packages]
+
+Do you wish to build TensorFlow with CUDA support? [y/N]: Y
+CUDA support will be enabled for TensorFlow.
+
+Please specify the CUDA SDK version you want to use. [Leave empty to default to CUDA 9.0]:
+
+Please specify the location where CUDA 9.0 toolkit is installed. Refer to README.md for more details. [Default is C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.0]:
+
+Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 7.0]: 7.0
+
+Please specify the location where cuDNN 7 library is installed. Refer to README.md for more details. [Default is C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.0]: C:\tools\cuda
+
+Please specify a list of comma-separated Cuda compute capabilities you want to build with.
+You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus.
+Please note that each additional compute capability significantly increases your build time and binary size. [Default is: 3.5,7.0]: 3.7
+
+Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is /arch:AVX]: 
+
+Would you like to override eigen strong inline for some C++ compilation to reduce the compilation time? [Y/n]:
+Eigen strong inline overridden.
+
+Configuration finished
+
+ +## Build the pip package + +### CPU-only support + +To build a pip package for TensorFlow with CPU-only support: + +
+C:\tensorflow> bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
+
+ +### GPU support + +To build a pip package for TensorFlow with GPU support: + +
+C:\tensorflow> bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
+
+ +**NOTE :** When building with GPU support, you might want to add `--copt=-nvcc_options=disable-warnings` +to suppress nvcc warning messages. + +The `bazel build` command builds a binary named `build_pip_package` +(an executable binary to launch bash and run a bash script to create the pip package). +Running this binary as follows will build a `.whl` file within the `C:/tmp/tensorflow_pkg` directory: + +
+C:\tensorflow> bazel-bin\tensorflow\tools\pip_package\build_pip_package C:/tmp/tensorflow_pkg
+
+ +## Install the pip package + +Invoke `pip3 install` to install that pip package. The filename of the `.whl` +file depends on the TensorFlow version and your platform. For example, the +following command will install the pip package for TensorFlow 1.11.0rc0: + +
+C:\tensorflow> pip3 install C:/tmp/tensorflow_pkg/tensorflow-1.11.0rc0-cp36-cp36m-win_amd64.whl
+
+ +## Validate your installation + +Validate your TensorFlow installation by doing the following: + +Start a terminal. + +Change directory (`cd`) to any directory on your system other than the +`tensorflow` subdirectory from which you invoked the `configure` command. + +Invoke python: + +
$ python
+ +Enter the following short program inside the python interactive shell: + +```python +# Python +import tensorflow as tf +hello = tf.constant('Hello, TensorFlow!') +sess = tf.Session() +print(sess.run(hello)) +``` + +If the system outputs the following, then you are ready to begin writing +TensorFlow programs: + +
Hello, TensorFlow!
+ +To learn more, see the [TensorFlow tutorials](../tutorials/). + +## Build under MSYS shell +The above instruction assumes you are building under the Windows native command line (`cmd.exe`), but you can also +build TensorFlow from MSYS shell. There are a few things to notice: + +* Disable the path conversion heuristic in MSYS. MSYS automatically converts arguments that look + like a Unix path to Windows path when running a program, this will confuse Bazel. + (eg. A Bazel label `//foo/bar:bin` is considered a Unix absolute path, only because it starts with a slash) + + ```sh +$ export MSYS_NO_PATHCONV=1 +$ export MSYS2_ARG_CONV_EXCL="*" +``` + +* Add the directory where you install Bazel in `$PATH`. Assume you have Bazel + installed at `C:\tools\bazel.exe`, issue the following command: + + ```sh +# `:` is used as path separator, so we have to convert the path to Unix style. +$ export PATH="/c/tools:$PATH" +``` + +* Add the directory where you install Python in `$PATH`. Assume you have + Python installed at `C:\Python36\python.exe`, issue the following command: + + ```sh +$ export PATH="/c/Python36:$PATH" +``` + +* If you have Python in `$PATH`, you can run configure script just by + `./configure`, a shell script will help you invoke python. + +* (For GPU build only) Add Cuda and cuDNN bin directories in `$PATH` in the following way: + + ```sh +$ export PATH="/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.0/bin:$PATH" +$ export PATH="/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.0/extras/CUPTI/libx64:$PATH" +$ export PATH="/c/tools/cuda/bin:$PATH" +``` + +The rest steps should be the same as building under `cmd.exe`. diff --git a/tensorflow/docs_src/install/install_windows.md b/tensorflow/docs_src/install/install_windows.md index e9061bf3c1..0bb0e5aeb9 100644 --- a/tensorflow/docs_src/install/install_windows.md +++ b/tensorflow/docs_src/install/install_windows.md @@ -24,6 +24,8 @@ You must choose one of the following types of TensorFlow to install: and you need to run performance-critical applications, you should ultimately install this version. + + ### Requirements to run TensorFlow with GPU support If you are installing TensorFlow with GPU support using one of the mechanisms diff --git a/tensorflow/docs_src/install/leftnav_files b/tensorflow/docs_src/install/leftnav_files index ace275c0e8..59292f7121 100644 --- a/tensorflow/docs_src/install/leftnav_files +++ b/tensorflow/docs_src/install/leftnav_files @@ -6,6 +6,7 @@ install_mac.md: MacOS install_windows.md: Windows install_raspbian.md: Raspbian install_sources.md: From source +install_sources_windows.md: From source on Windows >>> migration.md -- GitLab From 9b44e8bd7b116503f9f1fe605d8ff43ef6ee132e Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Mon, 13 Aug 2018 03:50:52 -0700 Subject: [PATCH 398/437] Fix 2 bugs in the logic of the ODE, impacting efficiency: 1) if either of the side is always zero, you never want to do the multiplication 2) because of the zero at the end, the if clause was never hit, not saving those flops. PiperOrigin-RevId: 208457125 --- tensorflow/contrib/integrate/python/ops/odes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow/contrib/integrate/python/ops/odes.py b/tensorflow/contrib/integrate/python/ops/odes.py index 61f78febfc..7b7ac4f347 100644 --- a/tensorflow/contrib/integrate/python/ops/odes.py +++ b/tensorflow/contrib/integrate/python/ops/odes.py @@ -73,7 +73,7 @@ def _scaled_dot_product(scale, xs, ys, name=None): # _possibly_nonzero lets us avoid wasted computation. return math_ops.add_n( [(scale * x) * y for x, y in zip(xs, ys) - if _possibly_nonzero(x) or _possibly_nonzero(y)], + if _possibly_nonzero(x) and _possibly_nonzero(y)], name=scope) @@ -122,7 +122,7 @@ def _runge_kutta_step(func, yi = y0 + _scaled_dot_product(dt_cast, beta_i, k) k.append(func(yi, ti)) - if not (tableau.c_sol[-1] == 0 and tableau.c_sol == tableau.beta[-1]): + if not (tableau.c_sol[-1] == 0 and tableau.c_sol[:-1] == tableau.beta[-1]): # This property (true for Dormand-Prince) lets us save a few FLOPs. yi = y0 + _scaled_dot_product(dt_cast, tableau.c_sol, k) -- GitLab From 2c623eaa7c0dca79d126247393a68d285baeb7f0 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Mon, 13 Aug 2018 05:02:45 -0700 Subject: [PATCH 399/437] Log new ErrorReporter and old nnapi delegate errors to logcat. On Android stderr is not captured for applications, so developers do not see the errors from tflite. This adds logcat output. Output to stderr is kept, as it is convenient for unit tests run through the shell. PiperOrigin-RevId: 208463170 --- tensorflow/contrib/lite/error_reporter.cc | 13 +++++++++++++ tensorflow/contrib/lite/nnapi_delegate.cc | 19 +++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/tensorflow/contrib/lite/error_reporter.cc b/tensorflow/contrib/lite/error_reporter.cc index 03fcd5409c..646913c026 100644 --- a/tensorflow/contrib/lite/error_reporter.cc +++ b/tensorflow/contrib/lite/error_reporter.cc @@ -16,6 +16,10 @@ limitations under the License. #include #include +#ifdef __ANDROID__ +#include +#endif + namespace tflite { ErrorReporter::~ErrorReporter() {} @@ -39,6 +43,15 @@ int ErrorReporter::ReportError(void*, const char* format, ...) { } int StderrReporter::Report(const char* format, va_list args) { +#ifdef __ANDROID__ + // On Android stderr is not captured for applications, only for code run from + // the shell. Rather than assume all users will set up a custom error + // reporter, let's output to logcat here + va_list args_for_log; + va_copy(args_for_log, args); + __android_log_vprint(ANDROID_LOG_ERROR, "tflite", format, args_for_log); + va_end(args_for_log); +#endif const int result = vfprintf(stderr, format, args); fputc('\n', stderr); return result; diff --git a/tensorflow/contrib/lite/nnapi_delegate.cc b/tensorflow/contrib/lite/nnapi_delegate.cc index 13325a8c7c..3f3d3ef5d1 100644 --- a/tensorflow/contrib/lite/nnapi_delegate.cc +++ b/tensorflow/contrib/lite/nnapi_delegate.cc @@ -24,20 +24,27 @@ limitations under the License. #include "tensorflow/contrib/lite/nnapi/NeuralNetworksShim.h" #ifdef __ANDROID__ +#include #include #endif namespace tflite { void logError(const char* format, ...) { - // TODO(mikie): use android logging, stderr is not captured for Java - // applications - va_list args; - va_start(args, format); - vfprintf(stderr, format, args); - va_end(args); + // stderr is convenient for native tests, but is not captured for apps + va_list args_for_stderr; + va_start(args_for_stderr, format); + vfprintf(stderr, format, args_for_stderr); + va_end(args_for_stderr); fprintf(stderr, "\n"); fflush(stderr); +#ifdef __ANDROID__ + // produce logcat output for general consumption + va_list args_for_log; + va_start(args_for_log, format); + __android_log_vprint(ANDROID_LOG_ERROR, "tflite", format, args_for_log); + va_end(args_for_log); +#endif } #define FATAL(...) \ -- GitLab From 24480df10b234d2ba0bc7e5d661e5ae555954e15 Mon Sep 17 00:00:00 2001 From: Misha Brukman Date: Mon, 13 Aug 2018 08:09:30 -0700 Subject: [PATCH 400/437] Link 1.10 release notes to Bigtable doc for discoverability PiperOrigin-RevId: 208481668 --- RELEASE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE.md b/RELEASE.md index ae41d56e14..763ef3b279 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -3,7 +3,7 @@ ## Major Features And Improvements * The `tf.lite` runtime now supports `complex64`. -* Initial Bigtable integration for `tf.data`. +* Initial [Google Cloud Bigtable integration](https://github.com/tensorflow/tensorflow/tree/r1.10/tensorflow/contrib/bigtable) for `tf.data`. * Improved local run behavior in `tf.estimator.train_and_evaluate` which does not reload checkpoints for evaluation. * `RunConfig` now sets device_filters to restrict how workers and PS can communicate. This can speed up training and ensure clean shutdowns in some situations. But if you have jobs that require communication between workers, you will have to set custom session_options in your `RunConfig`. * Moved Distributions and Bijectors from `tf.contrib.distributions` to [Tensorflow Probability (TFP)](https://github.com/tensorflow/probability). `tf.contrib.distributions` is now deprecated and will be removed by the end of 2018. -- GitLab From 3a99980fcaa8e6df827df121b9b2e15d75f3ace1 Mon Sep 17 00:00:00 2001 From: Alexandre Passos Date: Mon, 13 Aug 2018 08:16:16 -0700 Subject: [PATCH 401/437] tf.scatter_sub for resource variables PiperOrigin-RevId: 208482434 --- .../python_api/api_def_ScatterSub.pbtxt | 4 ++ .../resource_variable_ops_test.py | 6 +++ tensorflow/python/ops/state_ops.py | 54 +++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 tensorflow/core/api_def/python_api/api_def_ScatterSub.pbtxt diff --git a/tensorflow/core/api_def/python_api/api_def_ScatterSub.pbtxt b/tensorflow/core/api_def/python_api/api_def_ScatterSub.pbtxt new file mode 100644 index 0000000000..f1a4cccbc3 --- /dev/null +++ b/tensorflow/core/api_def/python_api/api_def_ScatterSub.pbtxt @@ -0,0 +1,4 @@ +op { + graph_op_name: "ScatterSub" + visibility: HIDDEN +} diff --git a/tensorflow/python/kernel_tests/resource_variable_ops_test.py b/tensorflow/python/kernel_tests/resource_variable_ops_test.py index c739cd2c0d..b1ef46f2a1 100644 --- a/tensorflow/python/kernel_tests/resource_variable_ops_test.py +++ b/tensorflow/python/kernel_tests/resource_variable_ops_test.py @@ -835,6 +835,12 @@ class ResourceVariableOpsTest(test_util.TensorFlowTestCase): state_ops.scatter_add(v, [1], [3]) self.assertAllEqual([1.0, 5.0], v.numpy()) + def testScatterSubStateOps(self): + with context.eager_mode(): + v = resource_variable_ops.ResourceVariable([1.0, 2.0], name="sub") + state_ops.scatter_sub(v, [1], [3]) + self.assertAllEqual([1.0, -1.0], v.numpy()) + def testScatterNdAddStateOps(self): with context.eager_mode(): v = resource_variable_ops.ResourceVariable( diff --git a/tensorflow/python/ops/state_ops.py b/tensorflow/python/ops/state_ops.py index 35fc1226ec..d556d11a1b 100644 --- a/tensorflow/python/ops/state_ops.py +++ b/tensorflow/python/ops/state_ops.py @@ -470,3 +470,57 @@ def scatter_nd_add(ref, indices, updates, use_locking=False, name=None): return ref._lazy_read(gen_state_ops.resource_scatter_nd_add( # pylint: disable=protected-access ref.handle, indices, ops.convert_to_tensor(updates, ref.dtype), name=name)) + + +@tf_export("scatter_sub") +def scatter_sub(ref, indices, updates, use_locking=False, name=None): + r"""Subtracts sparse updates to a variable reference. + + ```python + # Scalar indices + ref[indices, ...] -= updates[...] + + # Vector indices (for each i) + ref[indices[i], ...] -= updates[i, ...] + + # High rank indices (for each i, ..., j) + ref[indices[i, ..., j], ...] -= updates[i, ..., j, ...] + ``` + + This operation outputs `ref` after the update is done. + This makes it easier to chain operations that need to use the reset value. + + Duplicate entries are handled correctly: if multiple `indices` reference + the same location, their (negated) contributions add. + + Requires `updates.shape = indices.shape + ref.shape[1:]` or + `updates.shape = []`. + +
+ +
+ + Args: + ref: A mutable `Tensor`. Must be one of the following types: `float32`, + `float64`, `int32`, `uint8`, `int16`, `int8`, `complex64`, `int64`, + `qint8`, `quint8`, `qint32`, `bfloat16`, `uint16`, `complex128`, `half`, + `uint32`, `uint64`. Should be from a `Variable` node. + indices: A `Tensor`. Must be one of the following types: `int32`, `int64`. + A tensor of indices into the first dimension of `ref`. + updates: A `Tensor`. Must have the same type as `ref`. + A tensor of updated values to subtract from `ref`. + use_locking: An optional `bool`. Defaults to `False`. + If True, the subtraction will be protected by a lock; + otherwise the behavior is undefined, but may exhibit less contention. + name: A name for the operation (optional). + + Returns: + A mutable `Tensor`. Has the same type as `ref`. + """ + if ref.dtype._is_ref_dtype: + return gen_state_ops.scatter_sub(ref, indices, updates, + use_locking=use_locking, name=name) + return ref._lazy_read(gen_resource_variable_ops.resource_scatter_sub( # pylint: disable=protected-access + ref.handle, indices, ops.convert_to_tensor(updates, ref.dtype), + name=name)) -- GitLab From 0a60da0a19aed7df4da25876e93c645f26f640c4 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Mon, 13 Aug 2018 08:39:50 -0700 Subject: [PATCH 402/437] - Adds support for tar files in generated tests for stock Android - Fixes breakage in tests using nnapi PiperOrigin-RevId: 208485430 --- tensorflow/contrib/lite/nnapi_delegate.cc | 8 +- .../testing/generated_examples_zip_test.cc | 94 +++++++++++++------ 2 files changed, 70 insertions(+), 32 deletions(-) diff --git a/tensorflow/contrib/lite/nnapi_delegate.cc b/tensorflow/contrib/lite/nnapi_delegate.cc index 3f3d3ef5d1..45c92a8671 100644 --- a/tensorflow/contrib/lite/nnapi_delegate.cc +++ b/tensorflow/contrib/lite/nnapi_delegate.cc @@ -571,8 +571,14 @@ TfLiteStatus AddOpsAndParams( nn_op_type = ANEURALNETWORKS_L2_NORMALIZATION; if (reinterpret_cast(node.builtin_data) ->activation != kTfLiteActNone) { - FATAL( + logError( "NNAPI does not support L2Normalization with fused activations"); + return kTfLiteError; + } + if ((node.inputs->size > 0) && + (interpreter->tensor(node.inputs->data[0])->dims->size != 4)) { + logError("NNAPI only supports input rank 4 for L2Normalization"); + return kTfLiteError; } break; case tflite::BuiltinOperator_HASHTABLE_LOOKUP: diff --git a/tensorflow/contrib/lite/testing/generated_examples_zip_test.cc b/tensorflow/contrib/lite/testing/generated_examples_zip_test.cc index e475f256c0..e67fee2a1c 100644 --- a/tensorflow/contrib/lite/testing/generated_examples_zip_test.cc +++ b/tensorflow/contrib/lite/testing/generated_examples_zip_test.cc @@ -33,13 +33,18 @@ namespace testing { namespace { bool FLAGS_ignore_known_bugs = true; -// TODO(b/71769302) zip_files_dir should have a more accurate default, if -// possible -string* FLAGS_zip_file_path = new string("./"); +// As archive file names are test-specific, no default is possible. +// +// This test supports input as both zip and tar, as a stock android image does +// not have unzip but does have tar. +string* FLAGS_zip_file_path = new string; +string* FLAGS_tar_file_path = new string; #ifndef __ANDROID__ string* FLAGS_unzip_binary_path = new string("/usr/bin/unzip"); +string* FLAGS_tar_binary_path = new string("/bin/tar"); #else string* FLAGS_unzip_binary_path = new string("/system/bin/unzip"); +string* FLAGS_tar_binary_path = new string("/system/bin/tar"); #endif bool FLAGS_use_nnapi = false; bool FLAGS_ignore_unsupported_nnapi = false; @@ -98,11 +103,11 @@ std::map kBrokenTests = { "77546240"}, }; -// Allows test data to be unzipped into a temporary directory and makes +// Allows test data to be unarchived into a temporary directory and makes // sure those temporary directories are removed later. -class ZipEnvironment : public ::testing::Environment { +class ArchiveEnvironment : public ::testing::Environment { public: - ~ZipEnvironment() override {} + ~ArchiveEnvironment() override {} // Delete all temporary directories on teardown. void TearDown() override { @@ -114,15 +119,26 @@ class ZipEnvironment : public ::testing::Environment { temporary_directories_.clear(); } - // Unzip `zip` file into a new temporary directory `out_dir`. - tensorflow::Status UnZip(const string& zip, string* out_dir) { + // Unarchive `archive` file into a new temporary directory `out_dir`. + tensorflow::Status UnArchive(const string& zip, const string& tar, + string* out_dir) { string dir; TF_CHECK_OK(MakeTemporaryDirectory(&dir)); tensorflow::SubProcess proc; - string unzip_binary = *FLAGS_unzip_binary_path; - TF_CHECK_OK(env->FileExists(unzip_binary)); - TF_CHECK_OK(env->FileExists(zip)); - proc.SetProgram(unzip_binary, {"unzip", "-d", dir, zip}); + if (!zip.empty()) { + string unzip_binary = *FLAGS_unzip_binary_path; + TF_CHECK_OK(env->FileExists(unzip_binary)); + TF_CHECK_OK(env->FileExists(zip)); + proc.SetProgram(unzip_binary, {"unzip", "-d", dir, zip}); + } else { + string tar_binary = *FLAGS_tar_binary_path; + TF_CHECK_OK(env->FileExists(tar_binary)); + TF_CHECK_OK(env->FileExists(tar)); + // 'o' needs to be explicitly set on Android so that + // untarring works as non-root (otherwise tries to chown + // files, which fails) + proc.SetProgram(tar_binary, {"tar", "xfo", tar, "-C", dir}); + } proc.SetChannelAction(tensorflow::CHAN_STDOUT, tensorflow::ACTION_PIPE); proc.SetChannelAction(tensorflow::CHAN_STDERR, tensorflow::ACTION_PIPE); if (!proc.Start()) @@ -156,15 +172,15 @@ class ZipEnvironment : public ::testing::Environment { std::vector temporary_directories_; }; -// Return the singleton zip_environment. -ZipEnvironment* zip_environment() { - static ZipEnvironment* env = new ZipEnvironment; +// Return the singleton archive_environment. +ArchiveEnvironment* archive_environment() { + static ArchiveEnvironment* env = new ArchiveEnvironment; return env; } -// Read the manifest.txt out of the unarchived zip file. Specifically +// Read the manifest.txt out of the unarchived archive file. Specifically // `original_file` is the original zip file for error messages. `dir` is -// the temporary directory where the zip file has been unarchived and +// the temporary directory where the archive file has been unarchived and // `test_paths` is the list of test prefixes that were in the manifest. // Note, it is an error for a manifest to contain no tests. tensorflow::Status ReadManifest(const string& original_file, const string& dir, @@ -190,12 +206,22 @@ tensorflow::Status ReadManifest(const string& original_file, const string& dir, return tensorflow::Status::OK(); } -// Get a list of tests from a zip file `zip_file_name`. -std::vector UnarchiveZipAndFindTestNames(const string& zip_file) { +// Get a list of tests from either zip or tar file +std::vector UnarchiveAndFindTestNames(const string& zip_file, + const string& tar_file) { + if (zip_file.empty() && tar_file.empty()) { + TF_CHECK_OK(tensorflow::Status(tensorflow::error::UNKNOWN, + "Neither zip_file nor tar_file was given")); + } string decompress_tmp_dir; - TF_CHECK_OK(zip_environment()->UnZip(zip_file, &decompress_tmp_dir)); + TF_CHECK_OK(archive_environment()->UnArchive(zip_file, tar_file, + &decompress_tmp_dir)); std::vector stuff; - TF_CHECK_OK(ReadManifest(zip_file, decompress_tmp_dir, &stuff)); + if (!zip_file.empty()) { + TF_CHECK_OK(ReadManifest(zip_file, decompress_tmp_dir, &stuff)); + } else { + TF_CHECK_OK(ReadManifest(tar_file, decompress_tmp_dir, &stuff)); + } return stuff; } @@ -223,8 +249,7 @@ TEST_P(OpsTest, RunZipTests) { string message = test_driver.GetErrorMessage(); if (bug_number.empty()) { if (FLAGS_use_nnapi && FLAGS_ignore_unsupported_nnapi && !result) { - EXPECT_EQ(message, string("Failed to invoke NNAPI interpreter")) - << message; + EXPECT_EQ(message, string("Failed to invoke interpreter")) << message; } else { EXPECT_TRUE(result) << message; } @@ -256,27 +281,34 @@ struct ZipPathParamName { } }; -INSTANTIATE_TEST_CASE_P( - tests, OpsTest, - ::testing::ValuesIn(UnarchiveZipAndFindTestNames(*FLAGS_zip_file_path)), - ZipPathParamName()); +INSTANTIATE_TEST_CASE_P(tests, OpsTest, + ::testing::ValuesIn(UnarchiveAndFindTestNames( + *FLAGS_zip_file_path, *FLAGS_tar_file_path)), + ZipPathParamName()); } // namespace testing } // namespace tflite int main(int argc, char** argv) { - ::testing::AddGlobalTestEnvironment(tflite::testing::zip_environment()); + ::testing::AddGlobalTestEnvironment(tflite::testing::archive_environment()); std::vector flags = { tensorflow::Flag( "ignore_known_bugs", &tflite::testing::FLAGS_ignore_known_bugs, "If a particular model is affected by a known bug, the " "corresponding test should expect the outputs to not match."), - tensorflow::Flag("zip_file_path", tflite::testing::FLAGS_zip_file_path, - "Required: Location of the test zip file."), + tensorflow::Flag( + "tar_file_path", tflite::testing::FLAGS_tar_file_path, + "Required (or zip_file_path): Location of the test tar file."), + tensorflow::Flag( + "zip_file_path", tflite::testing::FLAGS_zip_file_path, + "Required (or tar_file_path): Location of the test zip file."), tensorflow::Flag("unzip_binary_path", tflite::testing::FLAGS_unzip_binary_path, - "Required: Location of a suitable unzip binary."), + "Location of a suitable unzip binary."), + tensorflow::Flag("tar_binary_path", + tflite::testing::FLAGS_tar_binary_path, + "Location of a suitable tar binary."), tensorflow::Flag("use_nnapi", &tflite::testing::FLAGS_use_nnapi, "Whether to enable the NNAPI delegate"), tensorflow::Flag("ignore_unsupported_nnapi", -- GitLab From bdda02d4b9869c6c6c751ab81e0bef60766d0ef2 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Mon, 13 Aug 2018 09:21:21 -0700 Subject: [PATCH 403/437] Adding constant Select and Tile resolution. PiperOrigin-RevId: 208491390 --- tensorflow/contrib/lite/toco/BUILD | 2 + .../graph_transformations.h | 2 + .../remove_trivial_passthrough.cc | 24 ++- .../remove_trivial_passthrough.h | 3 +- .../resolve_constant_select.cc | 78 ++++++++ .../resolve_constant_tile.cc | 173 ++++++++++++++++++ tensorflow/contrib/lite/toco/toco_tooling.cc | 2 + 7 files changed, 274 insertions(+), 10 deletions(-) create mode 100644 tensorflow/contrib/lite/toco/graph_transformations/resolve_constant_select.cc create mode 100644 tensorflow/contrib/lite/toco/graph_transformations/resolve_constant_tile.cc diff --git a/tensorflow/contrib/lite/toco/BUILD b/tensorflow/contrib/lite/toco/BUILD index aa4a4d8854..02d0890a7a 100644 --- a/tensorflow/contrib/lite/toco/BUILD +++ b/tensorflow/contrib/lite/toco/BUILD @@ -242,9 +242,11 @@ cc_library( "graph_transformations/resolve_constant_random_uniform.cc", "graph_transformations/resolve_constant_range.cc", "graph_transformations/resolve_constant_reshape.cc", + "graph_transformations/resolve_constant_select.cc", "graph_transformations/resolve_constant_shape_or_rank.cc", "graph_transformations/resolve_constant_slice.cc", "graph_transformations/resolve_constant_strided_slice.cc", + "graph_transformations/resolve_constant_tile.cc", "graph_transformations/resolve_constant_transpose.cc", "graph_transformations/resolve_constant_unary.cc", "graph_transformations/resolve_fake_quant_args_from_vars.cc", diff --git a/tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.h b/tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.h index 8d9a4c4700..99f4a7d8f6 100644 --- a/tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.h +++ b/tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.h @@ -190,6 +190,8 @@ DECLARE_GRAPH_TRANSFORMATION(ResolveConstantSlice) DECLARE_GRAPH_TRANSFORMATION(ResolveConstantStridedSlice) DECLARE_GRAPH_TRANSFORMATION(ResolveConstantFill) DECLARE_GRAPH_TRANSFORMATION(ResolveConstantGather) +DECLARE_GRAPH_TRANSFORMATION(ResolveConstantSelect) +DECLARE_GRAPH_TRANSFORMATION(ResolveConstantTile) DECLARE_GRAPH_TRANSFORMATION(ResolveMultiplyByZero) DECLARE_GRAPH_TRANSFORMATION(Dequantize) DECLARE_GRAPH_TRANSFORMATION(UnpartitionEmbeddingLookup) diff --git a/tensorflow/contrib/lite/toco/graph_transformations/remove_trivial_passthrough.cc b/tensorflow/contrib/lite/toco/graph_transformations/remove_trivial_passthrough.cc index 9f5d8b9450..fc49fbda59 100644 --- a/tensorflow/contrib/lite/toco/graph_transformations/remove_trivial_passthrough.cc +++ b/tensorflow/contrib/lite/toco/graph_transformations/remove_trivial_passthrough.cc @@ -48,20 +48,26 @@ void RerouteEdges(const string& from_array, const string& to_array, } // namespace bool RemoveTrivialPassthroughOp(GraphTransformation* transformation, - Model* model, std::size_t op_index) { + Model* model, std::size_t op_index, + int input_index) { const auto passthru_it = model->operators.begin() + op_index; auto* passthru_op = passthru_it->get(); CHECK_EQ(passthru_op->outputs.size(), 1); CHECK_GE(passthru_op->inputs.size(), 1); - int count_nonconstant_input_arrays = 0; - // We call 'main input' the unique nonconstant input array if there is one, - // or else the 0-th input. + int main_input_array_index = 0; - for (int i = 0; i < passthru_op->inputs.size(); i++) { - if (!model->GetArray(passthru_op->inputs[i]).buffer) { - count_nonconstant_input_arrays++; - if (count_nonconstant_input_arrays == 1) { - main_input_array_index = i; + if (input_index != -1) { + main_input_array_index = input_index; + } else { + // We call 'main input' the unique nonconstant input array if there is one, + // or else the 0-th input. + int count_nonconstant_input_arrays = 0; + for (int i = 0; i < passthru_op->inputs.size(); i++) { + if (!model->GetArray(passthru_op->inputs[i]).buffer) { + count_nonconstant_input_arrays++; + if (count_nonconstant_input_arrays == 1) { + main_input_array_index = i; + } } } } diff --git a/tensorflow/contrib/lite/toco/graph_transformations/remove_trivial_passthrough.h b/tensorflow/contrib/lite/toco/graph_transformations/remove_trivial_passthrough.h index 9d448c3ee9..663704e5ac 100644 --- a/tensorflow/contrib/lite/toco/graph_transformations/remove_trivial_passthrough.h +++ b/tensorflow/contrib/lite/toco/graph_transformations/remove_trivial_passthrough.h @@ -50,7 +50,8 @@ namespace toco { // and then discards it and returns true, or, if it's not trivial (if neither // the input nor the output may be discarded), returns false. bool RemoveTrivialPassthroughOp(GraphTransformation* transformation, - Model* model, std::size_t op_index); + Model* model, std::size_t op_index, + int input_index = -1); } // namespace toco diff --git a/tensorflow/contrib/lite/toco/graph_transformations/resolve_constant_select.cc b/tensorflow/contrib/lite/toco/graph_transformations/resolve_constant_select.cc new file mode 100644 index 0000000000..e880a3f44d --- /dev/null +++ b/tensorflow/contrib/lite/toco/graph_transformations/resolve_constant_select.cc @@ -0,0 +1,78 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ +#include + +#include "tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.h" +#include "tensorflow/contrib/lite/toco/graph_transformations/remove_trivial_passthrough.h" +#include "tensorflow/contrib/lite/toco/model.h" +#include "tensorflow/contrib/lite/toco/tooling_util.h" +#include "tensorflow/core/platform/logging.h" + +namespace toco { + +// Resolves a constant Select operation. +// +// This implementation is looking strictly for all-or-nothing on the select +// condition. It's possible to enhance this by looking per-element and possibly +// producing a Mul op. +bool ResolveConstantSelect::Run(Model* model, std::size_t op_index) { + auto it = model->operators.begin() + op_index; + const auto* base_op = it->get(); + if (base_op->type != OperatorType::kSelect) { + return false; + } + const auto* op = static_cast(base_op); + + CHECK_GE(op->inputs.size(), 3); + CHECK_EQ(op->outputs.size(), 1); + auto& output_array = model->GetArray(op->outputs[0]); + if (output_array.data_type == ArrayDataType::kNone) { + // Yield until the output type has been set by PropagateArrayDataTypes. + return false; + } + if (!output_array.has_shape()) { + // Yield until the output shape has been set by PropagateFixedShapes. + return false; + } + + // We require the cond input to be constant. + if (!IsConstantParameterArray(*model, op->inputs[0])) { + return false; + } + const Array& cond_array = model->GetArray(op->inputs[0]); + CHECK(cond_array.data_type == ArrayDataType::kBool) + << "Only bool conditions are supported"; + const auto& cond_data = cond_array.GetBuffer().data; + if (cond_data.empty()) { + return false; + } + + // Check if the condition is the same for all elements. + bool cond_value = cond_data[0]; + for (size_t i = 1; i < cond_data.size(); ++i) { + if (cond_data[i] != cond_value) { + AddMessageF( + "Cannot resolve %s as constant; cond_array has differing " + "per-element values", + LogName(*op)); + return false; + } + } + + // Pass-through the selected input. + return RemoveTrivialPassthroughOp(this, model, op_index, cond_value ? 1 : 2); +} + +} // namespace toco diff --git a/tensorflow/contrib/lite/toco/graph_transformations/resolve_constant_tile.cc b/tensorflow/contrib/lite/toco/graph_transformations/resolve_constant_tile.cc new file mode 100644 index 0000000000..0b0d070714 --- /dev/null +++ b/tensorflow/contrib/lite/toco/graph_transformations/resolve_constant_tile.cc @@ -0,0 +1,173 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ +#include + +#include "tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.h" +#include "tensorflow/contrib/lite/toco/model.h" +#include "tensorflow/contrib/lite/toco/tooling_util.h" +#include "tensorflow/core/platform/logging.h" + +namespace toco { + +namespace { + +// NOTE: the Tile implementation here is taken from tflite's Tile kernel. + +template +void CopyMultipleTimes(const T* in_data, int32_t in_size, int32_t multiplier, + T* out_data) { + for (int i = 0; i < multiplier; ++i) { + const T* in_end = in_data + in_size; + T* new_out_data = std::copy(in_data, in_end, out_data); + in_data = out_data; + out_data = new_out_data; + } +} + +template +std::pair TileOneDimension(const Shape& in_dimensions, + const T* in_data, const M* multipliers, + T* out_data, int dimension) { + const int dimension_size = in_dimensions.dims(dimension); + if (dimension == in_dimensions.dimensions_count() - 1) { + CopyMultipleTimes(in_data, dimension_size, multipliers[dimension], + out_data); + return std::make_pair( + dimension_size, + dimension_size * static_cast(multipliers[dimension])); + } + int total_stride_size = 0, total_tiled_stride_size = 0; + const T* copy_from_data = in_data; + T* copy_to_data = out_data; + for (int i = 0; i < dimension_size; ++i) { + int stride_size = 0, tiled_stride_size = 0; + std::tie(stride_size, tiled_stride_size) = + TileOneDimension(in_dimensions, copy_from_data, multipliers, + copy_to_data, dimension + 1); + copy_from_data += stride_size; + copy_to_data += tiled_stride_size; + total_stride_size += stride_size; + total_tiled_stride_size += tiled_stride_size; + } + CopyMultipleTimes(out_data, total_tiled_stride_size, + multipliers[dimension] - 1, + out_data + total_tiled_stride_size); + return std::make_pair(total_stride_size, + total_tiled_stride_size * multipliers[dimension]); +} + +template +inline void Tile(const Array& input_array, const Array& multiples_array, + Array* output_array) { + // Allocate output storage. + auto& output_data = output_array->GetMutableBuffer().data; + output_data.resize(RequiredBufferSizeForShape(output_array->shape())); + + switch (multiples_array.data_type) { + case ArrayDataType::kInt32: + TileOneDimension( + input_array.shape(), input_array.GetBuffer().data.data(), + multiples_array.GetBuffer().data.data(), + output_array->GetMutableBuffer().data.data(), 0); + break; + case ArrayDataType::kInt64: + TileOneDimension( + input_array.shape(), input_array.GetBuffer().data.data(), + multiples_array.GetBuffer().data.data(), + output_array->GetMutableBuffer().data.data(), 0); + break; + default: + CHECK(false); + break; + } +} + +} // namespace + +// Resolves a constant Tile operation. +bool ResolveConstantTile::Run(Model* model, std::size_t op_index) { + auto it = model->operators.begin() + op_index; + const auto* base_op = it->get(); + if (base_op->type != OperatorType::kTile) { + return false; + } + const auto* op = static_cast(base_op); + + CHECK_GE(op->inputs.size(), 2); + CHECK_EQ(op->outputs.size(), 1); + auto& output_array = model->GetArray(op->outputs[0]); + if (output_array.data_type == ArrayDataType::kNone) { + // Yield until the output type has been set by PropagateArrayDataTypes. + return false; + } + if (!output_array.has_shape()) { + // Yield until the output shape has been set by PropagateFixedShapes. + return false; + } + + // We require constant inputs. + if (!IsConstantParameterArray(*model, op->inputs[0]) || + !IsConstantParameterArray(*model, op->inputs[1])) { + return false; + } + const Array& input_array = model->GetArray(op->inputs[0]); + const Array& multiples_array = model->GetArray(op->inputs[1]); + CHECK(multiples_array.data_type == ArrayDataType::kInt32 || + multiples_array.data_type == ArrayDataType::kInt64) + << "Only int32/int64 indices are supported"; + + // Copy min/max info if present. The ranges of the selected values may be + // a subset of the original range but we want to ensure the quantization + // params stay the same. + if (input_array.minmax) { + const auto& input_minmax = input_array.GetMinMax(); + auto& output_minmax = output_array.GetOrCreateMinMax(); + output_minmax.min = input_minmax.min; + output_minmax.max = input_minmax.max; + } + + CHECK(!output_array.buffer); + switch (output_array.data_type) { + case ArrayDataType::kFloat: + Tile(input_array, multiples_array, &output_array); + break; + case ArrayDataType::kUint8: + Tile(input_array, multiples_array, &output_array); + break; + case ArrayDataType::kInt16: + Tile(input_array, multiples_array, &output_array); + break; + case ArrayDataType::kInt32: + Tile(input_array, multiples_array, &output_array); + break; + case ArrayDataType::kInt64: + Tile(input_array, multiples_array, &output_array); + break; + default: + LOG(FATAL) << "Unsupported data type given to Tile op with output \"" + << op->outputs[0] << "\""; + break; + } + + // Erase input arrays if no longer used after we remove the op. + DeleteArrayIfUsedOnce(op->inputs[0], model); + DeleteArrayIfUsedOnce(op->inputs[1], model); + + // Erase the operator. + model->operators.erase(it); + return true; +} + +} // namespace toco diff --git a/tensorflow/contrib/lite/toco/toco_tooling.cc b/tensorflow/contrib/lite/toco/toco_tooling.cc index fcd3cbab07..34130a02b0 100644 --- a/tensorflow/contrib/lite/toco/toco_tooling.cc +++ b/tensorflow/contrib/lite/toco/toco_tooling.cc @@ -90,8 +90,10 @@ void MakeGeneralGraphTransformationsSet( transformations->Add(new ResolveConstantRandomUniform); transformations->Add(new ResolveConstantRange); transformations->Add(new ResolveConstantReshape); + transformations->Add(new ResolveConstantSelect); transformations->Add(new ResolveConstantSlice); transformations->Add(new ResolveConstantStridedSlice); + transformations->Add(new ResolveConstantTile); transformations->Add(new ResolveConstantTranspose); transformations->Add(new ResolveConstantUnaryOperator); transformations->Add(new ResolveTensorFlowMerge); -- GitLab From 5dafd113d9fa1b9fb3e16406946db3117d9bb70a Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Mon, 13 Aug 2018 09:23:27 -0700 Subject: [PATCH 404/437] Upgrade cloud tpu profiler to 1.10. PiperOrigin-RevId: 208491690 --- tensorflow/contrib/tpu/profiler/pip_package/setup.py | 2 +- tensorflow/contrib/tpu/profiler/version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow/contrib/tpu/profiler/pip_package/setup.py b/tensorflow/contrib/tpu/profiler/pip_package/setup.py index 19f088f8b8..d4ccb0f246 100644 --- a/tensorflow/contrib/tpu/profiler/pip_package/setup.py +++ b/tensorflow/contrib/tpu/profiler/pip_package/setup.py @@ -20,7 +20,7 @@ from __future__ import print_function from setuptools import setup -_VERSION = '1.9.0' +_VERSION = '1.10.0' CONSOLE_SCRIPTS = [ 'capture_tpu_profile=cloud_tpu_profiler.main:run_main', diff --git a/tensorflow/contrib/tpu/profiler/version.h b/tensorflow/contrib/tpu/profiler/version.h index 1bf49966d1..aee094177b 100644 --- a/tensorflow/contrib/tpu/profiler/version.h +++ b/tensorflow/contrib/tpu/profiler/version.h @@ -16,6 +16,6 @@ limitations under the License. #ifndef TENSORFLOW_CONTRIB_TPU_PROFILER_VERSION_H_ #define TENSORFLOW_CONTRIB_TPU_PROFILER_VERSION_H_ -#define TPU_PROFILER_VERSION "1.9.0" +#define TPU_PROFILER_VERSION "1.10.0" #endif // TENSORFLOW_CONTRIB_TPU_PROFILER_VERSION_H_ -- GitLab From a983448448d3030674b2a13c5723a4e9db756003 Mon Sep 17 00:00:00 2001 From: Tiezhen WANG Date: Mon, 13 Aug 2018 09:49:38 -0700 Subject: [PATCH 405/437] TF train: allow passing in run_metadata to unblock tf profiler. PiperOrigin-RevId: 208495685 --- tensorflow/contrib/training/python/training/training.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tensorflow/contrib/training/python/training/training.py b/tensorflow/contrib/training/python/training/training.py index f72e0a3f83..c272a2ac14 100644 --- a/tensorflow/contrib/training/python/training/training.py +++ b/tensorflow/contrib/training/python/training/training.py @@ -484,7 +484,8 @@ def train(train_op, save_checkpoint_secs=600, save_summaries_steps=100, config=None, - max_wait_secs=7200): + max_wait_secs=7200, + run_metadata=None): """Runs the training loop. Args: @@ -511,6 +512,7 @@ def train(train_op, become available. This should be kept relatively short to help detect incorrect code, but sometimes may need to be increased if the chief takes a while to start up. + run_metadata: A [`RunMetadata`] protocol buffer. Returns: the value of the loss function after training. @@ -541,5 +543,5 @@ def train(train_op, max_wait_secs=max_wait_secs) as session: loss = None while not session.should_stop(): - loss = session.run(train_op) + loss = session.run(train_op, run_metadata=run_metadata) return loss -- GitLab From ec3d9d9cf32697b0a44c1738dd06ec79f8db9064 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Mon, 13 Aug 2018 09:49:38 -0700 Subject: [PATCH 406/437] Add HLO matcher for the tuple-select HLO. PiperOrigin-RevId: 208495688 --- tensorflow/compiler/xla/service/hlo_matchers.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tensorflow/compiler/xla/service/hlo_matchers.h b/tensorflow/compiler/xla/service/hlo_matchers.h index b57c940238..c577b4359a 100644 --- a/tensorflow/compiler/xla/service/hlo_matchers.h +++ b/tensorflow/compiler/xla/service/hlo_matchers.h @@ -231,6 +231,7 @@ HLO_MATCHER(Tanh); HLO_MATCHER(Trace); HLO_MATCHER(Transpose); HLO_MATCHER(Tuple); +HLO_MATCHER(TupleSelect); HLO_MATCHER(While); // The special cases below let you check additional information about the -- GitLab From bc89890f52a00b6094f2c49ec76a7264680beb8c Mon Sep 17 00:00:00 2001 From: Wesley Qian Date: Mon, 13 Aug 2018 10:01:45 -0700 Subject: [PATCH 407/437] Expose stargan_loss in train.py. PiperOrigin-RevId: 208497573 --- tensorflow/contrib/gan/python/train.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tensorflow/contrib/gan/python/train.py b/tensorflow/contrib/gan/python/train.py index 03f52d214b..9e5aea1498 100644 --- a/tensorflow/contrib/gan/python/train.py +++ b/tensorflow/contrib/gan/python/train.py @@ -52,7 +52,6 @@ from tensorflow.python.training import session_run_hook from tensorflow.python.training import sync_replicas_optimizer from tensorflow.python.training import training_util - __all__ = [ 'gan_model', 'infogan_model', @@ -61,6 +60,7 @@ __all__ = [ 'stargan_model', 'gan_loss', 'cyclegan_loss', + 'stargan_loss', 'gan_train_ops', 'gan_train', 'get_sequential_train_hooks', @@ -646,8 +646,9 @@ def gan_loss( type(model)) # Optionally create pooled model. - pooled_model = (_tensor_pool_adjusted_model(model, tensor_pool_fn) if - tensor_pool_fn else model) + pooled_model = ( + _tensor_pool_adjusted_model(model, tensor_pool_fn) + if tensor_pool_fn else model) # Create standard losses. gen_loss = generator_loss_fn(model, add_summaries=add_summaries) @@ -665,9 +666,10 @@ def gan_loss( if _use_aux_loss(mutual_information_penalty_weight): gen_info_loss = tfgan_losses.mutual_information_penalty( model, add_summaries=add_summaries) - dis_info_loss = (gen_info_loss if tensor_pool_fn is None else - tfgan_losses.mutual_information_penalty( - pooled_model, add_summaries=add_summaries)) + dis_info_loss = ( + gen_info_loss + if tensor_pool_fn is None else tfgan_losses.mutual_information_penalty( + pooled_model, add_summaries=add_summaries)) gen_loss += mutual_information_penalty_weight * gen_info_loss dis_loss += mutual_information_penalty_weight * dis_info_loss if _use_aux_loss(aux_cond_generator_weight): -- GitLab From 10d268b8cb4b23a81ee3622df9d54b8ded500d0f Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Mon, 13 Aug 2018 10:26:57 -0700 Subject: [PATCH 408/437] [XLA] Split CPU and GPU fastmath into separate flags. The motivation for this change is to allow us to change the default for CPU and GPU independently. In particular, we want to disable fastmath on both platforms, but I think it will be much easier on GPU, and I don't want that blocked on getting things perfect on CPU. The primary motivation for turning off fastmath is that on GPU with f16, model authors may use automatic loss scaling, which looks for NaNs in the loss and tweaks the loss scale factor. If fastmath is enabled, the compiler is free to produce any fp value instead of NaN, so this is unsound. The reason I expect this will be easier to do without regression on GPU is that on CPU some of the important vectorization we do relies on fastmath being enabled, but we have nothing of the sort on GPU. No functional change, since this patch leaves the defaults as they currently are (fastmath on for both platforms). PiperOrigin-RevId: 208502191 --- .../xla/legacy_flags/debug_options_flags.cc | 20 ++++++++++++++----- .../compiler/xla/service/cpu/cpu_compiler.cc | 10 +++++----- .../xla/service/cpu/dot_op_emitter.cc | 4 ++-- .../compiler/xla/service/cpu/ir_emitter.cc | 12 +++++------ .../xla/service/gpu/elemental_ir_emitter.cc | 7 +++++-- .../compiler/xla/service/gpu/ir_emitter.cc | 2 +- .../gpu/llvm_gpu_backend/nvptx_backend_lib.cc | 2 +- .../xla/tests/client_library_test_base.h | 5 +++-- tensorflow/compiler/xla/xla.proto | 19 +++++++++--------- 9 files changed, 48 insertions(+), 33 deletions(-) diff --git a/tensorflow/compiler/xla/legacy_flags/debug_options_flags.cc b/tensorflow/compiler/xla/legacy_flags/debug_options_flags.cc index f42fb92359..1bf8948ef6 100644 --- a/tensorflow/compiler/xla/legacy_flags/debug_options_flags.cc +++ b/tensorflow/compiler/xla/legacy_flags/debug_options_flags.cc @@ -31,7 +31,6 @@ std::vector* flag_objects; std::once_flag flags_init; void SetDebugOptionsDefaults(DebugOptions* flags) { - flags->set_xla_enable_fast_math(true); flags->set_xla_llvm_enable_alias_scope_metadata(true); flags->set_xla_llvm_enable_noalias_metadata(true); flags->set_xla_llvm_enable_invariant_load_metadata(true); @@ -53,6 +52,11 @@ void SetDebugOptionsDefaults(DebugOptions* flags) { // the heuristics needed to decide when to run on multiple streams. See // b/77879207. flags->set_xla_gpu_disable_multi_streaming(true); + + // TODO(jlebar): Disable fastmath once doing so is not a performance + // regression. + flags->set_xla_cpu_enable_fast_math(true); + flags->set_xla_gpu_enable_fast_math(true); } // Allocates flag_values and flag_objects; this function must not be called more @@ -150,10 +154,16 @@ void AllocateFlags() { flag_values->mutable_xla_generate_hlo_text_to(), "Dump all HLO modules as text into the provided directory path."), tensorflow::Flag( - "xla_enable_fast_math", - bool_setter_for(&DebugOptions::set_xla_enable_fast_math), - flag_values->xla_enable_fast_math(), - "Enable unsafe fast-math optimizations in the compiler; " + "xla_cpu_enable_fast_math", + bool_setter_for(&DebugOptions::set_xla_cpu_enable_fast_math), + flag_values->xla_cpu_enable_fast_math(), + "Enable unsafe fast-math optimizations in the CPU compiler; " + "this may produce faster code at the expense of some accuracy."), + tensorflow::Flag( + "xla_gpu_enable_fast_math", + bool_setter_for(&DebugOptions::set_xla_cpu_enable_fast_math), + flag_values->xla_cpu_enable_fast_math(), + "Enable unsafe fast-math optimizations in the GPU compiler; " "this may produce faster code at the expense of some accuracy."), tensorflow::Flag( "xla_llvm_enable_alias_scope_metadata", diff --git a/tensorflow/compiler/xla/service/cpu/cpu_compiler.cc b/tensorflow/compiler/xla/service/cpu/cpu_compiler.cc index 2df959c4dc..62272c29c0 100644 --- a/tensorflow/compiler/xla/service/cpu/cpu_compiler.cc +++ b/tensorflow/compiler/xla/service/cpu/cpu_compiler.cc @@ -356,7 +356,7 @@ llvm::TargetOptions CompilerTargetOptions( llvm::TargetOptions target_options; llvm_ir::SetTargetOptions( /*fast_math_enabled=*/module_config.debug_options() - .xla_enable_fast_math(), + .xla_cpu_enable_fast_math(), &target_options); return target_options; } @@ -523,7 +523,7 @@ StatusOr> CpuCompiler::RunBackend( CompilerTargetOptions(module->config()), CodeGenOptLevel(module->config()), options::OptimizeForSizeRequested(module->config()), - module->config().debug_options().xla_enable_fast_math(), + module->config().debug_options().xla_cpu_enable_fast_math(), module->config().debug_options().xla_llvm_disable_expensive_passes(), pre_optimization_ir_hook, post_optimization_ir_hook); llvm_module->setDataLayout(jit->data_layout()); @@ -653,9 +653,9 @@ CpuCompiler::CompileAheadOfTime(std::vector> modules, // so we bail if the configs have conflicting flags. At the moment, the only // flag that needs to be consistent is fast-math. const bool fast_math_enabled = - modules[0]->config().debug_options().xla_enable_fast_math(); + modules[0]->config().debug_options().xla_cpu_enable_fast_math(); for (const auto& module : modules) { - if (module->config().debug_options().xla_enable_fast_math() != + if (module->config().debug_options().xla_cpu_enable_fast_math() != fast_math_enabled) { return InvalidArgument( "All HLO module configs must have the same value for " @@ -832,7 +832,7 @@ CpuCompiler::CompileAheadOfTime(std::vector> modules, CompilerFunctor compiler_functor( target_machine.get(), &disassembler, opt_level, options::OptimizeForSizeRequested(module->config()), - module->config().debug_options().xla_enable_fast_math(), + module->config().debug_options().xla_cpu_enable_fast_math(), module->config().debug_options().xla_llvm_disable_expensive_passes(), pre_optimization_ir_dump_hook, post_optimization_ir_dump_hook); std::unique_ptr object_file = diff --git a/tensorflow/compiler/xla/service/cpu/dot_op_emitter.cc b/tensorflow/compiler/xla/service/cpu/dot_op_emitter.cc index 645888de78..f2ac742b6e 100644 --- a/tensorflow/compiler/xla/service/cpu/dot_op_emitter.cc +++ b/tensorflow/compiler/xla/service/cpu/dot_op_emitter.cc @@ -1066,7 +1066,7 @@ bool DotOpEmitter::EmitExperimentalGebpDotIfEnabled( << config.GetCacheKey(); const bool enable_fast_math = - hlo_module_config_.debug_options().xla_enable_fast_math(); + hlo_module_config_.debug_options().xla_cpu_enable_fast_math(); const bool optimize_for_size = options::OptimizeForSizeRequested(hlo_module_config_); @@ -1149,7 +1149,7 @@ bool DotOpEmitter::EmitLlvmIrDotIfProfitable() { swap_operands ? lhs_array_.GetBasePointer() : rhs_array_.GetBasePointer(); const bool enable_fast_math = - hlo_module_config_.debug_options().xla_enable_fast_math(); + hlo_module_config_.debug_options().xla_cpu_enable_fast_math(); const bool optimize_for_size = options::OptimizeForSizeRequested(hlo_module_config_); diff --git a/tensorflow/compiler/xla/service/cpu/ir_emitter.cc b/tensorflow/compiler/xla/service/cpu/ir_emitter.cc index 09909b62ba..d02d5beef2 100644 --- a/tensorflow/compiler/xla/service/cpu/ir_emitter.cc +++ b/tensorflow/compiler/xla/service/cpu/ir_emitter.cc @@ -99,7 +99,7 @@ IrEmitter::IrEmitter( target_machine_features_(*target_machine_features) { b_.setFastMathFlags(llvm_ir::GetFastMathFlags( /*fast_math_enabled=*/hlo_module_config_.debug_options() - .xla_enable_fast_math())); + .xla_cpu_enable_fast_math())); } StatusOr IrEmitter::EmitComputation( @@ -158,11 +158,11 @@ void IrEmitter::InitializeIrFunction(const string& function_name) { is_top_level_computation_ ? llvm::GlobalValue::ExternalLinkage : llvm::GlobalValue::InternalLinkage; // Create and initialize new IrFunction. - compute_function_.reset( - new IrFunction(function_name, linkage, - options::OptimizeForSizeRequested(hlo_module_config_), - hlo_module_config_.debug_options().xla_enable_fast_math(), - module_, &b_, num_dynamic_loop_bounds_)); + compute_function_.reset(new IrFunction( + function_name, linkage, + options::OptimizeForSizeRequested(hlo_module_config_), + hlo_module_config_.debug_options().xla_cpu_enable_fast_math(), module_, + &b_, num_dynamic_loop_bounds_)); } IrEmitter::~IrEmitter() {} diff --git a/tensorflow/compiler/xla/service/gpu/elemental_ir_emitter.cc b/tensorflow/compiler/xla/service/gpu/elemental_ir_emitter.cc index 69ba91793d..5233cd0255 100644 --- a/tensorflow/compiler/xla/service/gpu/elemental_ir_emitter.cc +++ b/tensorflow/compiler/xla/service/gpu/elemental_ir_emitter.cc @@ -210,11 +210,14 @@ StatusOr GpuElementalIrEmitter::EmitPowerOp( return make_sqrt(); } - if (hlo_module_config_.debug_options().xla_enable_fast_math() && + if (hlo_module_config_.debug_options().xla_gpu_enable_fast_math() && IsFPLiteralWithValue(rhs, -.5)) { VLOG(10) << "emitting pow(A, -.5) as 1/sqrt(A): " << op->ToString(); // LLVM's NVPTX backend knows how to transform 1/sqrt(A) into the NVPTX // rsqrt.approx instruction. + // + // TODO(jlebar): Does this happen with fastmath disabled? If not, should + // we force-enable it? TF_ASSIGN_OR_RETURN(auto* sqrt, make_sqrt()); return b_->CreateFDiv(llvm::ConstantFP::get(llvm_ty, 1), sqrt); } @@ -276,7 +279,7 @@ StatusOr GpuElementalIrEmitter::EmitTanh( PrimitiveType prim_type, llvm::Value* value) const { // If we don't care much about precision, emit a fast approximation of // tanh. - if (hlo_module_config_.debug_options().xla_enable_fast_math()) { + if (hlo_module_config_.debug_options().xla_gpu_enable_fast_math()) { // Upcast F16 to F32 if necessary. llvm::Type* type = prim_type == F16 ? b_->getFloatTy() : value->getType(); llvm::Value* input = b_->CreateFPCast(value, type); diff --git a/tensorflow/compiler/xla/service/gpu/ir_emitter.cc b/tensorflow/compiler/xla/service/gpu/ir_emitter.cc index 66aeb4efef..6675dbd3f9 100644 --- a/tensorflow/compiler/xla/service/gpu/ir_emitter.cc +++ b/tensorflow/compiler/xla/service/gpu/ir_emitter.cc @@ -64,7 +64,7 @@ IrEmitter::IrEmitter(const HloModuleConfig& hlo_module_config, hlo_module_config_(hlo_module_config) { b_.setFastMathFlags(llvm_ir::GetFastMathFlags( /*fast_math_enabled=*/hlo_module_config.debug_options() - .xla_enable_fast_math())); + .xla_gpu_enable_fast_math())); } Status IrEmitter::DefaultAction(HloInstruction* hlo) { diff --git a/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/nvptx_backend_lib.cc b/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/nvptx_backend_lib.cc index cf44458a2e..ff4ae1f9ef 100644 --- a/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/nvptx_backend_lib.cc +++ b/tensorflow/compiler/xla/service/gpu/llvm_gpu_backend/nvptx_backend_lib.cc @@ -180,7 +180,7 @@ std::unique_ptr GetTargetMachine( TargetOptions target_options = InitTargetOptionsFromCodeGenFlags(); llvm_ir::SetTargetOptions( /*fast_math_enabled=*/hlo_module_config.debug_options() - .xla_enable_fast_math(), + .xla_gpu_enable_fast_math(), &target_options); // Enable FMA synthesis. diff --git a/tensorflow/compiler/xla/tests/client_library_test_base.h b/tensorflow/compiler/xla/tests/client_library_test_base.h index 4a6e8a3124..b04a3b105c 100644 --- a/tensorflow/compiler/xla/tests/client_library_test_base.h +++ b/tensorflow/compiler/xla/tests/client_library_test_base.h @@ -74,8 +74,9 @@ class ClientLibraryTestBase : public ::testing::Test { string TestName() const; void SetFastMathDisabled(bool disabled) { - execution_options_.mutable_debug_options()->set_xla_enable_fast_math( - !disabled); + auto* opts = execution_options_.mutable_debug_options(); + opts->set_xla_cpu_enable_fast_math(!disabled); + opts->set_xla_gpu_enable_fast_math(!disabled); } void SetSeed(uint64 seed) { execution_options_.set_seed(seed); } diff --git a/tensorflow/compiler/xla/xla.proto b/tensorflow/compiler/xla/xla.proto index 10c0adc670..3b72eb17c6 100644 --- a/tensorflow/compiler/xla/xla.proto +++ b/tensorflow/compiler/xla/xla.proto @@ -104,15 +104,6 @@ message DebugOptions { // interpretation of this value is left to the backends. int32 xla_backend_optimization_level = 31; - // When true, "unsafe" mathematical optimizations are enabled. These - // transformations include but are not limited to: - // - // - Reducing the precision of operations (e.g. using an approximate sin - // function, or transforming x/y into x * (1/y)). - // - Assuming that operations never produce or consume NaN or +/- Inf. - // - Assuming that +0 and -0 are indistinguishable. - bool xla_enable_fast_math = 32; - // Embed the compiler IR as a string in the executable. bool xla_embed_ir_in_executable = 33; @@ -194,6 +185,16 @@ message DebugOptions { // Maximum kernel unroll factor for the GPU backend. int32 xla_gpu_max_kernel_unroll_factor = 98; + // When true, "unsafe" mathematical optimizations are enabled. These + // transformations include but are not limited to: + // + // - Reducing the precision of operations (e.g. using an approximate sin + // function, or transforming x/y into x * (1/y)). + // - Assuming that operations never produce or consume NaN or +/- Inf. + // - Assuming that +0 and -0 are indistinguishable. + bool xla_cpu_enable_fast_math = 99; + bool xla_gpu_enable_fast_math = 100; + // Extra options to pass to the compilation backend; specific interpretation // of these values is left to the backend. map xla_backend_extra_options = 500; -- GitLab From b619a92ed98b81bf7e9e2565a53ac27d2fad26fa Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Mon, 13 Aug 2018 10:28:57 -0700 Subject: [PATCH 409/437] Implement ShapeFn for UnravelIndexOp. PiperOrigin-RevId: 208502552 --- tensorflow/core/ops/array_ops.cc | 14 +++++++++++++- tensorflow/core/ops/array_ops_test.cc | 15 +++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/tensorflow/core/ops/array_ops.cc b/tensorflow/core/ops/array_ops.cc index ef8ad7972c..f87b4d6bde 100644 --- a/tensorflow/core/ops/array_ops.cc +++ b/tensorflow/core/ops/array_ops.cc @@ -427,7 +427,19 @@ REGISTER_OP("UnravelIndex") .Input("dims: Tidx") .Output("output: Tidx") .Attr("Tidx: {int32, int64} = DT_INT32") - .SetShapeFn([](InferenceContext* c) { return Status::OK(); }); + .SetShapeFn([](InferenceContext* c) { + ShapeHandle indices = c->input(0); + ShapeHandle dims; + TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 1, &dims)); + if (c->RankKnown(indices) && c->Rank(indices) == 0) { + c->set_output(0, c->Vector(c->Dim(dims, 0))); + } else if (c->RankKnown(indices)) { + c->set_output(0, c->Matrix(c->Dim(dims, 0), c->NumElements(indices))); + } else { + c->set_output(0, c->UnknownShape()); + } + return Status::OK(); + }); REGISTER_OP("BroadcastTo") .Input("input: T") diff --git a/tensorflow/core/ops/array_ops_test.cc b/tensorflow/core/ops/array_ops_test.cc index b1463338fb..c15409a246 100644 --- a/tensorflow/core/ops/array_ops_test.cc +++ b/tensorflow/core/ops/array_ops_test.cc @@ -27,6 +27,21 @@ limitations under the License. namespace tensorflow { +TEST(ArrayOpsTest, UnravelIndex_ShapeFn) { + ShapeInferenceTestOp op("UnravelIndex"); + + INFER_OK(op, "?;?", "?"); + + INFER_OK(op, "[];[?]", "[d1_0]"); + + INFER_OK(op, "[4,5];[?]", "[d1_0,20]"); + INFER_OK(op, "[2,3,4];[?]", "[d1_0,24]"); + INFER_OK(op, "?;[?]", "?"); + INFER_OK(op, "[?];[?]", "[d1_0,?]"); + + INFER_ERROR("Shape must be rank 1 but is rank 2", op, "?;[1,1]"); +} + TEST(ArrayOpsTest, Pack_ShapeFn) { ShapeInferenceTestOp op("Pack"); auto set_axis = [&op](int axis) { -- GitLab From dbcc981d0a1c0e516ebbe47510c2d8316e1f7d96 Mon Sep 17 00:00:00 2001 From: Yanan Cao Date: Mon, 13 Aug 2018 10:31:41 -0700 Subject: [PATCH 410/437] Add missing numerics dependency in clip_ops PiperOrigin-RevId: 208503071 --- tensorflow/python/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/python/BUILD b/tensorflow/python/BUILD index 2e6fb11655..2a71eaf030 100644 --- a/tensorflow/python/BUILD +++ b/tensorflow/python/BUILD @@ -1870,6 +1870,7 @@ py_library( ":framework_for_generated_wrappers", ":math_ops", ":nn_ops_gen", + ":numerics", "@six_archive//:six", ], ) @@ -1883,7 +1884,6 @@ py_test( ":client_testlib", ":clip_ops", ":framework_for_generated_wrappers", - ":numerics", "//third_party/py/numpy", ], ) -- GitLab From c965dd260303bfc645acb288a8e5f2aa7a7e9671 Mon Sep 17 00:00:00 2001 From: Peter Hawkins Date: Mon, 13 Aug 2018 10:45:54 -0700 Subject: [PATCH 411/437] Automated rollback of commit 56e4ea405d13125a3dcb6459019a83d12330bf84 PiperOrigin-RevId: 208505669 --- .../compiler/jit/kernels/xla_launch_op.cc | 3 +- .../compiler/jit/xla_compile_on_demand_op.cc | 3 +- tensorflow/compiler/jit/xla_device.cc | 41 +++++++-- tensorflow/compiler/jit/xla_device.h | 14 +-- tensorflow/compiler/jit/xla_device_context.cc | 89 ++++++++++++------- tensorflow/compiler/jit/xla_device_context.h | 31 ++++--- tensorflow/compiler/jit/xla_launch_util.cc | 62 +++++++------ tensorflow/compiler/jit/xla_launch_util.h | 6 +- tensorflow/compiler/jit/xla_tensor.cc | 7 +- tensorflow/compiler/jit/xla_tensor.h | 6 +- .../xla/service/interpreter/executor.h | 2 +- .../stream_executor/host/host_gpu_executor.h | 2 +- 12 files changed, 167 insertions(+), 99 deletions(-) diff --git a/tensorflow/compiler/jit/kernels/xla_launch_op.cc b/tensorflow/compiler/jit/kernels/xla_launch_op.cc index 37a2f3b5ac..7f4370b5b0 100644 --- a/tensorflow/compiler/jit/kernels/xla_launch_op.cc +++ b/tensorflow/compiler/jit/kernels/xla_launch_op.cc @@ -210,7 +210,8 @@ void XlaLocalLaunchBase::Compute(OpKernelContext* ctx) { auto elapsed = env->NowMicros() - start_time; VLOG(2) << "Elapsed time: " << elapsed << "us"; - launch_context.PopulateOutputs(ctx, kernel, run_result.ConsumeValueOrDie()); + OP_REQUIRES_OK(ctx, launch_context.PopulateOutputs( + ctx, kernel, run_result.ConsumeValueOrDie())); VLOG(1) << "Done"; } diff --git a/tensorflow/compiler/jit/xla_compile_on_demand_op.cc b/tensorflow/compiler/jit/xla_compile_on_demand_op.cc index f65f89ebf5..dd84fb34c1 100644 --- a/tensorflow/compiler/jit/xla_compile_on_demand_op.cc +++ b/tensorflow/compiler/jit/xla_compile_on_demand_op.cc @@ -78,7 +78,8 @@ Status XlaCompileOnDemandOp::Run(OpKernelContext* ctx, executable->Run(launch_context.arguments(), run_options); TF_RETURN_IF_ERROR(run_result.status()); - launch_context.PopulateOutputs(ctx, result, run_result.ConsumeValueOrDie()); + TF_RETURN_IF_ERROR(launch_context.PopulateOutputs( + ctx, result, run_result.ConsumeValueOrDie())); return Status::OK(); } diff --git a/tensorflow/compiler/jit/xla_device.cc b/tensorflow/compiler/jit/xla_device.cc index 4ddeaebd3e..2a2691a6a4 100644 --- a/tensorflow/compiler/jit/xla_device.cc +++ b/tensorflow/compiler/jit/xla_device.cc @@ -26,6 +26,7 @@ limitations under the License. #include "tensorflow/compiler/tf2xla/shape_util.h" #include "tensorflow/compiler/tf2xla/xla_op_registry.h" #include "tensorflow/compiler/xla/client/client_library.h" +#include "tensorflow/compiler/xla/service/stream_pool.h" #include "tensorflow/core/common_runtime/device.h" #include "tensorflow/core/common_runtime/device_factory.h" #include "tensorflow/core/common_runtime/dma_helper.h" @@ -216,6 +217,8 @@ XlaDevice::XlaDevice( transfer_as_literal_(transfer_as_literal), shape_representation_fn_(shape_representation_fn) { VLOG(1) << "Created XLA device " << jit_device_name << " " << this; + thread_pool_.reset(new thread::ThreadPool(options.env, "xla_device", + /*num_threads=*/1)); } XlaDevice::~XlaDevice() { @@ -262,10 +265,12 @@ Status XlaDevice::EnsureDeviceContextOk() { Status XlaDevice::EnsureStreamOkLocked(xla::Backend* backend, const string& name, - xla::StreamPool::Ptr* stream, + std::shared_ptr* stream, bool* stream_was_changed) { if (!(*stream) || !(*stream)->ok()) { - TF_ASSIGN_OR_RETURN(*stream, backend->BorrowStream(device_ordinal_)); + xla::StreamPool::Ptr ptr; + TF_ASSIGN_OR_RETURN(ptr, backend->BorrowStream(device_ordinal_)); + *stream = std::shared_ptr(std::move(ptr)); VLOG(1) << "XlaDevice " << this << " new " << name << " " << (*stream)->DebugStreamPointers(); *stream_was_changed = true; @@ -281,8 +286,8 @@ xla::StatusOr XlaDevice::GetDeviceContextLocked() { TF_RETURN_IF_ERROR(EnsureStreamOkLocked(backend, "stream", &stream_, &need_new_device_context)); - se::Stream* host_to_device_stream = stream_.get(); - se::Stream* device_to_host_stream = stream_.get(); + std::shared_ptr host_to_device_stream = stream_; + std::shared_ptr device_to_host_stream = stream_; if (use_multiple_streams_) { TF_RETURN_IF_ERROR(EnsureStreamOkLocked(backend, "host_to_device_stream", &host_to_device_stream_, @@ -290,8 +295,8 @@ xla::StatusOr XlaDevice::GetDeviceContextLocked() { TF_RETURN_IF_ERROR(EnsureStreamOkLocked(backend, "device_to_host_stream", &device_to_host_stream_, &need_new_device_context)); - host_to_device_stream = host_to_device_stream_.get(); - device_to_host_stream = device_to_host_stream_.get(); + host_to_device_stream = host_to_device_stream_; + device_to_host_stream = device_to_host_stream_; } if (!need_new_device_context) { @@ -304,9 +309,13 @@ xla::StatusOr XlaDevice::GetDeviceContextLocked() { if (device_context_) { device_context_->Unref(); } + // The XlaDeviceContext keeps a reference count to the streams, and the + // XlaDeviceContext remains live for the duration of a Executor run. This + // ensures that the streams remain live for the duration of a run, even if + // an error is encountered and the streams are replaced with new ones. device_context_ = new XlaDeviceContext( - stream_.get(), host_to_device_stream, device_to_host_stream, client(), - transfer_as_literal_, shape_representation_fn_); + stream_, host_to_device_stream, device_to_host_stream, client(), + transfer_as_literal_, shape_representation_fn_, thread_pool_.get()); VLOG(1) << "XlaDevice " << this << " new XlaDeviceContext " << device_context_; @@ -371,6 +380,22 @@ void XlaDevice::ComputeAsync(AsyncOpKernel* op_kernel, OpKernelContext* context, op_kernel->ComputeAsync(context, done); } +Status XlaDevice::Sync() { + VLOG(1) << "XlaDevice::Sync"; + std::shared_ptr stream; + { + mutex_lock lock(mu_); + stream = stream_; + } + if (!stream) return Status::OK(); + + if (!stream->parent()->SynchronizeAllActivity() || !stream->ok()) { + return errors::Internal("XlaDevice::Sync() failed."); + } + VLOG(1) << "XlaDevice::Sync completed"; + return Status::OK(); +} + Status XlaDevice::MakeTensorFromProto(const TensorProto& tensor_proto, const AllocatorAttributes alloc_attrs, Tensor* tensor) { diff --git a/tensorflow/compiler/jit/xla_device.h b/tensorflow/compiler/jit/xla_device.h index d8906419b0..dbf35f349f 100644 --- a/tensorflow/compiler/jit/xla_device.h +++ b/tensorflow/compiler/jit/xla_device.h @@ -30,7 +30,6 @@ limitations under the License. #include "tensorflow/compiler/tf2xla/xla_compiler.h" #include "tensorflow/compiler/tf2xla/xla_op_registry.h" #include "tensorflow/compiler/xla/client/local_client.h" -#include "tensorflow/compiler/xla/service/stream_pool.h" #include "tensorflow/core/common_runtime/device_factory.h" #include "tensorflow/core/common_runtime/local_device.h" #include "tensorflow/core/framework/allocator.h" @@ -124,7 +123,7 @@ class XlaDevice : public LocalDevice { void Compute(OpKernel* op_kernel, OpKernelContext* context) override; void ComputeAsync(AsyncOpKernel* op_kernel, OpKernelContext* context, AsyncOpKernel::DoneCallback done) override; - Status Sync() override { return Status::OK(); } + Status Sync() override; Status FillContextMap(const Graph* graph, DeviceContextMap* device_context_map) override @@ -153,7 +152,7 @@ class XlaDevice : public LocalDevice { Allocator* GetAllocatorLocked(AllocatorAttributes attr) EXCLUSIVE_LOCKS_REQUIRED(mu_); Status EnsureStreamOkLocked(xla::Backend* backend, const string& name, - xla::StreamPool::Ptr* stream, + std::shared_ptr* stream, bool* stream_was_changed) EXCLUSIVE_LOCKS_REQUIRED(mu_); xla::StatusOr GetDeviceContextLocked() @@ -174,17 +173,17 @@ class XlaDevice : public LocalDevice { // stream are executed on the device. Operations include data // copying back and forth between CPU and the device, and // computations enqueued by XLA. - xla::StreamPool::Ptr stream_ GUARDED_BY(mu_); + std::shared_ptr stream_ GUARDED_BY(mu_); // If false, only stream_ is valid and all computation and transfers use // stream_. If true, computation is performed by stream_ and transfers are // performed by host_to_device/device_to_host_stream. const bool use_multiple_streams_; // If use_multiple_streams_, host to device transfers are performed using this // stream. - xla::StreamPool::Ptr host_to_device_stream_ GUARDED_BY(mu_); + std::shared_ptr host_to_device_stream_ GUARDED_BY(mu_); // If use_multiple_streams_, device to host transfers are performed using this // stream. - xla::StreamPool::Ptr device_to_host_stream_ GUARDED_BY(mu_); + std::shared_ptr device_to_host_stream_ GUARDED_BY(mu_); // Must we use XLA's transfer manager for correct host<->device transfers? if // false, we can use ThenMemcpy() instead. const bool transfer_as_literal_; @@ -198,6 +197,9 @@ class XlaDevice : public LocalDevice { // Holds extra information for GPU and TPU devices, e.g. the device context. bool use_gpu_device_info_ GUARDED_BY(mu_) = false; std::unique_ptr gpu_device_info_ GUARDED_BY(mu_); + + // Thread pool used for running closures + std::unique_ptr thread_pool_; }; // Builds OpKernel registrations on 'device' for the JIT operators diff --git a/tensorflow/compiler/jit/xla_device_context.cc b/tensorflow/compiler/jit/xla_device_context.cc index 0100bf51ed..0a0c089241 100644 --- a/tensorflow/compiler/jit/xla_device_context.cc +++ b/tensorflow/compiler/jit/xla_device_context.cc @@ -15,6 +15,9 @@ limitations under the License. #include "tensorflow/compiler/jit/xla_device_context.h" +#include + +#include "tensorflow/compiler/jit/xla_device.h" #include "tensorflow/compiler/jit/xla_launch_util.h" #include "tensorflow/compiler/tf2xla/literal_util.h" #include "tensorflow/compiler/tf2xla/shape_util.h" @@ -48,17 +51,20 @@ void XlaDeviceAllocator::DeallocateRaw(void* ptr) { void XlaDeviceAllocator::GetStats(AllocatorStats* stats) { stats->Clear(); } XlaTransferManager::XlaTransferManager( - se::Stream* compute_stream, se::Stream* host_to_device_stream, - se::Stream* device_to_host_stream, xla::LocalClient* client, + std::shared_ptr compute_stream, + std::shared_ptr host_to_device_stream, + std::shared_ptr device_to_host_stream, xla::LocalClient* client, bool transfer_as_literal, - XlaCompiler::ShapeRepresentationFn shape_representation_fn) - : stream_(compute_stream), - host_to_device_stream_(host_to_device_stream), - device_to_host_stream_(device_to_host_stream), + XlaCompiler::ShapeRepresentationFn shape_representation_fn, + thread::ThreadPool* thread_pool) + : stream_(std::move(compute_stream)), + host_to_device_stream_(std::move(host_to_device_stream)), + device_to_host_stream_(std::move(device_to_host_stream)), client_(client), transfer_manager_(client->backend().transfer_manager()), transfer_as_literal_(transfer_as_literal), - shape_representation_fn_(std::move(shape_representation_fn)) { + shape_representation_fn_(std::move(shape_representation_fn)), + thread_pool_(thread_pool) { CHECK(host_to_device_stream_ != nullptr); CHECK(device_to_host_stream_ != nullptr); CHECK(stream_ != nullptr); @@ -88,15 +94,15 @@ Status XlaTransferManager::TransferLiteralToDevice( if (UseMultipleStreams()) { // Initially wait for the compute stream so that memory allocations are // synchronized. - host_to_device_stream_->ThenWaitFor(stream_); + host_to_device_stream_->ThenWaitFor(stream_.get()); } TF_RETURN_IF_ERROR(transfer_manager_->TransferLiteralToDeviceAsync( - host_to_device_stream_, *literal, shaped_buffer)); + host_to_device_stream_.get(), *literal, shaped_buffer)); if (UseMultipleStreams()) { - se::Event event(stream_->parent()); - TF_RET_CHECK(event.Init()) << "Event failed to initialize!"; - host_to_device_stream_->ThenRecordEvent(&event); - xla_tensor->SetDefinedOn(host_to_device_stream_, std::move(event)); + auto event = std::make_shared(stream_->parent()); + TF_RET_CHECK(event->Init()) << "Event failed to initialize!"; + host_to_device_stream_->ThenRecordEvent(event.get()); + xla_tensor->SetDefinedOn(host_to_device_stream_.get(), std::move(event)); } // Unref the host tensor, and capture the literal shared_ptr too so it goes // out of scope when the lambda completes. @@ -116,7 +122,7 @@ void XlaTransferManager::TransferLiteralFromDevice( TensorReference ref(device_tensor); transfer_manager_->TransferLiteralFromDevice( - device_to_host_stream_, shaped_buffer, literal, + device_to_host_stream_.get(), shaped_buffer, literal, [=, &shaped_buffer, &literal](xla::Status status) { ref.Unref(); done([&]() -> Status { @@ -179,8 +185,14 @@ void XlaTransferManager::CopyCPUTensorToDevice(const Tensor* cpu_tensor, status = TransferLiteralToDevice(reshaped_cpu_tensor, device_tensor); if (status.ok()) { xla_tensor->set_host_tensor(*cpu_tensor); - host_to_device_stream_->ThenDoHostCallback( - [done]() { done(Status::OK()); }); + host_to_device_stream_->ThenDoHostCallback([this, done]() { + // We must not call the done closure directly from DoHostCallback + // to avoid a deadlock. If done() is the callback that ends an + // Executor's run, the Executor may call XlaDevice::Sync() inside the + // callback. This deadlocks, because XlaDevice::Sync() waits for all + // stream activity to complete. + thread_pool_->Schedule([done]() { done(Status::OK()); }); + }); return; } } else { @@ -192,7 +204,7 @@ void XlaTransferManager::CopyCPUTensorToDevice(const Tensor* cpu_tensor, if (!block_status.ok()) { status = xla::InternalError( "Failed to complete data transfer on stream %p: %s", - host_to_device_stream_, block_status.error_message().c_str()); + host_to_device_stream_.get(), block_status.error_message().c_str()); } } xla_tensor->set_host_tensor(*cpu_tensor); @@ -225,9 +237,9 @@ void XlaTransferManager::CopyDeviceTensorToCPU(const Tensor* device_tensor, XlaTensor* xla_tensor = XlaTensor::FromTensor(device_tensor); if (se::Event* event = - xla_tensor->GetDefinitionEvent(device_to_host_stream_)) { + xla_tensor->GetDefinitionEvent(device_to_host_stream_.get())) { device_to_host_stream_->ThenWaitFor(event); - xla_tensor->SetDefinedOn(device_to_host_stream_); + xla_tensor->SetDefinedOn(device_to_host_stream_.get()); } Status status; @@ -240,7 +252,7 @@ void XlaTransferManager::CopyDeviceTensorToCPU(const Tensor* device_tensor, Status block_status = device_to_host_stream_->BlockHostUntilDone(); if (!block_status.ok()) { status = xla::InternalError( - "Failed to complete data transfer on stream %p: %s", stream_, + "Failed to complete data transfer on stream %p: %s", stream_.get(), block_status.error_message().c_str()); } } @@ -278,14 +290,14 @@ void XlaTransferManager::CopyDeviceTensorToDevice(const Tensor& src_tensor, if (stream_ != device_to_device_stream) { // Initially wait for the compute stream so that memory allocations are // synchronized. - device_to_device_stream->ThenWaitFor(stream_); + device_to_device_stream->ThenWaitFor(stream_.get()); } } if (se::Event* event = - xla_src->GetDefinitionEvent(device_to_device_stream)) { + xla_src->GetDefinitionEvent(device_to_device_stream.get())) { device_to_device_stream->ThenWaitFor(event); - xla_src->SetDefinedOn(device_to_device_stream); + xla_src->SetDefinedOn(device_to_device_stream.get()); } auto from_iter = xla_src->shaped_buffer().buffers().begin(); @@ -297,28 +309,37 @@ void XlaTransferManager::CopyDeviceTensorToDevice(const Tensor& src_tensor, } if (UseMultipleStreams()) { - se::Event event(stream_->parent()); - CHECK(event.Init()); - device_to_device_stream->ThenRecordEvent(&event); - xla_dst->SetDefinedOn(device_to_device_stream, std::move(event)); + auto event = std::make_shared(stream_->parent()); + TF_RET_CHECK(event->Init()) << "Event failed to initialize"; + device_to_device_stream->ThenRecordEvent(event.get()); + xla_dst->SetDefinedOn(device_to_device_stream.get(), std::move(event)); } return Status::OK(); }(); if (!status.ok()) { return done(status); } else { - stream_->ThenDoHostCallback([=]() { done(Status::OK()); }); + stream_->ThenDoHostCallback([this, done]() { + // We must not call the done closure directly from DoHostCallback to avoid + // a deadlock. If done() is the callback that ends an Executor's run, the + // Executor may call XlaDevice::Sync() inside the callback. This + // deadlocks, because XlaDevice::Sync() waits for all stream activity to + // complete. + thread_pool_->Schedule([done]() { done(Status::OK()); }); + }); } } XlaDeviceContext::XlaDeviceContext( - se::Stream* compute_stream, se::Stream* host_to_device_stream, - se::Stream* device_to_host_stream, xla::LocalClient* client, + std::shared_ptr compute_stream, + std::shared_ptr host_to_device_stream, + std::shared_ptr device_to_host_stream, xla::LocalClient* client, bool transfer_as_literal, - XlaCompiler::ShapeRepresentationFn shape_representation_fn) - : manager_(compute_stream, host_to_device_stream, device_to_host_stream, - client, transfer_as_literal, - std::move(shape_representation_fn)) {} + XlaCompiler::ShapeRepresentationFn shape_representation_fn, + thread::ThreadPool* thread_pool) + : manager_(std::move(compute_stream), std::move(host_to_device_stream), + std::move(device_to_host_stream), client, transfer_as_literal, + std::move(shape_representation_fn), thread_pool) {} void XlaDeviceContext::CopyCPUTensorToDevice(const Tensor* cpu_tensor, Device* device, diff --git a/tensorflow/compiler/jit/xla_device_context.h b/tensorflow/compiler/jit/xla_device_context.h index 912f8d779e..2e7445340c 100644 --- a/tensorflow/compiler/jit/xla_device_context.h +++ b/tensorflow/compiler/jit/xla_device_context.h @@ -47,10 +47,12 @@ class XlaDeviceAllocator : public Allocator { class XlaTransferManager { public: explicit XlaTransferManager( - se::Stream* compute_stream, se::Stream* host_to_device_stream, - se::Stream* device_to_host_stream, xla::LocalClient* client, - bool transfer_as_literal, - XlaCompiler::ShapeRepresentationFn shape_representation_fn); + std::shared_ptr compute_stream, + std::shared_ptr host_to_device_stream, + std::shared_ptr device_to_host_stream, + xla::LocalClient* client, bool transfer_as_literal, + XlaCompiler::ShapeRepresentationFn shape_representation_fn, + thread::ThreadPool* thread_pool); void CopyCPUTensorToDevice(const Tensor* cpu_tensor, Device* device, Tensor* device_tensor, StatusCallback done) const; @@ -61,7 +63,7 @@ class XlaTransferManager { void CopyDeviceTensorToDevice(const Tensor& src_tensor, Tensor* dst_tensor, const StatusCallback& done); - se::Stream* stream() const { return stream_; } + se::Stream* stream() const { return stream_.get(); } private: Status TransferLiteralToDevice(const Tensor& host_tensor, @@ -73,13 +75,13 @@ class XlaTransferManager { // The main compute stream of the device, used to synchronize the transfer // streams if they are set. - se::Stream* stream_; + std::shared_ptr stream_; // The stream to use for transferring data from host to device. Can be // idential to stream_, but must not be nullptr. - se::Stream* host_to_device_stream_; + std::shared_ptr host_to_device_stream_; // The stream to use for transferring data from device to host. Can be // idential to stream_, but must not be nullptr. - se::Stream* device_to_host_stream_; + std::shared_ptr device_to_host_stream_; // For the underlying memory allocator and XLA's TransferManager. xla::LocalClient* client_; // Transfer manager, for marshalling data to and from the device. @@ -87,6 +89,9 @@ class XlaTransferManager { // True if we must use XLA's TransferManager for correct device transfers. const bool transfer_as_literal_; XlaCompiler::ShapeRepresentationFn shape_representation_fn_; + + // Thread pool used for running closures + thread::ThreadPool* thread_pool_; }; // DeviceContext for operators assigned to XlaDevice devices. The @@ -95,10 +100,12 @@ class XlaTransferManager { class XlaDeviceContext : public DeviceContext { public: explicit XlaDeviceContext( - se::Stream* compute_stream, se::Stream* host_to_device_stream, - se::Stream* device_to_host_stream, xla::LocalClient* client, - bool transfer_as_literal, - XlaCompiler::ShapeRepresentationFn shape_representation_fn); + std::shared_ptr compute_stream, + std::shared_ptr host_to_device_stream, + std::shared_ptr device_to_host_stream, + xla::LocalClient* client, bool transfer_as_literal, + XlaCompiler::ShapeRepresentationFn shape_representation_fn, + thread::ThreadPool* thread_pool); void CopyCPUTensorToDevice(const Tensor* cpu_tensor, Device* device, Tensor* device_tensor, diff --git a/tensorflow/compiler/jit/xla_launch_util.cc b/tensorflow/compiler/jit/xla_launch_util.cc index 6134b8c694..4efbb2d5d7 100644 --- a/tensorflow/compiler/jit/xla_launch_util.cc +++ b/tensorflow/compiler/jit/xla_launch_util.cc @@ -15,6 +15,8 @@ limitations under the License. #include "tensorflow/compiler/jit/xla_launch_util.h" +#include + #include "tensorflow/compiler/jit/defs.h" #include "tensorflow/compiler/tf2xla/shape_util.h" #include "tensorflow/compiler/tf2xla/xla_compiler.h" @@ -182,7 +184,7 @@ void XlaComputationLaunchContext::PopulateInputs( } } -void XlaComputationLaunchContext::PopulateOutputs( +Status XlaComputationLaunchContext::PopulateOutputs( OpKernelContext* ctx, const XlaCompiler::CompilationResult* kernel, ScopedShapedBuffer output) { se::Stream* stream = @@ -211,6 +213,15 @@ void XlaComputationLaunchContext::PopulateOutputs( output = ScopedShapedBuffer(std::move(buffer), output.memory_allocator()); } + std::shared_ptr definition_event; + if (use_multiple_streams_) { + definition_event = std::make_shared(stream->parent()); + if (!definition_event->Init()) { + return errors::Internal("Failed to initialize tensor definition event."); + } + stream->ThenRecordEvent(definition_event.get()); + } + // Copy XLA results to the OpOutputList. int output_num = 0; for (int i = 0; i < ctx->num_outputs(); ++i) { @@ -228,12 +239,13 @@ void XlaComputationLaunchContext::PopulateOutputs( // reallocate the device buffer later. VLOG(1) << "Constant output tensor on device"; - OP_REQUIRES_OK( - ctx, ctx->allocate_output(i, const_tensor.shape(), &output_tensor)); + TF_RETURN_IF_ERROR( + ctx->allocate_output(i, const_tensor.shape(), &output_tensor)); Device* device = dynamic_cast(ctx->device()); - OP_REQUIRES(ctx, device != nullptr, - errors::Internal("DeviceBase was not a Device.")); + if (device == nullptr) { + return errors::Internal("DeviceBase was not a Device."); + } ctx->op_device_context()->CopyCPUTensorToDevice( &const_tensor, device, output_tensor, [&](Status status) { TF_CHECK_OK(status); }); @@ -263,16 +275,13 @@ void XlaComputationLaunchContext::PopulateOutputs( se::DeviceMemoryBase buffer = output.buffer({output_num}); if (allocate_xla_tensors_) { Tensor* output_tensor; - OP_REQUIRES_OK(ctx, ctx->allocate_output(i, shape, &output_tensor)); + TF_RETURN_IF_ERROR(ctx->allocate_output(i, shape, &output_tensor)); XlaTensor* xla_tensor = XlaTensor::FromTensor(output_tensor); if (xla_tensor) { xla_tensor->set_shaped_buffer(ScopedShapedBuffer( ExtractSubShapedBuffer(&output, output_num, xla_allocator_))); if (use_multiple_streams_) { - se::Event event(stream->parent()); - CHECK(event.Init()); - stream->ThenRecordEvent(&event); - xla_tensor->SetDefinedOn(stream, std::move(event)); + xla_tensor->SetDefinedOn(stream, definition_event); } } else { // xla_tensor wasn't valid, which must mean this is a zero-element @@ -298,41 +307,39 @@ void XlaComputationLaunchContext::PopulateOutputs( for (int i = 0; i < kernel->resource_updates.size(); ++i) { Allocator* allocator = ctx->device()->GetAllocator({}); const XlaCompiler::ResourceUpdate& write = kernel->resource_updates[i]; - OP_REQUIRES(ctx, - write.input_index >= 0 && write.input_index < ctx->num_inputs(), - errors::Internal("Invalid input index for variable write.")); + if (write.input_index < 0 || write.input_index >= ctx->num_inputs()) { + return errors::Internal("Invalid input index for variable write."); + } se::DeviceMemoryBase buffer = output.buffer({output_num}); Var* variable = nullptr; // TODO(b/35625933): tensorflow::Var should contain a PersistentTensor, // not a Tensor. - OP_REQUIRES_OK(ctx, LookupOrCreateResource( - ctx, HandleFromInput(ctx, write.input_index), - &variable, [this, ctx, &write](Var** ptr) { - *ptr = new Var(write.type); - return Status::OK(); - })); + TF_RETURN_IF_ERROR(LookupOrCreateResource( + ctx, HandleFromInput(ctx, write.input_index), &variable, + [&write](Var** ptr) { + *ptr = new Var(write.type); + return Status::OK(); + })); core::ScopedUnref s(variable); mutex_lock ml(*variable->mu()); - OP_REQUIRES(ctx, variable->tensor()->dtype() == write.type, - errors::Internal("Mismatched type in variable write")); + if (variable->tensor()->dtype() != write.type) { + return errors::Internal("Mismatched type in variable write"); + } if (allocate_xla_tensors_) { Tensor output_tensor; - OP_REQUIRES_OK( - ctx, ctx->allocate_temp(write.type, write.shape, &output_tensor)); + TF_RETURN_IF_ERROR( + ctx->allocate_temp(write.type, write.shape, &output_tensor)); XlaTensor* xla_tensor = XlaTensor::FromTensor(&output_tensor); CHECK(xla_tensor); xla_tensor->set_shaped_buffer( ExtractSubShapedBuffer(&output, output_num, xla_allocator_)); if (use_multiple_streams_) { - se::Event event(stream->parent()); - CHECK(event.Init()); - stream->ThenRecordEvent(&event); - xla_tensor->SetDefinedOn(stream, std::move(event)); + xla_tensor->SetDefinedOn(stream, definition_event); } *variable->tensor() = output_tensor; } else { @@ -343,6 +350,7 @@ void XlaComputationLaunchContext::PopulateOutputs( } ++output_num; } + return Status::OK(); } } // namespace tensorflow diff --git a/tensorflow/compiler/jit/xla_launch_util.h b/tensorflow/compiler/jit/xla_launch_util.h index 1ea3fa4cf2..4232f514b3 100644 --- a/tensorflow/compiler/jit/xla_launch_util.h +++ b/tensorflow/compiler/jit/xla_launch_util.h @@ -93,9 +93,9 @@ class XlaComputationLaunchContext { const std::map& variables); // Given the XLA output in `output`, populate all outputs of `ctx`. - void PopulateOutputs(OpKernelContext* ctx, - const XlaCompiler::CompilationResult* kernel, - xla::ScopedShapedBuffer output); + Status PopulateOutputs(OpKernelContext* ctx, + const XlaCompiler::CompilationResult* kernel, + xla::ScopedShapedBuffer output); // Return the argument list. Only valid after PopulateInputs() has been // called. diff --git a/tensorflow/compiler/jit/xla_tensor.cc b/tensorflow/compiler/jit/xla_tensor.cc index d777dfa5a3..92ba7de1b7 100644 --- a/tensorflow/compiler/jit/xla_tensor.cc +++ b/tensorflow/compiler/jit/xla_tensor.cc @@ -75,7 +75,7 @@ Status XlaTensor::AllocateShapedBuffer(DataType dtype, const TensorShape& shape, se::Event* XlaTensor::GetDefinitionEvent(se::Stream* stream) { mutex_lock lock(mu_); - if (!definition_event_.has_value()) { + if (!definition_event_) { return nullptr; } @@ -87,10 +87,11 @@ se::Event* XlaTensor::GetDefinitionEvent(se::Stream* stream) { return nullptr; } - return &*definition_event_; + return definition_event_.get(); } -void XlaTensor::SetDefinedOn(se::Stream* stream, se::Event event) { +void XlaTensor::SetDefinedOn(se::Stream* stream, + std::shared_ptr event) { mutex_lock lock(mu_); definition_event_ = std::move(event); streams_defined_on_ = {stream}; diff --git a/tensorflow/compiler/jit/xla_tensor.h b/tensorflow/compiler/jit/xla_tensor.h index f7e401c731..8d36d0fa0a 100644 --- a/tensorflow/compiler/jit/xla_tensor.h +++ b/tensorflow/compiler/jit/xla_tensor.h @@ -16,6 +16,8 @@ limitations under the License. #ifndef TENSORFLOW_COMPILER_JIT_XLA_TENSOR_H_ #define TENSORFLOW_COMPILER_JIT_XLA_TENSOR_H_ +#include + #include "tensorflow/compiler/xla/client/local_client.h" #include "tensorflow/compiler/xla/service/shaped_buffer.h" #include "tensorflow/core/framework/allocator.h" @@ -94,7 +96,7 @@ class XlaTensor { // Assert that the tensor's content is defined on 'stream' by the time 'event' // triggers. - void SetDefinedOn(se::Stream* stream, se::Event event); + void SetDefinedOn(se::Stream* stream, std::shared_ptr event); // Assert that the tensor's content is defined on 'stream'. This version does // not provide an event, and must be called *after* SetDefinedOn(Stream, @@ -116,7 +118,7 @@ class XlaTensor { // An optional event that is triggered when the tensor's content has been // defined. If this event is nullptr, it is assumed that the tensor's content // is always defined. - gtl::optional definition_event_; + std::shared_ptr definition_event_; // A list of all streams for which the tensor's content is defined for any // newly enqueued command. gtl::InlinedVector streams_defined_on_ GUARDED_BY(mu_); diff --git a/tensorflow/compiler/xla/service/interpreter/executor.h b/tensorflow/compiler/xla/service/interpreter/executor.h index 9b109022fb..db6b910b32 100644 --- a/tensorflow/compiler/xla/service/interpreter/executor.h +++ b/tensorflow/compiler/xla/service/interpreter/executor.h @@ -104,7 +104,7 @@ class XlaInterpreterExecutor : public internal::StreamExecutorInterface { } // No "synchronize all activity" implemented for this platform at the moment. - bool SynchronizeAllActivity() override { return false; } + bool SynchronizeAllActivity() override { return true; } bool SynchronousMemZero(DeviceMemoryBase *location, uint64 size) override { return false; } diff --git a/tensorflow/stream_executor/host/host_gpu_executor.h b/tensorflow/stream_executor/host/host_gpu_executor.h index 858396ef96..7ba1f18101 100644 --- a/tensorflow/stream_executor/host/host_gpu_executor.h +++ b/tensorflow/stream_executor/host/host_gpu_executor.h @@ -88,7 +88,7 @@ class HostExecutor : public internal::StreamExecutorInterface { uint64 size) override; // No "synchronize all activity" implemented for this platform at the moment. - bool SynchronizeAllActivity() override { return false; } + bool SynchronizeAllActivity() override { return true; } bool SynchronousMemZero(DeviceMemoryBase *location, uint64 size) override; bool SynchronousMemSet(DeviceMemoryBase *location, int value, -- GitLab From dfa844ac95d07ce9584fc841a931aad65d3b4ac8 Mon Sep 17 00:00:00 2001 From: Patrick Nguyen Date: Mon, 13 Aug 2018 10:57:40 -0700 Subject: [PATCH 412/437] Reduce output on pbtxt parse error. PiperOrigin-RevId: 208507857 --- tensorflow/core/api_def/api_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow/core/api_def/api_test.cc b/tensorflow/core/api_def/api_test.cc index ae03a61ae6..51812caeb2 100644 --- a/tensorflow/core/api_def/api_test.cc +++ b/tensorflow/core/api_def/api_test.cc @@ -59,8 +59,8 @@ void GetGoldenApiDefs(Env* env, const string& api_files_dir, file_contents = PBTxtFromMultiline(file_contents); ApiDefs api_defs; - CHECK(tensorflow::protobuf::TextFormat::ParseFromString(file_contents, - &api_defs)) + QCHECK(tensorflow::protobuf::TextFormat::ParseFromString(file_contents, + &api_defs)) << "Failed to load " << file_path; CHECK_EQ(api_defs.op_size(), 1); (*name_to_api_def)[api_defs.op(0).graph_op_name()] = api_defs.op(0); -- GitLab From a51400d1b33f3521221cd0f9f8dc0f8c036f347d Mon Sep 17 00:00:00 2001 From: Tim Shen Date: Mon, 13 Aug 2018 10:59:17 -0700 Subject: [PATCH 413/437] Destroy the task before unblocking its waiters. PiperOrigin-RevId: 208508212 --- .../stream_executor/host/host_stream.cc | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/tensorflow/stream_executor/host/host_stream.cc b/tensorflow/stream_executor/host/host_stream.cc index 5a7d3b3dd4..bfbfb56cd7 100644 --- a/tensorflow/stream_executor/host/host_stream.cc +++ b/tensorflow/stream_executor/host/host_stream.cc @@ -28,18 +28,28 @@ HostStream::HostStream() HostStream::~HostStream() {} bool HostStream::EnqueueTask(std::function task) { + struct NotifiedTask { + HostStream* stream; + std::function task; + + void operator()() { + task(); + // Destroy the task before unblocking its waiters, as BlockHostUntilDone() + // should guarantee that all tasks are destroyed. + task = std::function(); + { + mutex_lock lock(stream->mu_); + --stream->pending_tasks_; + } + stream->completion_condition_.notify_all(); + } + }; + { mutex_lock lock(mu_); ++pending_tasks_; } - host_executor_->Schedule([this, task]() { - task(); - { - mutex_lock lock(mu_); - --pending_tasks_; - } - completion_condition_.notify_all(); - }); + host_executor_->Schedule(NotifiedTask{this, std::move(task)}); return true; } -- GitLab From 79f19120cd4dd30d7e99b4db4659a3904f973761 Mon Sep 17 00:00:00 2001 From: Mark Heffernan Date: Mon, 13 Aug 2018 11:03:55 -0700 Subject: [PATCH 414/437] Elide copies for which the source and destination buffer is the same. During copy elision, copies which were previously added during copy insertion might end up with the same source and destination buffer. Previous logic did not remove them. This CL handles this corner case. PiperOrigin-RevId: 208509171 --- .../compiler/xla/service/copy_insertion.cc | 9 +++- .../xla/service/copy_insertion_test.cc | 41 +++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/tensorflow/compiler/xla/service/copy_insertion.cc b/tensorflow/compiler/xla/service/copy_insertion.cc index 36fb9b43aa..3e39c1bab1 100644 --- a/tensorflow/compiler/xla/service/copy_insertion.cc +++ b/tensorflow/compiler/xla/service/copy_insertion.cc @@ -312,7 +312,7 @@ Status AddCopiesForWhile(const HloAliasAnalysis& alias_analysis, return Status::OK(); } -// We add copies for all the indices of the true and false computaiton roots, +// We add copies for all the indices of the true and false computation roots, // in order to resolve interference. We later rely on the CopyRemover to drop // the unnecessary ones. Status AddCopiesForConditional(const HloAliasAnalysis& alias_analysis, @@ -648,7 +648,12 @@ class CopyRemover { // We can only perform copy elision if the resulting merged values have // totally ordered live ranges; otherwise the merged buffer would have // live range interference. - if (IsHead(*dest)) { + if (src->next == dest) { + // In the process of eliding copies, its possible for a copy to have the + // same source and destination buffer. In this case, the copy can be + // safely removed. + VLOG(2) << copy->name() << " source and destination buffers are same."; + } else if (IsHead(*dest)) { // The copy copies an arbitrary value in the source buffer (call it s_x) // and defines d_0, the first value in the destination buffer. After // merging, the values in the combined buffer must be strictly ordered diff --git a/tensorflow/compiler/xla/service/copy_insertion_test.cc b/tensorflow/compiler/xla/service/copy_insertion_test.cc index cd735256b8..892d0d7b54 100644 --- a/tensorflow/compiler/xla/service/copy_insertion_test.cc +++ b/tensorflow/compiler/xla/service/copy_insertion_test.cc @@ -2007,5 +2007,46 @@ ENTRY TestComputation { InsertCopies(module.get()); } +TEST_F(CopyInsertionTest, NestedWhiles) { + // Verify that only no unnecessary copies remain after copy insertion for + // trivial nested whiles (b/112472605). + const string& hlo_string = R"( +HloModule TestModule + +cond.inner { + ROOT param.cond.inner = pred[] parameter(0) +} + +body.inner { + param.body.inner = pred[] parameter(0) + ROOT neg = pred[] negate(param.body.inner) +} + +cond.outer { + ROOT param.cond.outer = pred[] parameter(0) +} + +body.outer { + param.cond.outer = pred[] parameter(0) + ROOT while = pred[] while(param.cond.outer), condition=cond.inner, body=body.inner +} + +ENTRY TestComputation { + entry_param = pred[] parameter(0) + ROOT while = pred[] while(entry_param), condition=cond.outer, body=body.outer +} +)"; + TF_ASSERT_OK_AND_ASSIGN( + std::unique_ptr module, + HloRunner::CreateModuleFromString(hlo_string, GetDebugOptionsForTest())); + InsertCopies(module.get()); + + // There should only be a single copy inserted, and it's in the entry + // computation. + EXPECT_EQ(CountCopies(*module), 1); + EXPECT_THAT(module->entry_computation()->root_instruction(), + op::While(op::Copy(op::Parameter()))); +} + } // namespace } // namespace xla -- GitLab From b4af892e0e037925c4376c7d40623d3635969f06 Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Mon, 13 Aug 2018 11:15:22 -0700 Subject: [PATCH 415/437] [XLA:GPU] Force-enable two math transformations that previously were only on with fastmath. - pow(x, -.5) => 1/sqrt(x) - tanh(x) => fast llvm-ir implementation, instead of __nv_tanh from libdevice. Both of these should be safe. The main thing we're concerned about when fastmath is disabled is getting proper NaN/Inf behavior, and these changes don't affect that. PiperOrigin-RevId: 208511562 --- .../xla/service/gpu/elemental_ir_emitter.cc | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/tensorflow/compiler/xla/service/gpu/elemental_ir_emitter.cc b/tensorflow/compiler/xla/service/gpu/elemental_ir_emitter.cc index 5233cd0255..9b6de115ad 100644 --- a/tensorflow/compiler/xla/service/gpu/elemental_ir_emitter.cc +++ b/tensorflow/compiler/xla/service/gpu/elemental_ir_emitter.cc @@ -210,8 +210,7 @@ StatusOr GpuElementalIrEmitter::EmitPowerOp( return make_sqrt(); } - if (hlo_module_config_.debug_options().xla_gpu_enable_fast_math() && - IsFPLiteralWithValue(rhs, -.5)) { + if (IsFPLiteralWithValue(rhs, -.5)) { VLOG(10) << "emitting pow(A, -.5) as 1/sqrt(A): " << op->ToString(); // LLVM's NVPTX backend knows how to transform 1/sqrt(A) into the NVPTX // rsqrt.approx instruction. @@ -277,16 +276,18 @@ StatusOr GpuElementalIrEmitter::EmitAtan2( StatusOr GpuElementalIrEmitter::EmitTanh( PrimitiveType prim_type, llvm::Value* value) const { - // If we don't care much about precision, emit a fast approximation of - // tanh. - if (hlo_module_config_.debug_options().xla_gpu_enable_fast_math()) { - // Upcast F16 to F32 if necessary. - llvm::Type* type = prim_type == F16 ? b_->getFloatTy() : value->getType(); - llvm::Value* input = b_->CreateFPCast(value, type); - llvm::Value* fast_tanh = llvm_ir::EmitFastTanh(b_, input); - return b_->CreateFPCast(fast_tanh, value->getType()); - } - return EmitLibdeviceMathCall("__nv_tanh", {value}, {prim_type}, prim_type); + // Emit a fast approximation of tanh instead of calling __nv_tanh. + // __nv_tanh is particularly bad because it contains branches, thus + // preventing LLVM's load-store vectorizer from working its magic across a + // function which contains tanh calls. + // + // This routine isn't numerically precise, but it's good enough for ML. + + // Upcast F16 to F32 if necessary. + llvm::Type* type = prim_type == F16 ? b_->getFloatTy() : value->getType(); + llvm::Value* input = b_->CreateFPCast(value, type); + llvm::Value* fast_tanh = llvm_ir::EmitFastTanh(b_, input); + return b_->CreateFPCast(fast_tanh, value->getType()); } llvm::Value* GpuElementalIrEmitter::EmitDeviceFunctionCall( -- GitLab From 28f5f7b58c15c33f90c639c46115b1d6581a7408 Mon Sep 17 00:00:00 2001 From: Wesley Qian Date: Mon, 13 Aug 2018 11:26:08 -0700 Subject: [PATCH 416/437] Add stargan image summaries to show result of transforming image to each domain. PiperOrigin-RevId: 208513708 --- tensorflow/contrib/gan/BUILD | 2 + .../gan/python/eval/python/summaries_impl.py | 91 +++++++++++++++++++ .../gan/python/eval/python/summaries_test.py | 40 +++++++- 3 files changed, 132 insertions(+), 1 deletion(-) diff --git a/tensorflow/contrib/gan/BUILD b/tensorflow/contrib/gan/BUILD index 82e3bbe3c0..9866fccfba 100644 --- a/tensorflow/contrib/gan/BUILD +++ b/tensorflow/contrib/gan/BUILD @@ -424,9 +424,11 @@ py_library( ":namedtuples", "//tensorflow/python:array_ops", "//tensorflow/python:framework_ops", + "//tensorflow/python:functional_ops", "//tensorflow/python:math_ops", "//tensorflow/python:summary", "//tensorflow/python:util", + "//tensorflow/python:variable_scope", "//tensorflow/python/ops/losses", ], ) diff --git a/tensorflow/contrib/gan/python/eval/python/summaries_impl.py b/tensorflow/contrib/gan/python/eval/python/summaries_impl.py index 508f487722..f9995bb19d 100644 --- a/tensorflow/contrib/gan/python/eval/python/summaries_impl.py +++ b/tensorflow/contrib/gan/python/eval/python/summaries_impl.py @@ -22,7 +22,9 @@ from tensorflow.contrib.gan.python import namedtuples from tensorflow.contrib.gan.python.eval.python import eval_utils from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops +from tensorflow.python.ops import functional_ops from tensorflow.python.ops import math_ops +from tensorflow.python.ops import variable_scope from tensorflow.python.ops.losses import util as loss_util from tensorflow.python.summary import summary @@ -32,6 +34,7 @@ __all__ = [ 'add_gan_model_summaries', 'add_regularization_loss_summaries', 'add_cyclegan_image_summaries', + 'add_stargan_image_summaries' ] @@ -179,6 +182,94 @@ def add_image_comparison_summaries(gan_model, num_comparisons=2, max_outputs=1) +def add_stargan_image_summaries(stargan_model, + num_images=2, + display_diffs=False): + """Adds image summaries to see StarGAN image results. + + If display_diffs is True, each image result has `2` rows and `num_domains + 1` + columns. + The first row looks like: + [original_image, transformed_to_domain_0, transformed_to_domain_1, ...] + The second row looks like: + [no_modification_baseline, transformed_to_domain_0-original_image, ...] + If display_diffs is False, only the first row is shown. + + IMPORTANT: + Since the model originally does not transformed the image to every domains, + we will transform them on-the-fly within this function in parallel. + + Args: + stargan_model: A StarGANModel tuple. + num_images: The number of examples/images to be transformed and shown. + display_diffs: Also display the difference between generated and target. + + Raises: + ValueError: If input_data is not images. + ValueError: If input_data_domain_label is not rank 2. + ValueError: If dimension 2 of input_data_domain_label is not fully defined. + """ + + _assert_is_image(stargan_model.input_data) + stargan_model.input_data_domain_label.shape.assert_has_rank(2) + stargan_model.input_data_domain_label.shape[1:].assert_is_fully_defined() + + num_domains = stargan_model.input_data_domain_label.get_shape().as_list()[-1] + + def _build_image(image): + """Helper function to create a result for each image on the fly.""" + + # Expand the first dimension as batch_size = 1. + images = array_ops.expand_dims(image, axis=0) + + # Tile the image num_domains times, so we can get all transformed together. + images = array_ops.tile(images, [num_domains, 1, 1, 1]) + + # Create the targets to 0, 1, 2, ..., num_domains-1. + targets = array_ops.one_hot(list(range(num_domains)), num_domains) + + with variable_scope.variable_scope( + stargan_model.generator_scope, reuse=True): + + # Add the original image. + output_images_list = [image] + + # Generate the image and add to the list. + gen_images = stargan_model.generator_fn(images, targets) + gen_images_list = array_ops.split(gen_images, num_domains) + gen_images_list = [ + array_ops.squeeze(img, axis=0) for img in gen_images_list + ] + output_images_list.extend(gen_images_list) + + # Display diffs. + if display_diffs: + diff_images = gen_images - images + diff_images_list = array_ops.split(diff_images, num_domains) + diff_images_list = [ + array_ops.squeeze(img, axis=0) for img in diff_images_list + ] + output_images_list.append(array_ops.zeros_like(image)) + output_images_list.extend(diff_images_list) + + # Create the final image. + final_image = eval_utils.image_reshaper( + output_images_list, num_cols=num_domains + 1) + + # Reduce the first rank. + return array_ops.squeeze(final_image, axis=0) + + summary.image( + 'stargan_image_generation', + functional_ops.map_fn( + _build_image, + stargan_model.input_data[:num_images], + parallel_iterations=num_images, + back_prop=False, + swap_memory=True), + max_outputs=num_images) + + def add_gan_model_summaries(gan_model): """Adds typical GANModel summaries. diff --git a/tensorflow/contrib/gan/python/eval/python/summaries_test.py b/tensorflow/contrib/gan/python/eval/python/summaries_test.py index 33d51bfc21..54a6f8d4d9 100644 --- a/tensorflow/contrib/gan/python/eval/python/summaries_test.py +++ b/tensorflow/contrib/gan/python/eval/python/summaries_test.py @@ -18,7 +18,6 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function - from tensorflow.contrib.gan.python import namedtuples from tensorflow.contrib.gan.python.eval.python import summaries_impl as summaries from tensorflow.python.framework import ops @@ -37,6 +36,10 @@ def discriminator_model(inputs, _): return variable_scope.get_variable('dummy_d', initializer=2.0) * inputs +def stargan_generator_model(inputs, _): + return generator_model(inputs) + + def get_gan_model(): # TODO(joelshor): Find a better way of creating a variable scope. with variable_scope.variable_scope('generator') as gen_scope: @@ -57,6 +60,31 @@ def get_gan_model(): discriminator_fn=discriminator_model) +def get_stargan_model(): + """Similar to get_gan_model().""" + # TODO(joelshor): Find a better way of creating a variable scope. + with variable_scope.variable_scope('discriminator') as dis_scope: + pass + with variable_scope.variable_scope('generator') as gen_scope: + return namedtuples.StarGANModel( + input_data=array_ops.ones([1, 2, 2, 3]), + input_data_domain_label=array_ops.ones([1, 2]), + generated_data=stargan_generator_model( + array_ops.ones([1, 2, 2, 3]), None), + generated_data_domain_target=array_ops.ones([1, 2]), + reconstructed_data=array_ops.ones([1, 2, 2, 3]), + discriminator_input_data_source_predication=array_ops.ones([1]), + discriminator_generated_data_source_predication=array_ops.ones([1]), + discriminator_input_data_domain_predication=array_ops.ones([1, 2]), + discriminator_generated_data_domain_predication=array_ops.ones([1, 2]), + generator_variables=None, + generator_scope=gen_scope, + generator_fn=stargan_generator_model, + discriminator_variables=None, + discriminator_scope=dis_scope, + discriminator_fn=discriminator_model) + + def get_cyclegan_model(): with variable_scope.variable_scope('x2y'): model_x2y = get_gan_model() @@ -143,6 +171,16 @@ class SummariesTest(test.TestCase): with self.test_session(use_gpu=True): summary.merge_all().eval() + def test_add_image_comparison_summaries_for_stargan(self): + + summaries.add_stargan_image_summaries(get_stargan_model()) + + self.assertEquals(1, len(ops.get_collection(ops.GraphKeys.SUMMARIES))) + + with self.test_session(use_gpu=True) as sess: + sess.run(variables.global_variables_initializer()) + summary.merge_all().eval() + if __name__ == '__main__': test.main() -- GitLab From 2942555be63f2dbf557cdf7be2bcbd5d4e9d0daf Mon Sep 17 00:00:00 2001 From: Anna R Date: Mon, 13 Aug 2018 11:31:17 -0700 Subject: [PATCH 417/437] Automated rollback of commit 3021cfae28bc7ae46fd903398f25bb4f0fa4e317. PiperOrigin-RevId: 208514584 --- tensorflow/contrib/makefile/download_dependencies.sh | 4 +++- tensorflow/workspace.bzl | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tensorflow/contrib/makefile/download_dependencies.sh b/tensorflow/contrib/makefile/download_dependencies.sh index 448ae6d22e..dc9b17a627 100755 --- a/tensorflow/contrib/makefile/download_dependencies.sh +++ b/tensorflow/contrib/makefile/download_dependencies.sh @@ -35,7 +35,9 @@ NSYNC_URL="$(grep -o 'https://mirror.bazel.build/github.com/google/nsync/.*tar\. # process. For now we're hardcoding to the version which is used by # TensorFlow 1.9. PROTOBUF_URL="https://mirror.bazel.build/github.com/google/protobuf/archive/396336eb961b75f03b25824fe86cf6490fb75e3a.tar.gz" -RE2_URL="$(grep -o 'https://mirror.bazel.build/github.com/google/re2/.*tar\.gz' "${BZL_FILE_PATH}" | head -n1)" +# TODO (yongtang): Replace the following with 'https://mirror.bazel.build/github.com/google/re2/.*tar\.gz' once +# the archive has been propagated in mirror.bazel.build. +RE2_URL="$(grep -o 'https://github.com/google/re2/.*tar\.gz' "${BZL_FILE_PATH}" | head -n1)" FFT2D_URL="$(grep -o 'http.*fft\.tgz' "${BZL_FILE_PATH}" | grep -v bazel-mirror | head -n1)" DOUBLE_CONVERSION_URL="$(grep -o "https.*google/double-conversion.*\.zip" "${BZL_FILE_PATH}" | head -n1)" ABSL_URL="$(grep -o 'https://github.com/abseil/abseil-cpp/.*tar.gz' "${BZL_FILE_PATH}" | head -n1)" diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl index c21e5ebc9e..217910c04f 100644 --- a/tensorflow/workspace.bzl +++ b/tensorflow/workspace.bzl @@ -157,11 +157,11 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""): tf_http_archive( name = "com_googlesource_code_re2", urls = [ - "https://mirror.bazel.build/github.com/google/re2/archive/2018-04-01.tar.gz", - "https://github.com/google/re2/archive/2018-04-01.tar.gz", + "https://mirror.bazel.build/github.com/google/re2/archive/2018-07-01.tar.gz", + "https://github.com/google/re2/archive/2018-07-01.tar.gz", ], - sha256 = "2f945446b71336e7f5a2bcace1abcf0b23fbba368266c6a1be33de3de3b3c912", - strip_prefix = "re2-2018-04-01", + sha256 = "803c7811146edeef8f91064de37c6f19136ff01a2a8cdb3230e940b2fd9f07fe", + strip_prefix = "re2-2018-07-01", system_build_file = clean_dep("//third_party/systemlibs:re2.BUILD"), ) -- GitLab From 54f3661a5f19cdae186abee7547c5edd93a0a122 Mon Sep 17 00:00:00 2001 From: Akshay Agrawal Date: Mon, 13 Aug 2018 11:44:03 -0700 Subject: [PATCH 418/437] Eliminate data race in ResourceVariable AssignVariableOp. Fixes a potential data race in which the tensor backing a variable can be read by one thread while another thread is writing to it. PiperOrigin-RevId: 208516878 --- tensorflow/core/kernels/resource_variable_ops.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tensorflow/core/kernels/resource_variable_ops.cc b/tensorflow/core/kernels/resource_variable_ops.cc index 115a8eb251..ebcfb673d1 100644 --- a/tensorflow/core/kernels/resource_variable_ops.cc +++ b/tensorflow/core/kernels/resource_variable_ops.cc @@ -232,12 +232,12 @@ class AssignVariableOp : public OpKernel { return Status::OK(); })); core::ScopedUnref s(variable); + mutex_lock ml(*variable->mu()); OP_REQUIRES(context, variable->tensor()->dtype() == dtype_, errors::InvalidArgument( "Trying to assign variable with wrong dtype. Expected ", DataTypeString(variable->tensor()->dtype()), " got ", DataTypeString(dtype_))); - mutex_lock ml(*variable->mu()); variable->is_initialized = true; *variable->tensor() = value; } @@ -268,11 +268,6 @@ class AssignVariableOp : public OpKernel { return Status::OK(); })); core::ScopedUnref s(variable); - OP_REQUIRES(context, variable->tensor()->dtype() == DT_VARIANT, - errors::InvalidArgument( - "Trying to assign variable with wrong dtype. Expected ", - DataTypeString(variable->tensor()->dtype()), " got ", - DataTypeString(DT_VARIANT))); // For purposes of forwarding DT_VARIANT, we want the least // restrictive attr; we already know the input is on host. @@ -293,6 +288,11 @@ class AssignVariableOp : public OpKernel { attr); mutex_lock ml(*variable->mu()); + OP_REQUIRES(context, variable->tensor()->dtype() == DT_VARIANT, + errors::InvalidArgument( + "Trying to assign variable with wrong dtype. Expected ", + DataTypeString(variable->tensor()->dtype()), " got ", + DataTypeString(DT_VARIANT))); variable->is_initialized = true; *variable->tensor() = Tensor(DT_VARIANT, value.shape()); -- GitLab From 1e2566f029ec24ab1208a9d65c6295b0ce499940 Mon Sep 17 00:00:00 2001 From: Francois Chollet Date: Mon, 13 Aug 2018 11:45:12 -0700 Subject: [PATCH 419/437] Replace applications tests with lighter integration test. Also remove MobileNetV2 due to a compatibility issue (will be re-enabled in the next version). PiperOrigin-RevId: 208517089 --- tensorflow/python/keras/BUILD | 116 +----------------- .../python/keras/applications/__init__.py | 2 +- .../keras/applications/applications_test.py | 58 +++++++++ .../keras/applications/densenet_test.py | 101 --------------- .../keras/applications/imagenet_utils_test.py | 93 -------------- .../applications/inception_resnet_v2_test.py | 59 --------- .../keras/applications/inception_v3_test.py | 58 --------- .../keras/applications/mobilenet_test.py | 71 ----------- .../python/keras/applications/mobilenet_v2.py | 12 +- .../python/keras/applications/nasnet_test.py | 76 ------------ .../keras/applications/resnet50_test.py | 51 -------- .../python/keras/applications/vgg16_test.py | 50 -------- .../python/keras/applications/vgg19_test.py | 50 -------- .../keras/applications/xception_test.py | 57 --------- .../tools/api/generator/api_init_files.bzl | 1 - .../tools/api/generator/api_init_files_v1.bzl | 1 - 16 files changed, 65 insertions(+), 791 deletions(-) create mode 100644 tensorflow/python/keras/applications/applications_test.py delete mode 100644 tensorflow/python/keras/applications/densenet_test.py delete mode 100644 tensorflow/python/keras/applications/imagenet_utils_test.py delete mode 100644 tensorflow/python/keras/applications/inception_resnet_v2_test.py delete mode 100644 tensorflow/python/keras/applications/inception_v3_test.py delete mode 100644 tensorflow/python/keras/applications/mobilenet_test.py delete mode 100644 tensorflow/python/keras/applications/nasnet_test.py delete mode 100644 tensorflow/python/keras/applications/resnet50_test.py delete mode 100644 tensorflow/python/keras/applications/vgg16_test.py delete mode 100644 tensorflow/python/keras/applications/vgg19_test.py delete mode 100644 tensorflow/python/keras/applications/xception_test.py diff --git a/tensorflow/python/keras/BUILD b/tensorflow/python/keras/BUILD index e04d0e93e2..7eb7884d1d 100755 --- a/tensorflow/python/keras/BUILD +++ b/tensorflow/python/keras/BUILD @@ -296,109 +296,15 @@ py_test( ) py_test( - name = "densenet_test", - size = "large", - srcs = ["applications/densenet_test.py"], - srcs_version = "PY2AND3", - tags = ["nomsan"], # times out, http://b/78650237 - deps = [ - ":keras", - "//tensorflow/python:client_testlib", - "//third_party/py/numpy", - ], -) - -py_test( - name = "inception_resnet_v2_test", - size = "medium", - srcs = ["applications/inception_resnet_v2_test.py"], - srcs_version = "PY2AND3", - deps = [ - ":keras", - "//tensorflow/python:client_testlib", - "//third_party/py/numpy", - ], -) - -py_test( - name = "inception_v3_test", - size = "medium", - srcs = ["applications/inception_v3_test.py"], - srcs_version = "PY2AND3", - deps = [ - ":keras", - "//tensorflow/python:client_testlib", - "//third_party/py/numpy", - ], -) - -py_test( - name = "mobilenet_test", - size = "medium", - srcs = ["applications/mobilenet_test.py"], - srcs_version = "PY2AND3", - deps = [ - ":keras", - "//tensorflow/python:client_testlib", - "//third_party/py/numpy", - ], -) - -py_test( - name = "nasnet_test", - size = "large", - srcs = ["applications/nasnet_test.py"], - srcs_version = "PY2AND3", - tags = ["nomsan"], # times out, http://b/78573625 - deps = [ - ":keras", - "//tensorflow/python:client_testlib", - "//third_party/py/numpy", - ], -) - -py_test( - name = "resnet50_test", - size = "medium", - srcs = ["applications/resnet50_test.py"], - srcs_version = "PY2AND3", - deps = [ - ":keras", - "//tensorflow/python:client_testlib", - ], -) - -py_test( - name = "vgg16_test", - size = "small", - srcs = ["applications/vgg16_test.py"], - srcs_version = "PY2AND3", - deps = [ - ":keras", - "//tensorflow/python:client_testlib", - ], -) - -py_test( - name = "vgg19_test", - size = "small", - srcs = ["applications/vgg19_test.py"], - srcs_version = "PY2AND3", - deps = [ - ":keras", - "//tensorflow/python:client_testlib", - ], -) - -py_test( - name = "xception_test", - size = "medium", - srcs = ["applications/xception_test.py"], + name = "applications_test", + size = "enormous", + srcs = ["applications/applications_test.py"], + shard_count = 2, srcs_version = "PY2AND3", deps = [ ":keras", "//tensorflow/python:client_testlib", - "//third_party/py/numpy", + "@absl_py//absl/testing:parameterized", ], ) @@ -718,18 +624,6 @@ cuda_py_test( ], ) -py_test( - name = "imagenet_utils_test", - size = "small", - srcs = ["applications/imagenet_utils_test.py"], - srcs_version = "PY2AND3", - deps = [ - ":keras", - "//tensorflow/python:client_testlib", - "//third_party/py/numpy", - ], -) - py_test( name = "image_test", size = "medium", diff --git a/tensorflow/python/keras/applications/__init__.py b/tensorflow/python/keras/applications/__init__.py index 51cc51998c..cd9462d6b5 100644 --- a/tensorflow/python/keras/applications/__init__.py +++ b/tensorflow/python/keras/applications/__init__.py @@ -39,7 +39,7 @@ from tensorflow.python.keras.applications.densenet import DenseNet201 from tensorflow.python.keras.applications.inception_resnet_v2 import InceptionResNetV2 from tensorflow.python.keras.applications.inception_v3 import InceptionV3 from tensorflow.python.keras.applications.mobilenet import MobileNet -from tensorflow.python.keras.applications.mobilenet_v2 import MobileNetV2 +# TODO(fchollet): enable MobileNetV2 in next version. from tensorflow.python.keras.applications.nasnet import NASNetLarge from tensorflow.python.keras.applications.nasnet import NASNetMobile from tensorflow.python.keras.applications.resnet50 import ResNet50 diff --git a/tensorflow/python/keras/applications/applications_test.py b/tensorflow/python/keras/applications/applications_test.py new file mode 100644 index 0000000000..ef3198a937 --- /dev/null +++ b/tensorflow/python/keras/applications/applications_test.py @@ -0,0 +1,58 @@ +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== +"""Integration tests for Keras applications.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +from absl.testing import parameterized + +from tensorflow.python.keras import applications +from tensorflow.python.platform import test + + +MODEL_LIST = [ + (applications.ResNet50, 2048), + (applications.VGG16, 512), + (applications.VGG19, 512), + (applications.Xception, 2048), + (applications.InceptionV3, 2048), + (applications.InceptionResNetV2, 1536), + (applications.MobileNet, 1024), + # TODO(fchollet): enable MobileNetV2 in next version. + (applications.DenseNet121, 1024), + (applications.DenseNet169, 1664), + (applications.DenseNet201, 1920), + (applications.NASNetMobile, 1056), + (applications.NASNetLarge, 4032), +] + + +class ApplicationsTest(test.TestCase, parameterized.TestCase): + + @parameterized.parameters(*MODEL_LIST) + def test_classification_model(self, model_fn, _): + model = model_fn(classes=1000, weights=None) + self.assertEqual(model.output_shape[-1], 1000) + + @parameterized.parameters(*MODEL_LIST) + def test_feature_extration_model(self, model_fn, output_dim): + model = model_fn(include_top=False, weights=None) + self.assertEqual(model.output_shape, (None, None, None, output_dim)) + + +if __name__ == '__main__': + test.main() diff --git a/tensorflow/python/keras/applications/densenet_test.py b/tensorflow/python/keras/applications/densenet_test.py deleted file mode 100644 index 8b6aa281ad..0000000000 --- a/tensorflow/python/keras/applications/densenet_test.py +++ /dev/null @@ -1,101 +0,0 @@ -# Copyright 2018 The TensorFlow Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Tests for DenseNet application.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -from tensorflow.python import keras -from tensorflow.python.platform import test - - -class DenseNet121Test(test.TestCase): - - def test_with_top(self): - model = keras.applications.DenseNet121(weights=None) - self.assertEqual(model.output_shape, (None, 1000)) - - def test_no_top(self): - model = keras.applications.DenseNet121(weights=None, include_top=False) - self.assertEqual(model.output_shape, (None, None, None, 1024)) - - def test_with_pooling(self): - model = keras.applications.DenseNet121(weights=None, - include_top=False, - pooling='avg') - self.assertEqual(model.output_shape, (None, 1024)) - - def test_weight_loading(self): - with self.assertRaises(ValueError): - keras.applications.DenseNet121(weights='unknown', - include_top=False) - with self.assertRaises(ValueError): - keras.applications.DenseNet121(weights='imagenet', - classes=2000) - - -class DenseNet169Test(test.TestCase): - - def test_with_top(self): - model = keras.applications.DenseNet169(weights=None) - self.assertEqual(model.output_shape, (None, 1000)) - - def test_no_top(self): - model = keras.applications.DenseNet169(weights=None, include_top=False) - self.assertEqual(model.output_shape, (None, None, None, 1664)) - - def test_with_pooling(self): - model = keras.applications.DenseNet169(weights=None, - include_top=False, - pooling='max') - self.assertEqual(model.output_shape, (None, 1664)) - - def test_weight_loading(self): - with self.assertRaises(ValueError): - keras.applications.DenseNet169(weights='unknown', - include_top=False) - with self.assertRaises(ValueError): - keras.applications.DenseNet169(weights='imagenet', - classes=2000) - - -class DenseNet201(test.TestCase): - - def test_with_top(self): - model = keras.applications.DenseNet201(weights=None) - self.assertEqual(model.output_shape, (None, 1000)) - - def test_no_top(self): - model = keras.applications.DenseNet201(weights=None, include_top=False) - self.assertEqual(model.output_shape, (None, None, None, 1920)) - - def test_with_pooling(self): - model = keras.applications.DenseNet201(weights=None, - include_top=False, - pooling='avg') - self.assertEqual(model.output_shape, (None, 1920)) - - def test_weight_loading(self): - with self.assertRaises(ValueError): - keras.applications.DenseNet201(weights='unknown', - include_top=False) - with self.assertRaises(ValueError): - keras.applications.DenseNet201(weights='imagenet', - classes=2000) - - -if __name__ == '__main__': - test.main() diff --git a/tensorflow/python/keras/applications/imagenet_utils_test.py b/tensorflow/python/keras/applications/imagenet_utils_test.py deleted file mode 100644 index 037e939ac5..0000000000 --- a/tensorflow/python/keras/applications/imagenet_utils_test.py +++ /dev/null @@ -1,93 +0,0 @@ -# Copyright 2016 The TensorFlow Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Tests for Inception V3 application.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import numpy as np - -from tensorflow.python import keras -from tensorflow.python.keras.applications.imagenet_utils import preprocess_input -from tensorflow.python.platform import test - - -class ImageNetUtilsTest(test.TestCase): - - def test_preprocess_input(self): - # Test batch of images - x = np.random.uniform(0, 255, (2, 10, 10, 3)) - self.assertEqual(preprocess_input(x).shape, x.shape) - out1 = preprocess_input(x, 'channels_last') - out2 = preprocess_input(np.transpose(x, (0, 3, 1, 2)), 'channels_first') - self.assertAllClose(out1, out2.transpose(0, 2, 3, 1)) - - # Test single image - x = np.random.uniform(0, 255, (10, 10, 3)) - self.assertEqual(preprocess_input(x).shape, x.shape) - out1 = preprocess_input(x, 'channels_last') - out2 = preprocess_input(np.transpose(x, (2, 0, 1)), 'channels_first') - self.assertAllClose(out1, out2.transpose(1, 2, 0)) - - def test_preprocess_input_symbolic(self): - # Test image batch - x = np.random.uniform(0, 255, (2, 10, 10, 3)) - inputs = keras.layers.Input(shape=x.shape[1:]) - outputs = keras.layers.Lambda( - preprocess_input, output_shape=x.shape[1:])(inputs) - model = keras.models.Model(inputs, outputs) - assert model.predict(x).shape == x.shape - # pylint: disable=g-long-lambda - outputs1 = keras.layers.Lambda(lambda x: - preprocess_input(x, 'channels_last'), - output_shape=x.shape[1:])(inputs) - model1 = keras.models.Model(inputs, outputs1) - out1 = model1.predict(x) - x2 = np.transpose(x, (0, 3, 1, 2)) - inputs2 = keras.layers.Input(shape=x2.shape[1:]) - # pylint: disable=g-long-lambda - outputs2 = keras.layers.Lambda(lambda x: - preprocess_input(x, 'channels_first'), - output_shape=x2.shape[1:])(inputs2) - model2 = keras.models.Model(inputs2, outputs2) - out2 = model2.predict(x2) - self.assertAllClose(out1, out2.transpose(0, 2, 3, 1)) - - # Test single image - x = np.random.uniform(0, 255, (10, 10, 3)) - inputs = keras.layers.Input(shape=x.shape) - outputs = keras.layers.Lambda(preprocess_input, - output_shape=x.shape)(inputs) - model = keras.models.Model(inputs, outputs) - assert model.predict(x[np.newaxis])[0].shape == x.shape - # pylint: disable=g-long-lambda - outputs1 = keras.layers.Lambda(lambda x: - preprocess_input(x, 'channels_last'), - output_shape=x.shape)(inputs) - model1 = keras.models.Model(inputs, outputs1) - out1 = model1.predict(x[np.newaxis])[0] - x2 = np.transpose(x, (2, 0, 1)) - inputs2 = keras.layers.Input(shape=x2.shape) - outputs2 = keras.layers.Lambda(lambda x: - preprocess_input(x, 'channels_first'), - output_shape=x2.shape)(inputs2) # pylint: disable=g-long-lambda - model2 = keras.models.Model(inputs2, outputs2) - out2 = model2.predict(x2[np.newaxis])[0] - self.assertAllClose(out1, out2.transpose(1, 2, 0)) - - -if __name__ == '__main__': - test.main() diff --git a/tensorflow/python/keras/applications/inception_resnet_v2_test.py b/tensorflow/python/keras/applications/inception_resnet_v2_test.py deleted file mode 100644 index 0a12f88505..0000000000 --- a/tensorflow/python/keras/applications/inception_resnet_v2_test.py +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright 2016 The TensorFlow Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Tests for Inception V3 application.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import numpy as np - -from tensorflow.python import keras -from tensorflow.python.platform import test - - -class InceptionResNetV2Test(test.TestCase): - - def test_with_top(self): - model = keras.applications.InceptionResNetV2(weights=None) - self.assertEqual(model.output_shape, (None, 1000)) - - def test_no_top(self): - model = keras.applications.InceptionResNetV2(weights=None, - include_top=False) - self.assertEqual(model.output_shape, (None, None, None, 1536)) - - def test_with_pooling(self): - model = keras.applications.InceptionResNetV2(weights=None, - include_top=False, - pooling='avg') - self.assertEqual(model.output_shape, (None, 1536)) - - def test_weight_loading(self): - with self.assertRaises(ValueError): - keras.applications.InceptionResNetV2(weights='unknown', - include_top=False) - with self.assertRaises(ValueError): - keras.applications.InceptionResNetV2(weights='imagenet', - classes=2000) - - def test_preprocess_input(self): - x = np.random.uniform(0, 255, (2, 300, 200, 3)) - out1 = keras.applications.inception_resnet_v2.preprocess_input(x) - self.assertAllClose(np.mean(out1), 0., atol=0.1) - - -if __name__ == '__main__': - test.main() diff --git a/tensorflow/python/keras/applications/inception_v3_test.py b/tensorflow/python/keras/applications/inception_v3_test.py deleted file mode 100644 index a3fcdd5564..0000000000 --- a/tensorflow/python/keras/applications/inception_v3_test.py +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright 2016 The TensorFlow Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Tests for Inception V3 application.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import numpy as np - -from tensorflow.python import keras -from tensorflow.python.platform import test - - -class InceptionV3Test(test.TestCase): - - def test_with_top(self): - model = keras.applications.InceptionV3(weights=None) - self.assertEqual(model.output_shape, (None, 1000)) - - def test_no_top(self): - model = keras.applications.InceptionV3(weights=None, include_top=False) - self.assertEqual(model.output_shape, (None, None, None, 2048)) - - def test_with_pooling(self): - model = keras.applications.InceptionV3(weights=None, - include_top=False, - pooling='avg') - self.assertEqual(model.output_shape, (None, 2048)) - - def test_weight_loading(self): - with self.assertRaises(ValueError): - keras.applications.InceptionV3(weights='unknown', - include_top=False) - with self.assertRaises(ValueError): - keras.applications.InceptionV3(weights='imagenet', - classes=2000) - - def test_preprocess_input(self): - x = np.random.uniform(0, 255, (2, 300, 200, 3)) - out1 = keras.applications.inception_v3.preprocess_input(x) - self.assertAllClose(np.mean(out1), 0., atol=0.1) - - -if __name__ == '__main__': - test.main() diff --git a/tensorflow/python/keras/applications/mobilenet_test.py b/tensorflow/python/keras/applications/mobilenet_test.py deleted file mode 100644 index 65e4991ded..0000000000 --- a/tensorflow/python/keras/applications/mobilenet_test.py +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright 2016 The TensorFlow Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Tests for MobileNet application.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import numpy as np - -from tensorflow.python import keras -from tensorflow.python.platform import test - - -class MobileNetTest(test.TestCase): - - def test_with_top(self): - model = keras.applications.MobileNet(weights=None) - self.assertEqual(model.output_shape, (None, 1000)) - - def test_no_top(self): - model = keras.applications.MobileNet(weights=None, include_top=False) - self.assertEqual(model.output_shape, (None, None, None, 1024)) - - def test_with_pooling(self): - model = keras.applications.MobileNet(weights=None, - include_top=False, - pooling='avg') - self.assertEqual(model.output_shape, (None, 1024)) - - def test_weight_loading(self): - with self.assertRaises(ValueError): - keras.applications.MobileNet(weights='unknown', - include_top=False) - with self.assertRaises(ValueError): - keras.applications.MobileNet(weights='imagenet', - classes=2000) - - def test_preprocess_input(self): - x = np.random.uniform(0, 255, (2, 300, 200, 3)) - out1 = keras.applications.mobilenet.preprocess_input(x) - self.assertAllClose(np.mean(out1), 0., atol=0.1) - - def test_mobilenet_variable_input_channels(self): - input_shape = (None, None, 1) - model = keras.applications.MobileNet(weights=None, - include_top=False, - input_shape=input_shape) - self.assertEqual(model.output_shape, (None, None, None, 1024)) - - input_shape = (None, None, 4) - model = keras.applications.MobileNet(weights=None, - include_top=False, - input_shape=input_shape) - self.assertEqual(model.output_shape, (None, None, None, 1024)) - - -if __name__ == '__main__': - test.main() diff --git a/tensorflow/python/keras/applications/mobilenet_v2.py b/tensorflow/python/keras/applications/mobilenet_v2.py index 74b8b029f8..9194c3ee14 100644 --- a/tensorflow/python/keras/applications/mobilenet_v2.py +++ b/tensorflow/python/keras/applications/mobilenet_v2.py @@ -19,14 +19,4 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -from keras_applications import mobilenet_v2 - -from tensorflow.python.util.tf_export import tf_export - -MobileNetV2 = mobilenet_v2.MobileNetV2 -decode_predictions = mobilenet_v2.decode_predictions -preprocess_input = mobilenet_v2.preprocess_input - -tf_export('keras.applications.mobilenet_v2.MobileNetV2', - 'keras.applications.MobileNetV2')(MobileNetV2) -tf_export('keras.applications.mobilenet_v2.preprocess_input')(preprocess_input) +# TODO(fchollet): export MobileNetV2 as part of the public API in next version. diff --git a/tensorflow/python/keras/applications/nasnet_test.py b/tensorflow/python/keras/applications/nasnet_test.py deleted file mode 100644 index f96c3aa51c..0000000000 --- a/tensorflow/python/keras/applications/nasnet_test.py +++ /dev/null @@ -1,76 +0,0 @@ -# Copyright 2018 The TensorFlow Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Tests for Nasnet application.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -from tensorflow.python import keras -from tensorflow.python.platform import test - - -class NASNetMobileTest(test.TestCase): - - def test_with_top(self): - model = keras.applications.NASNetMobile(weights=None) - self.assertEqual(model.output_shape, (None, 1000)) - - def test_no_top(self): - model = keras.applications.NASNetMobile(weights=None, include_top=False) - self.assertEqual(model.output_shape, (None, None, None, 1056)) - - def test_with_pooling(self): - model = keras.applications.NASNetMobile(weights=None, - include_top=False, - pooling='avg') - self.assertEqual(model.output_shape, (None, 1056)) - - def test_weight_loading(self): - with self.assertRaises(ValueError): - keras.applications.NASNetMobile(weights='unknown', - include_top=False) - with self.assertRaises(ValueError): - keras.applications.NASNetMobile(weights='imagenet', - classes=2000) - - -class NASNetLargeTest(test.TestCase): - - def test_with_top(self): - model = keras.applications.NASNetLarge(weights=None) - self.assertEqual(model.output_shape, (None, 1000)) - - def test_no_top(self): - model = keras.applications.NASNetLarge(weights=None, include_top=False) - self.assertEqual(model.output_shape, (None, None, None, 4032)) - - def test_with_pooling(self): - model = keras.applications.NASNetLarge(weights=None, - include_top=False, - pooling='avg') - self.assertEqual(model.output_shape, (None, 4032)) - - def test_weight_loading(self): - with self.assertRaises(ValueError): - keras.applications.NASNetLarge(weights='unknown', - include_top=False) - with self.assertRaises(ValueError): - keras.applications.NASNetLarge(weights='imagenet', - classes=2000) - - -if __name__ == '__main__': - test.main() diff --git a/tensorflow/python/keras/applications/resnet50_test.py b/tensorflow/python/keras/applications/resnet50_test.py deleted file mode 100644 index 22a3f05580..0000000000 --- a/tensorflow/python/keras/applications/resnet50_test.py +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2016 The TensorFlow Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Tests for ResNet50 application.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -from tensorflow.python import keras -from tensorflow.python.platform import test - - -class ResNet50Test(test.TestCase): - - def test_with_top(self): - model = keras.applications.ResNet50(weights=None) - self.assertEqual(model.output_shape, (None, 1000)) - - def test_no_top(self): - model = keras.applications.ResNet50(weights=None, include_top=False) - self.assertEqual(model.output_shape, (None, None, None, 2048)) - - def test_with_pooling(self): - model = keras.applications.ResNet50(weights=None, - include_top=False, - pooling='avg') - self.assertEqual(model.output_shape, (None, 2048)) - - def test_weight_loading(self): - with self.assertRaises(ValueError): - keras.applications.ResNet50(weights='unknown', - include_top=False) - - with self.assertRaises(ValueError): - keras.applications.ResNet50(weights='imagenet', - classes=2000) - -if __name__ == '__main__': - test.main() diff --git a/tensorflow/python/keras/applications/vgg16_test.py b/tensorflow/python/keras/applications/vgg16_test.py deleted file mode 100644 index cad65765f3..0000000000 --- a/tensorflow/python/keras/applications/vgg16_test.py +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2016 The TensorFlow Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Tests for VGG16 application.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -from tensorflow.python import keras -from tensorflow.python.platform import test - - -class VGG16Test(test.TestCase): - - def test_with_top(self): - model = keras.applications.VGG16(weights=None) - self.assertEqual(model.output_shape, (None, 1000)) - - def test_no_top(self): - model = keras.applications.VGG16(weights=None, include_top=False) - self.assertEqual(model.output_shape, (None, None, None, 512)) - - def test_with_pooling(self): - model = keras.applications.VGG16(weights=None, - include_top=False, - pooling='avg') - self.assertEqual(model.output_shape, (None, 512)) - - def test_weight_loading(self): - with self.assertRaises(ValueError): - keras.applications.VGG16(weights='unknown', - include_top=False) - with self.assertRaises(ValueError): - keras.applications.VGG16(weights='imagenet', - classes=2000) - -if __name__ == '__main__': - test.main() diff --git a/tensorflow/python/keras/applications/vgg19_test.py b/tensorflow/python/keras/applications/vgg19_test.py deleted file mode 100644 index 61dccc0c5c..0000000000 --- a/tensorflow/python/keras/applications/vgg19_test.py +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2016 The TensorFlow Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Tests for VGG19 application.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -from tensorflow.python import keras -from tensorflow.python.platform import test - - -class VGG19Test(test.TestCase): - - def test_with_top(self): - model = keras.applications.VGG19(weights=None) - self.assertEqual(model.output_shape, (None, 1000)) - - def test_no_top(self): - model = keras.applications.VGG19(weights=None, include_top=False) - self.assertEqual(model.output_shape, (None, None, None, 512)) - - def test_with_pooling(self): - model = keras.applications.VGG19(weights=None, - include_top=False, - pooling='avg') - self.assertEqual(model.output_shape, (None, 512)) - - def test_weight_loading(self): - with self.assertRaises(ValueError): - keras.applications.VGG19(weights='unknown', - include_top=False) - with self.assertRaises(ValueError): - keras.applications.VGG19(weights='imagenet', - classes=2000) - -if __name__ == '__main__': - test.main() diff --git a/tensorflow/python/keras/applications/xception_test.py b/tensorflow/python/keras/applications/xception_test.py deleted file mode 100644 index 7e2efd0017..0000000000 --- a/tensorflow/python/keras/applications/xception_test.py +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright 2016 The TensorFlow Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Tests for Xception application.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import numpy as np - -from tensorflow.python import keras -from tensorflow.python.platform import test - - -class XceptionTest(test.TestCase): - - def test_with_top(self): - model = keras.applications.Xception(weights=None) - self.assertEqual(model.output_shape, (None, 1000)) - - def test_no_top(self): - model = keras.applications.Xception(weights=None, include_top=False) - self.assertEqual(model.output_shape, (None, None, None, 2048)) - - def test_with_pooling(self): - model = keras.applications.Xception(weights=None, - include_top=False, - pooling='avg') - self.assertEqual(model.output_shape, (None, 2048)) - - def test_weight_loading(self): - with self.assertRaises(ValueError): - keras.applications.Xception(weights='unknown', - include_top=False) - with self.assertRaises(ValueError): - keras.applications.Xception(weights='imagenet', - classes=2000) - - def test_preprocess_input(self): - x = np.random.uniform(0, 255, (2, 300, 200, 3)) - out1 = keras.applications.xception.preprocess_input(x) - self.assertAllClose(np.mean(out1), 0., atol=0.1) - -if __name__ == '__main__': - test.main() diff --git a/tensorflow/python/tools/api/generator/api_init_files.bzl b/tensorflow/python/tools/api/generator/api_init_files.bzl index 64f0469482..7001e566ce 100644 --- a/tensorflow/python/tools/api/generator/api_init_files.bzl +++ b/tensorflow/python/tools/api/generator/api_init_files.bzl @@ -25,7 +25,6 @@ TENSORFLOW_API_INIT_FILES = [ "keras/applications/inception_resnet_v2/__init__.py", "keras/applications/inception_v3/__init__.py", "keras/applications/mobilenet/__init__.py", - "keras/applications/mobilenet_v2/__init__.py", "keras/applications/nasnet/__init__.py", "keras/applications/resnet50/__init__.py", "keras/applications/vgg16/__init__.py", diff --git a/tensorflow/python/tools/api/generator/api_init_files_v1.bzl b/tensorflow/python/tools/api/generator/api_init_files_v1.bzl index bc2f3516d1..73d11199d9 100644 --- a/tensorflow/python/tools/api/generator/api_init_files_v1.bzl +++ b/tensorflow/python/tools/api/generator/api_init_files_v1.bzl @@ -25,7 +25,6 @@ TENSORFLOW_API_INIT_FILES_V1 = [ "keras/applications/inception_resnet_v2/__init__.py", "keras/applications/inception_v3/__init__.py", "keras/applications/mobilenet/__init__.py", - "keras/applications/mobilenet_v2/__init__.py", "keras/applications/nasnet/__init__.py", "keras/applications/resnet50/__init__.py", "keras/applications/vgg16/__init__.py", -- GitLab From fcef09c17887451bfc138bac63b1be7b72993f71 Mon Sep 17 00:00:00 2001 From: Sanjoy Das Date: Mon, 13 Aug 2018 11:54:21 -0700 Subject: [PATCH 420/437] Minor NFC cleanups to MarkForCompilationPass - Make RunImpl private and expose it to the tests using a friend. - Improve (my subjective opinion) the logging somewhat: - Be briefer - Don't print redundant information - Print more detailed rationale for why a node wasn't clustered PiperOrigin-RevId: 208518576 --- tensorflow/compiler/jit/BUILD | 2 + .../compiler/jit/mark_for_compilation_pass.cc | 94 ++++++++++++------- .../compiler/jit/mark_for_compilation_pass.h | 8 +- .../jit/mark_for_compilation_pass_test.cc | 70 +++++--------- .../mark_for_compilation_pass_test_helper.cc | 40 ++++++++ .../mark_for_compilation_pass_test_helper.h | 35 +++++++ 6 files changed, 165 insertions(+), 84 deletions(-) create mode 100644 tensorflow/compiler/jit/mark_for_compilation_pass_test_helper.cc create mode 100644 tensorflow/compiler/jit/mark_for_compilation_pass_test_helper.h diff --git a/tensorflow/compiler/jit/BUILD b/tensorflow/compiler/jit/BUILD index 55b98da472..9e6d7fa0b1 100644 --- a/tensorflow/compiler/jit/BUILD +++ b/tensorflow/compiler/jit/BUILD @@ -314,12 +314,14 @@ cc_library( "deadness_analysis_internal.h", "encapsulate_subgraphs_pass.cc", "mark_for_compilation_pass.cc", + "mark_for_compilation_pass_test_helper.cc", ], hdrs = [ "build_xla_launch_ops_pass.h", "deadness_analysis.h", "encapsulate_subgraphs_pass.h", "mark_for_compilation_pass.h", + "mark_for_compilation_pass_test_helper.h", ], deps = [ ":common", diff --git a/tensorflow/compiler/jit/mark_for_compilation_pass.cc b/tensorflow/compiler/jit/mark_for_compilation_pass.cc index 45d422943c..d33287fcc3 100644 --- a/tensorflow/compiler/jit/mark_for_compilation_pass.cc +++ b/tensorflow/compiler/jit/mark_for_compilation_pass.cc @@ -65,6 +65,7 @@ bool HasXLAKernel(const Node& node, const DeviceType& jit_device_type) { // XLA cluster so it can't implement the forward-tensor-ref semantic. Leave // such nodes out of XLA clusters. if (HasForwardedRefInput(node)) { + VLOG(2) << "Rejecting " << node.name() << ": Identity with unsafe cast."; return false; } @@ -84,14 +85,13 @@ bool IsCompilableCall(const NodeDef& call_def, bool IsCompilableWhile(const Node& while_node, const DeviceType& jit_device_type, int depth, FunctionLibraryRuntime* lib_runtime) { - VLOG(2) << "Loop marking: " << while_node.type_string(); - const NameAttrList* name_attr; NodeDef call; Status status; status = GetNodeAttr(while_node.attrs(), "cond", &name_attr); if (!status.ok()) { - VLOG(2) << "Missing 'cond' attribute on While node."; + VLOG(2) << "Rejecting While " << while_node.name() + << ": missing 'cond' attribute on While node."; return false; } const string cond_func = name_attr->name(); @@ -99,12 +99,14 @@ bool IsCompilableWhile(const Node& while_node, call.set_op(cond_func); *call.mutable_attr() = name_attr->attr(); if (!IsCompilableCall(call, jit_device_type, depth + 1, lib_runtime)) { - VLOG(2) << "Can't compile loop condition: " << cond_func; + VLOG(2) << "Rejecting While " << while_node.name() + << ": can't compile loop condition: " << cond_func; return false; } status = GetNodeAttr(while_node.attrs(), "body", &name_attr); if (!status.ok()) { - VLOG(2) << "Missing 'body' attribute on While node."; + VLOG(2) << "Rejecting While " << while_node.name() + << ": missing 'body' attribute on While node."; return false; } const string body_func = name_attr->name(); @@ -112,10 +114,10 @@ bool IsCompilableWhile(const Node& while_node, call.set_op(body_func); *call.mutable_attr() = name_attr->attr(); if (!IsCompilableCall(call, jit_device_type, depth + 1, lib_runtime)) { - VLOG(2) << "Can't compile loop body: " << body_func; + VLOG(2) << "Rejecting While " << while_node.name() + << ": can't compile loop body: " << body_func; return false; } - VLOG(2) << "Loop is compilable."; return true; } @@ -125,10 +127,9 @@ bool IsCompilableWhile(const Node& while_node, bool IsCompilableCall(const NodeDef& call_def, const DeviceType& jit_device_type, int depth, FunctionLibraryRuntime* lib_runtime) { - VLOG(2) << "Function marking: " << call_def.op(); - if (depth > kMaxRecursionDepth) { - VLOG(2) << "Function depth limit exceeded"; + VLOG(2) << "Rejecting " << call_def.op() + << ": function depth limit exceeded."; return false; } @@ -136,7 +137,8 @@ bool IsCompilableCall(const NodeDef& call_def, Status status = lib_runtime->Instantiate(call_def.op(), AttrSlice(call_def), &handle); if (!status.ok()) { - VLOG(2) << "Could not instantiate " << call_def.op() << ": " << status; + VLOG(2) << "Rejecting " << call_def.op() + << ": could not instantiate: " << status; return false; } const FunctionBody* fbody = lib_runtime->GetFunctionBody(handle); @@ -150,7 +152,8 @@ bool IsCompilableCall(const NodeDef& call_def, // tf2xla to translate the TF graph into XLA. So we avoid this for now. // // TODO(b/36139787): Create a mechanism to set inlining hints. - VLOG(2) << "Can't compile noinline function: " << fdef.DebugString(); + VLOG(2) << "Rejecting " << call_def.op() + << ": can't compile noinline function."; return false; } @@ -164,12 +167,11 @@ bool IsCompilableCall(const NodeDef& call_def, if (!HasXLAKernel(*node, jit_device_type) && !IsCompilableCall(node->def(), jit_device_type, depth + 1, lib_runtime)) { - VLOG(2) << "Function marking failed: unsupported op " << node->name() - << ": " << node->def().ShortDebugString(); + VLOG(2) << "Rejecting " << call_def.op() << ": unsupported op " + << node->name() << ": " << node->def().ShortDebugString(); return false; } } - VLOG(2) << "Function is compilable: " << call_def.op(); return true; } @@ -357,24 +359,27 @@ Status FindCompilationCandidates( } std::sort(sorted_nodes.begin(), sorted_nodes.end(), NodeComparatorID()); + if (fuel >= std::numeric_limits::max() / 2) { + // The assumption is that if fuel started out as INT64_MAX, it will forever + // stay greater than INT64_MAX / 2. + VLOG(2) << "Starting fuel: infinity"; + } else { + VLOG(2) << "Starting fuel: " << fuel; + } + for (Node* node : sorted_nodes) { - VLOG(2) << "Fuel: " << fuel; if (fuel <= 0) { - VLOG(2) + VLOG(1) << "Hit fuel limit; not marking any remaining ops as clusterable."; break; } - VLOG(2) << "FindCompilationCandidates(): Processing " - << node->DebugString(); - DeviceType device_type(""); TF_RETURN_IF_ERROR( DeviceToDeviceType(node->assigned_device_name(), &device_type)); if (is_compilable_fn && !is_compilable_fn(node, device_type)) { - VLOG(2) << "Compilation rejected node: not compilable " << node->name() - << ": " << node->type_string(); + // is_compilable_fn has already logged the reason if it returned false. continue; } @@ -384,14 +389,14 @@ Status FindCompilationCandidates( DeviceType jit_device_type(registration->compilation_device_name); if (!HasXLAKernel(*node, jit_device_type) && !IsCompilableCall(node->def(), jit_device_type, 0, lib_runtime)) { - VLOG(2) << "Compilation rejected node: unsupported op " << node->name() - << ": " << node->type_string(); + VLOG(2) << "Rejecting " << node->name() << ": unsupported op " + << node->type_string(); continue; } if (!registration->compile_resource_ops && HasResourceInputOrOutput(*node)) { - VLOG(2) << "Compilation rejected node: resource input/output " - << node->name() << ": " << node->type_string(); + VLOG(2) << "Rejecting: " << node->name() << ": resource input/output " + << node->type_string(); continue; } if (node->type_string() == "While" && @@ -401,15 +406,11 @@ Status FindCompilationCandidates( // _Arg nodes in a top-level function represent feeds. // Do not compile them. if (node->type_string() == "_Arg") { - VLOG(2) << "Skipping jit compilation for '_Arg'-typed node " - << node->DebugString(); continue; } // _Retval nodes in a top-level function represent fetches. // Do not compile them. if (node->type_string() == "_Retval") { - VLOG(2) << "Compilation rejected node: return value " << node->name() - << ": " << node->type_string(); continue; } candidates->insert(node); @@ -475,6 +476,7 @@ Status MarkForCompilationPass::Run( const XlaOpRegistry::DeviceRegistration* registration; if (!XlaOpRegistry::GetCompilationDevice(device_type.type(), ®istration)) { + VLOG(2) << "Rejecting " << node->name() << ": could not find JIT device."; return false; } @@ -484,21 +486,36 @@ Status MarkForCompilationPass::Run( // If there is a _XlaCompile annotation, use its value. bool compile = false; Status status = GetNodeAttr(node->attrs(), kXlaCompileAttr, &compile); - if (status.ok()) return compile; + if (status.ok()) { + if (!compile) { + VLOG(2) << "Rejecting " << node->name() << ": kXlaCompileAttr(" + << kXlaCompileAttr << ") is false."; + } + return compile; + } status = fld->GetAttr(*node, kXlaCompileAttr, &compile); - if (status.ok()) return compile; + if (status.ok()) { + if (!compile) { + VLOG(2) << "Rejecting " << node->name() << ": kXlaCompileAttr(" + << kXlaCompileAttr << ") on callee is false."; + } + return compile; + } // If inputs to `node` can have conflicting deadness (i.e. some are alive // and some are dead) then don't compile it. XLA cannot represent the // deadness semantics of these nodes correctly and auto-clustering these // nodes can cause deadness to propagate to nodes that should be live. if (node->IsMerge() || deadness->HasInputsWithMismatchingDeadness(*node)) { + VLOG(2) << "Rejecting " << node->name() << ": mismatching deadness."; return false; } // Check for fusable ops only if requested. if (global_jit_level > 0 && fusion_only && !IsXlaFusable(node->def())) { + VLOG(2) << "Rejecting " << node->name() + << ": not fusable op but fusion_only enabled."; return false; } @@ -506,8 +523,17 @@ Status MarkForCompilationPass::Run( // Ignore enable_jit_by_default if global jit compilation for CPU // is explicitly requested via tf_xla_cpu_global_jit flag bool ignore_registration = cpu_global_jit && device_type == DEVICE_CPU; - return (ignore_registration || registration->enable_jit_by_default) && - global_jit_level > 0; + bool should_compile = + (ignore_registration || registration->enable_jit_by_default) && + global_jit_level > 0; + if (!should_compile) { + if (global_jit_level <= 0) { + VLOG(2) << "Rejecting " << node->name() << ": global jit disabled."; + } else { + VLOG(2) << "Rejecting " << node->name() << ": JIT for device disabled."; + } + } + return should_compile; }; return RunImpl(options, is_compilable); } diff --git a/tensorflow/compiler/jit/mark_for_compilation_pass.h b/tensorflow/compiler/jit/mark_for_compilation_pass.h index e9acbfb19e..f1137af3c1 100644 --- a/tensorflow/compiler/jit/mark_for_compilation_pass.h +++ b/tensorflow/compiler/jit/mark_for_compilation_pass.h @@ -40,20 +40,18 @@ class MarkForCompilationPass : public GraphOptimizationPass { Status Run(const GraphOptimizationPassOptions& options) override; - // Run() just calls RunImpl() if --tf_xla_auto_jit is enabled. To run the pass - // unconditionally, call RunImpl() directly. - // is_compilable_fn, if set, is a predicate that must be true for a node to - // be compiled. + private: Status RunImpl(const GraphOptimizationPassOptions& options, const std::function& is_compilable_fn = {}); + + friend class MarkForCompilationPassTestHelper; }; // Returns true iff 'ndef' is a call to a function that is compilable. A // function is compilable iff every operator in the function body is // compilable. bool IsCompilable(FunctionLibraryRuntime* flr, const NodeDef& ndef); - } // namespace tensorflow #endif // TENSORFLOW_COMPILER_JIT_MARK_FOR_COMPILATION_PASS_H_ diff --git a/tensorflow/compiler/jit/mark_for_compilation_pass_test.cc b/tensorflow/compiler/jit/mark_for_compilation_pass_test.cc index 2c5f4fb774..a780d4a936 100644 --- a/tensorflow/compiler/jit/mark_for_compilation_pass_test.cc +++ b/tensorflow/compiler/jit/mark_for_compilation_pass_test.cc @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -#include "tensorflow/compiler/jit/mark_for_compilation_pass.h" +#include "tensorflow/compiler/jit/mark_for_compilation_pass_test_helper.h" #include "tensorflow/cc/framework/ops.h" #include "tensorflow/cc/ops/array_ops.h" @@ -39,27 +39,6 @@ namespace { REGISTER_OP("UncompilableNullary").Output("o: float"); REGISTER_OP("UncompilableUnary").Input("a: float").Output("o: float"); -Status MarkForCompilation(std::unique_ptr* graph, - FunctionLibraryDefinition* flib_def) { - // Assign all nodes to the CPU device. - static const char* kCpuDevice = "/job:localhost/replica:0/task:0/cpu:0"; - for (Node* n : (*graph)->nodes()) { - n->set_assigned_device_name(kCpuDevice); - } - - GraphOptimizationPassOptions opt_options; - opt_options.graph = graph; - opt_options.flib_def = flib_def; - MarkForCompilationPass pass; - return pass.RunImpl(opt_options); -} - -Status MarkForCompilation(std::unique_ptr* graph) { - FunctionDefLibrary flib; - FunctionLibraryDefinition flib_def((*graph)->op_registry(), flib); - return MarkForCompilation(graph, &flib_def); -} - std::unordered_map GetClusters(const Graph& graph) { std::unordered_map ids; for (Node* node : graph.nodes()) { @@ -88,7 +67,7 @@ TEST(XlaCompilationTest, Chains) { TF_EXPECT_OK(GraphDefBuilderToGraph(builder, graph.get())); } - TF_ASSERT_OK(MarkForCompilation(&graph)); + TF_ASSERT_OK(MarkForCompilationPassTestHelper::MarkForCompilation(&graph)); auto clusters = GetClusters(*graph); EXPECT_EQ(4, clusters.size()); EXPECT_EQ(clusters["B"], clusters["C"]); @@ -113,7 +92,7 @@ TEST(XlaCompilationTest, UncompilableCycles) { TF_EXPECT_OK(GraphDefBuilderToGraph(builder, graph.get())); } - TF_ASSERT_OK(MarkForCompilation(&graph)); + TF_ASSERT_OK(MarkForCompilationPassTestHelper::MarkForCompilation(&graph)); auto clusters = GetClusters(*graph); EXPECT_TRUE(clusters.empty()); @@ -133,7 +112,7 @@ TEST(XlaCompilationTest, CompilableCycles) { TF_EXPECT_OK(GraphDefBuilderToGraph(builder, graph.get())); } - TF_ASSERT_OK(MarkForCompilation(&graph)); + TF_ASSERT_OK(MarkForCompilationPassTestHelper::MarkForCompilation(&graph)); auto clusters = GetClusters(*graph); EXPECT_EQ(3, clusters.size()); @@ -156,7 +135,7 @@ TEST(XlaCompilationTest, Complex128Unsupported) { TF_EXPECT_OK(GraphDefBuilderToGraph(builder, graph.get())); } - TF_ASSERT_OK(MarkForCompilation(&graph)); + TF_ASSERT_OK(MarkForCompilationPassTestHelper::MarkForCompilation(&graph)); auto clusters = GetClusters(*graph); EXPECT_TRUE(clusters.empty()); } @@ -177,7 +156,7 @@ TEST(XlaCompilationTest, HalfSupported) { TF_EXPECT_OK(GraphDefBuilderToGraph(builder, graph.get())); } - TF_ASSERT_OK(MarkForCompilation(&graph)); + TF_ASSERT_OK(MarkForCompilationPassTestHelper::MarkForCompilation(&graph)); auto clusters = GetClusters(*graph); EXPECT_FALSE(clusters.empty()); } @@ -206,7 +185,7 @@ TEST(XlaCompilationTest, ConcatWithConstArg) { TF_EXPECT_OK(GraphDefBuilderToGraph(builder, graph.get())); } - TF_ASSERT_OK(MarkForCompilation(&graph)); + TF_ASSERT_OK(MarkForCompilationPassTestHelper::MarkForCompilation(&graph)); auto clusters = GetClusters(*graph); EXPECT_EQ(3, clusters.size()); // Everything should be compiled. } @@ -241,7 +220,8 @@ TEST(XlaCompilationTest, FunctionCalls) { TF_EXPECT_OK(GraphDefBuilderToGraph(builder, graph.get())); } - TF_ASSERT_OK(MarkForCompilation(&graph, &flib_def)); + TF_ASSERT_OK( + MarkForCompilationPassTestHelper::MarkForCompilation(&graph, &flib_def)); auto clusters = GetClusters(*graph); EXPECT_EQ(2, clusters.size()); @@ -272,7 +252,7 @@ TEST(XlaCompilationTest, MetadataOpsDontStartClusters) { ops::UnaryOp("Shape", d, builder.opts().WithName("E")); TF_EXPECT_OK(GraphDefBuilderToGraph(builder, graph.get())); } - TF_ASSERT_OK(MarkForCompilation(&graph)); + TF_ASSERT_OK(MarkForCompilationPassTestHelper::MarkForCompilation(&graph)); auto clusters = GetClusters(*graph); EXPECT_EQ(0, clusters.size()); // Nothing should be compiled. } @@ -359,7 +339,7 @@ TEST(XlaCompilationTest, SymbolicGradients) { TF_EXPECT_OK(GraphDefBuilderToGraph(builder, graph.get())); } - TF_ASSERT_OK(MarkForCompilation(&graph)); + TF_ASSERT_OK(MarkForCompilationPassTestHelper::MarkForCompilation(&graph)); auto clusters = GetClusters(*graph); EXPECT_EQ(2, clusters.size()); @@ -384,7 +364,7 @@ TEST(XlaCompilationTest, Loops) { std::unique_ptr graph(new Graph(OpRegistry::Global())); TF_EXPECT_OK(root.ToGraph(graph.get())); - TF_ASSERT_OK(MarkForCompilation(&graph)); + TF_ASSERT_OK(MarkForCompilationPassTestHelper::MarkForCompilation(&graph)); auto clusters = GetClusters(*graph); // Nothing should be compiled. In particular, 'd' and 'c' must not be @@ -411,7 +391,7 @@ TEST(XlaCompilationTest, CyclesWithAllDifferentScopes) { TF_CHECK_OK(GraphDefBuilderToGraph(builder, graph.get())); } - TF_ASSERT_OK(MarkForCompilation(&graph)); + TF_ASSERT_OK(MarkForCompilationPassTestHelper::MarkForCompilation(&graph)); auto clusters = GetClusters(*graph); // The computation is: C = A + relu(A) @@ -442,7 +422,7 @@ TEST(XlaCompilationTest, CyclesWithSplittingScopes) { TF_CHECK_OK(GraphDefBuilderToGraph(builder, graph.get())); } - TF_ASSERT_OK(MarkForCompilation(&graph)); + TF_ASSERT_OK(MarkForCompilationPassTestHelper::MarkForCompilation(&graph)); auto clusters = GetClusters(*graph); // The computation is: D = relu(A) + (A @ relu(A)) @@ -472,7 +452,7 @@ TEST(XlaCompilationTest, CyclesWithDifferentScopesAndBridge) { TF_CHECK_OK(GraphDefBuilderToGraph(builder, graph.get())); } - TF_ASSERT_OK(MarkForCompilation(&graph)); + TF_ASSERT_OK(MarkForCompilationPassTestHelper::MarkForCompilation(&graph)); auto clusters = GetClusters(*graph); // The computation is: C = A @ relu(A) @@ -512,7 +492,7 @@ TEST(XlaCompilationTest, Resources) { ops::UnaryOp("Relu", d, builder.opts().WithName("E")); TF_EXPECT_OK(GraphDefBuilderToGraph(builder, graph.get())); } - TF_ASSERT_OK(MarkForCompilation(&graph)); + TF_ASSERT_OK(MarkForCompilationPassTestHelper::MarkForCompilation(&graph)); auto clusters = GetClusters(*graph); EXPECT_EQ(0, clusters.size()); // Nothing should be compiled. } @@ -542,7 +522,7 @@ TEST(XlaCompilationTest, IllegalCycle_UsefulErrorMessage) { TF_EXPECT_OK(root.ToGraph(graph.get())); - Status status = MarkForCompilation(&graph); + Status status = MarkForCompilationPassTestHelper::MarkForCompilation(&graph); EXPECT_FALSE(status.ok()); EXPECT_TRUE(str_util::StrContains(status.ToString(), "Edge from c to a would create a cycle.\n" @@ -570,7 +550,7 @@ TEST(XlaCompilationTest, Retval) { TF_EXPECT_OK(GraphDefBuilderToGraph(builder, graph.get())); } - TF_ASSERT_OK(MarkForCompilation(&graph)); + TF_ASSERT_OK(MarkForCompilationPassTestHelper::MarkForCompilation(&graph)); auto clusters = GetClusters(*graph); EXPECT_EQ(2, clusters.size()); @@ -588,7 +568,7 @@ TEST(XlaCompilationTest, DontCountIdentityOps) { auto r = ops::_Retval(root.WithOpName("R"), c, 0); } TF_ASSERT_OK(root.ToGraph(graph.get())); - TF_ASSERT_OK(MarkForCompilation(&graph)); + TF_ASSERT_OK(MarkForCompilationPassTestHelper::MarkForCompilation(&graph)); auto clusters = GetClusters(*graph); EXPECT_TRUE(clusters.empty()); @@ -604,7 +584,7 @@ TEST(XlaCompilationTest, DontCountIdentityOpsWithLocalJit) { auto r = ops::_Retval(root.WithOpName("R"), b, 0); } TF_ASSERT_OK(root.ToGraph(graph.get())); - TF_ASSERT_OK(MarkForCompilation(&graph)); + TF_ASSERT_OK(MarkForCompilationPassTestHelper::MarkForCompilation(&graph)); auto clusters = GetClusters(*graph); EXPECT_TRUE(clusters.empty()); @@ -618,7 +598,7 @@ TEST(XlaCompilationTest, ConstOp) { auto c = ops::Const(root.WithOpName("const"), 0.5f); c.node()->AddAttr(kXlaCompileAttr, true); TF_ASSERT_OK(root.ToGraph(graph.get())); - TF_ASSERT_OK(MarkForCompilation(&graph)); + TF_ASSERT_OK(MarkForCompilationPassTestHelper::MarkForCompilation(&graph)); EXPECT_EQ(1, GetClusters(*graph).size()); } @@ -629,7 +609,7 @@ TEST(XlaCompilationTest, ConstOp) { auto c = ops::Const(root.WithOpName("const"), string("string")); c.node()->AddAttr(kXlaCompileAttr, true); TF_ASSERT_OK(root.ToGraph(graph.get())); - TF_ASSERT_OK(MarkForCompilation(&graph)); + TF_ASSERT_OK(MarkForCompilationPassTestHelper::MarkForCompilation(&graph)); EXPECT_TRUE(GetClusters(*graph).empty()); } } @@ -644,7 +624,7 @@ TEST(XlaCompilationTest, DontClusterIdentityWithRefInput) { std::unique_ptr graph(new Graph(OpRegistry::Global())); TF_ASSERT_OK(root.ToGraph(graph.get())); - TF_ASSERT_OK(MarkForCompilation(&graph)); + TF_ASSERT_OK(MarkForCompilationPassTestHelper::MarkForCompilation(&graph)); std::unordered_map clusters = GetClusters(*graph); @@ -667,7 +647,7 @@ TEST(XlaCompilationTest, ClusterIdentityWithNonRefInput) { std::unique_ptr graph(new Graph(OpRegistry::Global())); TF_ASSERT_OK(root.ToGraph(graph.get())); - TF_ASSERT_OK(MarkForCompilation(&graph)); + TF_ASSERT_OK(MarkForCompilationPassTestHelper::MarkForCompilation(&graph)); std::unordered_map clusters = GetClusters(*graph); @@ -699,7 +679,7 @@ TEST(XlaCompilationTest, ClusterControlTrigger) { std::unique_ptr graph(new Graph(OpRegistry::Global())); TF_ASSERT_OK(root.ToGraph(graph.get())); - TF_ASSERT_OK(MarkForCompilation(&graph)); + TF_ASSERT_OK(MarkForCompilationPassTestHelper::MarkForCompilation(&graph)); std::unordered_map clusters = GetClusters(*graph); diff --git a/tensorflow/compiler/jit/mark_for_compilation_pass_test_helper.cc b/tensorflow/compiler/jit/mark_for_compilation_pass_test_helper.cc new file mode 100644 index 0000000000..a84b82e479 --- /dev/null +++ b/tensorflow/compiler/jit/mark_for_compilation_pass_test_helper.cc @@ -0,0 +1,40 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#include "tensorflow/compiler/jit/mark_for_compilation_pass_test_helper.h" + +namespace tensorflow { +/*static*/ Status MarkForCompilationPassTestHelper::MarkForCompilation( + std::unique_ptr* graph, FunctionLibraryDefinition* flib_def) { + // Assign all nodes to the CPU device. + static const char* kCpuDevice = "/job:localhost/replica:0/task:0/cpu:0"; + for (Node* n : (*graph)->nodes()) { + n->set_assigned_device_name(kCpuDevice); + } + + GraphOptimizationPassOptions opt_options; + opt_options.graph = graph; + opt_options.flib_def = flib_def; + MarkForCompilationPass pass; + return pass.RunImpl(opt_options); +} + +/*static*/ Status MarkForCompilationPassTestHelper::MarkForCompilation( + std::unique_ptr* graph) { + FunctionDefLibrary flib; + FunctionLibraryDefinition flib_def((*graph)->op_registry(), flib); + return MarkForCompilation(graph, &flib_def); +} +} // namespace tensorflow diff --git a/tensorflow/compiler/jit/mark_for_compilation_pass_test_helper.h b/tensorflow/compiler/jit/mark_for_compilation_pass_test_helper.h new file mode 100644 index 0000000000..b9a0531cb0 --- /dev/null +++ b/tensorflow/compiler/jit/mark_for_compilation_pass_test_helper.h @@ -0,0 +1,35 @@ +/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#ifndef TENSORFLOW_COMPILER_JIT_MARK_FOR_COMPILATION_PASS_TEST_HELPER_H_ +#define TENSORFLOW_COMPILER_JIT_MARK_FOR_COMPILATION_PASS_TEST_HELPER_H_ + +#include "tensorflow/compiler/jit/mark_for_compilation_pass.h" + +namespace tensorflow { +class MarkForCompilationPassTestHelper { + public: + // Runs the MarkForCompilation pass on `graph` after assigning all nodes in + // `graph` to the CPU device. To make testing easier, ignores device + // registration, _XlaCompile attributes, input deadness and global jit level. + static Status MarkForCompilation(std::unique_ptr* graph, + FunctionLibraryDefinition* flib_def); + + // Like `MarkForCompilation` but creates `flib_def` from the op registry. + static Status MarkForCompilation(std::unique_ptr* graph); +}; +} // namespace tensorflow + +#endif // TENSORFLOW_COMPILER_JIT_MARK_FOR_COMPILATION_PASS_TEST_HELPER_H_ -- GitLab From 881f58d20cc159817eadefa6f8e1b7d87c85d01f Mon Sep 17 00:00:00 2001 From: Mark Heffernan Date: Mon, 13 Aug 2018 11:58:25 -0700 Subject: [PATCH 421/437] Enable arbitrary comments in HLO in both /*...*/ and // forms. Allow '/*...*/' and '//' comments to appear anywhere in HLO text, including multi-line comments. Previously only '/*...*/' comments were only allowed and only in certain locations in a serialized Literal. PiperOrigin-RevId: 208519204 --- tensorflow/compiler/xla/service/hlo_lexer.cc | 55 ++++++++++---- tensorflow/compiler/xla/service/hlo_lexer.h | 1 - tensorflow/compiler/xla/service/hlo_parser.cc | 1 - .../compiler/xla/service/hlo_parser_test.cc | 75 +++++++++++++++++++ tensorflow/compiler/xla/service/hlo_token.h | 1 - 5 files changed, 116 insertions(+), 17 deletions(-) diff --git a/tensorflow/compiler/xla/service/hlo_lexer.cc b/tensorflow/compiler/xla/service/hlo_lexer.cc index 71b44507cc..8e0d38b6a6 100644 --- a/tensorflow/compiler/xla/service/hlo_lexer.cc +++ b/tensorflow/compiler/xla/service/hlo_lexer.cc @@ -143,8 +143,47 @@ TokKind HloLexer::LexToken() { return TokKind::kLparen; case ')': return TokKind::kRparen; - case '/': - return LexComment(); + case '/': { + if (PeekCurrentChar() == '*') { + // This is the start of a /*...*/ delimited comment. Save the current + // location in case the comment is unterminated so the error message + // will point to the beginning of the comment. + const char* comment_start = current_ptr_; + current_ptr_++; + // Advance until '*/' is found. + while (true) { + int current = GetNextChar(); + if (current == '*' && PeekCurrentChar() == '/') { + // End of comment. + current_ptr_++; + break; + } + if (current == kEOF) { + // Unterminated comment. + current_ptr_ = comment_start; + return TokKind::kError; + } + } + // Return no token for the comment. Keep lexing. + continue; + } else if (PeekCurrentChar() == '/') { + // This is the start of a '//' delimited comment. Throw away + // everything until end of line or file. The end-of-line character(s) + // are left unlexed in the buffer which is harmless because these are + // skipped later by the lexer. This approach enables support for + // different end-of-line encodings. + while (true) { + int current = PeekCurrentChar(); + if (current == kEOF || current == '\n' || current == '\r') { + break; + } + current_ptr_++; + } + continue; + } + // A lone '/' is an error. + return TokKind::kError; + } case '"': return LexString(); } @@ -357,16 +396,6 @@ tensorflow::StringPiece HloLexer::GetLine(LocTy loc) const { return StringPieceFromPointers(start, end); } -TokKind HloLexer::LexComment() { - auto consumable = RegexpStringPieceFromPointers(token_start_, buf_.end()); - static LazyRE2 comment_pattern = {R"(\/\*.*?\*\/)"}; - if (RE2::Consume(&consumable, *comment_pattern)) { - current_ptr_ = consumable.begin(); - return TokKind::kComment; - } - return TokKind::kError; -} - // Lexes quoted string with escaping characters. If matched, the quoted string // will be unescaped and stored to str_val_. TokKind HloLexer::LexString() { @@ -412,8 +441,6 @@ string TokKindToString(TokKind kind) { return "kRparen"; case TokKind::kArrow: return "kArrow"; - case TokKind::kComment: - return "kComment"; case TokKind::kw_HloModule: return "kw_HloModule"; case TokKind::kw_ENTRY: diff --git a/tensorflow/compiler/xla/service/hlo_lexer.h b/tensorflow/compiler/xla/service/hlo_lexer.h index ceb674f25e..003ac34ace 100644 --- a/tensorflow/compiler/xla/service/hlo_lexer.h +++ b/tensorflow/compiler/xla/service/hlo_lexer.h @@ -105,7 +105,6 @@ class HloLexer { TokKind LexShape(); TokKind LexConstant(); TokKind LexNumberOrPattern(); - TokKind LexComment(); TokKind LexString(); const tensorflow::StringPiece buf_; diff --git a/tensorflow/compiler/xla/service/hlo_parser.cc b/tensorflow/compiler/xla/service/hlo_parser.cc index 2a8c6ecd92..4b3cd99dc0 100644 --- a/tensorflow/compiler/xla/service/hlo_parser.cc +++ b/tensorflow/compiler/xla/service/hlo_parser.cc @@ -1824,7 +1824,6 @@ bool HloParser::ParseDenseLiteral(std::unique_ptr* literal, break; } case TokKind::kComma: - case TokKind::kComment: // Skip. lexer_.Lex(); break; diff --git a/tensorflow/compiler/xla/service/hlo_parser_test.cc b/tensorflow/compiler/xla/service/hlo_parser_test.cc index 4cd21841f4..5990a3d478 100644 --- a/tensorflow/compiler/xla/service/hlo_parser_test.cc +++ b/tensorflow/compiler/xla/service/hlo_parser_test.cc @@ -1560,6 +1560,81 @@ ENTRY consts { "last"); } +TEST_F(HloParserTest, Comments) { + const string original = R"(/* module description. */ +HloModule comments: + +ENTRY /*comment*/ c1 { + /* blah */ + ROOT const1 = /*foo*/f32[1]{0} constant({12345 /*bar*/}) + /* comment */ +} + +/* something else */ + +)"; + auto module = ParseHloString(original); + TF_ASSERT_OK(module.status()); +} + +TEST_F(HloParserTest, MultilineComments) { + const string original = R"(HloModule multiline_comment: +ENTRY c1 { + /* + ROOT foo = f32[1]{0} constant({12345}) + */ + ROOT const1 = f32[1]{0} constant({12345}) +/* +a +b +c +d + +*/ +})"; + auto module = ParseHloString(original); + TF_ASSERT_OK(module.status()); +} + +TEST_F(HloParserTest, UnterminatedComment) { + const string original = R"(HloModule unterminated_comment: +ENTRY c1 { +/* unterminated + ROOT const1 = f32[1]{0} constant({12345}) +})"; + // Verify that the error message points to the beginning of the unterminated + // comment. + ExpectHasSubstr(ParseHloString(original).status().error_message(), + "/* unterminated\n^"); +} + +TEST_F(HloParserTest, SlashSlashComments) { + const string original = R"(HloModule slash_slash_comment: +// Garbage +ENTRY c1 { + // Foo bar + ROOT const1 = f32[1]{0} constant({12345}) // Something else +})"; + auto module = ParseHloString(original); + TF_ASSERT_OK(module.status()); +} + +TEST_F(HloParserTest, SlashSlashCommentMsDosEolFormat) { + const string original = + "HloModule slash_slash_comment:\r\n// Garbage\r\nENTRY c1 {\r\n// Foo " + "bar\r\nROOT const1 = f32[1]{0} constant({12345}) // Something else\r\n}"; + auto module = ParseHloString(original); + TF_ASSERT_OK(module.status()); +} + +TEST_F(HloParserTest, SlashSlashCommentMacEolFormat) { + const string original = + "HloModule slash_slash_comment:\r// Garbage\rENTRY c1 {\r// Foo " + "bar\rROOT const1 = f32[1]{0} constant({12345}) // Something else\r}"; + auto module = ParseHloString(original); + TF_ASSERT_OK(module.status()); +} + TEST_F(HloParserTest, MultipleEntries) { const string original = R"(HloModule multiple_entries: ENTRY c1 { diff --git a/tensorflow/compiler/xla/service/hlo_token.h b/tensorflow/compiler/xla/service/hlo_token.h index 533429608b..4458c251de 100644 --- a/tensorflow/compiler/xla/service/hlo_token.h +++ b/tensorflow/compiler/xla/service/hlo_token.h @@ -44,7 +44,6 @@ enum class TokKind { kRparen, // ( ) kArrow, // -> - kComment, // /*xxx*/ // Keywords kw_HloModule, -- GitLab From e9b3bf0dc4c62500bec91d6fd15c52d413cf5a8d Mon Sep 17 00:00:00 2001 From: Austin Anderson Date: Mon, 13 Aug 2018 12:02:04 -0700 Subject: [PATCH 422/437] Change to internal CI for depthwiseconv_quantized_test for iOS PiperOrigin-RevId: 208519851 --- tensorflow/contrib/lite/kernels/internal/BUILD | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tensorflow/contrib/lite/kernels/internal/BUILD b/tensorflow/contrib/lite/kernels/internal/BUILD index 87155e4ba4..a97db6c6b2 100644 --- a/tensorflow/contrib/lite/kernels/internal/BUILD +++ b/tensorflow/contrib/lite/kernels/internal/BUILD @@ -539,7 +539,10 @@ cc_test( cc_test( name = "depthwiseconv_quantized_test", srcs = ["depthwiseconv_quantized_test.cc"], - tags = ["no_oss"], + tags = [ + "no_oss", + "tflite_not_portable_ios", + ], deps = [ ":optimized_base", ":reference_base", -- GitLab From 35535e6313c7c35a851466efd67be0ec1df14c9e Mon Sep 17 00:00:00 2001 From: Eugene Brevdo Date: Mon, 13 Aug 2018 13:03:13 -0700 Subject: [PATCH 423/437] [tf.contrib.lookup] Clean up shape inference for lookup ops. More of the shape inference can be done in C++-land, which may help grappler do its thing. Also fix a bug where keys.dim_size(0) was being requested even when keys.dims() == 0 [this should probably lead to DCHECK failure, but doesn't seem to]. PiperOrigin-RevId: 208529368 --- tensorflow/contrib/lookup/lookup_ops.py | 33 ++--- tensorflow/contrib/lookup/lookup_ops_test.py | 11 +- tensorflow/core/kernels/lookup_table_op.cc | 11 +- tensorflow/core/ops/lookup_ops.cc | 139 +++++++++++++++++-- 4 files changed, 149 insertions(+), 45 deletions(-) diff --git a/tensorflow/contrib/lookup/lookup_ops.py b/tensorflow/contrib/lookup/lookup_ops.py index 4942d94176..8c0bfefb30 100644 --- a/tensorflow/contrib/lookup/lookup_ops.py +++ b/tensorflow/contrib/lookup/lookup_ops.py @@ -20,7 +20,6 @@ from __future__ import print_function from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops -from tensorflow.python.framework import tensor_shape from tensorflow.python.ops import gen_lookup_ops from tensorflow.python.ops import lookup_ops # pylint: disable=unused-import @@ -395,17 +394,12 @@ class MutableHashTable(LookupInterface): Raises: TypeError: when `keys` do not match the table data types. """ - if keys.dtype.base_dtype != self._key_dtype: - raise TypeError("Signature mismatch. Keys must be dtype %s, got %s." % - (self._key_dtype, keys.dtype)) - with ops.name_scope(name, "%s_lookup_table_find" % self._name, (self._table_ref, keys, self._default_value)) as name: + keys = ops.convert_to_tensor(keys, dtype=self._key_dtype, name="keys") with ops.colocate_with(self._table_ref): values = gen_lookup_ops.lookup_table_find_v2( self._table_ref, keys, self._default_value, name=name) - - values.set_shape(keys.get_shape().concatenate(self._value_shape)) return values def insert(self, keys, values, name=None): @@ -451,9 +445,6 @@ class MutableHashTable(LookupInterface): with ops.colocate_with(self._table_ref): exported_keys, exported_values = gen_lookup_ops.lookup_table_export_v2( self._table_ref, self._key_dtype, self._value_dtype, name=name) - - exported_values.set_shape(exported_keys.get_shape().concatenate( - self._value_shape)) return exported_keys, exported_values class _Saveable(BaseSaverBuilder.SaveableObject): @@ -537,14 +528,15 @@ class MutableDenseHashTable(LookupInterface): ValueError: If checkpoint is True and no name was specified. """ self._default_value = ops.convert_to_tensor( - default_value, dtype=value_dtype) + default_value, dtype=value_dtype, name="default_value") self._value_shape = self._default_value.get_shape() # The table must be shared if checkpointing is requested for multi-worker # training to work correctly. Use the node name if no shared_name has been # explicitly specified. use_node_name_sharing = checkpoint and shared_name is None - empty_key = ops.convert_to_tensor(empty_key, dtype=key_dtype) + empty_key = ops.convert_to_tensor( + empty_key, dtype=key_dtype, name="empty_key") self._table_ref = gen_lookup_ops.mutable_dense_hash_table_v2( empty_key=empty_key, shared_name=shared_name, @@ -591,20 +583,13 @@ class MutableDenseHashTable(LookupInterface): Raises: TypeError: when `keys` do not match the table data types. """ - if keys.dtype.base_dtype != self._key_dtype: - raise TypeError("Signature mismatch. Keys must be dtype %s, got %s." % - (self._key_dtype, keys.dtype)) - with ops.name_scope(name, "%s_lookup_table_find" % self._name, [self._table_ref, keys]) as name: + keys = ops.convert_to_tensor(keys, dtype=self._key_dtype, name="keys") with ops.colocate_with(self._table_ref): values = gen_lookup_ops.lookup_table_find_v2( self._table_ref, keys, self._default_value, name=name) - if keys.get_shape().ndims is not None and keys.get_shape().ndims > 0: - values.set_shape( - tensor_shape.TensorShape([keys.get_shape().dims[0]]).concatenate( - self._value_shape)) return values def insert(self, keys, values, name=None): @@ -624,11 +609,11 @@ class MutableDenseHashTable(LookupInterface): TypeError: when `keys` or `values` doesn't match the table data types. """ - # pylint: disable=protected-access - lookup_ops._check_table_dtypes(self, keys.dtype, values.dtype) - # pylint: enable=protected-access with ops.name_scope(name, "%s_lookup_table_insert" % self._name, [self._table_ref, keys, values]) as name: + keys = ops.convert_to_tensor(keys, dtype=self._key_dtype, name="keys") + values = ops.convert_to_tensor( + values, dtype=self._value_dtype, name="values") with ops.colocate_with(self._table_ref): op = gen_lookup_ops.lookup_table_insert_v2( self._table_ref, keys, values, name=name) @@ -650,8 +635,6 @@ class MutableDenseHashTable(LookupInterface): exported_keys, exported_values = gen_lookup_ops.lookup_table_export_v2( self._table_ref, self._key_dtype, self._value_dtype, name=name) - exported_values.set_shape(exported_keys.get_shape().concatenate( - self._value_shape)) return exported_keys, exported_values class _Saveable(BaseSaverBuilder.SaveableObject): diff --git a/tensorflow/contrib/lookup/lookup_ops_test.py b/tensorflow/contrib/lookup/lookup_ops_test.py index 8d510ede58..6fb5244fc6 100644 --- a/tensorflow/contrib/lookup/lookup_ops_test.py +++ b/tensorflow/contrib/lookup/lookup_ops_test.py @@ -434,8 +434,10 @@ class MutableHashTableOpTest(test.TestCase): self.assertAllEqual([[0, 1], [2, 3], [-1, -1]], result) exported_keys, exported_values = table.export() - self.assertAllEqual([None], exported_keys.get_shape().as_list()) - self.assertAllEqual([None, 2], exported_values.get_shape().as_list()) + self.assertAllEqual([None], exported_keys.get_shape().as_list(), + msg="Saw shape %s" % exported_keys.shape) + self.assertAllEqual([None, 2], exported_values.get_shape().as_list(), + msg="Saw shape %s" % exported_values.shape) # exported data is in the order of the internal map, i.e. undefined sorted_keys = np.sort(exported_keys.eval()) sorted_values = np.sort(exported_values.eval()) @@ -669,7 +671,7 @@ class MutableHashTableOpTest(test.TestCase): # lookup with keys of the wrong type input_string = constant_op.constant([1, 2, 3], dtypes.int64) - with self.assertRaises(TypeError): + with self.assertRaises(ValueError): table.lookup(input_string).eval() # default value of the wrong type @@ -853,7 +855,8 @@ class MutableDenseHashTableOpTest(test.TestCase): input_string = constant_op.constant([11, 12, 15], dtypes.int64) output = table.lookup(input_string) - self.assertAllEqual([3, 4], output.get_shape()) + self.assertAllEqual( + [3, 4], output.shape, msg="Saw shape: %s" % output.shape) result = output.eval() self.assertAllEqual([[0, 1, 2, 3], [3, 4, 5, 6], [-1, -2, -3, -4]], diff --git a/tensorflow/core/kernels/lookup_table_op.cc b/tensorflow/core/kernels/lookup_table_op.cc index 07e754a6ef..cbe8560267 100644 --- a/tensorflow/core/kernels/lookup_table_op.cc +++ b/tensorflow/core/kernels/lookup_table_op.cc @@ -341,7 +341,7 @@ class MutableDenseHashTable final : public LookupInterface { Status Find(OpKernelContext* ctx, const Tensor& key, Tensor* value, const Tensor& default_value) override LOCKS_EXCLUDED(mu_) { - const int64 num_elements = key.dim_size(0); + const int64 num_elements = (key.dims() == 0) ? 1 : key.dim_size(0); const int64 key_size = key_shape_.num_elements(); const int64 value_size = value_shape_.num_elements(); if (key.NumElements() != num_elements * key_size) { @@ -403,8 +403,9 @@ class MutableDenseHashTable final : public LookupInterface { Status Insert(OpKernelContext* ctx, const Tensor& key, const Tensor& value) override LOCKS_EXCLUDED(mu_) { - if (key.NumElements() != key.dim_size(0) * key_shape_.num_elements()) { - TensorShape expected_shape({key.dim_size(0)}); + const int64 batch_size = (key.dims() == 0) ? 1 : key.dim_size(0); + if (key.NumElements() != batch_size * key_shape_.num_elements()) { + TensorShape expected_shape({batch_size}); expected_shape.AppendShape(key_shape_); return errors::InvalidArgument("Expected key shape ", expected_shape.DebugString(), " got ", @@ -415,7 +416,7 @@ class MutableDenseHashTable final : public LookupInterface { // rather than updates. That means we may grow the table even though we // don't need to. As long as the number of keys inserted in one call is // small compared to the size of the map, the impact of this is minimal. - const int64 pending_num_entries = num_entries_ + key.dim_size(0); + const int64 pending_num_entries = num_entries_ + batch_size; if (pending_num_entries > num_buckets_ * max_load_factor_) { int64 new_num_buckets = num_buckets_; do { @@ -500,7 +501,7 @@ class MutableDenseHashTable final : public LookupInterface { private: Status DoInsert(OpKernelContext* ctx, const Tensor& key, const Tensor& value, bool ignore_empty_key) EXCLUSIVE_LOCKS_REQUIRED(mu_) { - const int64 num_elements = key.dim_size(0); + const int64 num_elements = (key.dims() == 0) ? 1 : key.dim_size(0); const int64 value_size = value_shape_.num_elements(); const int64 key_size = key_shape_.num_elements(); const auto key_matrix = key.shaped({num_elements, key_size}); diff --git a/tensorflow/core/ops/lookup_ops.cc b/tensorflow/core/ops/lookup_ops.cc index 2059741da9..7c71406c6b 100644 --- a/tensorflow/core/ops/lookup_ops.cc +++ b/tensorflow/core/ops/lookup_ops.cc @@ -23,6 +23,7 @@ namespace tensorflow { using shape_inference::DimensionHandle; using shape_inference::InferenceContext; +using shape_inference::ShapeAndType; using shape_inference::ShapeHandle; // -------------------------------------------------------------------------- @@ -86,6 +87,74 @@ REGISTER_OP("LookupTableFind") return Status::OK(); }); +Status ValidateTableResourceHandle(InferenceContext* c, ShapeHandle keys, + const string& key_dtype_attr, + const string& value_dtype_attr, + bool is_lookup, + ShapeAndType* output_shape_and_type) { + auto* handle_data = c->input_handle_shapes_and_types(0); + if (handle_data == nullptr || handle_data->size() != 2) { + output_shape_and_type->shape = c->UnknownShape(); + output_shape_and_type->dtype = DT_INVALID; + } else { + const ShapeAndType& key_shape_and_type = (*handle_data)[0]; + const ShapeAndType& value_shape_and_type = (*handle_data)[1]; + DataType key_dtype; + TF_RETURN_IF_ERROR(c->GetAttr(key_dtype_attr, &key_dtype)); + if (key_shape_and_type.dtype != key_dtype) { + return errors::InvalidArgument( + "Trying to read value with wrong dtype. " + "Expected ", + DataTypeString(key_shape_and_type.dtype), " got ", + DataTypeString(key_dtype)); + } + DataType value_dtype; + TF_RETURN_IF_ERROR(c->GetAttr(value_dtype_attr, &value_dtype)); + if (value_shape_and_type.dtype != value_dtype) { + return errors::InvalidArgument( + "Trying to read value with wrong dtype. " + "Expected ", + DataTypeString(value_shape_and_type.dtype), " got ", + DataTypeString(value_dtype)); + } + output_shape_and_type->dtype = value_shape_and_type.dtype; + + if (is_lookup) { + if (c->RankKnown(key_shape_and_type.shape) && c->RankKnown(keys)) { + int keys_rank = c->Rank(keys); + int key_suffix_rank = c->Rank(key_shape_and_type.shape); + if (keys_rank < key_suffix_rank) { + return errors::InvalidArgument( + "Expected keys to have suffix ", + c->DebugString(key_shape_and_type.shape), + " but saw shape: ", c->DebugString(keys)); + } + for (int d = 0; d < key_suffix_rank; d++) { + // Ensure the suffix of keys match what's in the Table. + DimensionHandle dim = c->Dim(key_shape_and_type.shape, d); + TF_RETURN_IF_ERROR( + c->ReplaceDim(keys, keys_rank - key_suffix_rank + d, dim, &keys)); + } + std::vector keys_prefix_vec; + keys_prefix_vec.reserve(keys_rank - key_suffix_rank); + for (int d = 0; d < keys_rank - key_suffix_rank; ++d) { + keys_prefix_vec.push_back(c->Dim(keys, d)); + } + ShapeHandle keys_prefix = c->MakeShape(keys_prefix_vec); + TF_RETURN_IF_ERROR(c->Concatenate(keys_prefix, + value_shape_and_type.shape, + &output_shape_and_type->shape)); + } else { + output_shape_and_type->shape = c->UnknownShape(); + } + } else { + TF_RETURN_IF_ERROR(c->Concatenate(keys, value_shape_and_type.shape, + &output_shape_and_type->shape)); + } + } + return Status::OK(); +} + REGISTER_OP("LookupTableFindV2") .Input("table_handle: resource") .Input("keys: Tin") @@ -98,9 +167,18 @@ REGISTER_OP("LookupTableFindV2") TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 0, &handle)); // Default value must be scalar or vector. - ShapeHandle unused; - TF_RETURN_IF_ERROR(c->WithRankAtMost(c->input(2), 1, &unused)); - c->set_output(0, c->UnknownShape()); + ShapeHandle keys; + TF_RETURN_IF_ERROR(c->WithRankAtMost(c->input(2), 1, &keys)); + + ShapeAndType value_shape_and_type; + TF_RETURN_IF_ERROR(ValidateTableResourceHandle( + c, + /*keys=*/c->input(1), + /*key_dtype_attr=*/"Tin", + /*value_dtype_attr=*/"Tout", + /*is_lookup=*/true, &value_shape_and_type)); + c->set_output(0, value_shape_and_type.shape); + return Status::OK(); }); WHITELIST_STATEFUL_OP_FOR_DATASET_FUNCTIONS("LookupTableFindV2"); @@ -177,12 +255,16 @@ REGISTER_OP("LookupTableExportV2") .SetShapeFn([](InferenceContext* c) { ShapeHandle handle; TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 0, &handle)); - - ShapeHandle values = c->UnknownShape(); - TF_RETURN_IF_ERROR(c->WithRankAtLeast(values, 1, &values)); - ShapeHandle keys = c->Vector(c->Dim(values, 0)); + ShapeHandle keys = c->UnknownShapeOfRank(1); + ShapeAndType value_shape_and_type; + TF_RETURN_IF_ERROR(ValidateTableResourceHandle( + c, + /*keys=*/keys, + /*key_dtype_attr=*/"Tkeys", + /*value_dtype_attr=*/"Tvalues", + /*is_lookup=*/false, &value_shape_and_type)); c->set_output(0, keys); - c->set_output(1, values); + c->set_output(1, value_shape_and_type.shape); return Status::OK(); }); @@ -216,6 +298,26 @@ REGISTER_OP("LookupTableImportV2") return Status::OK(); }); +Status MutableHashTableShape(InferenceContext* c, const ShapeHandle& key, + const ShapeHandle& value) { + c->set_output(0, c->Scalar()); + + ShapeHandle key_s; + TF_RETURN_IF_ERROR(c->WithRankAtMost(key, 1, &key_s)); + + DataType key_t; + TF_RETURN_IF_ERROR(c->GetAttr("key_dtype", &key_t)); + + DataType value_t; + TF_RETURN_IF_ERROR(c->GetAttr("value_dtype", &value_t)); + + // ShapeAndType vector for {key, value}. + c->set_output_handle_shapes_and_types( + 0, std::vector{{key_s, key_t}, {value, value_t}}); + + return Status::OK(); +} + REGISTER_OP("HashTable") .Output("table_handle: Ref(string)") .Attr("container: string = ''") @@ -254,7 +356,10 @@ REGISTER_OP("MutableHashTableV2") .Attr("key_dtype: type") .Attr("value_dtype: type") .SetIsStateful() - .SetShapeFn(ScalarOutput); + .SetShapeFn([](InferenceContext* c) { + return MutableHashTableShape(c, /*key=*/c->Scalar(), + /*value=*/c->Scalar()); + }); REGISTER_OP("MutableHashTableOfTensors") .Output("table_handle: Ref(string)") @@ -276,7 +381,13 @@ REGISTER_OP("MutableHashTableOfTensorsV2") .Attr("value_dtype: type") .Attr("value_shape: shape = {}") .SetIsStateful() - .SetShapeFn(ScalarOutput); + .SetShapeFn([](InferenceContext* c) { + PartialTensorShape value_p; + TF_RETURN_IF_ERROR(c->GetAttr("value_shape", &value_p)); + ShapeHandle value_s; + TF_RETURN_IF_ERROR(c->MakeShapeFromPartialTensorShape(value_p, &value_s)); + return MutableHashTableShape(c, /*key=*/c->Scalar(), /*value=*/value_s); + }); REGISTER_OP("MutableDenseHashTable") .Input("empty_key: key_dtype") @@ -304,7 +415,13 @@ REGISTER_OP("MutableDenseHashTableV2") .Attr("initial_num_buckets: int = 131072") // 2^17 .Attr("max_load_factor: float = 0.8") .SetIsStateful() - .SetShapeFn(ScalarOutput); + .SetShapeFn([](InferenceContext* c) { + PartialTensorShape value_p; + TF_RETURN_IF_ERROR(c->GetAttr("value_shape", &value_p)); + ShapeHandle value_s; + TF_RETURN_IF_ERROR(c->MakeShapeFromPartialTensorShape(value_p, &value_s)); + return MutableHashTableShape(c, /*key=*/c->input(0), /*value=*/value_s); + }); REGISTER_OP("InitializeTable") .Input("table_handle: Ref(string)") -- GitLab From de5c8358e831d050bd45d9eaaa1b186513c7ef85 Mon Sep 17 00:00:00 2001 From: Gunhan Gulsoy Date: Mon, 13 Aug 2018 13:58:27 -0700 Subject: [PATCH 424/437] Make dynamic kernels config setting publicly visible BUILD rule. PiperOrigin-RevId: 208538037 --- tensorflow/BUILD | 1 + 1 file changed, 1 insertion(+) diff --git a/tensorflow/BUILD b/tensorflow/BUILD index f8cd682024..56069041c2 100644 --- a/tensorflow/BUILD +++ b/tensorflow/BUILD @@ -387,6 +387,7 @@ config_setting( define_values = { "dynamic_loaded_kernels": "true", }, + visibility = ["//visibility:public"], ) config_setting( -- GitLab From ca2d8d8d6d9759aef41995a7b78aa1e660f99bd5 Mon Sep 17 00:00:00 2001 From: Pete Warden Date: Mon, 13 Aug 2018 14:59:32 -0700 Subject: [PATCH 425/437] Refactored lite makefile to centralize platform-specific settings PiperOrigin-RevId: 208548301 --- tensorflow/contrib/lite/rpi_makefile.inc | 33 ----- .../contrib/lite/{ => tools/make}/Makefile | 132 ++++++------------ .../make}/build_ios_universal_lib.sh | 18 +-- .../lite/{ => tools/make}/build_rpi_lib.sh | 4 +- .../{ => tools/make}/download_dependencies.sh | 4 +- .../{ => tools/make/targets}/ios_makefile.inc | 26 ++-- .../tools/make/targets/linux_makefile.inc | 10 ++ .../tools/make/targets/riscv_makefile.inc | 10 ++ .../lite/tools/make/targets/rpi_makefile.inc | 60 ++++++++ .../tools/make/targets/stm32f1_makefile.inc | 21 +++ .../tools/make/targets/stm32f7_makefile.inc | 41 ++++++ 11 files changed, 207 insertions(+), 152 deletions(-) delete mode 100644 tensorflow/contrib/lite/rpi_makefile.inc rename tensorflow/contrib/lite/{ => tools/make}/Makefile (69%) rename tensorflow/contrib/lite/{ => tools/make}/build_ios_universal_lib.sh (66%) rename tensorflow/contrib/lite/{ => tools/make}/build_rpi_lib.sh (90%) rename tensorflow/contrib/lite/{ => tools/make}/download_dependencies.sh (98%) rename tensorflow/contrib/lite/{ => tools/make/targets}/ios_makefile.inc (67%) create mode 100644 tensorflow/contrib/lite/tools/make/targets/linux_makefile.inc create mode 100644 tensorflow/contrib/lite/tools/make/targets/riscv_makefile.inc create mode 100644 tensorflow/contrib/lite/tools/make/targets/rpi_makefile.inc create mode 100644 tensorflow/contrib/lite/tools/make/targets/stm32f1_makefile.inc create mode 100644 tensorflow/contrib/lite/tools/make/targets/stm32f7_makefile.inc diff --git a/tensorflow/contrib/lite/rpi_makefile.inc b/tensorflow/contrib/lite/rpi_makefile.inc deleted file mode 100644 index 832ef5824b..0000000000 --- a/tensorflow/contrib/lite/rpi_makefile.inc +++ /dev/null @@ -1,33 +0,0 @@ -# Settings for Raspberry Pi. -ifeq ($(TARGET), RPI) - ifeq ($(TARGET_ARCH), armv7) - CXXFLAGS += \ - -march=armv7-a \ - -mfpu=neon-vfpv4 \ - -funsafe-math-optimizations \ - -ftree-vectorize - - CCFLAGS += \ - -march=armv7-a \ - -mfpu=neon-vfpv4 \ - -funsafe-math-optimizations \ - -ftree-vectorize - - LDFLAGS := \ - -Wl,--no-export-dynamic \ - -Wl,--exclude-libs,ALL \ - -Wl,--gc-sections \ - -Wl,--as-needed - endif - - LIBS := \ - -lstdc++ \ - -lpthread \ - -lm \ - -ldl - - OBJDIR := $(OBJDIR)rpi_$(TARGET_ARCH)/ - LIBDIR := $(LIBDIR)rpi_$(TARGET_ARCH)/ - BINDIR := $(BINDIR)rpi_$(TARGET_ARCH)/ - DEPDIR := $(DEPDIR)rpi_$(TARGET_ARCH)/ -endif diff --git a/tensorflow/contrib/lite/Makefile b/tensorflow/contrib/lite/tools/make/Makefile similarity index 69% rename from tensorflow/contrib/lite/Makefile rename to tensorflow/contrib/lite/tools/make/Makefile index 46e0e6a6d7..e30cc1d70e 100644 --- a/tensorflow/contrib/lite/Makefile +++ b/tensorflow/contrib/lite/tools/make/Makefile @@ -6,120 +6,74 @@ endif # Try to figure out the host system HOST_OS := ifeq ($(OS),Windows_NT) - HOST_OS = WINDOWS + HOST_OS = windows else UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Linux) - HOST_OS := LINUX + HOST_OS := linux endif ifeq ($(UNAME_S),Darwin) - HOST_OS := OSX + HOST_OS := osx endif endif HOST_ARCH := $(shell if [[ $(shell uname -m) =~ i[345678]86 ]]; then echo x86_32; else echo $(shell uname -m); fi) -# Self-hosting -TARGET_ARCH := ${HOST_ARCH} +# Override these on the make command line to target a specific architecture. For example: +# make -f tensorflow/contrib/lite/Makefile TARGET=rpi TARGET_ARCH=armv7l +TARGET := $(HOST_OS) +TARGET_ARCH := $(HOST_ARCH) -# Cross compiling -ifeq ($(CROSS),rpi) - TARGET_ARCH := armv7l - TARGET_TOOLCHAIN_PREFIX := arm-linux-gnueabihf- -endif - -ifeq ($(CROSS),riscv) - TARGET_ARCH := riscv - TARGET_TOOLCHAIN_PREFIX := riscv32-unknown-elf- -endif -ifeq ($(CROSS),stm32f7) - TARGET_ARCH := armf7 - TARGET_TOOLCHAIN_PREFIX := arm-none-eabi- -endif -ifeq ($(CROSS),stm32f1) - TARGET_ARCH := armm1 - TARGET_TOOLCHAIN_PREFIX := arm-none-eabi- -endif - -# Where compiled objects are stored. -OBJDIR := $(MAKEFILE_DIR)/gen/obj/ -BINDIR := $(MAKEFILE_DIR)/gen/bin/ -LIBDIR := $(MAKEFILE_DIR)/gen/lib/ -GENDIR := $(MAKEFILE_DIR)/gen/obj/ - -LIBS := -ifeq ($(TARGET_ARCH),x86_64) - CXXFLAGS += -fPIC -DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK -pthread # -msse4.2 -endif - -ifeq ($(TARGET_ARCH),armv7l) - CXXFLAGS += -mfpu=neon -pthread -fPIC - LIBS += -ldl -endif - -ifeq ($(TARGET_ARCH),riscv) -# CXXFLAGS += -march=gap8 - CXXFLAGS += -DTFLITE_MCU - LIBS += -ldl - BUILD_TYPE := micro -endif - -ifeq ($(TARGET_ARCH),armf7) - CXXFLAGS += -DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK -DTFLITE_MCU - CXXFLAGS += -fno-rtti -fmessage-length=0 -fno-exceptions -fno-builtin -ffunction-sections -fdata-sections - CXXFLAGS += -funsigned-char -MMD - CXXFLAGS += -mcpu=cortex-m7 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=softfp - CXXFLAGS += '-std=gnu++11' '-fno-rtti' '-Wvla' '-c' '-Wall' '-Wextra' '-Wno-unused-parameter' '-Wno-missing-field-initializers' '-fmessage-length=0' '-fno-exceptions' '-fno-builtin' '-ffunction-sections' '-fdata-sections' '-funsigned-char' '-MMD' '-fno-delete-null-pointer-checks' '-fomit-frame-pointer' '-Os' - LIBS += -ldl - BUILD_TYPE := micro -endif -ifeq ($(TARGET_ARCH),armm1) - CXXFLAGS += -DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK -mcpu=cortex-m1 -mthumb -DTFLITE_MCU - CXXFLAGS += -fno-rtti -fmessage-length=0 -fno-exceptions -fno-builtin -ffunction-sections -fdata-sections - CXXFLAGS += -funsigned-char -MMD - LIBS += -ldl -endif +# These are the default libraries needed, but they can be added to or +# overridden by the platform-specific settings in target makefiles. +LIBS := \ +-lstdc++ \ +-lpthread \ +-lm \ +-lz -# Settings for the host compiler. -CXX := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}g++ -CXXFLAGS += -O3 -DNDEBUG +# There are no rules for compiling objects for the host system (since we don't +# generate things like the protobuf compiler that require that), so all of +# these settings are for the target compiler. +CXXFLAGS := -O3 -DNDEBUG CCFLAGS := ${CXXFLAGS} CXXFLAGS += --std=c++11 -CC := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}gcc -AR := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}ar CFLAGS := -LDOPTS := -LDOPTS += -L/usr/local/lib +LDOPTS := -L/usr/local/lib ARFLAGS := -r +TARGET_TOOLCHAIN_PREFIX := +CC_PREFIX := + +# These target-specific makefiles should modify or replace options like +# CXXFLAGS or LIBS to work for a specific targetted architecture. All logic +# based on platforms or architectures should happen within these files, to +# keep this main makefile focused on the sources and dependencies. +include $(wildcard $(MAKEFILE_DIR)/targets/*_makefile.inc) + +# Where compiled objects are stored. +GENDIR := $(MAKEFILE_DIR)/gen/$(TARGET)_$(TARGET_ARCH)/ +OBJDIR := $(GENDIR)obj/ +BINDIR := $(GENDIR)bin/ +LIBDIR := $(GENDIR)lib/ INCLUDES := \ -I. \ --I$(MAKEFILE_DIR)/../../../ \ --I$(MAKEFILE_DIR)/../../../../ \ +-I$(MAKEFILE_DIR)/../../../../../ \ +-I$(MAKEFILE_DIR)/../../../../../../ \ -I$(MAKEFILE_DIR)/downloads/ \ -I$(MAKEFILE_DIR)/downloads/eigen \ -I$(MAKEFILE_DIR)/downloads/gemmlowp \ -I$(MAKEFILE_DIR)/downloads/neon_2_sse \ -I$(MAKEFILE_DIR)/downloads/farmhash/src \ -I$(MAKEFILE_DIR)/downloads/flatbuffers/include \ --I$(GENDIR) +-I$(OBJDIR) # This is at the end so any globally-installed frameworks like protobuf don't # override local versions in the source tree. INCLUDES += -I/usr/local/include -LIBS += \ --lstdc++ \ --lpthread \ --lm \ --lz - -# If we're on Linux, also link in the dl library. -ifeq ($(HOST_OS),LINUX) - LIBS += -ldl -endif - -include $(MAKEFILE_DIR)/ios_makefile.inc -include $(MAKEFILE_DIR)/rpi_makefile.inc +CXX := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}g++ +CC := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}gcc +AR := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}ar # This library is the main target for this makefile. It will contain a minimal # runtime that can be linked in to other programs. @@ -163,8 +117,8 @@ $(wildcard tensorflow/contrib/lite/kernels/*.c) \ $(wildcard tensorflow/contrib/lite/kernels/internal/*.c) \ $(wildcard tensorflow/contrib/lite/kernels/internal/optimized/*.c) \ $(wildcard tensorflow/contrib/lite/kernels/internal/reference/*.c) \ -$(wildcard tensorflow/contrib/lite/downloads/farmhash/src/farmhash.cc) \ -$(wildcard tensorflow/contrib/lite/downloads/fft2d/fftsg.c) +$(wildcard tensorflow/contrib/lite/tools/make/downloads/farmhash/src/farmhash.cc) \ +$(wildcard tensorflow/contrib/lite/tools/make/downloads/fft2d/fftsg.c) endif # Remove any duplicates. CORE_CC_ALL_SRCS := $(sort $(CORE_CC_ALL_SRCS)) @@ -179,10 +133,6 @@ ifeq ($(BUILD_TYPE),micro) CORE_CC_EXCLUDE_SRCS += \ tensorflow/contrib/lite/mmap_allocation.cc \ tensorflow/contrib/lite/nnapi_delegate.cc -else -CORE_CC_EXCLUDE_SRCS += \ -tensorflow/contrib/lite/mmap_allocation_disabled.cc \ -tensorflow/contrib/lite/nnapi_delegate_disabled.cc endif # Filter out all the excluded files. TF_LITE_CC_SRCS := $(filter-out $(CORE_CC_EXCLUDE_SRCS), $(CORE_CC_ALL_SRCS)) diff --git a/tensorflow/contrib/lite/build_ios_universal_lib.sh b/tensorflow/contrib/lite/tools/make/build_ios_universal_lib.sh similarity index 66% rename from tensorflow/contrib/lite/build_ios_universal_lib.sh rename to tensorflow/contrib/lite/tools/make/build_ios_universal_lib.sh index 31df43a175..fe056945a6 100755 --- a/tensorflow/contrib/lite/build_ios_universal_lib.sh +++ b/tensorflow/contrib/lite/tools/make/build_ios_universal_lib.sh @@ -17,23 +17,23 @@ set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -cd "$SCRIPT_DIR/../../.." +cd "$SCRIPT_DIR/../../../../.." # Build library for supported architectures and packs them in a fat binary. make_library() { for arch in x86_64 armv7 armv7s arm64 do - make -f tensorflow/contrib/lite/Makefile TARGET=IOS IOS_ARCH=${arch} \ - -j 8 \ - $SCRIPT_DIR/gen/lib/ios_${arch}/${1} + make -f tensorflow/contrib/lite/tools/make/Makefile TARGET=ios TARGET_ARCH=${arch} \ + -j 8 done + mkdir -p tensorflow/contrib/lite/tools/make/gen/lib lipo \ - tensorflow/contrib/lite/gen/lib/ios_x86_64/${1} \ - tensorflow/contrib/lite/gen/lib/ios_armv7/${1} \ - tensorflow/contrib/lite/gen/lib/ios_armv7s/${1} \ - tensorflow/contrib/lite/gen/lib/ios_arm64/${1} \ + tensorflow/contrib/lite/tools/make/gen/ios_x86_64/lib/${1} \ + tensorflow/contrib/lite/tools/make/gen/ios_armv7/lib/${1} \ + tensorflow/contrib/lite/tools/make/gen/ios_armv7s/lib/${1} \ + tensorflow/contrib/lite/tools/make/gen/ios_arm64/lib/${1} \ -create \ - -output tensorflow/contrib/lite/gen/lib/${1} + -output tensorflow/contrib/lite/tools/make/gen/lib/${1} } make_library libtensorflow-lite.a diff --git a/tensorflow/contrib/lite/build_rpi_lib.sh b/tensorflow/contrib/lite/tools/make/build_rpi_lib.sh similarity index 90% rename from tensorflow/contrib/lite/build_rpi_lib.sh rename to tensorflow/contrib/lite/tools/make/build_rpi_lib.sh index 3824b16412..24ecd4356d 100755 --- a/tensorflow/contrib/lite/build_rpi_lib.sh +++ b/tensorflow/contrib/lite/tools/make/build_rpi_lib.sh @@ -17,6 +17,6 @@ set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -cd "$SCRIPT_DIR/../../.." +cd "$SCRIPT_DIR/../../../../.." -CC_PREFIX=arm-linux-gnueabihf- make -j 3 -f tensorflow/contrib/lite/Makefile TARGET=RPI TARGET_ARCH=armv7 +CC_PREFIX=arm-linux-gnueabihf- make -j 3 -f tensorflow/contrib/lite/tools/make/Makefile TARGET=rpi TARGET_ARCH=armv7l diff --git a/tensorflow/contrib/lite/download_dependencies.sh b/tensorflow/contrib/lite/tools/make/download_dependencies.sh similarity index 98% rename from tensorflow/contrib/lite/download_dependencies.sh rename to tensorflow/contrib/lite/tools/make/download_dependencies.sh index 8c7df474d5..29afa45133 100755 --- a/tensorflow/contrib/lite/download_dependencies.sh +++ b/tensorflow/contrib/lite/tools/make/download_dependencies.sh @@ -17,9 +17,9 @@ set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -cd "$SCRIPT_DIR/../../.." +cd "$SCRIPT_DIR/../../../../.." -DOWNLOADS_DIR=tensorflow/contrib/lite/downloads +DOWNLOADS_DIR=tensorflow/contrib/lite/tools/make/downloads BZL_FILE_PATH=tensorflow/workspace.bzl # Ensure it is being run from repo root diff --git a/tensorflow/contrib/lite/ios_makefile.inc b/tensorflow/contrib/lite/tools/make/targets/ios_makefile.inc similarity index 67% rename from tensorflow/contrib/lite/ios_makefile.inc rename to tensorflow/contrib/lite/tools/make/targets/ios_makefile.inc index 079320586f..7f36b8ecef 100644 --- a/tensorflow/contrib/lite/ios_makefile.inc +++ b/tensorflow/contrib/lite/tools/make/targets/ios_makefile.inc @@ -1,11 +1,11 @@ # Settings for iOS. -ifeq ($(TARGET), IOS) - BUILD_FOR_IOS_SIMULATOR := false - ifeq ($(IOS_ARCH), x86_64) - BUILD_FOR_IOS_SIMULATOR := true +ifeq ($(TARGET), ios) + BUILD_FOR_IOS_SIMULATOR := false + ifeq ($(TARGET_ARCH), x86_64) + BUILD_FOR_IOS_SIMULATOR := true endif - ifeq ($(IOS_ARCH), i386) - BUILD_FOR_IOS_SIMULATOR := true + ifeq ($(TARGET_ARCH), i386) + BUILD_FOR_IOS_SIMULATOR := true endif ifeq ($(BUILD_FOR_IOS_SIMULATOR), true) IPHONEOS_PLATFORM := $(shell xcrun --sdk iphonesimulator \ @@ -18,8 +18,8 @@ ifeq ($(TARGET), IOS) endif IOS_SDK_VERSION := $(shell xcrun --sdk iphoneos --show-sdk-version) MIN_SDK_VERSION := 9.0 - # Override IOS_ARCH with armv7, armv7s, arm64, i386, or x86_64. - IOS_ARCH := x86_64 + # Override TARGET_ARCH with armv7, armv7s, arm64, i386, or x86_64. + TARGET_ARCH := x86_64 CXXFLAGS += -miphoneos-version-min=$(MIN_SDK_VERSION) \ -DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK \ -DTFLITE_USE_APPLE_ACCELERATE_FOR_CONV \ @@ -29,21 +29,17 @@ ifeq ($(TARGET), IOS) -fno-exceptions \ -isysroot \ ${IPHONEOS_SYSROOT} \ - -arch $(IOS_ARCH) \ + -arch $(TARGET_ARCH) \ -O3 CCFLAGS += -miphoneos-version-min=$(MIN_SDK_VERSION) \ -fembed-bitcode \ -mno-thumb \ -isysroot \ ${IPHONEOS_SYSROOT} \ - -arch $(IOS_ARCH) \ + -arch $(TARGET_ARCH) \ -O3 LDFLAGS := -fembed-bitcode \ -miphoneos-version-min=${MIN_SDK_VERSION} \ -framework Accelerate \ - -arch $(IOS_ARCH) - OBJDIR := $(OBJDIR)ios_$(IOS_ARCH)/ - LIBDIR := $(LIBDIR)ios_$(IOS_ARCH)/ - BINDIR := $(BINDIR)ios_$(IOS_ARCH)/ - DEPDIR := $(DEPDIR)ios_$(IOS_ARCH)/ + -arch $(TARGET_ARCH) endif diff --git a/tensorflow/contrib/lite/tools/make/targets/linux_makefile.inc b/tensorflow/contrib/lite/tools/make/targets/linux_makefile.inc new file mode 100644 index 0000000000..86499da99e --- /dev/null +++ b/tensorflow/contrib/lite/tools/make/targets/linux_makefile.inc @@ -0,0 +1,10 @@ +# Settings for Linux. +ifeq ($(TARGET), linux) + CXXFLAGS += \ + -fPIC \ + -DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK \ + -pthread + # TODO(petewarden): In the future we may want to add architecture-specific + # flags like -msse4.2 + LIBS += -ldl +endif diff --git a/tensorflow/contrib/lite/tools/make/targets/riscv_makefile.inc b/tensorflow/contrib/lite/tools/make/targets/riscv_makefile.inc new file mode 100644 index 0000000000..1a82afec33 --- /dev/null +++ b/tensorflow/contrib/lite/tools/make/targets/riscv_makefile.inc @@ -0,0 +1,10 @@ +# Settings for RiscV platforms. +ifeq ($(TARGET), riscv) + TARGET_ARCH := riscv + TARGET_TOOLCHAIN_PREFIX := riscv32-unknown-elf- + + #CXXFLAGS += -march=gap8 + CXXFLAGS += -DTFLITE_MCU + LIBS += -ldl + BUILD_TYPE := micro +endif diff --git a/tensorflow/contrib/lite/tools/make/targets/rpi_makefile.inc b/tensorflow/contrib/lite/tools/make/targets/rpi_makefile.inc new file mode 100644 index 0000000000..1ad0c50237 --- /dev/null +++ b/tensorflow/contrib/lite/tools/make/targets/rpi_makefile.inc @@ -0,0 +1,60 @@ +# Settings for Raspberry Pi. +ifeq ($(TARGET),rpi) + # Default to the architecture used on the Pi Two/Three (ArmV7), but override this + # with TARGET_ARCH=armv6 to build for the Pi Zero or One. + TARGET_ARCH := armv7l + TARGET_TOOLCHAIN_PREFIX := arm-linux-gnueabihf- + + ifeq ($(TARGET_ARCH), armv7l) + CXXFLAGS += \ + -march=armv7-a \ + -mfpu=neon-vfpv4 \ + -funsafe-math-optimizations \ + -ftree-vectorize \ + -fPIC + + CCFLAGS += \ + -march=armv7-a \ + -mfpu=neon-vfpv4 \ + -funsafe-math-optimizations \ + -ftree-vectorize \ + -fPIC + + LDFLAGS := \ + -Wl,--no-export-dynamic \ + -Wl,--exclude-libs,ALL \ + -Wl,--gc-sections \ + -Wl,--as-needed + endif + + # TODO(petewarden) In the future, we'll want to use OpenBLAS as a faster + # alternative to Eigen on non-NEON ARM hardware like armv6. + ifeq ($(TARGET_ARCH), armv6) + CXXFLAGS += \ + -march=armv6 \ + -mfpu=vfp \ + -funsafe-math-optimizations \ + -ftree-vectorize \ + -fPIC + + CCFLAGS += \ + -march=armv6 \ + -mfpu=vfp \ + -funsafe-math-optimizations \ + -ftree-vectorize \ + -fPIC + + LDFLAGS := \ + -Wl,--no-export-dynamic \ + -Wl,--exclude-libs,ALL \ + -Wl,--gc-sections \ + -Wl,--as-needed + endif + + LIBS := \ + -lstdc++ \ + -lpthread \ + -lm \ + -ldl + +endif diff --git a/tensorflow/contrib/lite/tools/make/targets/stm32f1_makefile.inc b/tensorflow/contrib/lite/tools/make/targets/stm32f1_makefile.inc new file mode 100644 index 0000000000..7418e4d196 --- /dev/null +++ b/tensorflow/contrib/lite/tools/make/targets/stm32f1_makefile.inc @@ -0,0 +1,21 @@ +# Settings for STM32F1 platforms. +ifeq ($(TARGET), stm32f1) + TARGET_ARCH := armm1 + TARGET_TOOLCHAIN_PREFIX := arm-none-eabi- + + CXXFLAGS += \ + -DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK \ + -mcpu=cortex-m1 \ + -mthumb \ + -DTFLITE_MCU \ + -fno-rtti \ + -fmessage-length=0 \ + -fno-exceptions \ + -fno-builtin \ + -ffunction-sections \ + -fdata-sections \ + -funsigned-char \ + -MMD + LIBS += -ldl + BUILD_TYPE := micro +endif diff --git a/tensorflow/contrib/lite/tools/make/targets/stm32f7_makefile.inc b/tensorflow/contrib/lite/tools/make/targets/stm32f7_makefile.inc new file mode 100644 index 0000000000..48af71e5b4 --- /dev/null +++ b/tensorflow/contrib/lite/tools/make/targets/stm32f7_makefile.inc @@ -0,0 +1,41 @@ +# Settings for STM32F7 platforms. +ifeq ($(TARGET), stm32f7) + TARGET_ARCH := armf7 + TARGET_TOOLCHAIN_PREFIX := arm-none-eabi- + + CXXFLAGS += \ + -DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK \ + -DTFLITE_MCU \ + -fno-rtti \ + -fmessage-length=0 \ + -fno-exceptions \ + -fno-builtin \ + -ffunction-sections \ + -fdata-sections \ + -funsigned-char \ + -MMD \ + -mcpu=cortex-m7 \ + -mthumb \ + -mfpu=fpv5-sp-d16 \ + -mfloat-abi=softfp \ + -std=gnu++11 \ + -fno-rtti \ + -Wvla \ + -c \ + -Wall \ + -Wextra \ + -Wno-unused-parameter \ + -Wno-missing-field-initializers \ + -fmessage-length=0 \ + -fno-exceptions \ + -fno-builtin \ + -ffunction-sections \ + -fdata-sections \ + -funsigned-char \ + -MMD \ + -fno-delete-null-pointer-checks \ + -fomit-frame-pointer \ + -Os + LIBS += -ldl + BUILD_TYPE := micro +endif -- GitLab From 61e2bbf55f514420ff5dc3770bf86eb1f9f0d821 Mon Sep 17 00:00:00 2001 From: Tim Shen Date: Mon, 13 Aug 2018 15:43:43 -0700 Subject: [PATCH 426/437] Automated rollback of commit 0b36ff79021b907f5447bfcbaa060dbdc2114c67 PiperOrigin-RevId: 208556290 --- .../xla/service/cpu/cpu_executable.cc | 38 +++++++++---------- .../compiler/xla/service/cpu/cpu_executable.h | 10 +++++ 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/tensorflow/compiler/xla/service/cpu/cpu_executable.cc b/tensorflow/compiler/xla/service/cpu/cpu_executable.cc index 946f5124b8..c376864c3e 100644 --- a/tensorflow/compiler/xla/service/cpu/cpu_executable.cc +++ b/tensorflow/compiler/xla/service/cpu/cpu_executable.cc @@ -249,24 +249,11 @@ StatusOr CpuExecutable::ExecuteOnStream( const ServiceExecutableRunOptions* run_options, tensorflow::gtl::ArraySlice arguments, HloExecutionProfile* hlo_execution_profile) { - if (GetRootPointsToSet().IsAmbiguous()) { - return Unimplemented("Points-to set of root instruction is ambiguous"); - } - - se::Stream* stream = run_options->stream(); - DeviceMemoryAllocator* memory_allocator = run_options->allocator(); - - std::vector owning_buffers; - std::vector unowning_buffers; TF_ASSIGN_OR_RETURN( - std::tie(unowning_buffers, owning_buffers), - CreateTempArray(memory_allocator, stream->parent()->device_ordinal(), - arguments)); - - TF_RETURN_IF_ERROR(ExecuteComputeFunction( - &run_options->run_options(), unowning_buffers, hlo_execution_profile)); - - return CreateResultShapedBuffer(run_options, &owning_buffers); + auto result, + ExecuteAsyncOnStreamImpl(run_options, arguments, hlo_execution_profile)); + TF_RETURN_IF_ERROR(run_options->stream()->BlockHostUntilDone()); + return std::move(result); } StatusOr CpuExecutable::ExecuteAsyncOnStream( @@ -277,6 +264,16 @@ StatusOr CpuExecutable::ExecuteAsyncOnStream( "Asynchronous execution on stream with hlo profiling is not yet " "supported on CPU."); } + return ExecuteAsyncOnStreamImpl(run_options, arguments, nullptr); +} + +StatusOr CpuExecutable::ExecuteAsyncOnStreamImpl( + const ServiceExecutableRunOptions* run_options, + tensorflow::gtl::ArraySlice arguments, + HloExecutionProfile* hlo_execution_profile) { + if (GetRootPointsToSet().IsAmbiguous()) { + return Unimplemented("Points-to set of root instruction is ambiguous"); + } auto* host_stream = dynamic_cast( run_options->stream()->implementation()); @@ -310,19 +307,20 @@ StatusOr CpuExecutable::ExecuteAsyncOnStream( ServiceExecutableRunOptions run_options; std::vector unowning_buffers; std::shared_ptr> buffers; + HloExecutionProfile* hlo_execution_profile; void operator()() { // Failing a CHECK here is not great, but I don't see an obvious way to // return a failed Status asynchronously. TF_CHECK_OK(executable->ExecuteComputeFunction( - &run_options.run_options(), unowning_buffers, - /*hlo_execution_profile=*/nullptr)); + &run_options.run_options(), unowning_buffers, hlo_execution_profile)); } }; host_stream->EnqueueTask( AsyncRunTask{this, *run_options, std::move(unowning_buffers), std::make_shared>( - std::move(owning_buffers))}); + std::move(owning_buffers)), + hlo_execution_profile}); return std::move(result); } diff --git a/tensorflow/compiler/xla/service/cpu/cpu_executable.h b/tensorflow/compiler/xla/service/cpu/cpu_executable.h index 8af8a5dfec..96e53de57e 100644 --- a/tensorflow/compiler/xla/service/cpu/cpu_executable.h +++ b/tensorflow/compiler/xla/service/cpu/cpu_executable.h @@ -85,6 +85,16 @@ class CpuExecutable : public Executable { const BufferAssignment& buffer_assignment() const { return *assignment_; } private: + // This is for sharing the code between ExecuteOnStream and + // ExecuteAsyncOnStream. + // + // Notice that it's tricky to use correctly, as the profile object (when it + // exists) must out-live the task. + StatusOr ExecuteAsyncOnStreamImpl( + const ServiceExecutableRunOptions* run_options, + tensorflow::gtl::ArraySlice arguments, + HloExecutionProfile* hlo_execution_profile); + // Creates an array suitable for passing as the "temps" argument to the JIT // compiled function pointer. // -- GitLab From fb0cc0e54ae2beba3cf5659a582684957e46d124 Mon Sep 17 00:00:00 2001 From: Misha Brukman Date: Mon, 13 Aug 2018 15:45:34 -0700 Subject: [PATCH 427/437] Add missing `override` annotation to make compiler happy Removes build-time compiler warnings due to overriding a member function without an explicit `override` marker due to `-Winconsistent-missing-override` directive. PiperOrigin-RevId: 208556615 --- tensorflow/core/common_runtime/collective_rma_local.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/core/common_runtime/collective_rma_local.h b/tensorflow/core/common_runtime/collective_rma_local.h index dbb2e67c7d..44408438b9 100644 --- a/tensorflow/core/common_runtime/collective_rma_local.h +++ b/tensorflow/core/common_runtime/collective_rma_local.h @@ -34,7 +34,7 @@ class CollectiveRemoteAccessLocal : public PerStepCollectiveRemoteAccess { virtual ~CollectiveRemoteAccessLocal() {} - void StartAbort(const Status& s); + void StartAbort(const Status& s) override; void RecvFromPeer(const string& peer_device, const string& peer_task, bool peer_is_local, const string& key, Device* to_device, -- GitLab From c527d67d21f4b1d778ca92d3c3478c381aba5fd6 Mon Sep 17 00:00:00 2001 From: Sanjoy Das Date: Mon, 13 Aug 2018 15:55:53 -0700 Subject: [PATCH 428/437] Implement reduce-window on F16 for XLA:CPU. PiperOrigin-RevId: 208558224 --- .../compiler/xla/service/cpu/ir_emitter.cc | 2 +- .../compiler/xla/tests/reduce_window_test.cc | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tensorflow/compiler/xla/service/cpu/ir_emitter.cc b/tensorflow/compiler/xla/service/cpu/ir_emitter.cc index d02d5beef2..6f433b4f30 100644 --- a/tensorflow/compiler/xla/service/cpu/ir_emitter.cc +++ b/tensorflow/compiler/xla/service/cpu/ir_emitter.cc @@ -577,7 +577,7 @@ Status IrEmitter::HandleReduceWindow(HloInstruction* reduce_window) { TF_RETURN_IF_ERROR(ElementTypesSameAndSupported( /*instruction=*/*reduce_window, /*operands=*/{reduce_window->operand(0)}, - /*supported_types=*/{F32, BF16, S32})); + /*supported_types=*/{F32, BF16, S32, F16})); // TODO(b/31410564): Implement dilation for reduce-window. if (window_util::HasDilation(reduce_window->window())) { diff --git a/tensorflow/compiler/xla/tests/reduce_window_test.cc b/tensorflow/compiler/xla/tests/reduce_window_test.cc index 73edad89dc..92c93f08b2 100644 --- a/tensorflow/compiler/xla/tests/reduce_window_test.cc +++ b/tensorflow/compiler/xla/tests/reduce_window_test.cc @@ -1464,5 +1464,24 @@ ENTRY %reduce-window (parameter.0: s32[81,8], parameter.1: s32[]) -> s32[82,8] { EXPECT_TRUE(RunAndCompare(hlo_string, tensorflow::gtl::nullopt)); } +XLA_TEST_F(HloTestBase, ReduceWindowF16) { + const string hlo_string = R"( +HloModule reduce-window + +%identity.pad_to_reduce_window (param0: f16[], param1: f16[]) -> f16[] { + %param0 = f16[] parameter(0) + ROOT %param1 = f16[] parameter(1) +} + +ENTRY %reduce-window (parameter.0: f16[81,8], parameter.1: f16[]) -> f16[82,8] { + %parameter.0 = f16[81,8]{1,0} parameter(0) + %parameter.1 = f16[] parameter(1) + ROOT %reduce-window = f16[82,8]{1,0} reduce-window(f16[81,8]{1,0} %parameter.0, f16[] %parameter.1), window={size=1x1 pad=0_1x0_0}, to_apply=%identity.pad_to_reduce_window +} + +)"; + EXPECT_TRUE(RunAndCompare(hlo_string, tensorflow::gtl::nullopt)); +} + } // namespace } // namespace xla -- GitLab From 83f1458ec1c19b3d46676ab543dff4ec401a0dd0 Mon Sep 17 00:00:00 2001 From: Jiri Simsa Date: Mon, 13 Aug 2018 16:07:17 -0700 Subject: [PATCH 429/437] [tf.data] Internal refactoring of C++ classes and APIs. - replacing `OpKernelContext` with newly introduced `DatasetContext` in `DatasetBase` constructor to make it possible to instantiate `DatasetBase` in places where an instance of `OpKernelContext` is not available - replacing `dataset::MakeIteratorContext(OpKernelContext* ctx)` factory with `IteratorContext(OpKernelContext *ctx)` constructor. - folding `GraphDatasetBase` into `DataseBase` and removing the default implementation of `AsGraphDefInternal`, making it the responsibility of the derived class to implement it to encourage/hint developers to provide serialization logic PiperOrigin-RevId: 208560010 --- .../bigtable/kernels/bigtable_kernels.cc | 11 +- .../kernels/bigtable_lookup_dataset_op.cc | 16 ++- .../kernels/bigtable_prefix_key_dataset_op.cc | 18 ++- .../kernels/bigtable_range_key_dataset_op.cc | 16 ++- .../bigtable_sample_key_pairs_dataset_op.cc | 14 +- .../bigtable_sample_keys_dataset_op.cc | 14 +- .../kernels/bigtable_scan_dataset_op.cc | 16 ++- .../data/kernels/assert_next_dataset_op.cc | 4 +- .../contrib/data/kernels/csv_dataset_op.cc | 4 +- .../kernels/directed_interleave_dataset_op.cc | 4 +- .../data/kernels/ignore_errors_dataset_op.cc | 4 +- .../data/kernels/prefetching_kernels.cc | 5 +- .../data/kernels/threadpool_dataset_op.cc | 11 +- .../contrib/data/kernels/unique_dataset_op.cc | 4 +- .../hadoop/kernels/hadoop_dataset_ops.cc | 7 +- .../kafka/kernels/kafka_dataset_ops.cc | 4 +- .../kinesis/kernels/kinesis_dataset_ops.cc | 4 +- tensorflow/core/framework/dataset.cc | 54 +++----- tensorflow/core/framework/dataset.h | 120 +++++++++--------- .../core/kernels/data/batch_dataset_op.cc | 4 +- .../core/kernels/data/cache_dataset_ops.cc | 10 +- .../kernels/data/concatenate_dataset_op.cc | 4 +- .../data/dense_to_sparse_batch_dataset_op.cc | 4 +- .../data/filter_by_component_dataset_op.cc | 4 +- .../core/kernels/data/filter_dataset_op.cc | 4 +- .../core/kernels/data/flat_map_dataset_op.cc | 4 +- .../core/kernels/data/generator_dataset_op.cc | 13 +- .../data/group_by_reducer_dataset_op.cc | 4 +- .../data/group_by_window_dataset_op.cc | 4 +- .../kernels/data/interleave_dataset_op.cc | 4 +- tensorflow/core/kernels/data/iterator_ops.cc | 28 ++-- .../kernels/data/map_and_batch_dataset_op.cc | 4 +- .../core/kernels/data/map_dataset_op.cc | 4 +- .../core/kernels/data/optimize_dataset_op.cc | 4 +- .../kernels/data/padded_batch_dataset_op.cc | 4 +- .../data/parallel_interleave_dataset_op.cc | 4 +- .../kernels/data/parallel_map_dataset_op.cc | 4 +- .../core/kernels/data/prefetch_dataset_op.cc | 6 +- .../core/kernels/data/random_dataset_op.cc | 4 +- .../core/kernels/data/range_dataset_op.cc | 7 +- .../core/kernels/data/reader_dataset_ops.cc | 12 +- .../core/kernels/data/repeat_dataset_op.cc | 4 +- .../core/kernels/data/scan_dataset_op.cc | 4 +- .../core/kernels/data/shuffle_dataset_op.cc | 4 +- .../core/kernels/data/skip_dataset_op.cc | 4 +- .../core/kernels/data/slide_dataset_op.cc | 4 +- .../data/sparse_tensor_slice_dataset_op.cc | 4 +- .../core/kernels/data/sql_dataset_ops.cc | 4 +- .../data/stats_aggregator_dataset_op.cc | 12 +- .../core/kernels/data/stats_dataset_ops.cc | 18 ++- .../core/kernels/data/take_dataset_op.cc | 4 +- .../core/kernels/data/tensor_dataset_op.cc | 4 +- .../kernels/data/tensor_queue_dataset_op.cc | 4 +- .../kernels/data/tensor_slice_dataset_op.cc | 4 +- .../core/kernels/data/unbatch_dataset_op.cc | 4 +- .../core/kernels/data/window_dataset.cc | 14 +- .../core/kernels/data/window_dataset_op.cc | 6 +- tensorflow/core/kernels/data/writer_ops.cc | 11 +- .../core/kernels/data/zip_dataset_op.cc | 4 +- 59 files changed, 333 insertions(+), 250 deletions(-) diff --git a/tensorflow/contrib/bigtable/kernels/bigtable_kernels.cc b/tensorflow/contrib/bigtable/kernels/bigtable_kernels.cc index 1790b4bc11..a25a641cdb 100644 --- a/tensorflow/contrib/bigtable/kernels/bigtable_kernels.cc +++ b/tensorflow/contrib/bigtable/kernels/bigtable_kernels.cc @@ -218,11 +218,11 @@ class ToBigtableOp : public AsyncOpKernel { OP_REQUIRES_OK_ASYNC( ctx, GetDatasetFromVariantTensor(ctx->input(1), &dataset), done); - IteratorContext iter_ctx = dataset::MakeIteratorContext(ctx); std::unique_ptr iterator; OP_REQUIRES_OK_ASYNC( ctx, - dataset->MakeIterator(&iter_ctx, "ToBigtableOpIterator", &iterator), + dataset->MakeIterator(IteratorContext(ctx), "ToBigtableOpIterator", + &iterator), done); int64 timestamp_int; @@ -245,9 +245,10 @@ class ToBigtableOp : public AsyncOpKernel { ::google::cloud::bigtable::BulkMutation mutation; // TODO(saeta): Make # of mutations configurable. for (uint64 i = 0; i < 100 && !end_of_sequence; ++i) { - OP_REQUIRES_OK_ASYNC( - ctx, iterator->GetNext(&iter_ctx, &components, &end_of_sequence), - done); + OP_REQUIRES_OK_ASYNC(ctx, + iterator->GetNext(IteratorContext(ctx), + &components, &end_of_sequence), + done); if (!end_of_sequence) { OP_REQUIRES_OK_ASYNC( ctx, diff --git a/tensorflow/contrib/bigtable/kernels/bigtable_lookup_dataset_op.cc b/tensorflow/contrib/bigtable/kernels/bigtable_lookup_dataset_op.cc index 9e49fa35db..bd32672aa9 100644 --- a/tensorflow/contrib/bigtable/kernels/bigtable_lookup_dataset_op.cc +++ b/tensorflow/contrib/bigtable/kernels/bigtable_lookup_dataset_op.cc @@ -53,7 +53,7 @@ class BigtableLookupDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: explicit Dataset(OpKernelContext* ctx, const DatasetBase* input, BigtableTableResource* table, @@ -61,7 +61,7 @@ class BigtableLookupDatasetOp : public UnaryDatasetOpKernel { std::vector columns, const DataTypeVector& output_types, std::vector output_shapes) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), input_(input), table_(table), column_families_(std::move(column_families)), @@ -80,8 +80,8 @@ class BigtableLookupDatasetOp : public UnaryDatasetOpKernel { std::unique_ptr MakeIteratorInternal( const string& prefix) const override { - return std::unique_ptr(new Iterator( - {this, strings::StrCat(prefix, "::BigtableLookupDataset")})); + return std::unique_ptr( + new Iterator({this, strings::StrCat(prefix, "::BigtableLookup")})); } const DataTypeVector& output_dtypes() const override { @@ -96,6 +96,14 @@ class BigtableLookupDatasetOp : public UnaryDatasetOpKernel { return "BigtableLookupDatasetOp::Dataset"; } + protected: + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, + Node** output) const override { + return errors::Unimplemented("%s does not support serialization", + DebugString()); + } + private: static ::google::cloud::bigtable::Filter MakeFilter( const std::vector& column_families, diff --git a/tensorflow/contrib/bigtable/kernels/bigtable_prefix_key_dataset_op.cc b/tensorflow/contrib/bigtable/kernels/bigtable_prefix_key_dataset_op.cc index e960719614..a803fdcb49 100644 --- a/tensorflow/contrib/bigtable/kernels/bigtable_prefix_key_dataset_op.cc +++ b/tensorflow/contrib/bigtable/kernels/bigtable_prefix_key_dataset_op.cc @@ -35,11 +35,13 @@ class BigtablePrefixKeyDatasetOp : public DatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: explicit Dataset(OpKernelContext* ctx, BigtableTableResource* table, string prefix) - : GraphDatasetBase(ctx), table_(table), prefix_(std::move(prefix)) { + : DatasetBase(DatasetContext(ctx)), + table_(table), + prefix_(std::move(prefix)) { table_->Ref(); } @@ -47,8 +49,8 @@ class BigtablePrefixKeyDatasetOp : public DatasetOpKernel { std::unique_ptr MakeIteratorInternal( const string& prefix) const override { - return std::unique_ptr(new Iterator( - {this, strings::StrCat(prefix, "::BigtablePrefixKeyDataset")})); + return std::unique_ptr( + new Iterator({this, strings::StrCat(prefix, "::BigtablePrefixKey")})); } const DataTypeVector& output_dtypes() const override { @@ -68,6 +70,14 @@ class BigtablePrefixKeyDatasetOp : public DatasetOpKernel { BigtableTableResource* table() const { return table_; } + protected: + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, + Node** output) const override { + return errors::Unimplemented("%s does not support serialization", + DebugString()); + } + private: class Iterator : public BigtableReaderDatasetIterator { public: diff --git a/tensorflow/contrib/bigtable/kernels/bigtable_range_key_dataset_op.cc b/tensorflow/contrib/bigtable/kernels/bigtable_range_key_dataset_op.cc index 96d3565d9b..5cd0371c79 100644 --- a/tensorflow/contrib/bigtable/kernels/bigtable_range_key_dataset_op.cc +++ b/tensorflow/contrib/bigtable/kernels/bigtable_range_key_dataset_op.cc @@ -39,11 +39,11 @@ class BigtableRangeKeyDatasetOp : public DatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: explicit Dataset(OpKernelContext* ctx, BigtableTableResource* table, string start_key, string end_key) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), table_(table), start_key_(std::move(start_key)), end_key_(std::move(end_key)) { @@ -54,8 +54,8 @@ class BigtableRangeKeyDatasetOp : public DatasetOpKernel { std::unique_ptr MakeIteratorInternal( const string& prefix) const override { - return std::unique_ptr(new Iterator( - {this, strings::StrCat(prefix, "::BigtableRangeKeyDataset")})); + return std::unique_ptr( + new Iterator({this, strings::StrCat(prefix, "::BigtableRangeKey")})); } const DataTypeVector& output_dtypes() const override { @@ -75,6 +75,14 @@ class BigtableRangeKeyDatasetOp : public DatasetOpKernel { BigtableTableResource* table() const { return table_; } + protected: + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, + Node** output) const override { + return errors::Unimplemented("%s does not support serialization", + DebugString()); + } + private: class Iterator : public BigtableReaderDatasetIterator { public: diff --git a/tensorflow/contrib/bigtable/kernels/bigtable_sample_key_pairs_dataset_op.cc b/tensorflow/contrib/bigtable/kernels/bigtable_sample_key_pairs_dataset_op.cc index a1a63a975a..6928d9423c 100644 --- a/tensorflow/contrib/bigtable/kernels/bigtable_sample_key_pairs_dataset_op.cc +++ b/tensorflow/contrib/bigtable/kernels/bigtable_sample_key_pairs_dataset_op.cc @@ -52,11 +52,11 @@ class BigtableSampleKeyPairsDatasetOp : public DatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: explicit Dataset(OpKernelContext* ctx, BigtableTableResource* table, string prefix, string start_key, string end_key) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), table_(table), key_range_(MakeMultiModeKeyRange( std::move(prefix), std::move(start_key), std::move(end_key))) { @@ -68,7 +68,7 @@ class BigtableSampleKeyPairsDatasetOp : public DatasetOpKernel { std::unique_ptr MakeIteratorInternal( const string& prefix) const override { return std::unique_ptr(new Iterator( - {this, strings::StrCat(prefix, "::BigtableSampleKeyPairsDataset")})); + {this, strings::StrCat(prefix, "::BigtableSampleKeyPairs")})); } const DataTypeVector& output_dtypes() const override { @@ -87,6 +87,14 @@ class BigtableSampleKeyPairsDatasetOp : public DatasetOpKernel { return "BigtableSampleKeyPairsDatasetOp::Dataset"; } + protected: + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, + Node** output) const override { + return errors::Unimplemented("%s does not support serialization", + DebugString()); + } + private: static MultiModeKeyRange MakeMultiModeKeyRange(string prefix, string start_key, diff --git a/tensorflow/contrib/bigtable/kernels/bigtable_sample_keys_dataset_op.cc b/tensorflow/contrib/bigtable/kernels/bigtable_sample_keys_dataset_op.cc index a5a47cfe2d..a759fb5063 100644 --- a/tensorflow/contrib/bigtable/kernels/bigtable_sample_keys_dataset_op.cc +++ b/tensorflow/contrib/bigtable/kernels/bigtable_sample_keys_dataset_op.cc @@ -31,10 +31,10 @@ class BigtableSampleKeysDatasetOp : public DatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: explicit Dataset(OpKernelContext* ctx, BigtableTableResource* table) - : GraphDatasetBase(ctx), table_(table) { + : DatasetBase(DatasetContext(ctx)), table_(table) { table_->Ref(); } @@ -43,7 +43,7 @@ class BigtableSampleKeysDatasetOp : public DatasetOpKernel { std::unique_ptr MakeIteratorInternal( const string& prefix) const override { return std::unique_ptr(new Iterator( - {this, strings::StrCat(prefix, "::BigtableSampleKeysDataset")})); + {this, strings::StrCat(prefix, "::BigtableSampleKeys")})); } const DataTypeVector& output_dtypes() const override { @@ -63,6 +63,14 @@ class BigtableSampleKeysDatasetOp : public DatasetOpKernel { BigtableTableResource* table() const { return table_; } + protected: + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, + Node** output) const override { + return errors::Unimplemented("%s does not support serialization", + DebugString()); + } + private: class Iterator : public DatasetIterator { public: diff --git a/tensorflow/contrib/bigtable/kernels/bigtable_scan_dataset_op.cc b/tensorflow/contrib/bigtable/kernels/bigtable_scan_dataset_op.cc index 13cb868167..78a920b077 100644 --- a/tensorflow/contrib/bigtable/kernels/bigtable_scan_dataset_op.cc +++ b/tensorflow/contrib/bigtable/kernels/bigtable_scan_dataset_op.cc @@ -84,7 +84,7 @@ class BigtableScanDatasetOp : public DatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: explicit Dataset(OpKernelContext* ctx, BigtableTableResource* table, string prefix, string start_key, string end_key, @@ -92,7 +92,7 @@ class BigtableScanDatasetOp : public DatasetOpKernel { std::vector columns, float probability, const DataTypeVector& output_types, std::vector output_shapes) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), table_(table), prefix_(std::move(prefix)), start_key_(std::move(start_key)), @@ -111,8 +111,8 @@ class BigtableScanDatasetOp : public DatasetOpKernel { std::unique_ptr MakeIteratorInternal( const string& prefix) const override { - return std::unique_ptr(new Iterator( - {this, strings::StrCat(prefix, "::BigtableScanDataset")})); + return std::unique_ptr( + new Iterator({this, strings::StrCat(prefix, "::BigtableScan")})); } const DataTypeVector& output_dtypes() const override { @@ -129,6 +129,14 @@ class BigtableScanDatasetOp : public DatasetOpKernel { BigtableTableResource* table() const { return table_; } + protected: + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, + Node** output) const override { + return errors::Unimplemented("%s does not support serialization", + DebugString()); + } + private: class Iterator : public BigtableReaderDatasetIterator { public: diff --git a/tensorflow/contrib/data/kernels/assert_next_dataset_op.cc b/tensorflow/contrib/data/kernels/assert_next_dataset_op.cc index bff6301250..e36c9c0634 100644 --- a/tensorflow/contrib/data/kernels/assert_next_dataset_op.cc +++ b/tensorflow/contrib/data/kernels/assert_next_dataset_op.cc @@ -42,13 +42,13 @@ class AssertNextDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, const DatasetBase* input, const std::vector& transformations, const DataTypeVector& output_types, const std::vector& output_shapes) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), input_(input), transformations_(transformations), output_types_(output_types), diff --git a/tensorflow/contrib/data/kernels/csv_dataset_op.cc b/tensorflow/contrib/data/kernels/csv_dataset_op.cc index 51e1b9aa65..d242cfdf49 100644 --- a/tensorflow/contrib/data/kernels/csv_dataset_op.cc +++ b/tensorflow/contrib/data/kernels/csv_dataset_op.cc @@ -131,7 +131,7 @@ class CSVDatasetOp : public DatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, std::vector filenames, bool header, string compression_type, io::ZlibCompressionOptions options, @@ -139,7 +139,7 @@ class CSVDatasetOp : public DatasetOpKernel { const std::vector& output_shapes, std::vector record_defaults, std::vector select_cols, bool use_quote_delim, char delim, string na_value) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), filenames_(std::move(filenames)), header_(header), out_type_(output_types), diff --git a/tensorflow/contrib/data/kernels/directed_interleave_dataset_op.cc b/tensorflow/contrib/data/kernels/directed_interleave_dataset_op.cc index b9306f611b..ccf7ec1f84 100644 --- a/tensorflow/contrib/data/kernels/directed_interleave_dataset_op.cc +++ b/tensorflow/contrib/data/kernels/directed_interleave_dataset_op.cc @@ -63,11 +63,11 @@ class DirectedInterleaveDatasetOp : public DatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, const DatasetBase* selector_input, std::vector data_inputs) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), selector_input_(selector_input), data_inputs_(std::move(data_inputs)) { selector_input_->Ref(); diff --git a/tensorflow/contrib/data/kernels/ignore_errors_dataset_op.cc b/tensorflow/contrib/data/kernels/ignore_errors_dataset_op.cc index d77beb8e10..db24e60846 100644 --- a/tensorflow/contrib/data/kernels/ignore_errors_dataset_op.cc +++ b/tensorflow/contrib/data/kernels/ignore_errors_dataset_op.cc @@ -35,10 +35,10 @@ class IgnoreErrorsDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: explicit Dataset(OpKernelContext* ctx, const DatasetBase* input) - : GraphDatasetBase(ctx), input_(input) { + : DatasetBase(DatasetContext(ctx)), input_(input) { input_->Ref(); } diff --git a/tensorflow/contrib/data/kernels/prefetching_kernels.cc b/tensorflow/contrib/data/kernels/prefetching_kernels.cc index 13bcd77b4a..74df1e42a8 100644 --- a/tensorflow/contrib/data/kernels/prefetching_kernels.cc +++ b/tensorflow/contrib/data/kernels/prefetching_kernels.cc @@ -929,10 +929,9 @@ class MultiDeviceIteratorInitOp : public OpKernel { LookupResource(ctx, HandleFromInput(ctx, 1), &resource)); core::ScopedUnref unref(resource); - IteratorContext iter_ctx = dataset::MakeIteratorContext(ctx); std::unique_ptr iterator; - OP_REQUIRES_OK(ctx, - dataset->MakeIterator(&iter_ctx, "Iterator", &iterator)); + OP_REQUIRES_OK(ctx, dataset->MakeIterator(IteratorContext(ctx), "Iterator", + &iterator)); int64 incarnation_id; OP_REQUIRES_OK(ctx, resource->Init(std::move(iterator), max_buffer_size, &incarnation_id)); diff --git a/tensorflow/contrib/data/kernels/threadpool_dataset_op.cc b/tensorflow/contrib/data/kernels/threadpool_dataset_op.cc index 4dc69dc2ef..ab584504a0 100644 --- a/tensorflow/contrib/data/kernels/threadpool_dataset_op.cc +++ b/tensorflow/contrib/data/kernels/threadpool_dataset_op.cc @@ -130,11 +130,13 @@ class ThreadPoolDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, const DatasetBase* input, ThreadPoolResource* threadpool) - : GraphDatasetBase(ctx), input_(input), threadpool_(threadpool) { + : DatasetBase(DatasetContext(ctx)), + input_(input), + threadpool_(threadpool) { input_->Ref(); threadpool_->Ref(); } @@ -165,9 +167,8 @@ class ThreadPoolDatasetOp : public UnaryDatasetOpKernel { Status AsGraphDefInternal(SerializationContext* ctx, DatasetGraphDefBuilder* b, Node** output) const override { - return errors::Unimplemented( - "Cannot currently serialize the thread pool for a " - "ThreadPoolDataset."); + return errors::Unimplemented("%s does not support serialization", + DebugString()); } private: diff --git a/tensorflow/contrib/data/kernels/unique_dataset_op.cc b/tensorflow/contrib/data/kernels/unique_dataset_op.cc index f6bfc982e9..6fbf5d2ebb 100644 --- a/tensorflow/contrib/data/kernels/unique_dataset_op.cc +++ b/tensorflow/contrib/data/kernels/unique_dataset_op.cc @@ -47,10 +47,10 @@ class UniqueDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, const DatasetBase* input) - : GraphDatasetBase(ctx), input_(input) { + : DatasetBase(DatasetContext(ctx)), input_(input) { input_->Ref(); } diff --git a/tensorflow/contrib/hadoop/kernels/hadoop_dataset_ops.cc b/tensorflow/contrib/hadoop/kernels/hadoop_dataset_ops.cc index b510994152..80b2d3e08b 100644 --- a/tensorflow/contrib/hadoop/kernels/hadoop_dataset_ops.cc +++ b/tensorflow/contrib/hadoop/kernels/hadoop_dataset_ops.cc @@ -204,11 +204,11 @@ class SequenceFileDatasetOp : public DatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, const std::vector& filenames, const DataTypeVector& output_types) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), filenames_(filenames), output_types_(output_types) {} @@ -233,7 +233,8 @@ class SequenceFileDatasetOp : public DatasetOpKernel { } protected: - Status AsGraphDefInternal(DatasetGraphDefBuilder* b, + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, Node** output) const override { Node* filenames = nullptr; TF_RETURN_IF_ERROR(b->AddVector(filenames_, &filenames)); diff --git a/tensorflow/contrib/kafka/kernels/kafka_dataset_ops.cc b/tensorflow/contrib/kafka/kernels/kafka_dataset_ops.cc index 92ae79d3c7..d0ea961473 100644 --- a/tensorflow/contrib/kafka/kernels/kafka_dataset_ops.cc +++ b/tensorflow/contrib/kafka/kernels/kafka_dataset_ops.cc @@ -52,12 +52,12 @@ class KafkaDatasetOp : public DatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, std::vector topics, const string& servers, const string& group, const bool eof, const int64 timeout) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), topics_(std::move(topics)), servers_(servers), group_(group), diff --git a/tensorflow/contrib/kinesis/kernels/kinesis_dataset_ops.cc b/tensorflow/contrib/kinesis/kernels/kinesis_dataset_ops.cc index 7b28bb5e4d..95c7001371 100644 --- a/tensorflow/contrib/kinesis/kernels/kinesis_dataset_ops.cc +++ b/tensorflow/contrib/kinesis/kernels/kinesis_dataset_ops.cc @@ -164,11 +164,11 @@ class KinesisDatasetOp : public DatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, const string& stream, const string& shard, const bool read_indefinitely, const int64 interval) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), stream_(stream), shard_(shard), read_indefinitely_(read_indefinitely), diff --git a/tensorflow/core/framework/dataset.cc b/tensorflow/core/framework/dataset.cc index e886ef7b8e..f3c7189292 100644 --- a/tensorflow/core/framework/dataset.cc +++ b/tensorflow/core/framework/dataset.cc @@ -74,18 +74,18 @@ class DatasetVariantWrapper { } // namespace Status GraphDefBuilderWrapper::AddDataset( - const GraphDatasetBase* dataset, + const DatasetBase* dataset, const std::vector>& inputs, const std::vector>>& list_inputs, const std::vector>& attrs, Node** output) { - const string& op_type_name = dataset->op_name(); + const string& name = dataset->name(); std::unique_ptr opts( new GraphDefBuilder::Options(b_->opts())); // TODO(srbs|mrry): Not all datasets have output_types and output_shapes // attributes defined. It will be nice to have a consistent pattern. - bool has_output_types_attr = HasAttr(op_type_name, "output_types"); - bool has_output_shapes_attr = HasAttr(op_type_name, "output_shapes"); + bool has_output_types_attr = HasAttr(name, "output_types"); + bool has_output_shapes_attr = HasAttr(name, "output_shapes"); if (has_output_shapes_attr) { opts.reset(new GraphDefBuilder::Options( opts->WithAttr("output_shapes", dataset->output_shapes()))); @@ -102,8 +102,7 @@ Status GraphDefBuilderWrapper::AddDataset( return errors::Internal("AddDataset: Failed to build Options with error ", opts->StatusToString()); } - NodeBuilder node_builder(opts->GetNameForOp(op_type_name), op_type_name, - opts->op_registry()); + NodeBuilder node_builder(opts->GetNameForOp(name), name, opts->op_registry()); { size_t total_size = inputs.size() + list_inputs.size(); auto inputs_iter = inputs.begin(); @@ -128,7 +127,7 @@ Status GraphDefBuilderWrapper::AddDataset( } *output = opts->FinalizeBuilder(&node_builder); if (*output == nullptr) { - return errors::Internal("AddDataset: Failed to build ", op_type_name, + return errors::Internal("AddDataset: Failed to build ", name, " op with error ", opts->StatusToString()); } return Status::OK(); @@ -184,27 +183,32 @@ void GraphDefBuilderWrapper::AddTensorInternal(const Tensor& val, b_->opts().WithAttr("dtype", val.dtype()).WithAttr("value", val)); } -bool GraphDefBuilderWrapper::HasAttr(const string& op_type_name, +bool GraphDefBuilderWrapper::HasAttr(const string& name, const string& attr_name) const { const OpDef* op_def = nullptr; - Status s = b_->opts().op_registry()->LookUpOpDef(op_type_name, &op_def); + Status s = b_->opts().op_registry()->LookUpOpDef(name, &op_def); if (!s.ok() || op_def == nullptr) { return false; } return HasAttr(op_def, attr_name); } -Status GraphDatasetBase::Serialize(SerializationContext* ctx, - string* serialized_graph_def, - string* output_node) const { +Status DatasetBase::Save(SerializationContext* ctx, + IteratorStateWriter* writer) const { + string serialized_graph_def; + string output_node; GraphDefBuilder b; DatasetGraphDefBuilder db(&b); Node* node = nullptr; TF_RETURN_IF_ERROR(AsGraphDefInternal(ctx, &db, &node)); - *output_node = node->name(); + output_node = node->name(); GraphDef graph_def; TF_RETURN_IF_ERROR(b.ToGraphDef(&graph_def)); - graph_def.SerializeToString(serialized_graph_def); + graph_def.SerializeToString(&serialized_graph_def); + TF_RETURN_IF_ERROR( + writer->WriteScalar(kDatasetGraphKey, serialized_graph_def)); + TF_RETURN_IF_ERROR( + writer->WriteScalar(kDatasetGraphOutputNodeKey, output_node)); return Status::OK(); } @@ -264,8 +268,8 @@ void BinaryDatasetOpKernel::MakeDataset(OpKernelContext* ctx, MakeDataset(ctx, input, another_input, output); } -const char GraphDatasetBase::kDatasetGraphKey[] = "_DATASET_GRAPH"; -const char GraphDatasetBase::kDatasetGraphOutputNodeKey[] = +const char DatasetBase::kDatasetGraphKey[] = "_DATASET_GRAPH"; +const char DatasetBase::kDatasetGraphOutputNodeKey[] = "_DATASET_GRAPH_OUTPUT_NODE"; BackgroundWorker::BackgroundWorker(Env* env, const string& name) { @@ -315,22 +319,4 @@ void BackgroundWorker::WorkerLoop() { } } -namespace dataset { - -IteratorContext MakeIteratorContext(OpKernelContext* ctx) { - IteratorContext::Params params; - params.env = ctx->env(); - params.runner = *(ctx->runner()); - params.lib = ctx->function_library(); - // Note: must use reinterpret_cast because function.h forward-declares Device. - DeviceBase* device = - reinterpret_cast(ctx->function_library()->device()); - params.allocator_getter = [device](AllocatorAttributes attrs) { - return device->GetAllocator(attrs); - }; - return IteratorContext(params); -} - -} // namespace dataset - } // namespace tensorflow diff --git a/tensorflow/core/framework/dataset.h b/tensorflow/core/framework/dataset.h index 66e836f9a6..e0c26d9286 100644 --- a/tensorflow/core/framework/dataset.h +++ b/tensorflow/core/framework/dataset.h @@ -40,6 +40,8 @@ limitations under the License. namespace tensorflow { +class DatasetBase; + // Interface for reading values from a key-value store. // Used for restoring iterator state. class IteratorStateReader { @@ -66,7 +68,6 @@ class IteratorStateWriter { // Forward declarations to avoid introducing a dependency on headers in // "tensorflow/core/graph/...". class GraphDefBuilder; -class GraphDatasetBase; class Node; // Wrapper around GraphDefBuilder. Used to serialize Dataset graph. @@ -120,7 +121,7 @@ class GraphDefBuilderWrapper { return Status::OK(); } - Status AddDataset(const GraphDatasetBase* dataset, + Status AddDataset(const DatasetBase* dataset, const std::vector& inputs, Node** output) { return AddDataset(dataset, inputs, {}, output); } @@ -133,7 +134,7 @@ class GraphDefBuilderWrapper { // `*output` contains a pointer to the output `Node`. It is guaranteed to be // non-null if the method returns with an OK status. // The returned Node pointer is owned by the backing Graph of GraphDefBuilder. - Status AddDataset(const GraphDatasetBase* dataset, + Status AddDataset(const DatasetBase* dataset, const std::vector& inputs, const std::vector>& attrs, Node** output) { @@ -145,7 +146,7 @@ class GraphDefBuilderWrapper { } Status AddDataset( - const GraphDatasetBase* dataset, + const DatasetBase* dataset, const std::vector>& inputs, const std::vector>>& list_inputs, const std::vector>& attrs, @@ -276,6 +277,19 @@ class IteratorContext { explicit IteratorContext(Params params) : params_(std::move(params)) {} + explicit IteratorContext(OpKernelContext* ctx) { + params_.env = ctx->env(); + params_.runner = *(ctx->runner()); + params_.lib = ctx->function_library(); + // NOTE: must use reinterpret_cast because function.h forward-declares + // Device. + DeviceBase* device = + reinterpret_cast(ctx->function_library()->device()); + params_.allocator_getter = [device](AllocatorAttributes attrs) { + return device->GetAllocator(attrs); + }; + } + Env* env() const { return params_.env; } std::function)>* runner() { @@ -355,6 +369,11 @@ class IteratorBase { virtual Status GetNext(IteratorContext* ctx, std::vector* out_tensors, bool* end_of_sequence) = 0; + Status GetNext(IteratorContext&& ctx, std::vector* out_tensors, + bool* end_of_sequence) { + return GetNext(&ctx, out_tensors, end_of_sequence); + } + // Returns a vector of DataType values, representing the respective // element types of each tuple component in the outputs of this // iterator. @@ -406,10 +425,40 @@ class IteratorBase { } }; +// Represents runtime information needed to construct a dataset. +class DatasetContext { + public: + struct Params { + string name; + }; + + explicit DatasetContext(Params params) : params_(std::move(params)) {} + + explicit DatasetContext(OpKernelContext* ctx) { + params_.name = ctx->op_kernel().type_string(); + } + + const string& name() const { return params_.name; } + + private: + Params params_; +}; + // Represents a (potentially infinite) range of outputs, where each // output is a tuple of tensors. class DatasetBase : public core::RefCounted { public: + // Key for storing the Dataset graph in the serialized format. + TF_EXPORT static const char kDatasetGraphKey[]; + + // Key for storing the output node of the Dataset graph in the serialized + // format. + TF_EXPORT static const char kDatasetGraphOutputNodeKey[]; + + explicit DatasetBase(DatasetContext&& ctx) : name_(ctx.name()) {} + + const string& name() const { return name_; } + // Returns a new iterator for iterating over the range of elements in // this dataset. // @@ -426,6 +475,11 @@ class DatasetBase : public core::RefCounted { return (*iterator)->Initialize(ctx); } + Status MakeIterator(IteratorContext&& ctx, const string& prefix, + std::unique_ptr* iterator) const { + return MakeIterator(&ctx, prefix, iterator); + } + // Returns a vector of DataType values, representing the respective // element types of each tuple component in the outputs of this // dataset. @@ -441,16 +495,9 @@ class DatasetBase : public core::RefCounted { // Serializes the dataset and writes it to the `writer`. virtual Status Save(SerializationContext* ctx, - IteratorStateWriter* writer) const { - return errors::Unimplemented("%s does not support serialization", - DebugString()); - } + IteratorStateWriter* writer) const; protected: - // TODO(srbs): Ideally all graph related logic should reside in - // GraphDatasetBase. However, that would require Datasets defined in all ops - // to derive from GraphDatasetBase. Once that is done we can move - // DatasetGraphDefBuilder and AsGraphDefInternal to GraphDatasetBase. class DatasetGraphDefBuilder : public GraphDefBuilderWrapper { public: DatasetGraphDefBuilder(GraphDefBuilder* b) : GraphDefBuilderWrapper(b) {} @@ -463,54 +510,15 @@ class DatasetBase : public core::RefCounted { // TODO(jsimsa): Consolidate overloading into a single method. virtual Status AsGraphDefInternal(SerializationContext* ctx, DatasetGraphDefBuilder* b, - Node** node) const { - return AsGraphDefInternal(b, node); - } - - virtual Status AsGraphDefInternal(DatasetGraphDefBuilder* b, - Node** node) const { - return errors::Unimplemented("%s does not support serialization", - DebugString()); - } + Node** node) const = 0; virtual std::unique_ptr MakeIteratorInternal( const string& prefix) const = 0; friend class DatasetToGraphOp; // For access to graph related members. -}; - -// Base-class for datasets that are built by ops. -class GraphDatasetBase : public DatasetBase { - public: - GraphDatasetBase(OpKernelContext* ctx) - : op_name_(ctx->op_kernel().type_string()) {} - - const string op_name() const { return op_name_; } - - Status Save(SerializationContext* ctx, - IteratorStateWriter* writer) const override { - string serialized_graph_def; - string output_node; - TF_RETURN_IF_ERROR(Serialize(ctx, &serialized_graph_def, &output_node)); - TF_RETURN_IF_ERROR( - writer->WriteScalar(kDatasetGraphKey, serialized_graph_def)); - TF_RETURN_IF_ERROR( - writer->WriteScalar(kDatasetGraphOutputNodeKey, output_node)); - return Status::OK(); - } - - // Key for storing the Dataset graph in the serialized format. - TF_EXPORT static const char kDatasetGraphKey[]; - - // Key for storing the output node of the Dataset graph in the serialized - // format. - TF_EXPORT static const char kDatasetGraphOutputNodeKey[]; private: - Status Serialize(SerializationContext* ctx, string* serialized_graph_def, - string* output_node) const; - - const string op_name_; + const string name_; }; // Represents an iterator that is associated with a particular dataset. @@ -718,12 +726,6 @@ class BackgroundWorker { std::deque> work_queue_ GUARDED_BY(mu_); }; -namespace dataset { - -IteratorContext MakeIteratorContext(OpKernelContext* ctx); - -} // namespace dataset - } // namespace tensorflow #endif // TENSORFLOW_CORE_FRAMEWORK_DATASET_H_ diff --git a/tensorflow/core/kernels/data/batch_dataset_op.cc b/tensorflow/core/kernels/data/batch_dataset_op.cc index 5295c9d2a6..f9b5353724 100644 --- a/tensorflow/core/kernels/data/batch_dataset_op.cc +++ b/tensorflow/core/kernels/data/batch_dataset_op.cc @@ -49,11 +49,11 @@ class BatchDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, int64 batch_size, bool drop_remainder, const DatasetBase* input) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), batch_size_(batch_size), drop_remainder_(drop_remainder), input_(input) { diff --git a/tensorflow/core/kernels/data/cache_dataset_ops.cc b/tensorflow/core/kernels/data/cache_dataset_ops.cc index 3762e403a9..6ca0bcd37d 100644 --- a/tensorflow/core/kernels/data/cache_dataset_ops.cc +++ b/tensorflow/core/kernels/data/cache_dataset_ops.cc @@ -46,11 +46,11 @@ class CacheDatasetOp : public UnaryDatasetOpKernel { } private: - class FileDataset : public GraphDatasetBase { + class FileDataset : public DatasetBase { public: explicit FileDataset(OpKernelContext* ctx, const DatasetBase* input, string filename, Env* env) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), input_(input), filename_(std::move(filename)), env_(env), @@ -539,10 +539,12 @@ class CacheDatasetOp : public UnaryDatasetOpKernel { const string tensor_format_string_; }; // FileDataset - class MemoryDataset : public GraphDatasetBase { + class MemoryDataset : public DatasetBase { public: explicit MemoryDataset(OpKernelContext* ctx, const DatasetBase* input) - : GraphDatasetBase(ctx), input_(input), cache_(new MemoryCache()) { + : DatasetBase(DatasetContext(ctx)), + input_(input), + cache_(new MemoryCache()) { input->Ref(); } diff --git a/tensorflow/core/kernels/data/concatenate_dataset_op.cc b/tensorflow/core/kernels/data/concatenate_dataset_op.cc index 6393005cdc..c361a9adcb 100644 --- a/tensorflow/core/kernels/data/concatenate_dataset_op.cc +++ b/tensorflow/core/kernels/data/concatenate_dataset_op.cc @@ -39,11 +39,11 @@ class ConcatenateDatasetOp : public BinaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: explicit Dataset(OpKernelContext* ctx, const DatasetBase* input, const DatasetBase* to_concatenate) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), input_(input), to_concatenate_(to_concatenate) { input_->Ref(); diff --git a/tensorflow/core/kernels/data/dense_to_sparse_batch_dataset_op.cc b/tensorflow/core/kernels/data/dense_to_sparse_batch_dataset_op.cc index 9105587cf4..9770bc025d 100644 --- a/tensorflow/core/kernels/data/dense_to_sparse_batch_dataset_op.cc +++ b/tensorflow/core/kernels/data/dense_to_sparse_batch_dataset_op.cc @@ -76,11 +76,11 @@ class DenseToSparseBatchDatasetOp : public UnaryDatasetOpKernel { private: // TODO(mrry): Push the templated code down to the raw copying routine. template - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, int64 batch_size, const PartialTensorShape& row_shape, const DatasetBase* input) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), batch_size_(batch_size), row_shape_(row_shape), input_(input) { diff --git a/tensorflow/core/kernels/data/filter_by_component_dataset_op.cc b/tensorflow/core/kernels/data/filter_by_component_dataset_op.cc index 4b6d808af0..ce577397c5 100644 --- a/tensorflow/core/kernels/data/filter_by_component_dataset_op.cc +++ b/tensorflow/core/kernels/data/filter_by_component_dataset_op.cc @@ -48,12 +48,12 @@ class FilterByLastComponentDatasetOp : public UnaryDatasetOpKernel { DataTypeVector output_types_; std::vector output_shapes_; - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, const DatasetBase* input, const DataTypeVector& output_types, std::vector output_shapes) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), input_(input), output_types_(output_types), output_shapes_(std::move(output_shapes)) { diff --git a/tensorflow/core/kernels/data/filter_dataset_op.cc b/tensorflow/core/kernels/data/filter_dataset_op.cc index b11d7cf2ef..a80e102ccf 100644 --- a/tensorflow/core/kernels/data/filter_dataset_op.cc +++ b/tensorflow/core/kernels/data/filter_dataset_op.cc @@ -79,12 +79,12 @@ class FilterDatasetOp : public UnaryDatasetOpKernel { private: const int graph_def_version_; - class FilterDatasetBase : public GraphDatasetBase { + class FilterDatasetBase : public DatasetBase { public: FilterDatasetBase(OpKernelContext* ctx, const DatasetBase* input, const NameAttrList& func, std::unique_ptr captured_func) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), input_(input), func_(func), captured_func_(std::move(captured_func)) { diff --git a/tensorflow/core/kernels/data/flat_map_dataset_op.cc b/tensorflow/core/kernels/data/flat_map_dataset_op.cc index 3419eed6c6..07bcb9d414 100644 --- a/tensorflow/core/kernels/data/flat_map_dataset_op.cc +++ b/tensorflow/core/kernels/data/flat_map_dataset_op.cc @@ -56,14 +56,14 @@ class FlatMapDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, const DatasetBase* input, const NameAttrList& func, std::unique_ptr captured_func, const DataTypeVector& output_types, const std::vector& output_shapes) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), input_(input), func_(func), captured_func_(std::move(captured_func)), diff --git a/tensorflow/core/kernels/data/generator_dataset_op.cc b/tensorflow/core/kernels/data/generator_dataset_op.cc index c4dd849b8b..3c3d78b724 100644 --- a/tensorflow/core/kernels/data/generator_dataset_op.cc +++ b/tensorflow/core/kernels/data/generator_dataset_op.cc @@ -26,14 +26,14 @@ namespace tensorflow { // See documentation in ../ops/dataset_ops.cc for a high-level // description of the following op. -class GeneratorDatasetOp::Dataset : public GraphDatasetBase { +class GeneratorDatasetOp::Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, std::unique_ptr init_func, std::unique_ptr next_func, std::unique_ptr finalize_func, const DataTypeVector& output_types, const std::vector& output_shapes) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), init_func_(std::move(init_func)), next_func_(std::move(next_func)), finalize_func_(std::move(finalize_func)), @@ -47,12 +47,21 @@ class GeneratorDatasetOp::Dataset : public GraphDatasetBase { } const DataTypeVector& output_dtypes() const override { return output_types_; } + const std::vector& output_shapes() const override { return output_shapes_; } string DebugString() const override { return "GeneratorDatasetOp::Dataset"; } + protected: + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, + Node** output) const override { + return errors::Unimplemented("%s does not support serialization", + DebugString()); + } + private: class Iterator : public DatasetIterator { public: diff --git a/tensorflow/core/kernels/data/group_by_reducer_dataset_op.cc b/tensorflow/core/kernels/data/group_by_reducer_dataset_op.cc index bcf0adacc7..be4132a064 100644 --- a/tensorflow/core/kernels/data/group_by_reducer_dataset_op.cc +++ b/tensorflow/core/kernels/data/group_by_reducer_dataset_op.cc @@ -66,7 +66,7 @@ class GroupByReducerDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, const DatasetBase* input, std::unique_ptr captured_key_func, @@ -75,7 +75,7 @@ class GroupByReducerDatasetOp : public UnaryDatasetOpKernel { std::unique_ptr captured_finalize_func, const DataTypeVector& output_types, const std::vector& output_shapes) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), input_(input), captured_key_func_(std::move(captured_key_func)), captured_init_func_(std::move(captured_init_func)), diff --git a/tensorflow/core/kernels/data/group_by_window_dataset_op.cc b/tensorflow/core/kernels/data/group_by_window_dataset_op.cc index 683a50e71c..288695f3cd 100644 --- a/tensorflow/core/kernels/data/group_by_window_dataset_op.cc +++ b/tensorflow/core/kernels/data/group_by_window_dataset_op.cc @@ -93,7 +93,7 @@ class GroupByWindowDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, const DatasetBase* input, const NameAttrList& key_func, const NameAttrList& reduce_func, @@ -103,7 +103,7 @@ class GroupByWindowDatasetOp : public UnaryDatasetOpKernel { std::unique_ptr captured_window_size_func, const DataTypeVector& output_types, const std::vector& output_shapes) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), input_(input), key_func_(key_func), reduce_func_(reduce_func), diff --git a/tensorflow/core/kernels/data/interleave_dataset_op.cc b/tensorflow/core/kernels/data/interleave_dataset_op.cc index 8fee29d4d0..58b79d6026 100644 --- a/tensorflow/core/kernels/data/interleave_dataset_op.cc +++ b/tensorflow/core/kernels/data/interleave_dataset_op.cc @@ -76,14 +76,14 @@ class InterleaveDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, const DatasetBase* input, const NameAttrList& func, std::unique_ptr captured_func, int64 cycle_length, int64 block_length, const DataTypeVector& output_types, const std::vector& output_shapes) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), input_(input), func_(func), captured_func_(std::move(captured_func)), diff --git a/tensorflow/core/kernels/data/iterator_ops.cc b/tensorflow/core/kernels/data/iterator_ops.cc index da9d29dd76..61a6c06135 100644 --- a/tensorflow/core/kernels/data/iterator_ops.cc +++ b/tensorflow/core/kernels/data/iterator_ops.cc @@ -130,7 +130,7 @@ class IteratorResource : public ResourceBase { Status Restore(OpKernelContext* ctx, IteratorStateReader* reader) { string serialized_graph_def; - TF_RETURN_IF_ERROR(reader->ReadScalar(GraphDatasetBase::kDatasetGraphKey, + TF_RETURN_IF_ERROR(reader->ReadScalar(DatasetBase::kDatasetGraphKey, &serialized_graph_def)); GraphDef graph_def; if (!graph_def.ParseFromString(serialized_graph_def)) { @@ -138,7 +138,7 @@ class IteratorResource : public ResourceBase { } string output_node; TF_RETURN_IF_ERROR(reader->ReadScalar( - GraphDatasetBase::kDatasetGraphOutputNodeKey, &output_node)); + DatasetBase::kDatasetGraphOutputNodeKey, &output_node)); DatasetBase* dataset = nullptr; Graph graph(OpRegistry::Global()); TF_RETURN_IF_ERROR(ImportGraphDef({}, graph_def, &graph, nullptr)); @@ -161,9 +161,9 @@ class IteratorResource : public ResourceBase { graph_runner.Run(&graph, lib, {}, {output_node}, &outputs)); TF_RETURN_IF_ERROR(GetDatasetFromVariantTensor(outputs[0], &dataset)); - IteratorContext iter_ctx = dataset::MakeIteratorContext(ctx); std::unique_ptr iterator; - TF_RETURN_IF_ERROR(dataset->MakeIterator(&iter_ctx, "Iterator", &iterator)); + TF_RETURN_IF_ERROR( + dataset->MakeIterator(IteratorContext(ctx), "Iterator", &iterator)); TF_RETURN_IF_ERROR(set_iterator(std::move(iterator))); std::shared_ptr captured_iterator(iterator_); @@ -611,9 +611,9 @@ void MakeIteratorOp::Compute(OpKernelContext* ctx) { ctx, LookupResource(ctx, HandleFromInput(ctx, 1), &iterator_resource)); core::ScopedUnref unref(iterator_resource); - IteratorContext iter_ctx = dataset::MakeIteratorContext(ctx); std::unique_ptr iterator; - OP_REQUIRES_OK(ctx, dataset->MakeIterator(&iter_ctx, "Iterator", &iterator)); + OP_REQUIRES_OK( + ctx, dataset->MakeIterator(IteratorContext(ctx), "Iterator", &iterator)); OP_REQUIRES_OK(ctx, iterator_resource->set_iterator(std::move(iterator))); } @@ -633,11 +633,11 @@ class ToSingleElementOp : public AsyncOpKernel { DatasetBase* dataset; OP_REQUIRES_OK_ASYNC( ctx, GetDatasetFromVariantTensor(ctx->input(0), &dataset), done); - IteratorContext iter_ctx = dataset::MakeIteratorContext(ctx); std::unique_ptr iterator; OP_REQUIRES_OK_ASYNC( ctx, - dataset->MakeIterator(&iter_ctx, "SingleElementIterator", &iterator), + dataset->MakeIterator(IteratorContext(ctx), "SingleElementIterator", + &iterator), done); // NOTE(jsimsa): We must destroy the iterator before calling `done()`, to @@ -651,8 +651,8 @@ class ToSingleElementOp : public AsyncOpKernel { components.reserve(dataset->output_dtypes().size()); bool end_of_sequence = false; - Status s = - raw_iterator->GetNext(&iter_ctx, &components, &end_of_sequence); + Status s = raw_iterator->GetNext(IteratorContext(ctx), &components, + &end_of_sequence); if (!s.ok()) { ctx->SetStatus(s); return; @@ -667,8 +667,8 @@ class ToSingleElementOp : public AsyncOpKernel { } components.clear(); - Status s2 = - raw_iterator->GetNext(&iter_ctx, &components, &end_of_sequence); + Status s2 = raw_iterator->GetNext(IteratorContext(ctx), &components, + &end_of_sequence); if (!s2.ok()) { ctx->SetStatus(s2); return; @@ -836,9 +836,9 @@ class OneShotIteratorOp : public AsyncOpKernel { // factory function. DatasetBase* dataset; TF_RETURN_IF_ERROR(GetDatasetFromVariantTensor(return_values[0], &dataset)); - IteratorContext iter_ctx = dataset::MakeIteratorContext(ctx); std::unique_ptr iter; - TF_RETURN_IF_ERROR(dataset->MakeIterator(&iter_ctx, "Iterator", &iter)); + TF_RETURN_IF_ERROR( + dataset->MakeIterator(IteratorContext(ctx), "Iterator", &iter)); TF_RETURN_IF_ERROR((*iterator)->set_iterator(std::move(iter))); (*iterator)->Ref(); diff --git a/tensorflow/core/kernels/data/map_and_batch_dataset_op.cc b/tensorflow/core/kernels/data/map_and_batch_dataset_op.cc index 51a7fd23a8..0e17011b05 100644 --- a/tensorflow/core/kernels/data/map_and_batch_dataset_op.cc +++ b/tensorflow/core/kernels/data/map_and_batch_dataset_op.cc @@ -101,7 +101,7 @@ class MapAndBatchDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, const DatasetBase* input, int64 batch_size, int64 num_parallel_calls, bool drop_remainder, @@ -110,7 +110,7 @@ class MapAndBatchDatasetOp : public UnaryDatasetOpKernel { const NameAttrList& func, std::unique_ptr captured_func, const Eigen::ThreadPoolDevice* device) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), input_(input), batch_size_(batch_size), num_parallel_calls_(num_parallel_calls), diff --git a/tensorflow/core/kernels/data/map_dataset_op.cc b/tensorflow/core/kernels/data/map_dataset_op.cc index ec9e12453b..294fb1c49a 100644 --- a/tensorflow/core/kernels/data/map_dataset_op.cc +++ b/tensorflow/core/kernels/data/map_dataset_op.cc @@ -55,14 +55,14 @@ class MapDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, const DatasetBase* input, const NameAttrList& func, std::unique_ptr captured_func, const DataTypeVector& output_types, const std::vector& output_shapes) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), input_(input), func_(func), captured_func_(std::move(captured_func)), diff --git a/tensorflow/core/kernels/data/optimize_dataset_op.cc b/tensorflow/core/kernels/data/optimize_dataset_op.cc index 8add049123..b097598cd9 100644 --- a/tensorflow/core/kernels/data/optimize_dataset_op.cc +++ b/tensorflow/core/kernels/data/optimize_dataset_op.cc @@ -59,13 +59,13 @@ class OptimizeDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, const DatasetBase* input, const std::vector& optimizations, const DataTypeVector& output_types, const std::vector& output_shapes) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), input_(input), optimizations_(optimizations), output_types_(output_types), diff --git a/tensorflow/core/kernels/data/padded_batch_dataset_op.cc b/tensorflow/core/kernels/data/padded_batch_dataset_op.cc index 755d46dac2..be45eac46e 100644 --- a/tensorflow/core/kernels/data/padded_batch_dataset_op.cc +++ b/tensorflow/core/kernels/data/padded_batch_dataset_op.cc @@ -98,12 +98,12 @@ class PaddedBatchDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, int64 batch_size, bool drop_remainder, std::vector padded_shapes, std::vector padding_values, const DatasetBase* input) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), batch_size_(batch_size), drop_remainder_(drop_remainder), padded_shapes_(std::move(padded_shapes)), diff --git a/tensorflow/core/kernels/data/parallel_interleave_dataset_op.cc b/tensorflow/core/kernels/data/parallel_interleave_dataset_op.cc index d2b83f9eab..e492a8215a 100644 --- a/tensorflow/core/kernels/data/parallel_interleave_dataset_op.cc +++ b/tensorflow/core/kernels/data/parallel_interleave_dataset_op.cc @@ -92,7 +92,7 @@ class ParallelInterleaveDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, const DatasetBase* input, const NameAttrList& func, @@ -100,7 +100,7 @@ class ParallelInterleaveDatasetOp : public UnaryDatasetOpKernel { int64 block_length, bool sloppy, int64 buffer_output_elements, int64 prefetch_input_elements, const DataTypeVector& output_types, const std::vector& output_shapes) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), input_(input), interleave_func_(func), captured_func_(std::move(captured_func)), diff --git a/tensorflow/core/kernels/data/parallel_map_dataset_op.cc b/tensorflow/core/kernels/data/parallel_map_dataset_op.cc index c56a7ea808..a407abfce4 100644 --- a/tensorflow/core/kernels/data/parallel_map_dataset_op.cc +++ b/tensorflow/core/kernels/data/parallel_map_dataset_op.cc @@ -67,14 +67,14 @@ class ParallelMapDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, const DatasetBase* input, const NameAttrList& func, int32 num_parallel_calls, const DataTypeVector& output_types, const std::vector& output_shapes, std::unique_ptr captured_func) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), input_(input), func_(func), num_parallel_calls_(num_parallel_calls), diff --git a/tensorflow/core/kernels/data/prefetch_dataset_op.cc b/tensorflow/core/kernels/data/prefetch_dataset_op.cc index 20148a4378..50efbcbe2a 100644 --- a/tensorflow/core/kernels/data/prefetch_dataset_op.cc +++ b/tensorflow/core/kernels/data/prefetch_dataset_op.cc @@ -25,10 +25,12 @@ namespace tensorflow { // See documentation in ../ops/dataset_ops.cc for a high-level // description of the following op. -class PrefetchDatasetOp::Dataset : public GraphDatasetBase { +class PrefetchDatasetOp::Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, const DatasetBase* input, int64 buffer_size) - : GraphDatasetBase(ctx), input_(input), buffer_size_(buffer_size) { + : DatasetBase(DatasetContext(ctx)), + input_(input), + buffer_size_(buffer_size) { input_->Ref(); } diff --git a/tensorflow/core/kernels/data/random_dataset_op.cc b/tensorflow/core/kernels/data/random_dataset_op.cc index 7e48428b3f..7817170e73 100644 --- a/tensorflow/core/kernels/data/random_dataset_op.cc +++ b/tensorflow/core/kernels/data/random_dataset_op.cc @@ -49,10 +49,10 @@ class RandomDatasetOp : public DatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, int64 seed, int64 seed2) - : GraphDatasetBase(ctx), seed_(seed), seed2_(seed2) {} + : DatasetBase(DatasetContext(ctx)), seed_(seed), seed2_(seed2) {} std::unique_ptr MakeIteratorInternal( const string& prefix) const override { diff --git a/tensorflow/core/kernels/data/range_dataset_op.cc b/tensorflow/core/kernels/data/range_dataset_op.cc index 50bd3dac4e..aa38775125 100644 --- a/tensorflow/core/kernels/data/range_dataset_op.cc +++ b/tensorflow/core/kernels/data/range_dataset_op.cc @@ -43,10 +43,13 @@ class RangeDatasetOp : public DatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, int64 start, int64 stop, int64 step) - : GraphDatasetBase(ctx), start_(start), stop_(stop), step_(step) {} + : DatasetBase(DatasetContext(ctx)), + start_(start), + stop_(stop), + step_(step) {} std::unique_ptr MakeIteratorInternal( const string& prefix) const override { diff --git a/tensorflow/core/kernels/data/reader_dataset_ops.cc b/tensorflow/core/kernels/data/reader_dataset_ops.cc index 6a71a7af1d..086b552936 100644 --- a/tensorflow/core/kernels/data/reader_dataset_ops.cc +++ b/tensorflow/core/kernels/data/reader_dataset_ops.cc @@ -78,12 +78,12 @@ class TextLineDatasetOp : public DatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, std::vector filenames, const string& compression_type, const io::ZlibCompressionOptions& options) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), filenames_(std::move(filenames)), compression_type_(compression_type), use_compression_(!compression_type.empty()), @@ -312,12 +312,12 @@ class FixedLengthRecordDatasetOp : public DatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: explicit Dataset(OpKernelContext* ctx, std::vector filenames, int64 header_bytes, int64 record_bytes, int64 footer_bytes, int64 buffer_size) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), filenames_(std::move(filenames)), header_bytes_(header_bytes), record_bytes_(record_bytes), @@ -531,11 +531,11 @@ class TFRecordDatasetOp : public DatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: explicit Dataset(OpKernelContext* ctx, std::vector filenames, const string& compression_type, int64 buffer_size) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), filenames_(std::move(filenames)), compression_type_(compression_type), options_(io::RecordReaderOptions::CreateRecordReaderOptions( diff --git a/tensorflow/core/kernels/data/repeat_dataset_op.cc b/tensorflow/core/kernels/data/repeat_dataset_op.cc index 093ea563b4..5e9ace3486 100644 --- a/tensorflow/core/kernels/data/repeat_dataset_op.cc +++ b/tensorflow/core/kernels/data/repeat_dataset_op.cc @@ -39,10 +39,10 @@ class RepeatDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, int64 count, const DatasetBase* input) - : GraphDatasetBase(ctx), count_(count), input_(input) { + : DatasetBase(DatasetContext(ctx)), count_(count), input_(input) { input_->Ref(); } diff --git a/tensorflow/core/kernels/data/scan_dataset_op.cc b/tensorflow/core/kernels/data/scan_dataset_op.cc index 7c59874d96..e4cb31e2b2 100644 --- a/tensorflow/core/kernels/data/scan_dataset_op.cc +++ b/tensorflow/core/kernels/data/scan_dataset_op.cc @@ -69,7 +69,7 @@ class ScanDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, const DatasetBase* input, const NameAttrList& func, std::vector initial_state, @@ -77,7 +77,7 @@ class ScanDatasetOp : public UnaryDatasetOpKernel { const DataTypeVector& state_types, const DataTypeVector& output_types, const std::vector& output_shapes) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), input_(input), func_(func), initial_state_(std::move(initial_state)), diff --git a/tensorflow/core/kernels/data/shuffle_dataset_op.cc b/tensorflow/core/kernels/data/shuffle_dataset_op.cc index 603c3feb79..93a4376836 100644 --- a/tensorflow/core/kernels/data/shuffle_dataset_op.cc +++ b/tensorflow/core/kernels/data/shuffle_dataset_op.cc @@ -40,11 +40,11 @@ class ShuffleDatasetOpBase : public UnaryDatasetOpKernel { protected: // Abstract base dataset that implements a shuffling iterator. - class ShuffleDatasetBase : public GraphDatasetBase { + class ShuffleDatasetBase : public DatasetBase { public: ShuffleDatasetBase(OpKernelContext* ctx, const DatasetBase* input, int64 buffer_size, int64 count) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), input_(input), buffer_size_(buffer_size), count_(count) { diff --git a/tensorflow/core/kernels/data/skip_dataset_op.cc b/tensorflow/core/kernels/data/skip_dataset_op.cc index 61db6a0a54..fe7ef38d5f 100644 --- a/tensorflow/core/kernels/data/skip_dataset_op.cc +++ b/tensorflow/core/kernels/data/skip_dataset_op.cc @@ -38,10 +38,10 @@ class SkipDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, int64 count, const DatasetBase* input) - : GraphDatasetBase(ctx), count_(count), input_(input) { + : DatasetBase(DatasetContext(ctx)), count_(count), input_(input) { input_->Ref(); } diff --git a/tensorflow/core/kernels/data/slide_dataset_op.cc b/tensorflow/core/kernels/data/slide_dataset_op.cc index fd8c5ccd92..14df3a6801 100644 --- a/tensorflow/core/kernels/data/slide_dataset_op.cc +++ b/tensorflow/core/kernels/data/slide_dataset_op.cc @@ -63,11 +63,11 @@ class SlideDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, int64 window_size, int64 window_shift, int64 window_stride, const DatasetBase* input) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), window_size_(window_size), window_shift_(window_shift), window_stride_(window_stride), diff --git a/tensorflow/core/kernels/data/sparse_tensor_slice_dataset_op.cc b/tensorflow/core/kernels/data/sparse_tensor_slice_dataset_op.cc index 9bb86e76a2..e526578701 100644 --- a/tensorflow/core/kernels/data/sparse_tensor_slice_dataset_op.cc +++ b/tensorflow/core/kernels/data/sparse_tensor_slice_dataset_op.cc @@ -28,11 +28,11 @@ namespace { // description of the following op. template -class Dataset : public GraphDatasetBase { +class Dataset : public DatasetBase { public: explicit Dataset(OpKernelContext* ctx, const sparse::SparseTensor& sparse_tensor) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), sparse_tensor_(sparse_tensor), dtypes_({DT_INT64, sparse_tensor.dtype(), DT_INT64}), shapes_({{-1, sparse_tensor.dims() - 1}, diff --git a/tensorflow/core/kernels/data/sql_dataset_ops.cc b/tensorflow/core/kernels/data/sql_dataset_ops.cc index 9b0190e3fc..2aa153fcfa 100644 --- a/tensorflow/core/kernels/data/sql_dataset_ops.cc +++ b/tensorflow/core/kernels/data/sql_dataset_ops.cc @@ -75,13 +75,13 @@ class SqlDatasetOp : public DatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, const string& driver_name, const string& data_source_name, const string& query, const DataTypeVector& output_types, const std::vector& output_shapes) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), driver_name_(driver_name), data_source_name_(data_source_name), query_(query), diff --git a/tensorflow/core/kernels/data/stats_aggregator_dataset_op.cc b/tensorflow/core/kernels/data/stats_aggregator_dataset_op.cc index 8465a1d2c0..75af73df54 100644 --- a/tensorflow/core/kernels/data/stats_aggregator_dataset_op.cc +++ b/tensorflow/core/kernels/data/stats_aggregator_dataset_op.cc @@ -37,11 +37,11 @@ class SetStatsAggregatorDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: explicit Dataset(OpKernelContext* ctx, const DatasetBase* input, StatsAggregatorResource* stats_aggregator_resource) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), input_(input), stats_aggregator_resource_(stats_aggregator_resource) { input_->Ref(); @@ -70,6 +70,14 @@ class SetStatsAggregatorDatasetOp : public UnaryDatasetOpKernel { return "SetStatsAggregatorDatasetOp::Dataset"; } + protected: + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, + Node** output) const override { + return errors::Unimplemented("%s does not support serialization", + DebugString()); + } + private: class Iterator : public DatasetIterator { public: diff --git a/tensorflow/core/kernels/data/stats_dataset_ops.cc b/tensorflow/core/kernels/data/stats_dataset_ops.cc index 85fed31773..52753a3ccd 100644 --- a/tensorflow/core/kernels/data/stats_dataset_ops.cc +++ b/tensorflow/core/kernels/data/stats_dataset_ops.cc @@ -49,10 +49,12 @@ class LatencyStatsDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: explicit Dataset(OpKernelContext* ctx, const DatasetBase* input, string tag) - : GraphDatasetBase(ctx), input_(input), tag_(std::move(tag)) { + : DatasetBase(DatasetContext(ctx)), + input_(input), + tag_(std::move(tag)) { input_->Ref(); } @@ -149,10 +151,12 @@ class BytesProducedStatsDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: explicit Dataset(OpKernelContext* ctx, const DatasetBase* input, string tag) - : GraphDatasetBase(ctx), input_(input), tag_(std::move(tag)) { + : DatasetBase(DatasetContext(ctx)), + input_(input), + tag_(std::move(tag)) { input_->Ref(); } @@ -255,10 +259,12 @@ class FeatureStatsDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: explicit Dataset(OpKernelContext* ctx, const DatasetBase* input, string tag) - : GraphDatasetBase(ctx), input_(input), tag_(std::move(tag)) { + : DatasetBase(DatasetContext(ctx)), + input_(input), + tag_(std::move(tag)) { input_->Ref(); } diff --git a/tensorflow/core/kernels/data/take_dataset_op.cc b/tensorflow/core/kernels/data/take_dataset_op.cc index d4a3c7a978..e5c237dfaa 100644 --- a/tensorflow/core/kernels/data/take_dataset_op.cc +++ b/tensorflow/core/kernels/data/take_dataset_op.cc @@ -38,10 +38,10 @@ class TakeDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, int64 count, const DatasetBase* input) - : GraphDatasetBase(ctx), count_(count), input_(input) { + : DatasetBase(DatasetContext(ctx)), count_(count), input_(input) { input_->Ref(); } diff --git a/tensorflow/core/kernels/data/tensor_dataset_op.cc b/tensorflow/core/kernels/data/tensor_dataset_op.cc index ac2015c865..fc21c3235a 100644 --- a/tensorflow/core/kernels/data/tensor_dataset_op.cc +++ b/tensorflow/core/kernels/data/tensor_dataset_op.cc @@ -43,10 +43,10 @@ class TensorDatasetOp : public DatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, std::vector tensors) - : GraphDatasetBase(ctx), tensors_(std::move(tensors)) { + : DatasetBase(DatasetContext(ctx)), tensors_(std::move(tensors)) { for (const Tensor& t : tensors_) { dtypes_.push_back(t.dtype()); shapes_.emplace_back(t.shape().dim_sizes()); diff --git a/tensorflow/core/kernels/data/tensor_queue_dataset_op.cc b/tensorflow/core/kernels/data/tensor_queue_dataset_op.cc index ea472e2b79..ccd5e60acc 100644 --- a/tensorflow/core/kernels/data/tensor_queue_dataset_op.cc +++ b/tensorflow/core/kernels/data/tensor_queue_dataset_op.cc @@ -61,14 +61,14 @@ std::vector PrependQueueShapeWithBatch( class EnqueueInQueueDatasetOp; -class PrependFromQueueAndPaddedBatchDataset : public GraphDatasetBase { +class PrependFromQueueAndPaddedBatchDataset : public DatasetBase { public: PrependFromQueueAndPaddedBatchDataset( OpKernelContext* ctx, const int64 batch_size, const DatasetBase* input, const DataTypeVector& dtypes, const std::vector& shapes, std::vector padding_values) - : GraphDatasetBase(ctx), + : DatasetBase(DatasetContext(ctx)), batch_size_(batch_size), input_(input), dtypes_(dtypes), diff --git a/tensorflow/core/kernels/data/tensor_slice_dataset_op.cc b/tensorflow/core/kernels/data/tensor_slice_dataset_op.cc index 8f18d38f83..5b051e0e08 100644 --- a/tensorflow/core/kernels/data/tensor_slice_dataset_op.cc +++ b/tensorflow/core/kernels/data/tensor_slice_dataset_op.cc @@ -54,10 +54,10 @@ class TensorSliceDatasetOp : public DatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: explicit Dataset(OpKernelContext* ctx, std::vector tensors) - : GraphDatasetBase(ctx), tensors_(std::move(tensors)) { + : DatasetBase(DatasetContext(ctx)), tensors_(std::move(tensors)) { for (const Tensor& t : tensors_) { dtypes_.push_back(t.dtype()); gtl::InlinedVector partial_dim_sizes; diff --git a/tensorflow/core/kernels/data/unbatch_dataset_op.cc b/tensorflow/core/kernels/data/unbatch_dataset_op.cc index 02c3c5315a..1a79f72b28 100644 --- a/tensorflow/core/kernels/data/unbatch_dataset_op.cc +++ b/tensorflow/core/kernels/data/unbatch_dataset_op.cc @@ -35,10 +35,10 @@ class UnbatchDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: explicit Dataset(OpKernelContext* ctx, DatasetBase* input) - : GraphDatasetBase(ctx), input_(input) { + : DatasetBase(DatasetContext(ctx)), input_(input) { input_->Ref(); for (const PartialTensorShape& shape : input->output_shapes()) { gtl::InlinedVector partial_dim_sizes; diff --git a/tensorflow/core/kernels/data/window_dataset.cc b/tensorflow/core/kernels/data/window_dataset.cc index 17551bccd9..0ab6beabfc 100644 --- a/tensorflow/core/kernels/data/window_dataset.cc +++ b/tensorflow/core/kernels/data/window_dataset.cc @@ -13,17 +13,18 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #include "tensorflow/core/kernels/data/window_dataset.h" +#include "tensorflow/core/lib/core/errors.h" namespace tensorflow { namespace { -// TODO(b/110981596): Support checkpointing. class WindowDataset : public DatasetBase { public: WindowDataset(std::vector> elements, DataTypeVector output_types, std::vector output_shapes) - : elements_(std::move(elements)), + : DatasetBase(DatasetContext({"Window"})), + elements_(std::move(elements)), output_types_(std::move(output_types)), output_shapes_(std::move(output_shapes)) {} @@ -41,6 +42,15 @@ class WindowDataset : public DatasetBase { string DebugString() const override { return "WindowDataset"; } + protected: + // TODO(b/110981596): Support checkpointing. + Status AsGraphDefInternal(SerializationContext* ctx, + DatasetGraphDefBuilder* b, + Node** output) const override { + return errors::Unimplemented("%s does not support serialization", + DebugString()); + } + private: class Iterator : public DatasetIterator { public: diff --git a/tensorflow/core/kernels/data/window_dataset_op.cc b/tensorflow/core/kernels/data/window_dataset_op.cc index f9fd5b5a83..41bf9d43fe 100644 --- a/tensorflow/core/kernels/data/window_dataset_op.cc +++ b/tensorflow/core/kernels/data/window_dataset_op.cc @@ -43,10 +43,12 @@ class WindowDatasetOp : public UnaryDatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: Dataset(OpKernelContext* ctx, int64 window_size, const DatasetBase* input) - : GraphDatasetBase(ctx), window_size_(window_size), input_(input) { + : DatasetBase(DatasetContext(ctx)), + window_size_(window_size), + input_(input) { input_->Ref(); } diff --git a/tensorflow/core/kernels/data/writer_ops.cc b/tensorflow/core/kernels/data/writer_ops.cc index 80d9a5b867..1c49874a6a 100644 --- a/tensorflow/core/kernels/data/writer_ops.cc +++ b/tensorflow/core/kernels/data/writer_ops.cc @@ -70,20 +70,21 @@ class ToTFRecordOp : public AsyncOpKernel { DatasetBase* dataset; OP_REQUIRES_OK_ASYNC( ctx, GetDatasetFromVariantTensor(ctx->input(0), &dataset), done); - IteratorContext iter_ctx = dataset::MakeIteratorContext(ctx); std::unique_ptr iterator; OP_REQUIRES_OK_ASYNC( ctx, - dataset->MakeIterator(&iter_ctx, "ToTFRecordOpIterator", &iterator), + dataset->MakeIterator(IteratorContext(ctx), "ToTFRecordOpIterator", + &iterator), done); std::vector components; components.reserve(dataset->output_dtypes().size()); bool end_of_sequence; do { - OP_REQUIRES_OK_ASYNC( - ctx, iterator->GetNext(&iter_ctx, &components, &end_of_sequence), - done); + OP_REQUIRES_OK_ASYNC(ctx, + iterator->GetNext(IteratorContext(ctx), + &components, &end_of_sequence), + done); if (!end_of_sequence) { OP_REQUIRES_OK_ASYNC( diff --git a/tensorflow/core/kernels/data/zip_dataset_op.cc b/tensorflow/core/kernels/data/zip_dataset_op.cc index 63e9b99d4b..e4306579ed 100644 --- a/tensorflow/core/kernels/data/zip_dataset_op.cc +++ b/tensorflow/core/kernels/data/zip_dataset_op.cc @@ -38,11 +38,11 @@ class ZipDatasetOp : public DatasetOpKernel { } private: - class Dataset : public GraphDatasetBase { + class Dataset : public DatasetBase { public: explicit Dataset(OpKernelContext* ctx, const std::vector& inputs) - : GraphDatasetBase(ctx), inputs_(inputs) { + : DatasetBase(DatasetContext(ctx)), inputs_(inputs) { for (const auto& input : inputs_) { input->Ref(); for (DataType dt : input->output_dtypes()) { -- GitLab From 859f68f6c444619de24db9bf43f2a0978997797f Mon Sep 17 00:00:00 2001 From: Nupur Garg Date: Mon, 13 Aug 2018 16:11:54 -0700 Subject: [PATCH 430/437] Create a new graph for loading the frozen graph in TocoConverter. PiperOrigin-RevId: 208560644 --- tensorflow/contrib/lite/python/lite.py | 66 +++++++++++++------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/tensorflow/contrib/lite/python/lite.py b/tensorflow/contrib/lite/python/lite.py index 52ef43d71f..5ec52035ad 100644 --- a/tensorflow/contrib/lite/python/lite.py +++ b/tensorflow/contrib/lite/python/lite.py @@ -53,6 +53,7 @@ from tensorflow.core.framework import graph_pb2 as _graph_pb2 from tensorflow.python import keras as _keras from tensorflow.python.client import session as _session from tensorflow.python.framework import graph_util as _tf_graph_util +from tensorflow.python.framework import ops as _ops from tensorflow.python.framework.importer import import_graph_def as _import_graph_def from tensorflow.python.saved_model import signature_constants as _signature_constants from tensorflow.python.saved_model import tag_constants as _tag_constants @@ -193,40 +194,41 @@ class TocoConverter(object): The graph is not frozen. input_arrays or output_arrays contains an invalid tensor name. """ - with _session.Session() as sess: - # Read GraphDef from file. - graph_def = _graph_pb2.GraphDef() - with open(graph_def_file, "rb") as f: - file_content = f.read() - try: - graph_def.ParseFromString(file_content) - except (_text_format.ParseError, DecodeError): + with _ops.Graph().as_default(): + with _session.Session() as sess: + # Read GraphDef from file. + graph_def = _graph_pb2.GraphDef() + with open(graph_def_file, "rb") as f: + file_content = f.read() try: - print("Ignore 'tcmalloc: large alloc' warnings.") - - if not isinstance(file_content, str): - if PY3: - file_content = file_content.decode('utf-8') - else: - file_content = file_content.encode('utf-8') - _text_format.Merge(file_content, graph_def) + graph_def.ParseFromString(file_content) except (_text_format.ParseError, DecodeError): - raise ValueError( - "Unable to parse input file '{}'.".format(graph_def_file)) - sess.graph.as_default() - _import_graph_def(graph_def, name="") - - # Get input and output tensors. - input_tensors = _get_tensors_from_tensor_names(sess.graph, input_arrays) - output_tensors = _get_tensors_from_tensor_names(sess.graph, output_arrays) - _set_tensor_shapes(input_tensors, input_shapes) - - # Check if graph is frozen. - if not _is_frozen_graph(sess): - raise ValueError("Please freeze the graph using freeze_graph.py.") - - # Create TocoConverter class. - return cls(sess.graph_def, input_tensors, output_tensors) + try: + print("Ignore 'tcmalloc: large alloc' warnings.") + + if not isinstance(file_content, str): + if PY3: + file_content = file_content.decode("utf-8") + else: + file_content = file_content.encode("utf-8") + _text_format.Merge(file_content, graph_def) + except (_text_format.ParseError, DecodeError): + raise ValueError( + "Unable to parse input file '{}'.".format(graph_def_file)) + _import_graph_def(graph_def, name="") + + # Get input and output tensors. + input_tensors = _get_tensors_from_tensor_names(sess.graph, input_arrays) + output_tensors = _get_tensors_from_tensor_names(sess.graph, + output_arrays) + _set_tensor_shapes(input_tensors, input_shapes) + + # Check if graph is frozen. + if not _is_frozen_graph(sess): + raise ValueError("Please freeze the graph using freeze_graph.py.") + + # Create TocoConverter class. + return cls(sess.graph_def, input_tensors, output_tensors) @classmethod def from_saved_model(cls, -- GitLab From 8202d1c154d21a42ee7343f2bcab64c909c95c76 Mon Sep 17 00:00:00 2001 From: Nupur Garg Date: Mon, 13 Aug 2018 16:16:59 -0700 Subject: [PATCH 431/437] Add error message to freeze_graph. PiperOrigin-RevId: 208561390 --- tensorflow/python/tools/freeze_graph.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tensorflow/python/tools/freeze_graph.py b/tensorflow/python/tools/freeze_graph.py index 130fe70beb..acf070075e 100644 --- a/tensorflow/python/tools/freeze_graph.py +++ b/tensorflow/python/tools/freeze_graph.py @@ -59,6 +59,21 @@ from tensorflow.python.training import checkpoint_management from tensorflow.python.training import saver as saver_lib +def _has_variables(sess): + """Determines if the graph has any variables. + + Args: + sess: TensorFlow Session. + + Returns: + Bool. + """ + for op in sess.graph.get_operations(): + if op.type.startswith("Variable") or op.type.endswith("VariableOp"): + return False + return True + + def freeze_graph_with_def_protos(input_graph_def, input_saver_def, input_checkpoint, @@ -152,6 +167,11 @@ def freeze_graph_with_def_protos(input_graph_def, "from checkpoint files. Please pass in a SavedModel using " "the flag --input_saved_model_dir.") return -1 + # Models that have been frozen previously do not contain Variables. + elif _has_variables(sess): + print("No variables were found in this model. It is likely the model " + "was frozen previously. You cannot freeze a graph twice.") + return 0 else: raise e -- GitLab From 7a81491366afb444efb914b93594a11fdfc19896 Mon Sep 17 00:00:00 2001 From: Allen Lavoie Date: Mon, 13 Aug 2018 16:48:08 -0700 Subject: [PATCH 432/437] Add tf.contrib.checkpoint.CheckpointManager for deleting old checkpoints Removes a bit of boilerplate from training loops (making a prefix from a directory). Also clarifies the recovery of checkpoint lists (like tf.train.Saver.recover_last_checkpoints, but automatic and more thorough). Adds a couple fields to the CheckpointState proto to support this. Should live in contrib until I make it work well with tf.keras.Model.save_weights. When used together, save_weights needs to number its checkpoints. (There's a TODO for this.) PiperOrigin-RevId: 208566198 --- tensorflow/contrib/checkpoint/__init__.py | 4 + .../python/training/checkpoint_management.py | 281 +++++++++++++++++- .../training/checkpoint_management_test.py | 175 +++++++++++ .../python/training/checkpoint_state.proto | 8 +- .../python/training/checkpointable/util.py | 10 +- .../training/checkpointable/util_test.py | 9 +- .../api/golden/v1/tensorflow.train.pbtxt | 4 +- 7 files changed, 468 insertions(+), 23 deletions(-) diff --git a/tensorflow/contrib/checkpoint/__init__.py b/tensorflow/contrib/checkpoint/__init__.py index 2fbaa31d5e..e92f0bb841 100644 --- a/tensorflow/contrib/checkpoint/__init__.py +++ b/tensorflow/contrib/checkpoint/__init__.py @@ -31,6 +31,9 @@ Checkpointable data structures: @@List @@Mapping @@UniqueNameTracker + +Checkpoint management: +@@CheckpointManager """ from __future__ import absolute_import @@ -41,6 +44,7 @@ from tensorflow.contrib.checkpoint.python.containers import UniqueNameTracker from tensorflow.contrib.checkpoint.python.split_dependency import split_dependency from tensorflow.contrib.checkpoint.python.visualize import dot_graph_from_checkpoint from tensorflow.core.protobuf.checkpointable_object_graph_pb2 import CheckpointableObjectGraph +from tensorflow.python.training.checkpoint_management import CheckpointManager from tensorflow.python.training.checkpointable.base import CheckpointableBase from tensorflow.python.training.checkpointable.data_structures import List from tensorflow.python.training.checkpointable.data_structures import Mapping diff --git a/tensorflow/python/training/checkpoint_management.py b/tensorflow/python/training/checkpoint_management.py index aaddc015ed..9a90f91a7c 100644 --- a/tensorflow/python/training/checkpoint_management.py +++ b/tensorflow/python/training/checkpoint_management.py @@ -19,14 +19,19 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +import collections import os.path import re +import time from google.protobuf import text_format from tensorflow.core.protobuf import saver_pb2 +from tensorflow.python.eager import context from tensorflow.python.framework import errors +from tensorflow.python.framework import ops from tensorflow.python.lib.io import file_io +from tensorflow.python.ops import variable_scope from tensorflow.python.platform import tf_logging as logging from tensorflow.python.training.checkpoint_state_pb2 import CheckpointState from tensorflow.python.util.tf_export import tf_export @@ -51,7 +56,9 @@ def _GetCheckpointFilename(save_dir, latest_filename): @tf_export("train.generate_checkpoint_state_proto") def generate_checkpoint_state_proto(save_dir, model_checkpoint_path, - all_model_checkpoint_paths=None): + all_model_checkpoint_paths=None, + all_model_checkpoint_timestamps=None, + last_preserved_timestamp=None): """Generates a checkpoint state proto. Args: @@ -61,11 +68,20 @@ def generate_checkpoint_state_proto(save_dir, checkpoints, sorted from oldest to newest. If this is a non-empty list, the last element must be equal to model_checkpoint_path. These paths are also saved in the CheckpointState proto. - + all_model_checkpoint_timestamps: A list of floats, indicating the number of + seconds since the Epoch when each checkpoint was generated. + last_preserved_timestamp: A float, indicating the number of seconds since + the Epoch when the last preserved checkpoint was written, e.g. due to a + `keep_checkpoint_every_n_hours` parameter (see + `tf.contrib.checkpoint.CheckpointManager` for an implementation). Returns: CheckpointState proto with model_checkpoint_path and all_model_checkpoint_paths updated to either absolute paths or relative paths to the current save_dir. + + Raises: + ValueError: If `all_model_checkpoint_timestamps` was provided but its length + does not match `all_model_checkpoint_paths`. """ if all_model_checkpoint_paths is None: all_model_checkpoint_paths = [] @@ -76,6 +92,14 @@ def generate_checkpoint_state_proto(save_dir, model_checkpoint_path) all_model_checkpoint_paths.append(model_checkpoint_path) + if (all_model_checkpoint_timestamps + and (len(all_model_checkpoint_timestamps) + != len(all_model_checkpoint_paths))): + raise ValueError( + ("Checkpoint timestamps, if provided, must match checkpoint paths (got " + "paths %s and timestamps %s)") + % (all_model_checkpoint_paths, all_model_checkpoint_timestamps)) + # Relative paths need to be rewritten to be relative to the "save_dir" # if model_checkpoint_path already contains "save_dir". if not os.path.isabs(save_dir): @@ -88,7 +112,9 @@ def generate_checkpoint_state_proto(save_dir, coord_checkpoint_proto = CheckpointState( model_checkpoint_path=model_checkpoint_path, - all_model_checkpoint_paths=all_model_checkpoint_paths) + all_model_checkpoint_paths=all_model_checkpoint_paths, + all_model_checkpoint_timestamps=all_model_checkpoint_timestamps, + last_preserved_timestamp=last_preserved_timestamp) return coord_checkpoint_proto @@ -97,7 +123,9 @@ def generate_checkpoint_state_proto(save_dir, def update_checkpoint_state(save_dir, model_checkpoint_path, all_model_checkpoint_paths=None, - latest_filename=None): + latest_filename=None, + all_model_checkpoint_timestamps=None, + last_preserved_timestamp=None): """Updates the content of the 'checkpoint' file. This updates the checkpoint file containing a CheckpointState @@ -112,7 +140,13 @@ def update_checkpoint_state(save_dir, are also saved in the CheckpointState proto. latest_filename: Optional name of the checkpoint file. Default to 'checkpoint'. - + all_model_checkpoint_timestamps: Optional list of timestamps (floats, + seconds since the Epoch) indicating when the checkpoints in + `all_model_checkpoint_paths` were created. + last_preserved_timestamp: A float, indicating the number of seconds since + the Epoch when the last preserved checkpoint was written, e.g. due to a + `keep_checkpoint_every_n_hours` parameter (see + `tf.contrib.checkpoint.CheckpointManager` for an implementation). Raises: RuntimeError: If any of the model checkpoint paths conflict with the file containing CheckpointSate. @@ -122,14 +156,18 @@ def update_checkpoint_state(save_dir, model_checkpoint_path=model_checkpoint_path, all_model_checkpoint_paths=all_model_checkpoint_paths, latest_filename=latest_filename, - save_relative_paths=False) + save_relative_paths=False, + all_model_checkpoint_timestamps=all_model_checkpoint_timestamps, + last_preserved_timestamp=last_preserved_timestamp) def update_checkpoint_state_internal(save_dir, model_checkpoint_path, all_model_checkpoint_paths=None, latest_filename=None, - save_relative_paths=False): + save_relative_paths=False, + all_model_checkpoint_timestamps=None, + last_preserved_timestamp=None): """Updates the content of the 'checkpoint' file. This updates the checkpoint file containing a CheckpointState @@ -146,6 +184,13 @@ def update_checkpoint_state_internal(save_dir, 'checkpoint'. save_relative_paths: If `True`, will write relative paths to the checkpoint state file. + all_model_checkpoint_timestamps: Optional list of timestamps (floats, + seconds since the Epoch) indicating when the checkpoints in + `all_model_checkpoint_paths` were created. + last_preserved_timestamp: A float, indicating the number of seconds since + the Epoch when the last preserved checkpoint was written, e.g. due to a + `keep_checkpoint_every_n_hours` parameter (see + `tf.contrib.checkpoint.CheckpointManager` for an implementation). Raises: RuntimeError: If any of the model checkpoint paths conflict with the file @@ -168,12 +213,16 @@ def update_checkpoint_state_internal(save_dir, ckpt = generate_checkpoint_state_proto( save_dir, rel_model_checkpoint_path, - all_model_checkpoint_paths=rel_all_model_checkpoint_paths) + all_model_checkpoint_paths=rel_all_model_checkpoint_paths, + all_model_checkpoint_timestamps=all_model_checkpoint_timestamps, + last_preserved_timestamp=last_preserved_timestamp) else: ckpt = generate_checkpoint_state_proto( save_dir, model_checkpoint_path, - all_model_checkpoint_paths=all_model_checkpoint_paths) + all_model_checkpoint_paths=all_model_checkpoint_paths, + all_model_checkpoint_timestamps=all_model_checkpoint_timestamps, + last_preserved_timestamp=last_preserved_timestamp) if coord_checkpoint_filename == ckpt.model_checkpoint_path: raise RuntimeError("Save path '%s' conflicts with path used for " @@ -404,3 +453,217 @@ def meta_graph_filename(checkpoint_filename, meta_graph_suffix="meta"): basename = re.sub(r"-[\d\?]+-of-\d+$", "", checkpoint_filename) suffixed_filename = ".".join([basename, meta_graph_suffix]) return suffixed_filename + + +# TODO(allenl): Allow tf.keras.Model instances in the constructor directly? +class CheckpointManager(object): + """Deletes old checkpoints. + + Example usage: + ```python + import tensorflow as tf + checkpoint = tf.train.Checkpoint(optimizer=optimizer, model=model) + manager = tf.contrib.checkpoint.CheckpointManager( + checkpoint, directory="/tmp/model", max_to_keep=5) + status = checkpoint.restore(manager.latest_checkpoint) + while True: + # train + manager.save() + ``` + + `CheckpointManager` preserves its own state across instantiations (see the + `__init__` documentation for details). Only one should be active in a + particular directory at a time. + """ + + def __init__(self, checkpoint, directory, + max_to_keep, keep_checkpoint_every_n_hours=None): + """Configure a `CheckpointManager` for use in `directory`. + + If a `CheckpointManager` was previously used in `directory`, its + state will be restored. This includes the list of managed checkpoints and + the timestamp bookkeeping necessary to support + `keep_checkpoint_every_n_hours`. The behavior of the new `CheckpointManager` + will be the same as the previous `CheckpointManager`, including cleaning up + existing checkpoints if appropriate. + + Checkpoints are only considered for deletion just after a new checkpoint has + been added. At that point, `max_to_keep` checkpoints will remain in an + "active set". Once a checkpoint is preserved by + `keep_checkpoint_every_n_hours` it will not be deleted by this + `CheckpointManager` or any future `CheckpointManager` instantiated in + `directory` (regardless of the new setting of + `keep_checkpoint_every_n_hours`). The `max_to_keep` checkpoints in the + active set may be deleted by this `CheckpointManager` or a future + `CheckpointManager` instantiated in `directory` (subject to its + `max_to_keep` and `keep_checkpoint_every_n_hours` settings). + + Args: + checkpoint: The `tf.train.Checkpoint` instance to save and manage + checkpoints for. + directory: The path to a directory in which to write checkpoints. A + special file named "checkpoint" is also written to this directory (in a + human-readable text format) which contains the state of the + `CheckpointManager`. + max_to_keep: An integer, the number of checkpoints to keep. Unless + preserved by `keep_checkpoint_every_n_hours`, checkpoints will be + deleted from the active set, oldest first, until only `max_to_keep` + checkpoints remain. + keep_checkpoint_every_n_hours: Upon removal from the active set, a + checkpoint will be preserved if it has been at least + `keep_checkpoint_every_n_hours` since the last preserved checkpoint. The + default setting of `None` does not preserve any checkpoints in this way. + + Raises: + ValueError: If `max_to_keep` is not a positive integer. + """ + self._checkpoint = checkpoint + self._save_counter_assign = None + if not max_to_keep or max_to_keep < 0: + raise ValueError( + "Expected a positive integer for `max_to_max_to_keep`, got %d." + % (max_to_keep,)) + self._max_to_keep = max_to_keep + self._keep_checkpoint_every_n_hours = keep_checkpoint_every_n_hours + self._directory = directory + self._checkpoint_prefix = os.path.join(directory, "ckpt") + recovered_state = get_checkpoint_state(directory) + current_clock = time.time() + self._maybe_delete = collections.OrderedDict() + if recovered_state is None: + self._latest_checkpoint = None + self._last_preserved_timestamp = current_clock + else: + self._latest_checkpoint = recovered_state.model_checkpoint_path + self._last_preserved_timestamp = recovered_state.last_preserved_timestamp + if current_clock < self._last_preserved_timestamp: + # Time seems to have reversed itself. In addition to this warning, we'll + # min() saved checkpoint timestamps with the current time to ensure that + # old checkpoints don't get deleted accidentally. + logging.warning( + ("time.time() returned a value %f seconds behind the last " + "preserved checkpoint timestamp.") + % (self._last_preserved_timestamp - current_clock,)) + self._last_preserved_timestamp = current_clock + all_timestamps = recovered_state.all_model_checkpoint_timestamps + all_paths = recovered_state.all_model_checkpoint_paths + del recovered_state # Uses modified values from now on + if not all_timestamps: + all_timestamps = [self._last_preserved_timestamp] * len(all_paths) + + for filename, timestamp in zip(all_paths, all_timestamps): + timestamp = min(timestamp, current_clock) + if timestamp > self._last_preserved_timestamp: + self._maybe_delete[filename] = timestamp + + @property + def latest_checkpoint(self): + """The prefix of the most recent checkpoint in `directory`. + + Equivalent to `tf.train.latest_checkpoint(directory)` where `directory` is + the constructor argument to `CheckpointManager`. + + Suitable for passing to `tf.train.Checkpoint.restore` to resume training. + + Returns: + The checkpoint prefix. If there are no checkpoints, returns `None`. + """ + return self._latest_checkpoint + + @property + def checkpoints(self): + """A list of managed checkpoints. + + Note that checkpoints saved due to `keep_checkpoint_every_n_hours` will not + show up in this list (to avoid ever-growing filename lists). + + Returns: + A list of filenames, sorted from oldest to newest. + """ + return list(self._maybe_delete.keys()) + + def _sweep(self): + """Deletes or preserves managed checkpoints.""" + while len(self._maybe_delete) > self._max_to_keep: + filename, timestamp = self._maybe_delete.popitem(last=False) + # Even if we're keeping this checkpoint due to + # keep_checkpoint_every_n_hours, we won't reference it to avoid + # infinitely-growing CheckpointState protos. + if (self._keep_checkpoint_every_n_hours + and (timestamp - self._keep_checkpoint_every_n_hours * 3600. + >= self._last_preserved_timestamp)): + self._last_preserved_timestamp = timestamp + continue + remove_checkpoint(filename) + + def _record_state(self): + """Saves the `CheckpointManager`'s state in `directory`.""" + filenames, timestamps = zip(*self._maybe_delete.items()) + update_checkpoint_state_internal( + self._directory, + model_checkpoint_path=self.latest_checkpoint, + all_model_checkpoint_paths=filenames, + all_model_checkpoint_timestamps=timestamps, + last_preserved_timestamp=self._last_preserved_timestamp, + save_relative_paths=True) + + @property + def _prefix(self): + """A common prefix for all checkpoints saved with this manager. + + For example, if `directory` (a constructor argument) were `"/tmp/tf-model"`, + `prefix` would be `"/tmp/tf-model/ckpt"` and checkpoints would generally be + numbered `"/tmp/tf-model/ckpt-1"`, `"/tmp/tf-model/ckpt-2"`, and so on. Each + checkpoint has several associated files + (e.g. `"/tmp/tf-model/ckpt-2.index"`). + + Returns: + A string prefix. + """ + return self._checkpoint_prefix + + def save(self, session=None): + """Creates a new checkpoint and manages it. + + Args: + session: The session to evaluate variables in. Ignored when executing + eagerly. If not provided when graph building, the default session is + used. + + Returns: + The path to the new checkpoint. It is also recorded in the `checkpoints` + and `latest_checkpoint` properies. + """ + # Save counter logic duplicated from tf.train.Checkpoint, soon to diverge + # slightly with a custom numbering option. + if context.executing_eagerly(): + save_counter = self._checkpoint.save_counter + save_counter.assign_add(1) + checkpoint_number = save_counter.numpy() + else: + if session is None: + session = ops.get_default_session() + + def _initializing_creator(next_creator, **kwargs): + """Initialize the save counter if it has been newly created.""" + v = next_creator(**kwargs) + session.run(v.initializer) + return v + + with variable_scope.variable_creator_scope(_initializing_creator): + save_counter = self._checkpoint.save_counter + if self._save_counter_assign is None: + self._save_counter_assign = save_counter.assign_add(1, read_value=True) + checkpoint_number = session.run(self._save_counter_assign) + prefix = "%s-%d" % (self._prefix, checkpoint_number) + save_path = self._checkpoint.write(prefix) + timestamp = time.time() + # If this is an overwritten checkpoint we were previously tracking, delete + # and reinsert it to make sure it goes to the end of the queue. + if save_path in self._maybe_delete: + del self._maybe_delete[save_path] + self._maybe_delete[save_path] = timestamp + self._latest_checkpoint = save_path + self._sweep() + self._record_state() + return save_path diff --git a/tensorflow/python/training/checkpoint_management_test.py b/tensorflow/python/training/checkpoint_management_test.py index 4b31d0c613..95e688d3c7 100644 --- a/tensorflow/python/training/checkpoint_management_test.py +++ b/tensorflow/python/training/checkpoint_management_test.py @@ -27,13 +27,16 @@ from google.protobuf import text_format from tensorflow.core.protobuf import saver_pb2 from tensorflow.python.framework import ops as ops_lib +from tensorflow.python.framework import test_util from tensorflow.python.lib.io import file_io from tensorflow.python.ops import variables from tensorflow.python.platform import gfile from tensorflow.python.platform import test +from tensorflow.python.platform import tf_logging as logging from tensorflow.python.training import checkpoint_management from tensorflow.python.training import saver as saver_module from tensorflow.python.training.checkpoint_state_pb2 import CheckpointState +from tensorflow.python.training.checkpointable import util class LatestCheckpointWithRelativePaths(test.TestCase): @@ -312,5 +315,177 @@ class SaverUtilsTest(test.TestCase): self.assertFalse(checkpoint_management.checkpoint_exists(ckpt_prefix)) +class CheckpointManagerTest(test.TestCase): + + @test_util.run_in_graph_and_eager_modes + def testDeletion(self): + checkpoint = util.Checkpoint() + manager = checkpoint_management.CheckpointManager( + checkpoint, self.get_temp_dir(), max_to_keep=3) + first_path = manager.save() + second_path = manager.save() + third_path = manager.save() + fourth_path = manager.save() + self.assertTrue(checkpoint_management.checkpoint_exists(fourth_path)) + self.assertTrue(checkpoint_management.checkpoint_exists(third_path)) + self.assertTrue(checkpoint_management.checkpoint_exists(second_path)) + self.assertFalse(checkpoint_management.checkpoint_exists(first_path)) + + @test_util.run_in_graph_and_eager_modes + @test.mock.patch.object(checkpoint_management, "time") + def testSaveRestoreState(self, mock_time): + directory = self.get_temp_dir() + mock_time.time.return_value = 3. + checkpoint = util.Checkpoint() + first_manager = checkpoint_management.CheckpointManager( + checkpoint, directory, max_to_keep=2) + first_time = 10000. + first_name = os.path.join(directory, "ckpt-1") + mock_time.time.return_value = first_time + first_manager.save() + state = checkpoint_management.get_checkpoint_state(directory) + self.assertEqual([first_time], state.all_model_checkpoint_timestamps) + self.assertEqual(3., state.last_preserved_timestamp) + second_time = first_time + 3610. + second_name = os.path.join(directory, "ckpt-2") + mock_time.time.return_value = second_time + first_manager.save() + state = checkpoint_management.get_checkpoint_state(directory) + self.assertEqual([first_time, second_time], + state.all_model_checkpoint_timestamps) + self.assertEqual(3., state.last_preserved_timestamp) + self.assertEqual([first_name, second_name], first_manager.checkpoints) + self.assertEqual(second_name, first_manager.latest_checkpoint) + del first_manager + + second_manager = checkpoint_management.CheckpointManager( + checkpoint, directory, + max_to_keep=2, keep_checkpoint_every_n_hours=1.5) + self.assertEqual([first_name, second_name], second_manager.checkpoints) + self.assertEqual(second_name, second_manager.latest_checkpoint) + third_name = os.path.join(directory, "ckpt-3") + third_time = second_time + 3600. * 0.2 + mock_time.time.return_value = third_time + second_manager.save() + self.assertTrue(checkpoint_management.checkpoint_exists(first_name)) + self.assertTrue(checkpoint_management.checkpoint_exists(second_name)) + self.assertEqual([second_name, third_name], + second_manager.checkpoints) + state = checkpoint_management.get_checkpoint_state(directory) + self.assertEqual(first_time, state.last_preserved_timestamp) + fourth_time = third_time + 3600. * 0.5 + mock_time.time.return_value = fourth_time + fourth_name = os.path.join(directory, "ckpt-4") + second_manager.save() + self.assertTrue(checkpoint_management.checkpoint_exists(first_name)) + self.assertFalse(checkpoint_management.checkpoint_exists(second_name)) + self.assertEqual([third_name, fourth_name], + second_manager.checkpoints) + fifth_time = fourth_time + 3600. * 0.5 + mock_time.time.return_value = fifth_time + fifth_name = os.path.join(directory, "ckpt-5") + second_manager.save() + self.assertEqual([fourth_name, fifth_name], + second_manager.checkpoints) + state = checkpoint_management.get_checkpoint_state(directory) + self.assertEqual(first_time, state.last_preserved_timestamp) + del second_manager + third_manager = checkpoint_management.CheckpointManager( + checkpoint, directory, + max_to_keep=2, keep_checkpoint_every_n_hours=1.5) + self.assertEqual(fifth_name, third_manager.latest_checkpoint) + mock_time.time.return_value += 10. + third_manager.save() + sixth_name = os.path.join(directory, "ckpt-6") + state = checkpoint_management.get_checkpoint_state(directory) + self.assertEqual(fourth_time, state.last_preserved_timestamp) + self.assertTrue(checkpoint_management.checkpoint_exists(first_name)) + self.assertTrue(checkpoint_management.checkpoint_exists(fourth_name)) + self.assertTrue(checkpoint_management.checkpoint_exists(fifth_name)) + self.assertTrue(checkpoint_management.checkpoint_exists(sixth_name)) + self.assertFalse(checkpoint_management.checkpoint_exists(second_name)) + self.assertFalse(checkpoint_management.checkpoint_exists(third_name)) + self.assertEqual([fifth_name, sixth_name], + third_manager.checkpoints) + + @test_util.run_in_graph_and_eager_modes + def testContinueFromUnmanaged(self): + directory = self.get_temp_dir() + prefix = os.path.join(directory, "unusual_prefix") + checkpoint = util.Checkpoint() + first_path = checkpoint.save(prefix) + second_path = checkpoint.save(prefix) + del checkpoint + checkpoint = util.Checkpoint() + manager = checkpoint_management.CheckpointManager( + checkpoint, directory, max_to_keep=2) + checkpoint.restore(manager.latest_checkpoint).run_restore_ops() + self.assertEqual(2, self.evaluate(checkpoint.save_counter)) + third_path = manager.save() + self.assertEqual([third_path], manager.checkpoints) + fourth_path = manager.save() + self.assertEqual([third_path, fourth_path], + manager.checkpoints) + fifth_path = manager.save() + self.assertEqual([fourth_path, fifth_path], + manager.checkpoints) + self.assertTrue(checkpoint_management.checkpoint_exists(first_path)) + self.assertTrue(checkpoint_management.checkpoint_exists(second_path)) + self.assertFalse(checkpoint_management.checkpoint_exists(third_path)) + self.assertTrue(checkpoint_management.checkpoint_exists(fourth_path)) + self.assertTrue(checkpoint_management.checkpoint_exists(fifth_path)) + + @test_util.run_in_graph_and_eager_modes + @test.mock.patch.object(checkpoint_management, "time") + def testClockReset(self, mock_time): + directory = self.get_temp_dir() + mock_time.time.return_value = 10000. + checkpoint = util.Checkpoint() + first_manager = checkpoint_management.CheckpointManager( + checkpoint, directory, max_to_keep=1, keep_checkpoint_every_n_hours=1.) + first_path = first_manager.save() + mock_time.time.return_value += 3600. + second_path = first_manager.save() + mock_time.time.return_value += 3600. + third_path = first_manager.save() + self.assertFalse(checkpoint_management.checkpoint_exists(first_path)) + self.assertTrue(checkpoint_management.checkpoint_exists(second_path)) + self.assertTrue(checkpoint_management.checkpoint_exists(third_path)) + self.assertEqual([third_path], first_manager.checkpoints) + state = checkpoint_management.get_checkpoint_state(directory) + self.assertEqual(13600., state.last_preserved_timestamp) + # Set the clock back in time + mock_time.time.return_value = 5000. + del first_manager + with test.mock.patch.object(logging, "warning") as mock_log: + second_manager = checkpoint_management.CheckpointManager( + checkpoint, directory, max_to_keep=1) + self.assertRegexpMatches( + str(mock_log.call_args), + "behind the last preserved checkpoint timestamp") + # We should err on the side of keeping checkpoints around when we're not + # sure whether they were preserved or not due to clock funkiness. + self.assertTrue(checkpoint_management.checkpoint_exists(second_path)) + # We know about the existing checkpoints, but they'll never be deleted and + # so won't go in the CheckpointState proto on save. + self.assertEqual(third_path, second_manager.latest_checkpoint) + self.assertEqual([], second_manager.checkpoints) + mock_time.time.return_value += 10. + fourth_path = second_manager.save() + self.assertTrue(checkpoint_management.checkpoint_exists(second_path)) + self.assertTrue(checkpoint_management.checkpoint_exists(third_path)) + self.assertEqual(fourth_path, second_manager.latest_checkpoint) + self.assertEqual([fourth_path], second_manager.checkpoints) + mock_time.time.return_value += 10. + fifth_path = second_manager.save() + self.assertTrue(checkpoint_management.checkpoint_exists(second_path)) + self.assertTrue(checkpoint_management.checkpoint_exists(third_path)) + self.assertEqual([fifth_path], second_manager.checkpoints) + state = checkpoint_management.get_checkpoint_state(directory) + self.assertEqual(5000., state.last_preserved_timestamp) + self.assertEqual([5020.], + state.all_model_checkpoint_timestamps) + + if __name__ == "__main__": test.main() diff --git a/tensorflow/python/training/checkpoint_state.proto b/tensorflow/python/training/checkpoint_state.proto index 9172a5c331..704f7fdc88 100644 --- a/tensorflow/python/training/checkpoint_state.proto +++ b/tensorflow/python/training/checkpoint_state.proto @@ -4,8 +4,6 @@ package tensorflow; option cc_enable_arenas = true; // Protocol buffer representing the checkpoint state. -// -// TODO(touts): Add other attributes as needed. message CheckpointState { // Path to the most-recent model checkpoint. string model_checkpoint_path = 1; @@ -15,4 +13,10 @@ message CheckpointState { // Note that the value of model_checkpoint_path should be the last item in // this list. repeated string all_model_checkpoint_paths = 2; + // Unix timestamps corresponding to all_model_checkpoint_paths, indicating + // when each checkpoint was created. + repeated double all_model_checkpoint_timestamps = 3; + // Unix timestamp indicating the creation time for the last preserved + // checkpoint. + double last_preserved_timestamp = 4; } diff --git a/tensorflow/python/training/checkpointable/util.py b/tensorflow/python/training/checkpointable/util.py index 6c03bf0d51..e42f989469 100644 --- a/tensorflow/python/training/checkpointable/util.py +++ b/tensorflow/python/training/checkpointable/util.py @@ -35,8 +35,8 @@ from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import gen_io_ops as io_ops from tensorflow.python.ops import init_ops -from tensorflow.python.ops import resource_variable_ops from tensorflow.python.ops import variable_scope +from tensorflow.python.ops import variables from tensorflow.python.training import checkpoint_management from tensorflow.python.training import optimizer as optimizer_lib from tensorflow.python.training import saveable_object as saveable_object_lib @@ -227,10 +227,11 @@ def _default_getter(name, shape, dtype, initializer=None, def initial_value(): return initializer( shape_object.as_list(), dtype=dtype, partition_info=partition_info) - return resource_variable_ops.ResourceVariable( + return variables.Variable( initial_value=initial_value, name=name, dtype=variable_dtype, + use_resource=True, **kwargs ) @@ -1528,8 +1529,6 @@ class Checkpoint(tracking.Checkpointable): self._maybe_create_save_counter() return self._save_counter - # TODO(allenl): Update save's docstring with a pointer to - # tf.contrib.checkpoint.CheckpointManager once that's in. def save(self, file_prefix, session=None): """Saves a training checkpoint and provides basic checkpoint management. @@ -1541,7 +1540,8 @@ class Checkpoint(tracking.Checkpointable): sequentially numbering checkpoints using `save_counter` and updating the metadata used by `tf.train.latest_checkpoint`. More advanced checkpoint management, for example garbage collection and custom numbering, may be - provided by other utilities which also wrap `write`. + provided by other utilities which also wrap `write` + (`tf.contrib.checkpoint.CheckpointManager` for example). Args: file_prefix: A prefix to use for the checkpoint filenames diff --git a/tensorflow/python/training/checkpointable/util_test.py b/tensorflow/python/training/checkpointable/util_test.py index 98a42b1c20..a0a87b6b79 100644 --- a/tensorflow/python/training/checkpointable/util_test.py +++ b/tensorflow/python/training/checkpointable/util_test.py @@ -522,7 +522,6 @@ class CheckpointingTests(test.TestCase): # Does create garbage when executing eagerly due to ops.Graph() creation. num_training_steps = 10 checkpoint_directory = self.get_temp_dir() - checkpoint_prefix = os.path.join(checkpoint_directory, "ckpt") for training_continuation in range(3): with ops.Graph().as_default(), self.test_session( graph=ops.get_default_graph()), test_util.device(use_gpu=True): @@ -531,9 +530,9 @@ class CheckpointingTests(test.TestCase): root = checkpointable_utils.Checkpoint( optimizer=optimizer, model=model, global_step=training_util.get_or_create_global_step()) - checkpoint_path = checkpoint_management.latest_checkpoint( - checkpoint_directory) - status = root.restore(save_path=checkpoint_path) + manager = checkpoint_management.CheckpointManager( + root, checkpoint_directory, max_to_keep=1) + status = root.restore(save_path=manager.latest_checkpoint) input_value = constant_op.constant([[3.]]) train_fn = functools.partial( optimizer.minimize, @@ -544,7 +543,7 @@ class CheckpointingTests(test.TestCase): status.initialize_or_restore() for _ in range(num_training_steps): train_fn() - root.save(file_prefix=checkpoint_prefix) + manager.save() self.assertEqual((training_continuation + 1) * num_training_steps, self.evaluate(root.global_step)) self.assertEqual(training_continuation + 1, diff --git a/tensorflow/tools/api/golden/v1/tensorflow.train.pbtxt b/tensorflow/tools/api/golden/v1/tensorflow.train.pbtxt index b0fb04d7d4..9f35395284 100644 --- a/tensorflow/tools/api/golden/v1/tensorflow.train.pbtxt +++ b/tensorflow/tools/api/golden/v1/tensorflow.train.pbtxt @@ -298,7 +298,7 @@ tf_module { } member_method { name: "generate_checkpoint_state_proto" - argspec: "args=[\'save_dir\', \'model_checkpoint_path\', \'all_model_checkpoint_paths\'], varargs=None, keywords=None, defaults=[\'None\'], " + argspec: "args=[\'save_dir\', \'model_checkpoint_path\', \'all_model_checkpoint_paths\', \'all_model_checkpoint_timestamps\', \'last_preserved_timestamp\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\'], " } member_method { name: "get_checkpoint_mtimes" @@ -446,7 +446,7 @@ tf_module { } member_method { name: "update_checkpoint_state" - argspec: "args=[\'save_dir\', \'model_checkpoint_path\', \'all_model_checkpoint_paths\', \'latest_filename\'], varargs=None, keywords=None, defaults=[\'None\', \'None\'], " + argspec: "args=[\'save_dir\', \'model_checkpoint_path\', \'all_model_checkpoint_paths\', \'latest_filename\', \'all_model_checkpoint_timestamps\', \'last_preserved_timestamp\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], " } member_method { name: "warm_start" -- GitLab From f77a5d0df0023b1c72e6fad453fbda2770e10b3d Mon Sep 17 00:00:00 2001 From: Asim Shankar Date: Mon, 13 Aug 2018 16:59:32 -0700 Subject: [PATCH 433/437] Automated rollback of commit 165598d826170becd03692af2fa34151f9497f7f PiperOrigin-RevId: 208567907 --- tensorflow/docs_src/guide/eager.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tensorflow/docs_src/guide/eager.md b/tensorflow/docs_src/guide/eager.md index 017fdaf81e..24f6e4ee95 100644 --- a/tensorflow/docs_src/guide/eager.md +++ b/tensorflow/docs_src/guide/eager.md @@ -193,7 +193,8 @@ class MNISTModel(tf.keras.Model): def call(self, input): """Run the model.""" result = self.dense1(input) - result = self.dense2(result) # reuse variables from dense1 layer + result = self.dense2(result) + result = self.dense2(result) # reuse variables from dense2 layer return result model = MNISTModel() -- GitLab From 64acb73e0a970a8f177854a4286979acd40903d6 Mon Sep 17 00:00:00 2001 From: Asim Shankar Date: Mon, 13 Aug 2018 17:39:45 -0700 Subject: [PATCH 434/437] [Java]: Release 1.10.0 Fixes #16660 PiperOrigin-RevId: 208573227 --- tensorflow/java/maven/hadoop/pom.xml | 2 +- tensorflow/java/maven/libtensorflow/pom.xml | 2 +- tensorflow/java/maven/libtensorflow_jni/pom.xml | 2 +- tensorflow/java/maven/libtensorflow_jni_gpu/pom.xml | 2 +- tensorflow/java/maven/pom.xml | 2 +- tensorflow/java/maven/proto/pom.xml | 2 +- tensorflow/java/maven/run_inside_container.sh | 6 ++++++ tensorflow/java/maven/spark-connector/pom.xml | 2 +- tensorflow/java/maven/tensorflow/pom.xml | 2 +- 9 files changed, 14 insertions(+), 8 deletions(-) diff --git a/tensorflow/java/maven/hadoop/pom.xml b/tensorflow/java/maven/hadoop/pom.xml index 7fa751a46a..e0409fa41b 100644 --- a/tensorflow/java/maven/hadoop/pom.xml +++ b/tensorflow/java/maven/hadoop/pom.xml @@ -5,7 +5,7 @@ org.tensorflow hadoop jar - 1.10.0-rc1 + 1.10.0 tensorflow-hadoop https://www.tensorflow.org TensorFlow TFRecord InputFormat/OutputFormat for Apache Hadoop diff --git a/tensorflow/java/maven/libtensorflow/pom.xml b/tensorflow/java/maven/libtensorflow/pom.xml index 8ecabfd399..f9093ce385 100644 --- a/tensorflow/java/maven/libtensorflow/pom.xml +++ b/tensorflow/java/maven/libtensorflow/pom.xml @@ -6,7 +6,7 @@ org.tensorflow parentpom - 1.10.0-rc1 + 1.10.0 ../ libtensorflow diff --git a/tensorflow/java/maven/libtensorflow_jni/pom.xml b/tensorflow/java/maven/libtensorflow_jni/pom.xml index e03ce32216..1208956dec 100644 --- a/tensorflow/java/maven/libtensorflow_jni/pom.xml +++ b/tensorflow/java/maven/libtensorflow_jni/pom.xml @@ -6,7 +6,7 @@ org.tensorflow parentpom - 1.10.0-rc1 + 1.10.0 ../ libtensorflow_jni diff --git a/tensorflow/java/maven/libtensorflow_jni_gpu/pom.xml b/tensorflow/java/maven/libtensorflow_jni_gpu/pom.xml index fee840f547..755449cb3c 100644 --- a/tensorflow/java/maven/libtensorflow_jni_gpu/pom.xml +++ b/tensorflow/java/maven/libtensorflow_jni_gpu/pom.xml @@ -6,7 +6,7 @@ org.tensorflow parentpom - 1.10.0-rc1 + 1.10.0 ../ libtensorflow_jni_gpu diff --git a/tensorflow/java/maven/pom.xml b/tensorflow/java/maven/pom.xml index 0c33819b2b..035077e1e0 100644 --- a/tensorflow/java/maven/pom.xml +++ b/tensorflow/java/maven/pom.xml @@ -6,7 +6,7 @@ 4.0.0 org.tensorflow parentpom - 1.10.0-rc1 + 1.10.0 pom https://www.tensorflow.org diff --git a/tensorflow/java/maven/proto/pom.xml b/tensorflow/java/maven/proto/pom.xml index 2af7a5cd2e..b89f042567 100644 --- a/tensorflow/java/maven/proto/pom.xml +++ b/tensorflow/java/maven/proto/pom.xml @@ -6,7 +6,7 @@ org.tensorflow parentpom - 1.10.0-rc1 + 1.10.0 ../ proto diff --git a/tensorflow/java/maven/run_inside_container.sh b/tensorflow/java/maven/run_inside_container.sh index f4794d68a9..8c4c9d498c 100644 --- a/tensorflow/java/maven/run_inside_container.sh +++ b/tensorflow/java/maven/run_inside_container.sh @@ -110,11 +110,17 @@ download_libtensorflow_jni_gpu() { cd "${NATIVE_DIR}" mkdir linux-x86_64 + mkdir windows-x86_64 curl -L "${RELEASE_URL_PREFIX}/libtensorflow_jni-gpu-linux-x86_64-${TF_VERSION}.tar.gz" | tar -xvz -C linux-x86_64 + curl -L "${RELEASE_URL_PREFIX}/libtensorflow_jni-gpu-windows-x86_64-${TF_VERSION}.zip" -o /tmp/windows.zip + + unzip /tmp/windows.zip -d windows-x86_64 + rm -f /tmp/windows.zip # Updated timestamps seem to be required to get Maven to pick up the file. touch linux-x86_64/* + touch windows-x86_64/* cd "${DIR}" } diff --git a/tensorflow/java/maven/spark-connector/pom.xml b/tensorflow/java/maven/spark-connector/pom.xml index 27d9b54c6c..31e39c588a 100644 --- a/tensorflow/java/maven/spark-connector/pom.xml +++ b/tensorflow/java/maven/spark-connector/pom.xml @@ -6,7 +6,7 @@ org.tensorflow spark-connector_2.11 jar - 1.10.0-rc1 + 1.10.0 spark-tensorflow-connector https://www.tensorflow.org TensorFlow TFRecord connector for Apache Spark DataFrames diff --git a/tensorflow/java/maven/tensorflow/pom.xml b/tensorflow/java/maven/tensorflow/pom.xml index c952545bc6..0de90244b1 100644 --- a/tensorflow/java/maven/tensorflow/pom.xml +++ b/tensorflow/java/maven/tensorflow/pom.xml @@ -6,7 +6,7 @@ org.tensorflow parentpom - 1.10.0-rc1 + 1.10.0 ../ tensorflow -- GitLab From ab755c94beffc0531ca24b157858b3a10d10f397 Mon Sep 17 00:00:00 2001 From: Dustin Tran Date: Mon, 13 Aug 2018 17:59:45 -0700 Subject: [PATCH 435/437] Fix recurrent tutorial's code snippet. PiperOrigin-RevId: 208575390 --- tensorflow/docs_src/tutorials/sequences/recurrent.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tensorflow/docs_src/tutorials/sequences/recurrent.md b/tensorflow/docs_src/tutorials/sequences/recurrent.md index 715cc7856a..10d60f7966 100644 --- a/tensorflow/docs_src/tutorials/sequences/recurrent.md +++ b/tensorflow/docs_src/tutorials/sequences/recurrent.md @@ -77,9 +77,7 @@ The basic pseudocode is as follows: words_in_dataset = tf.placeholder(tf.float32, [time_steps, batch_size, num_features]) lstm = tf.contrib.rnn.BasicLSTMCell(lstm_size) # Initial state of the LSTM memory. -hidden_state = tf.zeros([batch_size, lstm.state_size]) -current_state = tf.zeros([batch_size, lstm.state_size]) -state = hidden_state, current_state +state = lstm.zero_state(batch_size, dtype=tf.float32) probabilities = [] loss = 0.0 for current_batch_of_words in words_in_dataset: @@ -112,7 +110,7 @@ words = tf.placeholder(tf.int32, [batch_size, num_steps]) lstm = tf.contrib.rnn.BasicLSTMCell(lstm_size) # Initial state of the LSTM memory. -initial_state = state = tf.zeros([batch_size, lstm.state_size]) +initial_state = state = lstm.zero_state(batch_size, dtype=tf.float32) for i in range(num_steps): # The value of state is updated after processing each batch of words. -- GitLab From e447ae4759317156d31a9421290716f0ffbffcd8 Mon Sep 17 00:00:00 2001 From: Amit Patankar Date: Mon, 13 Aug 2018 21:05:47 -0700 Subject: [PATCH 436/437] Add the keras pip packages to the Dockerfiles. PiperOrigin-RevId: 208590275 --- tensorflow/tools/docker/Dockerfile.devel | 2 ++ tensorflow/tools/docker/Dockerfile.devel-gpu | 2 ++ tensorflow/tools/docker/Dockerfile.devel-gpu-cuda9-cudnn7 | 2 ++ tensorflow/tools/docker/Dockerfile.devel-mkl | 3 ++- tensorflow/tools/docker/Dockerfile.devel-mkl-horovod | 2 ++ tensorflow/tools/docker/Dockerfile.gpu | 2 ++ tensorflow/tools/docker/Dockerfile.mkl | 2 ++ tensorflow/tools/docker/Dockerfile.mkl-horovod | 2 ++ 8 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tensorflow/tools/docker/Dockerfile.devel b/tensorflow/tools/docker/Dockerfile.devel index 6552588fac..0157ba892e 100644 --- a/tensorflow/tools/docker/Dockerfile.devel +++ b/tensorflow/tools/docker/Dockerfile.devel @@ -33,6 +33,8 @@ RUN pip --no-cache-dir install \ h5py \ ipykernel \ jupyter \ + keras_applications == 1.0.4 \ + keras_preprocessing == 1.0.2 \ matplotlib \ mock \ numpy==1.14.5 \ diff --git a/tensorflow/tools/docker/Dockerfile.devel-gpu b/tensorflow/tools/docker/Dockerfile.devel-gpu index f4c83f85d4..2d46af65bc 100644 --- a/tensorflow/tools/docker/Dockerfile.devel-gpu +++ b/tensorflow/tools/docker/Dockerfile.devel-gpu @@ -49,6 +49,8 @@ RUN pip --no-cache-dir install \ h5py \ ipykernel \ jupyter \ + keras_applications == 1.0.4 \ + keras_preprocessing == 1.0.2 \ matplotlib \ mock \ numpy==1.14.5 \ diff --git a/tensorflow/tools/docker/Dockerfile.devel-gpu-cuda9-cudnn7 b/tensorflow/tools/docker/Dockerfile.devel-gpu-cuda9-cudnn7 index 30bc2d2806..7fe97a1214 100644 --- a/tensorflow/tools/docker/Dockerfile.devel-gpu-cuda9-cudnn7 +++ b/tensorflow/tools/docker/Dockerfile.devel-gpu-cuda9-cudnn7 @@ -37,6 +37,8 @@ RUN pip --no-cache-dir install --upgrade \ RUN pip --no-cache-dir install \ ipykernel \ jupyter \ + keras_applications == 1.0.4 \ + keras_preprocessing == 1.0.2 \ matplotlib \ numpy \ scipy \ diff --git a/tensorflow/tools/docker/Dockerfile.devel-mkl b/tensorflow/tools/docker/Dockerfile.devel-mkl index 01d7adf1ee..2a1903c224 100755 --- a/tensorflow/tools/docker/Dockerfile.devel-mkl +++ b/tensorflow/tools/docker/Dockerfile.devel-mkl @@ -41,13 +41,14 @@ RUN ${PIP} --no-cache-dir install \ h5py \ ipykernel \ jupyter \ + keras_applications == 1.0.4 \ + keras_preprocessing == 1.0.2 \ matplotlib \ mock \ numpy \ scipy \ sklearn \ pandas \ - keras_applications \ && \ ${PYTHON} -m ipykernel.kernelspec diff --git a/tensorflow/tools/docker/Dockerfile.devel-mkl-horovod b/tensorflow/tools/docker/Dockerfile.devel-mkl-horovod index cf69fb9033..a87cbf472d 100755 --- a/tensorflow/tools/docker/Dockerfile.devel-mkl-horovod +++ b/tensorflow/tools/docker/Dockerfile.devel-mkl-horovod @@ -45,6 +45,8 @@ RUN ${PIP} --no-cache-dir install \ h5py \ ipykernel \ jupyter \ + keras_applications == 1.0.4 \ + keras_preprocessing == 1.0.2 \ matplotlib \ mock \ numpy \ diff --git a/tensorflow/tools/docker/Dockerfile.gpu b/tensorflow/tools/docker/Dockerfile.gpu index 5ec1e60f00..7b1870c5b9 100644 --- a/tensorflow/tools/docker/Dockerfile.gpu +++ b/tensorflow/tools/docker/Dockerfile.gpu @@ -37,6 +37,8 @@ RUN pip --no-cache-dir install \ h5py \ ipykernel \ jupyter \ + keras_applications == 1.0.4 \ + keras_preprocessing == 1.0.2 \ matplotlib \ numpy==1.14.5 \ pandas \ diff --git a/tensorflow/tools/docker/Dockerfile.mkl b/tensorflow/tools/docker/Dockerfile.mkl index ad5109f26d..f0bd9fcd7f 100755 --- a/tensorflow/tools/docker/Dockerfile.mkl +++ b/tensorflow/tools/docker/Dockerfile.mkl @@ -38,6 +38,8 @@ RUN ${PIP} --no-cache-dir install \ h5py \ ipykernel \ jupyter \ + keras_applications == 1.0.4 \ + keras_preprocessing == 1.0.2 \ matplotlib \ numpy \ pandas \ diff --git a/tensorflow/tools/docker/Dockerfile.mkl-horovod b/tensorflow/tools/docker/Dockerfile.mkl-horovod index 9485a5bff6..91fa037bf6 100755 --- a/tensorflow/tools/docker/Dockerfile.mkl-horovod +++ b/tensorflow/tools/docker/Dockerfile.mkl-horovod @@ -38,6 +38,8 @@ RUN ${PIP} --no-cache-dir install \ h5py \ ipykernel \ jupyter \ + keras_applications == 1.0.4 \ + keras_preprocessing == 1.0.2 \ matplotlib \ numpy \ pandas \ -- GitLab From cb53bfaf48588962f5799391d3a7a411dda72b49 Mon Sep 17 00:00:00 2001 From: Tayo Oguntebi Date: Mon, 13 Aug 2018 23:43:48 -0700 Subject: [PATCH 437/437] Modifies NonMaxSuppressionV4 output shape to be static. PiperOrigin-RevId: 208600876 --- tensorflow/core/framework/shape_inference.cc | 3 +- .../core/kernels/non_max_suppression_op.cc | 2 +- tensorflow/core/ops/image_ops.cc | 77 ++++++++----------- tensorflow/python/ops/image_ops_test.py | 35 +++++++++ 4 files changed, 71 insertions(+), 46 deletions(-) diff --git a/tensorflow/core/framework/shape_inference.cc b/tensorflow/core/framework/shape_inference.cc index 8d597e198d..3e77028a5f 100644 --- a/tensorflow/core/framework/shape_inference.cc +++ b/tensorflow/core/framework/shape_inference.cc @@ -950,8 +950,7 @@ Status InferenceContext::GetScalarFromTensor(const Tensor* t, int64* val) { *val = t->scalar()(); return Status::OK(); } else { - return errors::InvalidArgument( - "Scalar input for dim size must be int32 or int64"); + return errors::InvalidArgument("Scalar input must be int32 or int64."); } } diff --git a/tensorflow/core/kernels/non_max_suppression_op.cc b/tensorflow/core/kernels/non_max_suppression_op.cc index c7d0d4de0d..5d9257e20b 100644 --- a/tensorflow/core/kernels/non_max_suppression_op.cc +++ b/tensorflow/core/kernels/non_max_suppression_op.cc @@ -126,7 +126,7 @@ void DoNonMaxSuppressionOp( const Tensor& max_output_size, const float score_threshold, const std::function& suppress_check_fn, bool pad_to_max_output_size = false, int* ptr_num_valid_outputs = nullptr) { - const int output_size = std::min(max_output_size.scalar()(), num_boxes); + const int output_size = max_output_size.scalar()(); std::vector scores_data(num_boxes); std::copy_n(scores.flat().data(), num_boxes, scores_data.begin()); diff --git a/tensorflow/core/ops/image_ops.cc b/tensorflow/core/ops/image_ops.cc index 81f324a3ef..11ca0bd259 100644 --- a/tensorflow/core/ops/image_ops.cc +++ b/tensorflow/core/ops/image_ops.cc @@ -108,6 +108,29 @@ Status ColorspaceShapeFn(InferenceContext* c) { return Status::OK(); } +Status NMSShapeFn(InferenceContext* c) { + // Get inputs and validate ranks. + ShapeHandle boxes; + TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 2, &boxes)); + ShapeHandle scores; + TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 1, &scores)); + ShapeHandle max_output_size; + TF_RETURN_IF_ERROR(c->WithRank(c->input(2), 0, &max_output_size)); + ShapeHandle iou_threshold; + TF_RETURN_IF_ERROR(c->WithRank(c->input(3), 0, &iou_threshold)); + ShapeHandle score_threshold; + TF_RETURN_IF_ERROR(c->WithRank(c->input(4), 0, &score_threshold)); + // The boxes is a 2-D float Tensor of shape [num_boxes, 4]. + DimensionHandle unused; + // The boxes[0] and scores[0] are both num_boxes. + TF_RETURN_IF_ERROR(c->Merge(c->Dim(boxes, 0), c->Dim(scores, 0), &unused)); + // The boxes[1] is 4. + TF_RETURN_IF_ERROR(c->WithValue(c->Dim(boxes, 1), 4, &unused)); + + c->set_output(0, c->Vector(c->UnknownDim())); + return Status::OK(); +} + } // namespace // -------------------------------------------------------------------------- @@ -694,29 +717,7 @@ REGISTER_OP("NonMaxSuppressionV3") .Input("iou_threshold: float") .Input("score_threshold: float") .Output("selected_indices: int32") - .SetShapeFn([](InferenceContext* c) { - // Get inputs and validate ranks. - ShapeHandle boxes; - TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 2, &boxes)); - ShapeHandle scores; - TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 1, &scores)); - ShapeHandle max_output_size; - TF_RETURN_IF_ERROR(c->WithRank(c->input(2), 0, &max_output_size)); - ShapeHandle iou_threshold; - TF_RETURN_IF_ERROR(c->WithRank(c->input(3), 0, &iou_threshold)); - ShapeHandle score_threshold; - TF_RETURN_IF_ERROR(c->WithRank(c->input(4), 0, &score_threshold)); - // The boxes is a 2-D float Tensor of shape [num_boxes, 4]. - DimensionHandle unused; - // The boxes[0] and scores[0] are both num_boxes. - TF_RETURN_IF_ERROR( - c->Merge(c->Dim(boxes, 0), c->Dim(scores, 0), &unused)); - // The boxes[1] is 4. - TF_RETURN_IF_ERROR(c->WithValue(c->Dim(boxes, 1), 4, &unused)); - - c->set_output(0, c->Vector(c->UnknownDim())); - return Status::OK(); - }); + .SetShapeFn(NMSShapeFn); REGISTER_OP("NonMaxSuppressionV4") .Input("boxes: float") @@ -728,26 +729,16 @@ REGISTER_OP("NonMaxSuppressionV4") .Output("valid_outputs: int32") .Attr("pad_to_max_output_size: bool = false") .SetShapeFn([](InferenceContext* c) { - // Get inputs and validate ranks. - ShapeHandle boxes; - TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 2, &boxes)); - ShapeHandle scores; - TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 1, &scores)); - ShapeHandle max_output_size; - TF_RETURN_IF_ERROR(c->WithRank(c->input(2), 0, &max_output_size)); - ShapeHandle iou_threshold; - TF_RETURN_IF_ERROR(c->WithRank(c->input(3), 0, &iou_threshold)); - ShapeHandle score_threshold; - TF_RETURN_IF_ERROR(c->WithRank(c->input(4), 0, &score_threshold)); - // The boxes is a 2-D float Tensor of shape [num_boxes, 4]. - DimensionHandle unused; - // The boxes[0] and scores[0] are both num_boxes. - TF_RETURN_IF_ERROR( - c->Merge(c->Dim(boxes, 0), c->Dim(scores, 0), &unused)); - // The boxes[1] is 4. - TF_RETURN_IF_ERROR(c->WithValue(c->Dim(boxes, 1), 4, &unused)); - - c->set_output(0, c->Vector(c->UnknownDim())); + TF_RETURN_IF_ERROR(NMSShapeFn(c)); + + bool pad_to_max; + TF_RETURN_IF_ERROR(c->GetAttr("pad_to_max_output_size", &pad_to_max)); + if (pad_to_max) { + // If padded, overwrite the shape of the output to be static. + DimensionHandle output_dim; + TF_RETURN_IF_ERROR(c->MakeDimForScalarInput(2, &output_dim)); + c->set_output(0, c->MakeShape({output_dim})); + } c->set_output(1, c->MakeShape({})); return Status::OK(); }); diff --git a/tensorflow/python/ops/image_ops_test.py b/tensorflow/python/ops/image_ops_test.py index 0e4193e23b..2c61bb232a 100644 --- a/tensorflow/python/ops/image_ops_test.py +++ b/tensorflow/python/ops/image_ops_test.py @@ -3658,6 +3658,41 @@ class NonMaxSuppressionTest(test_util.TensorFlowTestCase): image_ops.non_max_suppression(boxes, scores, 3, [[0.5]]) +class NonMaxSuppressionPaddedTest(test_util.TensorFlowTestCase): + + def testSelectFromThreeClusters(self): + boxes_np = [[0, 0, 1, 1], [0, 0.1, 1, 1.1], [0, -0.1, 1, 0.9], + [0, 10, 1, 11], [0, 10.1, 1, 11.1], [0, 100, 1, 101]] + scores_np = [0.9, 0.75, 0.6, 0.95, 0.5, 0.3] + max_output_size_np = 5 + iou_threshold_np = 0.5 + boxes = constant_op.constant(boxes_np) + scores = constant_op.constant(scores_np) + max_output_size = constant_op.constant(max_output_size_np) + iou_threshold = constant_op.constant(iou_threshold_np) + selected_indices_padded, num_valid_padded = \ + image_ops.non_max_suppression_padded( + boxes, + scores, + max_output_size, + iou_threshold, + pad_to_max_output_size=True) + selected_indices, num_valid = image_ops.non_max_suppression_padded( + boxes, + scores, + max_output_size, + iou_threshold, + pad_to_max_output_size=False) + # The output shape of the padded operation must be fully defined. + self.assertEqual(selected_indices_padded.shape.is_fully_defined(), True) + self.assertEqual(selected_indices.shape.is_fully_defined(), False) + with self.test_session(): + self.assertAllClose(selected_indices_padded.eval(), [3, 0, 5, 0, 0]) + self.assertEqual(num_valid_padded.eval(), 3) + self.assertAllClose(selected_indices.eval(), [3, 0, 5]) + self.assertEqual(num_valid.eval(), 3) + + class VerifyCompatibleImageShapesTest(test_util.TensorFlowTestCase): """Tests utility function used by ssim() and psnr().""" -- GitLab