aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--CODEOWNERS94
-rw-r--r--CONTRIBUTING.md3
-rw-r--r--configure.py16
-rw-r--r--tensorflow/BUILD1
-rw-r--r--tensorflow/c/c_test_util.h2
-rw-r--r--tensorflow/c/eager/tape.h2
-rw-r--r--tensorflow/cc/gradients/math_grad.cc18
-rw-r--r--tensorflow/cc/gradients/math_grad_test.cc8
-rw-r--r--tensorflow/compiler/aot/tests/make_test_graphs.py9
-rw-r--r--tensorflow/compiler/tf2xla/xla_context.h2
-rw-r--r--tensorflow/compiler/xla/array.h1
-rw-r--r--tensorflow/compiler/xla/client/computation_builder.h2
-rw-r--r--tensorflow/compiler/xla/service/copy_insertion_test.cc2
-rw-r--r--tensorflow/compiler/xla/service/cpu/cpu_runtime_avx.h6
-rw-r--r--tensorflow/compiler/xla/service/cpu/cpu_runtime_neon.h6
-rw-r--r--tensorflow/compiler/xla/service/cpu/cpu_runtime_sse4_1.h6
-rw-r--r--tensorflow/compiler/xla/service/cpu/llvm_ir_runtime.cc10
-rw-r--r--tensorflow/compiler/xla/service/cpu/simple_orc_jit.cc32
-rw-r--r--tensorflow/compiler/xla/service/gpu/while_transformer.cc2
-rw-r--r--tensorflow/compiler/xla/service/heap_simulator.h2
-rw-r--r--tensorflow/compiler/xla/service/hlo_graph_dumper.cc11
-rw-r--r--tensorflow/compiler/xla/service/llvm_ir/kernel_support_library.cc11
-rw-r--r--tensorflow/compiler/xla/shape_tree.h2
-rw-r--r--tensorflow/compiler/xla/util.h3
-rw-r--r--tensorflow/contrib/BUILD1
-rw-r--r--tensorflow/contrib/android/README.md4
-rw-r--r--tensorflow/contrib/batching/BUILD4
-rw-r--r--tensorflow/contrib/batching/shared_batch_scheduler.h2
-rw-r--r--tensorflow/contrib/cmake/CMakeLists.txt12
-rw-r--r--tensorflow/contrib/cmake/python_modules.txt4
-rw-r--r--tensorflow/contrib/cmake/tf_core_kernels.cmake2
-rw-r--r--tensorflow/contrib/data/python/kernel_tests/BUILD2
-rw-r--r--tensorflow/contrib/gan/README.md16
-rw-r--r--tensorflow/contrib/learn/python/learn/learn_io/data_feeder.py4
-rw-r--r--tensorflow/contrib/libsvm/BUILD102
-rw-r--r--tensorflow/contrib/libsvm/__init__.py32
-rw-r--r--tensorflow/contrib/libsvm/kernels/decode_libsvm_op.cc178
-rw-r--r--tensorflow/contrib/libsvm/ops/libsvm_ops.cc58
-rw-r--r--tensorflow/contrib/libsvm/python/kernel_tests/decode_libsvm_op_test.py71
-rw-r--r--tensorflow/contrib/libsvm/python/ops/libsvm_ops.py50
-rw-r--r--tensorflow/contrib/lite/README.md2
-rw-r--r--tensorflow/contrib/lite/g3doc/ios.md4
-rw-r--r--tensorflow/contrib/lite/kernels/internal/BUILD9
-rw-r--r--tensorflow/contrib/lite/kernels/internal/reference/portable_tensor_utils.h2
-rw-r--r--tensorflow/contrib/lite/kernels/internal/tensor_utils.h2
-rw-r--r--tensorflow/contrib/lite/toco/graph_transformations/resolve_tensorflow_switch.cc2
-rw-r--r--tensorflow/contrib/lite/toco/import_tensorflow.cc2
-rw-r--r--tensorflow/contrib/memory_stats/kernels/memory_stats_ops.cc2
-rw-r--r--tensorflow/contrib/opt/__init__.py2
-rw-r--r--tensorflow/contrib/opt/python/training/elastic_average_optimizer.py9
-rw-r--r--tensorflow/contrib/opt/python/training/elastic_average_optimizer_test.py2
-rw-r--r--tensorflow/contrib/seq2seq/python/ops/helper.py3
-rw-r--r--tensorflow/contrib/tpu/profiler/pip_package/setup.py2
-rw-r--r--tensorflow/core/BUILD1
-rw-r--r--tensorflow/core/api_def/base_api/api_def_DecodeCompressed.pbtxt32
-rw-r--r--tensorflow/core/api_def/base_api/api_def_RecordInput.pbtxt7
-rw-r--r--tensorflow/core/framework/numeric_types.h1
-rw-r--r--tensorflow/core/grappler/costs/virtual_placer.h2
-rw-r--r--tensorflow/core/grappler/costs/virtual_scheduler_test.cc2
-rw-r--r--tensorflow/core/grappler/optimizers/dependency_optimizer.cc2
-rw-r--r--tensorflow/core/kernels/BUILD9
-rw-r--r--tensorflow/core/kernels/bucketize_op_gpu.cu.cc38
-rw-r--r--tensorflow/core/kernels/cwise_op_exp.cc3
-rw-r--r--tensorflow/core/kernels/cwise_op_gpu_exp.cu.cc2
-rw-r--r--tensorflow/core/kernels/cwise_ops.h40
-rw-r--r--tensorflow/core/kernels/decode_compressed_op.cc125
-rw-r--r--tensorflow/core/kernels/record_input_op.cc2
-rw-r--r--tensorflow/core/kernels/record_yielder.cc5
-rw-r--r--tensorflow/core/kernels/record_yielder.h2
-rw-r--r--tensorflow/core/kernels/slice_op.cc1
-rw-r--r--tensorflow/core/kernels/unique_op.cc6
-rw-r--r--tensorflow/core/kernels/unpack_op.cc13
-rw-r--r--tensorflow/core/lib/strings/str_util_test.cc2
-rw-r--r--tensorflow/core/ops/data_flow_ops.cc3
-rw-r--r--tensorflow/core/ops/parsing_ops.cc22
-rw-r--r--tensorflow/core/platform/cloud/file_block_cache_test.cc2
-rw-r--r--tensorflow/core/platform/default/mutex.h2
-rw-r--r--tensorflow/core/platform/env.cc65
-rw-r--r--tensorflow/core/platform/env.h4
-rw-r--r--tensorflow/core/platform/env_test.cc15
-rw-r--r--tensorflow/core/platform/macros.h3
-rw-r--r--tensorflow/core/public/session.h2
-rw-r--r--tensorflow/core/public/version.h2
-rw-r--r--tensorflow/core/util/strided_slice_op.cc4
-rw-r--r--tensorflow/core/util/tensor_slice_reader.h1
-rw-r--r--tensorflow/core/util/tensor_slice_reader_cache.h1
-rw-r--r--tensorflow/core/util/tensor_slice_writer.h1
-rw-r--r--tensorflow/docs_src/get_started/feature_columns.md2
-rw-r--r--tensorflow/docs_src/get_started/get_started.md2
-rw-r--r--tensorflow/docs_src/mobile/tflite/index.md2
-rw-r--r--tensorflow/docs_src/programmers_guide/debugger.md4
-rw-r--r--tensorflow/docs_src/programmers_guide/variables.md2
-rw-r--r--tensorflow/examples/how_tos/reading_data/fully_connected_reader.py4
-rw-r--r--tensorflow/examples/ios/.gitignore3
-rw-r--r--tensorflow/go/README.md9
-rw-r--r--tensorflow/go/genop/generate.sh5
-rw-r--r--tensorflow/go/genop/main.go2
-rw-r--r--tensorflow/java/src/gen/java/org/tensorflow/processor/OperatorProcessor.java2
-rw-r--r--tensorflow/java/src/test/java/org/tensorflow/SessionTest.java2
-rw-r--r--tensorflow/python/debug/wrappers/grpc_wrapper.py5
-rw-r--r--tensorflow/python/debug/wrappers/hooks.py4
-rw-r--r--tensorflow/python/kernel_tests/BUILD13
-rw-r--r--tensorflow/python/kernel_tests/cwise_ops_test.py4
-rw-r--r--tensorflow/python/kernel_tests/decode_compressed_op_test.py73
-rw-r--r--tensorflow/python/kernel_tests/dynamic_partition_op_test.py5
-rw-r--r--tensorflow/python/kernel_tests/lookup_ops_test.py23
-rw-r--r--tensorflow/python/kernel_tests/record_input_test.py47
-rw-r--r--tensorflow/python/kernel_tests/svd_op_test.py32
-rw-r--r--tensorflow/python/kernel_tests/unstack_op_test.py39
-rw-r--r--tensorflow/python/kernel_tests/variable_scope_test.py124
-rw-r--r--tensorflow/python/layers/base.py7
-rw-r--r--tensorflow/python/layers/base_test.py57
-rw-r--r--tensorflow/python/layers/convolutional.py52
-rw-r--r--tensorflow/python/layers/core.py2
-rw-r--r--tensorflow/python/layers/network.py18
-rw-r--r--tensorflow/python/lib/core/py_func.cc3
-rw-r--r--tensorflow/python/ops/data_flow_ops.py12
-rw-r--r--tensorflow/python/ops/linalg_grad.py71
-rw-r--r--tensorflow/python/ops/lookup_ops.py11
-rw-r--r--tensorflow/python/ops/math_ops.py4
-rw-r--r--tensorflow/python/ops/nn_ops.py23
-rw-r--r--tensorflow/python/ops/variable_scope.py38
-rw-r--r--tensorflow/python/util/util.cc2
-rw-r--r--tensorflow/stream_executor/cuda/cuda_dnn.cc2
-rw-r--r--tensorflow/stream_executor/cuda/cuda_gpu_executor.cc3
-rw-r--r--tensorflow/stream_executor/dnn.h6
-rw-r--r--tensorflow/tensorflow.bzl67
-rw-r--r--tensorflow/tools/api/golden/tensorflow.variable_scope.pbtxt2
-rw-r--r--tensorflow/tools/api/tests/api_compatibility_test.py4
-rw-r--r--tensorflow/tools/ci_build/windows/bazel/bazel_test_lib.sh1
-rwxr-xr-xtensorflow/tools/git/gen_git_source.py7
-rwxr-xr-xtensorflow/tools/git/gen_git_source.sh7
-rw-r--r--tensorflow/tools/graph_transforms/quantize_nodes.cc4
-rw-r--r--tensorflow/tools/pip_package/setup.py3
-rw-r--r--tensorflow/workspace.bzl16
-rw-r--r--third_party/eigen3/unsupported/Eigen/CXX11/src/NeuralNetworks/Patch3d.h2
-rw-r--r--third_party/flatbuffers/flatbuffers.BUILD19
137 files changed, 1716 insertions, 393 deletions
diff --git a/CODEOWNERS b/CODEOWNERS
index 57a4df40e6..007a304c3e 100644
--- a/CODEOWNERS
+++ b/CODEOWNERS
@@ -1,53 +1,53 @@
# NOTE: Disabled temporarily because it's too noisy on pushes.
# Where component owners are known, add them here.
-#tensorflow/core/platform/windows/* @mrry
-#tensorflow/java/* @asimshankar
-#tensorflow/tensorboard/* @jart @dandelionmane
-#tensorflow/tools/docs/* @markdaoust
+# /tensorflow/core/platform/windows/ @mrry
+# /tensorflow/java/ @asimshankar
+# /tensorflow/tensorboard/ @jart @dandelionmane
+# /tensorflow/tools/docs/ @markdaoust
# contrib
-# NEED OWNER: tensorflow/contrib/avro/*
-#tensorflow/contrib/batching/* @alextp @chrisolston
-#tensorflow/contrib/bayesflow/* @ebrevdo @rsepassi @jvdillon
-#tensorflow/contrib/boosted_trees/* @sshrdp @yk5 @nataliaponomareva
-#tensorflow/contrib/cmake/* @mrry @benoitsteiner
-#tensorflow/contrib/copy_graph/* @tucker @poxvoculi
-#tensorflow/contrib/crf/* @kentonl
-#tensorflow/contrib/data/* @mrry
-#tensorflow/contrib/distributions/* @jvdillon @langmore @rsepassi
-#tensorflow/contrib/factorization/* @agarwal-ashish @xavigonzalvo
-#tensorflow/contrib/ffmpeg/* @fredbertsch
-# NEED OWNER: tensorflow/contrib/framework/*
-#tensorflow/contrib/graph_editor/* @purpledog
-# NEED OWNER: tensorflow/contrib/grid_rnn/*
-#tensorflow/contrib/hvx/* @satok16
-#tensorflow/contrib/integrate/* @shoyer
-#tensorflow/contrib/kernel_methods/* @petrosmol
-#tensorflow/contrib/ios_examples/* @petewarden
-#tensorflow/contrib/labeled_tensor/* @shoyer
-#tensorflow/contrib/layers/* @fchollet @martinwicke
-#tensorflow/contrib/learn/* @martinwicke @ispirmustafa @alextp
-#tensorflow/contrib/linalg/* @langmore
-#tensorflow/contrib/linear_optimizer/* @petrosmol @andreasst @katsiapis
-#tensorflow/contrib/lookup/* @ysuematsu @andreasst
-#tensorflow/contrib/losses/* @alextp @ispirmustafa
-#tensorflow/contrib/makefile/* @petewarden @satok16 @wolffg
-#tensorflow/contrib/metrics/* @alextp @honkentuber @ispirmustafa
-#tensorflow/contrib/nccl/* @cwhipkey @zheng-xq
-#tensorflow/contrib/opt/* @strategist333
-#tensorflow/contrib/pi_examples/* @maciekcc
-#tensorflow/contrib/quantization/* @petewarden @cwhipkey @keveman
-#tensorflow/contrib/rnn/* @ebrevdo
-#tensorflow/contrib/saved_model/* @nfiedel @sukritiramesh
-#tensorflow/contrib/seq2seq/* @lukaszkaiser
-#tensorflow/contrib/session_bundle/* @nfiedel @sukritiramesh
-#tensorflow/contrib/slim/* @sguada @thenbasilmanran
-#tensorflow/contrib/stateless/* @girving
-#tensorflow/contrib/tensor_forest/* @gilberthendry @thomascolthurst
-#tensorflow/contrib/testing/* @dandelionmane
-#tensorflow/contrib/timeseries/* @allenlavoie
-#tensorflow/contrib/tpu/* @frankchn @saeta @jhseu
-#tensorflow/contrib/training/* @joel-shor @ebrevdo
-#tensorflow/contrib/util/* @sherrym
+# NEED OWNER: /tensorflow/contrib/avro/
+# /tensorflow/contrib/batching/ @alextp @chrisolston
+# /tensorflow/contrib/bayesflow/ @ebrevdo @rsepassi @jvdillon
+# /tensorflow/contrib/boosted_trees/ @sshrdp @yk5 @nataliaponomareva
+# /tensorflow/contrib/cmake/ @mrry @benoitsteiner
+# /tensorflow/contrib/copy_graph/ @tucker @poxvoculi
+# /tensorflow/contrib/crf/ @kentonl
+# /tensorflow/contrib/data/ @mrry
+# /tensorflow/contrib/distributions/ @jvdillon @langmore @rsepassi
+# /tensorflow/contrib/factorization/ @agarwal-ashish @xavigonzalvo
+# /tensorflow/contrib/ffmpeg/ @fredbertsch
+# NEED OWNER: /tensorflow/contrib/framework/
+# /tensorflow/contrib/graph_editor/ @purpledog
+# NEED OWNER: /tensorflow/contrib/grid_rnn/
+# /tensorflow/contrib/hvx/ @satok16
+# /tensorflow/contrib/integrate/ @shoyer
+# /tensorflow/contrib/kernel_methods/ @petrosmol
+# /tensorflow/contrib/ios_examples/ @petewarden
+# /tensorflow/contrib/labeled_tensor/ @shoyer
+# /tensorflow/contrib/layers/ @fchollet @martinwicke
+# /tensorflow/contrib/learn/ @martinwicke @ispirmustafa @alextp
+# /tensorflow/contrib/linalg/ @langmore
+# /tensorflow/contrib/linear_optimizer/ @petrosmol @andreasst @katsiapis
+# /tensorflow/contrib/lookup/ @ysuematsu @andreasst
+# /tensorflow/contrib/losses/ @alextp @ispirmustafa
+# /tensorflow/contrib/makefile/ @petewarden @satok16 @wolffg
+# /tensorflow/contrib/metrics/ @alextp @honkentuber @ispirmustafa
+# /tensorflow/contrib/nccl/ @cwhipkey @zheng-xq
+# /tensorflow/contrib/opt/ @strategist333
+# /tensorflow/contrib/pi_examples/ @maciekcc
+# /tensorflow/contrib/quantization/ @petewarden @cwhipkey @keveman
+# /tensorflow/contrib/rnn/ @ebrevdo
+# /tensorflow/contrib/saved_model/ @nfiedel @sukritiramesh
+# /tensorflow/contrib/seq2seq/ @lukaszkaiser
+# /tensorflow/contrib/session_bundle/ @nfiedel @sukritiramesh
+# /tensorflow/contrib/slim/ @sguada @thenbasilmanran
+# /tensorflow/contrib/stateless/ @girving
+# /tensorflow/contrib/tensor_forest/ @gilberthendry @thomascolthurst
+# /tensorflow/contrib/testing/ @dandelionmane
+# /tensorflow/contrib/timeseries/ @allenlavoie
+# /tensorflow/contrib/tpu/ @frankchn @saeta @jhseu
+# /tensorflow/contrib/training/ @joel-shor @ebrevdo
+# /tensorflow/contrib/util/ @sherrym
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 1b537ca73c..dc96bc2e3d 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -20,6 +20,9 @@ Follow either of the two links above to access the appropriate CLA and instructi
If you have improvements to TensorFlow, send us your pull requests! For those
just getting started, Github has a [howto](https://help.github.com/articles/using-pull-requests/).
+TensorFlow team members will be assigned to review your pull requests. Once the pull requests are approved and pass continuous integration checks, we will merge the pull requests.
+For some pull requests, we will apply the patch for each pull request to our internal version control system first, and export the change out as a new commit later, at which point the original pull request will be closed. The commits in the pull request will be squashed into a single commit with the pull request creator as the author. These pull requests will be labeled as pending merge internally.
+
If you want to contribute but you're not sure where to start, take a look at the
[issues with the "contributions welcome" label](https://github.com/tensorflow/tensorflow/labels/stat%3Acontributions%20welcome).
These are issues that we believe are particularly well suited for outside
diff --git a/configure.py b/configure.py
index 073bccad2b..1917af4b65 100644
--- a/configure.py
+++ b/configure.py
@@ -1133,22 +1133,6 @@ def set_trisycl_include_dir(environ_cp):
write_action_env_to_bazelrc('TRISYCL_INCLUDE_DIR',
trisycl_include_dir)
-def set_trisycl_include_dir(environ_cp):
- """Set TRISYCL_INCLUDE_DIR."""
-
- trisycl_include_dir = prompt_loop_or_load_from_env(
- environ_cp,
- var_name='TRISYCL_INCLUDE_DIR',
- var_default=_DEFAULT_TRISYCL_INCLUDE_DIR,
- ask_for_var=('Please specify the location of the triSYCL include '
- 'directory. (Use --config=sycl_trisycl when building with '
- 'Bazel)'),
- check_success=os.path.exists,
- error_msg='Invalid trySYCL include directory. %s cannot be found.',
- suppress_default_error=True)
-
- write_action_env_to_bazelrc('TRISYCL_INCLUDE_DIR', trisycl_include_dir)
-
def set_mpi_home(environ_cp):
"""Set MPI_HOME."""
diff --git a/tensorflow/BUILD b/tensorflow/BUILD
index 9437bef99f..5d639e7f8c 100644
--- a/tensorflow/BUILD
+++ b/tensorflow/BUILD
@@ -478,6 +478,7 @@ filegroup(
"//tensorflow/contrib/layers/kernels:all_files",
"//tensorflow/contrib/learn:all_files",
"//tensorflow/contrib/learn/python/learn/datasets:all_files",
+ "//tensorflow/contrib/libsvm:all_files",
"//tensorflow/contrib/linalg:all_files",
"//tensorflow/contrib/linear_optimizer:all_files",
"//tensorflow/contrib/lite:all_files",
diff --git a/tensorflow/c/c_test_util.h b/tensorflow/c/c_test_util.h
index 96a93afef3..3429009a71 100644
--- a/tensorflow/c/c_test_util.h
+++ b/tensorflow/c/c_test_util.h
@@ -77,7 +77,7 @@ TF_Operation* LessThan(TF_Output l, TF_Output r, TF_Graph* graph, TF_Status* s);
TF_Operation* RandomUniform(TF_Operation* shape, TF_DataType dtype,
TF_Graph* graph, TF_Status* s);
-// Split `input` along the first dimention into 3 tensors
+// Split `input` along the first dimension into 3 tensors
TF_Operation* Split3(TF_Operation* input, TF_Graph* graph, TF_Status* s,
const char* name = "split3");
diff --git a/tensorflow/c/eager/tape.h b/tensorflow/c/eager/tape.h
index 17c9c8cc9a..2b65e38f54 100644
--- a/tensorflow/c/eager/tape.h
+++ b/tensorflow/c/eager/tape.h
@@ -350,7 +350,7 @@ BackpropInitialState<BackwardFunction> PrepareBackprop(
// Call destructors for all unneeded gradient functions and
// clear the op_tape. We can clear the tape because ownership of
// backward functions that will be used for gradient computation
- // has been transfered to `result`.
+ // has been transferred to `result`.
for (const auto& op_pair : *op_tape) {
op_pair.second.backward_function_deleter();
}
diff --git a/tensorflow/cc/gradients/math_grad.cc b/tensorflow/cc/gradients/math_grad.cc
index d7446b9560..ebc0c77828 100644
--- a/tensorflow/cc/gradients/math_grad.cc
+++ b/tensorflow/cc/gradients/math_grad.cc
@@ -728,6 +728,24 @@ Status LgammaGrad(const Scope& scope, const Operation& op,
}
REGISTER_GRADIENT_OP("Lgamma", LgammaGrad);
+Status SelectGrad(const Scope& scope, const Operation& op,
+ const std::vector<Output>& grad_inputs,
+ std::vector<Output>* grad_outputs) {
+ auto comparator = op.input(0);
+ auto x = op.input(1);
+ auto zeros = ZerosLike(scope, x);
+ auto grad = grad_inputs[0];
+
+ auto gx_1 = Where3(scope, comparator, grad, zeros);
+ auto gx_2 = Where3(scope, comparator, zeros, grad);
+
+ grad_outputs->push_back(NoGradient());
+ grad_outputs->push_back(gx_1);
+ grad_outputs->push_back(gx_2);
+ return scope.status();
+}
+REGISTER_GRADIENT_OP("Select", SelectGrad);
+
Status MinOrMaxGrad(const Scope& scope, const Operation& op,
const std::vector<Output>& grad_inputs,
std::vector<Output>* grad_outputs) {
diff --git a/tensorflow/cc/gradients/math_grad_test.cc b/tensorflow/cc/gradients/math_grad_test.cc
index 6313f41da5..29def3c3ea 100644
--- a/tensorflow/cc/gradients/math_grad_test.cc
+++ b/tensorflow/cc/gradients/math_grad_test.cc
@@ -865,5 +865,13 @@ TEST_F(NaryGradTest, Minimum) {
RunTest(x, x_init_value, y, shape);
}
+TEST_F(NaryGradTest, Select) {
+ TensorShape shape({3, 4});
+ auto x1 = Placeholder(scope_, DT_FLOAT, Placeholder::Shape(shape));
+ auto x2 = Placeholder(scope_, DT_FLOAT, Placeholder::Shape(shape));
+ auto y = Where3(scope_, Greater(scope_, x1, x2), x1, x2);
+ RunTest({x1, x2}, {shape, shape}, {y}, {shape});
+}
+
} // namespace
} // namespace tensorflow
diff --git a/tensorflow/compiler/aot/tests/make_test_graphs.py b/tensorflow/compiler/aot/tests/make_test_graphs.py
index a898eab1d1..89c7cd4507 100644
--- a/tensorflow/compiler/aot/tests/make_test_graphs.py
+++ b/tensorflow/compiler/aot/tests/make_test_graphs.py
@@ -19,6 +19,7 @@ from __future__ import division
from __future__ import print_function
import argparse
+import os
import sys
from tensorflow.core.protobuf import saver_pb2
@@ -53,7 +54,7 @@ def tfadd_with_ckpt(out_dir):
sess.run(init_op)
sess.run(y.assign(y + 42))
# Without the checkpoint, the variable won't be set to 42.
- ckpt = '%s/test_graph_tfadd_with_ckpt.ckpt' % out_dir
+ ckpt = os.path.join(out_dir, 'test_graph_tfadd_with_ckpt.ckpt')
saver.save(sess, ckpt)
@@ -68,10 +69,10 @@ def tfadd_with_ckpt_saver(out_dir):
sess.run(init_op)
sess.run(y.assign(y + 42))
# Without the checkpoint, the variable won't be set to 42.
- ckpt_file = '%s/test_graph_tfadd_with_ckpt_saver.ckpt' % out_dir
+ ckpt_file = os.path.join(out_dir, 'test_graph_tfadd_with_ckpt_saver.ckpt')
saver.save(sess, ckpt_file)
# Without the SaverDef, the restore op won't be named correctly.
- saver_file = '%s/test_graph_tfadd_with_ckpt_saver.saver' % out_dir
+ saver_file = os.path.join(out_dir, 'test_graph_tfadd_with_ckpt_saver.saver')
with open(saver_file, 'wb') as f:
f.write(saver.as_saver_def().SerializeToString())
@@ -129,7 +130,7 @@ def write_graph(build_graph, out_dir):
g = ops.Graph()
with g.as_default():
build_graph(out_dir)
- filename = '%s/test_graph_%s.pb' % (out_dir, build_graph.__name__)
+ filename = os.path.join(out_dir, 'test_graph_%s.pb' % build_graph.__name__)
with open(filename, 'wb') as f:
f.write(g.as_graph_def().SerializeToString())
diff --git a/tensorflow/compiler/tf2xla/xla_context.h b/tensorflow/compiler/tf2xla/xla_context.h
index ebd758d154..1a7dafe8cd 100644
--- a/tensorflow/compiler/tf2xla/xla_context.h
+++ b/tensorflow/compiler/tf2xla/xla_context.h
@@ -116,7 +116,7 @@ class XlaContext : public ResourceBase {
const bool allow_cpu_custom_calls_;
// If true, constant return values are returned as Tensors instead of
- // run-time computation outptus.
+ // run-time computation outputs.
const bool resolve_compile_time_constants_;
// Arguments to the Tensorflow graph, indexed by _Arg index.
diff --git a/tensorflow/compiler/xla/array.h b/tensorflow/compiler/xla/array.h
index 213e0bac6c..71aa057cd3 100644
--- a/tensorflow/compiler/xla/array.h
+++ b/tensorflow/compiler/xla/array.h
@@ -22,6 +22,7 @@ limitations under the License.
#include <initializer_list>
#include <iterator>
#include <memory>
+#include <numeric>
#include <random>
#include <type_traits>
#include <vector>
diff --git a/tensorflow/compiler/xla/client/computation_builder.h b/tensorflow/compiler/xla/client/computation_builder.h
index daad09364c..7293b35c0f 100644
--- a/tensorflow/compiler/xla/client/computation_builder.h
+++ b/tensorflow/compiler/xla/client/computation_builder.h
@@ -770,7 +770,7 @@ class ComputationBuilder {
// The operand must represent a constant value, which in this case
// means that it must not statically depend on any parameter of the
// computation that is being built other then the ones specified on the
- // paramtere list. The parameters in the list will be indexed by their
+ // parameter list. The parameters in the list will be indexed by their
// parameter id property so the number of parameters specified should be at
// least as many as the largest used parameter index.
//
diff --git a/tensorflow/compiler/xla/service/copy_insertion_test.cc b/tensorflow/compiler/xla/service/copy_insertion_test.cc
index 3278fd5f06..8388574716 100644
--- a/tensorflow/compiler/xla/service/copy_insertion_test.cc
+++ b/tensorflow/compiler/xla/service/copy_insertion_test.cc
@@ -339,7 +339,7 @@ TEST_F(CopyInsertionTest, ElementOfNestedTupleParameter) {
ShapeUtil::MakeShape(F32, {42})}),
"param0"));
- // The return value of the computation is the zero-th elemnt of the nested
+ // The return value of the computation is the zero-th element of the nested
// tuple. This element is itself a tuple.
auto gte = builder.AddInstruction(HloInstruction::CreateGetTupleElement(
ShapeUtil::GetSubshape(param->shape(), {0}), param, 0));
diff --git a/tensorflow/compiler/xla/service/cpu/cpu_runtime_avx.h b/tensorflow/compiler/xla/service/cpu/cpu_runtime_avx.h
index acfada8540..74ae6d00c9 100644
--- a/tensorflow/compiler/xla/service/cpu/cpu_runtime_avx.h
+++ b/tensorflow/compiler/xla/service/cpu/cpu_runtime_avx.h
@@ -38,14 +38,16 @@ typedef float V8F32AVX __attribute__((__vector_size__(32)));
extern "C" {
+#ifdef __AVX__
// The following functions are vectorized versions of a selection of libm
// library functions.
// References to these functions are created by the LLVM vectorizer.
xla::cpu::runtime::V8F32AVX __xla_cpu_runtime_ExpV8F32AVX(
- xla::cpu::runtime::V8F32AVX x) TF_ATTRIBUTE_WEAK;
+ xla::cpu::runtime::V8F32AVX x);
xla::cpu::runtime::V8F32AVX __xla_cpu_runtime_LogV8F32AVX(
- xla::cpu::runtime::V8F32AVX x) TF_ATTRIBUTE_WEAK;
+ xla::cpu::runtime::V8F32AVX x);
+#endif
}
#endif // TENSORFLOW_COMPILER_XLA_SERVICE_CPU_CPU_RUNTIME_AVX_H_
diff --git a/tensorflow/compiler/xla/service/cpu/cpu_runtime_neon.h b/tensorflow/compiler/xla/service/cpu/cpu_runtime_neon.h
index 75cb16b273..645a43858f 100644
--- a/tensorflow/compiler/xla/service/cpu/cpu_runtime_neon.h
+++ b/tensorflow/compiler/xla/service/cpu/cpu_runtime_neon.h
@@ -49,14 +49,16 @@ struct V4F32NEON;
extern "C" {
+#ifdef __ARM_NEON__
// The following functions are vectorized versions of a selection of libm
// library functions.
// References to these functions are created by the LLVM vectorizer.
xla::cpu::runtime::V4F32NEON __xla_cpu_runtime_ExpV4F32NEON(
- xla::cpu::runtime::V4F32NEON x) TF_ATTRIBUTE_WEAK;
+ xla::cpu::runtime::V4F32NEON x);
xla::cpu::runtime::V4F32NEON __xla_cpu_runtime_LogV4F32NEON(
- xla::cpu::runtime::V4F32NEON x) TF_ATTRIBUTE_WEAK;
+ xla::cpu::runtime::V4F32NEON x);
+#endif // __ARM_NEON__
}
#endif // TENSORFLOW_COMPILER_XLA_SERVICE_CPU_CPU_RUNTIME_NEON_H_
diff --git a/tensorflow/compiler/xla/service/cpu/cpu_runtime_sse4_1.h b/tensorflow/compiler/xla/service/cpu/cpu_runtime_sse4_1.h
index 96587d10d2..80ca4243a2 100644
--- a/tensorflow/compiler/xla/service/cpu/cpu_runtime_sse4_1.h
+++ b/tensorflow/compiler/xla/service/cpu/cpu_runtime_sse4_1.h
@@ -39,14 +39,16 @@ typedef float V4F32SSE __attribute__((__vector_size__(16)));
extern "C" {
+#ifdef __SSE4_1__
// The following functions are vectorized versions of a selection of libm
// library functions.
// References to these functions are created by the LLVM vectorizer.
xla::cpu::runtime::V4F32SSE __xla_cpu_runtime_ExpV4F32SSE(
- xla::cpu::runtime::V4F32SSE x) TF_ATTRIBUTE_WEAK;
+ xla::cpu::runtime::V4F32SSE x);
xla::cpu::runtime::V4F32SSE __xla_cpu_runtime_LogV4F32SSE(
- xla::cpu::runtime::V4F32SSE x) TF_ATTRIBUTE_WEAK;
+ xla::cpu::runtime::V4F32SSE x);
+#endif
}
#endif // TENSORFLOW_COMPILER_XLA_SERVICE_CPU_CPU_RUNTIME_SSE4_1_H_
diff --git a/tensorflow/compiler/xla/service/cpu/llvm_ir_runtime.cc b/tensorflow/compiler/xla/service/cpu/llvm_ir_runtime.cc
index 81c29e4726..0f71258ff0 100644
--- a/tensorflow/compiler/xla/service/cpu/llvm_ir_runtime.cc
+++ b/tensorflow/compiler/xla/service/cpu/llvm_ir_runtime.cc
@@ -65,13 +65,13 @@ llvm::Function* EmitVectorF32TanhIfNeeded(llvm::Module* module,
llvm::ConstantFP::get(vector_type, 9.0), &ir_builder);
std::array<float, 7> numerator_coeffs(
- {{-2.76076847742355e-16f, 2.00018790482477e-13f, -8.60467152213735e-11f,
- 5.12229709037114e-08f, 1.48572235717979e-05f, 6.37261928875436e-04f,
- 4.89352455891786e-03f}});
+ {-2.76076847742355e-16f, 2.00018790482477e-13f, -8.60467152213735e-11f,
+ 5.12229709037114e-08f, 1.48572235717979e-05f, 6.37261928875436e-04f,
+ 4.89352455891786e-03f});
std::array<float, 4> denominator_coeffs(
- {{1.19825839466702e-06f, 1.18534705686654e-04f, 2.26843463243900e-03f,
- 4.89352518554385e-03f}});
+ {1.19825839466702e-06f, 1.18534705686654e-04f, 2.26843463243900e-03f,
+ 4.89352518554385e-03f});
llvm::Value* input_squared =
ir_builder.CreateFMul(input_clamped, input_clamped);
diff --git a/tensorflow/compiler/xla/service/cpu/simple_orc_jit.cc b/tensorflow/compiler/xla/service/cpu/simple_orc_jit.cc
index cda2783307..c942cd6bf1 100644
--- a/tensorflow/compiler/xla/service/cpu/simple_orc_jit.cc
+++ b/tensorflow/compiler/xla/service/cpu/simple_orc_jit.cc
@@ -102,9 +102,21 @@ llvm::StringRef GetHostCpuName() {
CompilerFunctor::VectorIntrinsics GetAvailableIntrinsics() {
CompilerFunctor::VectorIntrinsics intrinsics;
- intrinsics.sse_intrinsics = (&__xla_cpu_runtime_ExpV4F32SSE != nullptr);
- intrinsics.avx_intrinsics = (&__xla_cpu_runtime_ExpV8F32AVX != nullptr);
- intrinsics.neon_intrinsics = (&__xla_cpu_runtime_ExpV4F32NEON != nullptr);
+#ifdef __SSE4_1__
+ intrinsics.sse_intrinsics = true;
+#else
+ intrinsics.sse_intrinsics = false;
+#endif
+#ifdef __AVX__
+ intrinsics.avx_intrinsics = true;
+#else
+ intrinsics.avx_intrinsics = false;
+#endif
+#ifdef __ARM_NEON__
+ intrinsics.neon_intrinsics = true;
+#else
+ intrinsics.neon_intrinsics = false;
+#endif
return intrinsics;
}
@@ -201,12 +213,18 @@ bool RegisterKnownJITSymbols() {
REGISTER_CPU_RUNTIME_SYMBOL(EigenSingleThreadedConvF32);
REGISTER_CPU_RUNTIME_SYMBOL(EigenSingleThreadedMatMulF32);
REGISTER_CPU_RUNTIME_SYMBOL(EigenSingleThreadedMatMulF64);
+#ifdef __ARM_NEON__
REGISTER_CPU_RUNTIME_SYMBOL(ExpV4F32NEON);
- REGISTER_CPU_RUNTIME_SYMBOL(ExpV4F32SSE);
- REGISTER_CPU_RUNTIME_SYMBOL(ExpV8F32AVX);
REGISTER_CPU_RUNTIME_SYMBOL(LogV4F32NEON);
+#endif
+#ifdef __SSE4_1__
+ REGISTER_CPU_RUNTIME_SYMBOL(ExpV4F32SSE);
REGISTER_CPU_RUNTIME_SYMBOL(LogV4F32SSE);
+#endif
+#ifdef __AVX__
+ REGISTER_CPU_RUNTIME_SYMBOL(ExpV8F32AVX);
REGISTER_CPU_RUNTIME_SYMBOL(LogV8F32AVX);
+#endif
REGISTER_CPU_RUNTIME_SYMBOL(ParallelForkJoin);
REGISTER_CPU_RUNTIME_SYMBOL(ReleaseInfeedBufferAfterDequeue);
REGISTER_CPU_RUNTIME_SYMBOL(ReleaseOutfeedBufferAfterPopulation);
@@ -275,7 +293,11 @@ bool RegisterKnownJITSymbols() {
REGISTER_LIBM_SYMBOL(scalbln, double (*)(double, long));
REGISTER_LIBM_SYMBOL(scalbn, double (*)(double, int));
REGISTER_LIBM_SYMBOL(sin, double (*)(double));
+#ifdef __APPLE__
+ REGISTER_LIBM_SYMBOL(__sincos, void (*)(double, double*, double*));
+#else
REGISTER_LIBM_SYMBOL(sincos, void (*)(double, double*, double*));
+#endif
REGISTER_LIBM_SYMBOL(sinh, double (*)(double));
REGISTER_LIBM_SYMBOL(sqrt, double (*)(double));
REGISTER_LIBM_SYMBOL(tan, double (*)(double));
diff --git a/tensorflow/compiler/xla/service/gpu/while_transformer.cc b/tensorflow/compiler/xla/service/gpu/while_transformer.cc
index ccdd171759..ab94d7d543 100644
--- a/tensorflow/compiler/xla/service/gpu/while_transformer.cc
+++ b/tensorflow/compiler/xla/service/gpu/while_transformer.cc
@@ -44,7 +44,7 @@ namespace {
//
// Parameter
// |
-// Const GetTupleElemet
+// Const GetTupleElement
// \ /
// Add (root)
//
diff --git a/tensorflow/compiler/xla/service/heap_simulator.h b/tensorflow/compiler/xla/service/heap_simulator.h
index a03ad2f37c..88a8698d16 100644
--- a/tensorflow/compiler/xla/service/heap_simulator.h
+++ b/tensorflow/compiler/xla/service/heap_simulator.h
@@ -264,7 +264,7 @@ class LazyBestFitHeap : public HeapAlgorithm {
enum { kLazyAllocOffset = -1 };
struct OrderChunkByIncreasingSize {
- bool operator()(const Chunk& a, const Chunk& b) {
+ bool operator()(const Chunk& a, const Chunk& b) const {
if (a.size != b.size) return a.size < b.size;
return a.offset < b.offset;
}
diff --git a/tensorflow/compiler/xla/service/hlo_graph_dumper.cc b/tensorflow/compiler/xla/service/hlo_graph_dumper.cc
index 0e7ab00713..b9f76531f3 100644
--- a/tensorflow/compiler/xla/service/hlo_graph_dumper.cc
+++ b/tensorflow/compiler/xla/service/hlo_graph_dumper.cc
@@ -1318,19 +1318,16 @@ string SaveGraph(const string& graph,
file_extension = ".pbtxt";
break;
}
- string path = JoinPath(
- dest_path, StrCat("hlo_graph_", output_num++, ".XXXXXX", file_extension));
+ string path = JoinPath(dest_path, StrCat("hlo_graph_", output_num++, "."));
auto status = Status::OK();
- int fd = mkstemps(&path[0], file_extension.length());
- if (fd < 0) {
+ auto env = tensorflow::Env::Default();
+ if (!env->CreateUniqueFileName(&path, file_extension)) {
status =
Status(tensorflow::error::Code::UNKNOWN,
StrCat("Failed to create temporary file to dump HLO graph: ",
strerror(errno)));
} else {
- status =
- tensorflow::WriteStringToFile(tensorflow::Env::Default(), path, graph);
- close(fd);
+ status = tensorflow::WriteStringToFile(env, path, graph);
}
if (!status.ok()) {
LOG(WARNING) << "Saving HLO graph failed: " << status;
diff --git a/tensorflow/compiler/xla/service/llvm_ir/kernel_support_library.cc b/tensorflow/compiler/xla/service/llvm_ir/kernel_support_library.cc
index 5f6f9810c3..23d2d4e87d 100644
--- a/tensorflow/compiler/xla/service/llvm_ir/kernel_support_library.cc
+++ b/tensorflow/compiler/xla/service/llvm_ir/kernel_support_library.cc
@@ -111,8 +111,15 @@ void KernelSupportLibrary::EmitAndCallOutlinedKernel(
ir_builder->SetInsertPoint(return_inst);
std::vector<llvm::Value*> arg_values;
- std::transform(function->arg_begin(), function->arg_end(),
- std::back_inserter(arg_values), std::addressof<llvm::Value>);
+ /*
+ * clang on OSX doesn't like std::transform or range for loop here.
+ * See https://github.com/tensorflow/tensorflow/issues/15196
+ */
+ for (llvm::Function::arg_iterator arg = function->arg_begin(),
+ arg_e = function->arg_end();
+ arg != arg_e; ++arg) {
+ arg_values.push_back(arg);
+ }
if (null_arg_idx != -1) {
arg_values.insert(arg_values.begin() + null_arg_idx, nullptr);
}
diff --git a/tensorflow/compiler/xla/shape_tree.h b/tensorflow/compiler/xla/shape_tree.h
index bf8d190150..d752619bd6 100644
--- a/tensorflow/compiler/xla/shape_tree.h
+++ b/tensorflow/compiler/xla/shape_tree.h
@@ -238,7 +238,7 @@ class ShapeTree {
// (or compatible).
// index : the index of the element in the shape. See ShapeUtil::GetSubshape
// for definition of index.
- // data : The data value at this elemnt.
+ // data : The data value at this element.
template <typename Fn>
void ForEachElement(const Fn& func) const;
diff --git a/tensorflow/compiler/xla/util.h b/tensorflow/compiler/xla/util.h
index b722095d1f..277cc5ec86 100644
--- a/tensorflow/compiler/xla/util.h
+++ b/tensorflow/compiler/xla/util.h
@@ -239,11 +239,14 @@ std::vector<T> Permute(tensorflow::gtl::ArraySlice<int64> permutation,
// Override of the above that works around compile failures with gcc 7.1.1.
// For details see https://github.com/tensorflow/tensorflow/issues/10843
+// Hide this workaround from MSVC as it causes ambiguous error.
+#ifndef _MSC_VER
template <typename T>
std::vector<T> Permute(tensorflow::gtl::ArraySlice<int64> permutation,
const std::vector<T>& input) {
return Permute<std::vector, T>(permutation, input);
}
+#endif
// Inverts a permutation, i.e., output_permutation[input_permutation[i]] = i.
std::vector<int64> InversePermutation(
diff --git a/tensorflow/contrib/BUILD b/tensorflow/contrib/BUILD
index 604c41bf8a..6e2320bd0d 100644
--- a/tensorflow/contrib/BUILD
+++ b/tensorflow/contrib/BUILD
@@ -53,6 +53,7 @@ py_library(
"//tensorflow/contrib/layers:layers_py",
"//tensorflow/contrib/learn",
"//tensorflow/contrib/legacy_seq2seq:seq2seq_py",
+ "//tensorflow/contrib/libsvm",
"//tensorflow/contrib/linalg:linalg_py",
"//tensorflow/contrib/linear_optimizer:sdca_estimator_py",
"//tensorflow/contrib/linear_optimizer:sdca_ops_py",
diff --git a/tensorflow/contrib/android/README.md b/tensorflow/contrib/android/README.md
index c7c128bf14..b8d73bf24c 100644
--- a/tensorflow/contrib/android/README.md
+++ b/tensorflow/contrib/android/README.md
@@ -32,9 +32,9 @@ dependencies {
```
This will tell Gradle to use the
-[latest version](https://bintray.com/google/tensorflow/tensorflow-android/_latestVersion)
+[latest version](https://bintray.com/google/tensorflow/tensorflow/_latestVersion)
of the TensorFlow AAR that has been released to
-[https://bintray.com/google/tensorflow/tensorflow-android](https://bintray.com/google/tensorflow/tensorflow-android).
+[JCenter](https://jcenter.bintray.com/org/tensorflow/tensorflow-android/).
You may replace the `+` with an explicit version label if you wish to
use a specific release of TensorFlow in your app.
diff --git a/tensorflow/contrib/batching/BUILD b/tensorflow/contrib/batching/BUILD
index 8b7df4a84c..ea8ac2c680 100644
--- a/tensorflow/contrib/batching/BUILD
+++ b/tensorflow/contrib/batching/BUILD
@@ -82,6 +82,10 @@ cc_library(
tf_cc_test(
name = "adaptive_shared_batch_scheduler_test",
srcs = ["adaptive_shared_batch_scheduler_test.cc"],
+ tags = [
+ "local",
+ "manual",
+ ],
deps = [
":adaptive_shared_batch_scheduler",
"//tensorflow/contrib/batching/test_util:fake_clock_env",
diff --git a/tensorflow/contrib/batching/shared_batch_scheduler.h b/tensorflow/contrib/batching/shared_batch_scheduler.h
index 1d2158062e..86c45bdc2e 100644
--- a/tensorflow/contrib/batching/shared_batch_scheduler.h
+++ b/tensorflow/contrib/batching/shared_batch_scheduler.h
@@ -63,7 +63,7 @@ namespace serving {
// instead of N independent ones, with their sharing deliberately coordinated.
//
// SharedBatchScheduler does not implement the BatchScheduler API; rather, it
-// presents an abstraction of "queues", where each queue coresponds to one type
+// presents an abstraction of "queues", where each queue corresponds to one type
// of task. Tasks submitted to a given queue are placed in their own batches,
// and cannot be mixed with other tasks. Queues can be added and deleted
// dynamically, to accommodate e.g. versions of a model being brought up and
diff --git a/tensorflow/contrib/cmake/CMakeLists.txt b/tensorflow/contrib/cmake/CMakeLists.txt
index 7392daf66b..8d023cc81d 100644
--- a/tensorflow/contrib/cmake/CMakeLists.txt
+++ b/tensorflow/contrib/cmake/CMakeLists.txt
@@ -37,8 +37,8 @@ option(tensorflow_DISABLE_EIGEN_FORCEINLINE "Disable forceinline, to speed up bu
# GPU, CUDA and cuDNN options
option(tensorflow_ENABLE_GPU "Enable GPU support" OFF)
-option(tensorflow_CUDA_VERSION "CUDA version to build against" 9.0)
-option(tensorflow_CUDNN_VERSION "cuDNN version to build against" 7)
+set(tensorflow_CUDA_VERSION "9.0" CACHE STRING "CUDA version to build against")
+set(tensorflow_CUDNN_VERSION "7" CACHE STRING "cuDNN version to build against")
if(HAIKU)
option(tensorflow_ENABLE_POSITION_INDEPENDENT_CODE "Enable PIE support" OFF)
@@ -59,7 +59,15 @@ if (NOT WIN32)
set(tensorflow_CUDNN_INCLUDE /usr/include)
endif (NOT tensorflow_CUDNN_INCLUDE)
option(tensorflow_PATH_CUDNN_STATIC_LIB "Override PATH_STATIC_LIB for libcudnn_static.a" ${tensorflow_PATH_STATIC_LIB})
+ if (NOT tensorflow_PATH_CUDNN_STATIC_LIB)
+ # option's default value is OFF. Fill it with real default values
+ set (tensorflow_PATH_CUDNN_STATIC_LIB ${tensorflow_PATH_STATIC_LIB})
+ endif (NOT tensorflow_PATH_CUDNN_STATIC_LIB)
option(tensorflow_PATH_NCCL_STATIC_LIB "Override PATH_STATIC_LIB for libnccl_static.a" ${tensorflow_PATH_STATIC_LIB})
+ if (NOT tensorflow_PATH_NCCL_STATIC_LIB)
+ # option's default value is OFF. Fill it with real default values
+ set (tensorflow_PATH_NCCL_STATIC_LIB ${tensorflow_PATH_STATIC_LIB})
+ endif (NOT tensorflow_PATH_NCCL_STATIC_LIB)
option(tensorflow_CUDA_LIBRARY_PATH "Designate the default CUDA library paths" /usr/local/cuda/lib64)
if (NOT tensorflow_CUDA_LIBRARY_PATH)
# option's default value is OFF. Fill it with real default values
diff --git a/tensorflow/contrib/cmake/python_modules.txt b/tensorflow/contrib/cmake/python_modules.txt
index a0fca690ef..92edce77df 100644
--- a/tensorflow/contrib/cmake/python_modules.txt
+++ b/tensorflow/contrib/cmake/python_modules.txt
@@ -289,6 +289,10 @@ tensorflow/contrib/learn/python/learn/utils
tensorflow/contrib/legacy_seq2seq
tensorflow/contrib/legacy_seq2seq/python
tensorflow/contrib/legacy_seq2seq/python/ops
+tensorflow/contrib/libsvm
+tensorflow/contrib/libsvm/python
+tensorflow/contrib/libsvm/python/kernel_tests
+tensorflow/contrib/libsvm/python/ops
tensorflow/contrib/linalg
tensorflow/contrib/linalg/python
tensorflow/contrib/linalg/python/ops
diff --git a/tensorflow/contrib/cmake/tf_core_kernels.cmake b/tensorflow/contrib/cmake/tf_core_kernels.cmake
index eb6bf567aa..d3b6c0bdd3 100644
--- a/tensorflow/contrib/cmake/tf_core_kernels.cmake
+++ b/tensorflow/contrib/cmake/tf_core_kernels.cmake
@@ -85,6 +85,8 @@ if(tensorflow_BUILD_CONTRIB_KERNELS)
"${tensorflow_source_dir}/tensorflow/contrib/image/ops/single_image_random_dot_stereograms_ops.cc"
"${tensorflow_source_dir}/tensorflow/contrib/layers/kernels/sparse_feature_cross_kernel.cc"
"${tensorflow_source_dir}/tensorflow/contrib/layers/ops/sparse_feature_cross_op.cc"
+ "${tensorflow_source_dir}/tensorflow/contrib/libsvm/kernels/decode_libsvm_op.cc"
+ "${tensorflow_source_dir}/tensorflow/contrib/libsvm/ops/libsvm_ops.cc"
"${tensorflow_source_dir}/tensorflow/contrib/nccl/kernels/nccl_manager.cc"
"${tensorflow_source_dir}/tensorflow/contrib/nccl/kernels/nccl_ops.cc"
"${tensorflow_source_dir}/tensorflow/contrib/nccl/ops/nccl_ops.cc"
diff --git a/tensorflow/contrib/data/python/kernel_tests/BUILD b/tensorflow/contrib/data/python/kernel_tests/BUILD
index e6d2ed0387..cc511f7204 100644
--- a/tensorflow/contrib/data/python/kernel_tests/BUILD
+++ b/tensorflow/contrib/data/python/kernel_tests/BUILD
@@ -396,6 +396,7 @@ py_test(
size = "small",
srcs = ["scan_dataset_op_test.py"],
srcs_version = "PY2AND3",
+ tags = ["no_pip"],
deps = [
":dataset_serialization_test",
"//tensorflow/contrib/data/python/ops:transformation_ops",
@@ -482,6 +483,7 @@ py_test(
size = "small",
srcs = ["stats_dataset_ops_test.py"],
srcs_version = "PY2AND3",
+ tags = ["no_pip"],
deps = [
":dataset_serialization_test",
"//tensorflow/contrib/data/python/ops:dataset_ops",
diff --git a/tensorflow/contrib/gan/README.md b/tensorflow/contrib/gan/README.md
index 4bca0a1d62..4ead66ca13 100644
--- a/tensorflow/contrib/gan/README.md
+++ b/tensorflow/contrib/gan/README.md
@@ -99,8 +99,8 @@ gan_model = tfgan.gan_model(
# Build the GAN loss.
gan_loss = tfgan.gan_loss(
gan_model,
- generator_loss_fn=tfgan_losses.wasserstein_generator_loss,
- discriminator_loss_fn=tfgan_losses.wasserstein_discriminator_loss)
+ generator_loss_fn=tfgan.losses.wasserstein_generator_loss,
+ discriminator_loss_fn=tfgan.losses.wasserstein_discriminator_loss)
# Create the train ops, which calculate gradients and apply updates to weights.
train_ops = tfgan.gan_train_ops(
@@ -161,8 +161,8 @@ gan_model = tfgan.gan_model(
# Build the GAN loss and standard pixel loss.
gan_loss = tfgan.gan_loss(
gan_model,
- generator_loss_fn=tfgan_losses.wasserstein_generator_loss,
- discriminator_loss_fn=tfgan_losses.wasserstein_discriminator_loss,
+ generator_loss_fn=tfgan.losses.wasserstein_generator_loss,
+ discriminator_loss_fn=tfgan.losses.wasserstein_discriminator_loss,
gradient_penalty=1.0)
l1_pixel_loss = tf.norm(gan_model.real_data - gan_model.generated_data, ord=1)
@@ -193,8 +193,8 @@ gan_model = tfgan.gan_model(
# Build the GAN loss and standard pixel loss.
gan_loss = tfgan.gan_loss(
gan_model,
- generator_loss_fn=tfgan_losses.least_squares_generator_loss,
- discriminator_loss_fn=tfgan_losses.least_squares_discriminator_loss)
+ generator_loss_fn=tfgan.losses.least_squares_generator_loss,
+ discriminator_loss_fn=tfgan.losses.least_squares_discriminator_loss)
l1_pixel_loss = tf.norm(gan_model.real_data - gan_model.generated_data, ord=1)
# Modify the loss tuple to include the pixel loss.
@@ -223,8 +223,8 @@ gan_model = tfgan.infogan_model(
# Build the GAN loss with mutual information penalty.
gan_loss = tfgan.gan_loss(
gan_model,
- generator_loss_fn=tfgan_losses.wasserstein_generator_loss,
- discriminator_loss_fn=tfgan_losses.wasserstein_discriminator_loss,
+ generator_loss_fn=tfgan.losses.wasserstein_generator_loss,
+ discriminator_loss_fn=tfgan.losses.wasserstein_discriminator_loss,
gradient_penalty=1.0,
mutual_information_penalty_weight=1.0)
diff --git a/tensorflow/contrib/learn/python/learn/learn_io/data_feeder.py b/tensorflow/contrib/learn/python/learn/learn_io/data_feeder.py
index 86fad4c553..f36a778b52 100644
--- a/tensorflow/contrib/learn/python/learn/learn_io/data_feeder.py
+++ b/tensorflow/contrib/learn/python/learn/learn_io/data_feeder.py
@@ -857,8 +857,8 @@ class DaskDataFeeder(object):
"""Returns a function, that will sample data and provide it to placeholders.
Args:
- input_placeholder: tf.Placeholder for input features mini batch.
- output_placeholder: tf.Placeholder for output labels.
+ input_placeholder: tf.placeholder for input features mini batch.
+ output_placeholder: tf.placeholder for output labels.
Returns:
A function that when called samples a random subset of batch size
diff --git a/tensorflow/contrib/libsvm/BUILD b/tensorflow/contrib/libsvm/BUILD
new file mode 100644
index 0000000000..df96402a4f
--- /dev/null
+++ b/tensorflow/contrib/libsvm/BUILD
@@ -0,0 +1,102 @@
+package(
+ default_visibility = ["//visibility:private"],
+)
+
+licenses(["notice"]) # Apache 2.0
+
+exports_files(["LICENSE"])
+
+load("//tensorflow:tensorflow.bzl", "tf_custom_op_library")
+load("//tensorflow:tensorflow.bzl", "tf_gen_op_libs")
+load("//tensorflow:tensorflow.bzl", "tf_gen_op_wrapper_py")
+load("//tensorflow:tensorflow.bzl", "tf_kernel_library")
+load("//tensorflow:tensorflow.bzl", "tf_custom_op_py_library")
+load("//tensorflow:tensorflow.bzl", "tf_py_test")
+
+tf_custom_op_library(
+ name = "python/ops/_libsvm_ops.so",
+ srcs = [
+ "kernels/decode_libsvm_op.cc",
+ "ops/libsvm_ops.cc",
+ ],
+ deps = [
+ "//tensorflow/core/kernels:bounds_check_lib",
+ ],
+)
+
+tf_kernel_library(
+ name = "libsvm_kernels",
+ srcs = ["kernels/decode_libsvm_op.cc"],
+ visibility = ["//visibility:public"],
+ deps = [
+ "//tensorflow/core:framework",
+ "//tensorflow/core:lib",
+ "//tensorflow/core:lib_internal",
+ "//tensorflow/core/kernels:bounds_check_lib",
+ ],
+)
+
+tf_gen_op_libs(
+ op_lib_names = ["libsvm_ops"],
+ deps = [
+ "//tensorflow/core:lib",
+ ],
+)
+
+tf_gen_op_wrapper_py(
+ name = "libsvm_ops",
+ deps = [":libsvm_ops_op_lib"],
+)
+
+tf_custom_op_py_library(
+ name = "libsvm",
+ srcs = [
+ "__init__.py",
+ "python/ops/libsvm_ops.py",
+ ],
+ dso = [
+ ":python/ops/_libsvm_ops.so",
+ ],
+ kernels = [
+ ":libsvm_kernels",
+ ":libsvm_ops_op_lib",
+ ],
+ srcs_version = "PY2AND3",
+ visibility = ["//visibility:public"],
+ deps = [
+ ":libsvm_ops",
+ "//tensorflow/contrib/util:util_py",
+ "//tensorflow/python:array_ops",
+ "//tensorflow/python:control_flow_ops",
+ "//tensorflow/python:framework",
+ "//tensorflow/python:framework_for_generated_wrappers",
+ "//tensorflow/python:platform",
+ "//tensorflow/python:state_ops",
+ "//tensorflow/python:training",
+ ],
+)
+
+tf_py_test(
+ name = "decode_libsvm_op_test",
+ srcs = ["python/kernel_tests/decode_libsvm_op_test.py"],
+ additional_deps = [
+ ":libsvm",
+ "//third_party/py/numpy",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:framework",
+ "//tensorflow/python:framework_test_lib",
+ "//tensorflow/python:platform_test",
+ ],
+)
+
+filegroup(
+ name = "all_files",
+ srcs = glob(
+ ["**/*"],
+ exclude = [
+ "**/METADATA",
+ "**/OWNERS",
+ ],
+ ),
+ visibility = ["//tensorflow:__subpackages__"],
+)
diff --git a/tensorflow/contrib/libsvm/__init__.py b/tensorflow/contrib/libsvm/__init__.py
new file mode 100644
index 0000000000..a875863caa
--- /dev/null
+++ b/tensorflow/contrib/libsvm/__init__.py
@@ -0,0 +1,32 @@
+# 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.
+# ==============================================================================
+"""Libsvm decoder.
+
+@@decode_libsvm
+"""
+
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
+from tensorflow.contrib.libsvm.python.ops.libsvm_ops import decode_libsvm
+
+from tensorflow.python.util.all_util import remove_undocumented
+
+_allowed_symbols = [
+ "decode_libsvm",
+]
+
+remove_undocumented(__name__)
diff --git a/tensorflow/contrib/libsvm/kernels/decode_libsvm_op.cc b/tensorflow/contrib/libsvm/kernels/decode_libsvm_op.cc
new file mode 100644
index 0000000000..27ce55d568
--- /dev/null
+++ b/tensorflow/contrib/libsvm/kernels/decode_libsvm_op.cc
@@ -0,0 +1,178 @@
+/* Copyright 2015 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/op_kernel.h"
+#include "tensorflow/core/framework/tensor.h"
+#include "tensorflow/core/framework/tensor_shape.h"
+#include "tensorflow/core/framework/types.h"
+#include "tensorflow/core/lib/core/errors.h"
+#include "tensorflow/core/lib/strings/numbers.h"
+#include "tensorflow/core/lib/strings/str_util.h"
+
+namespace tensorflow {
+namespace {
+template <typename T>
+bool ConvertHelper(const string& s, T* value);
+}
+
+template <typename T, typename Tlabel>
+class DecodeLibsvmOp : public OpKernel {
+ public:
+ explicit DecodeLibsvmOp(OpKernelConstruction* ctx) : OpKernel(ctx) {
+ OP_REQUIRES_OK(ctx, ctx->GetAttr("num_features", &num_features_));
+ OP_REQUIRES(ctx, (num_features_ >= 1),
+ errors::InvalidArgument("Invalid number of features \"",
+ num_features_, "\""));
+ }
+
+ void Compute(OpKernelContext* ctx) override {
+ const Tensor* input_tensor;
+ OP_REQUIRES_OK(ctx, ctx->input("input", &input_tensor));
+ const auto& input_flat = input_tensor->flat<string>();
+
+ Tensor* label_tensor;
+ OP_REQUIRES_OK(
+ ctx, ctx->allocate_output(0, input_tensor->shape(), &label_tensor));
+ auto label = label_tensor->flat<Tlabel>();
+
+ std::vector<T> out_values;
+ std::vector<std::pair<int64, int64>> out_indices;
+ for (int i = 0; i < input_flat.size(); ++i) {
+ std::vector<string> entries =
+ str_util::Split(input_flat(i), " ", str_util::SkipEmpty());
+ OP_REQUIRES(ctx, !entries.empty(),
+ errors::InvalidArgument("No entries found for input[", i,
+ "]: \"", input_flat(i), "\""));
+ Tlabel label_value;
+ OP_REQUIRES(
+ ctx, ConvertHelper<Tlabel>(entries[0], &label_value),
+ errors::InvalidArgument("Label format incorrect: ", entries[0]));
+ label(i) = label_value;
+ for (int j = 1; j < entries.size(); j++) {
+ std::vector<string> pair = str_util::Split(entries[j], ":");
+ OP_REQUIRES(
+ ctx, (pair.size() == 2),
+ errors::InvalidArgument("Invalid feature \"", entries[j], "\""));
+ int64 feature_index;
+ OP_REQUIRES(
+ ctx, strings::safe_strto64(pair[0].c_str(), &feature_index),
+ errors::InvalidArgument("Feature format incorrect: ", entries[j]));
+ OP_REQUIRES(ctx, (feature_index >= 0),
+ errors::InvalidArgument(
+ "Feature index should be >= 0, got ", feature_index));
+ T feature_value;
+ OP_REQUIRES(
+ ctx, ConvertHelper<T>(pair[1], &feature_value),
+ errors::InvalidArgument("Feature format incorrect: ", entries[j]));
+ out_values.emplace_back(feature_value);
+ out_indices.emplace_back(std::pair<int64, int64>(i, feature_index));
+ }
+ }
+
+ Tensor* indices_tensor;
+ OP_REQUIRES_OK(ctx, ctx->allocate_output(
+ 1,
+ TensorShape({static_cast<int64>(out_indices.size()),
+ input_tensor->shape().dims() + 1}),
+ &indices_tensor));
+ auto indices = indices_tensor->matrix<int64>();
+ // Translate flat index to shaped index like np.unravel_index
+ // Calculate factors for each dimension
+ std::vector<int64> factors(input_tensor->shape().dims());
+ factors[input_tensor->shape().dims() - 1] = 1;
+ for (int j = input_tensor->shape().dims() - 2; j >= 0; j--) {
+ factors[j] = factors[j + 1] * input_tensor->shape().dim_size(j + 1);
+ }
+ for (int i = 0; i < out_indices.size(); i++) {
+ indices(i, 0) = out_indices[i].first;
+ int64 value = out_indices[i].first;
+ for (int j = 0; j < input_tensor->shape().dims(); j++) {
+ indices(i, j) = value / factors[j];
+ value = value % factors[j];
+ }
+ indices(i, input_tensor->shape().dims()) = out_indices[i].second;
+ }
+
+ Tensor* values_tensor;
+ OP_REQUIRES_OK(ctx,
+ ctx->allocate_output(
+ 2, TensorShape({static_cast<int64>(out_values.size())}),
+ &values_tensor));
+ auto values = values_tensor->vec<T>();
+ std::copy_n(out_values.begin(), out_values.size(), &values(0));
+
+ Tensor* shape_tensor;
+ OP_REQUIRES_OK(ctx, ctx->allocate_output(
+ 3, TensorShape({input_tensor->shape().dims() + 1}),
+ &shape_tensor));
+ auto shape = shape_tensor->flat<int64>();
+ for (int i = 0; i < input_tensor->shape().dims(); i++) {
+ shape(i) = input_tensor->shape().dim_size(i);
+ }
+ shape(input_tensor->shape().dims()) = num_features_;
+ }
+
+ private:
+ int64 num_features_;
+};
+
+namespace {
+template <>
+bool ConvertHelper<float>(const string& s, float* value) {
+ return strings::safe_strtof(s.c_str(), value);
+}
+template <>
+bool ConvertHelper<double>(const string& s, double* value) {
+ return strings::safe_strtod(s.c_str(), value);
+}
+template <>
+bool ConvertHelper<int32>(const string& s, int32* value) {
+ return strings::safe_strto32(s.c_str(), value);
+}
+template <>
+bool ConvertHelper<int64>(const string& s, int64* value) {
+ return strings::safe_strto64(s.c_str(), value);
+}
+} // namespace
+
+#define REGISTER_KERNEL(type) \
+ REGISTER_KERNEL_BUILDER(Name("DecodeLibsvm") \
+ .Device(DEVICE_CPU) \
+ .TypeConstraint<type>("dtype") \
+ .TypeConstraint<int32>("label_dtype"), \
+ DecodeLibsvmOp<type, int32>); \
+ REGISTER_KERNEL_BUILDER(Name("DecodeLibsvm") \
+ .Device(DEVICE_CPU) \
+ .TypeConstraint<type>("dtype") \
+ .TypeConstraint<int64>("label_dtype"), \
+ DecodeLibsvmOp<type, int64>); \
+ REGISTER_KERNEL_BUILDER(Name("DecodeLibsvm") \
+ .Device(DEVICE_CPU) \
+ .TypeConstraint<type>("dtype") \
+ .TypeConstraint<float>("label_dtype"), \
+ DecodeLibsvmOp<type, float>); \
+ REGISTER_KERNEL_BUILDER(Name("DecodeLibsvm") \
+ .Device(DEVICE_CPU) \
+ .TypeConstraint<type>("dtype") \
+ .TypeConstraint<double>("label_dtype"), \
+ DecodeLibsvmOp<type, double>);
+
+REGISTER_KERNEL(float);
+REGISTER_KERNEL(double);
+REGISTER_KERNEL(int32);
+REGISTER_KERNEL(int64);
+#undef REGISTER_KERNEL
+
+} // namespace tensorflow
diff --git a/tensorflow/contrib/libsvm/ops/libsvm_ops.cc b/tensorflow/contrib/libsvm/ops/libsvm_ops.cc
new file mode 100644
index 0000000000..dec946189e
--- /dev/null
+++ b/tensorflow/contrib/libsvm/ops/libsvm_ops.cc
@@ -0,0 +1,58 @@
+/* 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/core/framework/common_shape_fns.h"
+#include "tensorflow/core/framework/op.h"
+#include "tensorflow/core/framework/shape_inference.h"
+
+namespace tensorflow {
+
+using shape_inference::InferenceContext;
+
+REGISTER_OP("DecodeLibsvm")
+ .Input("input: string")
+ .Output("label: label_dtype")
+ .Output("feature_indices: int64")
+ .Output("feature_values: dtype")
+ .Output("feature_shape: int64")
+ .Attr("dtype: {float, double, int32, int64} = DT_FLOAT")
+ .Attr("label_dtype: {float, double, int32, int64} = DT_INT64")
+ .Attr("num_features: int >= 1")
+ .SetShapeFn([](InferenceContext* c) {
+ c->set_output(0, c->input(0));
+
+ c->set_output(1, c->Matrix(InferenceContext::kUnknownDim,
+ InferenceContext::kUnknownDim));
+ c->set_output(2, c->Vector(InferenceContext::kUnknownDim));
+ c->set_output(3, c->Vector(InferenceContext::kUnknownDim));
+
+ return Status::OK();
+ })
+
+ .Doc(R"doc(
+Convert LibSVM input to tensors. The output consists of
+a label and a feature tensor. The shape of the label tensor
+is the same as input and the shape of the feature tensor is
+`[input_shape, num_features]`.
+
+input: Each string is a record in the LibSVM.
+label: A tensor of the same shape as input.
+feature_indices: A 2-D int64 tensor of dense_shape [N, ndims].
+feature_values: A 1-D tensor of any type and dense_shape [N].
+feature_shape: A 1-D int64 tensor of dense_shape [ndims].
+num_features: The number of features.
+)doc");
+
+} // namespace tensorflow
diff --git a/tensorflow/contrib/libsvm/python/kernel_tests/decode_libsvm_op_test.py b/tensorflow/contrib/libsvm/python/kernel_tests/decode_libsvm_op_test.py
new file mode 100644
index 0000000000..423dcce8de
--- /dev/null
+++ b/tensorflow/contrib/libsvm/python/kernel_tests/decode_libsvm_op_test.py
@@ -0,0 +1,71 @@
+# 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.
+# ==============================================================================
+"""Tests for DecodeLibsvm op."""
+
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
+import numpy as np
+
+from tensorflow.contrib.libsvm.python.ops import libsvm_ops
+from tensorflow.python.framework import dtypes
+from tensorflow.python.ops import sparse_ops
+from tensorflow.python.platform import test
+
+
+class DecodeLibsvmOpTest(test.TestCase):
+
+ def testBasic(self):
+ with self.test_session() as sess:
+ content = [
+ "1 1:3.4 2:0.5 4:0.231", "1 2:2.5 3:inf 5:0.503",
+ "2 3:2.5 2:nan 1:0.105"
+ ]
+ sparse_features, labels = libsvm_ops.decode_libsvm(
+ content, num_features=6)
+ features = sparse_ops.sparse_tensor_to_dense(
+ sparse_features, validate_indices=False)
+
+ self.assertAllEqual(labels.get_shape().as_list(), [3])
+
+ features, labels = sess.run([features, labels])
+ self.assertAllEqual(labels, [1, 1, 2])
+ self.assertAllClose(
+ features, [[0, 3.4, 0.5, 0, 0.231, 0], [0, 0, 2.5, np.inf, 0, 0.503],
+ [0, 0.105, np.nan, 2.5, 0, 0]])
+
+ def testNDimension(self):
+ with self.test_session() as sess:
+ content = [["1 1:3.4 2:0.5 4:0.231", "1 1:3.4 2:0.5 4:0.231"],
+ ["1 2:2.5 3:inf 5:0.503", "1 2:2.5 3:inf 5:0.503"],
+ ["2 3:2.5 2:nan 1:0.105", "2 3:2.5 2:nan 1:0.105"]]
+ sparse_features, labels = libsvm_ops.decode_libsvm(
+ content, num_features=6, label_dtype=dtypes.float64)
+ features = sparse_ops.sparse_tensor_to_dense(
+ sparse_features, validate_indices=False)
+
+ self.assertAllEqual(labels.get_shape().as_list(), [3, 2])
+
+ features, labels = sess.run([features, labels])
+ self.assertAllEqual(labels, [[1, 1], [1, 1], [2, 2]])
+ self.assertAllClose(
+ features, [[[0, 3.4, 0.5, 0, 0.231, 0], [0, 3.4, 0.5, 0, 0.231, 0]], [
+ [0, 0, 2.5, np.inf, 0, 0.503], [0, 0, 2.5, np.inf, 0, 0.503]
+ ], [[0, 0.105, np.nan, 2.5, 0, 0], [0, 0.105, np.nan, 2.5, 0, 0]]])
+
+
+if __name__ == "__main__":
+ test.main()
diff --git a/tensorflow/contrib/libsvm/python/ops/libsvm_ops.py b/tensorflow/contrib/libsvm/python/ops/libsvm_ops.py
new file mode 100644
index 0000000000..b302250563
--- /dev/null
+++ b/tensorflow/contrib/libsvm/python/ops/libsvm_ops.py
@@ -0,0 +1,50 @@
+# 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.
+# ==============================================================================
+"""Libsvm decoder."""
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
+from tensorflow.contrib.libsvm.ops import gen_libsvm_ops
+from tensorflow.contrib.util import loader
+from tensorflow.python.framework import ops
+from tensorflow.python.framework import sparse_tensor
+from tensorflow.python.platform import resource_loader
+
+
+_libsvm_ops_so = loader.load_op_library(
+ resource_loader.get_path_to_datafile("_libsvm_ops.so"))
+
+
+def decode_libsvm(content, num_features, dtype=None, label_dtype=None):
+ """Convert Libsvm records to a tensor of label and a tensor of feature.
+
+ Args:
+ content: A `Tensor` of type `string`. Each string is a record/row in
+ the Libsvm format.
+ num_features: The number of features.
+ dtype: The type of the output feature tensor. Default to tf.float32.
+ label_dtype: The type of the output label tensor. Default to tf.int64.
+
+ Returns:
+ features: A `SparseTensor` of the shape `[input_shape, num_features]`.
+ labels: A `Tensor` of the same shape as content.
+ """
+ labels, indices, values, shape = gen_libsvm_ops.decode_libsvm(
+ content, num_features, dtype=dtype, label_dtype=label_dtype)
+ return sparse_tensor.SparseTensor(indices, values, shape), labels
+
+
+ops.NotDifferentiable("DecodeLibSVM")
diff --git a/tensorflow/contrib/lite/README.md b/tensorflow/contrib/lite/README.md
index 2fb40070cb..852284cbc7 100644
--- a/tensorflow/contrib/lite/README.md
+++ b/tensorflow/contrib/lite/README.md
@@ -186,7 +186,7 @@ bazel-bin/tensorflow/contrib/lite/toco/toco -- \
- Setting the input_array, output_array and input_shape arguments are a bit trickier. The easiest way to find these values is to explore the graph in tensorboard . The user should reuse the arguments that were used for specifying the output nodes for inference in the `freeze_graph`step.
Note, it is also possible to use the Tensorflow Optimizing Converter through protos either from Python or from the command line see the
-documentation [here](https://github.com/tensorflow/tensorflow/tree/mastertensorflow/contrib/lite/python:toco_from_protos target) A developer can then integrate the conversion step into their model design workflow to ensure that a model will be easily convertible to a mobile inference graph. For example,
+documentation [here](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/lite/toco/python/toco_from_protos.py). A developer can then integrate the conversion step into their model design workflow to ensure that a model will be easily convertible to a mobile inference graph. For example,
```
import tensorflow as tf
diff --git a/tensorflow/contrib/lite/g3doc/ios.md b/tensorflow/contrib/lite/g3doc/ios.md
index ce8b37fbf9..a359b8d4b4 100644
--- a/tensorflow/contrib/lite/g3doc/ios.md
+++ b/tensorflow/contrib/lite/g3doc/ios.md
@@ -45,6 +45,10 @@ into a universal file containing armv7, armv7s, arm64, i386, and x86_64
architectures. The resulting library is in
`tensorflow/contrib/lite/gen/lib/libtensorflow-lite.a`.
+If you get an error such as `no such file or directory: 'x86_64'` when running
+`build_ios_universal_lib.sh`: open Xcode > Preferences > Locations, and ensure
+a value is selected in the "Command Line Tools" dropdown.
+
## Using in your own application
You'll need to update various settings in your app to link against TensorFlow
diff --git a/tensorflow/contrib/lite/kernels/internal/BUILD b/tensorflow/contrib/lite/kernels/internal/BUILD
index 288534099b..a3ecb2ebf6 100644
--- a/tensorflow/contrib/lite/kernels/internal/BUILD
+++ b/tensorflow/contrib/lite/kernels/internal/BUILD
@@ -124,6 +124,13 @@ config_setting(
},
)
+config_setting(
+ name = "freebsd",
+ values = {
+ "cpu": "freebsd",
+ },
+)
+
cc_library(
name = "optimized_base",
srcs = [],
@@ -147,6 +154,7 @@ cc_library(
":x86": tflite_deps_intel,
":x86_64": tflite_deps_intel,
":darwin": tflite_deps_intel,
+ ":freebsd": tflite_deps_intel,
"//conditions:default": [],
}),
)
@@ -224,6 +232,7 @@ cc_library(
":x86": tflite_deps_intel,
":x86_64": tflite_deps_intel,
":darwin": tflite_deps_intel,
+ ":freebsd": tflite_deps_intel,
"//conditions:default": [],
}),
)
diff --git a/tensorflow/contrib/lite/kernels/internal/reference/portable_tensor_utils.h b/tensorflow/contrib/lite/kernels/internal/reference/portable_tensor_utils.h
index c2ab78000b..7f90d731b8 100644
--- a/tensorflow/contrib/lite/kernels/internal/reference/portable_tensor_utils.h
+++ b/tensorflow/contrib/lite/kernels/internal/reference/portable_tensor_utils.h
@@ -22,7 +22,7 @@ limitations under the License.
namespace tflite {
namespace tensor_utils {
-// Limit a float input f betweeen +abs_limit and -abs_limit.
+// Limit a float input f between +abs_limit and -abs_limit.
float PortableClip(float f, float abs_limit);
// Multiply a matrix by a batch vector, and store results in a batch-size
diff --git a/tensorflow/contrib/lite/kernels/internal/tensor_utils.h b/tensorflow/contrib/lite/kernels/internal/tensor_utils.h
index 0e69ef5982..e7e2994397 100644
--- a/tensorflow/contrib/lite/kernels/internal/tensor_utils.h
+++ b/tensorflow/contrib/lite/kernels/internal/tensor_utils.h
@@ -20,7 +20,7 @@ limitations under the License.
namespace tflite {
namespace tensor_utils {
-// Limit a float input f betweeen +abs_limit and -abs_limit.
+// Limit a float input f between +abs_limit and -abs_limit.
float Clip(float f, float abs_limit);
// Multiply a matrix by a batch vector, and store results in a batch-size
diff --git a/tensorflow/contrib/lite/toco/graph_transformations/resolve_tensorflow_switch.cc b/tensorflow/contrib/lite/toco/graph_transformations/resolve_tensorflow_switch.cc
index 55adfca037..150cf53da3 100644
--- a/tensorflow/contrib/lite/toco/graph_transformations/resolve_tensorflow_switch.cc
+++ b/tensorflow/contrib/lite/toco/graph_transformations/resolve_tensorflow_switch.cc
@@ -59,7 +59,7 @@ bool ResolveTensorFlowSwitch::Run(Model* model, std::size_t op_index) {
// From the TensorFlow docs on .switch() in
// third_party/tensorflow/python/ops/control_flow_ops.py
//
- // If `pred` is false, the `data` input is forwared to the first output.
+ // If `pred` is false, the `data` input is forwarded to the first output.
// Otherwise, the data goes to the second output.
//
// Note that this comment used to say the opposite and was recently fixed:
diff --git a/tensorflow/contrib/lite/toco/import_tensorflow.cc b/tensorflow/contrib/lite/toco/import_tensorflow.cc
index 866898cc3d..6146b92311 100644
--- a/tensorflow/contrib/lite/toco/import_tensorflow.cc
+++ b/tensorflow/contrib/lite/toco/import_tensorflow.cc
@@ -1582,7 +1582,7 @@ void ConvertOperatorSpecialCasedAsRNNBackEdge(
const NodeDef& node, const TensorFlowImportFlags& tf_import_flags,
Model* model) {
// At the moment, the only type of operator special-cased in this way is
- // NextIteration, occuring only in control-flow cycles.
+ // NextIteration, occurring only in control-flow cycles.
CHECK_EQ(node.op(), "NextIteration");
CHECK_EQ(node.input_size(), 1);
auto* rnn_state = model->flags.add_rnn_states();
diff --git a/tensorflow/contrib/memory_stats/kernels/memory_stats_ops.cc b/tensorflow/contrib/memory_stats/kernels/memory_stats_ops.cc
index 7e2e96e160..39c0d5af45 100644
--- a/tensorflow/contrib/memory_stats/kernels/memory_stats_ops.cc
+++ b/tensorflow/contrib/memory_stats/kernels/memory_stats_ops.cc
@@ -59,7 +59,7 @@ REGISTER_KERNEL_BUILDER(Name("BytesInUse").Device(DEVICE_GPU).HostMemory("out"),
#ifdef TENSORFLOW_USE_SYCL
REGISTER_KERNEL_BUILDER(
- Name("BytesInUse").Device(DEVICE_SYCL).HostMemory("out"), MaxBytesInUseOp);
+ Name("BytesInUse").Device(DEVICE_SYCL).HostMemory("out"), BytesInUseOp);
#endif // TENSORFLOW_USE_SYCL
// Op that measures the total memory (in bytes) of a device.
diff --git a/tensorflow/contrib/opt/__init__.py b/tensorflow/contrib/opt/__init__.py
index de8f1be05e..90d2f92462 100644
--- a/tensorflow/contrib/opt/__init__.py
+++ b/tensorflow/contrib/opt/__init__.py
@@ -47,7 +47,7 @@ _allowed_symbols = [
'VariableClippingOptimizer',
'MultitaskOptimizerWrapper',
'clip_gradients_by_global_norm',
- 'ElasticAverageOptimizer',
+ 'ElasticAverageOptimizer',
'ElasticAverageCustomGetter'
]
diff --git a/tensorflow/contrib/opt/python/training/elastic_average_optimizer.py b/tensorflow/contrib/opt/python/training/elastic_average_optimizer.py
index 9941f22b1f..6132cba1f5 100644
--- a/tensorflow/contrib/opt/python/training/elastic_average_optimizer.py
+++ b/tensorflow/contrib/opt/python/training/elastic_average_optimizer.py
@@ -79,9 +79,8 @@ class ElasticAverageCustomGetter(object):
if trainable:
with ops.device(self._worker_device):
local_var = getter(name, trainable=True,
- collections=[ops.GraphKeys.LOCAL_VARIABLES],
+ collections=[ops.GraphKeys.LOCAL_VARIABLES],
*args, **kwargs)
-
global_center_variable = variable_scope.variable(
name='%s/%s' %
(GLOBAL_VARIABLE_NAME,
@@ -96,7 +95,7 @@ class ElasticAverageCustomGetter(object):
initial_value=local_var.initialized_value(),
trainable=False,
collections=[ops.GraphKeys.LOCAL_VARIABLES])
-
+
self._local_map[local_var] = local_center_variable
self._global_map[local_var] = global_center_variable
return local_var
@@ -173,7 +172,7 @@ class ElasticAverageOptimizer(optimizer.Optimizer):
colocate_gradients_with_ops=False,
grad_loss=None):
"""Compute gradients of `loss` for the variables in `var_list`.
-
+
Add rho*elastic_difference to loss to control the exploration
This is the first part of `minimize()`. It returns a list
of (gradient, variable) pairs where "gradient" is the gradient
@@ -204,7 +203,7 @@ class ElasticAverageOptimizer(optimizer.Optimizer):
"""
if not var_list:
var_list = variables.trainable_variables()
-
+
elastic_difference = [math_ops.subtract(v, lv) for v, lv in zip(
variables.trainable_variables(),
[self._local_map[var] for var in var_list])]
diff --git a/tensorflow/contrib/opt/python/training/elastic_average_optimizer_test.py b/tensorflow/contrib/opt/python/training/elastic_average_optimizer_test.py
index 59e55fceee..446e91018d 100644
--- a/tensorflow/contrib/opt/python/training/elastic_average_optimizer_test.py
+++ b/tensorflow/contrib/opt/python/training/elastic_average_optimizer_test.py
@@ -144,7 +144,7 @@ class ElasticAverageOptimizerTest(test.TestCase):
self.assertAllEqual(1.0, sessions[0].run(var_1_g))
self.assertAllEqual(0, sessions[0].run(global_step))
- # iteration 2, global varibale update
+ # iteration 2, global variable update
sessions[0].run(train_ops[0])
self.assertAllEqual(0.0, sessions[0].run(var_0))
diff --git a/tensorflow/contrib/seq2seq/python/ops/helper.py b/tensorflow/contrib/seq2seq/python/ops/helper.py
index dec03ce43f..ef3722ee41 100644
--- a/tensorflow/contrib/seq2seq/python/ops/helper.py
+++ b/tensorflow/contrib/seq2seq/python/ops/helper.py
@@ -223,7 +223,8 @@ class TrainingHelper(Helper):
def sample(self, time, outputs, name=None, **unused_kwargs):
with ops.name_scope(name, "TrainingHelperSample", [time, outputs]):
- sample_ids = math_ops.argmax(outputs, axis=-1, output_type=dtypes.int32)
+ sample_ids = math_ops.cast(
+ math_ops.argmax(outputs, axis=-1), dtypes.int32)
return sample_ids
def next_inputs(self, time, outputs, state, name=None, **unused_kwargs):
diff --git a/tensorflow/contrib/tpu/profiler/pip_package/setup.py b/tensorflow/contrib/tpu/profiler/pip_package/setup.py
index ee6950699e..179d29602b 100644
--- a/tensorflow/contrib/tpu/profiler/pip_package/setup.py
+++ b/tensorflow/contrib/tpu/profiler/pip_package/setup.py
@@ -70,7 +70,7 @@ setup(
'Topic :: Scientific/Engineering :: Mathematics',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
'Topic :: Software Development',
- 'Topic :: Software Development :: Libraries',
+ 'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Libraries :: Python Modules',
],
license='Apache 2.0',
diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD
index c855bb05bc..ae38025942 100644
--- a/tensorflow/core/BUILD
+++ b/tensorflow/core/BUILD
@@ -575,6 +575,7 @@ cc_library(
# Generates library per group of ops.
tf_gen_op_libs(
+ is_external = False,
op_lib_names = [
"bitwise_ops",
"candidate_sampling_ops",
diff --git a/tensorflow/core/api_def/base_api/api_def_DecodeCompressed.pbtxt b/tensorflow/core/api_def/base_api/api_def_DecodeCompressed.pbtxt
new file mode 100644
index 0000000000..9babd82293
--- /dev/null
+++ b/tensorflow/core/api_def/base_api/api_def_DecodeCompressed.pbtxt
@@ -0,0 +1,32 @@
+op {
+ graph_op_name: "DecodeCompressed"
+ in_arg {
+ name: "bytes"
+ description: <<END
+A Tensor of string which is compressed.
+END
+ }
+ out_arg {
+ name: "output"
+ description: <<END
+A Tensor with the same shape as input `bytes`, uncompressed
+from bytes.
+END
+ }
+ attr {
+ name: "compression_type"
+ description: <<END
+A scalar containing either (i) the empty string (no
+compression), (ii) "ZLIB", or (iii) "GZIP".
+END
+ }
+ summary: "Decompress strings."
+ description: <<END
+This op decompresses each element of the `bytes` input `Tensor`, which
+is assumed to be compressed using the given `compression_type`.
+
+The `output` is a string `Tensor` of the same shape as `bytes`,
+each element containing the decompressed data from the corresponding
+element in `bytes`.
+END
+}
diff --git a/tensorflow/core/api_def/base_api/api_def_RecordInput.pbtxt b/tensorflow/core/api_def/base_api/api_def_RecordInput.pbtxt
index 7efc8cd833..333144d76e 100644
--- a/tensorflow/core/api_def/base_api/api_def_RecordInput.pbtxt
+++ b/tensorflow/core/api_def/base_api/api_def_RecordInput.pbtxt
@@ -43,5 +43,12 @@ END
The batch size.
END
}
+ attr {
+ name: "compression_type"
+ description: <<END
+The type of compression for the file. Currently ZLIB and
+GZIP are supported. Defaults to none.
+END
+ }
summary: "Emits randomized records."
}
diff --git a/tensorflow/core/framework/numeric_types.h b/tensorflow/core/framework/numeric_types.h
index 8514d7c474..650aa4203e 100644
--- a/tensorflow/core/framework/numeric_types.h
+++ b/tensorflow/core/framework/numeric_types.h
@@ -25,6 +25,7 @@ limitations under the License.
#include "third_party/eigen3/unsupported/Eigen/CXX11/FixedPoint"
// clang-format on
+#include "tensorflow/core/platform/cpu_info.h"
#include "tensorflow/core/platform/types.h"
namespace tensorflow {
diff --git a/tensorflow/core/grappler/costs/virtual_placer.h b/tensorflow/core/grappler/costs/virtual_placer.h
index 7ccb1ebb99..fee5ce0f51 100644
--- a/tensorflow/core/grappler/costs/virtual_placer.h
+++ b/tensorflow/core/grappler/costs/virtual_placer.h
@@ -41,7 +41,7 @@ class VirtualPlacer {
private:
// Converts given device name to Lowercase Fully-Qualified Name (LFQN) string.
// This helps us disambiguate device names internally and simplify matching.
- // If device_name couldn't be parsed succesfully, returns empty string.
+ // If device_name couldn't be parsed successfully, returns empty string.
string to_lfqn_or_empty(const string& device_name) const;
// Map based on the cluster info: cluster device name -> device properties.
diff --git a/tensorflow/core/grappler/costs/virtual_scheduler_test.cc b/tensorflow/core/grappler/costs/virtual_scheduler_test.cc
index 2e999c2957..cd960bab29 100644
--- a/tensorflow/core/grappler/costs/virtual_scheduler_test.cc
+++ b/tensorflow/core/grappler/costs/virtual_scheduler_test.cc
@@ -1768,7 +1768,7 @@ TEST_F(VirtualSchedulerTest, WhileLoop) {
EXPECT_NE(exit_start_micro, exit_1_start_micro);
// Check dependency among the nodes; no matter what scheduling mechanism we
- // use, the scheduled ops should follow these depedency chains.
+ // use, the scheduled ops should follow these dependency chains.
// Note that currently, VirtualScheduler executes while/Merge twice; hence,
// we're not testing dependency chains related to while/Merge.
// TODO(dyoon): after fixing while loop behavior correctly (run nodes in the
diff --git a/tensorflow/core/grappler/optimizers/dependency_optimizer.cc b/tensorflow/core/grappler/optimizers/dependency_optimizer.cc
index f41d954c4c..5b0b1986ff 100644
--- a/tensorflow/core/grappler/optimizers/dependency_optimizer.cc
+++ b/tensorflow/core/grappler/optimizers/dependency_optimizer.cc
@@ -52,7 +52,7 @@ int RemoveInput(NodeDef* node, const string& input, NodeMap* node_map) {
return num_removed;
}
-// Remove dulicate control inputs.
+// Remove duplicate control inputs.
void PruneControlInputs(NodeDef* node) {
std::unordered_set<string> inputs;
int pos = 0;
diff --git a/tensorflow/core/kernels/BUILD b/tensorflow/core/kernels/BUILD
index a24335e1ea..ae39c4522d 100644
--- a/tensorflow/core/kernels/BUILD
+++ b/tensorflow/core/kernels/BUILD
@@ -3495,6 +3495,7 @@ tf_kernel_library(
cc_library(
name = "parsing",
deps = [
+ ":decode_compressed_op",
":decode_csv_op",
":decode_raw_op",
":example_parsing_ops",
@@ -3524,6 +3525,14 @@ tf_kernel_library(
)
tf_kernel_library(
+ name = "decode_compressed_op",
+ prefix = "decode_compressed_op",
+ deps = [
+ "//tensorflow/core:lib_internal",
+ ] + PARSING_DEPS,
+)
+
+tf_kernel_library(
name = "example_parsing_ops",
prefix = "example_parsing_ops",
deps = PARSING_DEPS,
diff --git a/tensorflow/core/kernels/bucketize_op_gpu.cu.cc b/tensorflow/core/kernels/bucketize_op_gpu.cu.cc
index 325dee793b..551d77f495 100644
--- a/tensorflow/core/kernels/bucketize_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/bucketize_op_gpu.cu.cc
@@ -33,11 +33,28 @@ namespace tensorflow {
typedef Eigen::GpuDevice GPUDevice;
-template <typename T>
+template <typename T, bool useSharedMem>
__global__ void BucketizeCustomKernel(
const int32 size_in, const T* in, const int32 size_boundaries,
CudaDeviceArrayStruct<float> boundaries_array, int32* out) {
const float* boundaries = GetCudaDeviceArrayOnDevice(&boundaries_array);
+
+ extern __shared__ __align__(sizeof(float)) unsigned char shared_mem[];
+ float* shared_mem_boundaries = reinterpret_cast<float*>(shared_mem);
+
+ if (useSharedMem) {
+ int32 lidx = threadIdx.y * blockDim.x + threadIdx.x;
+ int32 blockSize = blockDim.x * blockDim.y;
+
+ for (int32 i = lidx; i < size_boundaries; i += blockSize) {
+ shared_mem_boundaries[i] = boundaries[i];
+ }
+
+ __syncthreads();
+
+ boundaries = shared_mem_boundaries;
+ }
+
CUDA_1D_KERNEL_LOOP(i, size_in) {
T value = in[i];
int32 bucket = 0;
@@ -77,11 +94,20 @@ struct BucketizeFunctor<GPUDevice, T> {
TF_RETURN_IF_ERROR(boundaries_array.Finalize());
CudaLaunchConfig config = GetCudaLaunchConfig(input.size(), d);
- BucketizeCustomKernel<T>
- <<<config.block_count, config.thread_per_block, 0, d.stream()>>>(
- input.size(), input.data(), boundaries_vector.size(),
- boundaries_array.data(), output.data());
-
+ int32 shared_mem_size = sizeof(float) * boundaries_vector.size();
+ const int32 kMaxSharedMemBytes = 16384;
+ if (shared_mem_size < d.sharedMemPerBlock() &&
+ shared_mem_size < kMaxSharedMemBytes) {
+ BucketizeCustomKernel<T, true>
+ <<<config.block_count, config.thread_per_block, shared_mem_size,
+ d.stream()>>>(input.size(), input.data(), boundaries_vector.size(),
+ boundaries_array.data(), output.data());
+ } else {
+ BucketizeCustomKernel<T, false>
+ <<<config.block_count, config.thread_per_block, 0, d.stream()>>>(
+ input.size(), input.data(), boundaries_vector.size(),
+ boundaries_array.data(), output.data());
+ }
return Status::OK();
}
};
diff --git a/tensorflow/core/kernels/cwise_op_exp.cc b/tensorflow/core/kernels/cwise_op_exp.cc
index 9d4d654427..66d7b7d22e 100644
--- a/tensorflow/core/kernels/cwise_op_exp.cc
+++ b/tensorflow/core/kernels/cwise_op_exp.cc
@@ -20,7 +20,8 @@ REGISTER5(UnaryOp, CPU, "Exp", functor::exp, float, Eigen::half, double,
complex64, complex128);
#if GOOGLE_CUDA
-REGISTER3(UnaryOp, GPU, "Exp", functor::exp, float, Eigen::half, double);
+REGISTER5(UnaryOp, GPU, "Exp", functor::exp, float, Eigen::half, double,
+ complex64, complex128);
#endif
#if TENSORFLOW_USE_SYCL
diff --git a/tensorflow/core/kernels/cwise_op_gpu_exp.cu.cc b/tensorflow/core/kernels/cwise_op_gpu_exp.cu.cc
index 0f492917bd..417e5da758 100644
--- a/tensorflow/core/kernels/cwise_op_gpu_exp.cu.cc
+++ b/tensorflow/core/kernels/cwise_op_gpu_exp.cu.cc
@@ -19,7 +19,7 @@ limitations under the License.
namespace tensorflow {
namespace functor {
-DEFINE_UNARY3(exp, Eigen::half, float, double);
+DEFINE_UNARY5(exp, Eigen::half, float, double, complex64, complex128);
} // namespace functor
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_ops.h b/tensorflow/core/kernels/cwise_ops.h
index d32185b6bf..da70b1e314 100644
--- a/tensorflow/core/kernels/cwise_ops.h
+++ b/tensorflow/core/kernels/cwise_ops.h
@@ -26,24 +26,28 @@ limitations under the License.
#include "tensorflow/core/kernels/bounds_check.h"
namespace Eigen {
-namespace internal {
+namespace numext {
+#if GOOGLE_CUDA
+template <>
+EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::complex<float> exp(
+ const std::complex<float>& x) {
+ auto com = ::expf(x.real());
+ auto res_real = com * ::cosf(x.imag());
+ auto res_imag = com * ::sinf(x.imag());
+ return std::complex<float>(res_real, res_imag);
+}
+template <>
+EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::complex<double> exp(
+ const std::complex<double>& x) {
+ auto com = ::exp(x.real());
+ auto res_real = com * ::cos(x.imag());
+ auto res_imag = com * ::sin(x.imag());
+ return std::complex<double>(res_real, res_imag);
+}
+#endif
+} // namespace numext
-// TODO(rmlarsen): Get rid of fmod2 once fmod is upstreamed to Eigen.
-template <typename T>
-struct scalar_fmod2_op {
- EIGEN_EMPTY_STRUCT_CTOR(scalar_fmod2_op)
- EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const T operator()(const T& a,
- const T& b) const {
- return std::fmod(a, b);
- }
-};
-template <typename T>
-struct functor_traits<scalar_fmod2_op<T>> {
- enum {
- Cost = 13, // Reciprocal throughput of FPREM on Haswell.
- PacketAccess = false,
- };
-};
+namespace internal {
template <typename T>
struct scalar_asinh_op {
@@ -702,7 +706,7 @@ struct safe_div : base<T, Eigen::internal::safe_div_or_mod_op<
};
template <typename T>
-struct fmod : base<T, Eigen::internal::scalar_fmod2_op<T>> {};
+struct fmod : base<T, Eigen::internal::scalar_fmod_op<T>> {};
template <typename T>
struct mod : base<T, Eigen::internal::scalar_mod2_op<T>> {};
diff --git a/tensorflow/core/kernels/decode_compressed_op.cc b/tensorflow/core/kernels/decode_compressed_op.cc
new file mode 100644
index 0000000000..3c3d49e1f8
--- /dev/null
+++ b/tensorflow/core/kernels/decode_compressed_op.cc
@@ -0,0 +1,125 @@
+/* Copyright 2015 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.
+==============================================================================*/
+
+// See docs in ../ops/parse_ops.cc.
+
+#include <algorithm>
+#include "tensorflow/core/framework/op_kernel.h"
+#include "tensorflow/core/framework/tensor.h"
+#include "tensorflow/core/framework/tensor_shape.h"
+#include "tensorflow/core/framework/types.h"
+#include "tensorflow/core/lib/core/errors.h"
+#include "tensorflow/core/lib/io/zlib_compression_options.h"
+#include "tensorflow/core/lib/io/zlib_inputstream.h"
+
+namespace tensorflow {
+namespace {
+// Wrap memory buffer into InputStreamInterface
+class MemoryInputStream : public io::InputStreamInterface {
+ public:
+ explicit MemoryInputStream(const char* buffer, size_t length)
+ : buf_(buffer), len_(length), pos_(0) {}
+
+ ~MemoryInputStream() override {}
+
+ Status ReadNBytes(int64 bytes_to_read, string* result) override {
+ result->clear();
+ if (bytes_to_read < 0) {
+ return errors::InvalidArgument("Can't read a negative number of bytes: ",
+ bytes_to_read);
+ }
+ int64 bytes = bytes_to_read;
+ Status s = Status::OK();
+ if (pos_ + bytes_to_read > len_) {
+ bytes = len_ - pos_;
+ s = errors::OutOfRange("reached end of file");
+ }
+ if (bytes > 0) {
+ result->resize(bytes);
+ memcpy(&(*result)[0], &buf_[pos_], bytes);
+ pos_ += bytes;
+ }
+ return s;
+ }
+
+ int64 Tell() const override { return pos_; }
+
+ Status Reset() override {
+ pos_ = 0;
+ return Status::OK();
+ }
+
+ private:
+ const char* buf_; // Not owned.
+ int64 len_;
+ int64 pos_ = 0; // Tracks where we are in the file.
+};
+} // namespace
+
+class DecodeCompressedOp : public OpKernel {
+ public:
+ explicit DecodeCompressedOp(OpKernelConstruction* context)
+ : OpKernel(context) {
+ OP_REQUIRES_OK(context,
+ context->GetAttr("compression_type", &compression_type_));
+ OP_REQUIRES(context,
+ (compression_type_.empty() || compression_type_ == "ZLIB" ||
+ compression_type_ == "GZIP"),
+ errors::InvalidArgument(
+ "Only ZLIB, GZIP or NONE are supported compressions"));
+ }
+
+ void Compute(OpKernelContext* context) override {
+ const Tensor* bytes_tensor;
+ OP_REQUIRES_OK(context, context->input("bytes", &bytes_tensor));
+ const auto& bytes_flat = bytes_tensor->flat<string>();
+
+ Tensor* output_tensor = nullptr;
+ OP_REQUIRES_OK(context,
+ context->allocate_output("output", bytes_tensor->shape(),
+ &output_tensor));
+ auto output_flat = output_tensor->flat<string>();
+ if (compression_type_.empty()) {
+ for (int64 i = 0; i < bytes_flat.size(); i++) {
+ output_flat(i) = bytes_flat(i);
+ }
+ } else {
+ const io::ZlibCompressionOptions zlib_options =
+ compression_type_ == "ZLIB" ? io::ZlibCompressionOptions::DEFAULT()
+ : io::ZlibCompressionOptions::GZIP();
+ for (int64 i = 0; i < bytes_flat.size(); i++) {
+ std::unique_ptr<MemoryInputStream> input_stream(
+ new MemoryInputStream(bytes_flat(i).data(), bytes_flat(i).size()));
+ std::unique_ptr<io::ZlibInputStream> zlib_stream(
+ new io::ZlibInputStream(
+ input_stream.get(), static_cast<size_t>(kBufferSize),
+ static_cast<size_t>(kBufferSize), zlib_options));
+ string output_string;
+ Status s = zlib_stream->ReadNBytes(INT_MAX, &output_string);
+ OP_REQUIRES(context, (s.ok() || errors::IsOutOfRange(s)), s);
+ output_flat(i) = output_string;
+ }
+ }
+ }
+
+ private:
+ enum { kBufferSize = 256 << 10 /* 256 kB */ };
+ string compression_type_;
+};
+
+REGISTER_KERNEL_BUILDER(Name("DecodeCompressed").Device(DEVICE_CPU),
+ DecodeCompressedOp)
+
+} // namespace tensorflow
diff --git a/tensorflow/core/kernels/record_input_op.cc b/tensorflow/core/kernels/record_input_op.cc
index 878996c9d6..1448feb6f6 100644
--- a/tensorflow/core/kernels/record_input_op.cc
+++ b/tensorflow/core/kernels/record_input_op.cc
@@ -36,6 +36,7 @@ class RecordInputOp : public OpKernel {
GETATTR(int64, file_buffer_size);
GETATTR(int64, file_parallelism);
GETATTR(int64, batch_size);
+ GETATTR(string, compression_type);
#undef GETATTR
RecordYielder::Options yopts;
@@ -44,6 +45,7 @@ class RecordInputOp : public OpKernel {
yopts.bufsize = file_buffer_size;
yopts.file_shuffle_shift_ratio = file_shuffle_shift_ratio;
yopts.parallelism = file_parallelism;
+ yopts.compression_type = compression_type;
yielder_ = std::unique_ptr<RecordYielder>(new RecordYielder(ctx, yopts));
batch_size_ = batch_size;
diff --git a/tensorflow/core/kernels/record_yielder.cc b/tensorflow/core/kernels/record_yielder.cc
index e4fa0ed322..3fd9bf9def 100644
--- a/tensorflow/core/kernels/record_yielder.cc
+++ b/tensorflow/core/kernels/record_yielder.cc
@@ -206,7 +206,10 @@ void RecordYielder::ShardLoop(Shard* shard) {
shard->status = errors::InvalidArgument("Can't open ", filename);
break;
}
- io::RecordReader rdr(file.get());
+ io::RecordReaderOptions options =
+ io::RecordReaderOptions::CreateRecordReaderOptions(
+ opts_.compression_type);
+ io::RecordReader rdr(file.get(), options);
uint64 offset = 0;
string record;
while (true) {
diff --git a/tensorflow/core/kernels/record_yielder.h b/tensorflow/core/kernels/record_yielder.h
index c630181221..34817ad51b 100644
--- a/tensorflow/core/kernels/record_yielder.h
+++ b/tensorflow/core/kernels/record_yielder.h
@@ -78,6 +78,8 @@ class RecordYielder {
// Uses these many concurrent tfrecord iterators to iterate through
// tfrecords.
int32 parallelism = 1;
+
+ string compression_type;
};
explicit RecordYielder(OpKernelConstruction* context,
diff --git a/tensorflow/core/kernels/slice_op.cc b/tensorflow/core/kernels/slice_op.cc
index a9e31cc336..43f17df898 100644
--- a/tensorflow/core/kernels/slice_op.cc
+++ b/tensorflow/core/kernels/slice_op.cc
@@ -273,7 +273,6 @@ class MklSliceOp : public OpKernel {
HANDLE_DIM(1);
HANDLE_DIM(2);
HANDLE_DIM(3);
- HANDLE_DIM(4);
HANDLE_DIM(5);
HANDLE_DIM(6);
HANDLE_DIM(7);
diff --git a/tensorflow/core/kernels/unique_op.cc b/tensorflow/core/kernels/unique_op.cc
index d087784c8a..782470210f 100644
--- a/tensorflow/core/kernels/unique_op.cc
+++ b/tensorflow/core/kernels/unique_op.cc
@@ -133,11 +133,7 @@ class UniqueOp : public OpKernel {
auto Tout = output->shaped<T, 3>(new_sizes);
for (auto it : uniq) {
- for (int64 i = 0; i < Tin.dimension(0); i++) {
- for (int64 j = 0; j < Tin.dimension(2); j++) {
- Tout(i, it.second, j) = Tin(i, it.first, j);
- }
- }
+ Tout.chip(it.second, 1) = Tin.chip(it.first, 1);
}
if (num_outputs() > 2) {
diff --git a/tensorflow/core/kernels/unpack_op.cc b/tensorflow/core/kernels/unpack_op.cc
index 71bbb50fb1..397bdd5670 100644
--- a/tensorflow/core/kernels/unpack_op.cc
+++ b/tensorflow/core/kernels/unpack_op.cc
@@ -154,6 +154,12 @@ REGISTER_KERNEL_BUILDER(Name("Unpack")
.HostMemory("output")
.TypeConstraint<int32>("T"),
UnpackOp<CPUDevice, int32>);
+REGISTER_KERNEL_BUILDER(Name("Unpack")
+ .Device(DEVICE_GPU)
+ .HostMemory("value")
+ .HostMemory("output")
+ .TypeConstraint<int64>("T"),
+ UnpackOp<CPUDevice, int64>);
#endif // GOOGLE_CUDA
@@ -171,6 +177,13 @@ REGISTER_KERNEL_BUILDER(Name("Unpack")
.HostMemory("output")
.TypeConstraint<int32>("T"),
UnpackOp<CPUDevice, int32>);
+
+REGISTER_KERNEL_BUILDER(Name("Unpack")
+ .Device(DEVICE_SYCL)
+ .HostMemory("value")
+ .HostMemory("output")
+ .TypeConstraint<int64>("T"),
+ UnpackOp<CPUDevice, int64>);
#undef REGISTER_SYCL
#endif // TENSORFLOW_USE_SYCL
diff --git a/tensorflow/core/lib/strings/str_util_test.cc b/tensorflow/core/lib/strings/str_util_test.cc
index d5909d17aa..6d461241f7 100644
--- a/tensorflow/core/lib/strings/str_util_test.cc
+++ b/tensorflow/core/lib/strings/str_util_test.cc
@@ -305,7 +305,7 @@ TEST(SplitAndParseAsInts, Int64) {
EXPECT_EQ(nums[0], 134);
EXPECT_EQ(nums[1], 2);
EXPECT_EQ(nums[2], 13);
- EXPECT_EQ(nums[3], -4000000000);
+ EXPECT_EQ(nums[3], static_cast<int64>(-4000000000ull));
EXPECT_FALSE(str_util::SplitAndParseAsInts("abc", ',', &nums));
diff --git a/tensorflow/core/ops/data_flow_ops.cc b/tensorflow/core/ops/data_flow_ops.cc
index ac2dc601f1..b3d7653359 100644
--- a/tensorflow/core/ops/data_flow_ops.cc
+++ b/tensorflow/core/ops/data_flow_ops.cc
@@ -2497,6 +2497,7 @@ REGISTER_OP("RecordInput")
.Attr("file_buffer_size: int = 10000")
.Attr("file_parallelism: int = 16")
.Attr("batch_size: int = 32")
+ .Attr("compression_type: string = ''")
.SetIsStateful()
.SetShapeFn(shape_inference::UnknownShape)
.Doc(R"doc(
@@ -2510,6 +2511,8 @@ file_shuffle_shift_ratio: Shifts the list of files after the list is randomly
file_buffer_size: The randomization shuffling buffer.
file_parallelism: How many sstables are opened and concurrently iterated over.
batch_size: The batch size.
+compression_type: The type of compression for the file. Currently ZLIB and
+ GZIP are supported. Defaults to none.
)doc");
} // namespace tensorflow
diff --git a/tensorflow/core/ops/parsing_ops.cc b/tensorflow/core/ops/parsing_ops.cc
index 11b28badc8..c7c6ff5b35 100644
--- a/tensorflow/core/ops/parsing_ops.cc
+++ b/tensorflow/core/ops/parsing_ops.cc
@@ -48,6 +48,28 @@ output: A Tensor with one more dimension than the input `bytes`. The
of `bytes` divided by the number of bytes to represent `out_type`.
)doc");
+REGISTER_OP("DecodeCompressed")
+ .Input("bytes: string")
+ .Output("output: string")
+ .Attr("compression_type: string = ''")
+ .SetShapeFn(shape_inference::UnchangedShape)
+ .Doc(R"doc(
+Decompress strings.
+
+This op decompresses each element of the `bytes` input `Tensor`, which
+is assumed to be compressed using the given `compression_type`.
+
+The `output` is a string `Tensor` of the same shape as `bytes`,
+each element containing the decompressed data from the corresponding
+element in `bytes`.
+
+bytes: A Tensor of string which is compressed.
+output: A Tensor with the same shape as input `bytes`, uncompressed
+ from bytes.
+compression_type: A scalar containing either (i) the empty string (no
+ compression), (ii) "ZLIB", or (iii) "GZIP".
+)doc");
+
REGISTER_OP("ParseExample")
.Input("serialized: string")
.Input("names: string")
diff --git a/tensorflow/core/platform/cloud/file_block_cache_test.cc b/tensorflow/core/platform/cloud/file_block_cache_test.cc
index 12ad44011f..ae87e0de29 100644
--- a/tensorflow/core/platform/cloud/file_block_cache_test.cc
+++ b/tensorflow/core/platform/cloud/file_block_cache_test.cc
@@ -482,7 +482,7 @@ TEST(FileBlockCacheTest, CoalesceConcurrentReads) {
FileBlockCache cache(block_size, block_size, 0, fetcher);
// Fork off thread for parallel read.
std::unique_ptr<Thread> concurrent(
- Env::Default()->StartThread({}, "concurrent", [&cache] {
+ Env::Default()->StartThread({}, "concurrent", [&cache, block_size] {
std::vector<char> out;
TF_EXPECT_OK(ReadCache(&cache, "", 0, block_size / 2, &out));
EXPECT_EQ(out.size(), block_size / 2);
diff --git a/tensorflow/core/platform/default/mutex.h b/tensorflow/core/platform/default/mutex.h
index c3e44c42d9..044c754e80 100644
--- a/tensorflow/core/platform/default/mutex.h
+++ b/tensorflow/core/platform/default/mutex.h
@@ -31,6 +31,8 @@ namespace tensorflow {
enum LinkerInitialized { LINKER_INITIALIZED };
+class condition_variable;
+
// Mimic std::mutex + C++17's shared_mutex, adding a LinkerInitialized
// constructor interface. This type is as fast as mutex, but is also a shared
// lock.
diff --git a/tensorflow/core/platform/env.cc b/tensorflow/core/platform/env.cc
index 12ef55ec26..816ffa464f 100644
--- a/tensorflow/core/platform/env.cc
+++ b/tensorflow/core/platform/env.cc
@@ -20,6 +20,10 @@ limitations under the License.
#if defined(__APPLE__)
#include <mach-o/dyld.h>
#endif
+#if defined(__FreeBSD__)
+#include <sys/sysctl.h>
+#include <sys/types.h>
+#endif
#if defined(PLATFORM_WINDOWS)
#include <windows.h>
#include "tensorflow/core/platform/windows/windows_file_system.h"
@@ -266,6 +270,14 @@ string Env::GetExecutablePath() {
char unresolved_path[buffer_size];
_NSGetExecutablePath(unresolved_path, &buffer_size);
CHECK(realpath(unresolved_path, exe_path));
+#elif defined(__FreeBSD__)
+ int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
+ size_t exe_path_size = PATH_MAX;
+
+ if (sysctl(mib, 4, exe_path, &exe_path_size, NULL, 0) != 0) {
+ // Resolution of path failed
+ return "";
+ }
#elif defined(PLATFORM_WINDOWS)
HMODULE hModule = GetModuleHandleW(NULL);
WCHAR wc_file_path[MAX_PATH] = {0};
@@ -288,30 +300,47 @@ bool Env::LocalTempFilename(string* filename) {
// Try each directory, as they might be full, have inappropriate
// permissions or have different problems at times.
for (const string& dir : dirs) {
+ *filename = io::JoinPath(dir, "tempfile-");
+ if (CreateUniqueFileName(filename, "")) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool Env::CreateUniqueFileName(string* prefix, const string& suffix) {
#ifdef __APPLE__
- uint64_t tid64;
- pthread_threadid_np(nullptr, &tid64);
- int32 tid = static_cast<int32>(tid64);
- int32 pid = static_cast<int32>(getpid());
+ uint64_t tid64;
+ pthread_threadid_np(nullptr, &tid64);
+ int32 tid = static_cast<int32>(tid64);
+ int32 pid = static_cast<int32>(getpid());
+#elif defined(__FreeBSD__)
+ // Has to be casted to long first, else this error appears:
+ // static_cast from 'pthread_t' (aka 'pthread *') to 'int32' (aka 'int')
+ // is not allowed
+ int32 tid = static_cast<int32>(static_cast<int64>(pthread_self()));
+ int32 pid = static_cast<int32>(getpid());
#elif defined(PLATFORM_WINDOWS)
- int32 tid = static_cast<int32>(GetCurrentThreadId());
- int32 pid = static_cast<int32>(GetCurrentProcessId());
+ int32 tid = static_cast<int32>(GetCurrentThreadId());
+ int32 pid = static_cast<int32>(GetCurrentProcessId());
#else
- int32 tid = static_cast<int32>(pthread_self());
- int32 pid = static_cast<int32>(getpid());
+ int32 tid = static_cast<int32>(pthread_self());
+ int32 pid = static_cast<int32>(getpid());
#endif
- uint64 now_microsec = NowMicros();
+ uint64 now_microsec = NowMicros();
- *filename = io::JoinPath(
- dir, strings::Printf("tempfile-%s-%x-%d-%llx", port::Hostname().c_str(),
- tid, pid, now_microsec));
- if (FileExists(*filename).ok()) {
- filename->clear();
- } else {
- return true;
- }
+ *prefix += strings::Printf("%s-%x-%d-%llx", port::Hostname().c_str(), tid,
+ pid, now_microsec);
+
+ if (!suffix.empty()) {
+ *prefix += suffix;
+ }
+ if (FileExists(*prefix).ok()) {
+ prefix->clear();
+ return false;
+ } else {
+ return true;
}
- return false;
}
Thread::~Thread() {}
diff --git a/tensorflow/core/platform/env.h b/tensorflow/core/platform/env.h
index da8c3e2d7e..a0adf70ef4 100644
--- a/tensorflow/core/platform/env.h
+++ b/tensorflow/core/platform/env.h
@@ -218,6 +218,10 @@ class Env {
/// Creates a local unique temporary file name. Returns true if success.
bool LocalTempFilename(string* filename);
+ /// Creates a local unique file name that starts with |prefix| and ends with
+ /// |suffix|. Returns true if success.
+ bool CreateUniqueFileName(string* prefix, const string& suffix);
+
// TODO(jeff,sanjay): Add back thread/thread-pool support if needed.
// TODO(jeff,sanjay): if needed, tighten spec so relative to epoch, or
// provide a routine to get the absolute time.
diff --git a/tensorflow/core/platform/env_test.cc b/tensorflow/core/platform/env_test.cc
index c9b362f182..233c370a5f 100644
--- a/tensorflow/core/platform/env_test.cc
+++ b/tensorflow/core/platform/env_test.cc
@@ -20,6 +20,7 @@ limitations under the License.
#include "tensorflow/core/framework/graph.pb.h"
#include "tensorflow/core/framework/node_def.pb.h"
#include "tensorflow/core/lib/core/status_test_util.h"
+#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/io/path.h"
#include "tensorflow/core/lib/strings/str_util.h"
#include "tensorflow/core/lib/strings/strcat.h"
@@ -340,4 +341,18 @@ TEST_F(DefaultEnvTest, LocalTempFilename) {
EXPECT_FALSE(env->FileExists(filename).ok());
}
+TEST_F(DefaultEnvTest, CreateUniqueFileName) {
+ Env* env = Env::Default();
+
+ string prefix = "tempfile-prefix-";
+ string suffix = ".tmp";
+ string filename = prefix;
+
+ EXPECT_TRUE(env->CreateUniqueFileName(&filename, suffix));
+
+ StringPiece str(filename);
+ EXPECT_TRUE(str.starts_with(prefix));
+ EXPECT_TRUE(str.ends_with(suffix));
+}
+
} // namespace tensorflow
diff --git a/tensorflow/core/platform/macros.h b/tensorflow/core/platform/macros.h
index 47523c7d2b..6119edfd5a 100644
--- a/tensorflow/core/platform/macros.h
+++ b/tensorflow/core/platform/macros.h
@@ -93,7 +93,8 @@ limitations under the License.
((sizeof(a) / sizeof(*(a))) / \
static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
-#if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
+#if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L || \
+ (defined(_MSC_VER) && _MSC_VER >= 1900)
// Define this to 1 if the code is compiled in C++11 mode; leave it
// undefined otherwise. Do NOT define it to 0 -- that causes
// '#ifdef LANG_CXX11' to behave differently from '#if LANG_CXX11'.
diff --git a/tensorflow/core/public/session.h b/tensorflow/core/public/session.h
index bca384e59f..75ad50f6f2 100644
--- a/tensorflow/core/public/session.h
+++ b/tensorflow/core/public/session.h
@@ -186,7 +186,7 @@ class Session {
/// the `SessionOptions::target` field).
virtual Status Close() = 0;
- // NOTE(ashankar): As of July 2017, this method was added to faciliate some
+ // NOTE(ashankar): As of July 2017, this method was added to facilitate some
// experimentation. Reconsider/re-evaluate after September 2017.
//
// Sets `*output` to the `DeviceMgr` that owns accessible devices in the
diff --git a/tensorflow/core/public/version.h b/tensorflow/core/public/version.h
index ec077c4283..d8e7df48c2 100644
--- a/tensorflow/core/public/version.h
+++ b/tensorflow/core/public/version.h
@@ -119,5 +119,7 @@ extern const char* tf_compiler_version();
extern const char* tf_git_version();
// Value of the _GLIBCXX_USE_CXX11_ABI flag, or 0 if it's not set.
extern const int tf_cxx11_abi_flag();
+// Returns 1 if build is monolithic, or 0 otherwise.
+extern const int tf_monolithic_build();
#endif // TENSORFLOW_CORE_PUBLIC_VERSION_H_
diff --git a/tensorflow/core/util/strided_slice_op.cc b/tensorflow/core/util/strided_slice_op.cc
index cfe9275a09..aca60b942d 100644
--- a/tensorflow/core/util/strided_slice_op.cc
+++ b/tensorflow/core/util/strided_slice_op.cc
@@ -218,8 +218,8 @@ Status ValidateStridedSliceOp(
// Step 2: Make a sparse spec into a full index spec
//
- // The sparse spec does not corresopnds to the number of dimensions
- // Make a dense spec that corresponds to thte number of dimensions
+ // The sparse spec does not correspond to the number of dimensions
+ // Make a dense spec that corresponds to the number of dimensions
//
// For example suppose foo[...,3:] on foo.shape=(2,2,3) then
// we need to produce the missing begin_mask for the first two
diff --git a/tensorflow/core/util/tensor_slice_reader.h b/tensorflow/core/util/tensor_slice_reader.h
index 4bb2b24615..263f56c7fc 100644
--- a/tensorflow/core/util/tensor_slice_reader.h
+++ b/tensorflow/core/util/tensor_slice_reader.h
@@ -15,7 +15,6 @@ limitations under the License.
// The utility to read checkpoints for google brain tensor ops and v3
// checkpoints for dist_belief.
-//
#ifndef TENSORFLOW_UTIL_TENSOR_SLICE_READER_H_
#define TENSORFLOW_UTIL_TENSOR_SLICE_READER_H_
diff --git a/tensorflow/core/util/tensor_slice_reader_cache.h b/tensorflow/core/util/tensor_slice_reader_cache.h
index bdd36a2791..63a8d0b068 100644
--- a/tensorflow/core/util/tensor_slice_reader_cache.h
+++ b/tensorflow/core/util/tensor_slice_reader_cache.h
@@ -15,7 +15,6 @@ limitations under the License.
// The utility to read checkpoints for google brain tensor ops and v3
// checkpoints for dist_belief.
-//
#ifndef TENSORFLOW_UTIL_TENSOR_SLICE_READER_CACHE_H_
#define TENSORFLOW_UTIL_TENSOR_SLICE_READER_CACHE_H_
diff --git a/tensorflow/core/util/tensor_slice_writer.h b/tensorflow/core/util/tensor_slice_writer.h
index 95d6384afe..bdb4921e1b 100644
--- a/tensorflow/core/util/tensor_slice_writer.h
+++ b/tensorflow/core/util/tensor_slice_writer.h
@@ -15,7 +15,6 @@ limitations under the License.
// The utility to write checkpoints for google brain tensor ops and v3
// checkpoints for dist_belief.
-//
#ifndef TENSORFLOW_UTIL_TENSOR_SLICE_WRITER_H_
#define TENSORFLOW_UTIL_TENSOR_SLICE_WRITER_H_
diff --git a/tensorflow/docs_src/get_started/feature_columns.md b/tensorflow/docs_src/get_started/feature_columns.md
index 7726dd2822..a725b1f31c 100644
--- a/tensorflow/docs_src/get_started/feature_columns.md
+++ b/tensorflow/docs_src/get_started/feature_columns.md
@@ -419,7 +419,7 @@ still adds significant value to the learning capability of your models.
Somewhat counterintuitively, when creating feature crosses, you typically still
should include the original (uncrossed) features in your model (as in the
preceding code snippet). The independent latitude and longitude features help the
-model distinguish between examples where a hash collision has occured in the
+model distinguish between examples where a hash collision has occurred in the
crossed feature.
## Indicator and embedding columns
diff --git a/tensorflow/docs_src/get_started/get_started.md b/tensorflow/docs_src/get_started/get_started.md
index 231108215a..701635075c 100644
--- a/tensorflow/docs_src/get_started/get_started.md
+++ b/tensorflow/docs_src/get_started/get_started.md
@@ -375,7 +375,7 @@ estimator = tf.estimator.LinearRegressor(feature_columns=feature_columns)
x_train = np.array([1., 2., 3., 4.])
y_train = np.array([0., -1., -2., -3.])
x_eval = np.array([2., 5., 8., 1.])
-y_eval = np.array([-1.01, -4.1, -7, 0.])
+y_eval = np.array([-1.01, -4.1, -7., 0.])
input_fn = tf.estimator.inputs.numpy_input_fn(
{"x": x_train}, y_train, batch_size=4, num_epochs=None, shuffle=True)
train_input_fn = tf.estimator.inputs.numpy_input_fn(
diff --git a/tensorflow/docs_src/mobile/tflite/index.md b/tensorflow/docs_src/mobile/tflite/index.md
index 49d93669a2..6c4589d693 100644
--- a/tensorflow/docs_src/mobile/tflite/index.md
+++ b/tensorflow/docs_src/mobile/tflite/index.md
@@ -155,7 +155,7 @@ retraining for both floating point and quantized inference.
The following diagram shows the architectural design of TensorFlow Lite:
-<img src = "/images/tflite-architecture.jpg">
+![tensorflow lite architecture](https://www.tensorflow.org/images/tflite-architecture.jpg)
Starting with a trained TensorFlow model on disk, you'll convert that model to
the TensorFlow Lite file format (`.tflite`) using the TensorFlow Lite
diff --git a/tensorflow/docs_src/programmers_guide/debugger.md b/tensorflow/docs_src/programmers_guide/debugger.md
index 3cdfeaeeed..9eaee27028 100644
--- a/tensorflow/docs_src/programmers_guide/debugger.md
+++ b/tensorflow/docs_src/programmers_guide/debugger.md
@@ -340,11 +340,11 @@ tfdbg> ni cross_entropy/Log
![tfdbg run-end UI: infs and nans](https://www.tensorflow.org/images/tfdbg_screenshot_run_end_node_info.png)
You can see that this node has the op type `Log`
-and that its input is the node `softmax/Softmax`. Run the following command to
+and that its input is the node `Softmax`. Run the following command to
take a closer look at the input tensor:
```none
-tfdbg> pt softmax/Softmax:0
+tfdbg> pt Softmax:0
```
Examine the values in the input tensor, searching for zeros:
diff --git a/tensorflow/docs_src/programmers_guide/variables.md b/tensorflow/docs_src/programmers_guide/variables.md
index bac385c02c..6425073805 100644
--- a/tensorflow/docs_src/programmers_guide/variables.md
+++ b/tensorflow/docs_src/programmers_guide/variables.md
@@ -205,7 +205,7 @@ methods:
v = tf.get_variable("v", shape=(), initializer=tf.zeros_initializer())
assignment = v.assign_add(1)
tf.global_variables_initializer().run()
-sess.run(assignment) # or assignment.op.run()
+sess.run(assignment) # or assignment.op.run(), or assignment.eval()
```
Most TensorFlow optimizers have specialized ops that efficiently update the
diff --git a/tensorflow/examples/how_tos/reading_data/fully_connected_reader.py b/tensorflow/examples/how_tos/reading_data/fully_connected_reader.py
index 9db8835d92..fa4c1c0da5 100644
--- a/tensorflow/examples/how_tos/reading_data/fully_connected_reader.py
+++ b/tensorflow/examples/how_tos/reading_data/fully_connected_reader.py
@@ -62,7 +62,7 @@ def decode(serialized_example):
# Convert label from a scalar uint8 tensor to an int32 scalar.
label = tf.cast(features['label'], tf.int32)
-
+
return image, label
def augment(image, label):
@@ -172,7 +172,7 @@ def run_training():
step += 1
except tf.errors.OutOfRangeError:
print('Done training for %d epochs, %d steps.' % (FLAGS.num_epochs, step))
-
+
def main(_):
run_training()
diff --git a/tensorflow/examples/ios/.gitignore b/tensorflow/examples/ios/.gitignore
index e572b3012c..dbabfb33bf 100644
--- a/tensorflow/examples/ios/.gitignore
+++ b/tensorflow/examples/ios/.gitignore
@@ -2,3 +2,6 @@ project.xcworkspace
xcuserdata
imagenet_comp_graph_label_strings.txt
tensorflow_inception_graph.pb
+simple/data/LICENSE
+camera/data/LICENSE
+benchmark/data/LICENSE
diff --git a/tensorflow/go/README.md b/tensorflow/go/README.md
index 376e22b380..b1bd87eb0c 100644
--- a/tensorflow/go/README.md
+++ b/tensorflow/go/README.md
@@ -26,9 +26,12 @@ from source.
([Linux](https://www.tensorflow.org/install/install_sources#PrepareLinux)
or [OS
X](https://www.tensorflow.org/install/install_sources#PrepareMac)).
- If you don't need GPU support, then try the following: `sh # Linux sudo
- apt-get install python swig python-numpy # OS X with homebrew brew install
- swig`
+ If you don't need GPU support, then try the following:
+
+ ```sh
+ sudo apt-get install python swig python-numpy # Linux
+ brew install swig # OS X with homebrew
+ ```
### Build
diff --git a/tensorflow/go/genop/generate.sh b/tensorflow/go/genop/generate.sh
index 01fcfb9058..a894c87c27 100644
--- a/tensorflow/go/genop/generate.sh
+++ b/tensorflow/go/genop/generate.sh
@@ -19,6 +19,11 @@ set -e
go get github.com/golang/protobuf/proto
go get github.com/golang/protobuf/protoc-gen-go
+if [ -z "${GOPATH}" ]
+then
+ GOPATH=$(go env GOPATH)
+fi
+
cd $(dirname $0)
for g in $(echo "${GOPATH//:/ }"); do
TF_DIR="${g}/src/github.com/tensorflow/tensorflow"
diff --git a/tensorflow/go/genop/main.go b/tensorflow/go/genop/main.go
index 4d4940edf9..4a53084ed1 100644
--- a/tensorflow/go/genop/main.go
+++ b/tensorflow/go/genop/main.go
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-//go:generate sh generate.sh
+//go:generate bash generate.sh
// Command genop generates a Go source file with functions for TensorFlow ops.
package main
diff --git a/tensorflow/java/src/gen/java/org/tensorflow/processor/OperatorProcessor.java b/tensorflow/java/src/gen/java/org/tensorflow/processor/OperatorProcessor.java
index 45e42878c7..11fda4fc22 100644
--- a/tensorflow/java/src/gen/java/org/tensorflow/processor/OperatorProcessor.java
+++ b/tensorflow/java/src/gen/java/org/tensorflow/processor/OperatorProcessor.java
@@ -77,7 +77,7 @@ public final class OperatorProcessor extends AbstractProcessor {
TypeElement annotation = annotations.iterator().next();
Set<? extends Element> annotated = roundEnv.getElementsAnnotatedWith(annotation);
- // If there are no annotated elements, claim the annotion but do nothing.
+ // If there are no annotated elements, claim the annotation but do nothing.
if (annotated.size() == 0) {
return true;
}
diff --git a/tensorflow/java/src/test/java/org/tensorflow/SessionTest.java b/tensorflow/java/src/test/java/org/tensorflow/SessionTest.java
index a86b4dd117..e8cc76c2a6 100644
--- a/tensorflow/java/src/test/java/org/tensorflow/SessionTest.java
+++ b/tensorflow/java/src/test/java/org/tensorflow/SessionTest.java
@@ -151,7 +151,7 @@ public class SessionTest {
s.close();
try {
s.runner().run();
- fail("methods on a close()d session should fail");
+ fail("methods on a session should fail after close() is called");
} catch (IllegalStateException e) {
// expected exception
}
diff --git a/tensorflow/python/debug/wrappers/grpc_wrapper.py b/tensorflow/python/debug/wrappers/grpc_wrapper.py
index cb9bf95782..dc93dda86c 100644
--- a/tensorflow/python/debug/wrappers/grpc_wrapper.py
+++ b/tensorflow/python/debug/wrappers/grpc_wrapper.py
@@ -17,7 +17,6 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
-import sys
import traceback
# Google-internal import(s).
@@ -139,7 +138,7 @@ class GrpcDebugWrapperSession(framework.NonInteractiveDebugWrapperSession):
class TensorBoardDebugWrapperSession(GrpcDebugWrapperSession):
- """A tfdbg Session wrapper that can be used with TensroBoard Debugger Plugin.
+ """A tfdbg Session wrapper that can be used with TensorBoard Debugger Plugin.
This wrapper is the same as `GrpcDebugWrapperSession`, except that it uses a
predefined `watch_fn` that
@@ -169,7 +168,7 @@ class TensorBoardDebugWrapperSession(GrpcDebugWrapperSession):
# Keeps track of the latest version of Python graph object that has been
# sent to the debug servers.
- self._sent_graph_version = -sys.maxint
+ self._sent_graph_version = -1
def run(self,
fetches,
diff --git a/tensorflow/python/debug/wrappers/hooks.py b/tensorflow/python/debug/wrappers/hooks.py
index aa9f065040..835c7378c7 100644
--- a/tensorflow/python/debug/wrappers/hooks.py
+++ b/tensorflow/python/debug/wrappers/hooks.py
@@ -18,8 +18,6 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
-import sys
-
from tensorflow.core.protobuf import config_pb2
from tensorflow.python.debug.lib import debug_utils
from tensorflow.python.debug.lib import stepper
@@ -335,7 +333,7 @@ class TensorBoardDebugHook(GrpcDebugHook):
log_usage=log_usage)
self._grpc_debug_server_addresses = grpc_debug_server_addresses
- self._sent_graph_version = -sys.maxint
+ self._sent_graph_version = -1
def before_run(self, run_context):
self._sent_graph_version = grpc_wrapper.publish_traceback(
diff --git a/tensorflow/python/kernel_tests/BUILD b/tensorflow/python/kernel_tests/BUILD
index d98bb0f8cc..f5ada46eeb 100644
--- a/tensorflow/python/kernel_tests/BUILD
+++ b/tensorflow/python/kernel_tests/BUILD
@@ -294,6 +294,19 @@ tf_py_test(
],
)
+tf_py_test(
+ name = "decode_compressed_op_test",
+ size = "small",
+ srcs = ["decode_compressed_op_test.py"],
+ additional_deps = [
+ "//third_party/py/numpy",
+ "//tensorflow/python:array_ops",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:framework_for_generated_wrappers",
+ "//tensorflow/python:parsing_ops",
+ ],
+)
+
cuda_py_test(
name = "determinant_op_test",
size = "small",
diff --git a/tensorflow/python/kernel_tests/cwise_ops_test.py b/tensorflow/python/kernel_tests/cwise_ops_test.py
index e0c53950e6..cea12ea8ec 100644
--- a/tensorflow/python/kernel_tests/cwise_ops_test.py
+++ b/tensorflow/python/kernel_tests/cwise_ops_test.py
@@ -416,7 +416,7 @@ class UnaryOpTest(test.TestCase):
self._compareCpu(x, np.square, math_ops.square)
self._compareCpu(y, np.sqrt, math_ops.sqrt)
self._compareCpu(y, self._rsqrt, math_ops.rsqrt)
- self._compareCpu(x, np.exp, math_ops.exp)
+ self._compareBoth(x, np.exp, math_ops.exp)
self._compareCpu(x, np.expm1, math_ops.expm1)
self._compareCpu(y, np.log, math_ops.log)
self._compareCpu(y, np.log1p, math_ops.log1p)
@@ -460,7 +460,7 @@ class UnaryOpTest(test.TestCase):
self._compareCpu(x, np.square, math_ops.square)
self._compareCpu(y, np.sqrt, math_ops.sqrt)
self._compareCpu(y, self._rsqrt, math_ops.rsqrt)
- self._compareCpu(x, np.exp, math_ops.exp)
+ self._compareBoth(x, np.exp, math_ops.exp)
self._compareCpu(x, np.expm1, math_ops.expm1)
self._compareCpu(y, np.log, math_ops.log)
self._compareCpu(y, np.log1p, math_ops.log1p)
diff --git a/tensorflow/python/kernel_tests/decode_compressed_op_test.py b/tensorflow/python/kernel_tests/decode_compressed_op_test.py
new file mode 100644
index 0000000000..c9bda58ca7
--- /dev/null
+++ b/tensorflow/python/kernel_tests/decode_compressed_op_test.py
@@ -0,0 +1,73 @@
+# Copyright 2015 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 DecodeRaw op from parsing_ops."""
+
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
+import gzip
+import zlib
+
+from six import BytesIO
+
+from tensorflow.python.framework import dtypes
+from tensorflow.python.ops import array_ops
+from tensorflow.python.ops import parsing_ops
+from tensorflow.python.platform import test
+
+
+class DecodeCompressedOpTest(test.TestCase):
+
+ def _compress(self, bytes_in, compression_type):
+ if not compression_type:
+ return bytes_in
+ elif compression_type == "ZLIB":
+ return zlib.compress(bytes_in)
+ else:
+ out = BytesIO()
+ with gzip.GzipFile(fileobj=out, mode="wb") as f:
+ f.write(bytes_in)
+ return out.getvalue()
+
+ def testDecompress(self):
+ for compression_type in ["ZLIB", "GZIP", ""]:
+ with self.test_session():
+ in_bytes = array_ops.placeholder(dtypes.string, shape=[2])
+ decompressed = parsing_ops.decode_compressed(
+ in_bytes, compression_type=compression_type)
+ self.assertEqual([2], decompressed.get_shape().as_list())
+
+ result = decompressed.eval(
+ feed_dict={in_bytes: [self._compress(b"AaAA", compression_type),
+ self._compress(b"bBbb", compression_type)]})
+ self.assertAllEqual([b"AaAA", b"bBbb"], result)
+
+ def testDecompressWithRaw(self):
+ for compression_type in ["ZLIB", "GZIP", ""]:
+ with self.test_session():
+ in_bytes = array_ops.placeholder(dtypes.string, shape=[None])
+ decompressed = parsing_ops.decode_compressed(
+ in_bytes, compression_type=compression_type)
+ decode = parsing_ops.decode_raw(decompressed, out_type=dtypes.int16)
+
+ result = decode.eval(
+ feed_dict={in_bytes: [self._compress(b"AaBC", compression_type)]})
+ self.assertAllEqual(
+ [[ord("A") + ord("a") * 256, ord("B") + ord("C") * 256]], result)
+
+
+if __name__ == "__main__":
+ test.main()
diff --git a/tensorflow/python/kernel_tests/dynamic_partition_op_test.py b/tensorflow/python/kernel_tests/dynamic_partition_op_test.py
index b4fb5aa411..fedbf9e696 100644
--- a/tensorflow/python/kernel_tests/dynamic_partition_op_test.py
+++ b/tensorflow/python/kernel_tests/dynamic_partition_op_test.py
@@ -18,6 +18,8 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
+import unittest
+
import numpy as np
from six.moves import xrange # pylint: disable=redefined-builtin
@@ -219,6 +221,7 @@ class DynamicPartitionTest(test.TestCase):
self.assertAllEqual([], partition_vals[0])
self.assertAllEqual([], partition_vals[1])
+ @unittest.skip("Fails on windows.")
def testGPUTooManyParts(self):
# This test only makes sense on the GPU. There we do not check
# for errors. In this case, we should discard all but the first
@@ -239,6 +242,7 @@ class DynamicPartitionTest(test.TestCase):
self.assertAllEqual([6], partition_vals[0])
self.assertAllEqual([5], partition_vals[1])
+ @unittest.skip("Fails on windows.")
def testGPUPartsTooLarge(self):
# This test only makes sense on the GPU. There we do not check
# for errors. In this case, we should discard all the values
@@ -262,6 +266,7 @@ class DynamicPartitionTest(test.TestCase):
self.assertAllEqual([], partition_vals[3])
self.assertAllEqual([], partition_vals[4])
+ @unittest.skip("Fails on windows.")
def testGPUAllIndicesBig(self):
# This test only makes sense on the GPU. There we do not check
# for errors. In this case, we should discard all the values
diff --git a/tensorflow/python/kernel_tests/lookup_ops_test.py b/tensorflow/python/kernel_tests/lookup_ops_test.py
index e4c799cb1c..5f08339fe5 100644
--- a/tensorflow/python/kernel_tests/lookup_ops_test.py
+++ b/tensorflow/python/kernel_tests/lookup_ops_test.py
@@ -618,15 +618,20 @@ class IndexToStringTableFromFileTest(test.TestCase):
return vocabulary_file
def test_index_to_string_table(self):
- vocabulary_file = self._createVocabFile("i2f_vocab1.txt")
- with self.test_session():
- table = lookup_ops.index_to_string_table_from_file(
- vocabulary_file=vocabulary_file)
- features = table.lookup(constant_op.constant([0, 1, 2, 3], dtypes.int64))
- self.assertRaises(errors_impl.OpError, features.eval)
- lookup_ops.tables_initializer().run()
- self.assertAllEqual((b"brain", b"salad", b"surgery", b"UNK"),
- features.eval())
+ vocabulary_path = self._createVocabFile("i2f_vocab1.txt")
+ # vocabulary_file supports string and tensor
+ type_funcs = [str, constant_op.constant]
+ for type_func in type_funcs:
+ vocabulary_file = type_func(vocabulary_path)
+ with self.test_session():
+ table = lookup_ops.index_to_string_table_from_file(
+ vocabulary_file=vocabulary_file)
+ features = table.lookup(
+ constant_op.constant([0, 1, 2, 3], dtypes.int64))
+ self.assertRaises(errors_impl.OpError, features.eval)
+ lookup_ops.tables_initializer().run()
+ self.assertAllEqual((b"brain", b"salad", b"surgery", b"UNK"),
+ features.eval())
def test_index_to_string_table_from_multicolumn_file(self):
vocabulary_file = self._createVocabFile(
diff --git a/tensorflow/python/kernel_tests/record_input_test.py b/tensorflow/python/kernel_tests/record_input_test.py
index 1ec48ac361..44cd89022c 100644
--- a/tensorflow/python/kernel_tests/record_input_test.py
+++ b/tensorflow/python/kernel_tests/record_input_test.py
@@ -29,10 +29,15 @@ from tensorflow.python.platform import test
class RecordInputOpTest(test.TestCase):
- def generateTestData(self, prefix, n, m):
+ def generateTestData(self,
+ prefix,
+ n,
+ m,
+ compression_type=tf_record.TFRecordCompressionType.NONE):
+ options = tf_record.TFRecordOptions(compression_type)
for i in range(n):
f = os.path.join(self.get_temp_dir(), prefix + "." + str(i))
- w = tf_record.TFRecordWriter(f)
+ w = tf_record.TFRecordWriter(f, options=options)
for j in range(m):
w.write("{0:0{width}}".format(i * m + j, width=10).encode("utf-8"))
@@ -52,6 +57,44 @@ class RecordInputOpTest(test.TestCase):
self.assertEqual(sess.run(yield_op), b"0000000000")
+ def testRecordInputSimpleGzip(self):
+ with self.test_session() as sess:
+ self.generateTestData(
+ "basic",
+ 1,
+ 1,
+ compression_type=tf_record.TFRecordCompressionType.GZIP)
+
+ yield_op = data_flow_ops.RecordInput(
+ file_pattern=os.path.join(self.get_temp_dir(), "basic.*"),
+ parallelism=1,
+ buffer_size=1,
+ batch_size=1,
+ name="record_input",
+ compression_type=tf_record.TFRecordCompressionType.GZIP).get_yield_op(
+ )
+
+ self.assertEqual(sess.run(yield_op), b"0000000000")
+
+ def testRecordInputSimpleZlib(self):
+ with self.test_session() as sess:
+ self.generateTestData(
+ "basic",
+ 1,
+ 1,
+ compression_type=tf_record.TFRecordCompressionType.ZLIB)
+
+ yield_op = data_flow_ops.RecordInput(
+ file_pattern=os.path.join(self.get_temp_dir(), "basic.*"),
+ parallelism=1,
+ buffer_size=1,
+ batch_size=1,
+ name="record_input",
+ compression_type=tf_record.TFRecordCompressionType.ZLIB).get_yield_op(
+ )
+
+ self.assertEqual(sess.run(yield_op), b"0000000000")
+
def testRecordInputEpochs(self):
files = 100
records_per_file = 100
diff --git a/tensorflow/python/kernel_tests/svd_op_test.py b/tensorflow/python/kernel_tests/svd_op_test.py
index 9871eacb03..d20567bf0e 100644
--- a/tensorflow/python/kernel_tests/svd_op_test.py
+++ b/tensorflow/python/kernel_tests/svd_op_test.py
@@ -190,10 +190,11 @@ class SvdGradOpTest(test.TestCase):
pass # Filled in below
-def _GetSvdGradOpTest(dtype_, shape_, compute_uv_):
+def _GetSvdGradOpTest(dtype_, shape_, compute_uv_, full_matrices_):
def _NormalizingSvd(tf_a):
- tf_s, tf_u, tf_v = linalg_ops.svd(tf_a, compute_uv=True, full_matrices=True)
+ tf_s, tf_u, tf_v = linalg_ops.svd(
+ tf_a, compute_uv=True, full_matrices=full_matrices_)
# Singular vectors are only unique up to an arbitrary phase. We normalize
# the vectors such that the first component of u (if m >=n) or v (if n > m)
# have phase 0.
@@ -270,17 +271,20 @@ if __name__ == "__main__":
_GetSvdOpTest(dtype, shape, use_static_shape,
compute_uv, full_matrices))
for compute_uv in False, True:
- dtypes = ([np.float32, np.float64] + [np.complex64, np.complex128] *
- (not compute_uv))
- for dtype in dtypes:
- mat_shapes = ([(10, 11), (11, 10),
- (11, 11)] + [(5, 11), (11, 5)] * (not compute_uv))
- for mat_shape in mat_shapes:
- for batch_dims in [(), (3,)]:
- shape = batch_dims + mat_shape
- name = "%s_%s_compute_uv_%s" % (dtype.__name__,
- "_".join(map(str, shape)), compute_uv)
- _AddTest(SvdGradOpTest, "SvdGrad", name,
- _GetSvdGradOpTest(dtype, shape, compute_uv))
+ for full_matrices in False, True:
+ dtypes = ([np.float32, np.float64]
+ + [np.complex64, np.complex128] * (not compute_uv))
+ for dtype in dtypes:
+ mat_shapes = [(10, 11), (11, 10), (11, 11)]
+ if not full_matrices or not compute_uv:
+ mat_shapes += [(5, 11), (11, 5)]
+ for mat_shape in mat_shapes:
+ for batch_dims in [(), (3,)]:
+ shape = batch_dims + mat_shape
+ name = "%s_%s_compute_uv_%s_full_%s" % (
+ dtype.__name__, "_".join(map(str, shape)), compute_uv,
+ full_matrices)
+ _AddTest(SvdGradOpTest, "SvdGrad", name,
+ _GetSvdGradOpTest(dtype, shape, compute_uv, full_matrices))
test.main()
diff --git a/tensorflow/python/kernel_tests/unstack_op_test.py b/tensorflow/python/kernel_tests/unstack_op_test.py
index c2dcff978a..8481875576 100644
--- a/tensorflow/python/kernel_tests/unstack_op_test.py
+++ b/tensorflow/python/kernel_tests/unstack_op_test.py
@@ -22,6 +22,7 @@ import numpy as np
from six.moves import xrange # pylint: disable=redefined-builtin
from tensorflow.python.framework import constant_op
+from tensorflow.python.framework import test_util
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import gradient_checker
from tensorflow.python.platform import test
@@ -42,15 +43,35 @@ class UnstackOpTest(test.TestCase):
np.random.seed(7)
with self.test_session(use_gpu=True):
for shape in (2,), (3,), (2, 3), (3, 2), (4, 3, 2):
- data = np.random.randn(*shape)
- # Convert data to a single tensorflow tensor
- x = constant_op.constant(data)
- # Unpack into a list of tensors
- cs = array_ops.unstack(x, num=shape[0])
- self.assertEqual(type(cs), list)
- self.assertEqual(len(cs), shape[0])
- cs = [c.eval() for c in cs]
- self.assertAllEqual(cs, data)
+ for dtype in [
+ np.bool, np.float16, np.float32, np.float64, np.int32, np.int64
+ ]:
+ data = np.random.randn(*shape).astype(dtype)
+ # Convert data to a single tensorflow tensor
+ x = constant_op.constant(data)
+ # Unpack into a list of tensors
+ cs = array_ops.unstack(x, num=shape[0])
+ self.assertEqual(type(cs), list)
+ self.assertEqual(len(cs), shape[0])
+ cs = [c.eval() for c in cs]
+ self.assertAllEqual(cs, data)
+
+ def testSimpleGpu(self):
+ if not test_util.is_gpu_available():
+ self.skipTest('No GPU available')
+ np.random.seed(7)
+ with self.test_session(use_gpu=True, force_gpu=True):
+ for shape in (2,), (3,), (2, 3), (3, 2), (4, 3, 2):
+ for dtype in [np.float16, np.float32, np.float64, np.int32, np.int64]:
+ data = np.random.randn(*shape).astype(dtype)
+ # Convert data to a single tensorflow tensor
+ x = constant_op.constant(data)
+ # Unpack into a list of tensors
+ cs = array_ops.unstack(x, num=shape[0])
+ self.assertEqual(type(cs), list)
+ self.assertEqual(len(cs), shape[0])
+ cs = [c.eval() for c in cs]
+ self.assertAllEqual(cs, data)
def testGradientsAxis0(self):
for shape in (2,), (3,), (2, 3), (3, 2), (4, 3, 2):
diff --git a/tensorflow/python/kernel_tests/variable_scope_test.py b/tensorflow/python/kernel_tests/variable_scope_test.py
index 8491171923..c090715cc4 100644
--- a/tensorflow/python/kernel_tests/variable_scope_test.py
+++ b/tensorflow/python/kernel_tests/variable_scope_test.py
@@ -746,6 +746,130 @@ class VariableScopeTest(test.TestCase):
with ops.name_scope("scope2") as sc2:
self.assertEqual(sc2, "outer_1/default/scope2/")
+ def testBasicWhenAuxiliaryNameScopeIsFalse(self):
+ with self.test_session():
+ with variable_scope.variable_scope(
+ "scope", auxiliary_name_scope=False) as scope:
+ self.assertEqual(scope.original_name_scope, "")
+ self.assertEqual(variable_scope.get_variable("w", []).name, "scope/w:0")
+ self.assertEqual(constant_op.constant([], name="c").name, "c:0")
+ with variable_scope.variable_scope(scope, auxiliary_name_scope=False):
+ self.assertEqual(scope.original_name_scope, "")
+ self.assertEqual(
+ variable_scope.get_variable("w1", []).name, "scope/w1:0")
+ self.assertEqual(constant_op.constant([], name="c1").name, "c1:0")
+ # Recheck: new name scope is NOT created before
+ with ops.name_scope("scope"):
+ self.assertEqual(constant_op.constant([], name="c").name, "scope/c:0")
+
+ with variable_scope.variable_scope("outer"):
+ with variable_scope.variable_scope(
+ "inner", auxiliary_name_scope=False) as inner:
+ self.assertEqual(inner.original_name_scope, "outer/")
+ self.assertEqual(
+ variable_scope.get_variable("w", []).name, "outer/inner/w:0")
+ self.assertEqual(constant_op.constant([], name="c").name, "outer/c:0")
+ with variable_scope.variable_scope(
+ inner, auxiliary_name_scope=False) as inner1:
+ self.assertEqual(inner1.original_name_scope, "outer/")
+ self.assertEqual(
+ variable_scope.get_variable("w1", []).name, "outer/inner/w1:0")
+ self.assertEqual(
+ constant_op.constant([], name="c1").name, "outer/c1:0")
+ # Recheck: new name scope is NOT created before
+ with ops.name_scope("inner"):
+ self.assertEqual(
+ constant_op.constant([], name="c").name, "outer/inner/c:0")
+
+ def testCreatedByDefaultNameWhenAuxiliaryNameScopeIsFalse(self):
+ with self.test_session():
+ with variable_scope.variable_scope(
+ None, default_name="default", auxiliary_name_scope=False) as scope:
+ self.assertEqual(scope.original_name_scope, "")
+ self.assertEqual(
+ variable_scope.get_variable("w", []).name, "default/w:0")
+ self.assertEqual(constant_op.constant([], name="c").name, "c:0")
+ # Recheck: new name scope is NOT created before
+ with ops.name_scope("default"):
+ self.assertEqual(constant_op.constant([], name="c").name, "default/c:0")
+
+ with variable_scope.variable_scope("outer"):
+ with variable_scope.variable_scope(
+ None, default_name="default", auxiliary_name_scope=False) as inner:
+ self.assertEqual(inner.original_name_scope, "outer/")
+ self.assertEqual(
+ variable_scope.get_variable("w", []).name, "outer/default/w:0")
+ self.assertEqual(constant_op.constant([], name="c").name, "outer/c:0")
+ # Recheck: new name scope is NOT created before
+ with ops.name_scope("default"):
+ self.assertEqual(
+ constant_op.constant([], name="c").name, "outer/default/c:0")
+
+ def testReenterRootScopeWhenAuxiliaryNameScopeIsFalse(self):
+ with self.test_session():
+ root_scope = variable_scope.get_variable_scope()
+ with variable_scope.variable_scope(
+ root_scope, auxiliary_name_scope=False) as scope:
+ self.assertEqual(scope.original_name_scope, "")
+ self.assertEqual(variable_scope.get_variable("w", []).name, "w:0")
+ self.assertEqual(constant_op.constant([], name="c").name, "c:0")
+
+ with variable_scope.variable_scope("outer"):
+ with variable_scope.variable_scope(
+ root_scope, auxiliary_name_scope=False) as inner:
+ self.assertEqual(inner.original_name_scope, "")
+ self.assertEqual(variable_scope.get_variable("w1", []).name, "w1:0")
+ self.assertEqual(
+ constant_op.constant([], name="c1").name, "outer/c1:0")
+
+ def testAuxiliaryNameScopeIsInvalid(self):
+ with self.test_session():
+ with self.assertRaisesRegexp(TypeError, "auxiliary_name_scope"):
+ with variable_scope.variable_scope(
+ None, default_name="scope", auxiliary_name_scope="invalid"):
+ pass
+
+ with self.assertRaisesRegexp(TypeError, "auxiliary_name_scope"):
+ with variable_scope.variable_scope(
+ "scope", auxiliary_name_scope="invalid"):
+ pass
+
+ with variable_scope.variable_scope("scope") as scope:
+ pass
+ with self.assertRaisesRegexp(TypeError, "auxiliary_name_scope"):
+ with variable_scope.variable_scope(
+ scope, auxiliary_name_scope="invalid"):
+ pass
+
+ def testReuseScopeWithoutNameScopeCollision(self):
+ # Github issue: #13429
+ with self.test_session():
+ with variable_scope.variable_scope("outer"):
+ with variable_scope.variable_scope("inner") as inner:
+ pass
+
+ with variable_scope.variable_scope(
+ inner, auxiliary_name_scope=False) as scope:
+ with ops.name_scope(scope.original_name_scope):
+ self.assertEqual(
+ variable_scope.get_variable("w", []).name, "outer/inner/w:0")
+ self.assertEqual(
+ constant_op.constant([], name="c").name, "outer/inner/c:0")
+ with ops.name_scope("inner"):
+ self.assertEqual(constant_op.constant([], name="c").name, "inner/c:0")
+
+ with variable_scope.variable_scope("another"):
+ with variable_scope.variable_scope(
+ inner, auxiliary_name_scope=False) as scope1:
+ with ops.name_scope(scope1.original_name_scope):
+ self.assertEqual(
+ variable_scope.get_variable("w1", []).name, "outer/inner/w1:0")
+ self.assertEqual(
+ constant_op.constant([], name="c1").name, "outer/inner/c1:0")
+ with ops.name_scope("inner"):
+ self.assertEqual(
+ constant_op.constant([], name="c").name, "another/inner/c:0")
+
@test_util.run_in_graph_and_eager_modes()
def testGetLocalVar(self):
# Check that local variable respects naming.
diff --git a/tensorflow/python/layers/base.py b/tensorflow/python/layers/base.py
index ee5277d16d..26ce0a6518 100644
--- a/tensorflow/python/layers/base.py
+++ b/tensorflow/python/layers/base.py
@@ -493,7 +493,8 @@ class Layer(object):
self._set_scope(None)
with vs.variable_scope(
- self._scope, reuse=(self.built or self._reuse)) as scope:
+ self._scope, reuse=(self.built or self._reuse),
+ auxiliary_name_scope=False) as scope:
with ops.name_scope(self._name_scope_name(scope)):
variable = vs.get_variable(name,
shape=shape,
@@ -602,11 +603,11 @@ class Layer(object):
# variable scope with this setting. We avoid re-creating variable scopes
# after this point as an optimization.
self._always_reuse_variable_scope = vs.variable_scope(
- self._scope, reuse=True)
+ self._scope, reuse=True, auxiliary_name_scope=False)
scope_context_manager = self._always_reuse_variable_scope
else:
scope_context_manager = vs.variable_scope(
- self._scope, reuse=self._reuse)
+ self._scope, reuse=self._reuse, auxiliary_name_scope=False)
with scope_context_manager as scope:
with ops.name_scope(self._name_scope_name(scope)):
if not self.built:
diff --git a/tensorflow/python/layers/base_test.py b/tensorflow/python/layers/base_test.py
index 3e5a51eb62..c26b13667e 100644
--- a/tensorflow/python/layers/base_test.py
+++ b/tensorflow/python/layers/base_test.py
@@ -474,6 +474,63 @@ class BaseLayerTest(test.TestCase):
layer.apply(x)
self.assertEqual(len(layer.get_losses_for(x)), 1)
+ def testNameScopeIsConsistentWithVariableScope(self):
+ # Github issue 13429.
+
+ class MyLayer(base_layers.Layer):
+
+ def build(self, input_shape):
+ self.my_var = self.add_variable('my_var', (), dtypes.float32)
+ self.built = True
+
+ def call(self, inputs):
+ return math_ops.multiply(inputs, self.my_var, name='my_op')
+
+ def _gen_layer(x, name=None):
+ layer = MyLayer(name=name)
+ out = layer.apply(x)
+ return layer, out
+
+ # unnamed layer
+ with ops.Graph().as_default():
+ x = array_ops.placeholder(dtypes.float32, (), 'x')
+ layer, op = _gen_layer(x)
+ layer1, op1 = _gen_layer(op)
+ layer2, op2 = _gen_layer(op1)
+
+ self.assertEqual(layer.my_var.name, 'my_layer/my_var:0')
+ self.assertEqual(op.name, 'my_layer/my_op:0')
+ self.assertEqual(layer1.my_var.name, 'my_layer_1/my_var:0')
+ self.assertEqual(op1.name, 'my_layer_1/my_op:0')
+ self.assertEqual(layer2.my_var.name, 'my_layer_2/my_var:0')
+ self.assertEqual(op2.name, 'my_layer_2/my_op:0')
+ # name starts from zero
+ with ops.Graph().as_default():
+ x = array_ops.placeholder(dtypes.float32, (), 'x')
+ layer, op = _gen_layer(x, name='name')
+ layer1, op1 = _gen_layer(op, name='name_1')
+ layer2, op2 = _gen_layer(op1, name='name_2')
+
+ self.assertEqual(layer.my_var.name, 'name/my_var:0')
+ self.assertEqual(op.name, 'name/my_op:0')
+ self.assertEqual(layer1.my_var.name, 'name_1/my_var:0')
+ self.assertEqual(op1.name, 'name_1/my_op:0')
+ self.assertEqual(layer2.my_var.name, 'name_2/my_var:0')
+ self.assertEqual(op2.name, 'name_2/my_op:0')
+ # name starts from one
+ with ops.Graph().as_default():
+ x = array_ops.placeholder(dtypes.float32, (), 'x')
+ layer, op = _gen_layer(x, name='name_1')
+ layer1, op1 = _gen_layer(op, name='name_2')
+ layer2, op2 = _gen_layer(op1, name='name_3')
+
+ self.assertEqual(layer.my_var.name, 'name_1/my_var:0')
+ self.assertEqual(op.name, 'name_1/my_op:0')
+ self.assertEqual(layer1.my_var.name, 'name_2/my_var:0')
+ self.assertEqual(op1.name, 'name_2/my_op:0')
+ self.assertEqual(layer2.my_var.name, 'name_3/my_var:0')
+ self.assertEqual(op2.name, 'name_3/my_op:0')
+
if __name__ == '__main__':
test.main()
diff --git a/tensorflow/python/layers/convolutional.py b/tensorflow/python/layers/convolutional.py
index fbb13bb72c..dc9bf5a673 100644
--- a/tensorflow/python/layers/convolutional.py
+++ b/tensorflow/python/layers/convolutional.py
@@ -64,8 +64,8 @@ class _Conv(base.Layer):
linear activation.
use_bias: Boolean, whether the layer uses a bias.
kernel_initializer: An initializer for the convolution kernel.
- bias_initializer: An initializer for the bias vector. If None, no bias will
- be applied.
+ bias_initializer: An initializer for the bias vector. If None, the default
+ initializer will be used.
kernel_regularizer: Optional regularizer for the convolution kernel.
bias_regularizer: Optional regularizer for the bias vector.
activity_regularizer: Optional regularizer function for the output.
@@ -254,8 +254,8 @@ class Conv1D(_Conv):
linear activation.
use_bias: Boolean, whether the layer uses a bias.
kernel_initializer: An initializer for the convolution kernel.
- bias_initializer: An initializer for the bias vector. If None, no bias will
- be applied.
+ bias_initializer: An initializer for the bias vector. If None, the default
+ initializer will be used.
kernel_regularizer: Optional regularizer for the convolution kernel.
bias_regularizer: Optional regularizer for the bias vector.
activity_regularizer: Optional regularizer function for the output.
@@ -362,8 +362,8 @@ def conv1d(inputs,
linear activation.
use_bias: Boolean, whether the layer uses a bias.
kernel_initializer: An initializer for the convolution kernel.
- bias_initializer: An initializer for the bias vector. If None, no bias will
- be applied.
+ bias_initializer: An initializer for the bias vector. If None, the default
+ initializer will be used.
kernel_regularizer: Optional regularizer for the convolution kernel.
bias_regularizer: Optional regularizer for the bias vector.
activity_regularizer: Optional regularizer function for the output.
@@ -450,8 +450,8 @@ class Conv2D(_Conv):
linear activation.
use_bias: Boolean, whether the layer uses a bias.
kernel_initializer: An initializer for the convolution kernel.
- bias_initializer: An initializer for the bias vector. If None, no bias will
- be applied.
+ bias_initializer: An initializer for the bias vector. If None, the default
+ initializer will be used.
kernel_regularizer: Optional regularizer for the convolution kernel.
bias_regularizer: Optional regularizer for the bias vector.
activity_regularizer: Optional regularizer function for the output.
@@ -565,8 +565,8 @@ def conv2d(inputs,
linear activation.
use_bias: Boolean, whether the layer uses a bias.
kernel_initializer: An initializer for the convolution kernel.
- bias_initializer: An initializer for the bias vector. If None, no bias will
- be applied.
+ bias_initializer: An initializer for the bias vector. If None, the default
+ initializer will be used.
kernel_regularizer: Optional regularizer for the convolution kernel.
bias_regularizer: Optional regularizer for the bias vector.
activity_regularizer: Optional regularizer function for the output.
@@ -654,8 +654,8 @@ class Conv3D(_Conv):
linear activation.
use_bias: Boolean, whether the layer uses a bias.
kernel_initializer: An initializer for the convolution kernel.
- bias_initializer: An initializer for the bias vector. If None, no bias will
- be applied.
+ bias_initializer: An initializer for the bias vector. If None, the default
+ initializer will be used.
kernel_regularizer: Optional regularizer for the convolution kernel.
bias_regularizer: Optional regularizer for the bias vector.
activity_regularizer: Optional regularizer function for the output.
@@ -770,8 +770,8 @@ def conv3d(inputs,
linear activation.
use_bias: Boolean, whether the layer uses a bias.
kernel_initializer: An initializer for the convolution kernel.
- bias_initializer: An initializer for the bias vector. If None, no bias will
- be applied.
+ bias_initializer: An initializer for the bias vector. If None, the default
+ initializer will be used.
kernel_regularizer: Optional regularizer for the convolution kernel.
bias_regularizer: Optional regularizer for the bias vector.
activity_regularizer: Optional regularizer function for the output.
@@ -860,8 +860,8 @@ class SeparableConv2D(Conv2D):
use_bias: Boolean, whether the layer uses a bias.
depthwise_initializer: An initializer for the depthwise convolution kernel.
pointwise_initializer: An initializer for the pointwise convolution kernel.
- bias_initializer: An initializer for the bias vector. If None, no bias will
- be applied.
+ bias_initializer: An initializer for the bias vector. If None, the default
+ initializer will be used.
depthwise_regularizer: Optional regularizer for the depthwise
convolution kernel.
pointwise_regularizer: Optional regularizer for the pointwise
@@ -1089,8 +1089,8 @@ def separable_conv2d(inputs,
use_bias: Boolean, whether the layer uses a bias.
depthwise_initializer: An initializer for the depthwise convolution kernel.
pointwise_initializer: An initializer for the pointwise convolution kernel.
- bias_initializer: An initializer for the bias vector. If None, no bias will
- be applied.
+ bias_initializer: An initializer for the bias vector. If None, the default
+ initializer will be used.
depthwise_regularizer: Optional regularizer for the depthwise
convolution kernel.
pointwise_regularizer: Optional regularizer for the pointwise
@@ -1175,8 +1175,8 @@ class Conv2DTranspose(Conv2D):
linear activation.
use_bias: Boolean, whether the layer uses a bias.
kernel_initializer: An initializer for the convolution kernel.
- bias_initializer: An initializer for the bias vector. If None, no bias will
- be applied.
+ bias_initializer: An initializer for the bias vector. If None, the default
+ initializer will be used.
kernel_regularizer: Optional regularizer for the convolution kernel.
bias_regularizer: Optional regularizer for the bias vector.
activity_regularizer: Optional regularizer function for the output.
@@ -1391,8 +1391,8 @@ def conv2d_transpose(inputs,
linear activation.
use_bias: Boolean, whether the layer uses a bias.
kernel_initializer: An initializer for the convolution kernel.
- bias_initializer: An initializer for the bias vector. If `None`, then no
- bias will be applied.
+ bias_initializer: An initializer for the bias vector. If `None`, the default
+ initializer will be used.
kernel_regularizer: Optional regularizer for the convolution kernel.
bias_regularizer: Optional regularizer for the bias vector.
activity_regularizer: Optional regularizer function for the output.
@@ -1464,8 +1464,8 @@ class Conv3DTranspose(Conv3D):
linear activation.
use_bias: Boolean, whether the layer uses a bias.
kernel_initializer: An initializer for the convolution kernel.
- bias_initializer: An initializer for the bias vector. If `None`, then no
- bias will be applied.
+ bias_initializer: An initializer for the bias vector. If `None`, the default
+ initializer will be used.
kernel_regularizer: Optional regularizer for the convolution kernel.
bias_regularizer: Optional regularizer for the bias vector.
activity_regularizer: Optional regularizer function for the output.
@@ -1705,8 +1705,8 @@ def conv3d_transpose(inputs,
linear activation.
use_bias: Boolean, whether the layer uses a bias.
kernel_initializer: An initializer for the convolution kernel.
- bias_initializer: An initializer for the bias vector. If None, no bias will
- be applied.
+ bias_initializer: An initializer for the bias vector. If None, the default
+ initializer will be used.
kernel_regularizer: Optional regularizer for the convolution kernel.
bias_regularizer: Optional regularizer for the bias vector.
activity_regularizer: Optional regularizer function for the output.
diff --git a/tensorflow/python/layers/core.py b/tensorflow/python/layers/core.py
index 7be1fa5cfe..44016d5eda 100644
--- a/tensorflow/python/layers/core.py
+++ b/tensorflow/python/layers/core.py
@@ -43,7 +43,7 @@ class Dense(base.Layer):
"""Densely-connected layer class.
This layer implements the operation:
- `outputs = activation(inputs.kernel + bias)`
+ `outputs = activation(inputs * kernel + bias)`
Where `activation` is the activation function passed as the `activation`
argument (if not `None`), `kernel` is a weights matrix created by the layer,
and `bias` is a bias vector created by the layer
diff --git a/tensorflow/python/layers/network.py b/tensorflow/python/layers/network.py
index edc52545f9..fe5588e5b2 100644
--- a/tensorflow/python/layers/network.py
+++ b/tensorflow/python/layers/network.py
@@ -794,17 +794,17 @@ class GraphNetwork(base.Layer):
# Store in cache.
self._output_shape_cache[cache_key] = output_shapes
- else:
- # Cache hit.
- output_shapes = self._output_shape_cache[cache_key]
+ else:
+ # Cache hit.
+ output_shapes = self._output_shape_cache[cache_key]
- if isinstance(output_shapes, list):
- if len(output_shapes) == 1:
- return tensor_shape.TensorShape(output_shapes[0])
- else:
- return [tensor_shape.TensorShape(shape) for shape in output_shapes]
+ if isinstance(output_shapes, list):
+ if len(output_shapes) == 1:
+ return tensor_shape.TensorShape(output_shapes[0])
else:
- return tensor_shape.TensorShape(output_shapes)
+ return [tensor_shape.TensorShape(shape) for shape in output_shapes]
+ else:
+ return tensor_shape.TensorShape(output_shapes)
def _run_internal_graph(self, inputs, masks=None):
"""Computes output tensors for new inputs.
diff --git a/tensorflow/python/lib/core/py_func.cc b/tensorflow/python/lib/core/py_func.cc
index eae1c2eea6..dc56b39486 100644
--- a/tensorflow/python/lib/core/py_func.cc
+++ b/tensorflow/python/lib/core/py_func.cc
@@ -432,6 +432,9 @@ class PyFuncOp : public OpKernel {
py_threadstate = PyGILState_Ensure();
bool log_on_error;
Status s = DoCallPyFunc(&call, &log_on_error);
+ // Sometimes py_funcs can be called without a session and leak memory. This
+ // ensures we clear the decref cache so this doesn't happen.
+ ClearDecrefCache();
PyGILState_Release(py_threadstate);
// Ensures that GIL is released even when !s.ok().
diff --git a/tensorflow/python/ops/data_flow_ops.py b/tensorflow/python/ops/data_flow_ops.py
index c186eb5b7e..f441f6d4bf 100644
--- a/tensorflow/python/ops/data_flow_ops.py
+++ b/tensorflow/python/ops/data_flow_ops.py
@@ -31,6 +31,7 @@ from tensorflow.python.framework import ops
from tensorflow.python.framework import random_seed
from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import tensor_util
+from tensorflow.python.lib.io import python_io
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import control_flow_ops
from tensorflow.python.ops import gen_data_flow_ops
@@ -2225,7 +2226,8 @@ class RecordInput(object):
shift_ratio=0,
seed=0,
name=None,
- batches=None):
+ batches=None,
+ compression_type=None):
"""Constructs a RecordInput Op.
Args:
@@ -2243,6 +2245,8 @@ class RecordInput(object):
how many batches to create, which are returned as a list when
`get_yield_op()` is called. An example use case is to split processing
between devices on one computer.
+ compression_type: The type of compression for the file. Currently ZLIB and
+ GZIP are supported. Defaults to none.
Raises:
ValueError: If one of the arguments is invalid.
@@ -2257,12 +2261,17 @@ class RecordInput(object):
self._shift_ratio = shift_ratio
self._seed = seed
self._name = name
+ self._compression_type = python_io.TFRecordCompressionType.NONE
+ if compression_type is not None:
+ self._compression_type = compression_type
def get_yield_op(self):
"""Adds a node that yields a group of records every time it is executed.
If RecordInput `batches` parameter is not None, it yields a list of
record batches with the specified `batch_size`.
"""
+ compression_type = python_io.TFRecordOptions.get_compression_type_string(
+ python_io.TFRecordOptions(self._compression_type))
records = gen_data_flow_ops.record_input(
file_pattern=self._file_pattern,
file_buffer_size=self._buffer_size,
@@ -2270,6 +2279,7 @@ class RecordInput(object):
file_shuffle_shift_ratio=self._shift_ratio,
batch_size=self._batch_size,
file_random_seed=self._seed,
+ compression_type=compression_type,
name=self._name)
if self._batches is None:
return records
diff --git a/tensorflow/python/ops/linalg_grad.py b/tensorflow/python/ops/linalg_grad.py
index 8a76fe3ce5..13a32c83d9 100644
--- a/tensorflow/python/ops/linalg_grad.py
+++ b/tensorflow/python/ops/linalg_grad.py
@@ -268,13 +268,13 @@ def _SelfAdjointEigV2Grad(op, grad_e, grad_v):
@ops.RegisterGradient("Svd")
def _SvdGrad(op, grad_s, grad_u, grad_v):
- """Gradient for Svd based on Giles' algorithm. Reference at top of file."""
-
- if op.get_attr("compute_uv") and not op.get_attr("full_matrices"):
- raise NotImplementedError(
- "SVD gradient is not implemented for compute_uv=True and "
- "full_matrices=False.")
+ """Gradient for the singular value decomposition."""
+ # The derivation for the compute_uv=False case, and most of
+ # the derivation for the full_matrices=True case, are in
+ # Giles' paper (see reference at top of file). A derivation for
+ # the full_matrices=False case is available at
+ # https://j-towns.github.io/papers/svd-derivative.pdf
a = op.inputs[0]
a_shape = a.get_shape().with_rank_at_least(2)
@@ -300,7 +300,7 @@ def _SvdGrad(op, grad_s, grad_u, grad_v):
"SVD gradient has not been implemented for input with unknown "
"inner matrix shape.")
- if not op.get_attr("full_matrices") or not op.get_attr("compute_uv"):
+ if not op.get_attr("compute_uv"):
s, u, v = linalg_ops.svd(a, compute_uv=True, full_matrices=True)
else:
s = op.outputs[0]
@@ -329,14 +329,10 @@ def _SvdGrad(op, grad_s, grad_u, grad_v):
grad_a.set_shape(a_shape)
return grad_a
- # TODO(rmlarsen): Define a gradient that is numerically stable for
- # abs(m-n) > 1. Currently this does not work because there are effectively
- # multiple singular values with value zero. I am not sure if this is a true
- # instability or if it simply throws off the finite difference gradient
- # checker.
- if abs(m - n) > 1:
+ if op.get_attr("full_matrices") and abs(m - n) > 1:
raise NotImplementedError(
- "svd gradient is not implemented for abs(m - n) > 1")
+ "svd gradient is not implemented for abs(m - n) > 1 "
+ "when full_matrices is True")
s_mat = array_ops.matrix_diag(s)
s2 = math_ops.square(s)
@@ -352,32 +348,45 @@ def _SvdGrad(op, grad_s, grad_u, grad_v):
array_ops.expand_dims(s2, -2) - array_ops.expand_dims(s2, -1)),
array_ops.zeros_like(s))
s_inv_mat = array_ops.matrix_diag(math_ops.reciprocal(s))
+
+ v1 = v[..., :, :m]
+ grad_v1 = grad_v[..., :, :m]
+
u_gu = math_ops.matmul(u, grad_u, adjoint_a=True)
- v_gv = math_ops.matmul(v, grad_v, adjoint_a=True)
+ v_gv = math_ops.matmul(v1, grad_v1, adjoint_a=True)
- if m == n:
- f_u = f * u_gu
- f_v = f * v_gv
- else:
- dv2 = array_ops.matrix_transpose(v_gv[..., m:n, :m]) - v_gv[..., :m, m:n]
- f_u = f * u_gu
- f_v = f * v_gv[..., :m, :m]
+ f_u = f * u_gu
+ f_v = f * v_gv
- grad_a_nouv = (
+ term1_nouv = (
grad_s_mat + math_ops.matmul(f_u + _linalg.adjoint(f_u), s_mat) +
math_ops.matmul(s_mat, f_v + _linalg.adjoint(f_v)))
- if m != n:
- grad_a_nouv = array_ops.concat(
- [grad_a_nouv, math_ops.matmul(s_inv_mat, dv2)], -1)
+ term1 = math_ops.matmul(u, math_ops.matmul(term1_nouv, v1, adjoint_b=True))
+
+ if m == n:
+ grad_a_before_transpose = term1
+ else:
+ gv1t = array_ops.matrix_transpose(grad_v1)
+ gv1t_v1 = math_ops.matmul(gv1t, v1)
+ term2_nous = gv1t - math_ops.matmul(gv1t_v1, v1, adjoint_b=True)
+
+ if op.get_attr("full_matrices"):
+ v2 = v[..., :, m:n]
+ grad_v2 = grad_v[..., :, m:n]
+
+ v1t_gv2 = math_ops.matmul(v1, grad_v2, adjoint_a=True)
+ term2_nous -= math_ops.matmul(v1t_gv2, v2, adjoint_b=True)
+
+ u_s_inv = math_ops.matmul(u, s_inv_mat)
+ term2 = math_ops.matmul(u_s_inv, term2_nous)
+
+ grad_a_before_transpose = term1 + term2
if use_adjoint:
- # Use (U X V^H)^H = V (U X)^H.
- grad_a = math_ops.matmul(
- v, math_ops.matmul(u, grad_a_nouv), adjoint_b=True)
+ grad_a = array_ops.matrix_transpose(grad_a_before_transpose)
else:
- grad_a = math_ops.matmul(u,
- math_ops.matmul(grad_a_nouv, v, adjoint_b=True))
+ grad_a = grad_a_before_transpose
grad_a.set_shape(a_shape)
return grad_a
diff --git a/tensorflow/python/ops/lookup_ops.py b/tensorflow/python/ops/lookup_ops.py
index 227e1a5265..d68b32cc6b 100644
--- a/tensorflow/python/ops/lookup_ops.py
+++ b/tensorflow/python/ops/lookup_ops.py
@@ -20,6 +20,7 @@ from __future__ import print_function
import collections
import functools
+import six
from tensorflow.python.eager import context
from tensorflow.python.framework import constant_op
@@ -962,7 +963,7 @@ def index_table_from_file(vocabulary_file=None,
than zero.
"""
if vocabulary_file is None or (
- isinstance(vocabulary_file, str) and not vocabulary_file):
+ isinstance(vocabulary_file, six.string_types) and not vocabulary_file):
raise ValueError("vocabulary_file must be specified and must not be empty.")
if num_oov_buckets < 0:
raise ValueError("num_oov_buckets must be greater or equal than 0, got %d."
@@ -1166,7 +1167,7 @@ def index_to_string_table_from_file(vocabulary_file,
```
Args:
- vocabulary_file: The vocabulary filename.
+ vocabulary_file: The vocabulary filename, may be a constant scalar `Tensor`.
vocab_size: Number of the elements in the vocabulary, if known.
default_value: The value to use for out-of-vocabulary indices.
name: A name for this op (optional).
@@ -1184,8 +1185,10 @@ def index_to_string_table_from_file(vocabulary_file,
ValueError: when `vocabulary_file` is empty.
ValueError: when `vocab_size` is invalid.
"""
- if not vocabulary_file:
- raise ValueError("vocabulary_file must be specified.")
+ if vocabulary_file is None or (
+ isinstance(vocabulary_file, six.string_types) and not vocabulary_file):
+ raise ValueError("vocabulary_file must be specified and must not be empty.")
+
if vocab_size is not None and vocab_size < 1:
raise ValueError("vocab_size must be greater than 0, got %d." % vocab_size)
diff --git a/tensorflow/python/ops/math_ops.py b/tensorflow/python/ops/math_ops.py
index 6af36343d5..cd07dad613 100644
--- a/tensorflow/python/ops/math_ops.py
+++ b/tensorflow/python/ops/math_ops.py
@@ -252,7 +252,7 @@ def abs(x, name=None):
Returns:
A `Tensor` or `SparseTensor` the same size and type as `x` with absolute
values.
- Note, for `complex64` or `complex128' input, the returned `Tensor` will be
+ Note, for `complex64` or `complex128` input, the returned `Tensor` will be
of type `float32` or `float64`, respectively.
"""
with ops.name_scope(name, "Abs", [x]) as name:
@@ -1437,7 +1437,7 @@ def reduce_mean(input_tensor,
input_tensor: The tensor to reduce. Should have numeric type.
axis: The dimensions to reduce. If `None` (the default),
reduces all dimensions. Must be in the range
- `[-rank(input_tensor), rank(input_tensor))`.
+ `[-rank(input_tensor), rank(input_tensor)]`.
keepdims: If true, retains reduced dimensions with length 1.
name: A name for the operation (optional).
reduction_indices: The old (deprecated) name for axis.
diff --git a/tensorflow/python/ops/nn_ops.py b/tensorflow/python/ops/nn_ops.py
index b3c0a22efc..a563e7c588 100644
--- a/tensorflow/python/ops/nn_ops.py
+++ b/tensorflow/python/ops/nn_ops.py
@@ -2253,6 +2253,12 @@ def nth_element(input, n, reverse=False, name=None):
return gen_nn_ops.nth_element(input, n, reverse=reverse, name=name)
+@deprecation.deprecated_arg_values(
+ None, "`NCHW` for data_format is deprecated, use `NCW` instead",
+ warn_once=True, data_format="NCHW")
+@deprecation.deprecated_arg_values(
+ None, "`NHWC` for data_format is deprecated, use `NWC` instead",
+ warn_once=True, data_format="NHWC")
def conv1d(value, filters, stride, padding,
use_cudnn_on_gpu=None, data_format=None,
name=None):
@@ -2260,9 +2266,9 @@ def conv1d(value, filters, stride, padding,
Given an input tensor of shape
[batch, in_width, in_channels]
- if data_format is "NHWC", or
+ if data_format is "NWC", or
[batch, in_channels, in_width]
- if data_format is "NCHW",
+ if data_format is "NCW",
and a filter / kernel tensor of shape
[filter_width, in_channels, out_channels], this op reshapes
the arguments to pass them to conv2d to perform the equivalent
@@ -2287,9 +2293,9 @@ def conv1d(value, filters, stride, padding,
the filter is moved right at each step.
padding: 'SAME' or 'VALID'
use_cudnn_on_gpu: An optional `bool`. Defaults to `True`.
- data_format: An optional `string` from `"NHWC", "NCHW"`. Defaults
- to `"NHWC"`, the data is stored in the order of
- [batch, in_width, in_channels]. The `"NCHW"` format stores
+ data_format: An optional `string` from `"NWC", "NCW"`. Defaults
+ to `"NWC"`, the data is stored in the order of
+ [batch, in_width, in_channels]. The `"NCW"` format stores
data as [batch, in_channels, in_width].
name: A name for the operation (optional).
@@ -2301,15 +2307,16 @@ def conv1d(value, filters, stride, padding,
"""
with ops.name_scope(name, "conv1d", [value, filters]) as name:
# Reshape the input tensor to [batch, 1, in_width, in_channels]
- if data_format is None or data_format == "NHWC":
+ if data_format is None or data_format == "NHWC" or data_format == "NWC":
data_format = "NHWC"
spatial_start_dim = 1
strides = [1, 1, stride, 1]
- elif data_format == "NCHW":
+ elif data_format == "NCHW" or data_format == "NCW":
+ data_format = "NCHW"
spatial_start_dim = 2
strides = [1, 1, 1, stride]
else:
- raise ValueError("data_format must be \"NHWC\" or \"NCHW\".")
+ raise ValueError("data_format must be \"NWC\" or \"NCW\".")
value = array_ops.expand_dims(value, spatial_start_dim)
filters = array_ops.expand_dims(filters, 0)
result = gen_nn_ops.conv2d(value, filters, strides, padding,
diff --git a/tensorflow/python/ops/variable_scope.py b/tensorflow/python/ops/variable_scope.py
index 4a23d96721..e46ff529de 100644
--- a/tensorflow/python/ops/variable_scope.py
+++ b/tensorflow/python/ops/variable_scope.py
@@ -1584,6 +1584,10 @@ class _pure_variable_scope(object): # pylint: disable=invalid-name
else self._name_or_scope)
self._reuse = (self._reuse
or self._old.reuse) # Re-using is inherited by sub-scopes.
+ if self._old_name_scope is None:
+ name_scope = self._name_or_scope
+ else:
+ name_scope = self._old_name_scope
variable_scope_object = VariableScope(
self._reuse,
name=self._new_name,
@@ -1594,7 +1598,7 @@ class _pure_variable_scope(object): # pylint: disable=invalid-name
dtype=self._old.dtype,
use_resource=self._old.use_resource,
custom_getter=self._old.custom_getter,
- name_scope=self._old_name_scope or self._name_or_scope,
+ name_scope=name_scope,
constraint=self._constraint)
if self._initializer is not None:
variable_scope_object.set_initializer(self._initializer)
@@ -1763,7 +1767,8 @@ class variable_scope(object): # pylint: disable=invalid-name
reuse=None,
dtype=None,
use_resource=None,
- constraint=None):
+ constraint=None,
+ auxiliary_name_scope=True):
"""Initialize the context manager.
Args:
@@ -1795,6 +1800,8 @@ class variable_scope(object): # pylint: disable=invalid-name
variable and return the Tensor for the projected value
(which must have the same shape). Constraints are not safe to
use when doing asynchronous distributed training.
+ auxiliary_name_scope: If `True`, we create an auxiliary name scope with
+ the scope. If `False`, we don't touch name scope.
Returns:
A scope that can be captured and reused.
@@ -1832,6 +1839,10 @@ class variable_scope(object): # pylint: disable=invalid-name
self._graph = ops._get_graph_from_inputs(self._values) # pylint: disable=protected-access
self._cached_pure_variable_scope = None
self._current_name_scope = None
+ if not isinstance(auxiliary_name_scope, bool):
+ raise TypeError("The auxiliary_name_scope must be `True` or `False`, "
+ "while get {}".format(auxiliary_name_scope))
+ self._auxiliary_name_scope = auxiliary_name_scope
def __enter__(self):
# If the default graph is building a function, then we should not replace it
@@ -1850,6 +1861,21 @@ class variable_scope(object): # pylint: disable=invalid-name
if self._current_name_scope is not None:
self._current_name_scope.__enter__()
return self._cached_pure_variable_scope.__enter__()
+
+ if self._auxiliary_name_scope:
+ # Create a new name scope later
+ current_name_scope = None
+ else:
+ # Reenter the current name scope
+ name_scope = ops.get_name_scope()
+ if name_scope:
+ # Hack to reenter
+ name_scope += "/"
+ current_name_scope = ops.name_scope(name_scope)
+ else:
+ # Root scope
+ current_name_scope = ops.name_scope(name_scope)
+
if self._name_or_scope is not None:
if not isinstance(self._name_or_scope,
(VariableScope,) + six.string_types):
@@ -1859,8 +1885,9 @@ class variable_scope(object): # pylint: disable=invalid-name
name_scope = self._name_or_scope
else:
name_scope = self._name_or_scope.name.split("/")[-1]
- if name_scope:
- self._current_name_scope = ops.name_scope(name_scope)
+ if name_scope or current_name_scope:
+ self._current_name_scope = current_name_scope or ops.name_scope(
+ name_scope)
current_name_scope_name = self._current_name_scope.__enter__()
if isinstance(self._name_or_scope, six.string_types):
old_name_scope = current_name_scope_name
@@ -1898,7 +1925,8 @@ class variable_scope(object): # pylint: disable=invalid-name
else: # Here name_or_scope is None. Using default name, but made unique.
if self._reuse:
raise ValueError("reuse=True cannot be used without a name_or_scope")
- self._current_name_scope = ops.name_scope(self._default_name)
+ self._current_name_scope = current_name_scope or ops.name_scope(
+ self._default_name)
current_name_scope_name = self._current_name_scope.__enter__()
unique_default_name = _get_unique_variable_scope(self._default_name)
self._cached_pure_variable_scope = _pure_variable_scope(
diff --git a/tensorflow/python/util/util.cc b/tensorflow/python/util/util.cc
index c3d7611ad4..a41fa7df25 100644
--- a/tensorflow/python/util/util.cc
+++ b/tensorflow/python/util/util.cc
@@ -29,7 +29,7 @@ bool WarnedThatSetIsNotSequence = false;
// Returns 1 if `o` is considered a sequence for the purposes of Flatten().
// Returns 0 otherwise.
-// Returns -1 if an error occured.
+// Returns -1 if an error occurred.
int IsSequenceHelper(PyObject* o) {
if (PyDict_Check(o)) return true;
if (PySet_Check(o) && !WarnedThatSetIsNotSequence) {
diff --git a/tensorflow/stream_executor/cuda/cuda_dnn.cc b/tensorflow/stream_executor/cuda/cuda_dnn.cc
index 6acd87c223..5519381d51 100644
--- a/tensorflow/stream_executor/cuda/cuda_dnn.cc
+++ b/tensorflow/stream_executor/cuda/cuda_dnn.cc
@@ -2677,7 +2677,7 @@ bool CudnnSupport::GetConvolveBackwardFilterAlgorithms(
// CUDNN_CONVOLUTION_BWD_FILTER_ALGO_WINOGRAD,
// clang-format on
};
-#if CUDNN_VERSION >= 5110
+#if CUDNN_VERSION >= 5100
if (CudnnEnvVar<WinogradNonfused>::IsEnabled() && with_winograd_nonfused) {
algo_types.push_back(CUDNN_CONVOLUTION_BWD_FILTER_ALGO_WINOGRAD_NONFUSED);
}
diff --git a/tensorflow/stream_executor/cuda/cuda_gpu_executor.cc b/tensorflow/stream_executor/cuda/cuda_gpu_executor.cc
index 878fa8d9ad..4bbd531e14 100644
--- a/tensorflow/stream_executor/cuda/cuda_gpu_executor.cc
+++ b/tensorflow/stream_executor/cuda/cuda_gpu_executor.cc
@@ -861,6 +861,9 @@ static int TryToReadNumaNode(const string &pci_bus_id, int device_ordinal) {
#elif defined(PLATFORM_WINDOWS)
// Windows support for NUMA is not currently implemented. Return node 0.
return 0;
+#elif defined(__aarch64__)
+ LOG(INFO) << "ARM64 does not support NUMA - returning NUMA node zero";
+ return 0;
#else
VLOG(2) << "trying to read NUMA node for device ordinal: " << device_ordinal;
static const int kUnknownNumaNode = -1;
diff --git a/tensorflow/stream_executor/dnn.h b/tensorflow/stream_executor/dnn.h
index 07314a0ff7..f4162b0962 100644
--- a/tensorflow/stream_executor/dnn.h
+++ b/tensorflow/stream_executor/dnn.h
@@ -2024,7 +2024,7 @@ class DnnSupport {
// output_h_desc: descriptor for the output "h" state.
// output_h_data: the memory region that stores the output "h" data.
// output_c_desc: descriptor for the output "c" state.
- // output_c_data: the memory region that stores the outptu "c" data. This
+ // output_c_data: the memory region that stores the output "c" data. This
// must be specified for LSTM models.
// is_training: whether this is used in training or inference. That decides
// whether respace_space data need to be produced.
@@ -2033,7 +2033,7 @@ class DnnSupport {
// retains the data and feed it to the backward pass.
// workspace_allocator: an allocator to create temporary workspace used in
// this kernel. The caller is responsible for retaining the memory long
- // enough for the lifespan of this operation, and recycles aftewards.
+ // enough for the lifespan of this operation, and recycles afterwards.
virtual bool DoRnnForward(Stream* stream, const dnn::RnnDescriptor& rnn_desc,
const dnn::RnnSequenceTensorDescriptor& input_desc,
const DeviceMemory<Eigen::half>& input_data,
@@ -2112,7 +2112,7 @@ class DnnSupport {
// output_h_desc: descriptor for the output "h" state.
// output_h_data: the memory region that stores the output "h" data.
// output_c_desc: descriptor for the output "c" state.
- // output_c_data: the memory region that stores the outptu "c" data. This
+ // output_c_data: the memory region that stores the output "c" data. This
// must be specified for LSTM models.
// output_backprop_data: the device memory region that contains the backprop
// to the output sequence.
diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl
index e51e20c282..b71328f847 100644
--- a/tensorflow/tensorflow.bzl
+++ b/tensorflow/tensorflow.bzl
@@ -19,6 +19,7 @@ load(
"//third_party/mkl:build_defs.bzl",
"if_mkl",
)
+
def register_extension_info(**kwargs):
pass
@@ -149,24 +150,27 @@ def if_darwin(a):
"//conditions:default": [],
})
-WIN_COPTS = [
- "/DLANG_CXX11",
- "/D__VERSION__=\\\"MSVC\\\"",
- "/DPLATFORM_WINDOWS",
- "/DTF_COMPILE_LIBRARY",
- "/DEIGEN_HAS_C99_MATH",
- "/DTENSORFLOW_USE_EIGEN_THREADPOOL",
- "/DEIGEN_AVOID_STL_ARRAY",
- "/Iexternal/gemmlowp",
- "/wd4018", # -Wno-sign-compare
- "/U_HAS_EXCEPTIONS",
- "/D_HAS_EXCEPTIONS=1",
- "/EHsc", # -fno-exceptions
- "/DNOGDI",
-]
+def get_win_copts(is_external=False):
+ WINDOWS_COPTS = [
+ "/D__VERSION__=\\\"MSVC\\\"",
+ "/DPLATFORM_WINDOWS",
+ "/DEIGEN_HAS_C99_MATH",
+ "/DTENSORFLOW_USE_EIGEN_THREADPOOL",
+ "/DEIGEN_AVOID_STL_ARRAY",
+ "/Iexternal/gemmlowp",
+ "/wd4018", # -Wno-sign-compare
+ "/U_HAS_EXCEPTIONS",
+ "/D_HAS_EXCEPTIONS=1",
+ "/EHsc", # -fno-exceptions
+ "/DNOGDI",
+ ]
+ if is_external:
+ return WINDOWS_COPTS + ["/UTF_COMPILE_LIBRARY"]
+ else:
+ return WINDOWS_COPTS + ["/DTF_COMPILE_LIBRARY"]
# LINT.IfChange
-def tf_copts(android_optimization_level_override="-O2"):
+def tf_copts(android_optimization_level_override="-O2", is_external=False):
# For compatibility reasons, android_optimization_level_override
# is currently only being set for Android.
# To clear this value, and allow the CROSSTOOL default
@@ -194,8 +198,8 @@ def tf_copts(android_optimization_level_override="-O2"):
+ select({
clean_dep("//tensorflow:android"): android_copts,
clean_dep("//tensorflow:darwin"): [],
- clean_dep("//tensorflow:windows"): WIN_COPTS,
- clean_dep("//tensorflow:windows_msvc"): WIN_COPTS,
+ 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"]
}))
@@ -211,7 +215,7 @@ def tf_opts_nortti_if_android():
# Given a list of "op_lib_names" (a list of files in the ops directory
# without their .cc extensions), generate a library for that file.
-def tf_gen_op_libs(op_lib_names, deps=None):
+def tf_gen_op_libs(op_lib_names, deps=None, is_external=True):
# Make library out of each op so it can also be used to generate wrappers
# for various languages.
if not deps:
@@ -219,7 +223,7 @@ def tf_gen_op_libs(op_lib_names, deps=None):
for n in op_lib_names:
native.cc_library(
name=n + "_op_lib",
- copts=tf_copts(),
+ copts=tf_copts(is_external=is_external),
srcs=["ops/" + n + ".cc"],
deps=deps + [clean_dep("//tensorflow/core:framework")],
visibility=["//visibility:public"],
@@ -292,9 +296,11 @@ def tf_cc_binary(name,
srcs=[],
deps=[],
linkopts=[],
+ copts=tf_copts(),
**kwargs):
native.cc_binary(
name=name,
+ copts=copts,
srcs=srcs + tf_binary_additional_srcs(),
deps=deps + if_mkl(
[
@@ -325,7 +331,7 @@ def tf_gen_op_wrapper_cc(name,
tf_cc_binary(
name=tool,
copts=tf_copts(),
- linkopts=["-lm"],
+ linkopts=if_not_windows(["-lm"]),
linkstatic=1, # Faster to link this one-time-use binary dynamically
deps=[op_gen] + deps)
@@ -496,7 +502,7 @@ def tf_gen_op_wrapper_py(name,
deps = [str(Label("//tensorflow/core:" + name + "_op_lib"))]
tf_cc_binary(
name=tool_name,
- linkopts=["-lm"] + cc_linkopts,
+ linkopts=if_not_windows(["-lm"]) + cc_linkopts,
copts=tf_copts(),
linkstatic=1, # Faster to link this one-time-use binary dynamically
deps=([
@@ -711,7 +717,7 @@ def tf_cuda_only_cc_test(name,
deps=deps + if_cuda([
clean_dep("//tensorflow/core:cuda"),
clean_dep("//tensorflow/core:gpu_lib")]),
- linkopts=["-lpthread", "-lm"] + linkopts + _rpath_linkopts(name),
+ linkopts=if_not_windows(["-lpthread", "-lm"]) + linkopts + _rpath_linkopts(name),
linkstatic=linkstatic or select({
# cc_tests with ".so"s in srcs incorrectly link on Darwin
# unless linkstatic=1.
@@ -849,7 +855,7 @@ register_extension_info(
label_regex_for_dep = "{extension_name}",
)
-def tf_cuda_library(deps=None, cuda_deps=None, copts=None, **kwargs):
+def tf_cuda_library(deps=None, cuda_deps=None, copts=tf_copts(), **kwargs):
"""Generate a cc_library with a conditional set of CUDA dependencies.
When the library is built with --config=cuda:
@@ -869,8 +875,6 @@ def tf_cuda_library(deps=None, cuda_deps=None, copts=None, **kwargs):
deps = []
if not cuda_deps:
cuda_deps = []
- if not copts:
- copts = []
native.cc_library(
deps=deps + if_cuda(cuda_deps + [
@@ -892,7 +896,8 @@ def tf_kernel_library(name,
hdrs=None,
deps=None,
alwayslink=1,
- copts=tf_copts(),
+ copts=None,
+ is_external=False,
**kwargs):
"""A rule to build a TensorFlow OpKernel.
@@ -921,7 +926,8 @@ def tf_kernel_library(name,
hdrs = []
if not deps:
deps = []
-
+ if not copts:
+ copts = tf_copts(is_external=is_external)
if prefix:
if native.glob([prefix + "*.cu.cc"], exclude=["*test*"]):
if not gpu_srcs:
@@ -1233,7 +1239,7 @@ def tf_custom_op_library(name, srcs=[], gpu_srcs=[], deps=[], linkopts=[]):
srcs=srcs,
deps=deps + if_cuda(cuda_deps),
data=[name + "_check_deps"],
- copts=tf_copts(),
+ copts=tf_copts(is_external=True),
linkopts=linkopts + select({
"//conditions:default": [
"-lm",
@@ -1577,9 +1583,10 @@ def tf_py_build_info_genrule():
def cc_library_with_android_deps(deps,
android_deps=[],
common_deps=[],
+ copts=tf_copts(),
**kwargs):
deps = if_not_android(deps) + if_android(android_deps) + common_deps
- native.cc_library(deps=deps, **kwargs)
+ native.cc_library(deps=deps, copts=copts, **kwargs)
register_extension_info(
extension_name = "cc_library_with_android_deps",
diff --git a/tensorflow/tools/api/golden/tensorflow.variable_scope.pbtxt b/tensorflow/tools/api/golden/tensorflow.variable_scope.pbtxt
index de1ad7e860..e62dec93e6 100644
--- a/tensorflow/tools/api/golden/tensorflow.variable_scope.pbtxt
+++ b/tensorflow/tools/api/golden/tensorflow.variable_scope.pbtxt
@@ -4,6 +4,6 @@ tf_class {
is_instance: "<type \'object\'>"
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\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\', \'None\'], "
+ 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/tests/api_compatibility_test.py b/tensorflow/tools/api/tests/api_compatibility_test.py
index 1fa4e85e02..afcbf50944 100644
--- a/tensorflow/tools/api/tests/api_compatibility_test.py
+++ b/tensorflow/tools/api/tests/api_compatibility_test.py
@@ -248,8 +248,8 @@ class ApiCompatibilityTest(test.TestCase):
logging.info('No differences found between API and golden.')
@unittest.skipUnless(
- sys.version_info.major == 2 and os.uname()[0] == 'Linux',
- 'API compabitility test goldens are generated using python2 on Linux.')
+ sys.version_info.major == 2,
+ 'API compabitility test goldens are generated using python2.')
def testAPIBackwardsCompatibility(self):
# Extract all API stuff.
visitor = python_object_to_proto_visitor.PythonObjectToProtoVisitor()
diff --git a/tensorflow/tools/ci_build/windows/bazel/bazel_test_lib.sh b/tensorflow/tools/ci_build/windows/bazel/bazel_test_lib.sh
index 8d50250c3a..0c9f3bb5b3 100644
--- a/tensorflow/tools/ci_build/windows/bazel/bazel_test_lib.sh
+++ b/tensorflow/tools/ci_build/windows/bazel/bazel_test_lib.sh
@@ -21,7 +21,6 @@ failing_cpu_cc_tests="\
//tensorflow/core:lib_core_status_test + \
//tensorflow/core:lib_monitoring_collection_registry_test + \
//tensorflow/core:lib_strings_numbers_test + \
- //tensorflow/core:lib_strings_str_util_test + \
//tensorflow/core/platform/hadoop:hadoop_file_system_test + \
//tensorflow/core:platform_file_system_test + \
//tensorflow/core:platform_logging_test + \
diff --git a/tensorflow/tools/git/gen_git_source.py b/tensorflow/tools/git/gen_git_source.py
index 0307d2a0eb..2e27487d2f 100755
--- a/tensorflow/tools/git/gen_git_source.py
+++ b/tensorflow/tools/git/gen_git_source.py
@@ -180,6 +180,13 @@ const int tf_cxx11_abi_flag() {
return 0;
#endif
}
+const int tf_monolithic_build() {
+#ifdef TENSORFLOW_MONOLITHIC_BUILD
+ return 1;
+#else
+ return 0;
+#endif
+}
""" % git_version
open(filename, "w").write(contents)
diff --git a/tensorflow/tools/git/gen_git_source.sh b/tensorflow/tools/git/gen_git_source.sh
index 788f9e6e57..db20bb00e8 100755
--- a/tensorflow/tools/git/gen_git_source.sh
+++ b/tensorflow/tools/git/gen_git_source.sh
@@ -36,5 +36,12 @@ const int tf_cxx11_abi_flag() {
return 0;
#endif
}
+const int tf_monolithic_build() {
+#ifdef TENSORFLOW_MONOLITHIC_BUILD
+ return 1;
+#else
+ return 0;
+#endif
+}
EOF
diff --git a/tensorflow/tools/graph_transforms/quantize_nodes.cc b/tensorflow/tools/graph_transforms/quantize_nodes.cc
index 97e8f77616..5ccd88cfa1 100644
--- a/tensorflow/tools/graph_transforms/quantize_nodes.cc
+++ b/tensorflow/tools/graph_transforms/quantize_nodes.cc
@@ -759,7 +759,7 @@ Status QuantizeNodes(const GraphDef& input_graph_def,
NodeDef reshape_dims;
reshape_dims.set_op("Const");
reshape_dims.set_name(unique_input_name + "/reshape_dims");
- AddNodeInput("^" + input_name, &reshape_dims);
+ AddNodeInput("^" + NodeNameFromInput(input_name), &reshape_dims);
SetNodeAttr("dtype", DT_INT32, &reshape_dims);
Tensor reshape_dims_tensor(DT_INT32, {1});
reshape_dims_tensor.flat<int32>()(0) = -1;
@@ -769,7 +769,7 @@ Status QuantizeNodes(const GraphDef& input_graph_def,
NodeDef reduction_dims;
reduction_dims.set_op("Const");
reduction_dims.set_name(unique_input_name + "/reduction_dims");
- AddNodeInput("^" + input_name, &reduction_dims);
+ AddNodeInput("^" + NodeNameFromInput(input_name), &reduction_dims);
SetNodeAttr("dtype", DT_INT32, &reduction_dims);
Tensor reduction_dims_tensor(DT_INT32, {1});
reduction_dims_tensor.flat<int32>()(0) = 0;
diff --git a/tensorflow/tools/pip_package/setup.py b/tensorflow/tools/pip_package/setup.py
index 1b2e007f9d..7da688ff0d 100644
--- a/tensorflow/tools/pip_package/setup.py
+++ b/tensorflow/tools/pip_package/setup.py
@@ -177,6 +177,9 @@ def find_files(pattern, root):
matches = ['../' + x for x in find_files('*', 'external') if '.py' not in x]
matches += ['../' + x for x in find_files('*', '_solib_k8') if '.py' not in x]
+matches += [
+ '../' + x for x in find_files('*', '_solib_local') if '.py' not in x
+]
if os.name == 'nt':
EXTENSION_NAME = 'python/_pywrap_tensorflow_internal.pyd'
diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl
index 846b9bc645..6a496f53f0 100644
--- a/tensorflow/workspace.bzl
+++ b/tensorflow/workspace.bzl
@@ -59,11 +59,11 @@ def tf_workspace(path_prefix="", tf_repo_name=""):
mkl_repository(
name = "mkl",
urls = [
- "https://mirror.bazel.build/github.com/01org/mkl-dnn/releases/download/v0.9/mklml_lnx_2018.0.20170720.tgz",
- "https://github.com/01org/mkl-dnn/releases/download/v0.9/mklml_lnx_2018.0.20170720.tgz",
+ "https://mirror.bazel.build/github.com/01org/mkl-dnn/releases/download/v0.11/mklml_lnx_2018.0.1.20171007.tgz",
+ "https://github.com/01org/mkl-dnn/releases/download/v0.11/mklml_lnx_2018.0.1.20171007.tgz",
],
- sha256 = "57ba56c4c243f403ff78f417ff854ef50b9eddf4a610a917b7c95e7fa8553a4b",
- strip_prefix = "mklml_lnx_2018.0.20170720",
+ sha256 = "6b07cb7e5451db67c2e31e785ae458b18f7f363c60a61685488f69e9ae7199d4",
+ strip_prefix = "mklml_lnx_2018.0.1.20171007",
build_file = str(Label("//third_party/mkl:mkl.BUILD")),
)
@@ -85,11 +85,11 @@ def tf_workspace(path_prefix="", tf_repo_name=""):
tf_http_archive(
name = "com_google_absl",
urls = [
- "https://mirror.bazel.build/github.com/abseil/abseil-cpp/archive/cc4bed2d74f7c8717e31f9579214ab52a9c9c610.tar.gz",
- "https://github.com/abseil/abseil-cpp/archive/cc4bed2d74f7c8717e31f9579214ab52a9c9c610.tar.gz",
+ "https://mirror.bazel.build/github.com/abseil/abseil-cpp/archive/720c017e30339fd1786ce4aac68bc8559736e53f.tar.gz",
+ "https://github.com/abseil/abseil-cpp/archive/720c017e30339fd1786ce4aac68bc8559736e53f.tar.gz",
],
- sha256 = "f1a7349f88d2846210c42e2f7271dabeee404c2a3b4198e34a797993e3569b03",
- strip_prefix = "abseil-cpp-cc4bed2d74f7c8717e31f9579214ab52a9c9c610",
+ sha256 = "5996380e3e8b981f55d1c8d58e709c00dbb4806ba367be75d0925a68cc2f6478",
+ strip_prefix = "abseil-cpp-720c017e30339fd1786ce4aac68bc8559736e53f",
)
tf_http_archive(
diff --git a/third_party/eigen3/unsupported/Eigen/CXX11/src/NeuralNetworks/Patch3d.h b/third_party/eigen3/unsupported/Eigen/CXX11/src/NeuralNetworks/Patch3d.h
index 89190eb1af..2864f83299 100644
--- a/third_party/eigen3/unsupported/Eigen/CXX11/src/NeuralNetworks/Patch3d.h
+++ b/third_party/eigen3/unsupported/Eigen/CXX11/src/NeuralNetworks/Patch3d.h
@@ -151,7 +151,7 @@ Extract3DPatches(
// TODO(mjanusz): Consider getting rid of pad(), and stride() and extend
// extract_patches to take additional parameters for padding/striding,
- // similarly to etract_image_patches.
+ // similarly to extract_image_patches.
return input.pad(paddings, padding_value).extract_patches(patch_dims).reshape(pre_stride_dims).stride(strides);
}
diff --git a/third_party/flatbuffers/flatbuffers.BUILD b/third_party/flatbuffers/flatbuffers.BUILD
index 0a76adcf91..f6b8e6ddb0 100644
--- a/third_party/flatbuffers/flatbuffers.BUILD
+++ b/third_party/flatbuffers/flatbuffers.BUILD
@@ -4,6 +4,12 @@ package(
licenses(["notice"]) # Apache 2.0
+config_setting(
+ name = "freebsd",
+ values = {"cpu": "freebsd"},
+ visibility = ["//visibility:public"],
+)
+
FLATBUFFERS_COPTS = [
"-fexceptions",
] + select({
@@ -107,10 +113,15 @@ cc_binary(
"grpc/",
"include/",
],
- linkopts = [
- "-lm",
- "-ldl",
- ],
+ linkopts = select({
+ ":freebsd": [
+ "-lm",
+ ],
+ "//conditions:default": [
+ "-lm",
+ "-ldl",
+ ],
+ }),
deps = [
":flatc_library",
],