aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Shanqing Cai <cais@google.com>2017-07-10 19:22:04 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-07-10 19:26:59 -0700
commit90d6421c5e0898fb840197d9533c2f8ba1a7c651 (patch)
tree445d68f0fa98d2db739a16004f7cb605bba3efb8
parentaa239529c47c09599d1085791fc849f03efbddfe (diff)
Merge changes from github.
END_PUBLIC --- Commit d0f53f77f authored by Penghao Cen<scorpiocph@gmail.com> Committed by Shanqing Cai<cais@google.com>: Minor fix typo (#11323) --- Commit 02fcf564e authored by Chris Song<sjhshy@gmail.com> Committed by Chris Song<sjhshy@gmail.com>: Fix misspells. --- Commit 764c9b6b4 authored by Louis Tiao<ltiao@users.noreply.github.com> Committed by GitHub<noreply@github.com>: Fixed typo in docstring --- Commit f8cd1283e authored by Shanqing Cai<cais@google.com> Committed by Shanqing Cai<cais@google.com>: Chaser --- Commit 01383b946 authored by Shanqing Cai<cais@google.com> Committed by Shanqing Cai<cais@google.com>: Adapt TensorFlowTestCase.setUp() to new reset_default_graph() semantics Avoid calling reset_default_graph() directly to prevent exceptions in cases where test methods error out from within nested graph contexts, which can leave _default_graph_stack non-empty in certain Python versions. --- Commit 0ffc37890 authored by Amit Patankar<amitpatankar@google.com> Committed by Amit Patankar<amitpatankar@google.com>: Removing second declaration of functions. --- Commit f9c9cacb0 authored by A. Unique TensorFlower<gardener@tensorflow.org> Committed by TensorFlower Gardener<gardener@tensorflow.org>: Refactor ElementalIrEmitter's slice index finding code into IrArray::Index::SourceIndexOfSlice(). PiperOrigin-RevId: 161140653 --- Commit ba297aec9 authored by A. Unique TensorFlower<gardener@tensorflow.org> Committed by TensorFlower Gardener<gardener@tensorflow.org>: Update ops-related pbtxt files. PiperOrigin-RevId: 161138258 --- Commit 68d666737 authored by Alexandre Passos<apassos@google.com> Committed by TensorFlower Gardener<gardener@tensorflow.org>: Fixes a reentrant lock issue with tensors using ndarray memory which uses tensor memory. PiperOrigin-RevId: 161137788 --- Commit a2ee8bca3 authored by A. Unique TensorFlower<gardener@tensorflow.org> Committed by TensorFlower Gardener<gardener@tensorflow.org>: Add support for int8 x int8 -> int32 matrix multiplication via cublasGemmEx to stream_executor. PiperOrigin-RevId: 161137741 --- Commit 755fa7b50 authored by Mark Daoust<markdaoust@google.com> Committed by TensorFlower Gardener<gardener@tensorflow.org>: Block generate_test, and docs generating from running in python3. - Doc generation is currently unsupported in python3 - These both end in errors in python 3.5.1+ PiperOrigin-RevId: 161137467 --- Commit 97cbcac45 authored by Peter Hawkins<phawkins@google.com> Committed by TensorFlower Gardener<gardener@tensorflow.org>: [TF:XLA] Fix failure in functionalize_control_flow rewrite for Enter nodes that are unused. Make sure we ignore such nodes without producing an error. PiperOrigin-RevId: 161136545 --- Commit dabcb60bc authored by A. Unique TensorFlower<gardener@tensorflow.org> Committed by TensorFlower Gardener<gardener@tensorflow.org>: [XLA] Add reasonable error messages to Builder::Build for bad parameter numbers. PiperOrigin-RevId: 161136262 --- Commit 0cbd249e8 authored by A. Unique TensorFlower<gardener@tensorflow.org> Committed by TensorFlower Gardener<gardener@tensorflow.org>: Add complex tensors support to `matrix_determinant`. PiperOrigin-RevId: 161132422 --- Commit 335f1f14d authored by A. Unique TensorFlower<gardener@tensorflow.org> Committed by TensorFlower Gardener<gardener@tensorflow.org>: Extend static shape inference for SparseTensors with dense_shapes constructed using slicing. PiperOrigin-RevId: 161132391 --- Commit 53604916e authored by Jianwei Xie<xiejw@google.com> Committed by TensorFlower Gardener<gardener@tensorflow.org>: Fixed the missing labels test in TPUEstimator. PiperOrigin-RevId: 161131282 --- Commit 9f57dc8dd authored by Bruno Rosa<bruno.rosa@eldorado.org.br> Committed by Bruno Rosa<bruno.rosa@eldorado.org.br>: Use mcpu instead of march for ppc64le march is not support by gcc on ppc64le --- Commit 7d5c74a9c authored by Skye Wanderman-Milne<skyewm@google.com> Committed by TensorFlower Gardener<gardener@tensorflow.org>: Move duplicate detection logic from Graph to FunctionLibraryDefinition Turns out this is more useful, since there are many function libraries that don't belong to a graph. This will be used in a future change. Note that this maintains the current behavior of Graph. In addition, updates FunctionDefsEqual() to handle unset attr entries (I ran into this when using this in said future change). PiperOrigin-RevId: 161126628 --- Commit 2caec3af1 authored by Shanqing Cai<cais@google.com> Committed by TensorFlower Gardener<gardener@tensorflow.org>: Disable more timeseries py tests failing in OSS PIP GPU builds PiperOrigin-RevId: 161124799 --- Commit 0b5cce367 authored by Eugene Brevdo<ebrevdo@google.com> Committed by TensorFlower Gardener<gardener@tensorflow.org>: Get TopK op working on GPU again. Extend using cub's radix sort. 1. Undo rollback of Andreas Kirsch's initial implementation. 2. Use cub segmented radix sort if Andreas' heap-based impl for large k and small num_cols (thresholds of k=100, n=1000 determined empirically). 3. Use cub segmented radix sort if k == num_cols (this case is always faster). 4. Added benchmarks. Benchmarks show that the GPU implementation is up to 3x slower for small k but can be 10x faster for large num_cols and k. Benchmarks: Benchmark: m_128_n_10_k_5_use_gpu_False wall_time: 0.000166 s Throughput: 0.0077 GB/s Benchmark: m_128_n_10_k_5_use_gpu_True wall_time: 0.000796 s Throughput: 0.00161 GB/s Benchmark: m_128_n_10_k_9_use_gpu_False wall_time: 0.00017 s Throughput: 0.00751 GB/s Benchmark: m_128_n_10_k_9_use_gpu_True wall_time: 0.000796 s Throughput: 0.00161 GB/s Benchmark: m_128_n_10_k_10_use_gpu_False wall_time: 0.00017 s Throughput: 0.00753 GB/s Benchmark: m_128_n_10_k_10_use_gpu_True wall_time: 0.000775 s Throughput: 0.00165 GB/s Benchmark: m_128_n_100_k_1_use_gpu_False wall_time: 0.000155 s Throughput: 0.0826 GB/s Benchmark: m_128_n_100_k_1_use_gpu_True wall_time: 0.000796 s Throughput: 0.0161 GB/s Benchmark: m_128_n_100_k_50_use_gpu_False wall_time: 0.000247 s Throughput: 0.0519 GB/s Benchmark: m_128_n_100_k_50_use_gpu_True wall_time: 0.0008 s Throughput: 0.016 GB/s Benchmark: m_128_n_100_k_99_use_gpu_False wall_time: 0.000261 s Throughput: 0.049 GB/s Benchmark: m_128_n_100_k_99_use_gpu_True wall_time: 0.000794 s Throughput: 0.0161 GB/s Benchmark: m_128_n_100_k_100_use_gpu_False wall_time: 0.000239 s Throughput: 0.0536 GB/s Benchmark: m_128_n_100_k_100_use_gpu_True wall_time: 0.000777 s Throughput: 0.0165 GB/s Benchmark: m_128_n_1000_k_1_use_gpu_False wall_time: 0.000324 s Throughput: 0.395 GB/s Benchmark: m_128_n_1000_k_1_use_gpu_True wall_time: 0.000916 s Throughput: 0.14 GB/s Benchmark: m_128_n_1000_k_10_use_gpu_False wall_time: 0.00042 s Throughput: 0.305 GB/s Benchmark: m_128_n_1000_k_10_use_gpu_True wall_time: 0.000902 s Throughput: 0.142 GB/s Benchmark: m_128_n_1000_k_500_use_gpu_False wall_time: 0.0011 s Throughput: 0.116 GB/s Benchmark: m_128_n_1000_k_500_use_gpu_True wall_time: 0.00097 s Throughput: 0.132 GB/s Benchmark: m_128_n_1000_k_990_use_gpu_False wall_time: 0.00133 s Throughput: 0.0962 GB/s Benchmark: m_128_n_1000_k_990_use_gpu_True wall_time: 0.000993 s Throughput: 0.129 GB/s Benchmark: m_128_n_1000_k_1000_use_gpu_False wall_time: 0.00102 s Throughput: 0.126 GB/s Benchmark: m_128_n_1000_k_1000_use_gpu_True wall_time: 0.000964 s Throughput: 0.133 GB/s Benchmark: m_128_n_10000_k_10_use_gpu_False wall_time: 0.002 s Throughput: 0.64 GB/s Benchmark: m_128_n_10000_k_10_use_gpu_True wall_time: 0.00288 s Throughput: 0.445 GB/s Benchmark: m_128_n_10000_k_100_use_gpu_False wall_time: 0.00233 s Throughput: 0.549 GB/s Benchmark: m_128_n_10000_k_100_use_gpu_True wall_time: 0.00325 s Throughput: 0.394 GB/s Benchmark: m_128_n_10000_k_5000_use_gpu_False wall_time: 0.0127 s Throughput: 0.101 GB/s Benchmark: m_128_n_10000_k_5000_use_gpu_True wall_time: 0.00381 s Throughput: 0.336 GB/s Benchmark: m_128_n_10000_k_9900_use_gpu_False wall_time: 0.015 s Throughput: 0.0853 GB/s Benchmark: m_128_n_10000_k_9900_use_gpu_True wall_time: 0.00438 s Throughput: 0.292 GB/s Benchmark: m_128_n_10000_k_10000_use_gpu_False wall_time: 0.0104 s Throughput: 0.123 GB/s Benchmark: m_128_n_10000_k_10000_use_gpu_True wall_time: 0.00427 s Throughput: 0.3 GB/s Benchmark: m_128_n_100000_k_100_use_gpu_False wall_time: 0.0148 s Throughput: 0.865 GB/s Benchmark: m_128_n_100000_k_100_use_gpu_True wall_time: 0.0262 s Throughput: 0.488 GB/s Benchmark: m_128_n_100000_k_1000_use_gpu_False wall_time: 0.0201 s Throughput: 0.636 GB/s Benchmark: m_128_n_100000_k_1000_use_gpu_True wall_time: 0.0263 s Throughput: 0.486 GB/s Benchmark: m_128_n_100000_k_50000_use_gpu_False wall_time: 0.214 s Throughput: 0.0599 GB/s Benchmark: m_128_n_100000_k_50000_use_gpu_True wall_time: 0.0322 s Throughput: 0.398 GB/s Benchmark: m_128_n_100000_k_99000_use_gpu_False wall_time: 0.262 s Throughput: 0.0489 GB/s Benchmark: m_128_n_100000_k_99000_use_gpu_True wall_time: 0.0377 s Throughput: 0.34 GB/s Benchmark: m_128_n_100000_k_100000_use_gpu_False wall_time: 0.118 s Throughput: 0.108 GB/s Benchmark: m_128_n_100000_k_100000_use_gpu_True wall_time: 0.0365 s Throughput: 0.351 GB/s END_PUBLIC BEGIN_PUBLIC BEGIN_PUBLIC Automated g4 rollback of changelist 157169178 PiperOrigin-RevId: 161476569
-rw-r--r--ISSUE_TEMPLATE.md1
-rw-r--r--README.md16
-rw-r--r--RELEASE.md6
-rwxr-xr-xconfigure11
-rw-r--r--tensorflow/c/c_api_test.cc2
-rw-r--r--tensorflow/cc/framework/gradients.cc6
-rw-r--r--tensorflow/cc/gradients/math_grad.cc40
-rw-r--r--tensorflow/cc/gradients/math_grad_test.cc82
-rw-r--r--tensorflow/compiler/tf2xla/functionalize_control_flow.cc2
-rw-r--r--tensorflow/compiler/xla/service/cpu/cpu_parallelization_preparation.h2
-rw-r--r--tensorflow/compiler/xla/service/cpu/infeed_manager.h1
-rw-r--r--tensorflow/compiler/xla/service/cpu/parallel_cpu_executable.cc2
-rw-r--r--tensorflow/compiler/xla/service/cpu/shape_partition.cc2
-rw-r--r--tensorflow/compiler/xla/service/cpu/shape_partition.h2
-rw-r--r--tensorflow/compiler/xla/service/hlo_alias_analysis_test.cc2
-rw-r--r--tensorflow/compiler/xla/tests/BUILD2
-rw-r--r--tensorflow/compiler/xla/tests/build_defs.bzl8
-rw-r--r--tensorflow/compiler/xla/tests/plugin.bzl32
-rw-r--r--tensorflow/contrib/batching/kernels/batch_kernels.cc6
-rw-r--r--tensorflow/contrib/boosted_trees/lib/learner/stochastic/handlers/categorical-feature-column-handler.cc2
-rw-r--r--tensorflow/contrib/boosted_trees/lib/learner/stochastic/handlers/dense-quantized-feature-column-handler.cc2
-rw-r--r--tensorflow/contrib/boosted_trees/lib/learner/stochastic/handlers/sparse-quantized-feature-column-handler.cc6
-rw-r--r--tensorflow/contrib/boosted_trees/python/kernel_tests/prediction_ops_test.py2
-rw-r--r--tensorflow/contrib/cmake/external/cub.cmake3
-rw-r--r--tensorflow/contrib/cmake/tf_core_kernels.cmake4
-rw-r--r--tensorflow/contrib/cmake/tf_tests.cmake5
-rw-r--r--tensorflow/contrib/distributions/python/ops/binomial.py2
-rw-r--r--tensorflow/contrib/distributions/python/ops/vector_student_t.py2
-rw-r--r--tensorflow/contrib/factorization/python/ops/factorization_ops.py2
-rw-r--r--tensorflow/contrib/image/kernels/image_ops.cc12
-rw-r--r--tensorflow/contrib/keras/python/keras/backend.py4
-rw-r--r--tensorflow/contrib/keras/python/keras/layers/convolutional.py2
-rw-r--r--tensorflow/contrib/keras/python/keras/testing_utils.py2
-rw-r--r--tensorflow/contrib/layers/kernels/sparse_feature_cross_kernel.cc6
-rw-r--r--tensorflow/contrib/layers/python/layers/embedding_ops.py2
-rw-r--r--tensorflow/contrib/layers/python/layers/feature_column.py4
-rw-r--r--tensorflow/contrib/layers/python/layers/layers.py2
-rw-r--r--tensorflow/contrib/layers/python/layers/layers_test.py4
-rw-r--r--tensorflow/contrib/learn/python/learn/experiment.py2
-rw-r--r--tensorflow/contrib/makefile/create_ios_frameworks.sh2
-rw-r--r--tensorflow/contrib/seq2seq/python/ops/attention_wrapper.py2
-rw-r--r--tensorflow/contrib/slim/README.md2
-rw-r--r--tensorflow/contrib/tensor_forest/client/random_forest.py2
-rw-r--r--tensorflow/contrib/tensor_forest/kernels/v4/grow_stats.h2
-rw-r--r--tensorflow/contrib/timeseries/python/timeseries/math_utils.py4
-rw-r--r--tensorflow/contrib/timeseries/python/timeseries/state_management.py4
-rw-r--r--tensorflow/contrib/timeseries/python/timeseries/state_space_models/filtering_postprocessor.py2
-rw-r--r--tensorflow/contrib/timeseries/python/timeseries/state_space_models/structural_ensemble.py2
-rw-r--r--tensorflow/contrib/tpu/python/tpu/tpu_estimator.py2
-rw-r--r--tensorflow/contrib/tpu/python/tpu/tpu_feed.py2
-rw-r--r--tensorflow/contrib/training/python/training/bucket_ops.py2
-rw-r--r--tensorflow/contrib/training/python/training/evaluation_test.py4
-rw-r--r--tensorflow/contrib/verbs/rdma.cc16
-rw-r--r--tensorflow/core/BUILD4
-rw-r--r--tensorflow/core/framework/op.cc7
-rw-r--r--tensorflow/core/framework/op_gen_lib.cc2
-rw-r--r--tensorflow/core/framework/op_kernel.h2
-rw-r--r--tensorflow/core/framework/queue_interface.h3
-rw-r--r--tensorflow/core/graph/graph.cc2
-rw-r--r--tensorflow/core/grappler/clusters/single_machine.cc2
-rw-r--r--tensorflow/core/grappler/costs/graph_properties.cc4
-rw-r--r--tensorflow/core/grappler/costs/virtual_scheduler.cc2
-rw-r--r--tensorflow/core/grappler/optimizers/constant_folding.cc2
-rw-r--r--tensorflow/core/kernels/BUILD13
-rw-r--r--tensorflow/core/kernels/barrier_ops.cc2
-rw-r--r--tensorflow/core/kernels/cast_op_impl.h40
-rw-r--r--tensorflow/core/kernels/cast_op_impl_bool.cc5
-rw-r--r--tensorflow/core/kernels/cast_op_impl_double.cc5
-rw-r--r--tensorflow/core/kernels/cast_op_impl_float.cc5
-rw-r--r--tensorflow/core/kernels/cast_op_impl_int16.cc9
-rw-r--r--tensorflow/core/kernels/cast_op_impl_int32.cc4
-rw-r--r--tensorflow/core/kernels/cast_op_impl_int64.cc4
-rw-r--r--tensorflow/core/kernels/cast_op_impl_int8.cc9
-rw-r--r--tensorflow/core/kernels/cast_op_impl_uint16.cc9
-rw-r--r--tensorflow/core/kernels/cast_op_impl_uint8.cc9
-rw-r--r--tensorflow/core/kernels/cwise_op_abs.cc20
-rw-r--r--tensorflow/core/kernels/cwise_op_acos.cc16
-rw-r--r--tensorflow/core/kernels/cwise_op_acosh.cc38
-rw-r--r--tensorflow/core/kernels/cwise_op_add_1.cc31
-rw-r--r--tensorflow/core/kernels/cwise_op_asin.cc16
-rw-r--r--tensorflow/core/kernels/cwise_op_asinh.cc38
-rw-r--r--tensorflow/core/kernels/cwise_op_atan.cc16
-rw-r--r--tensorflow/core/kernels/cwise_op_atanh.cc38
-rw-r--r--tensorflow/core/kernels/cwise_op_ceil.cc16
-rw-r--r--tensorflow/core/kernels/cwise_op_cos.cc16
-rw-r--r--tensorflow/core/kernels/cwise_op_div.cc37
-rw-r--r--tensorflow/core/kernels/cwise_op_equal_to_1.cc4
-rw-r--r--tensorflow/core/kernels/cwise_op_exp.cc16
-rw-r--r--tensorflow/core/kernels/cwise_op_expm1.cc2
-rw-r--r--tensorflow/core/kernels/cwise_op_floor.cc15
-rw-r--r--tensorflow/core/kernels/cwise_op_gpu_acosh.cu.cc27
-rw-r--r--tensorflow/core/kernels/cwise_op_gpu_asinh.cu.cc27
-rw-r--r--tensorflow/core/kernels/cwise_op_gpu_atanh.cu.cc27
-rw-r--r--tensorflow/core/kernels/cwise_op_greater.cc6
-rw-r--r--tensorflow/core/kernels/cwise_op_greater_equal.cc2
-rw-r--r--tensorflow/core/kernels/cwise_op_isfinite.cc16
-rw-r--r--tensorflow/core/kernels/cwise_op_isinf.cc16
-rw-r--r--tensorflow/core/kernels/cwise_op_isnan.cc16
-rw-r--r--tensorflow/core/kernels/cwise_op_less.cc1
-rw-r--r--tensorflow/core/kernels/cwise_op_less_equal.cc5
-rw-r--r--tensorflow/core/kernels/cwise_op_log.cc16
-rw-r--r--tensorflow/core/kernels/cwise_op_log1p.cc16
-rw-r--r--tensorflow/core/kernels/cwise_op_maximum.cc7
-rw-r--r--tensorflow/core/kernels/cwise_op_minimum.cc3
-rw-r--r--tensorflow/core/kernels/cwise_op_mul_1.cc28
-rw-r--r--tensorflow/core/kernels/cwise_op_neg.cc17
-rw-r--r--tensorflow/core/kernels/cwise_op_pow.cc15
-rw-r--r--tensorflow/core/kernels/cwise_op_round.cc3
-rw-r--r--tensorflow/core/kernels/cwise_op_rsqrt.cc19
-rw-r--r--tensorflow/core/kernels/cwise_op_select.cc2
-rw-r--r--tensorflow/core/kernels/cwise_op_sign.cc5
-rw-r--r--tensorflow/core/kernels/cwise_op_sin.cc16
-rw-r--r--tensorflow/core/kernels/cwise_op_sqrt.cc20
-rw-r--r--tensorflow/core/kernels/cwise_op_square.cc22
-rw-r--r--tensorflow/core/kernels/cwise_op_sub.cc31
-rw-r--r--tensorflow/core/kernels/cwise_op_tan.cc16
-rw-r--r--tensorflow/core/kernels/cwise_op_tanh.cc16
-rw-r--r--tensorflow/core/kernels/cwise_ops.h42
-rw-r--r--tensorflow/core/kernels/fixed_length_record_reader_op.cc132
-rw-r--r--tensorflow/core/kernels/fused_batch_norm_op.cc2
-rw-r--r--tensorflow/core/kernels/hexagon/hexagon_ops_definitions.h2
-rw-r--r--tensorflow/core/kernels/map_stage_op.cc15
-rw-r--r--tensorflow/core/kernels/ops_util.h14
-rw-r--r--tensorflow/core/kernels/parameterized_truncated_normal_op_gpu.cu.cc2
-rw-r--r--tensorflow/core/kernels/queue_base.h2
-rw-r--r--tensorflow/core/kernels/queue_ops.cc21
-rw-r--r--tensorflow/core/kernels/remote_fused_graph_execute_utils.cc14
-rw-r--r--tensorflow/core/kernels/remote_fused_graph_rewriter_transform.cc6
-rw-r--r--tensorflow/core/kernels/sample_distorted_bounding_box_op.cc53
-rw-r--r--tensorflow/core/kernels/sparse_slice_op.cc104
-rw-r--r--tensorflow/core/kernels/tile_functor.h15
-rw-r--r--tensorflow/core/kernels/tile_functor_cpu.cc1
-rw-r--r--tensorflow/core/kernels/tile_functor_gpu.cu.cc1
-rw-r--r--tensorflow/core/kernels/transpose_functor.h24
-rw-r--r--tensorflow/core/kernels/transpose_functor_cpu.cc51
-rw-r--r--tensorflow/core/kernels/transpose_functor_gpu.cu.cc25
-rw-r--r--tensorflow/core/lib/gtl/array_slice.h2
-rw-r--r--tensorflow/core/lib/gtl/flatrep.h2
-rw-r--r--tensorflow/core/ops/data_flow_ops.cc26
-rw-r--r--tensorflow/core/ops/image_ops.cc104
-rw-r--r--tensorflow/core/ops/io_ops.cc3
-rw-r--r--tensorflow/core/ops/math_grad.cc36
-rw-r--r--tensorflow/core/ops/math_grad_test.cc38
-rw-r--r--tensorflow/core/ops/math_ops.cc12
-rw-r--r--tensorflow/core/ops/ops.pbtxt99
-rw-r--r--tensorflow/core/ops/sparse_ops.cc66
-rw-r--r--tensorflow/core/platform/default/build_config.bzl5
-rw-r--r--tensorflow/core/platform/profile_utils/cpu_utils.cc13
-rw-r--r--tensorflow/core/platform/profile_utils/cpu_utils.h6
-rw-r--r--tensorflow/core/platform/profile_utils/cpu_utils_test.cc12
-rw-r--r--tensorflow/core/profiler/internal/BUILD5
-rw-r--r--tensorflow/core/profiler/internal/tfprof_timeline.cc2
-rw-r--r--tensorflow/core/protobuf/worker.proto2
-rw-r--r--tensorflow/core/public/version.h2
-rw-r--r--tensorflow/core/util/memmapped_file_system_test.cc2
-rw-r--r--tensorflow/core/util/sparse/sparse_tensor.h90
-rw-r--r--tensorflow/core/util/sparse/sparse_tensor_test.cc46
-rw-r--r--tensorflow/core/util/tensor_bundle/BUILD3
-rw-r--r--tensorflow/docs_src/api_guides/python/math_ops.md3
-rw-r--r--tensorflow/docs_src/community/documentation.md2
-rw-r--r--tensorflow/docs_src/community/welcome.md4
-rw-r--r--tensorflow/docs_src/get_started/get_started.md23
-rw-r--r--tensorflow/docs_src/get_started/mnist/beginners.md10
-rw-r--r--tensorflow/docs_src/install/install_c.md4
-rw-r--r--tensorflow/docs_src/install/install_go.md2
-rw-r--r--tensorflow/docs_src/install/install_java.md18
-rw-r--r--tensorflow/docs_src/install/install_linux.md26
-rw-r--r--tensorflow/docs_src/install/install_mac.md14
-rw-r--r--tensorflow/docs_src/install/install_sources.md4
-rw-r--r--tensorflow/docs_src/install/install_windows.md4
-rw-r--r--tensorflow/docs_src/programmers_guide/embedding.md4
-rw-r--r--tensorflow/docs_src/programmers_guide/threading_and_queues.md3
-rw-r--r--tensorflow/docs_src/programmers_guide/variables.md4
-rw-r--r--tensorflow/docs_src/programmers_guide/version_compat.md2
-rw-r--r--tensorflow/docs_src/tutorials/deep_cnn.md2
-rw-r--r--tensorflow/docs_src/tutorials/seq2seq.md2
-rw-r--r--tensorflow/examples/ios/README.md2
-rw-r--r--tensorflow/go/op/wrappers.go45
-rw-r--r--tensorflow/java/src/main/java/org/tensorflow/Input.java2
-rw-r--r--tensorflow/java/src/main/java/org/tensorflow/Operation.java2
-rw-r--r--tensorflow/java/src/main/java/org/tensorflow/OperationBuilder.java31
-rw-r--r--tensorflow/java/src/main/java/org/tensorflow/Session.java2
-rw-r--r--tensorflow/java/src/main/java/org/tensorflow/Shape.java2
-rw-r--r--tensorflow/java/src/main/native/operation_builder_jni.cc27
-rw-r--r--tensorflow/java/src/main/native/operation_builder_jni.h8
-rw-r--r--tensorflow/python/BUILD4
-rw-r--r--tensorflow/python/client/tf_session_helper.cc4
-rw-r--r--tensorflow/python/estimator/canned/linear_testing_utils.py2
-rw-r--r--tensorflow/python/framework/ops.py9
-rw-r--r--tensorflow/python/framework/ops_test.py6
-rw-r--r--tensorflow/python/framework/tensor_shape.py2
-rw-r--r--tensorflow/python/framework/test_util.py7
-rw-r--r--tensorflow/python/kernel_tests/BUILD12
-rw-r--r--tensorflow/python/kernel_tests/basic_gpu_test.py4
-rw-r--r--tensorflow/python/kernel_tests/cast_op_test.py14
-rw-r--r--tensorflow/python/kernel_tests/cwise_ops_test.py20
-rw-r--r--tensorflow/python/kernel_tests/map_stage_op_test.py4
-rw-r--r--tensorflow/python/kernel_tests/pooling_ops_test.py2
-rw-r--r--tensorflow/python/kernel_tests/reader_ops_test.py159
-rw-r--r--tensorflow/python/kernel_tests/sparse_slice_op_test.py251
-rw-r--r--tensorflow/python/kernel_tests/stage_op_test.py4
-rw-r--r--tensorflow/python/layers/base.py6
-rw-r--r--tensorflow/python/layers/convolutional.py15
-rw-r--r--tensorflow/python/ops/data_flow_ops.py19
-rw-r--r--tensorflow/python/ops/distributions/dirichlet_multinomial.py2
-rw-r--r--tensorflow/python/ops/distributions/distribution.py2
-rw-r--r--tensorflow/python/ops/distributions/multinomial.py2
-rw-r--r--tensorflow/python/ops/distributions/util.py2
-rw-r--r--tensorflow/python/ops/gradients_impl.py2
-rw-r--r--tensorflow/python/ops/hidden_ops.txt2
-rw-r--r--tensorflow/python/ops/image_ops_impl.py102
-rw-r--r--tensorflow/python/ops/image_ops_test.py49
-rw-r--r--tensorflow/python/ops/io_ops.py5
-rw-r--r--tensorflow/python/ops/math_grad.py34
-rw-r--r--tensorflow/python/ops/math_grad_test.py23
-rw-r--r--tensorflow/python/ops/math_ops.py7
-rw-r--r--tensorflow/python/ops/sets_impl.py2
-rw-r--r--tensorflow/python/ops/sparse_ops.py45
-rw-r--r--tensorflow/python/ops/summary_op_util.py2
-rw-r--r--tensorflow/python/training/adam.py2
-rw-r--r--tensorflow/python/util/deprecation_test.py2
-rw-r--r--tensorflow/python/util/nest.py6
-rw-r--r--tensorflow/python/util/tfprof.i1
-rw-r--r--tensorflow/tensorflow.bzl12
-rw-r--r--tensorflow/tools/api/golden/tensorflow.-f-i-f-o-queue.pbtxt4
-rw-r--r--tensorflow/tools/api/golden/tensorflow.-fixed-length-record-reader.pbtxt2
-rw-r--r--tensorflow/tools/api/golden/tensorflow.-padding-f-i-f-o-queue.pbtxt4
-rw-r--r--tensorflow/tools/api/golden/tensorflow.-priority-queue.pbtxt4
-rw-r--r--tensorflow/tools/api/golden/tensorflow.-queue-base.pbtxt4
-rw-r--r--tensorflow/tools/api/golden/tensorflow.-random-shuffle-queue.pbtxt4
-rw-r--r--tensorflow/tools/api/golden/tensorflow.pbtxt16
-rw-r--r--tensorflow/tools/dist_test/python/mnist_replica.py6
-rw-r--r--tensorflow/tools/docker/Dockerfile.devel-gpu1
-rw-r--r--tensorflow/tools/docker/README.md2
-rw-r--r--tensorflow/tools/docs/generate_lib.py2
-rw-r--r--tensorflow/tools/docs/parser.py2
-rw-r--r--tensorflow/tools/pip_package/setup.py2
-rw-r--r--tensorflow/workspace.bzl5
-rw-r--r--third_party/lmdb.BUILD4
-rw-r--r--third_party/snappy.BUILD24
-rwxr-xr-xthird_party/sycl/crosstool/computecpp.tpl2
-rw-r--r--third_party/toolchains/cpus/CROSSTOOL6
-rw-r--r--third_party/zlib.BUILD24
243 files changed, 2707 insertions, 814 deletions
diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md
index 4f1666c2e7..5bf13ee152 100644
--- a/ISSUE_TEMPLATE.md
+++ b/ISSUE_TEMPLATE.md
@@ -17,6 +17,7 @@ If you open a GitHub issue, here is our policy:
- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**:
- **TensorFlow installed from (source or binary)**:
- **TensorFlow version (use command below)**:
+- **Python version**:
- **Bazel version (if compiling from source)**:
- **CUDA/cuDNN version**:
- **GPU model and memory**:
diff --git a/README.md b/README.md
index abbead98a7..90d50f6768 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@ or more CPUs or GPUs in a desktop, server, or mobile device without rewriting
code. TensorFlow also includes TensorBoard, a data visualization toolkit.
TensorFlow was originally developed by researchers and engineers
-working on the Google Brain team within Google's Machine Intelligence research
+working on the Google Brain team within Google's Machine Intelligence Research
organization for the purposes of conducting machine learning and deep neural
networks research. The system is general enough to be applicable in a wide
variety of other domains, as well.
@@ -34,13 +34,13 @@ and discussion.**
People who are a little more adventurous can also try our nightly binaries:
-* Linux CPU-only: [Python 2](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=cpu-slave/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow-1.2.0-cp27-none-linux_x86_64.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=cpu-slave)) / [Python 3.4](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3,label=cpu-slave/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow-1.2.0-cp34-cp34m-linux_x86_64.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3,label=cpu-slave/)) / [Python 3.5](https://ci.tensorflow.org/view/Nightly/job/nightly-python35-linux-cpu/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow-1.2.0-cp35-cp35m-linux_x86_64.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-python35-linux-cpu/))
-* Linux GPU: [Python 2](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-linux-gpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=gpu-linux/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow_gpu-1.2.0-cp27-none-linux_x86_64.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-linux-gpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=gpu-linux/)) / [Python 3.4](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-linux-gpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3,label=gpu-linux/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow_gpu-1.2.0-cp34-cp34m-linux_x86_64.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-linux-gpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3,label=gpu-linux/)) / [Python 3.5](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-linux-gpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3.5,label=gpu-linux/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow_gpu-1.2.0-cp35-cp35m-linux_x86_64.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-linux-gpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3.5,label=gpu-linux/))
-* Mac CPU-only: [Python 2](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=mac-slave/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow-1.2.0-py2-none-any.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=mac-slave/)) / [Python 3](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3,label=mac-slave/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow-1.2.0-py3-none-any.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3,label=mac-slave/))
-* Mac GPU: [Python 2](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-mac-gpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=gpu-mac/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow_gpu-1.2.0-py2-none-any.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-mac-gpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=gpu-mac/)) / [Python 3](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-mac-gpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3,label=gpu-mac/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow_gpu-1.2.0-py3-none-any.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-mac-gpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3,label=gpu-mac/))
-* Windows CPU-only: [Python 3.5 64-bit](https://ci.tensorflow.org/view/Nightly/job/nightly-win/M=windows,PY=35/lastSuccessfulBuild/artifact/cmake_build/tf_python/dist/tensorflow-1.2.0-cp35-cp35m-win_amd64.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-win/M=windows,PY=35/)) / [Python 3.6 64-bit](https://ci.tensorflow.org/view/Nightly/job/nightly-win/M=windows,PY=36/lastSuccessfulBuild/artifact/cmake_build/tf_python/dist/tensorflow-1.2.0-cp36-cp36m-win_amd64.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-win/M=windows,PY=36/))
-* Windows GPU: [Python 3.5 64-bit](https://ci.tensorflow.org/view/Nightly/job/nightly-win/M=windows-gpu,PY=35/lastSuccessfulBuild/artifact/cmake_build/tf_python/dist/tensorflow_gpu-1.2.0-cp35-cp35m-win_amd64.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-win/M=windows-gpu,PY=35/)) / [Python 3.6 64-bit](https://ci.tensorflow.org/view/Nightly/job/nightly-win/M=windows-gpu,PY=36/lastSuccessfulBuild/artifact/cmake_build/tf_python/dist/tensorflow_gpu-1.2.0-cp36-cp36m-win_amd64.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-win/M=windows-gpu,PY=36/))
-* Android: [demo APK](https://ci.tensorflow.org/view/Nightly/job/nightly-android/lastSuccessfulBuild/artifact/out/tensorflow_demo.apk), [native libs](https://ci.tensorflow.org/view/Nightly/job/nightly-android/lastSuccessfulBuild/artifact/out/native/)
+* Linux CPU-only: [Python 2](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=cpu-slave/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow-1.2.1-cp27-none-linux_x86_64.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=cpu-slave)) / [Python 3.4](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3,label=cpu-slave/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow-1.2.1-cp34-cp34m-linux_x86_64.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3,label=cpu-slave/)) / [Python 3.5](https://ci.tensorflow.org/view/Nightly/job/nightly-python35-linux-cpu/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow-1.2.1-cp35-cp35m-linux_x86_64.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-python35-linux-cpu/))
+* Linux GPU: [Python 2](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-linux-gpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=gpu-linux/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow_gpu-1.2.1-cp27-none-linux_x86_64.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-linux-gpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=gpu-linux/)) / [Python 3.4](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-linux-gpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3,label=gpu-linux/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow_gpu-1.2.1-cp34-cp34m-linux_x86_64.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-linux-gpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3,label=gpu-linux/)) / [Python 3.5](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-linux-gpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3.5,label=gpu-linux/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow_gpu-1.2.1-cp35-cp35m-linux_x86_64.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-linux-gpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3.5,label=gpu-linux/))
+* Mac CPU-only: [Python 2](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=mac-slave/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow-1.2.1-py2-none-any.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=mac-slave/)) / [Python 3](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3,label=mac-slave/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow-1.2.1-py3-none-any.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3,label=mac-slave/))
+* Mac GPU: [Python 2](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-mac-gpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=gpu-mac/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow_gpu-1.2.1-py2-none-any.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-mac-gpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=gpu-mac/)) / [Python 3](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-mac-gpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3,label=gpu-mac/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow_gpu-1.2.1-py3-none-any.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-mac-gpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3,label=gpu-mac/))
+* Windows CPU-only: [Python 3.5 64-bit](https://ci.tensorflow.org/view/Nightly/job/nightly-win/M=windows,PY=35/lastSuccessfulBuild/artifact/cmake_build/tf_python/dist/tensorflow-1.2.1-cp35-cp35m-win_amd64.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-win/M=windows,PY=35/)) / [Python 3.6 64-bit](https://ci.tensorflow.org/view/Nightly/job/nightly-win/M=windows,PY=36/lastSuccessfulBuild/artifact/cmake_build/tf_python/dist/tensorflow-1.2.1-cp36-cp36m-win_amd64.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-win/M=windows,PY=36/))
+* Windows GPU: [Python 3.5 64-bit](https://ci.tensorflow.org/view/Nightly/job/nightly-win/M=windows-gpu,PY=35/lastSuccessfulBuild/artifact/cmake_build/tf_python/dist/tensorflow_gpu-1.2.1-cp35-cp35m-win_amd64.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-win/M=windows-gpu,PY=35/)) / [Python 3.6 64-bit](https://ci.tensorflow.org/view/Nightly/job/nightly-win/M=windows-gpu,PY=36/lastSuccessfulBuild/artifact/cmake_build/tf_python/dist/tensorflow_gpu-1.2.1-cp36-cp36m-win_amd64.whl) ([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-win/M=windows-gpu,PY=36/))
+* Android: [demo APK](https://ci.tensorflow.org/view/Nightly/job/nightly-android/lastSuccessfulBuild/artifact/out/tensorflow_demo.apk), [native libs](http://ci.tensorflow.org/view/Nightly/job/nightly-android/lastSuccessfulBuild/artifact/out/native/)
([build history](https://ci.tensorflow.org/view/Nightly/job/nightly-android/))
#### *Try your first TensorFlow program*
diff --git a/RELEASE.md b/RELEASE.md
index 9875838d7e..0cd4eef5d6 100644
--- a/RELEASE.md
+++ b/RELEASE.md
@@ -1,3 +1,9 @@
+# Release 1.2.1
+
+## Bug Fixes and Other Changes
+* Updating markdown version required to >= 2.6.8.
+* Support tensors as dropout rates again, by removing the min(max(..))
+
# Release 1.2.0
## Major Features and Improvements
diff --git a/configure b/configure
index 4bcf11e0a9..4c6cba2169 100755
--- a/configure
+++ b/configure
@@ -25,6 +25,10 @@ function is_windows() {
[[ "${PLATFORM}" =~ msys_nt*|mingw*|cygwin*|uwin* ]]
}
+function is_ppc64le() {
+ [[ "${uname -m}" == "ppc64le" ]]
+}
+
function sed_in_place() {
sed -e $1 $2 > "$2.bak"
mv "$2.bak" $2
@@ -294,7 +298,12 @@ fi # TF_NEED_MKL
## Set up architecture-dependent optimization flags.
if [ -z "$CC_OPT_FLAGS" ]; then
- default_cc_opt_flags="-march=native"
+ if [ is_ppc64le ]; then
+ # gcc on ppc64le does not support -march, use mcpu instead
+ default_cc_opt_flags="-mcpu=native"
+ else
+ default_cc_opt_flags="-march=native"
+ fi
read -p "Please specify optimization flags to use during compilation when bazel option "\
"\"--config=opt\" is specified [Default is $default_cc_opt_flags]: " CC_OPT_FLAGS
if [ -z "$CC_OPT_FLAGS" ]; then
diff --git a/tensorflow/c/c_api_test.cc b/tensorflow/c/c_api_test.cc
index 35d6e295c2..736f56837c 100644
--- a/tensorflow/c/c_api_test.cc
+++ b/tensorflow/c/c_api_test.cc
@@ -912,11 +912,13 @@ class CSession {
for (TF_Operation* o : outputs) {
outputs_.emplace_back(TF_Output{o, 0});
}
+ output_values_.resize(outputs_.size());
}
void SetOutputs(const std::vector<TF_Output>& outputs) {
ResetOutputValues();
outputs_ = outputs;
+ output_values_.resize(outputs_.size());
}
void SetTargets(std::initializer_list<TF_Operation*> targets) {
diff --git a/tensorflow/cc/framework/gradients.cc b/tensorflow/cc/framework/gradients.cc
index 8c00a6f704..29ad8a934b 100644
--- a/tensorflow/cc/framework/gradients.cc
+++ b/tensorflow/cc/framework/gradients.cc
@@ -152,12 +152,12 @@ Status SymbolicGradientBuilder::Initialize() {
grad_outputs_->resize(inputs_.size());
// Populate `output_nodes_` from node ids in `outputs_`.
output_nodes_.reserve(outputs_.size());
- for (int i = 0; i < outputs_.size(); ++i) {
+ for (size_t i = 0; i < outputs_.size(); ++i) {
output_nodes_.insert(outputs_[i].node()->id());
}
// Populate `input_nodes_` from Outputs in `inputs_`.
input_nodes_.reserve(inputs_.size());
- for (int i = 0; i < inputs_.size(); ++i) {
+ for (size_t i = 0; i < inputs_.size(); ++i) {
input_nodes_.insert({inputs_[i], i});
}
@@ -341,7 +341,7 @@ Status SymbolicGradientBuilder::AddGradients() {
// gradient function to the src node/output to which it should be
// backproped. Maybe grad functions can return a vector of Output pairs to
// make this association explicit.
- int dx_index = 0;
+ size_t dx_index = 0;
for (const Edge* e : n->in_edges()) {
if (e->IsControlEdge()) continue;
if (dx_index == dx.size()) {
diff --git a/tensorflow/cc/gradients/math_grad.cc b/tensorflow/cc/gradients/math_grad.cc
index 71d9a8ed7b..0b9b665b1e 100644
--- a/tensorflow/cc/gradients/math_grad.cc
+++ b/tensorflow/cc/gradients/math_grad.cc
@@ -203,6 +203,46 @@ Status TanhGrad(const Scope& scope, const Operation& op,
}
REGISTER_GRADIENT_OP("Tanh", TanhGrad);
+Status AsinhGrad(const Scope& scope, const Operation& op,
+ const std::vector<Output>& grad_inputs,
+ std::vector<Output>* grad_outputs) {
+ // y = asinh(x)
+ // dy/dx = 1 / cosh(y)
+ auto dydx = Reciprocal(scope, Cosh(scope, op.output(0)));
+ // grad(x) = grad(y) * conj(dy/dx)
+ grad_outputs->push_back(
+ Mul(scope, grad_inputs[0], ConjugateHelper(scope, dydx)));
+ return scope.status();
+}
+REGISTER_GRADIENT_OP("Asinh", AsinhGrad);
+
+Status AcoshGrad(const Scope& scope, const Operation& op,
+ const std::vector<Output>& grad_inputs,
+ std::vector<Output>* grad_outputs) {
+ // y = acosh(x)
+ // dy/dx = 1 / sinh(y)
+ auto dydx = Reciprocal(scope, Sinh(scope, op.output(0)));
+ // grad(x) = grad(y) * conj(dy/dx)
+ grad_outputs->push_back(
+ Mul(scope, grad_inputs[0], ConjugateHelper(scope, dydx)));
+ return scope.status();
+}
+REGISTER_GRADIENT_OP("Acosh", AcoshGrad);
+
+Status AtanhGrad(const Scope& scope, const Operation& op,
+ const std::vector<Output>& grad_inputs,
+ std::vector<Output>* grad_outputs) {
+ // y = atanh(x)
+ // dy/dx = 1 / (1 - x^2)
+ auto one = Cast(scope, Const(scope, 1.0), op.input(0).type());
+ auto dydx = Reciprocal(scope, Sub(scope, one, Square(scope, op.input(0))));
+ // grad(x) = grad(y) * conj(dy/dx)
+ grad_outputs->push_back(
+ Mul(scope, grad_inputs[0], ConjugateHelper(scope, dydx)));
+ return scope.status();
+}
+REGISTER_GRADIENT_OP("Atanh", AtanhGrad);
+
Status SigmoidGrad(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 1653b04378..48b3ddbe90 100644
--- a/tensorflow/cc/gradients/math_grad_test.cc
+++ b/tensorflow/cc/gradients/math_grad_test.cc
@@ -48,6 +48,9 @@ class CWiseUnaryGradTest : public ::testing::Test {
SINH,
COSH,
TANH,
+ ASINH,
+ ACOSH,
+ ATANH,
SIGMOID,
SIGN,
SIN,
@@ -122,6 +125,15 @@ class CWiseUnaryGradTest : public ::testing::Test {
case TANH:
y = Tanh(scope_, x);
break;
+ case ASINH:
+ y = Asinh(scope_, x);
+ break;
+ case ACOSH:
+ y = Acosh(scope_, x);
+ break;
+ case ATANH:
+ y = Atanh(scope_, x);
+ break;
case SIGMOID:
y = Sigmoid(scope_, x);
break;
@@ -413,6 +425,76 @@ TEST_F(CWiseUnaryGradTest, Tanh_Complex) {
TestCWiseGrad<complex64>(TANH, x_fn, dy_fn, dx_fn);
}
+TEST_F(CWiseUnaryGradTest, Asinh) {
+ auto x_fn = [this](const int i) { return RV({0, -1, 1, -2, 2, -3, 3}); };
+ auto dy_fn = [this](const float x) { return x + RV({-2, 2, -3, 3, -4, 4}); };
+ auto dx_fn = [this](const float x, const float dy) {
+ auto y = std::asinh(x);
+ return dy / std::cosh(y);
+ };
+ TestCWiseGrad<float>(ASINH, x_fn, dy_fn, dx_fn);
+}
+
+TEST_F(CWiseUnaryGradTest, Asinh_Complex) {
+ auto x_fn = [this](const int i) {
+ return CRV({{1, 0}, {0, 1}, {2, -1}, {1, 2}, {3, 4}});
+ };
+ auto dy_fn = [this](const complex64& x) {
+ return x + CRV({{-2, 2}, {-3, 3}, {1, -4}});
+ };
+ auto dx_fn = [this](const complex64& x, const complex64& dy) {
+ auto y = std::asinh(x);
+ return dy / conjugate(std::cosh(y));
+ };
+ TestCWiseGrad<complex64>(ASINH, x_fn, dy_fn, dx_fn);
+}
+
+TEST_F(CWiseUnaryGradTest, Acosh) {
+ auto x_fn = [this](const int i) { return RV({1, 2, 3, 4, 5, 6, 7}); };
+ auto dy_fn = [this](const float x) { return x + RV({8, 9, 10, 11, 12, 13, 14}); };
+ auto dx_fn = [this](const float x, const float dy) {
+ auto y = std::acosh(x);
+ return dy / std::sinh(y);
+ };
+ TestCWiseGrad<float>(ACOSH, x_fn, dy_fn, dx_fn);
+}
+
+TEST_F(CWiseUnaryGradTest, Acosh_Complex) {
+ auto x_fn = [this](const int i) {
+ return CRV({{1, 1}, {2, 1}, {1, 4}, {1, 2}, {3, 4}});
+ };
+ auto dy_fn = [this](const complex64& x) {
+ return x + CRV({{2, 2}, {3, 3}, {1, 4}});
+ };
+ auto dx_fn = [this](const complex64& x, const complex64& dy) {
+ auto y = std::acosh(x);
+ return dy / conjugate(std::sinh(y));
+ };
+ TestCWiseGrad<complex64>(ACOSH, x_fn, dy_fn, dx_fn);
+}
+
+TEST_F(CWiseUnaryGradTest, Atanh) {
+ auto x_fn = [this](const int i) { return RV({0, -0.5, 0.5, -0.1, 0.1}); };
+ auto dy_fn = [this](const float x) { return x + RV({-2, 2, -3, 3, -4, 4}); };
+ auto dx_fn = [this](const float x, const float dy) {
+ return dy * (1. / (1. - x * x));
+ };
+ TestCWiseGrad<float>(ATANH, x_fn, dy_fn, dx_fn);
+}
+
+TEST_F(CWiseUnaryGradTest, Atanh_Complex) {
+ auto x_fn = [this](const int i) {
+ return CRV({{0.1, 0}, {0, 0.1}, {0.2, -0.1}, {0.1, 0.2}, {0.3, 0.4}});
+ };
+ auto dy_fn = [this](const complex64& x) {
+ return x + CRV({{-2, 2}, {-3, 3}, {1, -4}});
+ };
+ auto dx_fn = [this](const complex64& x, const complex64& dy) {
+ return dy / conjugate(one_ - x * x);
+ };
+ TestCWiseGrad<complex64>(ATANH, x_fn, dy_fn, dx_fn);
+}
+
TEST_F(CWiseUnaryGradTest, Sigmoid) {
auto x_fn = [this](const int i) { return RV({0, -1, 1, -2, 2, -3, 3}); };
auto dy_fn = [this](const float x) { return x + RV({-2, 2, -3, 3, -4, 4}); };
diff --git a/tensorflow/compiler/tf2xla/functionalize_control_flow.cc b/tensorflow/compiler/tf2xla/functionalize_control_flow.cc
index 1c2c327347..faa88ecfe2 100644
--- a/tensorflow/compiler/tf2xla/functionalize_control_flow.cc
+++ b/tensorflow/compiler/tf2xla/functionalize_control_flow.cc
@@ -383,7 +383,7 @@ Status FunctionalizeLoop(Graph* graph, Frame* frame,
}
}
if (arg.exit == nullptr) {
- return errors::InvalidArgument("Mising Exit successor to ",
+ return errors::InvalidArgument("Missing Exit successor to ",
arg.switch_node->name());
}
}
diff --git a/tensorflow/compiler/xla/service/cpu/cpu_parallelization_preparation.h b/tensorflow/compiler/xla/service/cpu/cpu_parallelization_preparation.h
index 70e3492934..d53fc46150 100644
--- a/tensorflow/compiler/xla/service/cpu/cpu_parallelization_preparation.h
+++ b/tensorflow/compiler/xla/service/cpu/cpu_parallelization_preparation.h
@@ -63,7 +63,7 @@ class ParallelizationPreparation : public HloPassInterface {
// Outlines 'instruction' from entry computation, if it had
// been assigned parallel tasks in an earlier pass through the computation.
- // Returns true if 'instruction' was succesfully outlined, false otherwise.
+ // Returns true if 'instruction' was successfully outlined, false otherwise.
bool OutlineParallelizableInstruction(HloInstruction* instruction);
// Returns true if 'instruction' can be outlined into the same sub-computation
diff --git a/tensorflow/compiler/xla/service/cpu/infeed_manager.h b/tensorflow/compiler/xla/service/cpu/infeed_manager.h
index 756582ef78..e965988453 100644
--- a/tensorflow/compiler/xla/service/cpu/infeed_manager.h
+++ b/tensorflow/compiler/xla/service/cpu/infeed_manager.h
@@ -21,6 +21,7 @@ limitations under the License.
#define TENSORFLOW_COMPILER_XLA_SERVICE_CPU_INFEED_MANAGER_H_
#include <deque>
+#include <vector>
#include "tensorflow/compiler/xla/types.h"
#include "tensorflow/core/platform/mutex.h"
diff --git a/tensorflow/compiler/xla/service/cpu/parallel_cpu_executable.cc b/tensorflow/compiler/xla/service/cpu/parallel_cpu_executable.cc
index 85fccd327f..f0af3e7b89 100644
--- a/tensorflow/compiler/xla/service/cpu/parallel_cpu_executable.cc
+++ b/tensorflow/compiler/xla/service/cpu/parallel_cpu_executable.cc
@@ -441,7 +441,7 @@ Status ParallelCpuExecutable::ExecuteComputeFunctions(
// TODO(b/27458679) Manage scheduling based on in-flight concurrency limits.
// For example, if we expect a library conv/matmul call to run at max
// concurrency, we should not dispatch runnable instructions until the
- // libary call is finished (to avoid expensive cache invalidation).
+ // library call is finished (to avoid expensive cache invalidation).
Executor executor(functions, run_options, &pending, &results,
buffer_pointers.data(), profile_counters.data(),
assignment_.get());
diff --git a/tensorflow/compiler/xla/service/cpu/shape_partition.cc b/tensorflow/compiler/xla/service/cpu/shape_partition.cc
index e27ff13edd..61b408b8c2 100644
--- a/tensorflow/compiler/xla/service/cpu/shape_partition.cc
+++ b/tensorflow/compiler/xla/service/cpu/shape_partition.cc
@@ -20,7 +20,7 @@ namespace cpu {
std::vector<int64> ShapePartitionAssigner::Run(int64 target_partition_count) {
// Gather outer-most dims where dim_size >= 'target_partition_count'.
- // Note: always leave inner-dim static for vectorization/optimzations.
+ // Note: always leave inner-dim static for vectorization/optimizations.
std::vector<int64> outer_dims;
int64 outer_dim_size = 1;
// TODO(b/27458679) Consider reserving enough minor dimensions (based on
diff --git a/tensorflow/compiler/xla/service/cpu/shape_partition.h b/tensorflow/compiler/xla/service/cpu/shape_partition.h
index bdbcb874c1..7a2d00421c 100644
--- a/tensorflow/compiler/xla/service/cpu/shape_partition.h
+++ b/tensorflow/compiler/xla/service/cpu/shape_partition.h
@@ -38,7 +38,7 @@ namespace cpu {
//
// [0, 1), [1, 2), [2, 3), [3, 4), [4, 5) [5, 8)
//
-// Note that the last parition has residule because the dimension size is
+// Note that the last partition has residule because the dimension size is
// not a multiple of the partition count.
//
//
diff --git a/tensorflow/compiler/xla/service/hlo_alias_analysis_test.cc b/tensorflow/compiler/xla/service/hlo_alias_analysis_test.cc
index 442585772f..d67b48dff0 100644
--- a/tensorflow/compiler/xla/service/hlo_alias_analysis_test.cc
+++ b/tensorflow/compiler/xla/service/hlo_alias_analysis_test.cc
@@ -495,7 +495,7 @@ TEST_F(HloAliasAnalysisTest, NestedWhiles) {
};
// Build separate condition computations so the call graph is flat. The
// callgraph is always flattened in the compiler pipeline, and the flattened
- // callgraph enables representive interference analysis.
+ // callgraph enables representative interference analysis.
HloComputation* condition1 =
module_->AddEmbeddedComputation(build_cond_computation());
HloComputation* condition2 =
diff --git a/tensorflow/compiler/xla/tests/BUILD b/tensorflow/compiler/xla/tests/BUILD
index 7a899d6e23..5298af788e 100644
--- a/tensorflow/compiler/xla/tests/BUILD
+++ b/tensorflow/compiler/xla/tests/BUILD
@@ -527,7 +527,7 @@ xla_test(
)
# Tests the dot operation in some cases that can be performed via a
-# runtime call on some backends - e.g. a runtime call to to Eigen.
+# runtime call on some backends - e.g. a runtime call to Eigen.
xla_test(
name = "dot_operation_runtime_test",
srcs = ["dot_operation_test.cc"],
diff --git a/tensorflow/compiler/xla/tests/build_defs.bzl b/tensorflow/compiler/xla/tests/build_defs.bzl
index 50edd8ea5b..a297132dd3 100644
--- a/tensorflow/compiler/xla/tests/build_defs.bzl
+++ b/tensorflow/compiler/xla/tests/build_defs.bzl
@@ -1,8 +1,9 @@
"""Build rules for XLA testing."""
load("@local_config_cuda//cuda:build_defs.bzl", "cuda_is_configured")
+load("//tensorflow/compiler/xla/tests:plugin.bzl", "plugins")
-all_backends = ["cpu", "cpu_parallel", "gpu"]
+all_backends = ["cpu", "cpu_parallel", "gpu"] + plugins.keys()
def filter_backends(backends):
"""Removes "gpu" from a backend list if CUDA is not enabled.
@@ -121,6 +122,11 @@ def xla_test(name,
backend_deps = ["//tensorflow/compiler/xla/service:gpu_plugin"]
backend_deps += ["//tensorflow/compiler/xla/tests:test_macros_gpu"]
this_backend_tags += ["requires-gpu-sm35"]
+ elif backend in plugins:
+ backend_deps = plugins[backend]["deps"]
+ this_backend_copts += plugins[backend]["copts"]
+ this_backend_tags += plugins[backend]["tags"]
+ this_backend_args += plugins[backend]["args"]
else:
fail("Unknown backend %s" % backend)
diff --git a/tensorflow/compiler/xla/tests/plugin.bzl b/tensorflow/compiler/xla/tests/plugin.bzl
new file mode 100644
index 0000000000..1b10c778ce
--- /dev/null
+++ b/tensorflow/compiler/xla/tests/plugin.bzl
@@ -0,0 +1,32 @@
+# 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.
+# ==============================================================================
+"""Additional XLA devices to be included in the unit test suite."""
+
+# Example:
+#
+# plugins = {
+# "foo": {
+# "deps": [
+# "//tensorflow/compiler/plugin/foo:foo_lib",
+# "//tensorflow/compiler/plugin/foo:test_macros",
+# ],
+# "copts": [],
+# "tags": [],
+# "args": []
+# },
+# }
+
+plugins = {}
+
diff --git a/tensorflow/contrib/batching/kernels/batch_kernels.cc b/tensorflow/contrib/batching/kernels/batch_kernels.cc
index 3c06325651..3b7c538fcc 100644
--- a/tensorflow/contrib/batching/kernels/batch_kernels.cc
+++ b/tensorflow/contrib/batching/kernels/batch_kernels.cc
@@ -51,7 +51,7 @@ Status Concat(OpKernelContext* context, const gtl::ArraySlice<Tensor>& inputs,
std::vector<std::unique_ptr<typename TTypes<T, 2>::ConstMatrix>> inputs_flat;
inputs_flat.reserve(inputs.size());
int64 output_dim0 = 0;
- for (int i = 0; i < inputs.size(); ++i) {
+ for (size_t i = 0; i < inputs.size(); ++i) {
const Tensor& input = inputs[i];
if (input.dims() != input_dims) {
return errors::InvalidArgument(
@@ -548,7 +548,7 @@ class BatchKernel : public AsyncOpKernel {
return Status::OK();
}
int32 last_size = 0;
- for (int i = 0; i < allowed_batch_sizes_.size(); ++i) {
+ for (size_t i = 0; i < allowed_batch_sizes_.size(); ++i) {
const int32 size = allowed_batch_sizes_.at(i);
if (i > 0 && size <= last_size) {
return errors::InvalidArgument(
@@ -675,7 +675,7 @@ class UnbatchResource : public ResourceBase {
// If we have a non-empty tensor, finish the waitlisted runs,
// and store any remaining pieces.
if (nonempty_input) {
- for (int i = 0; i < batch_keys.size(); ++i) {
+ for (size_t i = 0; i < batch_keys.size(); ++i) {
auto runs_it = waiting_callbacks_.find(batch_keys[i]);
if (runs_it != waiting_callbacks_.end()) {
runs_it->second.context->set_output(0, split_inputs[i]);
diff --git a/tensorflow/contrib/boosted_trees/lib/learner/stochastic/handlers/categorical-feature-column-handler.cc b/tensorflow/contrib/boosted_trees/lib/learner/stochastic/handlers/categorical-feature-column-handler.cc
index 2f76224ff0..3a6c409f84 100644
--- a/tensorflow/contrib/boosted_trees/lib/learner/stochastic/handlers/categorical-feature-column-handler.cc
+++ b/tensorflow/contrib/boosted_trees/lib/learner/stochastic/handlers/categorical-feature-column-handler.cc
@@ -106,7 +106,7 @@ void CategoricalFeatureColumnHandler::GenerateFeatureSplitCandidates(
NodeStats left_node_stats(learner_config, left_gradient_stats);
NodeStats right_node_stats(learner_config, right_gradient_stats);
- // Generate split candiate and update best split candidate for the
+ // Generate split candidate and update best split candidate for the
// current root if needed.
FeatureSplitCandidate split_candidate(
slot_id_,
diff --git a/tensorflow/contrib/boosted_trees/lib/learner/stochastic/handlers/dense-quantized-feature-column-handler.cc b/tensorflow/contrib/boosted_trees/lib/learner/stochastic/handlers/dense-quantized-feature-column-handler.cc
index f43112c8a4..ca7bb71e7d 100644
--- a/tensorflow/contrib/boosted_trees/lib/learner/stochastic/handlers/dense-quantized-feature-column-handler.cc
+++ b/tensorflow/contrib/boosted_trees/lib/learner/stochastic/handlers/dense-quantized-feature-column-handler.cc
@@ -93,7 +93,7 @@ void DenseQuantizedFeatureColumnHandler::GenerateFeatureSplitCandidates(
NodeStats left_node_stats(learner_config, left_gradient_stats);
NodeStats right_node_stats(learner_config, right_gradient_stats);
- // Generate split candiate.
+ // Generate split candidate.
const float threshold = dense_quantiles_(bucket_id);
FeatureSplitCandidate split_candidate(
slot_id_, CreateDenseSplitNode(dense_feature_column_, threshold),
diff --git a/tensorflow/contrib/boosted_trees/lib/learner/stochastic/handlers/sparse-quantized-feature-column-handler.cc b/tensorflow/contrib/boosted_trees/lib/learner/stochastic/handlers/sparse-quantized-feature-column-handler.cc
index 76da16ab93..a0e9efbbc5 100644
--- a/tensorflow/contrib/boosted_trees/lib/learner/stochastic/handlers/sparse-quantized-feature-column-handler.cc
+++ b/tensorflow/contrib/boosted_trees/lib/learner/stochastic/handlers/sparse-quantized-feature-column-handler.cc
@@ -109,7 +109,7 @@ void SparseQuantizedFeatureColumnHandler::GenerateFeatureSplitCandidates(
NodeStats left_node_stats(learner_config, left_gradient_stats);
NodeStats right_node_stats(learner_config, right_gradient_stats);
- // Generate split candiate.
+ // Generate split candidate.
const float threshold = sparse_quantiles_(bucket_id);
FeatureSplitCandidate split_candidate(
slot_id_,
@@ -124,7 +124,7 @@ void SparseQuantizedFeatureColumnHandler::GenerateFeatureSplitCandidates(
// Determine if we need a backward pass by checking if the residual gradient
// after forward aggregation is almost the same as the aggregated gradient.
- // for the current root. This helps avoid unecessary computation as well
+ // for the current root. This helps avoid unnecessary computation as well
// as consistency due to floating point precision.
if (!right_gradient_stats.IsAlmostZero()) {
// Backward pass with left default direction.
@@ -147,7 +147,7 @@ void SparseQuantizedFeatureColumnHandler::GenerateFeatureSplitCandidates(
NodeStats left_node_stats(learner_config, left_gradient_stats);
NodeStats right_node_stats(learner_config, right_gradient_stats);
- // Generate split candiate.
+ // Generate split candidate.
const float threshold = sparse_quantiles_(bucket_id - 1);
FeatureSplitCandidate split_candidate(
slot_id_,
diff --git a/tensorflow/contrib/boosted_trees/python/kernel_tests/prediction_ops_test.py b/tensorflow/contrib/boosted_trees/python/kernel_tests/prediction_ops_test.py
index aa665d95d7..e5624da965 100644
--- a/tensorflow/contrib/boosted_trees/python/kernel_tests/prediction_ops_test.py
+++ b/tensorflow/contrib/boosted_trees/python/kernel_tests/prediction_ops_test.py
@@ -1149,7 +1149,7 @@ class PredictionOpsTest(test_util.TensorFlowTestCase):
adjusted_tree_ensemble_config = (
tree_config_pb2.DecisionTreeEnsembleConfig())
# When we say to average over more trees than possible, it is averaging
- # accross all trees.
+ # across all trees.
total_num = 100
for i in range(0, total_num):
tree = tree_ensemble_config.trees.add()
diff --git a/tensorflow/contrib/cmake/external/cub.cmake b/tensorflow/contrib/cmake/external/cub.cmake
index 54329dbd70..1119f0ccba 100644
--- a/tensorflow/contrib/cmake/external/cub.cmake
+++ b/tensorflow/contrib/cmake/external/cub.cmake
@@ -18,6 +18,7 @@ set(cub_URL https://github.com/NVlabs/cub/archive/1.6.4.zip)
set(cub_HASH SHA256=966d0c4f41e2bdc81aebf9ccfbf0baffaac5a74f00b826b06f4dee79b2bb8cee)
set(cub_BUILD ${CMAKE_CURRENT_BINARY_DIR}/cub/src/cub)
set(cub_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/cub/src/cub)
+set(cub_ARCHIVE_DIR ${CMAKE_CURRENT_BINARY_DIR}/external/cub_archive)
ExternalProject_Add(cub
PREFIX cub
@@ -26,4 +27,4 @@ ExternalProject_Add(cub
DOWNLOAD_DIR "${DOWNLOAD_LOCATION}"
BUILD_IN_SOURCE 1
PATCH_COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/patches/cub/CMakeLists.txt ${cub_BUILD}
- INSTALL_COMMAND "")
+ INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory ${cub_INCLUDE_DIR}/cub ${cub_ARCHIVE_DIR}/cub)
diff --git a/tensorflow/contrib/cmake/tf_core_kernels.cmake b/tensorflow/contrib/cmake/tf_core_kernels.cmake
index 6b8c130490..57df33c13e 100644
--- a/tensorflow/contrib/cmake/tf_core_kernels.cmake
+++ b/tensorflow/contrib/cmake/tf_core_kernels.cmake
@@ -126,13 +126,15 @@ if(WIN32)
"${tensorflow_source_dir}/tensorflow/core/kernels/*quantiz*.h"
"${tensorflow_source_dir}/tensorflow/core/kernels/*quantiz*.cc"
"${tensorflow_source_dir}/tensorflow/core/kernels/neon/*"
- # no in tensorflow.dll - comes from .so
+ # not in core - those are loaded dynamically as dll
"${tensorflow_source_dir}/tensorflow/contrib/resampler/kernels/resampler_ops.cc"
"${tensorflow_source_dir}/tensorflow/contrib/rnn/kernels/blas_gemm.cc"
"${tensorflow_source_dir}/tensorflow/contrib/rnn/kernels/gru_ops.cc"
"${tensorflow_source_dir}/tensorflow/contrib/rnn/kernels/lstm_ops.cc"
"${tensorflow_source_dir}/tensorflow/contrib/rnn/ops/gru_ops.cc"
"${tensorflow_source_dir}/tensorflow/contrib/rnn/ops/lstm_ops.cc"
+ "${tensorflow_source_dir}/tensorflow/contrib/seq2seq/kernels/beam_search_ops.cc"
+ "${tensorflow_source_dir}/tensorflow/contrib/seq2seq/ops/beam_search_ops.cc"
# temporarily disable nccl (nccl itself needs to be ported to windows first)
"${tensorflow_source_dir}/tensorflow/contrib/nccl/kernels/nccl_manager.cc"
"${tensorflow_source_dir}/tensorflow/contrib/nccl/kernels/nccl_ops.cc"
diff --git a/tensorflow/contrib/cmake/tf_tests.cmake b/tensorflow/contrib/cmake/tf_tests.cmake
index 0d49ecd0fd..b7023dbac8 100644
--- a/tensorflow/contrib/cmake/tf_tests.cmake
+++ b/tensorflow/contrib/cmake/tf_tests.cmake
@@ -148,6 +148,7 @@ if (tensorflow_BUILD_PYTHON_TESTS)
"${tensorflow_source_dir}/tensorflow/contrib/data/*_test.py"
"${tensorflow_source_dir}/tensorflow/contrib/factorization/*_test.py"
"${tensorflow_source_dir}/tensorflow/contrib/keras/python/keras/integration_test.py"
+ "${tensorflow_source_dir}/tensorflow/contrib/seq2seq/python/kernel_tests/*_test.py"
"${tensorflow_source_dir}/tensorflow/contrib/stateless/python/kernel_tests/*_test.py"
# NOTE: tensor_forest tests in tensor_forest/hybrid/... still don't pass.
"${tensorflow_source_dir}/tensorflow/contrib/tensor_forest/client/*_test.py"
@@ -171,6 +172,10 @@ if (tensorflow_BUILD_PYTHON_TESTS)
"${tensorflow_source_dir}/tensorflow/python/saved_model/saved_model_test.py"
# requires scipy
"${tensorflow_source_dir}/tensorflow/contrib/keras/python/keras/preprocessing/*_test.py"
+ "${tensorflow_source_dir}/tensorflow/contrib/tfprof/python/tools/tfprof/pprof_profiler_test.py"
+ # flaky tests
+ "${tensorflow_source_dir}/tensorflow/python/kernel_tests/cwise_ops_test.py"
+ "${tensorflow_source_dir}/tensorflow/contrib/tfprof/python/tools/tfprof/internal/run_metadata_test.py"
)
if (WIN32)
set(tf_test_src_py_exclude
diff --git a/tensorflow/contrib/distributions/python/ops/binomial.py b/tensorflow/contrib/distributions/python/ops/binomial.py
index d8bc77eaa4..6a1bb39ab2 100644
--- a/tensorflow/contrib/distributions/python/ops/binomial.py
+++ b/tensorflow/contrib/distributions/python/ops/binomial.py
@@ -196,7 +196,7 @@ class Binomial(distribution.Distribution):
@property
def probs(self):
- """Probability of of drawing a `1`."""
+ """Probability of drawing a `1`."""
return self._probs
def _batch_shape_tensor(self):
diff --git a/tensorflow/contrib/distributions/python/ops/vector_student_t.py b/tensorflow/contrib/distributions/python/ops/vector_student_t.py
index ae804b6172..507493560b 100644
--- a/tensorflow/contrib/distributions/python/ops/vector_student_t.py
+++ b/tensorflow/contrib/distributions/python/ops/vector_student_t.py
@@ -160,7 +160,7 @@ class _VectorStudentT(transformed_distribution.TransformedDistribution):
#### Examples
A single instance of a "Vector Student's t-distribution" is defined by a mean
- vector of of length `k` and a scale matrix of shape `k x k`.
+ vector of length `k` and a scale matrix of shape `k x k`.
Extra leading dimensions, if provided, allow for batches.
diff --git a/tensorflow/contrib/factorization/python/ops/factorization_ops.py b/tensorflow/contrib/factorization/python/ops/factorization_ops.py
index 14a2311a42..fb400dbcea 100644
--- a/tensorflow/contrib/factorization/python/ops/factorization_ops.py
+++ b/tensorflow/contrib/factorization/python/ops/factorization_ops.py
@@ -800,7 +800,7 @@ class WALSModel(object):
regularization: A tensor (scalar) that contains the normalized
regularization term for the minibatch loss corresponding to sp_input.
sum_weights: The sum of the weights corresponding to sp_input. This
- can be used with unregularized loss to caluclate the root weighted
+ can be used with unregularized loss to calculate the root weighted
squared error.
"""
assert isinstance(sp_input, sparse_tensor.SparseTensor)
diff --git a/tensorflow/contrib/image/kernels/image_ops.cc b/tensorflow/contrib/image/kernels/image_ops.cc
index 8a97f07732..6adf837ca0 100644
--- a/tensorflow/contrib/image/kernels/image_ops.cc
+++ b/tensorflow/contrib/image/kernels/image_ops.cc
@@ -32,11 +32,11 @@ namespace functor {
// Explicit instantiation of the CPU functor.
typedef Eigen::ThreadPoolDevice CPUDevice;
-template class FillProjectiveTransform<CPUDevice, uint8>;
-template class FillProjectiveTransform<CPUDevice, int32>;
-template class FillProjectiveTransform<CPUDevice, int64>;
-template class FillProjectiveTransform<CPUDevice, float>;
-template class FillProjectiveTransform<CPUDevice, double>;
+template struct FillProjectiveTransform<CPUDevice, uint8>;
+template struct FillProjectiveTransform<CPUDevice, int32>;
+template struct FillProjectiveTransform<CPUDevice, int64>;
+template struct FillProjectiveTransform<CPUDevice, float>;
+template struct FillProjectiveTransform<CPUDevice, double>;
} // end namespace functor
@@ -116,7 +116,7 @@ namespace functor {
void FillProjectiveTransform<GPUDevice, TYPE>::operator()( \
const GPUDevice& device, OutputType* output, const InputType& images, \
const TransformsType& transform) const; \
- extern template class FillProjectiveTransform<GPUDevice, TYPE>
+ extern template struct FillProjectiveTransform<GPUDevice, TYPE>
TF_CALL_uint8(DECLARE_FUNCTOR);
TF_CALL_int32(DECLARE_FUNCTOR);
diff --git a/tensorflow/contrib/keras/python/keras/backend.py b/tensorflow/contrib/keras/python/keras/backend.py
index 5175bd0040..4fa4ec0dd4 100644
--- a/tensorflow/contrib/keras/python/keras/backend.py
+++ b/tensorflow/contrib/keras/python/keras/backend.py
@@ -21,6 +21,7 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
+import collections
import json
import os
@@ -263,6 +264,9 @@ def get_uid(prefix=''):
```
"""
graph = ops.get_default_graph()
+ if graph not in tf_base_layers.PER_GRAPH_LAYER_NAME_UIDS:
+ tf_base_layers.PER_GRAPH_LAYER_NAME_UIDS[graph] = collections.defaultdict(
+ int)
layer_name_uids = tf_base_layers.PER_GRAPH_LAYER_NAME_UIDS[graph]
layer_name_uids[prefix] += 1
return layer_name_uids[prefix]
diff --git a/tensorflow/contrib/keras/python/keras/layers/convolutional.py b/tensorflow/contrib/keras/python/keras/layers/convolutional.py
index 24ff0baf84..b5e44c89c0 100644
--- a/tensorflow/contrib/keras/python/keras/layers/convolutional.py
+++ b/tensorflow/contrib/keras/python/keras/layers/convolutional.py
@@ -316,7 +316,7 @@ class Conv3D(tf_convolutional_layers.Conv3D, Layer):
When using this layer as the first layer in a model,
provide the keyword argument `input_shape`
(tuple of integers, does not include the sample axis),
- e.g. `input_shape=(128, 128, 128, 3)` for 128x128x128 volumes
+ e.g. `input_shape=(128, 128, 128, 1)` for 128x128x128 volumes
with a single channel,
in `data_format="channels_last"`.
diff --git a/tensorflow/contrib/keras/python/keras/testing_utils.py b/tensorflow/contrib/keras/python/keras/testing_utils.py
index bf6f661adf..2f51ace945 100644
--- a/tensorflow/contrib/keras/python/keras/testing_utils.py
+++ b/tensorflow/contrib/keras/python/keras/testing_utils.py
@@ -78,7 +78,7 @@ def layer_test(layer_cls, kwargs=None, input_shape=None, input_dtype=None,
if e is None:
input_data_shape[i] = np.random.randint(1, 4)
input_data = 10 * np.random.random(input_data_shape)
- if input_dtype[:4] == 'float':
+ if input_dtype[:5] == 'float':
input_data -= 0.5
input_data = input_data.astype(input_dtype)
elif input_shape is None:
diff --git a/tensorflow/contrib/layers/kernels/sparse_feature_cross_kernel.cc b/tensorflow/contrib/layers/kernels/sparse_feature_cross_kernel.cc
index badf9d486a..932c5ab992 100644
--- a/tensorflow/contrib/layers/kernels/sparse_feature_cross_kernel.cc
+++ b/tensorflow/contrib/layers/kernels/sparse_feature_cross_kernel.cc
@@ -177,7 +177,7 @@ class StringCrosser {
static const auto k_feature_separator = "_X_";
gtl::InlinedVector<InternalType, 6> cross_vec(columns_.size());
- for (int i = 0; i < permutation.size(); i++) {
+ for (size_t i = 0; i < permutation.size(); i++) {
cross_vec[i] = columns_[i]->Feature(batch_index, permutation[i]);
}
// TODO(zakaria): this will copy the string twice, might effect
@@ -267,7 +267,7 @@ class ProductIterator {
next_permutation_.resize(columns_.size(), 0);
// Sets has_next_ to false if any feature column has 0 features.
has_next_ = true;
- for (int i = 0; i < columns_.size(); i++) {
+ for (size_t i = 0; i < columns_.size(); i++) {
if (columns_[i]->FeatureCount(batch_index_) == 0) {
has_next_ = false;
break;
@@ -581,7 +581,7 @@ class SparseFeatureCrossOp : public OpKernel {
columns,
int batch_index) {
int64 cross_count = 1;
- for (int i = 0; i < columns.size(); i++) {
+ for (size_t i = 0; i < columns.size(); i++) {
const auto feature_count = columns[i]->FeatureCount(batch_index);
// If one column is missing any feature, there won't be any cross.
if (feature_count == 0) {
diff --git a/tensorflow/contrib/layers/python/layers/embedding_ops.py b/tensorflow/contrib/layers/python/layers/embedding_ops.py
index f8f4122d1d..b62e3050cd 100644
--- a/tensorflow/contrib/layers/python/layers/embedding_ops.py
+++ b/tensorflow/contrib/layers/python/layers/embedding_ops.py
@@ -871,7 +871,7 @@ def _embedding_lookup_with_distributed_aggregation(params,
p_segment_ids = array_ops.gather(segment_ids, pindices[p])
# Number the p_segment_ids to meet segment_sum's requirements. Note
# that unique_p_segment_ids contains unique segment ids of this
- # partiton and these ids' order is unchanged.
+ # partition and these ids' order is unchanged.
unique_p_segment_ids, unique_p_segment_idx = array_ops.unique(
p_segment_ids)
partitioned_segment_ids.append(unique_p_segment_ids)
diff --git a/tensorflow/contrib/layers/python/layers/feature_column.py b/tensorflow/contrib/layers/python/layers/feature_column.py
index 68159fe9b9..4cbd198c02 100644
--- a/tensorflow/contrib/layers/python/layers/feature_column.py
+++ b/tensorflow/contrib/layers/python/layers/feature_column.py
@@ -165,7 +165,7 @@ class _LinearEmbeddingLookupArguments(
"combiner"])):
"""Represents the information needed from a column for embedding lookup.
- Used to to compute DNN inputs and weighted sum.
+ Used to compute DNN inputs and weighted sum.
"""
pass
@@ -184,7 +184,7 @@ class _DeepEmbeddingLookupArguments(
"trainable"])):
"""Represents the information needed from a column for embedding lookup.
- Used to to compute DNN inputs and weighted sum.
+ Used to compute DNN inputs and weighted sum.
"""
pass
diff --git a/tensorflow/contrib/layers/python/layers/layers.py b/tensorflow/contrib/layers/python/layers/layers.py
index ed4b723ca7..8b3ccea995 100644
--- a/tensorflow/contrib/layers/python/layers/layers.py
+++ b/tensorflow/contrib/layers/python/layers/layers.py
@@ -938,7 +938,7 @@ def convolution(inputs,
with "NC".
num_outputs: Integer, the number of output filters.
kernel_size: A sequence of N positive integers specifying the spatial
- dimensions of of the filters. Can be a single integer to specify the same
+ dimensions of the filters. Can be a single integer to specify the same
value for all spatial dimensions.
stride: A sequence of N positive integers specifying the stride at which to
compute output. Can be a single integer to specify the same value for all
diff --git a/tensorflow/contrib/layers/python/layers/layers_test.py b/tensorflow/contrib/layers/python/layers/layers_test.py
index 15809ea180..2d08a0cb91 100644
--- a/tensorflow/contrib/layers/python/layers/layers_test.py
+++ b/tensorflow/contrib/layers/python/layers/layers_test.py
@@ -1493,12 +1493,12 @@ class PartialFlattenTest(test.TestCase):
def testSparsePartialFlatten(self):
"""Test `_inner_flatten` on `SparseTensor`s."""
- shape = [4, 3, 11, 6, 1, 3]
+ shape = [4, 3, 11, 6]
np.random.seed(10301)
random_ = np.random.rand(*shape)
indices, values, _ = _sparsify(random_)
- for new_rank in [1, 2, 3, 4, 5]:
+ for new_rank in [1, 2, 3]:
expected_shape = (shape[:new_rank - 1] + [np.prod(shape[new_rank - 1:])])
reshaped_random_ = np.reshape(random_, expected_shape)
expected_indices, expected_values, _ = _sparsify(reshaped_random_)
diff --git a/tensorflow/contrib/learn/python/learn/experiment.py b/tensorflow/contrib/learn/python/learn/experiment.py
index 3b6399c7e6..475f5beefd 100644
--- a/tensorflow/contrib/learn/python/learn/experiment.py
+++ b/tensorflow/contrib/learn/python/learn/experiment.py
@@ -525,7 +525,7 @@ class Experiment(object):
differences in resource control. First, the resources (e.g., memory) used
by training will be released before evaluation (`train_and_evaluate` takes
double resources). Second, more checkpoints will be saved as a checkpoint
- is generated at the end of each trainning iteration.
+ is generated at the end of each training iteration.
3. As the estimator.train starts from scratch (new graph, new states for
input, etc) at each iteration, it is recommended to have the
diff --git a/tensorflow/contrib/makefile/create_ios_frameworks.sh b/tensorflow/contrib/makefile/create_ios_frameworks.sh
index 2ad095b397..2bbde6aa88 100644
--- a/tensorflow/contrib/makefile/create_ios_frameworks.sh
+++ b/tensorflow/contrib/makefile/create_ios_frameworks.sh
@@ -79,7 +79,7 @@ cd $SCRIPT_DIR/gen/proto
tar cf $FW_DIR_TFCORE_HDRS/tmp.tar tensorflow
cd $FW_DIR_TFCORE_HDRS
tar xf tmp.tar
-# Dont include the auto downloaded/generated to build this library
+# Don't include the auto downloaded/generated to build this library
rm -rf tensorflow/contrib/makefile
rm -f tmp.tar
diff --git a/tensorflow/contrib/seq2seq/python/ops/attention_wrapper.py b/tensorflow/contrib/seq2seq/python/ops/attention_wrapper.py
index 0b1692ef2e..cd65a54b83 100644
--- a/tensorflow/contrib/seq2seq/python/ops/attention_wrapper.py
+++ b/tensorflow/contrib/seq2seq/python/ops/attention_wrapper.py
@@ -283,7 +283,7 @@ def _luong_score(query, keys, scale):
raise ValueError(
"Incompatible or unknown inner dimensions between query and keys. "
"Query (%s) has units: %s. Keys (%s) have units: %s. "
- "Perhaps you need to set num_units to the the keys' dimension (%s)?"
+ "Perhaps you need to set num_units to the keys' dimension (%s)?"
% (query, depth, keys, key_units, key_units))
dtype = query.dtype
diff --git a/tensorflow/contrib/slim/README.md b/tensorflow/contrib/slim/README.md
index 4bde661698..c0aa6d445a 100644
--- a/tensorflow/contrib/slim/README.md
+++ b/tensorflow/contrib/slim/README.md
@@ -775,7 +775,7 @@ images, labels = LoadTestData(...)
predictions = MyModel(images)
mae_value_op, mae_update_op = slim.metrics.streaming_mean_absolute_error(predictions, labels)
-mre_value_op, mre_update_op = slim.metrics.streaming_mean_relative_error(predictions, labels, labels)
+mre_value_op, mre_update_op = slim.metrics.streaming_mean_relative_error(predictions, labels)
pl_value_op, pl_update_op = slim.metrics.percentage_less(mean_relative_errors, 0.3)
```
diff --git a/tensorflow/contrib/tensor_forest/client/random_forest.py b/tensorflow/contrib/tensor_forest/client/random_forest.py
index 47685df4a5..1221165baa 100644
--- a/tensorflow/contrib/tensor_forest/client/random_forest.py
+++ b/tensorflow/contrib/tensor_forest/client/random_forest.py
@@ -315,7 +315,7 @@ class TensorForestEstimator(estimator.Estimator):
though training might be distributed.
version: String indicating TensorForest version to use, for backward
compatibility. Either 'v2', 'v4', or None to let system pick.
- Overrides grpah_builder_class.
+ Overrides graph_builder_class.
Returns:
A `TensorForestEstimator` instance.
diff --git a/tensorflow/contrib/tensor_forest/kernels/v4/grow_stats.h b/tensorflow/contrib/tensor_forest/kernels/v4/grow_stats.h
index 6702b81c79..ba73d1d246 100644
--- a/tensorflow/contrib/tensor_forest/kernels/v4/grow_stats.h
+++ b/tensorflow/contrib/tensor_forest/kernels/v4/grow_stats.h
@@ -109,7 +109,7 @@ class GrowStats {
const TensorForestParams& params_;
- // We cache these beacuse they're used often.
+ // We cache these because they're used often.
const int split_after_samples_;
const int num_splits_to_consider_;
diff --git a/tensorflow/contrib/timeseries/python/timeseries/math_utils.py b/tensorflow/contrib/timeseries/python/timeseries/math_utils.py
index e65e3eab3d..c70da3e082 100644
--- a/tensorflow/contrib/timeseries/python/timeseries/math_utils.py
+++ b/tensorflow/contrib/timeseries/python/timeseries/math_utils.py
@@ -689,11 +689,11 @@ class InputStatisticsFromMiniBatch(object):
values = features[TrainEvalFeatures.VALUES]
else:
# times and values may not be available, for example during prediction. We
- # still need to retreive our variables so that they can be read from, even
+ # still need to retrieve our variables so that they can be read from, even
# if we're not going to update them.
times = None
values = None
- # Create/retreive variables representing input statistics, initialized
+ # Create/retrieve variables representing input statistics, initialized
# without data to avoid deadlocking if variables are initialized before
# queue runners are started.
with variable_scope.variable_scope("input_statistics", use_resource=True):
diff --git a/tensorflow/contrib/timeseries/python/timeseries/state_management.py b/tensorflow/contrib/timeseries/python/timeseries/state_management.py
index ba51a82f4c..dc8f8fdb92 100644
--- a/tensorflow/contrib/timeseries/python/timeseries/state_management.py
+++ b/tensorflow/contrib/timeseries/python/timeseries/state_management.py
@@ -196,7 +196,7 @@ class ChainingStateManager(_OverridableStateManager):
return time // self._state_saving_interval
def _get_cached_states(self, times):
- """Retreive cached states for a batch of times."""
+ """Retrieve cached states for a batch of times."""
read_chunk_numbers = self._get_chunk_number(times)
looked_up_state = list(self._cached_states.lookup(
math_ops.cast(read_chunk_numbers, dtypes.int64)))
@@ -242,7 +242,7 @@ class ChainingStateManager(_OverridableStateManager):
# written to the next bucket). This assumes fixed missing times (i.e. if we
# were presented with times [10, 50] we will never see times [30, 50]).
#
- # TODO(allenl): Retreive the highest time less than the current time rather
+ # TODO(allenl): Retrieve the highest time less than the current time rather
# than relying on fixed bucketing.
write_chunk_numbers = math_ops.maximum(
self._get_chunk_number(array_ops.concat(
diff --git a/tensorflow/contrib/timeseries/python/timeseries/state_space_models/filtering_postprocessor.py b/tensorflow/contrib/timeseries/python/timeseries/state_space_models/filtering_postprocessor.py
index 163819ae2f..7fa538a16e 100644
--- a/tensorflow/contrib/timeseries/python/timeseries/state_space_models/filtering_postprocessor.py
+++ b/tensorflow/contrib/timeseries/python/timeseries/state_space_models/filtering_postprocessor.py
@@ -150,7 +150,7 @@ class StateInterpolatingAnomalyDetector(FilteringStepPostprocessor):
This is simply Bayes' theorem, where p(data | anomaly) is the
alternative/anomaly distribution, p(data | not anomaly) is the model's
predicted distribution, and anomaly_prior_probability is the prior probability
- of an anomaly occuring (user-specified, defaulting to 1%).
+ of an anomaly occurring (user-specified, defaulting to 1%).
Rather than computing p(anomaly | data) directly, we use the odds ratio:
diff --git a/tensorflow/contrib/timeseries/python/timeseries/state_space_models/structural_ensemble.py b/tensorflow/contrib/timeseries/python/timeseries/state_space_models/structural_ensemble.py
index 26ab726591..a7a80a8e3e 100644
--- a/tensorflow/contrib/timeseries/python/timeseries/state_space_models/structural_ensemble.py
+++ b/tensorflow/contrib/timeseries/python/timeseries/state_space_models/structural_ensemble.py
@@ -70,7 +70,7 @@ class StructuralEnsemble(state_space_model.StateSpaceIndependentEnsemble):
`observation_noise`, `level_noise`, `trend noise`, `seasonality_noise`, and
`transient` are (typically scalar) Gaussian random variables whose variance is
- learned from data, and that variance is not time dependant in this
+ learned from data, and that variance is not time dependent in this
implementation. Level noise is optional due to its similarity with observation
noise in some cases. Seasonality is enforced by constraining a full cycle of
seasonal variables to have zero expectation, allowing seasonality to adapt
diff --git a/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py b/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py
index 193d14e1ce..24a3d01272 100644
--- a/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py
+++ b/tensorflow/contrib/tpu/python/tpu/tpu_estimator.py
@@ -544,7 +544,7 @@ def _convert_model_fn_to_train_step(model_fn, dequeue_fn, mode, run_config,
# TODO(xiejw): how to do we support hook and savers in the original
# model_fn. Realistically, the original
- # model_fn will be excuted on TPU chips in a replica way. The hooks
+ # model_fn will be executed on TPU chips in a replica way. The hooks
# returned by the model_fn cannot be supported at all. If we have to,
# the graph construction part in the model_fn should be separated from the
# control part (such as hooks and savers). By that the graph construction
diff --git a/tensorflow/contrib/tpu/python/tpu/tpu_feed.py b/tensorflow/contrib/tpu/python/tpu/tpu_feed.py
index c955de524c..3d0a532010 100644
--- a/tensorflow/contrib/tpu/python/tpu/tpu_feed.py
+++ b/tensorflow/contrib/tpu/python/tpu/tpu_feed.py
@@ -298,7 +298,7 @@ class InfeedQueue(object):
input_tensors is a list of lists of Tensors whose types and shapes are used
to set the queue configuration. The length of the outer list is the number
of shards required, and each inner list is the tuple of Tensors to use to
- determine the types and shapes of the correponding shard. This method
+ determine the types and shapes of the corresponding shard. This method
depends on the shard dimension, and calling it freezes the shard policy.
Args:
diff --git a/tensorflow/contrib/training/python/training/bucket_ops.py b/tensorflow/contrib/training/python/training/bucket_ops.py
index 7e293da551..5523cc375f 100644
--- a/tensorflow/contrib/training/python/training/bucket_ops.py
+++ b/tensorflow/contrib/training/python/training/bucket_ops.py
@@ -88,7 +88,7 @@ def bucket(tensors,
This function is implemented using several queues. A `QueueRunner` for the
queues is added to the current `Graph`'s `QUEUE_RUNNER` collection.
- As the returned tensors are the result of of a dequeue operation, evaluating
+ As the returned tensors are the result of a dequeue operation, evaluating
them will throw a `tf.errors.OutOfRangeError` when the input queue is
exhausted. If these tensors are feeding another input queue, its queue runner
will catch this exception, however, if they are used in your main thread
diff --git a/tensorflow/contrib/training/python/training/evaluation_test.py b/tensorflow/contrib/training/python/training/evaluation_test.py
index babd2239b6..b07039916c 100644
--- a/tensorflow/contrib/training/python/training/evaluation_test.py
+++ b/tensorflow/contrib/training/python/training/evaluation_test.py
@@ -329,7 +329,7 @@ class EvaluateRepeatedlyTest(test.TestCase):
if not gfile.Exists(checkpoint_dir):
gfile.MakeDirs(checkpoint_dir)
- # We need a variable that that the saver will try to restore.
+ # We need a variable that the saver will try to restore.
variables.get_or_create_global_step()
# Run with placeholders. If we actually try to evaluate this, we'd fail
@@ -394,7 +394,7 @@ class EvaluateRepeatedlyTest(test.TestCase):
'evaluate_with_eval_feed_dict')
self._train_model(checkpoint_dir, num_steps=1)
- # We need a variable that that the saver will try to restore.
+ # We need a variable that the saver will try to restore.
variables.get_or_create_global_step()
# Create a variable and an eval op that increments it with a placeholder.
diff --git a/tensorflow/contrib/verbs/rdma.cc b/tensorflow/contrib/verbs/rdma.cc
index 6f3a616fe8..445cbe290a 100644
--- a/tensorflow/contrib/verbs/rdma.cc
+++ b/tensorflow/contrib/verbs/rdma.cc
@@ -761,8 +761,8 @@ void RdmaTensorBuffer::SendNextItem() {
(buffer_size > size_ && local_status_ == idle &&
remote_status_ == idle)) {
if ((local_status_ != none) && (buffer_size > size_)) {
- CHECK(rm.data_type_ == DT_STRING)
- << "Only string tensor allows to change size";
+ VLOG(2) << "Extend RDMA buffer from " << size_ << " to "
+ << buffer_size;
}
CreateCPUBuffer(buffer_size, false);
mu_.unlock();
@@ -782,11 +782,13 @@ void RdmaTensorBuffer::SendNextItem() {
// local/remote_status_ won't be set back to idle
// unitl Write() is successful
mu_.unlock();
- CHECK((buffer_size == size_ && rm.data_type_ != DT_STRING) ||
- (buffer_size <= size_ && rm.data_type_ == DT_STRING))
- << "tensor and buffer size do not agree!"
- << " buffer_size = " << size_
- << " requested tensor size = " << buffer_size << in.DebugString();
+ if (!((buffer_size == size_ && rm.data_type_ != DT_STRING) ||
+ (buffer_size <= size_ && rm.data_type_ == DT_STRING))) {
+ VLOG(2) << "Tensor and buffer size do not agree,"
+ << " buffer_size = " << size_
+ << " requested tensor size = "
+ << buffer_size << in.DebugString();
+ }
uint32_t imm_data = LookupBufferIndex(key);
rm.type_ = RDMA_MESSAGE_TENSOR_WRITE;
string message = RdmaMessage::CreateMessage(rm);
diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD
index a969a39edc..9411377733 100644
--- a/tensorflow/core/BUILD
+++ b/tensorflow/core/BUILD
@@ -1221,6 +1221,9 @@ LIB_INTERNAL_WINDOWS_DEPS = glob(
"platform/*.cc",
"platform/profile_utils/**/*.h",
"platform/profile_utils/**/*.cc",
+ ] + [
+ "framework/resource_handle.h",
+ "framework/resource_handle.cc",
],
exclude = [
"**/*test*",
@@ -1250,7 +1253,6 @@ cc_library(
"platform/*.cc",
"platform/profile_utils/**/*.h",
"platform/profile_utils/**/*.cc",
- ] + [
"framework/resource_handle.h",
"framework/resource_handle.cc",
],
diff --git a/tensorflow/core/framework/op.cc b/tensorflow/core/framework/op.cc
index fe333dc9ff..4f5a1f80a0 100644
--- a/tensorflow/core/framework/op.cc
+++ b/tensorflow/core/framework/op.cc
@@ -77,9 +77,10 @@ Status OpRegistry::LookUp(const string& op_type_name,
if (first_unregistered) {
OpList op_list;
Export(true, &op_list);
- VLOG(1) << "All registered Ops:";
- for (const auto& op : op_list.op()) {
- VLOG(1) << SummarizeOpDef(op);
+ if (VLOG_IS_ON(3)) {
+ LOG(INFO) << "All registered Ops:";
+ for (const auto& op : op_list.op())
+ LOG(INFO) << SummarizeOpDef(op);
}
first_unregistered = false;
}
diff --git a/tensorflow/core/framework/op_gen_lib.cc b/tensorflow/core/framework/op_gen_lib.cc
index cedfd6fc9c..143da996a1 100644
--- a/tensorflow/core/framework/op_gen_lib.cc
+++ b/tensorflow/core/framework/op_gen_lib.cc
@@ -73,7 +73,7 @@ bool ConsumeEquals(StringPiece* description) {
return false;
}
-// Split `*orig` into two pieces at the first occurence of `split_ch`.
+// Split `*orig` into two pieces at the first occurrence of `split_ch`.
// Returns whether `split_ch` was found. Afterwards, `*before_split`
// contains the maximum prefix of the input `*orig` that doesn't
// contain `split_ch`, and `*orig` contains everything after the
diff --git a/tensorflow/core/framework/op_kernel.h b/tensorflow/core/framework/op_kernel.h
index 1b716c5a5a..bf52c53b88 100644
--- a/tensorflow/core/framework/op_kernel.h
+++ b/tensorflow/core/framework/op_kernel.h
@@ -716,7 +716,7 @@ class OpKernelContext {
StringPiece output_name, const TensorShape& output_shape,
Tensor** output) TF_MUST_USE_RESULT;
- // Tries to reuse one of of the inputs given in input_indices as a temporary.
+ // Tries to reuse one of the inputs given in input_indices as a temporary.
// If none of the given inputs can be forwarded, calls
// allocate_temp() to allocate a new temporary buffer.
Status forward_input_or_allocate_temp(
diff --git a/tensorflow/core/framework/queue_interface.h b/tensorflow/core/framework/queue_interface.h
index baddf0bbfa..4aeaab3d9b 100644
--- a/tensorflow/core/framework/queue_interface.h
+++ b/tensorflow/core/framework/queue_interface.h
@@ -77,6 +77,9 @@ class QueueInterface : public ResourceBase {
virtual void Close(OpKernelContext* ctx, bool cancel_pending_enqueues,
DoneCallback callback) = 0;
+ // Returns true if a given queue is closed and false if it is open.
+ virtual bool is_closed() const = 0;
+
// Assuming *this represents a shared queue, verify that it matches
// another instantiation indicated by node_def.
virtual Status MatchesNodeDef(const NodeDef& node_def) = 0;
diff --git a/tensorflow/core/graph/graph.cc b/tensorflow/core/graph/graph.cc
index 9691326c99..a840ef39d2 100644
--- a/tensorflow/core/graph/graph.cc
+++ b/tensorflow/core/graph/graph.cc
@@ -31,7 +31,7 @@ namespace tensorflow {
const int Graph::kControlSlot = -1;
-struct NodeProperties {
+class NodeProperties {
public:
NodeProperties(const OpDef* op_def, const NodeDef& node_def,
const DataTypeSlice inputs, const DataTypeSlice outputs)
diff --git a/tensorflow/core/grappler/clusters/single_machine.cc b/tensorflow/core/grappler/clusters/single_machine.cc
index 58b9fc6429..a1531f1cfc 100644
--- a/tensorflow/core/grappler/clusters/single_machine.cc
+++ b/tensorflow/core/grappler/clusters/single_machine.cc
@@ -158,7 +158,7 @@ Status SingleMachine::Run(const GraphDef& graph_def,
// Also clear the timeline to save memory
init_metadata_.clear_step_stats();
}
- for (int i = 0; i < queue_runner_defs_.size(); ++i) {
+ for (size_t i = 0; i < queue_runner_defs_.size(); ++i) {
std::unique_ptr<QueueRunner> queue_runner;
TF_RETURN_IF_ERROR(QueueRunner::New(queue_runner_defs_[i],
coordinator_.get(), &queue_runner));
diff --git a/tensorflow/core/grappler/costs/graph_properties.cc b/tensorflow/core/grappler/costs/graph_properties.cc
index cd673a64a0..e29f32b270 100644
--- a/tensorflow/core/grappler/costs/graph_properties.cc
+++ b/tensorflow/core/grappler/costs/graph_properties.cc
@@ -141,7 +141,7 @@ Status GraphProperties::MergeEnqueueShapesAndTypes(
"Enqueue nodes mixed number of tensors: ", shapes_and_types.size(),
" vs ", queue_shapes_and_types->size());
}
- for (int i = 0; i < shapes_and_types.size(); ++i) {
+ for (size_t i = 0; i < shapes_and_types.size(); ++i) {
const ShapeAndType& a = shapes_and_types[i];
ShapeAndType& b = (*queue_shapes_and_types)[i];
if (a.dtype != b.dtype) {
@@ -163,7 +163,7 @@ Status GraphProperties::RelaxEnqueueShapesAndMergeTypes(
"Enqueue nodes mixed number of tensors: ", shapes_and_types.size(),
" vs ", queue_shapes_and_types->size());
}
- for (int i = 0; i < shapes_and_types.size(); ++i) {
+ for (size_t i = 0; i < shapes_and_types.size(); ++i) {
const ShapeAndType& a = shapes_and_types[i];
ShapeAndType& b = (*queue_shapes_and_types)[i];
if (a.dtype != b.dtype) {
diff --git a/tensorflow/core/grappler/costs/virtual_scheduler.cc b/tensorflow/core/grappler/costs/virtual_scheduler.cc
index 11650cb6a2..15ebef188f 100644
--- a/tensorflow/core/grappler/costs/virtual_scheduler.cc
+++ b/tensorflow/core/grappler/costs/virtual_scheduler.cc
@@ -365,7 +365,7 @@ NodeState& VirtualScheduler::GetNodeStateOrCreateIt(const NodeDef* node) {
// Initialize output port related data:
// Assume the size of OutputProperties represents the number of output ports
// of this node.
- for (int i = 0; i < node_state.output_properties.size(); ++i) {
+ for (size_t i = 0; i < node_state.output_properties.size(); ++i) {
node_state.time_no_references[i] = Costs::Duration::max();
node_state.num_outputs_executed[i] = 0;
// Populate an empty vector for each port. The caller will add nodes
diff --git a/tensorflow/core/grappler/optimizers/constant_folding.cc b/tensorflow/core/grappler/optimizers/constant_folding.cc
index 63159dc3aa..715b6e97d2 100644
--- a/tensorflow/core/grappler/optimizers/constant_folding.cc
+++ b/tensorflow/core/grappler/optimizers/constant_folding.cc
@@ -396,7 +396,7 @@ Status ConstantFolding::EvaluateOneFoldable(const NodeDef& node,
if (output_tensors.empty()) {
Status(error::INVALID_ARGUMENT, "Expected at least one output.");
}
- for (int i = 0; i < output_tensors.size(); i++) {
+ for (size_t i = 0; i < output_tensors.size(); i++) {
string node_name = AddPrefixToNodeName(node.name(), kConstantFoldingConst);
if (output_tensors.size() > 1) {
node_name = strings::StrCat(node_name, "-", i);
diff --git a/tensorflow/core/kernels/BUILD b/tensorflow/core/kernels/BUILD
index 96a7999c11..6eee2e16eb 100644
--- a/tensorflow/core/kernels/BUILD
+++ b/tensorflow/core/kernels/BUILD
@@ -32,6 +32,7 @@ load(
"tf_kernel_library",
"tf_mkl_kernel_library",
"cc_header_only_library",
+ "if_not_windows",
)
load("@local_config_sycl//sycl:build_defs.bzl", "if_sycl")
load("//tensorflow:tensorflow.bzl", "tf_cuda_cc_test")
@@ -231,7 +232,7 @@ cc_library(
name = "ops_util",
srcs = ["ops_util.cc"],
hdrs = ["ops_util.h"],
- copts = ["-Wno-sign-compare"],
+ copts = if_not_windows(["-Wno-sign-compare"]),
deps = [
"//tensorflow/core:framework",
"//tensorflow/core:lib",
@@ -344,7 +345,7 @@ cc_library(
name = "save_restore_tensor",
srcs = ["save_restore_tensor.cc"],
hdrs = ["save_restore_tensor.h"],
- copts = ["-Wno-sign-compare"],
+ copts = if_not_windows(["-Wno-sign-compare"]),
deps = [
":bounds_check",
"//tensorflow/core:framework",
@@ -1222,6 +1223,7 @@ tf_kernel_library(
],
visibility = ["//visibility:private"],
deps = [
+ ":ops_util",
"//tensorflow/core:framework",
"//tensorflow/core/kernels:conv_ops",
"//third_party/eigen3",
@@ -3219,6 +3221,7 @@ cc_library(
":sparse_reduce_op",
":sparse_reorder_op",
":sparse_reshape_op",
+ ":sparse_slice_op",
":sparse_softmax",
":sparse_sparse_binary_op_shared",
":sparse_split_op",
@@ -3302,6 +3305,12 @@ tf_kernel_library(
)
tf_kernel_library(
+ name = "sparse_slice_op",
+ prefix = "sparse_slice_op",
+ deps = SPARSE_DEPS,
+)
+
+tf_kernel_library(
name = "sparse_softmax",
prefix = "sparse_softmax",
deps = SPARSE_DEPS,
diff --git a/tensorflow/core/kernels/barrier_ops.cc b/tensorflow/core/kernels/barrier_ops.cc
index 83633a1dd9..3b880a9635 100644
--- a/tensorflow/core/kernels/barrier_ops.cc
+++ b/tensorflow/core/kernels/barrier_ops.cc
@@ -413,7 +413,7 @@ class Barrier : public ResourceBase {
}
queue_closed_ = true;
if (cancel_pending_enqueues) queue_cancelled_ = true;
- if (!ready_queue_->closed()) {
+ if (!ready_queue_->is_closed()) {
ready_queue_->Close(ctx, cancel_pending_enqueues, callback);
}
}
diff --git a/tensorflow/core/kernels/cast_op_impl.h b/tensorflow/core/kernels/cast_op_impl.h
index 1ee0796ac1..6309e4a4dc 100644
--- a/tensorflow/core/kernels/cast_op_impl.h
+++ b/tensorflow/core/kernels/cast_op_impl.h
@@ -45,20 +45,23 @@ struct CastFunctor<Eigen::SyclDevice, O, I> {
} // namespace functor
-#define CURRY_TYPES3(FN, arg0, arg1) \
- FN(arg0, arg1, bool); \
- FN(arg0, arg1, uint8); \
- FN(arg0, arg1, int8); \
- FN(arg0, arg1, uint16); \
- FN(arg0, arg1, int16); \
- FN(arg0, arg1, int32); \
- FN(arg0, arg1, int64); \
- FN(arg0, arg1, Eigen::half); \
- FN(arg0, arg1, float); \
- FN(arg0, arg1, double); \
- FN(arg0, arg1, std::complex<float>); \
+#define CURRY_TYPES3_NO_HALF(FN, arg0, arg1) \
+ FN(arg0, arg1, bool); \
+ FN(arg0, arg1, uint8); \
+ FN(arg0, arg1, int8); \
+ FN(arg0, arg1, uint16); \
+ FN(arg0, arg1, int16); \
+ FN(arg0, arg1, int32); \
+ FN(arg0, arg1, int64); \
+ FN(arg0, arg1, float); \
+ FN(arg0, arg1, double); \
+ FN(arg0, arg1, std::complex<float>); \
FN(arg0, arg1, std::complex<double>)
+#define CURRY_TYPES3(FN, arg0, arg1) \
+ CURRY_TYPES3_NO_HALF(FN, arg0, arg1) \
+ FN(arg0, arg1, Eigen::half);
+
#define CAST_CASE(DEVICE, IN, OUT) \
if (DataTypeToEnum<OUT>::value == dst_dtype) { \
return [](OpKernelContext* ctx, const Tensor& inp, Tensor* out) { \
@@ -155,6 +158,15 @@ std::function<void(OpKernelContext*, const Tensor&, Tensor*)>
GetSyclCastFromBool(DataType dst_dtype);
std::function<void(OpKernelContext*, const Tensor&, Tensor*)>
+GetSyclCastFromUint8(DataType dst_dtype);
+
+std::function<void(OpKernelContext*, const Tensor&, Tensor*)>
+GetSyclCastFromUint16(DataType dst_dtype);
+
+std::function<void(OpKernelContext*, const Tensor&, Tensor*)>
+GetSyclCastFromInt16(DataType dst_dtype);
+
+std::function<void(OpKernelContext*, const Tensor&, Tensor*)>
GetSyclCastFromInt32(DataType dst_dtype);
std::function<void(OpKernelContext*, const Tensor&, Tensor*)>
@@ -165,10 +177,8 @@ GetSyclCastFromFloat(DataType dst_dtype);
std::function<void(OpKernelContext*, const Tensor&, Tensor*)>
GetSyclCastFromDouble(DataType dst_dtype);
-
-#endif // TENSORFLOW_USE_SYCL
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
#endif // THIRD_PARTY_TENSORFLOW_CORE_KERNELS_CAST_OP_IMPL_H_
-
diff --git a/tensorflow/core/kernels/cast_op_impl_bool.cc b/tensorflow/core/kernels/cast_op_impl_bool.cc
index a13f163009..5cd63f2458 100644
--- a/tensorflow/core/kernels/cast_op_impl_bool.cc
+++ b/tensorflow/core/kernels/cast_op_impl_bool.cc
@@ -38,10 +38,9 @@ GetGpuCastFromBool(DataType dst_dtype) {
typedef Eigen::SyclDevice SYCLDevice;
std::function<void(OpKernelContext*, const Tensor&, Tensor*)>
GetSyclCastFromBool(DataType dst_dtype) {
- CURRY_TYPES3(CAST_CASE, SYCLDevice, bool);
+ CURRY_TYPES3_NO_HALF(CAST_CASE, SYCLDevice, bool);
return nullptr;
}
-#endif // TENSORFLOW_USE_SYCL
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
-
diff --git a/tensorflow/core/kernels/cast_op_impl_double.cc b/tensorflow/core/kernels/cast_op_impl_double.cc
index fdc8d51158..1203f066a2 100644
--- a/tensorflow/core/kernels/cast_op_impl_double.cc
+++ b/tensorflow/core/kernels/cast_op_impl_double.cc
@@ -38,10 +38,9 @@ GetGpuCastFromDouble(DataType dst_dtype) {
typedef Eigen::SyclDevice SYCLDevice;
std::function<void(OpKernelContext*, const Tensor&, Tensor*)>
GetSyclCastFromDouble(DataType dst_dtype) {
- CURRY_TYPES3(CAST_CASE, SYCLDevice, double);
+ CURRY_TYPES3_NO_HALF(CAST_CASE, SYCLDevice, double);
return nullptr;
}
-#endif // TENSORFLOW_USE_SYC
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
-
diff --git a/tensorflow/core/kernels/cast_op_impl_float.cc b/tensorflow/core/kernels/cast_op_impl_float.cc
index 1241dcd8f2..2ff9af21f2 100644
--- a/tensorflow/core/kernels/cast_op_impl_float.cc
+++ b/tensorflow/core/kernels/cast_op_impl_float.cc
@@ -53,10 +53,9 @@ GetGpuCastFromFloat(DataType dst_dtype) {
typedef Eigen::SyclDevice SYCLDevice;
std::function<void(OpKernelContext*, const Tensor&, Tensor*)>
GetSyclCastFromFloat(DataType dst_dtype) {
- CURRY_TYPES3(CAST_CASE, SYCLDevice, float);
+ CURRY_TYPES3_NO_HALF(CAST_CASE, SYCLDevice, float);
return nullptr;
}
-#endif // TENSORFLOW_USE_SYCL
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
-
diff --git a/tensorflow/core/kernels/cast_op_impl_int16.cc b/tensorflow/core/kernels/cast_op_impl_int16.cc
index 3c2d6185e3..f12d852e95 100644
--- a/tensorflow/core/kernels/cast_op_impl_int16.cc
+++ b/tensorflow/core/kernels/cast_op_impl_int16.cc
@@ -34,4 +34,13 @@ GetGpuCastFromInt16(DataType dst_dtype) {
}
#endif // GOOGLE_CUDA
+#ifdef TENSORFLOW_USE_SYCL
+typedef Eigen::SyclDevice SYCLDevice;
+std::function<void(OpKernelContext*, const Tensor&, Tensor*)>
+GetSyclCastFromInt16(DataType dst_dtype) {
+ CURRY_TYPES3_NO_HALF(CAST_CASE, SYCLDevice, int16);
+ return nullptr;
+}
+#endif // TENSORFLOW_USE_SYCL
+
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cast_op_impl_int32.cc b/tensorflow/core/kernels/cast_op_impl_int32.cc
index 69ed760455..2a4b27a12d 100644
--- a/tensorflow/core/kernels/cast_op_impl_int32.cc
+++ b/tensorflow/core/kernels/cast_op_impl_int32.cc
@@ -38,9 +38,9 @@ GetGpuCastFromInt32(DataType dst_dtype) {
typedef Eigen::SyclDevice SYCLDevice;
std::function<void(OpKernelContext*, const Tensor&, Tensor*)>
GetSyclCastFromInt32(DataType dst_dtype) {
- CURRY_TYPES3(CAST_CASE, SYCLDevice, int32);
+ CURRY_TYPES3_NO_HALF(CAST_CASE, SYCLDevice, int32);
return nullptr;
}
-#endif // TENSORFLOW_USE_SYCL
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cast_op_impl_int64.cc b/tensorflow/core/kernels/cast_op_impl_int64.cc
index 7a8363ca39..065defabbb 100644
--- a/tensorflow/core/kernels/cast_op_impl_int64.cc
+++ b/tensorflow/core/kernels/cast_op_impl_int64.cc
@@ -38,9 +38,9 @@ GetGpuCastFromInt64(DataType dst_dtype) {
typedef Eigen::SyclDevice SYCLDevice;
std::function<void(OpKernelContext*, const Tensor&, Tensor*)>
GetSyclCastFromInt64(DataType dst_dtype) {
- CURRY_TYPES3(CAST_CASE, SYCLDevice, int64);
+ CURRY_TYPES3_NO_HALF(CAST_CASE, SYCLDevice, int64);
return nullptr;
}
-#endif // TENSORFLOW_USE_SYCL
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cast_op_impl_int8.cc b/tensorflow/core/kernels/cast_op_impl_int8.cc
index 62971fa95c..8d678c4733 100644
--- a/tensorflow/core/kernels/cast_op_impl_int8.cc
+++ b/tensorflow/core/kernels/cast_op_impl_int8.cc
@@ -34,4 +34,13 @@ GetGpuCastFromInt8(DataType dst_dtype) {
}
#endif // GOOGLE_CUDA
+#ifdef TENSORFLOW_USE_SYCL
+typedef Eigen::SyclDevice SYCLDevice;
+std::function<void(OpKernelContext*, const Tensor&, Tensor*)>
+GetSyclCastFromInt8(DataType dst_dtype) {
+ CURRY_TYPES3_NO_HALF(CAST_CASE, SYCLDevice, int8);
+ return nullptr;
+}
+#endif // TENSORFLOW_USE_SYCL
+
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cast_op_impl_uint16.cc b/tensorflow/core/kernels/cast_op_impl_uint16.cc
index 529d9758f0..c917aaf7bd 100644
--- a/tensorflow/core/kernels/cast_op_impl_uint16.cc
+++ b/tensorflow/core/kernels/cast_op_impl_uint16.cc
@@ -34,4 +34,13 @@ GetGpuCastFromUint16(DataType dst_dtype) {
}
#endif // GOOGLE_CUDA
+#ifdef TENSORFLOW_USE_SYCL
+typedef Eigen::SyclDevice SYCLDevice;
+std::function<void(OpKernelContext*, const Tensor&, Tensor*)>
+GetSyclCastFromUint16(DataType dst_dtype) {
+ CURRY_TYPES3_NO_HALF(CAST_CASE, SYCLDevice, uint16);
+ return nullptr;
+}
+#endif // TENSORFLOW_USE_SYCL
+
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cast_op_impl_uint8.cc b/tensorflow/core/kernels/cast_op_impl_uint8.cc
index 1a5025b054..377c8ca953 100644
--- a/tensorflow/core/kernels/cast_op_impl_uint8.cc
+++ b/tensorflow/core/kernels/cast_op_impl_uint8.cc
@@ -34,4 +34,13 @@ GetGpuCastFromUint8(DataType dst_dtype) {
}
#endif // GOOGLE_CUDA
+#ifdef TENSORFLOW_USE_SYCL
+typedef Eigen::SyclDevice SYCLDevice;
+std::function<void(OpKernelContext*, const Tensor&, Tensor*)>
+GetSyclCastFromUint8(DataType dst_dtype) {
+ CURRY_TYPES3_NO_HALF(CAST_CASE, SYCLDevice, uint8);
+ return nullptr;
+}
+#endif // TENSORFLOW_USE_SYCL
+
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_abs.cc b/tensorflow/core/kernels/cwise_op_abs.cc
index 8cf1eac41e..5fd38d9dc2 100644
--- a/tensorflow/core/kernels/cwise_op_abs.cc
+++ b/tensorflow/core/kernels/cwise_op_abs.cc
@@ -22,17 +22,6 @@ REGISTER5(UnaryOp, CPU, "Abs", functor::abs, float, Eigen::half, double, int32,
REGISTER2(UnaryOp, CPU, "ComplexAbs", functor::abs, complex64, complex128);
#endif
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("Abs") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- UnaryOp<SYCLDevice, functor::abs<TYPE>>);
-REGISTER_SYCL_KERNEL(float);
-#undef REGISTER_SYCL_KERNEL
-#endif // TENSORFLOW_USE_SYCL
-
#if GOOGLE_CUDA
REGISTER4(UnaryOp, GPU, "Abs", functor::abs, float, Eigen::half, double, int64);
REGISTER2(UnaryOp, GPU, "ComplexAbs", functor::abs, complex64, complex128);
@@ -48,4 +37,13 @@ REGISTER_KERNEL_BUILDER(Name("Abs")
UnaryOp<CPUDevice, functor::abs<int32>>);
#endif
+#if TENSORFLOW_USE_SYCL
+REGISTER3(UnaryOp, SYCL, "Abs", functor::abs, float, double, int64);
+REGISTER_KERNEL_BUILDER(Name("Abs")
+ .Device(DEVICE_SYCL)
+ .HostMemory("x")
+ .HostMemory("y")
+ .TypeConstraint<int32>("T"),
+ UnaryOp<CPUDevice, functor::abs<int32>>);
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_acos.cc b/tensorflow/core/kernels/cwise_op_acos.cc
index 65801da3c7..12cc6c8bdd 100644
--- a/tensorflow/core/kernels/cwise_op_acos.cc
+++ b/tensorflow/core/kernels/cwise_op_acos.cc
@@ -18,19 +18,11 @@ limitations under the License.
namespace tensorflow {
REGISTER2(UnaryOp, CPU, "Acos", functor::acos, float, double);
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("Acos") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- UnaryOp<SYCLDevice, functor::acos<TYPE>>);
-REGISTER_SYCL_KERNEL(float);
-REGISTER_SYCL_KERNEL(double);
-#undef REGISTER_SYCL_KERNEL
-#endif // TENSORFLOW_USE_SYCL
-
#if GOOGLE_CUDA
REGISTER2(UnaryOp, GPU, "Acos", functor::acos, float, double);
#endif
+
+#if TENSORFLOW_USE_SYCL
+REGISTER2(UnaryOp, SYCL, "Acos", functor::acos, float, double);
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_acosh.cc b/tensorflow/core/kernels/cwise_op_acosh.cc
new file mode 100644
index 0000000000..7bdd8d22a3
--- /dev/null
+++ b/tensorflow/core/kernels/cwise_op_acosh.cc
@@ -0,0 +1,38 @@
+/* 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/kernels/cwise_ops_common.h"
+#include "tensorflow/core/kernels/cwise_ops_gradients.h"
+
+namespace tensorflow {
+REGISTER4(UnaryOp, CPU, "Acosh", functor::acosh, float, double,
+ complex64, complex128);
+
+#if TENSORFLOW_USE_SYCL
+#define REGISTER_SYCL_KERNEL(TYPE) \
+ REGISTER_KERNEL_BUILDER( \
+ Name("Acosh") \
+ .Device(DEVICE_SYCL) \
+ .TypeConstraint<TYPE>("T"), \
+ UnaryOp<SYCLDevice, functor::acosh<TYPE>>);
+REGISTER_SYCL_KERNEL(float);
+REGISTER_SYCL_KERNEL(double);
+#undef REGISTER_SYCL_KERNEL
+#endif // TENSORFLOW_USE_SYCL
+
+#if GOOGLE_CUDA
+REGISTER2(UnaryOp, GPU, "Acosh", functor::acosh, float, double);
+#endif
+} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_add_1.cc b/tensorflow/core/kernels/cwise_op_add_1.cc
index f6e9b59cf8..acf1f2ad49 100644
--- a/tensorflow/core/kernels/cwise_op_add_1.cc
+++ b/tensorflow/core/kernels/cwise_op_add_1.cc
@@ -19,26 +19,6 @@ namespace tensorflow {
REGISTER5(BinaryOp, CPU, "Add", functor::add, float, Eigen::half, double, int32,
int64);
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("Add") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- BinaryOp<SYCLDevice, functor::add<TYPE>>);
-REGISTER_SYCL_KERNEL(float);
-REGISTER_SYCL_KERNEL(double);
-#undef REGISTER_SYCL_KERNEL
-
-REGISTER_KERNEL_BUILDER(Name("Add")
- .Device(DEVICE_SYCL)
- .HostMemory("x")
- .HostMemory("y")
- .HostMemory("z")
- .TypeConstraint<int32>("T"),
- BinaryOp<CPUDevice, functor::add<int32>>);
-#endif // TENSORFLOW_USE_SYCL
-
#if GOOGLE_CUDA
REGISTER3(BinaryOp, GPU, "Add", functor::add, float, Eigen::half, double);
@@ -54,4 +34,15 @@ REGISTER_KERNEL_BUILDER(Name("Add")
BinaryOp<CPUDevice, functor::add<int32>>);
#endif
+
+#if TENSORFLOW_USE_SYCL
+REGISTER2(BinaryOp, SYCL, "Add", functor::add, float, double);
+REGISTER_KERNEL_BUILDER(Name("Add")
+ .Device(DEVICE_SYCL)
+ .HostMemory("x")
+ .HostMemory("y")
+ .HostMemory("z")
+ .TypeConstraint<int32>("T"),
+ BinaryOp<CPUDevice, functor::add<int32>>);
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_asin.cc b/tensorflow/core/kernels/cwise_op_asin.cc
index c9ebfe759b..c28e27d95a 100644
--- a/tensorflow/core/kernels/cwise_op_asin.cc
+++ b/tensorflow/core/kernels/cwise_op_asin.cc
@@ -18,19 +18,11 @@ limitations under the License.
namespace tensorflow {
REGISTER2(UnaryOp, CPU, "Asin", functor::asin, float, double);
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("Asin") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- UnaryOp<SYCLDevice, functor::asin<TYPE>>);
-REGISTER_SYCL_KERNEL(float);
-REGISTER_SYCL_KERNEL(double);
-#undef REGISTER_SYCL_KERNEL
-#endif // TENSORFLOW_USE_SYCL
-
#if GOOGLE_CUDA
REGISTER2(UnaryOp, GPU, "Asin", functor::asin, float, double);
#endif
+
+#if TENSORFLOW_USE_SYCL
+REGISTER2(UnaryOp, SYCL, "Asin", functor::asin, float, double);
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_asinh.cc b/tensorflow/core/kernels/cwise_op_asinh.cc
new file mode 100644
index 0000000000..e0644323c0
--- /dev/null
+++ b/tensorflow/core/kernels/cwise_op_asinh.cc
@@ -0,0 +1,38 @@
+/* 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/kernels/cwise_ops_common.h"
+#include "tensorflow/core/kernels/cwise_ops_gradients.h"
+
+namespace tensorflow {
+REGISTER4(UnaryOp, CPU, "Asinh", functor::asinh, float, double,
+ complex64, complex128);
+
+#if TENSORFLOW_USE_SYCL
+#define REGISTER_SYCL_KERNEL(TYPE) \
+ REGISTER_KERNEL_BUILDER( \
+ Name("Asinh") \
+ .Device(DEVICE_SYCL) \
+ .TypeConstraint<TYPE>("T"), \
+ UnaryOp<SYCLDevice, functor::asinh<TYPE>>);
+REGISTER_SYCL_KERNEL(float);
+REGISTER_SYCL_KERNEL(double);
+#undef REGISTER_SYCL_KERNEL
+#endif // TENSORFLOW_USE_SYC
+
+#if GOOGLE_CUDA
+REGISTER2(UnaryOp, GPU, "Asinh", functor::asinh, float, double);
+#endif
+} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_atan.cc b/tensorflow/core/kernels/cwise_op_atan.cc
index 72645b303f..7d73de4810 100644
--- a/tensorflow/core/kernels/cwise_op_atan.cc
+++ b/tensorflow/core/kernels/cwise_op_atan.cc
@@ -18,19 +18,11 @@ limitations under the License.
namespace tensorflow {
REGISTER2(UnaryOp, CPU, "Atan", functor::atan, float, double);
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("Atan") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- UnaryOp<SYCLDevice, functor::atan<TYPE>>);
-REGISTER_SYCL_KERNEL(float);
-REGISTER_SYCL_KERNEL(double);
-#undef REGISTER_SYCL_KERNEL
-#endif // TENSORFLOW_USE_SYCL
-
#if GOOGLE_CUDA
REGISTER2(UnaryOp, GPU, "Atan", functor::atan, float, double);
#endif
+
+#if TENSORFLOW_USE_SYCL
+REGISTER2(UnaryOp, SYCL, "Atan", functor::atan, float, double);
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_atanh.cc b/tensorflow/core/kernels/cwise_op_atanh.cc
new file mode 100644
index 0000000000..058f5140c5
--- /dev/null
+++ b/tensorflow/core/kernels/cwise_op_atanh.cc
@@ -0,0 +1,38 @@
+/* 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/kernels/cwise_ops_common.h"
+#include "tensorflow/core/kernels/cwise_ops_gradients.h"
+
+namespace tensorflow {
+REGISTER4(UnaryOp, CPU, "Atanh", functor::atanh, float, double,
+ complex64, complex128);
+
+#if TENSORFLOW_USE_SYCL
+#define REGISTER_SYCL_KERNEL(TYPE) \
+ REGISTER_KERNEL_BUILDER( \
+ Name("Atanh") \
+ .Device(DEVICE_SYCL) \
+ .TypeConstraint<TYPE>("T"), \
+ UnaryOp<SYCLDevice, functor::atanh<TYPE>>);
+REGISTER_SYCL_KERNEL(float);
+REGISTER_SYCL_KERNEL(double);
+#undef REGISTER_SYCL_KERNEL
+#endif // TENSORFLOW_USE_SYC
+
+#if GOOGLE_CUDA
+REGISTER2(UnaryOp, GPU, "Atanh", functor::atanh, float, double);
+#endif
+} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_ceil.cc b/tensorflow/core/kernels/cwise_op_ceil.cc
index c74e10576d..0111e9d5fd 100644
--- a/tensorflow/core/kernels/cwise_op_ceil.cc
+++ b/tensorflow/core/kernels/cwise_op_ceil.cc
@@ -18,19 +18,11 @@ limitations under the License.
namespace tensorflow {
REGISTER3(UnaryOp, CPU, "Ceil", functor::ceil, float, Eigen::half, double);
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("Ceil") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- UnaryOp<SYCLDevice, functor::ceil<TYPE>>);
-REGISTER_SYCL_KERNEL(float);
-REGISTER_SYCL_KERNEL(double);
-#undef REGISTER_SYCL_KERNEL
-#endif // TENSORFLOW_USE_SYCL
-
#if GOOGLE_CUDA
REGISTER3(UnaryOp, GPU, "Ceil", functor::ceil, float, Eigen::half, double);
#endif
+
+#if TENSORFLOW_USE_SYCL
+REGISTER2(UnaryOp, SYCL, "Ceil", functor::ceil, float, double);
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_cos.cc b/tensorflow/core/kernels/cwise_op_cos.cc
index 634c90adc6..d4b3b0e393 100644
--- a/tensorflow/core/kernels/cwise_op_cos.cc
+++ b/tensorflow/core/kernels/cwise_op_cos.cc
@@ -19,19 +19,11 @@ namespace tensorflow {
REGISTER5(UnaryOp, CPU, "Cos", functor::cos, float, Eigen::half, double,
complex64, complex128);
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("Cos") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- UnaryOp<SYCLDevice, functor::cos<TYPE>>);
-REGISTER_SYCL_KERNEL(float);
-REGISTER_SYCL_KERNEL(double);
-#undef REGISTER_SYCL_KERNEL
-#endif // TENSORFLOW_USE_SYCL
-
#if GOOGLE_CUDA
REGISTER3(UnaryOp, GPU, "Cos", functor::cos, float, Eigen::half, double);
#endif
+
+#ifdef TENSORFLOW_USE_SYCL
+REGISTER2(UnaryOp, SYCL, "Cos", functor::cos, float, double);
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_div.cc b/tensorflow/core/kernels/cwise_op_div.cc
index 1e2300832f..d44c1bf473 100644
--- a/tensorflow/core/kernels/cwise_op_div.cc
+++ b/tensorflow/core/kernels/cwise_op_div.cc
@@ -24,32 +24,6 @@ REGISTER5(BinaryOp, CPU, "TruncateDiv", functor::safe_div, uint8, uint16, int16,
int32, int64);
REGISTER5(BinaryOp, CPU, "RealDiv", functor::div, float, Eigen::half, double,
complex64, complex128);
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("Div") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- BinaryOp<SYCLDevice, functor::div<TYPE>>); \
- REGISTER_KERNEL_BUILDER( \
- Name("RealDiv") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- BinaryOp<SYCLDevice, functor::div<TYPE>>);
-REGISTER_SYCL_KERNEL(float)
-REGISTER_SYCL_KERNEL(double)
-#undef REGISTER_SYCL_KERNEL
-// A special GPU kernel for int32.
-// TODO(b/25387198): Also enable int32 in device memory. This kernel
-// registration requires all int32 inputs and outputs to be in host memory.
-REGISTER_KERNEL_BUILDER(Name("Div")
- .Device(DEVICE_SYCL)
- .HostMemory("x")
- .HostMemory("y")
- .HostMemory("z")
- .TypeConstraint<int32>("T"),
- BinaryOp<CPUDevice, functor::safe_div<int32>>);
-#endif // TENSORFLOW_USE_SYCL
#if GOOGLE_CUDA
REGISTER9(BinaryOp, GPU, "Div", functor::div, float, Eigen::half, double, uint8,
uint16, int16, int64, complex64, complex128);
@@ -70,4 +44,15 @@ REGISTER_KERNEL_BUILDER(Name("Div")
BinaryOp<CPUDevice, functor::safe_div<int32>>);
#endif
+#ifdef TENSORFLOW_USE_SYCL
+REGISTER2(BinaryOp, SYCL, "Div", functor::div, float, double);
+REGISTER2(BinaryOp, SYCL, "RealDiv", functor::div, float, double);
+REGISTER_KERNEL_BUILDER(Name("Div")
+ .Device(DEVICE_SYCL)
+ .HostMemory("x")
+ .HostMemory("y")
+ .HostMemory("z")
+ .TypeConstraint<int32>("T"),
+ BinaryOp<CPUDevice, functor::safe_div<int32>>);
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_equal_to_1.cc b/tensorflow/core/kernels/cwise_op_equal_to_1.cc
index 7049305deb..ea10ebe9a0 100644
--- a/tensorflow/core/kernels/cwise_op_equal_to_1.cc
+++ b/tensorflow/core/kernels/cwise_op_equal_to_1.cc
@@ -47,8 +47,8 @@ REGISTER_KERNEL_BUILDER(Name("Equal")
#endif
#ifdef TENSORFLOW_USE_SYCL
-REGISTER2(BinaryOp, SYCL, "Equal", functor::equal_to, float, double);
-
+REGISTER5(BinaryOp, SYCL, "Equal", functor::equal_to, float, double, uint8,
+ int8, int16);
REGISTER_KERNEL_BUILDER(Name("Equal")
.Device(DEVICE_SYCL)
.HostMemory("x")
diff --git a/tensorflow/core/kernels/cwise_op_exp.cc b/tensorflow/core/kernels/cwise_op_exp.cc
index 2e3a60cf79..9d4d654427 100644
--- a/tensorflow/core/kernels/cwise_op_exp.cc
+++ b/tensorflow/core/kernels/cwise_op_exp.cc
@@ -19,19 +19,11 @@ namespace tensorflow {
REGISTER5(UnaryOp, CPU, "Exp", functor::exp, float, Eigen::half, double,
complex64, complex128);
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("Exp") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- UnaryOp<SYCLDevice, functor::exp<TYPE>>);
-REGISTER_SYCL_KERNEL(float);
-REGISTER_SYCL_KERNEL(double);
-#undef REGISTER_SYCL_KERNEL
-#endif // TENSORFLOW_USE_SYCL
-
#if GOOGLE_CUDA
REGISTER3(UnaryOp, GPU, "Exp", functor::exp, float, Eigen::half, double);
#endif
+
+#if TENSORFLOW_USE_SYCL
+REGISTER2(UnaryOp, SYCL, "Exp", functor::exp, float, double);
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_expm1.cc b/tensorflow/core/kernels/cwise_op_expm1.cc
index 5573c2bcc2..4f72308006 100644
--- a/tensorflow/core/kernels/cwise_op_expm1.cc
+++ b/tensorflow/core/kernels/cwise_op_expm1.cc
@@ -22,6 +22,6 @@ REGISTER5(UnaryOp, CPU, "Expm1", functor::expm1, float, Eigen::half, double,
REGISTER3(UnaryOp, GPU, "Expm1", functor::expm1, float, Eigen::half, double);
#endif
#ifdef TENSORFLOW_USE_SYCL
-REGISTER(UnaryOp, SYCL, "Expm1", functor::expm1, float);
+REGISTER2(UnaryOp, SYCL, "Expm1", functor::expm1, float, double);
#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_floor.cc b/tensorflow/core/kernels/cwise_op_floor.cc
index 59e32d7f6f..5a142b9ce9 100644
--- a/tensorflow/core/kernels/cwise_op_floor.cc
+++ b/tensorflow/core/kernels/cwise_op_floor.cc
@@ -18,19 +18,10 @@ limitations under the License.
namespace tensorflow {
REGISTER3(UnaryOp, CPU, "Floor", functor::floor, float, Eigen::half, double);
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("Floor") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- UnaryOp<SYCLDevice, functor::floor<TYPE>>);
-REGISTER_SYCL_KERNEL(float);
-REGISTER_SYCL_KERNEL(double);
-#undef REGISTER_SYCL_KERNEL
-#endif // TENSORFLOW_USE_SYCL
-
#if GOOGLE_CUDA
REGISTER3(UnaryOp, GPU, "Floor", functor::floor, float, Eigen::half, double);
#endif
+#ifdef TENSORFLOW_USE_SYCL
+REGISTER2(UnaryOp, SYCL, "Floor", functor::floor, float, double);
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_gpu_acosh.cu.cc b/tensorflow/core/kernels/cwise_op_gpu_acosh.cu.cc
new file mode 100644
index 0000000000..a29c9a374d
--- /dev/null
+++ b/tensorflow/core/kernels/cwise_op_gpu_acosh.cu.cc
@@ -0,0 +1,27 @@
+/* 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.
+==============================================================================*/
+
+#if GOOGLE_CUDA
+
+#include "tensorflow/core/kernels/cwise_ops_gpu_common.cu.h"
+#include "tensorflow/core/kernels/cwise_ops_gpu_gradients.cu.h"
+
+namespace tensorflow {
+namespace functor {
+DEFINE_UNARY2(acosh, float, double);
+} // namespace functor
+} // namespace tensorflow
+
+#endif // GOOGLE_CUDA
diff --git a/tensorflow/core/kernels/cwise_op_gpu_asinh.cu.cc b/tensorflow/core/kernels/cwise_op_gpu_asinh.cu.cc
new file mode 100644
index 0000000000..c78f09e5e9
--- /dev/null
+++ b/tensorflow/core/kernels/cwise_op_gpu_asinh.cu.cc
@@ -0,0 +1,27 @@
+/* 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.
+==============================================================================*/
+
+#if GOOGLE_CUDA
+
+#include "tensorflow/core/kernels/cwise_ops_gpu_common.cu.h"
+#include "tensorflow/core/kernels/cwise_ops_gpu_gradients.cu.h"
+
+namespace tensorflow {
+namespace functor {
+DEFINE_UNARY2(asinh, float, double);
+} // namespace functor
+} // namespace tensorflow
+
+#endif // GOOGLE_CUDA
diff --git a/tensorflow/core/kernels/cwise_op_gpu_atanh.cu.cc b/tensorflow/core/kernels/cwise_op_gpu_atanh.cu.cc
new file mode 100644
index 0000000000..895dcbff02
--- /dev/null
+++ b/tensorflow/core/kernels/cwise_op_gpu_atanh.cu.cc
@@ -0,0 +1,27 @@
+/* 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.
+==============================================================================*/
+
+#if GOOGLE_CUDA
+
+#include "tensorflow/core/kernels/cwise_ops_gpu_common.cu.h"
+#include "tensorflow/core/kernels/cwise_ops_gpu_gradients.cu.h"
+
+namespace tensorflow {
+namespace functor {
+DEFINE_UNARY2(atanh, float, double);
+} // namespace functor
+} // namespace tensorflow
+
+#endif // GOOGLE_CUDA
diff --git a/tensorflow/core/kernels/cwise_op_greater.cc b/tensorflow/core/kernels/cwise_op_greater.cc
index 6b5a806aa2..ba89899fb3 100644
--- a/tensorflow/core/kernels/cwise_op_greater.cc
+++ b/tensorflow/core/kernels/cwise_op_greater.cc
@@ -34,11 +34,8 @@ REGISTER_KERNEL_BUILDER(Name("Greater")
BinaryOp<CPUDevice, functor::greater<int32>>);
#endif
#ifdef TENSORFLOW_USE_SYCL
-REGISTER(BinaryOp, SYCL, "Greater", functor::greater, float);
+REGISTER2(BinaryOp, SYCL, "Greater", functor::greater, float, double);
-// A special GPU kernel for int32.
-// TODO(b/25387198): Also enable int32 in device memory. This kernel
-// registration requires all int32 inputs and outputs to be in host memory.
REGISTER_KERNEL_BUILDER(Name("Greater")
.Device(DEVICE_SYCL)
.HostMemory("x")
@@ -47,5 +44,4 @@ REGISTER_KERNEL_BUILDER(Name("Greater")
.TypeConstraint<int32>("T"),
BinaryOp<CPUDevice, functor::greater<int32>>);
#endif // TENSORFLOW_USE_SYCL
-
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_greater_equal.cc b/tensorflow/core/kernels/cwise_op_greater_equal.cc
index ac21528256..8f0c483aec 100644
--- a/tensorflow/core/kernels/cwise_op_greater_equal.cc
+++ b/tensorflow/core/kernels/cwise_op_greater_equal.cc
@@ -35,7 +35,7 @@ REGISTER_KERNEL_BUILDER(Name("GreaterEqual")
#endif
#ifdef TENSORFLOW_USE_SYCL
-REGISTER(BinaryOp, SYCL, "GreaterEqual", functor::greater_equal, float);
+REGISTER2(BinaryOp, SYCL, "GreaterEqual", functor::greater_equal, float, double);
REGISTER_KERNEL_BUILDER(Name("GreaterEqual")
.Device(DEVICE_SYCL)
diff --git a/tensorflow/core/kernels/cwise_op_isfinite.cc b/tensorflow/core/kernels/cwise_op_isfinite.cc
index 0faeffa95c..53ec1c1c63 100644
--- a/tensorflow/core/kernels/cwise_op_isfinite.cc
+++ b/tensorflow/core/kernels/cwise_op_isfinite.cc
@@ -19,20 +19,12 @@ namespace tensorflow {
REGISTER3(UnaryOp, CPU, "IsFinite", functor::isfinite, float, Eigen::half,
double);
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("IsFinite") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- UnaryOp<SYCLDevice, functor::isfinite<TYPE>>);
-REGISTER_SYCL_KERNEL(float);
-REGISTER_SYCL_KERNEL(double);
-#undef REGISTER_SYCL_KERNEL
-#endif // TENSORFLOW_USE_SYCL
-
#if GOOGLE_CUDA
REGISTER3(UnaryOp, GPU, "IsFinite", functor::isfinite, float, Eigen::half,
double);
#endif
+
+#ifdef TENSORFLOW_USE_SYCL
+REGISTER2(UnaryOp, SYCL, "IsFinite", functor::isfinite, float, double);
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_isinf.cc b/tensorflow/core/kernels/cwise_op_isinf.cc
index df63006b3f..4b34744304 100644
--- a/tensorflow/core/kernels/cwise_op_isinf.cc
+++ b/tensorflow/core/kernels/cwise_op_isinf.cc
@@ -18,19 +18,11 @@ limitations under the License.
namespace tensorflow {
REGISTER3(UnaryOp, CPU, "IsInf", functor::isinf, float, Eigen::half, double);
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("IsInf") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- UnaryOp<SYCLDevice, functor::isinf<TYPE>>);
-REGISTER_SYCL_KERNEL(float);
-REGISTER_SYCL_KERNEL(double);
-#undef REGISTER_SYCL_KERNEL
-#endif // TENSORFLOW_USE_SYCL
-
#if GOOGLE_CUDA
REGISTER3(UnaryOp, GPU, "IsInf", functor::isinf, float, Eigen::half, double);
#endif
+
+#ifdef TENSORFLOW_USE_SYCL
+REGISTER2(UnaryOp, SYCL, "IsInf", functor::isinf, float, double);
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_isnan.cc b/tensorflow/core/kernels/cwise_op_isnan.cc
index e1cf7a8637..ad2dd3f722 100644
--- a/tensorflow/core/kernels/cwise_op_isnan.cc
+++ b/tensorflow/core/kernels/cwise_op_isnan.cc
@@ -18,19 +18,11 @@ limitations under the License.
namespace tensorflow {
REGISTER3(UnaryOp, CPU, "IsNan", functor::isnan, float, Eigen::half, double);
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("IsNan") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- UnaryOp<SYCLDevice, functor::isnan<TYPE>>);
-REGISTER_SYCL_KERNEL(float);
-REGISTER_SYCL_KERNEL(double);
-#undef REGISTER_SYCL_KERNEL
-#endif // TENSORFLOW_USE_SYCL
-
#if GOOGLE_CUDA
REGISTER3(UnaryOp, GPU, "IsNan", functor::isnan, float, Eigen::half, double);
#endif
+
+#ifdef TENSORFLOW_USE_SYCL
+REGISTER2(UnaryOp, SYCL, "IsNan", functor::isnan, float, double);
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_less.cc b/tensorflow/core/kernels/cwise_op_less.cc
index a38f1024a9..136c3666df 100644
--- a/tensorflow/core/kernels/cwise_op_less.cc
+++ b/tensorflow/core/kernels/cwise_op_less.cc
@@ -35,7 +35,6 @@ REGISTER_KERNEL_BUILDER(Name("Less")
#endif
#ifdef TENSORFLOW_USE_SYCL
REGISTER3(BinaryOp, SYCL, "Less", functor::less, float, double, int64);
-
REGISTER_KERNEL_BUILDER(Name("Less")
.Device(DEVICE_SYCL)
.HostMemory("x")
diff --git a/tensorflow/core/kernels/cwise_op_less_equal.cc b/tensorflow/core/kernels/cwise_op_less_equal.cc
index 3a2cc2ae0e..97a2508d12 100644
--- a/tensorflow/core/kernels/cwise_op_less_equal.cc
+++ b/tensorflow/core/kernels/cwise_op_less_equal.cc
@@ -35,8 +35,8 @@ REGISTER_KERNEL_BUILDER(Name("LessEqual")
#endif
#ifdef TENSORFLOW_USE_SYCL
-REGISTER(BinaryOp, SYCL, "LessEqual", functor::less_equal, float);
-
+REGISTER6(BinaryOp, SYCL, "LessEqual", functor::less_equal, float, double,
+ int64, uint8, int8, int16);
REGISTER_KERNEL_BUILDER(Name("LessEqual")
.Device(DEVICE_SYCL)
.HostMemory("x")
@@ -45,5 +45,4 @@ REGISTER_KERNEL_BUILDER(Name("LessEqual")
.TypeConstraint<int32>("T"),
BinaryOp<CPUDevice, functor::less_equal<int32>>);
#endif // TENSORFLOW_USE_SYCL
-
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_log.cc b/tensorflow/core/kernels/cwise_op_log.cc
index 5e74e778c7..7fdfdff0e3 100644
--- a/tensorflow/core/kernels/cwise_op_log.cc
+++ b/tensorflow/core/kernels/cwise_op_log.cc
@@ -19,19 +19,11 @@ namespace tensorflow {
REGISTER5(UnaryOp, CPU, "Log", functor::log, float, Eigen::half, double,
complex64, complex128);
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("Log") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- UnaryOp<SYCLDevice, functor::log<TYPE>>);
-REGISTER_SYCL_KERNEL(float);
-REGISTER_SYCL_KERNEL(double);
-#undef REGISTER_SYCL_KERNEL
-#endif // TENSORFLOW_USE_SYCL
-
#if GOOGLE_CUDA
REGISTER3(UnaryOp, GPU, "Log", functor::log, float, Eigen::half, double);
#endif
+
+#ifdef TENSORFLOW_USE_SYCL
+REGISTER2(UnaryOp, SYCL, "Log", functor::log, float, double);
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_log1p.cc b/tensorflow/core/kernels/cwise_op_log1p.cc
index edb821318e..25ad7b24bb 100644
--- a/tensorflow/core/kernels/cwise_op_log1p.cc
+++ b/tensorflow/core/kernels/cwise_op_log1p.cc
@@ -19,19 +19,11 @@ namespace tensorflow {
REGISTER5(UnaryOp, CPU, "Log1p", functor::log1p, float, Eigen::half, double,
complex64, complex128);
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("Log1p") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- UnaryOp<SYCLDevice, functor::log1p<TYPE>>);
-REGISTER_SYCL_KERNEL(float);
-REGISTER_SYCL_KERNEL(double);
-#undef REGISTER_SYCL_KERNEL
-#endif // TENSORFLOW_USE_SYCL
-
#if GOOGLE_CUDA
REGISTER3(UnaryOp, GPU, "Log1p", functor::log1p, float, Eigen::half, double);
#endif
+
+#ifdef TENSORFLOW_USE_SYCL
+REGISTER2(UnaryOp, SYCL, "Log1p", functor::log1p, float, double);
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_maximum.cc b/tensorflow/core/kernels/cwise_op_maximum.cc
index 7311f25ec0..87d54e380b 100644
--- a/tensorflow/core/kernels/cwise_op_maximum.cc
+++ b/tensorflow/core/kernels/cwise_op_maximum.cc
@@ -35,11 +35,7 @@ REGISTER_KERNEL_BUILDER(Name("Maximum")
#endif
#ifdef TENSORFLOW_USE_SYCL
-REGISTER(BinaryOp, SYCL, "Maximum", functor::maximum, float);
-
-// A special GPU kernel for int32.
-// TODO(b/25387198): Also enable int32 in device memory. This kernel
-// registration requires all int32 inputs and outputs to be in host memory.
+REGISTER3(BinaryOp, SYCL, "Maximum", functor::maximum, float, double, int64);
REGISTER_KERNEL_BUILDER(Name("Maximum")
.Device(DEVICE_SYCL)
.HostMemory("x")
@@ -48,5 +44,4 @@ REGISTER_KERNEL_BUILDER(Name("Maximum")
.TypeConstraint<int32>("T"),
BinaryOp<CPUDevice, functor::maximum<int32>>);
#endif // TENSORFLOW_USE_SYCL
-
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_minimum.cc b/tensorflow/core/kernels/cwise_op_minimum.cc
index 99e5a76620..442171193b 100644
--- a/tensorflow/core/kernels/cwise_op_minimum.cc
+++ b/tensorflow/core/kernels/cwise_op_minimum.cc
@@ -35,8 +35,7 @@ REGISTER_KERNEL_BUILDER(Name("Minimum")
#endif
#ifdef TENSORFLOW_USE_SYCL
-REGISTER(BinaryOp, SYCL, "Minimum", functor::minimum, float);
-
+REGISTER3(BinaryOp, SYCL, "Minimum", functor::minimum, float, double, int64);
REGISTER_KERNEL_BUILDER(Name("Minimum")
.Device(DEVICE_SYCL)
.HostMemory("x")
diff --git a/tensorflow/core/kernels/cwise_op_mul_1.cc b/tensorflow/core/kernels/cwise_op_mul_1.cc
index a3cdfa5f84..023eb07ca3 100644
--- a/tensorflow/core/kernels/cwise_op_mul_1.cc
+++ b/tensorflow/core/kernels/cwise_op_mul_1.cc
@@ -26,24 +26,6 @@ REGISTER5(BinaryOp, CPU, "Mul", functor::mul, float, Eigen::half, double,
REGISTER(BinaryOp, CPU, "Mul", functor::mul, int32);
#endif // __ANDROID_TYPES_SLIM__
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("Mul") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- BinaryOp<SYCLDevice, functor::mul<TYPE>>);
-REGISTER_SYCL_KERNEL(float)
-REGISTER_SYCL_KERNEL(double)
-#undef REGISTER_SYCL_KERNEL
-REGISTER_KERNEL_BUILDER(Name("Mul")
- .Device(DEVICE_SYCL)
- .HostMemory("x")
- .HostMemory("y")
- .HostMemory("z")
- .TypeConstraint<int32>("T"),
- BinaryOp<CPUDevice, functor::mul<int32>>);
-#endif // TENSORFLOW_USE_SYCL
#if GOOGLE_CUDA
REGISTER4(BinaryOp, GPU, "Mul", functor::mul, float, Eigen::half, double,
uint8);
@@ -59,4 +41,14 @@ REGISTER_KERNEL_BUILDER(Name("Mul")
BinaryOp<CPUDevice, functor::mul<int32>>);
#endif
+#ifdef TENSORFLOW_USE_SYCL
+REGISTER3(BinaryOp, SYCL, "Mul", functor::mul, float, double, uint8);
+REGISTER_KERNEL_BUILDER(Name("Mul")
+ .Device(DEVICE_SYCL)
+ .HostMemory("x")
+ .HostMemory("y")
+ .HostMemory("z")
+ .TypeConstraint<int32>("T"),
+ BinaryOp<CPUDevice, functor::mul<int32>>);
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_neg.cc b/tensorflow/core/kernels/cwise_op_neg.cc
index eb7e3764d9..536891b548 100644
--- a/tensorflow/core/kernels/cwise_op_neg.cc
+++ b/tensorflow/core/kernels/cwise_op_neg.cc
@@ -19,27 +19,14 @@ namespace tensorflow {
REGISTER7(UnaryOp, CPU, "Neg", functor::neg, float, Eigen::half, double, int32,
complex64, int64, complex128);
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("Neg") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- UnaryOp<SYCLDevice, functor::neg<TYPE>>);
-REGISTER_SYCL_KERNEL(float);
-REGISTER_SYCL_KERNEL(double);
-
-// A special GPU kernel for int32.
-// TODO(b/25387198): Also enable int32 in device memory. This kernel
-// registration requires all int32 inputs and outputs to be in host memory.
+#ifdef TENSORFLOW_USE_SYCL
+REGISTER3(UnaryOp, SYCL, "Neg", functor::neg, float, double, int64);
REGISTER_KERNEL_BUILDER(Name("Neg")
.Device(DEVICE_SYCL)
.HostMemory("x")
.HostMemory("y")
.TypeConstraint<int32>("T"),
UnaryOp<CPUDevice, functor::neg<int32>>);
-
-#undef REGISTER_SYCL_KERNEL
#endif // TENSORFLOW_USE_SYCL
#if GOOGLE_CUDA
diff --git a/tensorflow/core/kernels/cwise_op_pow.cc b/tensorflow/core/kernels/cwise_op_pow.cc
index f1780168e4..5fb0735ac1 100644
--- a/tensorflow/core/kernels/cwise_op_pow.cc
+++ b/tensorflow/core/kernels/cwise_op_pow.cc
@@ -19,20 +19,11 @@ namespace tensorflow {
REGISTER7(BinaryOp, CPU, "Pow", functor::pow, float, Eigen::half, double, int32,
int64, complex64, complex128);
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("Pow") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- BinaryOp<SYCLDevice, functor::pow<TYPE>>);
-REGISTER_SYCL_KERNEL(float);
-REGISTER_SYCL_KERNEL(double);
-#undef REGISTER_SYCL_KERNEL
-#endif // TENSORFLOW_USE_SYCL
-
#if GOOGLE_CUDA
REGISTER4(BinaryOp, GPU, "Pow", functor::pow, float, Eigen::half, double,
int64);
#endif
+#ifdef TENSORFLOW_USE_SYCL
+REGISTER2(BinaryOp, SYCL, "Pow", functor::pow, float, double);
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_round.cc b/tensorflow/core/kernels/cwise_op_round.cc
index e192f89782..163814aac4 100644
--- a/tensorflow/core/kernels/cwise_op_round.cc
+++ b/tensorflow/core/kernels/cwise_op_round.cc
@@ -21,9 +21,6 @@ REGISTER5(UnaryOp, CPU, "Round", functor::round, Eigen::half, float, double,
#ifdef TENSORFLOW_USE_SYCL
REGISTER2(UnaryOp, SYCL, "Round", functor::round, float, double);
-namespace functor {
-DEFINE_UNARY2(round, float, double);
-} // namespace functor
#endif
#if GOOGLE_CUDA
diff --git a/tensorflow/core/kernels/cwise_op_rsqrt.cc b/tensorflow/core/kernels/cwise_op_rsqrt.cc
index f23725f48e..a434538fbf 100644
--- a/tensorflow/core/kernels/cwise_op_rsqrt.cc
+++ b/tensorflow/core/kernels/cwise_op_rsqrt.cc
@@ -19,21 +19,12 @@ namespace tensorflow {
REGISTER5(UnaryOp, CPU, "Rsqrt", functor::rsqrt, float, Eigen::half, double,
complex64, complex128);
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("Rsqrt") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- UnaryOp<SYCLDevice, functor::rsqrt<TYPE>>);
-REGISTER_SYCL_KERNEL(float);
-REGISTER_SYCL_KERNEL(double);
-#undef REGISTER_SYCL_KERNEL
-#endif // TENSORFLOW_USE_SYCL
-
#if GOOGLE_CUDA
REGISTER3(UnaryOp, GPU, "Rsqrt", functor::rsqrt, float, Eigen::half, double);
#endif
+#ifdef TENSORFLOW_USE_SYCL
+REGISTER2(UnaryOp, SYCL, "Rsqrt", functor::rsqrt, float, double);
+#endif // TENSORFLOW_USE_SYCL
REGISTER5(SimpleBinaryOp, CPU, "RsqrtGrad", functor::rsqrt_grad, float,
Eigen::half, double, complex64, complex128);
@@ -41,4 +32,8 @@ REGISTER5(SimpleBinaryOp, CPU, "RsqrtGrad", functor::rsqrt_grad, float,
REGISTER3(SimpleBinaryOp, GPU, "RsqrtGrad", functor::rsqrt_grad, float,
Eigen::half, double);
#endif
+#ifdef TENSORFLOW_USE_SYCL
+REGISTER2(SimpleBinaryOp, SYCL, "RsqrtGrad", functor::rsqrt_grad, float,
+ double);
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_select.cc b/tensorflow/core/kernels/cwise_op_select.cc
index 709628da13..3dd9de8d89 100644
--- a/tensorflow/core/kernels/cwise_op_select.cc
+++ b/tensorflow/core/kernels/cwise_op_select.cc
@@ -181,7 +181,9 @@ REGISTER_SELECT_GPU(complex128);
SelectOp<SYCLDevice, type>);
REGISTER_SELECT_SYCL(float);
+REGISTER_SELECT_SYCL(double);
REGISTER_SELECT_SYCL(int32);
+REGISTER_SELECT_SYCL(int64);
#undef REGISTER_SELECT_SYCL
#endif // TENSORFLOW_USE_SYCL
diff --git a/tensorflow/core/kernels/cwise_op_sign.cc b/tensorflow/core/kernels/cwise_op_sign.cc
index dedd414db5..a4084d5ad1 100644
--- a/tensorflow/core/kernels/cwise_op_sign.cc
+++ b/tensorflow/core/kernels/cwise_op_sign.cc
@@ -34,10 +34,7 @@ REGISTER_KERNEL_BUILDER(Name("Sign")
#endif
#ifdef TENSORFLOW_USE_SYCL
-REGISTER(UnaryOp, SYCL, "Sign", functor::sign, float);
-// A special GPU kernel for int32.
-// TODO(b/25387198): Also enable int32 in device memory. This kernel
-// registration requires all int32 inputs and outputs to be in host memory.
+REGISTER3(UnaryOp, SYCL, "Sign", functor::sign, float, double, int64);
REGISTER_KERNEL_BUILDER(Name("Sign")
.Device(DEVICE_SYCL)
.HostMemory("x")
diff --git a/tensorflow/core/kernels/cwise_op_sin.cc b/tensorflow/core/kernels/cwise_op_sin.cc
index ab54c61b56..b91ff1ac30 100644
--- a/tensorflow/core/kernels/cwise_op_sin.cc
+++ b/tensorflow/core/kernels/cwise_op_sin.cc
@@ -19,19 +19,11 @@ namespace tensorflow {
REGISTER5(UnaryOp, CPU, "Sin", functor::sin, float, Eigen::half, double,
complex64, complex128);
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("Sin") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- UnaryOp<SYCLDevice, functor::sin<TYPE>>);
-REGISTER_SYCL_KERNEL(float);
-REGISTER_SYCL_KERNEL(double);
-#undef REGISTER_SYCL_KERNEL
-#endif // TENSORFLOW_USE_SYC
-
#if GOOGLE_CUDA
REGISTER3(UnaryOp, GPU, "Sin", functor::sin, float, Eigen::half, double);
#endif
+
+#ifdef TENSORFLOW_USE_SYCL
+REGISTER2(UnaryOp, SYCL, "Sin", functor::sin, float, double);
+#endif // TENSORFLOW_USE_SYC
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_sqrt.cc b/tensorflow/core/kernels/cwise_op_sqrt.cc
index 55acf648db..00efbb00f1 100644
--- a/tensorflow/core/kernels/cwise_op_sqrt.cc
+++ b/tensorflow/core/kernels/cwise_op_sqrt.cc
@@ -19,26 +19,22 @@ namespace tensorflow {
REGISTER5(UnaryOp, CPU, "Sqrt", functor::sqrt, float, Eigen::half, double,
complex64, complex128);
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("Sqrt") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- UnaryOp<SYCLDevice, functor::sqrt<TYPE>>);
-REGISTER_SYCL_KERNEL(float);
-REGISTER_SYCL_KERNEL(double);
-#undef REGISTER_SYCL_KERNEL
-#endif // TENSORFLOW_USE_SYCL
-
#if GOOGLE_CUDA
REGISTER3(UnaryOp, GPU, "Sqrt", functor::sqrt, float, Eigen::half, double);
#endif
+#ifdef TENSORFLOW_USE_SYCL
+REGISTER2(UnaryOp, SYCL, "Sqrt", functor::sqrt, float, double);
+#endif // TENSORFLOW_USE_SYCL
+
REGISTER5(SimpleBinaryOp, CPU, "SqrtGrad", functor::sqrt_grad, float,
Eigen::half, double, complex64, complex128);
#if GOOGLE_CUDA
REGISTER3(SimpleBinaryOp, GPU, "SqrtGrad", functor::sqrt_grad, float,
Eigen::half, double);
#endif
+
+#ifdef TENSORFLOW_USE_SYCL
+REGISTER2(SimpleBinaryOp, SYCL, "SqrtGrad", functor::sqrt_grad, float, double);
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_square.cc b/tensorflow/core/kernels/cwise_op_square.cc
index afcacfec1c..07a4b0b084 100644
--- a/tensorflow/core/kernels/cwise_op_square.cc
+++ b/tensorflow/core/kernels/cwise_op_square.cc
@@ -19,18 +19,6 @@ namespace tensorflow {
REGISTER7(UnaryOp, CPU, "Square", functor::square, float, Eigen::half, double,
int32, int64, complex64, complex128);
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("Square") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- UnaryOp<SYCLDevice, functor::square<TYPE>>);
-REGISTER_SYCL_KERNEL(float);
-REGISTER_SYCL_KERNEL(double);
-#undef REGISTER_SYCL_KERNEL
-#endif // TENSORFLOW_USE_SYC
-
#if GOOGLE_CUDA
REGISTER4(UnaryOp, GPU, "Square", functor::square, float, Eigen::half, double,
int64);
@@ -45,4 +33,14 @@ REGISTER_KERNEL_BUILDER(Name("Square")
.TypeConstraint<int32>("T"),
UnaryOp<CPUDevice, functor::square<int32>>);
#endif
+
+#ifdef TENSORFLOW_USE_SYCL
+REGISTER3(UnaryOp, SYCL, "Square", functor::square, float, double, int64);
+REGISTER_KERNEL_BUILDER(Name("Square")
+ .Device(DEVICE_SYCL)
+ .HostMemory("x")
+ .HostMemory("y")
+ .TypeConstraint<int32>("T"),
+ UnaryOp<CPUDevice, functor::square<int32>>);
+#endif // TENSORFLOW_USE_SYC
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_sub.cc b/tensorflow/core/kernels/cwise_op_sub.cc
index eab1e2a09c..eb173c7040 100644
--- a/tensorflow/core/kernels/cwise_op_sub.cc
+++ b/tensorflow/core/kernels/cwise_op_sub.cc
@@ -24,28 +24,7 @@ REGISTER7(BinaryOp, CPU, "Sub", functor::sub, float, Eigen::half, double, int32,
// int32 version of this op is needed, so explicitly include it.
REGISTER(BinaryOp, CPU, "Sub", functor::sub, int32);
#endif // __ANDROID_TYPES_SLIM__
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("Sub") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- BinaryOp<SYCLDevice, functor::sub<TYPE>>);
- REGISTER_SYCL_KERNEL(float);
- REGISTER_SYCL_KERNEL(double);
-// A special GPU kernel for int32.
-// TODO(b/25387198): Also enable int32 in device memory. This kernel
-// registration requires all int32 inputs and outputs to be in host memory.
-REGISTER_KERNEL_BUILDER(Name("Sub")
- .Device(DEVICE_SYCL)
- .HostMemory("x")
- .HostMemory("y")
- .HostMemory("z")
- .TypeConstraint<int32>("T"),
- BinaryOp<CPUDevice, functor::sub<int32>>);
-#undef REGISTER_SYCL_KERNEL
-#endif // TENSORFLOW_USE_SYCL
#if GOOGLE_CUDA
REGISTER6(BinaryOp, GPU, "Sub", functor::sub, float, Eigen::half, double, int64,
complex64, complex128);
@@ -62,4 +41,14 @@ REGISTER_KERNEL_BUILDER(Name("Sub")
BinaryOp<CPUDevice, functor::sub<int32>>);
#endif
+#ifdef TENSORFLOW_USE_SYCL
+REGISTER3(BinaryOp, SYCL, "Sub", functor::sub, float, double, int64);
+REGISTER_KERNEL_BUILDER(Name("Sub")
+ .Device(DEVICE_SYCL)
+ .HostMemory("x")
+ .HostMemory("y")
+ .HostMemory("z")
+ .TypeConstraint<int32>("T"),
+ BinaryOp<CPUDevice, functor::sub<int32>>);
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_tan.cc b/tensorflow/core/kernels/cwise_op_tan.cc
index 9c850c9420..7891b1183d 100644
--- a/tensorflow/core/kernels/cwise_op_tan.cc
+++ b/tensorflow/core/kernels/cwise_op_tan.cc
@@ -18,19 +18,11 @@ limitations under the License.
namespace tensorflow {
REGISTER2(UnaryOp, CPU, "Tan", functor::tan, float, double);
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("Tan") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- UnaryOp<SYCLDevice, functor::tan<TYPE>>);
-REGISTER_SYCL_KERNEL(float);
-REGISTER_SYCL_KERNEL(double);
-#undef REGISTER_SYCL_KERNEL
-#endif // TENSORFLOW_USE_SYC
-
#if GOOGLE_CUDA
REGISTER2(UnaryOp, GPU, "Tan", functor::tan, float, double);
#endif
+
+#ifdef TENSORFLOW_USE_SYCL
+REGISTER2(UnaryOp, SYCL, "Tan", functor::tan, float, double);
+#endif // TENSORFLOW_USE_SYCL
} // namespace tensorflow
diff --git a/tensorflow/core/kernels/cwise_op_tanh.cc b/tensorflow/core/kernels/cwise_op_tanh.cc
index 1dbc13061b..8b3900892c 100644
--- a/tensorflow/core/kernels/cwise_op_tanh.cc
+++ b/tensorflow/core/kernels/cwise_op_tanh.cc
@@ -20,22 +20,14 @@ namespace tensorflow {
REGISTER5(UnaryOp, CPU, "Tanh", functor::tanh, float, Eigen::half, double,
complex64, complex128);
-#if TENSORFLOW_USE_SYCL
-#define REGISTER_SYCL_KERNEL(TYPE) \
- REGISTER_KERNEL_BUILDER( \
- Name("Tanh") \
- .Device(DEVICE_SYCL) \
- .TypeConstraint<TYPE>("T"), \
- UnaryOp<SYCLDevice, functor::tanh<TYPE>>);
-REGISTER_SYCL_KERNEL(float);
-REGISTER_SYCL_KERNEL(double);
-#undef REGISTER_SYCL_KERNEL
-#endif // TENSORFLOW_USE_SYC
-
#if GOOGLE_CUDA
REGISTER3(UnaryOp, GPU, "Tanh", functor::tanh, float, Eigen::half, double);
#endif
+#ifdef TENSORFLOW_USE_SYCL
+REGISTER2(UnaryOp, SYCL, "Tanh", functor::tanh, float, double);
+#endif // TENSORFLOW_USE_SYCL
+
REGISTER5(SimpleBinaryOp, CPU, "TanhGrad", functor::tanh_grad, float,
Eigen::half, double, complex64, complex128);
#if GOOGLE_CUDA
diff --git a/tensorflow/core/kernels/cwise_ops.h b/tensorflow/core/kernels/cwise_ops.h
index c11d6cfabb..e198fda473 100644
--- a/tensorflow/core/kernels/cwise_ops.h
+++ b/tensorflow/core/kernels/cwise_ops.h
@@ -43,6 +43,39 @@ struct functor_traits<scalar_fmod2_op<T>> {
};
};
+template<typename T> struct scalar_asinh_op {
+ EIGEN_EMPTY_STRUCT_CTOR(scalar_asinh_op)
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const T operator()(const T& a) const {
+ return std::asinh(a);
+ }
+};
+template<typename T>
+struct functor_traits<scalar_asinh_op<T>> {
+ enum { Cost = 5 * NumTraits<T>::MulCost, PacketAccess = false };
+};
+
+template<typename T> struct scalar_acosh_op {
+ EIGEN_EMPTY_STRUCT_CTOR(scalar_acosh_op)
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const T operator()(const T& a) const {
+ return std::acosh(a);
+ }
+};
+template<typename T>
+struct functor_traits<scalar_acosh_op<T>> {
+ enum { Cost = 5 * NumTraits<T>::MulCost, PacketAccess = false };
+};
+
+template<typename T> struct scalar_atanh_op {
+ EIGEN_EMPTY_STRUCT_CTOR(scalar_atanh_op)
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const T operator()(const T& a) const {
+ return std::atanh(a);
+ }
+};
+template<typename T>
+struct functor_traits<scalar_atanh_op<T>> {
+ enum { Cost = 5 * NumTraits<T>::MulCost, PacketAccess = false };
+};
+
// TODO(rmlarsen): This is a workaround for upstream change
// https://bitbucket.org/eigen/eigen/commits/f339468d04d0f87caeb6cab9aef568627e9f6ea9
// that renamed scalar_binary_pow_op to scalar_pow_op and deleted the unary
@@ -493,6 +526,15 @@ template <typename T>
struct tanh : base<T, Eigen::internal::scalar_tanh_op<T> > {};
template <typename T>
+struct asinh : base<T, Eigen::internal::scalar_asinh_op<T> > {};
+
+template <typename T>
+struct acosh : base<T, Eigen::internal::scalar_acosh_op<T> > {};
+
+template <typename T>
+struct atanh : base<T, Eigen::internal::scalar_atanh_op<T> > {};
+
+template <typename T>
struct lgamma : base<T, Eigen::internal::scalar_lgamma_op<T> > {};
template <typename T>
diff --git a/tensorflow/core/kernels/fixed_length_record_reader_op.cc b/tensorflow/core/kernels/fixed_length_record_reader_op.cc
index ce7fb9c332..298a4e3678 100644
--- a/tensorflow/core/kernels/fixed_length_record_reader_op.cc
+++ b/tensorflow/core/kernels/fixed_length_record_reader_op.cc
@@ -19,83 +19,118 @@ limitations under the License.
#include "tensorflow/core/framework/reader_base.h"
#include "tensorflow/core/framework/reader_op_kernel.h"
#include "tensorflow/core/lib/core/errors.h"
-#include "tensorflow/core/lib/io/inputbuffer.h"
+#include "tensorflow/core/lib/io/buffered_inputstream.h"
+#include "tensorflow/core/lib/io/random_inputstream.h"
+#include "tensorflow/core/lib/io/zlib_compression_options.h"
+#include "tensorflow/core/lib/io/zlib_inputstream.h"
#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/env.h"
namespace tensorflow {
+// In the constructor hop_bytes_ is set to record_bytes_ if it was 0,
+// so that we will always "hop" after each read (except first).
class FixedLengthRecordReader : public ReaderBase {
public:
FixedLengthRecordReader(const string& node_name, int64 header_bytes,
int64 record_bytes, int64 footer_bytes,
- int64 hop_bytes, Env* env)
+ int64 hop_bytes, const string& encoding, Env* env)
: ReaderBase(
strings::StrCat("FixedLengthRecordReader '", node_name, "'")),
header_bytes_(header_bytes),
record_bytes_(record_bytes),
footer_bytes_(footer_bytes),
- hop_bytes_(hop_bytes),
+ hop_bytes_(hop_bytes == 0 ? record_bytes : hop_bytes),
env_(env),
- file_pos_limit_(-1),
- record_number_(0) {}
+ record_number_(0),
+ encoding_(encoding) {}
// On success:
- // * input_buffer_ != nullptr,
- // * input_buffer_->Tell() == header_bytes_
- // * file_pos_limit_ == file size - footer_bytes_
+ // * buffered_inputstream_ != nullptr,
+ // * buffered_inputstream_->Tell() == header_bytes_
Status OnWorkStartedLocked() override {
record_number_ = 0;
- uint64 file_size = 0;
- TF_RETURN_IF_ERROR(env_->GetFileSize(current_work(), &file_size));
- file_pos_limit_ = file_size - footer_bytes_;
+
+ lookahead_cache_.clear();
TF_RETURN_IF_ERROR(env_->NewRandomAccessFile(current_work(), &file_));
+ if (encoding_ == "ZLIB" || encoding_ == "GZIP") {
+ const io::ZlibCompressionOptions zlib_options =
+ encoding_ == "ZLIB" ? io::ZlibCompressionOptions::DEFAULT()
+ : io::ZlibCompressionOptions::GZIP();
+ file_stream_.reset(new io::RandomAccessInputStream(file_.get()));
+ buffered_inputstream_.reset(
+ new io::ZlibInputStream(file_stream_.get(), (size_t)kBufferSize,
+ (size_t)kBufferSize, zlib_options));
+ } else {
+ buffered_inputstream_.reset(
+ new io::BufferedInputStream(file_.get(), kBufferSize));
+ }
+ // header_bytes_ is always skipped.
+ TF_RETURN_IF_ERROR(buffered_inputstream_->SkipNBytes(header_bytes_));
- input_buffer_.reset(new io::InputBuffer(file_.get(), kBufferSize));
- TF_RETURN_IF_ERROR(input_buffer_->SkipNBytes(header_bytes_));
return Status::OK();
}
Status OnWorkFinishedLocked() override {
- input_buffer_.reset(nullptr);
+ buffered_inputstream_.reset(nullptr);
return Status::OK();
}
Status ReadLocked(string* key, string* value, bool* produced,
bool* at_end) override {
- // The condition `input_buffer_->Tell() + record_bytes_ > file_pos_limit_`
- // is to confirm that none of record bytes is out of the range of
- // file_pos_limit_.
- // This is necessary for the condition `hop_bytes > 0`. For example.
- // File: "0123456"
- // Reader setting: `record_bytes=3`, `hop_bytes=2`, `footer_bytes=0`,
- // `header_bytes=0`
- // Without this checking condition, the forth time the reader will at
- // this position: "012345|6" and the reading operation will result in
- // an error.
- if (input_buffer_->Tell() >= file_pos_limit_ ||
- input_buffer_->Tell() + record_bytes_ > file_pos_limit_) {
+ // We will always "hop" the hop_bytes_ except the first record
+ // where record_number_ == 0
+ if (record_number_ != 0) {
+ if (hop_bytes_ <= lookahead_cache_.size()) {
+ // If hop_bytes_ is smaller than the cached data we skip the
+ // hop_bytes_ from the cache.
+ lookahead_cache_ = lookahead_cache_.substr(hop_bytes_);
+ } else {
+ // If hop_bytes_ is larger than the cached data, we clean up
+ // the cache, then skip hop_bytes_ - cache_size from the file
+ // as the cache_size has been skipped through cache.
+ int64 cache_size = lookahead_cache_.size();
+ lookahead_cache_.clear();
+ Status s = buffered_inputstream_->SkipNBytes(hop_bytes_ - cache_size);
+ if (!s.ok()) {
+ if (!errors::IsOutOfRange(s)) {
+ return s;
+ }
+ *at_end = true;
+ return Status::OK();
+ }
+ }
+ }
+
+ // Fill up lookahead_cache_ to record_bytes_ + footer_bytes_
+ int bytes_to_read = record_bytes_ + footer_bytes_ - lookahead_cache_.size();
+ Status s = buffered_inputstream_->ReadNBytes(bytes_to_read, value);
+ if (!s.ok()) {
+ value->clear();
+ if (!errors::IsOutOfRange(s)) {
+ return s;
+ }
*at_end = true;
return Status::OK();
}
- const int64 pos_before_read = input_buffer_->Tell();
- TF_RETURN_IF_ERROR(input_buffer_->ReadNBytes(record_bytes_, value));
+ lookahead_cache_.append(*value, 0, bytes_to_read);
+ value->clear();
+
+ // Copy first record_bytes_ from cache to value
+ *value = lookahead_cache_.substr(0, record_bytes_);
+
*key = strings::StrCat(current_work(), ":", record_number_);
*produced = true;
++record_number_;
- if (hop_bytes_ > 0) {
- input_buffer_->Seek(pos_before_read + hop_bytes_).IgnoreError();
- }
-
return Status::OK();
}
Status ResetLocked() override {
- file_pos_limit_ = -1;
record_number_ = 0;
- input_buffer_.reset(nullptr);
+ buffered_inputstream_.reset(nullptr);
+ lookahead_cache_.clear();
return ReaderBase::ResetLocked();
}
@@ -107,11 +142,21 @@ class FixedLengthRecordReader : public ReaderBase {
const int64 record_bytes_;
const int64 footer_bytes_;
const int64 hop_bytes_;
+ // The purpose of lookahead_cache_ is to allows "one-pass" processing
+ // without revisit previous processed data of the stream. This is needed
+ // because certain compression like zlib does not allow random access
+ // or even obtain the uncompressed stream size before hand.
+ // The max size of the lookahead_cache_ could be
+ // record_bytes_ + footer_bytes_
+ string lookahead_cache_;
Env* const env_;
- int64 file_pos_limit_;
int64 record_number_;
- std::unique_ptr<RandomAccessFile> file_; // must outlive input_buffer_
- std::unique_ptr<io::InputBuffer> input_buffer_;
+ string encoding_;
+ // must outlive buffered_inputstream_
+ std::unique_ptr<RandomAccessFile> file_;
+ // must outlive buffered_inputstream_
+ std::unique_ptr<io::RandomAccessInputStream> file_stream_;
+ std::unique_ptr<io::InputStreamInterface> buffered_inputstream_;
};
class FixedLengthRecordReaderOp : public ReaderOpKernel {
@@ -137,11 +182,14 @@ class FixedLengthRecordReaderOp : public ReaderOpKernel {
context, hop_bytes >= 0,
errors::InvalidArgument("hop_bytes must be >= 0 not ", hop_bytes));
Env* env = context->env();
- SetReaderFactory(
- [this, header_bytes, record_bytes, footer_bytes, hop_bytes, env]() {
- return new FixedLengthRecordReader(name(), header_bytes, record_bytes,
- footer_bytes, hop_bytes, env);
- });
+ string encoding;
+ TF_CHECK_OK(context->GetAttr("encoding", &encoding));
+ SetReaderFactory([this, header_bytes, record_bytes, footer_bytes, hop_bytes,
+ encoding, env]() {
+ return new FixedLengthRecordReader(name(), header_bytes, record_bytes,
+ footer_bytes, hop_bytes, encoding,
+ env);
+ });
}
};
diff --git a/tensorflow/core/kernels/fused_batch_norm_op.cc b/tensorflow/core/kernels/fused_batch_norm_op.cc
index 37758e82eb..81551ee26f 100644
--- a/tensorflow/core/kernels/fused_batch_norm_op.cc
+++ b/tensorflow/core/kernels/fused_batch_norm_op.cc
@@ -149,7 +149,7 @@ struct FusedBatchNormGrad<CPUDevice, T> {
typename TTypes<T>::Vec scale_backprop(scale_backprop_output->vec<T>());
typename TTypes<T>::Vec offset_backprop(offset_backprop_output->vec<T>());
- // Note: the following formulas are used to to compute the gradients for
+ // Note: the following formulas are used to compute the gradients for
// back propagation.
// x_backprop = scale * rsqrt(variance + epsilon) *
// [y_backprop - mean(y_backprop) - (x - mean(x)) *
diff --git a/tensorflow/core/kernels/hexagon/hexagon_ops_definitions.h b/tensorflow/core/kernels/hexagon/hexagon_ops_definitions.h
index bd1120e1df..d0689428dd 100644
--- a/tensorflow/core/kernels/hexagon/hexagon_ops_definitions.h
+++ b/tensorflow/core/kernels/hexagon/hexagon_ops_definitions.h
@@ -24,7 +24,7 @@ limitations under the License.
namespace tensorflow {
-// HexagonOpsDefinitions provides ops definitons supported in hexagon library
+// HexagonOpsDefinitions provides ops definitions supported in hexagon library
// TODO(satok): add a functionality to call functions in hexagon library
class HexagonOpsDefinitions final : public IGraphTransferOpsDefinitions {
public:
diff --git a/tensorflow/core/kernels/map_stage_op.cc b/tensorflow/core/kernels/map_stage_op.cc
index 46eaf3d9e7..0168b57d35 100644
--- a/tensorflow/core/kernels/map_stage_op.cc
+++ b/tensorflow/core/kernels/map_stage_op.cc
@@ -550,12 +550,17 @@ REGISTER_KERNEL_BUILDER(Name("OrderedMapStage")
#endif // GOOGLE_CUDA
#ifdef TENSORFLOW_USE_SYCL
-REGISTER_KERNEL_BUILDER(Name("MapStage").HostMemory("key").Device(DEVICE_SYCL),
+REGISTER_KERNEL_BUILDER(Name("MapStage")
+ .HostMemory("key")
+ .HostMemory("indices")
+ .Device(DEVICE_SYCL),
MapStageOp<false>);
-REGISTER_KERNEL_BUILDER(
- Name("OrderedMapStage").HostMemory("key").Device(DEVICE_SYCL),
- MapStageOp<true>);
-#endif // TENSORFLOW_USE_SYCL
+REGISTER_KERNEL_BUILDER(Name("OrderedMapStage")
+ .HostMemory("key")
+ .HostMemory("indices")
+ .Device(DEVICE_SYCL),
+ MapStageOp<true>);
+#endif // TENSORFLOW_USE_SYCL
template <bool Ordered>
class MapUnstageOp : public OpKernel {
diff --git a/tensorflow/core/kernels/ops_util.h b/tensorflow/core/kernels/ops_util.h
index 68a9c37406..d3d1b56c9d 100644
--- a/tensorflow/core/kernels/ops_util.h
+++ b/tensorflow/core/kernels/ops_util.h
@@ -84,6 +84,20 @@ bool IsDim0SliceAligned(const TensorShape& s, int64 start, int64 end_or_size) {
// Returns <suffix> sanitized to have only [a-zA-Z0-9-_].
string SanitizeThreadSuffix(string suffix);
+// Helper to compute 'strides' given a tensor 'shape'. I.e.,
+// strides[i] = prod(shape.dim_size[(i+1):])
+template <typename T>
+gtl::InlinedVector<T, 8> ComputeStride(const TensorShape& shape) {
+ const int ndims = shape.dims();
+ gtl::InlinedVector<T, 8> strides(ndims);
+ T stride = 1;
+ for (int i = ndims - 1; i >= 0; --i) {
+ strides[i] = stride;
+ stride *= static_cast<T>(shape.dim_size(i));
+ }
+ return strides;
+}
+
} // namespace tensorflow
#endif // TENSORFLOW_KERNELS_OPS_UTIL_H_
diff --git a/tensorflow/core/kernels/parameterized_truncated_normal_op_gpu.cu.cc b/tensorflow/core/kernels/parameterized_truncated_normal_op_gpu.cu.cc
index 8b85bd4ebe..933de65c15 100644
--- a/tensorflow/core/kernels/parameterized_truncated_normal_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/parameterized_truncated_normal_op_gpu.cu.cc
@@ -32,7 +32,7 @@ limitations under the License.
#ifdef COMPILER_MSVC
// msvc does not support unroll. One could try the loop pragma but we need to
// take a closer look if this generates better code in this case. For now let
-// the compiler take care of of it.
+// the compiler take care of it.
#define UNROLL
#else
#define UNROLL _Pragma("unroll")
diff --git a/tensorflow/core/kernels/queue_base.h b/tensorflow/core/kernels/queue_base.h
index 0a0e51a7c3..c101fb3579 100644
--- a/tensorflow/core/kernels/queue_base.h
+++ b/tensorflow/core/kernels/queue_base.h
@@ -69,7 +69,7 @@ class QueueBase : public QueueInterface {
int32 capacity() const { return capacity_; }
- bool closed() {
+ bool is_closed() const override {
mutex_lock lock(mu_);
return closed_;
}
diff --git a/tensorflow/core/kernels/queue_ops.cc b/tensorflow/core/kernels/queue_ops.cc
index f2ac09c4e6..d51dc4ecb0 100644
--- a/tensorflow/core/kernels/queue_ops.cc
+++ b/tensorflow/core/kernels/queue_ops.cc
@@ -425,6 +425,27 @@ class QueueSizeOp : public QueueOpKernel {
REGISTER_KERNEL_BUILDER(Name("QueueSize").Device(DEVICE_CPU), QueueSizeOp);
REGISTER_KERNEL_BUILDER(Name("QueueSizeV2").Device(DEVICE_CPU), QueueSizeOp);
+class QueueIsClosedOp : public QueueOpKernel {
+ public:
+ explicit QueueIsClosedOp(OpKernelConstruction* context)
+ : QueueOpKernel(context) {}
+
+ protected:
+ void ComputeAsync(OpKernelContext* ctx, QueueInterface* queue,
+ DoneCallback callback) override {
+ Tensor* Tqueue_is_closed = nullptr;
+ OP_REQUIRES_OK(ctx, ctx->allocate_output(0, TensorShape({}), &Tqueue_is_closed));
+ Tqueue_is_closed->flat<bool>().setConstant(queue->is_closed());
+ callback();
+ }
+
+ private:
+ TF_DISALLOW_COPY_AND_ASSIGN(QueueIsClosedOp);
+};
+
+REGISTER_KERNEL_BUILDER(Name("QueueIsClosed").Device(DEVICE_CPU), QueueIsClosedOp);
+REGISTER_KERNEL_BUILDER(Name("QueueIsClosedV2").Device(DEVICE_CPU), QueueIsClosedOp);
+
class FakeQueueOp : public OpKernel {
public:
explicit FakeQueueOp(OpKernelConstruction* context) : OpKernel(context) {
diff --git a/tensorflow/core/kernels/remote_fused_graph_execute_utils.cc b/tensorflow/core/kernels/remote_fused_graph_execute_utils.cc
index ed088bfba7..a79092e8a8 100644
--- a/tensorflow/core/kernels/remote_fused_graph_execute_utils.cc
+++ b/tensorflow/core/kernels/remote_fused_graph_execute_utils.cc
@@ -104,7 +104,7 @@ void ConvertMapToVector(const std::unordered_map<int, string>& in,
std::vector<string>* out) {
CHECK_NOTNULL(out);
out->resize(in.size());
- for (int i = 0; i < in.size(); ++i) {
+ for (size_t i = 0; i < in.size(); ++i) {
CHECK(in.count(i) > 0);
out->at(i) = in.at(i);
}
@@ -993,7 +993,7 @@ RemoteFusedGraphExecuteUtils::BuildRemoteFusedGraphExecuteOpNode(
for (const string& output : outputs) {
const TensorId output_tid = ParseTensorName(output);
const string output_name = output_tid.first.ToString();
- for (int i = 0; i < border_outputs.size(); ++i) {
+ for (size_t i = 0; i < border_outputs.size(); ++i) {
const TensorId subgraph_output_tid =
ParseTensorName(border_outputs.at(i));
const string& subgraph_output_name = subgraph_output_tid.first.ToString();
@@ -1040,7 +1040,7 @@ RemoteFusedGraphExecuteUtils::BuildRemoteFusedGraphExecuteOpNode(
TF_RETURN_IF_ERROR(RemoteFusedGraphExecuteUtils::ClusterizeNodes(
subgraph_nodes, input_graph_def, &ci_vec));
- for (int i = 0; i < ci_vec.size(); ++i) {
+ for (size_t i = 0; i < ci_vec.size(); ++i) {
const string remote_fused_graph_node_name =
strings::StrCat(remote_fused_graph_node_name_prefix, "/", i);
TF_RETURN_IF_ERROR(FuseCluster(input_graph_def, inputs, outputs,
@@ -1100,7 +1100,7 @@ RemoteFusedGraphExecuteUtils::BuildRemoteFusedGraphExecuteOpNode(
for (NodeDef& node_def : *graph_def->mutable_node()) {
string attr_str;
TensorId tid;
- for (int i = 0; i < inputs.size(); ++i) {
+ for (size_t i = 0; i < inputs.size(); ++i) {
if (IsSameNodeName(node_def, inputs.at(i), &tid)) {
AppendDeliminator(&attr_str);
attr_str += BuildNodeTypeAttr(RemoteFusedGraphExecuteInfo::GRAPH_INPUT,
@@ -1108,7 +1108,7 @@ RemoteFusedGraphExecuteUtils::BuildRemoteFusedGraphExecuteOpNode(
remote_fused_graph_node_name);
}
}
- for (int i = 0; i < outputs.size(); ++i) {
+ for (size_t i = 0; i < outputs.size(); ++i) {
if (IsSameNodeName(node_def, outputs.at(i), &tid)) {
AppendDeliminator(&attr_str);
attr_str += BuildNodeTypeAttr(RemoteFusedGraphExecuteInfo::GRAPH_OUTPUT,
@@ -1127,14 +1127,14 @@ RemoteFusedGraphExecuteUtils::BuildRemoteFusedGraphExecuteOpNode(
attr_str += BuildNodeTypeAttr(RemoteFusedGraphExecuteInfo::FUSED_NODE);
}
}
- for (int i = 0; i < border_inputs.size(); ++i) {
+ for (size_t i = 0; i < border_inputs.size(); ++i) {
if (IsSameNodeName(node_def, border_inputs.at(i), &tid)) {
AppendDeliminator(&attr_str);
attr_str += BuildNodeTypeAttr(RemoteFusedGraphExecuteInfo::BORDER_INPUT,
tid.second, i);
}
}
- for (int i = 0; i < border_outputs.size(); ++i) {
+ for (size_t i = 0; i < border_outputs.size(); ++i) {
if (IsSameNodeName(node_def, border_outputs.at(i), &tid)) {
AppendDeliminator(&attr_str);
attr_str += BuildNodeTypeAttr(
diff --git a/tensorflow/core/kernels/remote_fused_graph_rewriter_transform.cc b/tensorflow/core/kernels/remote_fused_graph_rewriter_transform.cc
index 1f8c2a7684..11670e80c7 100644
--- a/tensorflow/core/kernels/remote_fused_graph_rewriter_transform.cc
+++ b/tensorflow/core/kernels/remote_fused_graph_rewriter_transform.cc
@@ -111,7 +111,7 @@ static Status PlaceShapeType(const std::vector<string>& inputs,
CHECK_EQ(inputs.size(), input_types_strs.size());
CHECK_EQ(inputs.size(), input_shapes_strs.size());
std::vector<std::pair<string, Tensor>> input_tensors;
- for (int i = 0; i < inputs.size(); ++i) {
+ for (size_t i = 0; i < inputs.size(); ++i) {
const string& name = inputs.at(i);
std::vector<int64> dims;
CHECK(str_util::SplitAndParseAsInts(input_shapes_strs.at(i), ',', &dims));
@@ -168,10 +168,10 @@ Status FuseRemoteGraph(const GraphDef& input_graph_def,
str_util::Split(border_inputs_str, ",");
const std::vector<string> border_outputs =
str_util::Split(border_outputs_str, ",");
- for (int i = 0; i < border_inputs.size(); ++i) {
+ for (size_t i = 0; i < border_inputs.size(); ++i) {
VLOG(2) << "Border Input(" << i << "): " << border_inputs.at(i);
}
- for (int i = 0; i < border_outputs.size(); ++i) {
+ for (size_t i = 0; i < border_outputs.size(); ++i) {
VLOG(2) << "Border Output(" << i << "): " << border_outputs.at(i);
}
TF_RETURN_IF_ERROR(RemoteFusedGraphExecuteUtils::FuseRemoteGraphByBorder(
diff --git a/tensorflow/core/kernels/sample_distorted_bounding_box_op.cc b/tensorflow/core/kernels/sample_distorted_bounding_box_op.cc
index 4dae5da635..44a817a5c7 100644
--- a/tensorflow/core/kernels/sample_distorted_bounding_box_op.cc
+++ b/tensorflow/core/kernels/sample_distorted_bounding_box_op.cc
@@ -192,18 +192,20 @@ bool GenerateRandomCrop(int original_width, int original_height,
} // namespace
template <typename T>
-class SampleDistortedBoundingBoxOp : public OpKernel {
+class SampleDistortedBoundingBoxV2Op : public OpKernel {
public:
- explicit SampleDistortedBoundingBoxOp(OpKernelConstruction* context)
+ explicit SampleDistortedBoundingBoxV2Op(OpKernelConstruction* context)
: OpKernel(context) {
OP_REQUIRES_OK(context, generator_.Init(context));
- OP_REQUIRES_OK(
- context, context->GetAttr("min_object_covered", &min_object_covered_));
- OP_REQUIRES(
- context, min_object_covered_ >= 0,
- errors::InvalidArgument("Min object covered must be non-negative: ",
- min_object_covered_));
+ if (context->num_inputs() == 2) {
+ OP_REQUIRES_OK(context, context->GetAttr("min_object_covered",
+ &min_object_covered_));
+ OP_REQUIRES(
+ context, min_object_covered_ >= 0,
+ errors::InvalidArgument("Min object covered must be non-negative: ",
+ min_object_covered_));
+ }
OP_REQUIRES_OK(context, context->GetAttr("use_image_if_no_bounding_boxes",
&use_image_if_no_bounding_boxes_));
@@ -275,6 +277,25 @@ class SampleDistortedBoundingBoxOp : public OpKernel {
"bounding boxes must have shape [4] or [*, 4], got ",
input_boxes.shape().DebugString()));
+ float min_object_covered_val = 0.0;
+ if (context->num_inputs() == 3) {
+ const Tensor& min_object_covered = context->input(2);
+
+ OP_REQUIRES(
+ context, TensorShapeUtils::IsScalar(min_object_covered.shape()),
+ errors::InvalidArgument("min_object_covered must be 0-D, got shape ",
+ min_object_covered.shape().DebugString()));
+
+ min_object_covered_val = min_object_covered.scalar<float>()();
+
+ OP_REQUIRES(
+ context, min_object_covered_val >= 0,
+ errors::InvalidArgument("Min object covered must be non-negative: ",
+ min_object_covered_val));
+ } else {
+ min_object_covered_val = min_object_covered_;
+ }
+
std::vector<Rectangle> bounding_boxes;
if (input_boxes.NumElements() > 0) {
TTypes<float>::ConstMatrix boxes = input_boxes.flat_inner_dims<float>();
@@ -325,7 +346,7 @@ class SampleDistortedBoundingBoxOp : public OpKernel {
if (GenerateRandomCrop(width, height, min_sample_area, max_sample_area,
sample_aspect_ratio, &random, &crop_rect)) {
- if (SatisfiesOverlapConstraints(crop_rect, min_object_covered_,
+ if (SatisfiesOverlapConstraints(crop_rect, min_object_covered_val,
bounding_boxes)) {
sample_generated = true;
break;
@@ -399,11 +420,15 @@ class SampleDistortedBoundingBoxOp : public OpKernel {
bool use_image_if_no_bounding_boxes_;
};
-#define REGISTER_KERNELS(type) \
- REGISTER_KERNEL_BUILDER( \
- Name("SampleDistortedBoundingBox").Device(DEVICE_CPU) \
- .TypeConstraint<type>("T"), \
- SampleDistortedBoundingBoxOp<type>)
+#define REGISTER_KERNELS(type) \
+ REGISTER_KERNEL_BUILDER(Name("SampleDistortedBoundingBox") \
+ .Device(DEVICE_CPU) \
+ .TypeConstraint<type>("T"), \
+ SampleDistortedBoundingBoxV2Op<type>) \
+ REGISTER_KERNEL_BUILDER(Name("SampleDistortedBoundingBoxV2") \
+ .Device(DEVICE_CPU) \
+ .TypeConstraint<type>("T"), \
+ SampleDistortedBoundingBoxV2Op<type>)
TF_CALL_INTEGRAL_TYPES(REGISTER_KERNELS);
#undef REGISTER_KERNELS
diff --git a/tensorflow/core/kernels/sparse_slice_op.cc b/tensorflow/core/kernels/sparse_slice_op.cc
new file mode 100644
index 0000000000..10dc208ab6
--- /dev/null
+++ b/tensorflow/core/kernels/sparse_slice_op.cc
@@ -0,0 +1,104 @@
+/* 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.
+==============================================================================*/
+
+#define EIGEN_USE_THREADS
+
+#include <vector>
+#include "tensorflow/core/framework/op_kernel.h"
+#include "tensorflow/core/framework/register_types.h"
+#include "tensorflow/core/util/sparse/sparse_tensor.h"
+
+namespace tensorflow {
+
+template <typename T>
+class SparseSliceOp : public OpKernel {
+ public:
+ explicit SparseSliceOp(OpKernelConstruction* context) : OpKernel(context) {}
+
+ void Compute(OpKernelContext* context) override {
+ const Tensor& input_indices = context->input(0);
+ const Tensor& input_values = context->input(1);
+ const Tensor& input_shape = context->input(2);
+ const Tensor& input_start = context->input(3);
+ const Tensor& input_size = context->input(4);
+
+ OP_REQUIRES(context, TensorShapeUtils::IsMatrix(input_indices.shape()),
+ errors::InvalidArgument(
+ "Input indices should be a matrix but received shape ",
+ input_indices.shape().DebugString()));
+ OP_REQUIRES(context, TensorShapeUtils::IsVector(input_values.shape()),
+ errors::InvalidArgument(
+ "Input values should be a vector but received shape ",
+ input_indices.shape().DebugString()));
+ OP_REQUIRES(context, TensorShapeUtils::IsVector(input_shape.shape()),
+ errors::InvalidArgument(
+ "Input shape should be a vector but received shape ",
+ input_shape.shape().DebugString()));
+ OP_REQUIRES(context, TensorShapeUtils::IsVector(input_start.shape()),
+ errors::InvalidArgument(
+ "Input start should be a vector but received shape ",
+ input_start.shape().DebugString()));
+ OP_REQUIRES(context, TensorShapeUtils::IsVector(input_size.shape()),
+ errors::InvalidArgument(
+ "Input size should be a vector but received shape ",
+ input_size.shape().DebugString()));
+
+ const int input_dims = input_shape.NumElements();
+ OP_REQUIRES(context, input_dims == input_start.NumElements(),
+ errors::InvalidArgument(
+ "Expected start to be a vector of length ", input_dims,
+ " but got length ", input_start.NumElements()));
+
+ OP_REQUIRES(context, input_dims == input_size.NumElements(),
+ errors::InvalidArgument(
+ "Expected size to be a vector of length ", input_dims,
+ " but got length ", input_size.NumElements()));
+
+ sparse::SparseTensor sparse_tensor(input_indices, input_values,
+ TensorShape(input_shape.vec<int64>()));
+
+ const gtl::ArraySlice<int64> start(input_start.flat<int64>().data(),
+ input_dims);
+ const gtl::ArraySlice<int64> size(input_size.flat<int64>().data(),
+ input_dims);
+
+ const sparse::SparseTensor output =
+ sparse::SparseTensor::Slice<T>(sparse_tensor, start, size);
+
+ context->set_output(0, output.indices());
+ context->set_output(1, output.values());
+
+ const TensorShape output_shape(output.shape());
+
+ Tensor* shape = nullptr;
+ OP_REQUIRES_OK(context,
+ context->allocate_output(2, {output_shape.dims()}, &shape));
+ for (int dim = 0; dim < output_shape.dims(); ++dim) {
+ shape->vec<int64>()(dim) = output_shape.dim_size(dim);
+ }
+ }
+
+ private:
+};
+
+#define REGISTER_KERNELS(type) \
+ REGISTER_KERNEL_BUILDER( \
+ Name("SparseSlice").Device(DEVICE_CPU).TypeConstraint<type>("T"), \
+ SparseSliceOp<type>)
+
+TF_CALL_ALL_TYPES(REGISTER_KERNELS);
+#undef REGISTER_KERNELS
+
+} // namespace tensorflow
diff --git a/tensorflow/core/kernels/tile_functor.h b/tensorflow/core/kernels/tile_functor.h
index d80898b24f..28af2dace3 100644
--- a/tensorflow/core/kernels/tile_functor.h
+++ b/tensorflow/core/kernels/tile_functor.h
@@ -25,21 +25,6 @@ namespace tensorflow {
namespace internal {
-// Helper to compute 'strides' given a tensor 'shape'. I.e.,
-// strides[i] = prod(shape.dim_size[(i+1):])
-template <typename Index>
-gtl::InlinedVector<Index, 8> ComputeStride(const TensorShape& shape) {
- const int ndims = shape.dims();
- gtl::InlinedVector<Index, 8> strides(ndims);
- Index stride = 1;
- for (int i = ndims - 1; i >= 0; --i) {
- strides[i] = stride;
- stride *= static_cast<Index>(shape.dim_size(i));
- }
- return strides;
-}
-
-
// Device-specific naive implementation for tile.
template <typename Device, typename T>
void TileSimple(const Device& d, Tensor* out, const Tensor& in);
diff --git a/tensorflow/core/kernels/tile_functor_cpu.cc b/tensorflow/core/kernels/tile_functor_cpu.cc
index 3af00350b9..c5418fa142 100644
--- a/tensorflow/core/kernels/tile_functor_cpu.cc
+++ b/tensorflow/core/kernels/tile_functor_cpu.cc
@@ -17,6 +17,7 @@ limitations under the License.
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/kernels/tile_functor.h"
+#include "tensorflow/core/kernels/ops_util.h"
namespace tensorflow {
diff --git a/tensorflow/core/kernels/tile_functor_gpu.cu.cc b/tensorflow/core/kernels/tile_functor_gpu.cu.cc
index 08aca8c731..1c61c3030a 100644
--- a/tensorflow/core/kernels/tile_functor_gpu.cu.cc
+++ b/tensorflow/core/kernels/tile_functor_gpu.cu.cc
@@ -19,6 +19,7 @@ limitations under the License.
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/core/kernels/tile_functor.h"
+#include "tensorflow/core/kernels/ops_util.h"
#include "tensorflow/core/util/cuda_kernel_helper.h"
#include "tensorflow/core/framework/register_types.h"
diff --git a/tensorflow/core/kernels/transpose_functor.h b/tensorflow/core/kernels/transpose_functor.h
index f1ab770eeb..498030fdfe 100644
--- a/tensorflow/core/kernels/transpose_functor.h
+++ b/tensorflow/core/kernels/transpose_functor.h
@@ -38,18 +38,6 @@ namespace internal {
typedef gtl::InlinedVector<int64, 8> TransposeDimsVec;
typedef gtl::InlinedVector<int32, 8> TransposePermsVec;
-// Helper to compute 'strides' given a tensor 'shape'. I.e.,
-// strides[i] = prod(shape.dim_size[(i+1):])
-template <typename Index>
-void ComputeStride(const TensorShape& shape, Index* strides) {
- const int ndims = shape.dims();
- Index stride = 1;
- for (int i = ndims - 1; i >= 0; --i) {
- strides[i] = stride;
- stride *= static_cast<Index>(shape.dim_size(i));
- }
-}
-
// Helper function that takes a tensor shape, a permutation, combines the
// neighboring shapes if their indices in the permutation are consecutive.
// The function outputs the combined shape and new permutation.
@@ -130,7 +118,17 @@ void TransposeSimple(const Device& d, const Tensor& in,
// Uses Eigen to transpose.
template <typename Device, typename T, int NDIMS>
void TransposeUsingEigen(const Device& d, const Tensor& in,
- const gtl::ArraySlice<int32> perm, Tensor* out);
+ const gtl::ArraySlice<int32> perm, Tensor* out) {
+ Eigen::array<int, NDIMS> p;
+ for (int i = 0; i < NDIMS; ++i) p[i] = perm[i];
+ auto x = typename TTypes<T, NDIMS>::ConstTensor(
+ reinterpret_cast<const T*>(in.tensor_data().data()),
+ in.shape().AsEigenDSizes<NDIMS>());
+ auto y = typename TTypes<T, NDIMS>::Tensor(
+ reinterpret_cast<T*>(const_cast<char*>(out->tensor_data().data())),
+ out->shape().AsEigenDSizes<NDIMS>());
+ y.device(d) = x.shuffle(p);
+}
#ifdef TENSORFLOW_USE_SYCL
diff --git a/tensorflow/core/kernels/transpose_functor_cpu.cc b/tensorflow/core/kernels/transpose_functor_cpu.cc
index 248c11976e..a004cb2293 100644
--- a/tensorflow/core/kernels/transpose_functor_cpu.cc
+++ b/tensorflow/core/kernels/transpose_functor_cpu.cc
@@ -16,6 +16,7 @@ limitations under the License.
#define EIGEN_USE_THREADS
#include "tensorflow/core/kernels/transpose_functor.h"
+#include "tensorflow/core/kernels/ops_util.h"
namespace tensorflow {
namespace internal {
@@ -24,10 +25,8 @@ template <typename Device, typename T>
void TransposeSimple(const Device& d, const Tensor& in,
const gtl::ArraySlice<int32> perm, Tensor* out) {
const int ndims = in.dims();
- gtl::InlinedVector<int64, 8> in_strides(ndims);
- ComputeStride(in.shape(), in_strides.data());
- gtl::InlinedVector<int64, 8> out_strides(ndims);
- ComputeStride(out->shape(), out_strides.data());
+ gtl::InlinedVector<int64, 8> in_strides = ComputeStride<int64>(in.shape());
+ gtl::InlinedVector<int64, 8> out_strides = ComputeStride<int64>(out->shape());
const int64 nelem = in.NumElements();
const T* p = reinterpret_cast<const T*>(in.tensor_data().data());
T* q = reinterpret_cast<T*>(const_cast<char*>((out->tensor_data().data())));
@@ -45,20 +44,6 @@ void TransposeSimple(const Device& d, const Tensor& in,
}
}
-template <typename Device, typename T, int NDIMS>
-void TransposeUsingEigen(const Device& d, const Tensor& in,
- const gtl::ArraySlice<int32> perm, Tensor* out) {
- Eigen::array<int, NDIMS> p;
- for (int i = 0; i < NDIMS; ++i) p[i] = perm[i];
- auto x = typename TTypes<T, NDIMS>::ConstTensor(
- reinterpret_cast<const T*>(in.tensor_data().data()),
- in.shape().AsEigenDSizes<NDIMS>());
- auto y = typename TTypes<T, NDIMS>::Tensor(
- reinterpret_cast<T*>(const_cast<char*>(out->tensor_data().data())),
- out->shape().AsEigenDSizes<NDIMS>());
- y.device(d) = x.shuffle(p);
-}
-
} // end namespace internal
typedef Eigen::ThreadPoolDevice CPUDevice;
@@ -182,7 +167,35 @@ template <typename T>
struct Transpose<SYCLDevice, T> {
static void run(const SYCLDevice& d, const Tensor& in,
const gtl::ArraySlice<int32> perm, Tensor* out) {
- // Should add a specialized implementation for SYCLDevice here.
+ switch (in.dims()) {
+ case 1:
+ internal::TransposeUsingEigen<SYCLDevice, T, 1>(d, in, perm, out);
+ break;
+ case 2:
+ internal::TransposeUsingEigen<SYCLDevice, T, 2>(d, in, perm, out);
+ break;
+ case 3:
+ internal::TransposeUsingEigen<SYCLDevice, T, 3>(d, in, perm, out);
+ break;
+ case 4:
+ internal::TransposeUsingEigen<SYCLDevice, T, 4>(d, in, perm, out);
+ break;
+ case 5:
+ internal::TransposeUsingEigen<SYCLDevice, T, 5>(d, in, perm, out);
+ break;
+ case 6:
+ internal::TransposeUsingEigen<SYCLDevice, T, 6>(d, in, perm, out);
+ break;
+ case 7:
+ internal::TransposeUsingEigen<SYCLDevice, T, 7>(d, in, perm, out);
+ break;
+ case 8:
+ internal::TransposeUsingEigen<SYCLDevice, T, 8>(d, in, perm, out);
+ break;
+ default:
+ LOG(FATAL) << "Unsupported TransposeUsingEigen for: " << in.dims();
+ break;
+ }
}
};
diff --git a/tensorflow/core/kernels/transpose_functor_gpu.cu.cc b/tensorflow/core/kernels/transpose_functor_gpu.cu.cc
index bc72bfb2fd..a118cc80c9 100644
--- a/tensorflow/core/kernels/transpose_functor_gpu.cu.cc
+++ b/tensorflow/core/kernels/transpose_functor_gpu.cu.cc
@@ -19,6 +19,7 @@ limitations under the License.
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/core/kernels/transpose_functor.h"
+#include "tensorflow/core/kernels/ops_util.h"
#include "tensorflow/core/util/cuda_kernel_helper.h"
// TODO(yangzihao): Remove the dependency of conv_2d.h once we move all
@@ -53,13 +54,13 @@ void TransposeSimple(const Device& d, const Tensor& in,
CHECK_LT(nelem, kint32max) << "Tensor too large to transpose on GPU";
// Pack strides and permutation into one buffer.
const int32 ndims = in.dims();
- gtl::InlinedVector<int32, 16> host_buf(ndims * 3);
- // Input strides.
- ComputeStride(in.shape(), &host_buf[0]);
- // Output strides.
- ComputeStride(out->shape(), &host_buf[ndims]);
+ gtl::InlinedVector<int32, 24> host_buf(ndims * 3);
+ gtl::InlinedVector<int32, 8> in_strides = ComputeStride<int32>(in.shape());
+ gtl::InlinedVector<int32, 8> out_strides = ComputeStride<int32>(out->shape());
// Dimension permutation.
for (int i = 0; i < ndims; ++i) {
+ host_buf[i] = in_strides[i];
+ host_buf[ndims + i] = out_strides[i];
host_buf[ndims * 2 + i] = perm[i];
}
// Copies the input strides, output strides and permutation to the device.
@@ -79,20 +80,6 @@ void TransposeSimple(const Device& d, const Tensor& in,
d.deallocate(dev_buf);
}
-template <typename Device, typename T, int NDIMS>
-void TransposeUsingEigen(const Device& d, const Tensor& in,
- const gtl::ArraySlice<int32> perm, Tensor* out) {
- Eigen::array<int, NDIMS> p;
- for (int i = 0; i < NDIMS; ++i) p[i] = perm[i];
- auto x = typename TTypes<T, NDIMS>::ConstTensor(
- reinterpret_cast<const T*>(in.tensor_data().data()),
- in.shape().AsEigenDSizes<NDIMS>());
- auto y = typename TTypes<T, NDIMS>::Tensor(
- reinterpret_cast<T*>(const_cast<char*>(out->tensor_data().data())),
- out->shape().AsEigenDSizes<NDIMS>());
- y.device(d) = x.shuffle(p);
-}
-
// TransposeUsingTile tries to reduce the dimension of the input tensor to 3 and
// then call special kernels to swap either dimension 1 and dimension 2 or
// dimension 0 and dimension 2. It returns true if the operation is success,
diff --git a/tensorflow/core/lib/gtl/array_slice.h b/tensorflow/core/lib/gtl/array_slice.h
index 30ef19ebe8..002d166c72 100644
--- a/tensorflow/core/lib/gtl/array_slice.h
+++ b/tensorflow/core/lib/gtl/array_slice.h
@@ -191,7 +191,7 @@ class ArraySlice {
void pop_front() { remove_prefix(1); }
// These relational operators have the same semantics as the
- // std::vector<T> relational operators: they do deep (elementwise)
+ // std::vector<T> relational operators: they do deep (element-wise)
// comparisons. Array slices are equal iff their size is the same
// and all their elements are equal.
bool operator==(ArraySlice<T> other) const { return impl_ == other.impl_; }
diff --git a/tensorflow/core/lib/gtl/flatrep.h b/tensorflow/core/lib/gtl/flatrep.h
index f5e318be1f..bb405b327a 100644
--- a/tensorflow/core/lib/gtl/flatrep.h
+++ b/tensorflow/core/lib/gtl/flatrep.h
@@ -29,7 +29,7 @@ namespace internal {
//
// The representation is an open-addressed hash table. Conceptually,
// the representation is a flat array of entries. However we
-// structure it as an array of of buckets where each bucket holds
+// structure it as an array of buckets where each bucket holds
// kWidth entries along with metadata for the kWidth entries. The
// metadata marker is
//
diff --git a/tensorflow/core/ops/data_flow_ops.cc b/tensorflow/core/ops/data_flow_ops.cc
index 51a964e3e3..fe709405f4 100644
--- a/tensorflow/core/ops/data_flow_ops.cc
+++ b/tensorflow/core/ops/data_flow_ops.cc
@@ -881,6 +881,32 @@ cancel_pending_enqueues: If true, all pending enqueue requests that are
blocked on the given queue will be canceled.
)doc");
+REGISTER_OP("QueueIsClosed")
+ .Input("handle: Ref(string)")
+ .Output("is_closed: bool")
+ .SetShapeFn(shape_inference::ScalarShape)
+ .Doc(R"doc(
+Returns true if queue is closed.
+
+This operation returns true if the queue is closed and false if the queue
+is open.
+
+handle: The handle to a queue.
+)doc");
+
+REGISTER_OP("QueueIsClosedV2")
+ .Input("handle: resource")
+ .Output("is_closed: bool")
+ .SetShapeFn(shape_inference::ScalarShape)
+ .Doc(R"doc(
+Returns true if queue is closed.
+
+This operation returns true if the queue is closed and false if the queue
+is open.
+
+handle: The handle to a queue.
+)doc");
+
REGISTER_OP("QueueSize")
.Input("handle: Ref(string)")
.Output("size: int32")
diff --git a/tensorflow/core/ops/image_ops.cc b/tensorflow/core/ops/image_ops.cc
index 68f4863026..0f8563a2da 100644
--- a/tensorflow/core/ops/image_ops.cc
+++ b/tensorflow/core/ops/image_ops.cc
@@ -82,9 +82,8 @@ Status DecodeImageShapeFn(InferenceContext* c) {
channels_dim = c->MakeDim(channels);
}
- c->set_output(0,
- c->MakeShape({InferenceContext::kUnknownDim,
- InferenceContext::kUnknownDim, channels_dim}));
+ c->set_output(0, c->MakeShape({InferenceContext::kUnknownDim,
+ InferenceContext::kUnknownDim, channels_dim}));
return Status::OK();
}
@@ -628,10 +627,9 @@ REGISTER_OP("DecodeGif")
.SetShapeFn([](InferenceContext* c) {
ShapeHandle unused;
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 0, &unused));
- c->set_output(0,
- c->MakeShape({InferenceContext::kUnknownDim,
- InferenceContext::kUnknownDim,
- InferenceContext::kUnknownDim, 3}));
+ c->set_output(0, c->MakeShape({InferenceContext::kUnknownDim,
+ InferenceContext::kUnknownDim,
+ InferenceContext::kUnknownDim, 3}));
return Status::OK();
})
.Doc(R"doc(
@@ -813,6 +811,98 @@ use_image_if_no_bounding_boxes: Controls behavior if no bounding boxes supplied.
raise an error.
)doc");
+REGISTER_OP("SampleDistortedBoundingBoxV2")
+ .Input("image_size: T")
+ .Input("bounding_boxes: float")
+ .Input("min_object_covered: float")
+ .Output("begin: T")
+ .Output("size: T")
+ .Output("bboxes: float")
+ .Attr("T: {uint8, int8, int16, int32, int64}")
+ .Attr("seed: int = 0")
+ .Attr("seed2: int = 0")
+ .Attr("aspect_ratio_range: list(float) = [0.75, 1.33]")
+ .Attr("area_range: list(float) = [0.05, 1.0]")
+ .Attr("max_attempts: int = 100")
+ .Attr("use_image_if_no_bounding_boxes: bool = false")
+ .SetIsStateful()
+ .SetShapeFn([](InferenceContext* c) {
+ c->set_output(0, c->Vector(3));
+ c->set_output(1, c->Vector(3));
+ c->set_output(2, c->MakeShape({1, 1, 4}));
+ return Status::OK();
+ })
+ .Doc(R"doc(
+Generate a single randomly distorted bounding box for an image.
+
+Bounding box annotations are often supplied in addition to ground-truth labels
+in image recognition or object localization tasks. A common technique for
+training such a system is to randomly distort an image while preserving
+its content, i.e. *data augmentation*. This Op outputs a randomly distorted
+localization of an object, i.e. bounding box, given an `image_size`,
+`bounding_boxes` and a series of constraints.
+
+The output of this Op is a single bounding box that may be used to crop the
+original image. The output is returned as 3 tensors: `begin`, `size` and
+`bboxes`. The first 2 tensors can be fed directly into `tf.slice` to crop the
+image. The latter may be supplied to `tf.image.draw_bounding_boxes` to visualize
+what the bounding box looks like.
+
+Bounding boxes are supplied and returned as `[y_min, x_min, y_max, x_max]`. The
+bounding box coordinates are floats in `[0.0, 1.0]` relative to the width and
+height of the underlying image.
+
+For example,
+
+```python
+ # Generate a single distorted bounding box.
+ begin, size, bbox_for_draw = tf.image.sample_distorted_bounding_box(
+ tf.shape(image),
+ bounding_boxes=bounding_boxes)
+
+ # Draw the bounding box in an image summary.
+ image_with_box = tf.image.draw_bounding_boxes(tf.expand_dims(image, 0),
+ bbox_for_draw)
+ tf.image_summary('images_with_box', image_with_box)
+
+ # Employ the bounding box to distort the image.
+ distorted_image = tf.slice(image, begin, size)
+```
+
+Note that if no bounding box information is available, setting
+`use_image_if_no_bounding_boxes = true` will assume there is a single implicit
+bounding box covering the whole image. If `use_image_if_no_bounding_boxes` is
+false and no bounding boxes are supplied, an error is raised.
+
+image_size: 1-D, containing `[height, width, channels]`.
+bounding_boxes: 3-D with shape `[batch, N, 4]` describing the N bounding boxes
+ associated with the image.
+min_object_covered: The cropped area of the image must contain at least this
+ fraction of any bounding box supplied. The value of this parameter should be
+ non-negative. In the case of 0, the cropped area does not need to overlap
+ any of the bounding boxes supplied.
+begin: 1-D, containing `[offset_height, offset_width, 0]`. Provide as input to
+ `tf.slice`.
+size: 1-D, containing `[target_height, target_width, -1]`. Provide as input to
+ `tf.slice`.
+bboxes: 3-D with shape `[1, 1, 4]` containing the distorted bounding box.
+ Provide as input to `tf.image.draw_bounding_boxes`.
+seed: If either `seed` or `seed2` are set to non-zero, the random number
+ generator is seeded by the given `seed`. Otherwise, it is seeded by a random
+ seed.
+seed2: A second seed to avoid seed collision.
+aspect_ratio_range: The cropped area of the image must have an aspect ratio =
+ width / height within this range.
+area_range: The cropped area of the image must contain a fraction of the
+ supplied image within in this range.
+max_attempts: Number of attempts at generating a cropped region of the image
+ of the specified constraints. After `max_attempts` failures, return the entire
+ image.
+use_image_if_no_bounding_boxes: Controls behavior if no bounding boxes supplied.
+ If true, assume an implicit bounding box covering the whole input. If false,
+ raise an error.
+)doc");
+
// --------------------------------------------------------------------------
// glimpse = extract_glimpse(input, size, offsets) extract the glimpse
diff --git a/tensorflow/core/ops/io_ops.cc b/tensorflow/core/ops/io_ops.cc
index b92c18416f..350aefe2c8 100644
--- a/tensorflow/core/ops/io_ops.cc
+++ b/tensorflow/core/ops/io_ops.cc
@@ -474,6 +474,7 @@ REGISTER_OP("FixedLengthRecordReaderV2")
.Attr("hop_bytes: int = 0")
.Attr("container: string = ''")
.Attr("shared_name: string = ''")
+ .Attr("encoding: string = ''")
.SetIsStateful()
.SetShapeFn(shape_inference::ScalarShape)
.Doc(R"doc(
@@ -489,6 +490,8 @@ container: If non-empty, this reader is placed in the given container.
Otherwise, a default container is used.
shared_name: If non-empty, this reader is named in the given bucket
with this shared_name. Otherwise, the node name is used instead.
+encoding: The type of encoding for the file. Currently ZLIB and GZIP
+ are supported. Defaults to none.
)doc");
// TODO(cwhipkey): mark this deprecated in favor of V2.
diff --git a/tensorflow/core/ops/math_grad.cc b/tensorflow/core/ops/math_grad.cc
index 9a58a31757..5e082ce8f5 100644
--- a/tensorflow/core/ops/math_grad.cc
+++ b/tensorflow/core/ops/math_grad.cc
@@ -189,6 +189,42 @@ Status TanhGrad(const AttrSlice& attrs, FunctionDef* g) {
}
REGISTER_OP_GRADIENT("Tanh", TanhGrad);
+Status AsinhGrad(const AttrSlice& attrs, FunctionDef* g) {
+ // clang-format off
+ return GradForUnaryCwise(g, {
+ {{"y"}, "Asinh", {"x"}},
+ {{"cosh"}, "Cosh", {"y"}},
+ {{"dx"}, "Mul", {"dy", "cosh"}}, // dy * cosh(y)
+ });
+ // clang-format on
+}
+REGISTER_OP_GRADIENT("Asinh", AsinhGrad);
+
+Status AcoshGrad(const AttrSlice& attrs, FunctionDef* g) {
+ // clang-format off
+ return GradForUnaryCwise(g, {
+ {{"y"}, "Acosh", {"x"}},
+ {{"sinh"}, "Sinh", {"y"}},
+ {{"dx"}, "Mul", {"dy", "sinh"}}, // dy * sinh(y)
+ });
+ // clang-format on
+}
+REGISTER_OP_GRADIENT("Acosh", AcoshGrad);
+
+Status AtanhGrad(const AttrSlice& attrs, FunctionDef* g) {
+ // clang-format off
+ return GradForUnaryCwise(g, {
+ {{"x2"}, "Square", {"x"}},
+ FDH::Const("const", 1.0f),
+ {{"one"}, "Cast", {"const"}, {{"SrcT", DT_FLOAT}, {"DstT", "$T"}}},
+ {{"a"}, "Sub", {"one", "x2"}}, // 1 - x^2
+ {{"inv"}, "Reciprocal", {"a"}},
+ {{"dx"}, "Mul", {"dy", "inv"}}
+ });
+ // clang-format on
+}
+REGISTER_OP_GRADIENT("Atanh", AtanhGrad);
+
Status SigmoidGrad(const AttrSlice& attrs, FunctionDef* g) {
// clang-format off
return GradForUnaryCwise(g, {
diff --git a/tensorflow/core/ops/math_grad_test.cc b/tensorflow/core/ops/math_grad_test.cc
index aa9706a328..1393bffb91 100644
--- a/tensorflow/core/ops/math_grad_test.cc
+++ b/tensorflow/core/ops/math_grad_test.cc
@@ -528,6 +528,44 @@ TEST_F(MathGradTest, Tanh) {
test::ExpectClose(ans, dx);
}
+TEST_F(MathGradTest, Asinh) {
+ auto x = test::AsTensor<float>({-3.f, -2.f, -1.f, 1.f, 2.f, 3.f},
+ TensorShape({2, 3}));
+ auto g = [](float x) {
+ auto y = std::asinh(x);
+ return std::cosh(y);
+ };
+ auto dx = test::AsTensor<float>(
+ {g(-3.f), g(-2.f), g(-1.f), g(1.f), g(2.f), g(3.f)}, TensorShape({2, 3}));
+ auto ans = SymGrad("Asinh", x);
+ test::ExpectClose(ans, dx);
+}
+
+TEST_F(MathGradTest, Acosh) {
+ auto x = test::AsTensor<float>({6.f, 5.f, 4.f, 1.f, 2.f, 3.f},
+ TensorShape({2, 3}));
+ auto g = [](float x) {
+ auto y = std::acosh(x);
+ return std::sinh(y);
+ };
+ auto dx = test::AsTensor<float>(
+ {g(6.f), g(5.f), g(4.f), g(1.f), g(2.f), g(3.f)}, TensorShape({2, 3}));
+ auto ans = SymGrad("Acosh", x);
+ test::ExpectClose(ans, dx);
+}
+
+TEST_F(MathGradTest, Atanh) {
+ auto x = test::AsTensor<float>({-0.3f, -0.2f, -0.1f, 0.1f, 0.2f, 0.3f},
+ TensorShape({2, 3}));
+ auto g = [](float x) {
+ return 1.f / (1.f - x * x);
+ };
+ auto dx = test::AsTensor<float>(
+ {g(-0.3f), g(-0.2f), g(-0.1f), g(0.1f), g(0.2f), g(0.3f)}, TensorShape({2, 3}));
+ auto ans = SymGrad("Atanh", x);
+ test::ExpectClose(ans, dx);
+}
+
TEST_F(MathGradTest, Sigmoid) {
auto x = test::AsTensor<float>({-3.f, -2.f, -1.f, 1.f, 2.f, 3.f},
TensorShape({2, 3}));
diff --git a/tensorflow/core/ops/math_ops.cc b/tensorflow/core/ops/math_ops.cc
index 30d6987707..89818bc210 100644
--- a/tensorflow/core/ops/math_ops.cc
+++ b/tensorflow/core/ops/math_ops.cc
@@ -305,6 +305,18 @@ REGISTER_OP("Tanh").UNARY_COMPLEX().Doc(R"doc(
Computes hyperbolic tangent of `x` element-wise.
)doc");
+REGISTER_OP("Asinh").UNARY_COMPLEX().Doc(R"doc(
+Computes inverse hyperbolic sine of x element-wise.
+)doc");
+
+REGISTER_OP("Acosh").UNARY_COMPLEX().Doc(R"doc(
+Computes inverse hyperbolic cosine of x element-wise.
+)doc");
+
+REGISTER_OP("Atanh").UNARY_COMPLEX().Doc(R"doc(
+Computes inverse hyperbolic tangent of x element-wise.
+)doc");
+
REGISTER_OP("TanhGrad").UNARY_GRADIENT_COMPLEX().Doc(R"doc(
Computes the gradient for the tanh of `x` wrt its input.
diff --git a/tensorflow/core/ops/ops.pbtxt b/tensorflow/core/ops/ops.pbtxt
index 0b10382471..7270e31fe4 100644
--- a/tensorflow/core/ops/ops.pbtxt
+++ b/tensorflow/core/ops/ops.pbtxt
@@ -191,6 +191,30 @@ op {
summary: "Computes acos of x element-wise."
}
op {
+ name: "Acosh"
+ input_arg {
+ name: "x"
+ type_attr: "T"
+ }
+ output_arg {
+ name: "y"
+ type_attr: "T"
+ }
+ attr {
+ name: "T"
+ type: "type"
+ allowed_values {
+ list {
+ type: DT_FLOAT
+ type: DT_DOUBLE
+ type: DT_COMPLEX64
+ type: DT_COMPLEX128
+ }
+ }
+ }
+ summary: "Computes acosh of x element-wise."
+}
+op {
name: "Add"
input_arg {
name: "x"
@@ -1886,6 +1910,30 @@ op {
summary: "Computes asin of x element-wise."
}
op {
+ name: "Asinh"
+ input_arg {
+ name: "x"
+ type_attr: "T"
+ }
+ output_arg {
+ name: "y"
+ type_attr: "T"
+ }
+ attr {
+ name: "T"
+ type: "type"
+ allowed_values {
+ list {
+ type: DT_FLOAT
+ type: DT_DOUBLE
+ type: DT_COMPLEX64
+ type: DT_COMPLEX128
+ }
+ }
+ }
+ summary: "Computes asinh of x element-wise."
+}
+op {
name: "Assert"
input_arg {
name: "condition"
@@ -2117,6 +2165,30 @@ op {
description: "This is the angle \\( \\theta \\in [-\\pi, \\pi] \\) such that\n\\[ x = r \\cos(\\theta) \\]\nand\n\\[ y = r \\sin(\\theta) \\]\nwhere \\(r = \\sqrt(x^2 + y^2) \\)."
}
op {
+ name: "Atanh"
+ input_arg {
+ name: "x"
+ type_attr: "T"
+ }
+ output_arg {
+ name: "y"
+ type_attr: "T"
+ }
+ attr {
+ name: "T"
+ type: "type"
+ allowed_values {
+ list {
+ type: DT_FLOAT
+ type: DT_DOUBLE
+ type: DT_COMPLEX64
+ type: DT_COMPLEX128
+ }
+ }
+ }
+ summary: "Computes atanh of x element-wise."
+}
+op {
name: "AudioSpectrogram"
input_arg {
name: "input"
@@ -28121,6 +28193,33 @@ op {
is_stateful: true
}
op {
+ name: "LMDBReader"
+ output_arg {
+ name: "reader_handle"
+ description: "The handle to reference the Reader."
+ type: DT_STRING
+ is_ref: true
+ }
+ attr {
+ name: "container"
+ type: "string"
+ default_value {
+ s: ""
+ }
+ description: "If non-empty, this reader is placed in the given container.\nOtherwise, a default container is used."
+ }
+ attr {
+ name: "shared_name"
+ type: "string"
+ default_value {
+ s: ""
+ }
+ description: "If non-empty, this reader is named in the given bucket\nwith this shared_name. Otherwise, the node name is used instead."
+ }
+ summary: "A Reader that outputs the records from a LMDB database."
+ is_stateful: true
+}
+op {
name: "TakeDataset"
input_arg {
name: "input_dataset"
diff --git a/tensorflow/core/ops/sparse_ops.cc b/tensorflow/core/ops/sparse_ops.cc
index 6aca2c3b01..646c379586 100644
--- a/tensorflow/core/ops/sparse_ops.cc
+++ b/tensorflow/core/ops/sparse_ops.cc
@@ -597,6 +597,60 @@ output_shape: A list of 1-D tensors represents the shape of the output sparse
tensors.
)doc");
+REGISTER_OP("SparseSlice")
+ .Input("indices: int64")
+ .Input("values: T")
+ .Input("shape: int64")
+ .Input("start: int64")
+ .Input("size: int64")
+ .Output("output_indices: int64")
+ .Output("output_values: T")
+ .Output("output_shape: int64")
+ .Attr("T: type")
+ .SetShapeFn([](InferenceContext* c) {
+ ShapeHandle input_shape = c->input(2);
+ ShapeHandle output_indices =
+ c->Matrix(InferenceContext::kUnknownDim, c->NumElements(input_shape));
+ ShapeHandle output_values = c->Vector(InferenceContext::kUnknownDim);
+ ShapeHandle output_shape = input_shape;
+
+ c->set_output(0, output_indices);
+ c->set_output(1, output_values);
+ c->set_output(2, output_shape);
+ return Status::OK();
+ })
+ .Doc(R"doc(
+Slice a `SparseTensor` based on the `start` and `size`.
+
+For example, if the input is
+
+ input_tensor = shape = [2, 7]
+ [ a d e ]
+ [b c ]
+
+Graphically the output tensors are:
+
+ sparse_slice([0, 0], [2, 4]) = shape = [2, 4]
+ [ a ]
+ [b c ]
+
+ sparse_slice([0, 4], [2, 3]) = shape = [2, 3]
+ [ d e ]
+ [ ]
+
+indices: 2-D tensor represents the indices of the sparse tensor.
+values: 1-D tensor represents the values of the sparse tensor.
+shape: 1-D. tensor represents the shape of the sparse tensor.
+start: 1-D. tensor represents the start of the slice.
+size: 1-D. tensor represents the size of the slice.
+output indices: A list of 1-D tensors represents the indices of the output
+sparse tensors.
+output_values: A list of 1-D tensors represents the values of the output sparse
+ tensors.
+output_shape: A list of 1-D tensors represents the shape of the output sparse
+ tensors.
+)doc");
+
REGISTER_OP("SparseReorder")
.Input("input_indices: int64")
.Input("input_values: T")
@@ -862,7 +916,9 @@ keep_dims: If true, retain reduced dimensions with length 1.
return Status::OK(); \
})
-REGISTER_OP("SparseDenseCwiseMul").SPARSE_DENSE_CWISE_SIGNATURE().Doc(R"doc(
+REGISTER_OP("SparseDenseCwiseMul")
+ .SPARSE_DENSE_CWISE_SIGNATURE()
+ .Doc(R"doc(
Component-wise multiplies a SparseTensor by a dense Tensor.
The output locations corresponding to the implicitly zero elements in the sparse
@@ -880,7 +936,9 @@ dense: `R`-D. The dense Tensor operand.
output: 1-D. The `N` values that are operated on.
)doc");
-REGISTER_OP("SparseDenseCwiseDiv").SPARSE_DENSE_CWISE_SIGNATURE().Doc(R"doc(
+REGISTER_OP("SparseDenseCwiseDiv")
+ .SPARSE_DENSE_CWISE_SIGNATURE()
+ .Doc(R"doc(
Component-wise divides a SparseTensor by a dense Tensor.
*Limitation*: this Op only broadcasts the dense side to the sparse side, but not
@@ -894,7 +952,9 @@ dense: `R`-D. The dense Tensor operand.
output: 1-D. The `N` values that are operated on.
)doc");
-REGISTER_OP("SparseDenseCwiseAdd").SPARSE_DENSE_CWISE_SIGNATURE().Doc(R"doc(
+REGISTER_OP("SparseDenseCwiseAdd")
+ .SPARSE_DENSE_CWISE_SIGNATURE()
+ .Doc(R"doc(
Adds up a SparseTensor and a dense Tensor, using these special rules:
(1) Broadcasts the dense side to have the same shape as the sparse side, if
diff --git a/tensorflow/core/platform/default/build_config.bzl b/tensorflow/core/platform/default/build_config.bzl
index 94f255663e..f9c876cc21 100644
--- a/tensorflow/core/platform/default/build_config.bzl
+++ b/tensorflow/core/platform/default/build_config.bzl
@@ -3,6 +3,7 @@
load("@protobuf//:protobuf.bzl", "cc_proto_library")
load("@protobuf//:protobuf.bzl", "py_proto_library")
load("//tensorflow:tensorflow.bzl", "if_not_mobile")
+load("//tensorflow:tensorflow.bzl", "if_not_windows")
# Appends a suffix to a list of deps.
def tf_deps(deps, suffix):
@@ -45,11 +46,11 @@ def tf_proto_library_cc(name, srcs = [], has_services = None,
srcs = srcs,
deps = tf_deps(protodeps, "_cc") + ["@protobuf//:cc_wkt_protos"],
cc_libs = cc_libs + ["@protobuf//:protobuf"],
- copts = [
+ copts = if_not_windows([
"-Wno-unknown-warning-option",
"-Wno-unused-but-set-variable",
"-Wno-sign-compare",
- ],
+ ]),
protoc = "@protobuf//:protoc",
default_runtime = "@protobuf//:protobuf",
use_grpc_plugin = use_grpc_plugin,
diff --git a/tensorflow/core/platform/profile_utils/cpu_utils.cc b/tensorflow/core/platform/profile_utils/cpu_utils.cc
index 22400565d6..52df84e81c 100644
--- a/tensorflow/core/platform/profile_utils/cpu_utils.cc
+++ b/tensorflow/core/platform/profile_utils/cpu_utils.cc
@@ -28,10 +28,17 @@ namespace profile_utils {
static ICpuUtilsHelper* cpu_utils_helper_instance_ = nullptr;
-/* static */ int64 CpuUtils::GetCycleCounterFrequency() {
- static const int64 cpu_frequency = GetCycleCounterFrequencyImpl();
- return cpu_frequency;
+#if defined(__powerpc__) || defined(__ppc__) && ( __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
+ /* static */ uint64 CpuUtils::GetCycleCounterFrequency() {
+ static const uint64 cpu_frequency = GetCycleCounterFrequencyImpl();
+ return cpu_frequency;
}
+#else
+ /* static */ int64 CpuUtils::GetCycleCounterFrequency() {
+ static const int64 cpu_frequency = GetCycleCounterFrequencyImpl();
+ return cpu_frequency;
+}
+#endif
/* static */ double CpuUtils::GetMicroSecPerClock() {
static const double micro_sec_per_clock =
diff --git a/tensorflow/core/platform/profile_utils/cpu_utils.h b/tensorflow/core/platform/profile_utils/cpu_utils.h
index 19471ec858..8979a40ea1 100644
--- a/tensorflow/core/platform/profile_utils/cpu_utils.h
+++ b/tensorflow/core/platform/profile_utils/cpu_utils.h
@@ -97,7 +97,11 @@ class CpuUtils {
// Return cycle counter frequency.
// As this method caches the cpu frequency internally,
// the first call will incur overhead, but not subsequent calls.
- static int64 GetCycleCounterFrequency();
+ #if defined(__powerpc__) || defined(__ppc__) && ( __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
+ static uint64 GetCycleCounterFrequency();
+ #else
+ static int64 GetCycleCounterFrequency();
+ #endif
// Return micro secound per each clock
// As this method caches the cpu frequency internally,
diff --git a/tensorflow/core/platform/profile_utils/cpu_utils_test.cc b/tensorflow/core/platform/profile_utils/cpu_utils_test.cc
index ca487965a0..e1ec4aaac0 100644
--- a/tensorflow/core/platform/profile_utils/cpu_utils_test.cc
+++ b/tensorflow/core/platform/profile_utils/cpu_utils_test.cc
@@ -53,9 +53,15 @@ TEST_F(CpuUtilsTest, CheckGetCurrentClockCycle) {
}
TEST_F(CpuUtilsTest, CheckCycleCounterFrequency) {
- const int64 cpu_frequency = CpuUtils::GetCycleCounterFrequency();
- CHECK_GT(cpu_frequency, 0);
- CHECK_NE(cpu_frequency, CpuUtils::INVALID_FREQUENCY);
+ #if defined(__powerpc__) || defined(__ppc__) && ( __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
+ const uint64 cpu_frequency = CpuUtils::GetCycleCounterFrequency();
+ CHECK_GT(cpu_frequency, 0);
+ CHECK_NE(cpu_frequency, unsigned(CpuUtils::INVALID_FREQUENCY));
+ #else
+ const int64 cpu_frequency = CpuUtils::GetCycleCounterFrequency();
+ CHECK_GT(cpu_frequency, 0);
+ CHECK_NE(cpu_frequency, CpuUtils::INVALID_FREQUENCY);
+ #endif
if (DBG) {
LOG(INFO) << "Cpu frequency = " << cpu_frequency;
}
diff --git a/tensorflow/core/profiler/internal/BUILD b/tensorflow/core/profiler/internal/BUILD
index abb4534f77..129a42deeb 100644
--- a/tensorflow/core/profiler/internal/BUILD
+++ b/tensorflow/core/profiler/internal/BUILD
@@ -9,6 +9,7 @@ package(
licenses(["notice"]) # Apache 2.0
load("//tensorflow:tensorflow.bzl", "tf_cc_test")
+load("//tensorflow:tensorflow.bzl", "if_not_windows")
cc_library(
name = "tfprof_stats",
@@ -243,7 +244,7 @@ cc_library(
name = "tfprof_utils",
srcs = ["tfprof_utils.cc"],
hdrs = ["tfprof_utils.h"],
- copts = ["-Wno-sign-compare"],
+ copts = if_not_windows(["-Wno-sign-compare"]),
deps = [
":tfprof_options",
"//tensorflow/core:lib",
@@ -315,7 +316,7 @@ cc_library(
name = "tfprof_tensor",
srcs = ["tfprof_tensor.cc"],
hdrs = ["tfprof_tensor.h"],
- copts = ["-Wno-sign-compare"],
+ copts = if_not_windows(["-Wno-sign-compare"]),
deps = [
"//tensorflow/core:framework",
"//tensorflow/core:lib",
diff --git a/tensorflow/core/profiler/internal/tfprof_timeline.cc b/tensorflow/core/profiler/internal/tfprof_timeline.cc
index ce0d8b7c7b..cfd80b875a 100644
--- a/tensorflow/core/profiler/internal/tfprof_timeline.cc
+++ b/tensorflow/core/profiler/internal/tfprof_timeline.cc
@@ -327,7 +327,7 @@ void Timeline::AllocateLanes() {
int64 start_time = tnode.second->start_micros;
int64 end_time = tnode.second->start_micros + tnode.second->exec_micros;
int64 l = -1;
- for (int i = 0; i < p->lanes.size(); ++i) {
+ for (int64 i = 0; i < p->lanes.size(); ++i) {
const auto& lane = p->lanes[i];
l = i;
for (auto cur_it = lane.rbegin(); cur_it != lane.rend(); ++cur_it) {
diff --git a/tensorflow/core/protobuf/worker.proto b/tensorflow/core/protobuf/worker.proto
index e476a84a13..9d4a417aa3 100644
--- a/tensorflow/core/protobuf/worker.proto
+++ b/tensorflow/core/protobuf/worker.proto
@@ -141,7 +141,7 @@ message DeregisterGraphResponse {
message CleanupAllRequest {
// A list of container names.
//
- // If 'container' is not empty, releases resoures in the given
+ // If 'container' is not empty, releases resources in the given
// containers in all devices.
//
// If 'container' is empty, releases resources in the default
diff --git a/tensorflow/core/public/version.h b/tensorflow/core/public/version.h
index e76876c9dc..8fc10111a6 100644
--- a/tensorflow/core/public/version.h
+++ b/tensorflow/core/public/version.h
@@ -20,7 +20,7 @@ limitations under the License.
#define TF_MAJOR_VERSION 1
#define TF_MINOR_VERSION 2
-#define TF_PATCH_VERSION 0
+#define TF_PATCH_VERSION 1
// TF_VERSION_SUFFIX is non-empty for pre-releases (e.g. "-alpha", "-alpha.1",
// "-beta", "-rc", "-rc.1")
diff --git a/tensorflow/core/util/memmapped_file_system_test.cc b/tensorflow/core/util/memmapped_file_system_test.cc
index 24ce5ebafc..a5f24b08b3 100644
--- a/tensorflow/core/util/memmapped_file_system_test.cc
+++ b/tensorflow/core/util/memmapped_file_system_test.cc
@@ -110,7 +110,7 @@ TEST(MemmappedFileSystemTest, SimpleTest) {
memmapped_env.FileExists("bla-bla-bla").code());
}
-TEST(MemmappedFileSystemTest, NotInitalized) {
+TEST(MemmappedFileSystemTest, NotInitialized) {
MemmappedEnv memmapped_env(Env::Default());
std::unique_ptr<ReadOnlyMemoryRegion> memory_region;
EXPECT_EQ(
diff --git a/tensorflow/core/util/sparse/sparse_tensor.h b/tensorflow/core/util/sparse/sparse_tensor.h
index d8e5d90142..0ea74c38b1 100644
--- a/tensorflow/core/util/sparse/sparse_tensor.h
+++ b/tensorflow/core/util/sparse/sparse_tensor.h
@@ -20,7 +20,6 @@ limitations under the License.
#include <numeric>
#include <vector>
-#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/framework/tensor_types.h"
#include "tensorflow/core/framework/types.h"
@@ -32,6 +31,7 @@ limitations under the License.
#include "tensorflow/core/platform/types.h"
#include "tensorflow/core/util/sparse/dim_comparator.h"
#include "tensorflow/core/util/sparse/group_iterator.h"
+#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
namespace tensorflow {
namespace sparse {
@@ -59,8 +59,8 @@ class SparseTensor {
shape_(shape.begin(), shape.end()),
order_(order.begin(), order.end()),
dims_(GetDimsFromIx(ix)) {
- CHECK_EQ(ix.dtype(), DT_INT64)
- << "indices must be type int64 but got: " << ix.dtype();
+ CHECK_EQ(ix.dtype(), DT_INT64) << "indices must be type int64 but got: "
+ << ix.dtype();
CHECK(TensorShapeUtils::IsVector(vals.shape()))
<< "vals must be a vec, but got: " << vals.shape().DebugString();
CHECK_EQ(ix.shape().dim_size(0), vals.shape().dim_size(0))
@@ -155,6 +155,15 @@ class SparseTensor {
const int split_dim,
const int num_split);
+ // Slice() will slice the input SparseTensor into a SparseTensor based on
+ // specified start and size. Both start and size are 1-D array with each
+ // element of the array representing one dimension. The start is the start
+ // index at each dimension and the size is the size at each dimension.
+ template <typename T>
+ static SparseTensor Slice(const SparseTensor& tensor,
+ const gtl::ArraySlice<int64>& start,
+ const gtl::ArraySlice<int64>& size);
+
// Picks out the dimensions according to `dim_indices`.
std::vector<int64> PickDims(gtl::ArraySlice<int64> dim_indices) const {
std::vector<int64> res(dim_indices.size());
@@ -541,6 +550,81 @@ std::vector<SparseTensor> SparseTensor::Split(const SparseTensor& input_tensor,
return output_tensors;
}
+template <typename T>
+SparseTensor SparseTensor::Slice(const SparseTensor& input_tensor,
+ const gtl::ArraySlice<int64>& start,
+ const gtl::ArraySlice<int64>& size) {
+ TensorShape output_shape(input_tensor.shape());
+
+ const int dims = input_tensor.dims();
+ for (int dim = 0; dim < dims; dim++) {
+ int64 dim_size = start[dim] + size[dim] < output_shape.dim_size(dim)
+ ? size[dim]
+ : output_shape.dim_size(dim) - start[dim];
+ output_shape.set_dim(dim, dim_size);
+ }
+
+ auto input_indices_t = input_tensor.indices().matrix<int64>();
+ auto input_values_t = input_tensor.values().vec<T>();
+
+ // Find the number of indices that fall inside start and size.
+ int count = 0;
+ for (int i = 0; i < input_tensor.indices().dim_size(0); i++) {
+ // The following will check to see if an input is within the
+ // range specified by start and size.
+ // The for loop below iterates through all dimensions. In case
+ // the index falls outside of the start and size at any dimension,
+ // it will be considered as a "no hit" (hit = false). In this
+ // case, it will not be counted as the index that fall inside
+ // the range specified by start and size.
+ bool hit = true;
+ for (int dim = 0; dim < dims; dim++) {
+ if (!(start[dim] <= input_indices_t(i, dim) &&
+ input_indices_t(i, dim) < start[dim] + size[dim])) {
+ hit = false;
+ break;
+ }
+ }
+ if (!hit) {
+ continue;
+ }
+ count++;
+ }
+
+ Tensor output_values(DataTypeToEnum<T>::v(), TensorShape({count}));
+ Tensor output_indices(DT_INT64, TensorShape({count, dims}));
+
+ auto output_values_t = output_values.vec<T>();
+ auto output_indices_t = output_indices.matrix<int64>();
+
+ // Obtain the output indices that fall inside start and size.
+ int index = 0;
+ for (int i = 0; i < input_tensor.indices().dim_size(0) && index < count;
+ i++) {
+ // The logic here is similiar as the above except that the above
+ // only count the number of indices while here we actually generate
+ // the output.
+ bool hit = true;
+ for (int dim = 0; dim < dims; dim++) {
+ if (!(start[dim] <= input_indices_t(i, dim) &&
+ input_indices_t(i, dim) < start[dim] + size[dim])) {
+ hit = false;
+ break;
+ }
+ }
+ if (!hit) {
+ continue;
+ }
+ output_values_t(index) = input_values_t(i);
+ for (int dim = 0; dim < dims; dim++) {
+ output_indices_t(index, dim) = input_indices_t(i, dim) - start[dim];
+ }
+ index++;
+ }
+
+ return SparseTensor(output_indices, output_values, output_shape);
+}
+
} // namespace sparse
} // namespace tensorflow
diff --git a/tensorflow/core/util/sparse/sparse_tensor_test.cc b/tensorflow/core/util/sparse/sparse_tensor_test.cc
index 5edd6cb1d8..efdd97fd3d 100644
--- a/tensorflow/core/util/sparse/sparse_tensor_test.cc
+++ b/tensorflow/core/util/sparse/sparse_tensor_test.cc
@@ -18,7 +18,6 @@ limitations under the License.
#include <string>
#include <vector>
-#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/framework/tensor_types.h"
#include "tensorflow/core/lib/core/status_test_util.h"
@@ -26,6 +25,7 @@ limitations under the License.
#include "tensorflow/core/lib/strings/str_util.h"
#include "tensorflow/core/platform/test.h"
#include "tensorflow/core/platform/test_benchmark.h"
+#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
namespace tensorflow {
namespace sparse {
@@ -612,6 +612,50 @@ TEST(SparseTensorTest, Split) {
EXPECT_EQ(st_list[1].indices().matrix<int64>()(0, 1), 0);
}
+TEST(SparseTensorTest, Slice) {
+ const int N = 4;
+ const int DIM = 2;
+
+ Tensor ids(DT_INT64, TensorShape({N, DIM}));
+ Tensor vals(DT_INT64, TensorShape({N}));
+
+ ids.matrix<int64>()(0, 0) = 0;
+ ids.matrix<int64>()(0, 1) = 0;
+ ids.matrix<int64>()(1, 0) = 1;
+ ids.matrix<int64>()(1, 1) = 1;
+ ids.matrix<int64>()(2, 0) = 1;
+ ids.matrix<int64>()(2, 1) = 2;
+ ids.matrix<int64>()(3, 0) = 3;
+ ids.matrix<int64>()(3, 1) = 0;
+
+ vals.vec<int64>()(0) = 1;
+ vals.vec<int64>()(1) = 2;
+ vals.vec<int64>()(2) = 3;
+ vals.vec<int64>()(3) = 4;
+
+ SparseTensor st(ids, vals, TensorShape({4, 3}));
+
+ std::vector<int64> start(2, 0);
+ std::vector<int64> size(2);
+ size[0] = 2;
+ size[1] = 3;
+
+ SparseTensor slice = SparseTensor::Slice<int64>(st, start, size);
+
+ EXPECT_EQ(TensorShape(slice.shape()), TensorShape({2, 3}));
+ EXPECT_EQ(slice.values().NumElements(), 3);
+ EXPECT_EQ(slice.values().vec<int64>()(0), 1);
+ EXPECT_EQ(slice.values().vec<int64>()(1), 2);
+ EXPECT_EQ(slice.values().vec<int64>()(2), 3);
+ EXPECT_EQ(slice.indices().NumElements(), 6);
+ EXPECT_EQ(slice.indices().matrix<int64>()(0, 0), 0);
+ EXPECT_EQ(slice.indices().matrix<int64>()(0, 1), 0);
+ EXPECT_EQ(slice.indices().matrix<int64>()(1, 0), 1);
+ EXPECT_EQ(slice.indices().matrix<int64>()(1, 1), 1);
+ EXPECT_EQ(slice.indices().matrix<int64>()(2, 0), 1);
+ EXPECT_EQ(slice.indices().matrix<int64>()(2, 1), 2);
+}
+
TEST(SparseTensorTest, Dim0SparseTensorToDenseTensor) {
Tensor ix(DT_INT64, TensorShape({1, 0}));
Tensor vals(DT_INT32, TensorShape({1}));
diff --git a/tensorflow/core/util/tensor_bundle/BUILD b/tensorflow/core/util/tensor_bundle/BUILD
index ca92713a62..1045cf84b4 100644
--- a/tensorflow/core/util/tensor_bundle/BUILD
+++ b/tensorflow/core/util/tensor_bundle/BUILD
@@ -11,6 +11,7 @@ licenses(["notice"]) # Apache 2.0
load(
"//tensorflow:tensorflow.bzl",
"cc_header_only_library",
+ "if_not_windows",
"tf_copts",
)
@@ -34,7 +35,7 @@ cc_library(
name = "tensor_bundle",
srcs = ["tensor_bundle.cc"],
hdrs = ["tensor_bundle.h"],
- copts = tf_copts() + ["-Wno-sign-compare"],
+ copts = tf_copts() + if_not_windows(["-Wno-sign-compare"]),
deps = [
":naming",
"//tensorflow/core:core_cpu_internal",
diff --git a/tensorflow/docs_src/api_guides/python/math_ops.md b/tensorflow/docs_src/api_guides/python/math_ops.md
index 3d9f203297..b3c7a0c010 100644
--- a/tensorflow/docs_src/api_guides/python/math_ops.md
+++ b/tensorflow/docs_src/api_guides/python/math_ops.md
@@ -61,6 +61,9 @@ mathematical functions to your graph.
* @{tf.atan}
* @{tf.cosh}
* @{tf.sinh}
+* @{tf.asinh}
+* @{tf.acosh}
+* @{tf.atanh}
* @{tf.lgamma}
* @{tf.digamma}
* @{tf.erf}
diff --git a/tensorflow/docs_src/community/documentation.md b/tensorflow/docs_src/community/documentation.md
index 31a10d1f15..a757d8c66d 100644
--- a/tensorflow/docs_src/community/documentation.md
+++ b/tensorflow/docs_src/community/documentation.md
@@ -276,7 +276,7 @@ __init__.py:
# Otherwise import symbols directly
from tensorflow.some_module.some_other_file import some_symbol
- from tensorflow.platform.all_util import remove_undocumented
+ from tensorflow.python.util.all_util import remove_undocumented
_allowed_symbols = [‘some_symbol’, ‘some_other_symbol’]
diff --git a/tensorflow/docs_src/community/welcome.md b/tensorflow/docs_src/community/welcome.md
index 4c8c4e1a97..194649a304 100644
--- a/tensorflow/docs_src/community/welcome.md
+++ b/tensorflow/docs_src/community/welcome.md
@@ -25,6 +25,10 @@ The TensorFlow community has created many great projects around TensorFlow, incl
* [Bitfusion's` GPU-enabled AWS EC2 TensorFlow AMI](https://github.com/bitfusionio/amis/tree/master/awsmrkt-bfboost-ubuntu14-cuda75-tensorflow) ([Launch AMI](https://aws.amazon.com/marketplace/pp/B01EYKBEQ0))
* [Rust language bindings](https://github.com/google/tensorflow-rust)
* [Operator Vectorization Library](https://github.com/opveclib/opveclib)
+* [Swift language bindings](https://github.com/PerfectlySoft/Perfect-TensorFlow)
+* [Sublime Tensorflow - A plugin for Sublime Text](https://github.com/baptisteArnaud/Sublime-Tensorflow)
+* [Edward - A library for probabilistic modeling, inference, and criticism](http://edwardlib.org) ([Github](https://github.com/blei-lab/edward), [Forum](https://discourse.edwardlib.org))
+* [GPflow - Gaussian processes in TensorFlow](https://github.com/GPflow/GPflow)
## TensorFlow Communities Around the World
diff --git a/tensorflow/docs_src/get_started/get_started.md b/tensorflow/docs_src/get_started/get_started.md
index d1c9cd696c..17d07cc582 100644
--- a/tensorflow/docs_src/get_started/get_started.md
+++ b/tensorflow/docs_src/get_started/get_started.md
@@ -295,7 +295,6 @@ next section.
The completed trainable linear regression model is shown here:
```python
-import numpy as np
import tensorflow as tf
# Model parameters
@@ -305,14 +304,16 @@ b = tf.Variable([-.3], dtype=tf.float32)
x = tf.placeholder(tf.float32)
linear_model = W * x + b
y = tf.placeholder(tf.float32)
+
# loss
loss = tf.reduce_sum(tf.square(linear_model - y)) # sum of the squares
# optimizer
optimizer = tf.train.GradientDescentOptimizer(0.01)
train = optimizer.minimize(loss)
+
# training data
-x_train = [1,2,3,4]
-y_train = [0,-1,-2,-3]
+x_train = [1, 2, 3, 4]
+y_train = [0, -1, -2, -3]
# training loop
init = tf.global_variables_initializer()
sess = tf.Session()
@@ -329,9 +330,9 @@ When run, it produces
W: [-0.9999969] b: [ 0.99999082] loss: 5.69997e-11
```
-Notice that the loss is a very small number (close to zero). If you run this
-program your loss will not be exactly the same, because the model is initialized
-with random values.
+Notice that the loss is a very small number (very close to zero). If you run this
+program, your loss may not be the exact same because the model is initialized
+with pseudorandom values.
This more complicated program can still be visualized in TensorBoard
![TensorBoard final model visualization](https://www.tensorflow.org/images/getting_started_final.png)
@@ -394,8 +395,8 @@ print("eval metrics: %r"% eval_metrics)
```
When run, it produces
```
- train metrics: {'global_step': 1000, 'loss': 4.3049088e-08}
- eval metrics: {'global_step': 1000, 'loss': 0.0025487561}
+train metrics: {'loss': 1.2712867e-09, 'global_step': 1000}
+eval metrics: {'loss': 0.0025279333, 'global_step': 1000}
```
Notice how our eval data has a higher loss, but it is still close to zero.
That means we are learning properly.
@@ -425,7 +426,7 @@ def model_fn(features, labels, mode):
# Build a linear model and predict values
W = tf.get_variable("W", [1], dtype=tf.float64)
b = tf.get_variable("b", [1], dtype=tf.float64)
- y = W*features['x'] + b
+ y = W * features['x'] + b
# Loss sub-graph
loss = tf.reduce_sum(tf.square(y - labels))
# Training sub-graph
@@ -464,8 +465,8 @@ print("eval metrics: %r"% eval_metrics)
```
When run, it produces
```
-train metrics: {'global_step': 1000, 'loss': 4.9380226e-11}
-eval metrics: {'global_step': 1000, 'loss': 0.01010081}
+train metrics: {'loss': 1.227995e-11, 'global_step': 1000}
+eval metrics: {'loss': 0.01010036, 'global_step': 1000}
```
Notice how the contents of the custom `model_fn()` function are very similar
diff --git a/tensorflow/docs_src/get_started/mnist/beginners.md b/tensorflow/docs_src/get_started/mnist/beginners.md
index 4858b3cf92..193dd41b2a 100644
--- a/tensorflow/docs_src/get_started/mnist/beginners.md
+++ b/tensorflow/docs_src/get_started/mnist/beginners.md
@@ -95,7 +95,7 @@ We can flatten this array into a vector of 28x28 = 784 numbers. It doesn't
matter how we flatten the array, as long as we're consistent between images.
From this perspective, the MNIST images are just a bunch of points in a
784-dimensional vector space, with a
-[very rich structure](http://colah.github.io/posts/2014-10-Visualizing-MNIST/)
+[very rich structure](https://colah.github.io/posts/2014-10-Visualizing-MNIST/)
(warning: computationally intensive visualizations).
Flattening the data throws away information about the 2D structure of the image.
@@ -231,7 +231,7 @@ Now let's turn that into something that TensorFlow can use.
To do efficient numerical computing in Python, we typically use libraries like
-[NumPy](http://www.numpy.org/) that do expensive operations such as matrix
+[NumPy](http://www.numpy.org) that do expensive operations such as matrix
multiplication outside Python, using highly efficient code implemented in
another language. Unfortunately, there can still be a lot of overhead from
switching back to Python every operation. This overhead is especially bad if you
@@ -324,7 +324,7 @@ distribution (the one-hot vector with the digit labels). In some rough sense, t
cross-entropy is measuring how inefficient our predictions are for describing
the truth. Going into more detail about cross-entropy is beyond the scope of
this tutorial, but it's well worth
-[understanding](http://colah.github.io/posts/2015-09-Visual-Information/).
+[understanding](https://colah.github.io/posts/2015-09-Visual-Information).
To implement cross-entropy we need to first add a new placeholder to input the
correct answers:
@@ -356,7 +356,7 @@ instead.
Now that we know what we want our model to do, it's very easy to have TensorFlow
train it to do so. Because TensorFlow knows the entire graph of your
computations, it can automatically use the
-[backpropagation algorithm](http://colah.github.io/posts/2015-08-Backprop/) to
+[backpropagation algorithm](https://colah.github.io/posts/2015-08-Backprop) to
efficiently determine how your variables affect the loss you ask it to
minimize. Then it can apply your choice of optimization algorithm to modify the
variables and reduce the loss.
@@ -447,7 +447,7 @@ Is that good? Well, not really. In fact, it's pretty bad. This is because we're
using a very simple model. With some small changes, we can get to 97%. The best
models can get to over 99.7% accuracy! (For more information, have a look at
this
-[list of results](http://rodrigob.github.io/are_we_there_yet/build/classification_datasets_results.html).)
+[list of results](https://rodrigob.github.io/are_we_there_yet/build/classification_datasets_results).)
What matters is that we learned from this model. Still, if you're feeling a bit
down about these results, check out
diff --git a/tensorflow/docs_src/install/install_c.md b/tensorflow/docs_src/install/install_c.md
index 81aa6e3f76..e971a03d36 100644
--- a/tensorflow/docs_src/install/install_c.md
+++ b/tensorflow/docs_src/install/install_c.md
@@ -1,7 +1,7 @@
# Installing TensorFlow for C
TensorFlow provides a C API defined in
-[`c_api.h`](https://github.com/tensorflow/tensorflow/tree/master/c/c_api.h),
+[`c_api.h`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/c/c_api.h),
which is suitable for
[building bindings for other languages](https://www.tensorflow.org/extend/language_bindings).
The API leans towards simplicity and uniformity rather than convenience.
@@ -35,7 +35,7 @@ enable TensorFlow for C:
OS="linux" # Change to "darwin" for Mac OS
TARGET_DIRECTORY="/usr/local"
curl -L \
- "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-${TF_TYPE}-${OS}-x86_64-1.2.0.tar.gz" |
+ "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-${TF_TYPE}-${OS}-x86_64-1.2.1.tar.gz" |
sudo tar -C $TARGET_DIRECTORY -xz
The `tar` command extracts the TensorFlow C library into the `lib`
diff --git a/tensorflow/docs_src/install/install_go.md b/tensorflow/docs_src/install/install_go.md
index 3f9096b822..6fb8f7eb55 100644
--- a/tensorflow/docs_src/install/install_go.md
+++ b/tensorflow/docs_src/install/install_go.md
@@ -35,7 +35,7 @@ steps to install this library and enable TensorFlow for Go:
TF_TYPE="cpu" # Change to "gpu" for GPU support
TARGET_DIRECTORY='/usr/local'
curl -L \
- "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-${TF_TYPE}-$(go env GOOS)-x86_64-1.2.0.tar.gz" |
+ "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-${TF_TYPE}-$(go env GOOS)-x86_64-1.2.1.tar.gz" |
sudo tar -C $TARGET_DIRECTORY -xz
The `tar` command extracts the TensorFlow C library into the `lib`
diff --git a/tensorflow/docs_src/install/install_java.md b/tensorflow/docs_src/install/install_java.md
index 40ed9e1826..a8e6356f9d 100644
--- a/tensorflow/docs_src/install/install_java.md
+++ b/tensorflow/docs_src/install/install_java.md
@@ -34,7 +34,7 @@ following to the project's `pom.xml` to use the TensorFlow Java APIs:
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow</artifactId>
- <version>1.2.0</version>
+ <version>1.2.1</version>
</dependency>
```
@@ -63,7 +63,7 @@ As an example, these steps will create a Maven project that uses TensorFlow:
<dependency>
<groupId>org.tensorflow</groupId>
<artifactId>tensorflow</artifactId>
- <version>1.2.0</version>
+ <version>1.2.1</version>
</dependency>
</dependencies>
</project>
@@ -122,7 +122,7 @@ refer to the simpler instructions above instead.
Take the following steps to install TensorFlow for Java on Linux or Mac OS:
1. Download
- [libtensorflow.jar](https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-1.2.0.jar),
+ [libtensorflow.jar](https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-1.2.1.jar),
which is the TensorFlow Java Archive (JAR).
2. Decide whether you will run TensorFlow for Java on CPU(s) only or with
@@ -141,7 +141,7 @@ Take the following steps to install TensorFlow for Java on Linux or Mac OS:
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
mkdir -p ./jni
curl -L \
- "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow_jni-${TF_TYPE}-${OS}-x86_64-1.2.0.tar.gz" |
+ "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow_jni-${TF_TYPE}-${OS}-x86_64-1.2.1.tar.gz" |
tar -xz -C ./jni
### Install on Windows
@@ -149,10 +149,10 @@ Take the following steps to install TensorFlow for Java on Linux or Mac OS:
Take the following steps to install TensorFlow for Java on Windows:
1. Download
- [libtensorflow.jar](https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-1.2.0.jar),
+ [libtensorflow.jar](https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-1.2.1.jar),
which is the TensorFlow Java Archive (JAR).
2. Download the following Java Native Interface (JNI) file appropriate for
- [TensorFlow for Java on Windows](https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow_jni-cpu-windows-x86_64-1.2.0.zip).
+ [TensorFlow for Java on Windows](https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow_jni-cpu-windows-x86_64-1.2.1.zip).
3. Extract this .zip file.
@@ -200,7 +200,7 @@ must be part of your `classpath`. For example, you can include the
downloaded `.jar` in your `classpath` by using the `-cp` compilation flag
as follows:
-<pre><b>javac -cp libtensorflow-1.2.0.jar HelloTF.java</b></pre>
+<pre><b>javac -cp libtensorflow-1.2.1.jar HelloTF.java</b></pre>
### Running
@@ -214,11 +214,11 @@ two files are available to the JVM:
For example, the following command line executes the `HelloTF` program on Linux
and Mac OS X:
-<pre><b>java -cp libtensorflow-1.2.0.jar:. -Djava.library.path=./jni HelloTF</b></pre>
+<pre><b>java -cp libtensorflow-1.2.1.jar:. -Djava.library.path=./jni HelloTF</b></pre>
And the following command line executes the `HelloTF` program on Windows:
-<pre><b>java -cp libtensorflow-1.2.0.jar;. -Djava.library.path=jni HelloTF</b></pre>
+<pre><b>java -cp libtensorflow-1.2.1.jar;. -Djava.library.path=jni HelloTF</b></pre>
If the program prints <tt>Hello from <i>version</i></tt>, you've successfully
installed TensorFlow for Java and are ready to use the API. If the program
diff --git a/tensorflow/docs_src/install/install_linux.md b/tensorflow/docs_src/install/install_linux.md
index 99f27d7b85..c371712f57 100644
--- a/tensorflow/docs_src/install/install_linux.md
+++ b/tensorflow/docs_src/install/install_linux.md
@@ -171,8 +171,8 @@ Take the following steps to install TensorFlow with Virtualenv:
issue the following command to install TensorFlow in the active
virtualenv environment:
- <pre>(tensorflow)$ <b>pip install --upgrade \
- https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.0-cp27-none-linux_x86_64.whl</b></pre>
+ <pre>(tensorflow)$ <b>pip3 install --upgrade \
+ https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.1-cp34-cp34m-linux_x86_64.whl</b></pre>
If you encounter installation problems, see
[Common Installation Problems](#common_installation_problems).
@@ -276,8 +276,8 @@ take the following steps:
the following command:
<pre>
- $ <b>sudo pip install --upgrade \
- https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.0-cp27-none-linux_x86_64.whl</b>
+ $ <b>sudo pip3 install --upgrade \
+ https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.1-cp34-cp34m-linux_x86_64.whl</b>
</pre>
If this step fails, see
@@ -464,7 +464,7 @@ Take the following steps to install TensorFlow in an Anaconda environment:
<pre>
(tensorflow)$ <b>pip install --ignore-installed --upgrade \
- https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.0-cp27-none-linux_x86_64.whl</b></pre>
+ https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.1-cp34-cp34m-linux_x86_64.whl</b></pre>
<a name="ValidateYourInstallation"></a>
@@ -632,14 +632,14 @@ This section documents the relevant values for Linux installations.
CPU only:
<pre>
-https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.0-cp27-none-linux_x86_64.whl
+https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.1-cp27-none-linux_x86_64.whl
</pre>
GPU support:
<pre>
-https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.2.0-cp27-none-linux_x86_64.whl
+https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.2.1-cp27-none-linux_x86_64.whl
</pre>
Note that GPU support requires the NVIDIA hardware and software described in
@@ -651,14 +651,14 @@ Note that GPU support requires the NVIDIA hardware and software described in
CPU only:
<pre>
-https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.0-cp34-cp34m-linux_x86_64.whl
+https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.1-cp34-cp34m-linux_x86_64.whl
</pre>
GPU support:
<pre>
-https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.2.0-cp34-cp34m-linux_x86_64.whl
+https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.2.1-cp34-cp34m-linux_x86_64.whl
</pre>
Note that GPU support requires the NVIDIA hardware and software described in
@@ -670,14 +670,14 @@ Note that GPU support requires the NVIDIA hardware and software described in
CPU only:
<pre>
-https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.0-cp35-cp35m-linux_x86_64.whl
+https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.1-cp35-cp35m-linux_x86_64.whl
</pre>
GPU support:
<pre>
-https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.2.0-cp35-cp35m-linux_x86_64.whl
+https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.2.1-cp35-cp35m-linux_x86_64.whl
</pre>
@@ -689,14 +689,14 @@ Note that GPU support requires the NVIDIA hardware and software described in
CPU only:
<pre>
-https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.0-cp36-cp36m-linux_x86_64.whl
+https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.1-cp36-cp36m-linux_x86_64.whl
</pre>
GPU support:
<pre>
-https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.2.0-cp36-cp36m-linux_x86_64.whl
+https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.2.1-cp36-cp36m-linux_x86_64.whl
</pre>
diff --git a/tensorflow/docs_src/install/install_mac.md b/tensorflow/docs_src/install/install_mac.md
index 8ff0fb872f..c8a9c49559 100644
--- a/tensorflow/docs_src/install/install_mac.md
+++ b/tensorflow/docs_src/install/install_mac.md
@@ -108,8 +108,8 @@ Take the following steps to install TensorFlow with Virtualenv:
Python 2.7, the command to install
TensorFlow in the active Virtualenv is as follows:
- <pre> $ <b>pip install --upgrade \
- https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.2.0-py2-none-any.whl</b></pre>
+ <pre> $ <b>pip3 install --upgrade \
+ https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.2.1-py2-none-any.whl</b></pre>
If you encounter installation problems, see
[Common Installation Problems](#common-installation-problems).
@@ -229,8 +229,8 @@ take the following steps:
you are installing TensorFlow for Mac OS and Python 2.7
issue the following command:
- <pre> $ <b>sudo pip install --upgrade \
- https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.2.0-py2-none-any.whl</b> </pre>
+ <pre> $ <b>sudo pip3 install --upgrade \
+ https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.2.1-py2-none-any.whl</b> </pre>
If the preceding command fails, see
[installation problems](#common-installation-problems).
@@ -339,7 +339,7 @@ Take the following steps to install TensorFlow in an Anaconda environment:
TensorFlow for Python 2.7:
<pre> (tensorflow)$ <b>pip install --ignore-installed --upgrade \
- https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.2.0-py2-none-any.whl</b></pre>
+ https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.2.1-py2-none-any.whl</b></pre>
<a name="ValidateYourInstallation"></a>
@@ -512,7 +512,7 @@ This section documents the relevant values for Mac OS installations.
<pre>
-https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.2.0-py2-none-any.whl
+https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.2.1-py2-none-any.whl
</pre>
@@ -520,7 +520,7 @@ https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.2.0-py2-none-any.
<pre>
-https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.2.0-py3-none-any.whl
+https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.2.1-py3-none-any.whl
</pre>
diff --git a/tensorflow/docs_src/install/install_sources.md b/tensorflow/docs_src/install/install_sources.md
index a082c3ce78..37ef3816af 100644
--- a/tensorflow/docs_src/install/install_sources.md
+++ b/tensorflow/docs_src/install/install_sources.md
@@ -342,10 +342,10 @@ Invoke `pip install` to install that pip package.
The filename of the `.whl` file depends on your platform.
For example, the following command will install the pip package
-for TensorFlow 1.2.0 on Linux:
+for TensorFlow 1.2.1 on Linux:
<pre>
-$ <b>sudo pip install /tmp/tensorflow_pkg/tensorflow-1.2.0-py2-none-any.whl</b>
+$ <b>sudo pip install /tmp/tensorflow_pkg/tensorflow-1.2.1-py2-none-any.whl</b>
</pre>
## Validate your installation
diff --git a/tensorflow/docs_src/install/install_windows.md b/tensorflow/docs_src/install/install_windows.md
index 8282afaab4..221e6d4ff1 100644
--- a/tensorflow/docs_src/install/install_windows.md
+++ b/tensorflow/docs_src/install/install_windows.md
@@ -115,12 +115,12 @@ Take the following steps to install TensorFlow in an Anaconda environment:
environment. To install the CPU-only version of TensorFlow, enter the
following command:
- <pre>(tensorflow)C:\> <b>pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.2.0-cp35-cp35m-win_amd64.whl</b> </pre>
+ <pre>(tensorflow)C:\> <b>pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.2.1-cp35-cp35m-win_amd64.whl</b> </pre>
To install the GPU version of TensorFlow, enter the following command
(on a single line):
- <pre>(tensorflow)C:\> <b>pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.2.0-cp35-cp35m-win_amd64.whl</b> </pre>
+ <pre>(tensorflow)C:\> <b>pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.2.1-cp35-cp35m-win_amd64.whl</b> </pre>
## Validate your installation
diff --git a/tensorflow/docs_src/programmers_guide/embedding.md b/tensorflow/docs_src/programmers_guide/embedding.md
index 975850349f..91beb36f96 100644
--- a/tensorflow/docs_src/programmers_guide/embedding.md
+++ b/tensorflow/docs_src/programmers_guide/embedding.md
@@ -84,7 +84,7 @@ labels/images to the data points. You can do this by generating a
[metadata file](#metadata) containing the labels for each point and configuring
the projector either by using our Python API, or manually constructing and
saving a
-<code>[projector_config.pbtxt](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/tensorboard/plugins/projector/projector_config.proto)</code>
+<code>[projector_config.pbtxt](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/tensorboard/plugins/projector/projector_config.proto)</code>
in the same directory as your checkpoint file.
### Setup
@@ -113,7 +113,7 @@ saver.save(session, os.path.join(LOG_DIR, "model.ckpt"), step)
If you have any metadata (labels, images) associated with your embedding, you
can tell TensorBoard about it either by directly storing a
-<code>[projector_config.pbtxt](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/tensorboard/plugins/projector/projector_config.proto)</code>
+<code>[projector_config.pbtxt](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/tensorboard/plugins/projector/projector_config.proto)</code>
in the <code>LOG_DIR</code>, or use our python API.
For instance, the following <code>projector_config.ptxt</code> associates the
diff --git a/tensorflow/docs_src/programmers_guide/threading_and_queues.md b/tensorflow/docs_src/programmers_guide/threading_and_queues.md
index 7f3e6f0da5..3483c7533c 100644
--- a/tensorflow/docs_src/programmers_guide/threading_and_queues.md
+++ b/tensorflow/docs_src/programmers_guide/threading_and_queues.md
@@ -97,6 +97,9 @@ Any thread can decide that the computation should stop. It only has to call
return `True`.
```python
+# Using Python's threading library.
+import threading
+
# Thread body: loop until the coordinator indicates a stop was requested.
# If some condition becomes true, ask the coordinator to stop.
def MyLoop(coord):
diff --git a/tensorflow/docs_src/programmers_guide/variables.md b/tensorflow/docs_src/programmers_guide/variables.md
index a7b7db626a..0ccd2c4899 100644
--- a/tensorflow/docs_src/programmers_guide/variables.md
+++ b/tensorflow/docs_src/programmers_guide/variables.md
@@ -410,7 +410,7 @@ calling this function repeatedly would not work:
``` python
input1 = tf.random_normal([1,10,10,32])
input2 = tf.random_normal([1,20,20,32])
-x = conv_relu(input1, kernel_shape=[5, 5, 32, 32], bias_shape=[32])
+x = conv_relu(input1, kernel_shape=[5, 5, 1, 32], bias_shape=[32])
x = conv_relu(x, kernel_shape=[5, 5, 32, 32], bias_shape = [32]) # This fails.
```
@@ -422,7 +422,7 @@ however, clarifies that we want to create new variables:
def my_image_filter(input_images):
with tf.variable_scope("conv1"):
# Variables created here will be named "conv1/weights", "conv1/biases".
- relu1 = conv_relu(input_images, [5, 5, 32, 32], [32])
+ relu1 = conv_relu(input_images, [5, 5, 1, 32], [32])
with tf.variable_scope("conv2"):
# Variables created here will be named "conv2/weights", "conv2/biases".
return conv_relu(relu1, [5, 5, 32, 32], [32])
diff --git a/tensorflow/docs_src/programmers_guide/version_compat.md b/tensorflow/docs_src/programmers_guide/version_compat.md
index 13c410fada..db6d596acf 100644
--- a/tensorflow/docs_src/programmers_guide/version_compat.md
+++ b/tensorflow/docs_src/programmers_guide/version_compat.md
@@ -54,7 +54,7 @@ patch versions. The public APIs consist of
* [`event`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/util/event.proto)
* [`graph`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/graph.proto)
* [`op_def`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/op_def.proto)
- * [`reader_base`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/kernels/reader_base.proto)
+ * [`reader_base`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/reader_base.proto)
* [`summary`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/summary.proto)
* [`tensor`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/tensor.proto)
* [`tensor_shape`](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/tensor_shape.proto)
diff --git a/tensorflow/docs_src/tutorials/deep_cnn.md b/tensorflow/docs_src/tutorials/deep_cnn.md
index adf66b904e..a9802b0849 100644
--- a/tensorflow/docs_src/tutorials/deep_cnn.md
+++ b/tensorflow/docs_src/tutorials/deep_cnn.md
@@ -178,7 +178,7 @@ the network architecture to return normalized predictions using
@{tf.nn.softmax}.
The `inputs()` and `inference()` functions provide all the components
-necessary to perform evaluation on a model. We now shift our focus towards
+necessary to perform an evaluation of a model. We now shift our focus towards
building operations for training a model.
> **EXERCISE:** The model architecture in `inference()` differs slightly from
diff --git a/tensorflow/docs_src/tutorials/seq2seq.md b/tensorflow/docs_src/tutorials/seq2seq.md
index dd2ca8d524..84c8a9c9f3 100644
--- a/tensorflow/docs_src/tutorials/seq2seq.md
+++ b/tensorflow/docs_src/tutorials/seq2seq.md
@@ -140,7 +140,7 @@ When training models with large output vocabularies, i.e., when
tensors. Instead, it is better to return smaller output tensors, which will
later be projected onto a large output tensor using `output_projection`.
This allows to use our seq2seq models with a sampled softmax loss, as described
-in [Jean et. al., 2014](http://arxiv.org/abs/1412.2007)
+in [Jean et al., 2014](http://arxiv.org/abs/1412.2007)
([pdf](http://arxiv.org/pdf/1412.2007.pdf)).
In addition to `basic_rnn_seq2seq` and `embedding_rnn_seq2seq` there are a few
diff --git a/tensorflow/examples/ios/README.md b/tensorflow/examples/ios/README.md
index a412381196..7974b8c879 100644
--- a/tensorflow/examples/ios/README.md
+++ b/tensorflow/examples/ios/README.md
@@ -66,7 +66,7 @@ target 'YourProjectName'
```
- Then you run ```pod install``` to download and install the
- TensorFlow-experimental pod, and finaly perform
+ TensorFlow-experimental pod, and finally perform
```open YourProjectName.xcworkspace``` and add your code.
- In your apps "Build Settings", make sure to add $(inherited) to sections
diff --git a/tensorflow/go/op/wrappers.go b/tensorflow/go/op/wrappers.go
index 0025692146..5b53bd81f7 100644
--- a/tensorflow/go/op/wrappers.go
+++ b/tensorflow/go/op/wrappers.go
@@ -14306,6 +14306,51 @@ func Tanh(scope *Scope, x tf.Output) (y tf.Output) {
return op.Output(0)
}
+// Computes inverse hyperbolic sine of x element-wise.
+func Asinh(scope *Scope, x tf.Output) (y tf.Output) {
+ if scope.Err() != nil {
+ return
+ }
+ opspec := tf.OpSpec{
+ Type: "Asinh",
+ Input: []tf.Input{
+ x,
+ },
+ }
+ op := scope.AddOperation(opspec)
+ return op.Output(0)
+}
+
+// Computes inverse hyperbolic cosine of x element-wise.
+func Acosh(scope *Scope, x tf.Output) (y tf.Output) {
+ if scope.Err() != nil {
+ return
+ }
+ opspec := tf.OpSpec{
+ Type: "Acosh",
+ Input: []tf.Input{
+ x,
+ },
+ }
+ op := scope.AddOperation(opspec)
+ return op.Output(0)
+}
+
+// Computes inverse hyperbolic tangent of x element-wise.
+func Atanh(scope *Scope, x tf.Output) (y tf.Output) {
+ if scope.Err() != nil {
+ return
+ }
+ opspec := tf.OpSpec{
+ Type: "Atanh",
+ Input: []tf.Input{
+ x,
+ },
+ }
+ op := scope.AddOperation(opspec)
+ return op.Output(0)
+}
+
// TextLineReaderV2Attr is an optional argument to TextLineReaderV2.
type TextLineReaderV2Attr func(optionalAttr)
diff --git a/tensorflow/java/src/main/java/org/tensorflow/Input.java b/tensorflow/java/src/main/java/org/tensorflow/Input.java
index dff3a45463..8e6685ee0f 100644
--- a/tensorflow/java/src/main/java/org/tensorflow/Input.java
+++ b/tensorflow/java/src/main/java/org/tensorflow/Input.java
@@ -42,7 +42,7 @@ public interface Input {
* <p>Inputs to TensorFlow operations are outputs of another TensorFlow operation. This method is
* used to obtain a symbolic handle that represents the computation of the input.
*
- * @see {@link OperationBuilder#addInput(Output)}.
+ * @see OperationBuilder#addInput(Output)
*/
Output asOutput();
}
diff --git a/tensorflow/java/src/main/java/org/tensorflow/Operation.java b/tensorflow/java/src/main/java/org/tensorflow/Operation.java
index 200350f7ae..d584085282 100644
--- a/tensorflow/java/src/main/java/org/tensorflow/Operation.java
+++ b/tensorflow/java/src/main/java/org/tensorflow/Operation.java
@@ -139,7 +139,7 @@ public final class Operation {
*
* @param name identifier of the list of tensors (of which there may be many) inputs to this
* operation.
- * @returns the size of the list of Tensors produced by this named input.
+ * @return the size of the list of Tensors produced by this named input.
* @throws IllegalArgumentException if this operation has no input with the provided name.
*/
public int inputListLength(final String name) {
diff --git a/tensorflow/java/src/main/java/org/tensorflow/OperationBuilder.java b/tensorflow/java/src/main/java/org/tensorflow/OperationBuilder.java
index 8f7559d39e..15077ce439 100644
--- a/tensorflow/java/src/main/java/org/tensorflow/OperationBuilder.java
+++ b/tensorflow/java/src/main/java/org/tensorflow/OperationBuilder.java
@@ -63,6 +63,16 @@ public final class OperationBuilder {
}
}
+
+ /**
+ * Returns the builder to create an operation.
+ *
+ * <p>Inputs to TensorFlow operations are outputs of another TensorFlow operation. This method is
+ * used to add a input to a {@link OperationBuilder}.
+ *
+ * @param input {@link Output} supposed to be the input of the OperationBuilder.
+ * @return the OperationBuilder instance for chaining.
+ */
public OperationBuilder addInput(Output input) {
Graph.Reference r = graph.ref();
try {
@@ -256,6 +266,21 @@ public final class OperationBuilder {
return this;
}
+ public OperationBuilder setAttr(String name, String[] value) {
+ Charset utf8 = Charset.forName("UTF-8");
+ Object[] objects = new Object[value.length];
+ for (int i = 0; i < value.length; ++i) {
+ objects[i] = value[i].getBytes(utf8);
+ }
+ Graph.Reference r = graph.ref();
+ try {
+ setAttrStringList(unsafeNativeHandle, name, objects);
+ } finally {
+ r.close();
+ }
+ return this;
+ }
+
private long unsafeNativeHandle;
private Graph graph;
@@ -273,10 +298,7 @@ public final class OperationBuilder {
// The names of all the setAttr* family functions below correspond to the C library types, not the
// Java library types. Roughly, setAttrFoo calls the TensorFlow C library function: TF_SetAttrFoo.
- //
// TODO(ashankar):
- // - setAttrStringList: Which would take in an array of byte[] (java Strings will need to be UTF-8
- // encoded?)
// - setAttrShapeList: Which would take in a long[][]
private static native void setAttrString(long handle, String name, byte[] value);
@@ -302,4 +324,7 @@ public final class OperationBuilder {
private static native void setAttrTensorList(long handle, String name, long[] tensorHandle);
private static native void setAttrShape(long handle, String name, long[] shape, int numDims);
+
+ private static native void setAttrStringList(long handle, String name, Object[] value);
+
}
diff --git a/tensorflow/java/src/main/java/org/tensorflow/Session.java b/tensorflow/java/src/main/java/org/tensorflow/Session.java
index f73cded4e3..83a300a560 100644
--- a/tensorflow/java/src/main/java/org/tensorflow/Session.java
+++ b/tensorflow/java/src/main/java/org/tensorflow/Session.java
@@ -113,7 +113,7 @@ public final class Session implements AutoCloseable {
*
* <p>A Runner runs the necessary graph fragments to execute every {@link Operation} required to
* evaluate the {@link Tensor}s to fetch. The {@link #feed(String,int,Tensor)} call allows callers
- * to override the value of {@link Tensor}s in the graph by substituing the provided {@link
+ * to override the value of {@link Tensor}s in the graph by substituting the provided {@link
* Tensor}s for the outputs of the operations provided to {@link #feed(String,int,Tensor)}.
*/
public final class Runner {
diff --git a/tensorflow/java/src/main/java/org/tensorflow/Shape.java b/tensorflow/java/src/main/java/org/tensorflow/Shape.java
index 90d6cf7b85..9aa92be111 100644
--- a/tensorflow/java/src/main/java/org/tensorflow/Shape.java
+++ b/tensorflow/java/src/main/java/org/tensorflow/Shape.java
@@ -77,7 +77,7 @@ public final class Shape {
return shape[i];
}
- /** Succint description of the shape meant for debugging. */
+ /** Succinct description of the shape meant for debugging. */
@Override
public String toString() {
if (shape == null) {
diff --git a/tensorflow/java/src/main/native/operation_builder_jni.cc b/tensorflow/java/src/main/native/operation_builder_jni.cc
index a7696182c7..37f01a943a 100644
--- a/tensorflow/java/src/main/native/operation_builder_jni.cc
+++ b/tensorflow/java/src/main/native/operation_builder_jni.cc
@@ -257,3 +257,30 @@ JNIEXPORT void JNICALL Java_org_tensorflow_OperationBuilder_setAttrShape(
TF_SetAttrShape(d, cname, cvalue.get(), static_cast<int>(num_dims));
env->ReleaseStringUTFChars(name, cname);
}
+
+JNIEXPORT void JNICALL Java_org_tensorflow_OperationBuilder_setAttrStringList(
+ JNIEnv* env, jclass object, jlong handle, jstring name, jobjectArray values) {
+ TF_OperationDescription* d = requireHandle(env, handle);
+ if (d == nullptr) return;
+ const char* cname = env->GetStringUTFChars(name, nullptr);
+ int num_values = env->GetArrayLength(values);
+ static_assert(sizeof(jbyte) == 1,
+ "Require Java byte to be represented as a single byte");
+ std::unique_ptr<jbyteArray[]> jarrays(new jbyteArray[num_values]);
+ std::unique_ptr<jbyte*[]> jvalues(new jbyte*[num_values]);
+ std::unique_ptr<void*[]> cvalues(new void*[num_values]);
+ std::unique_ptr<size_t[]> lengths(new size_t[num_values]);
+
+ for (int i = 0; i < num_values; ++i) {
+ jbyteArray v = static_cast<jbyteArray>(env->GetObjectArrayElement(values, i));
+ jarrays[i] = v;
+ jvalues[i] = env->GetByteArrayElements(v, nullptr);
+ cvalues[i] = jvalues[i];
+ lengths[i] = static_cast<size_t>(env->GetArrayLength(v));
+ }
+ TF_SetAttrStringList(d, cname, cvalues.get(), lengths.get(), num_values);
+ for (int i = 0; i < num_values; ++i) {
+ env->ReleaseByteArrayElements(jarrays[i], jvalues[i], JNI_ABORT);
+ }
+ env->ReleaseStringUTFChars(name, cname);
+}
diff --git a/tensorflow/java/src/main/native/operation_builder_jni.h b/tensorflow/java/src/main/native/operation_builder_jni.h
index 9b64c32820..2e72bd68da 100644
--- a/tensorflow/java/src/main/native/operation_builder_jni.h
+++ b/tensorflow/java/src/main/native/operation_builder_jni.h
@@ -169,6 +169,14 @@ JNIEXPORT void JNICALL Java_org_tensorflow_OperationBuilder_setAttrTensorList(
JNIEXPORT void JNICALL Java_org_tensorflow_OperationBuilder_setAttrShape(
JNIEnv *, jclass, jlong, jstring, jlongArray, jint);
+/*
+ * Class: org_tensorflow_OperationBuilder
+ * Method: setAttrStringList
+ * Signature: (JLjava/lang/String;[L)V
+ */
+JNIEXPORT void JNICALL Java_org_tensorflow_OperationBuilder_setAttrStringList(
+ JNIEnv *, jclass, jlong, jstring, jobjectArray);
+
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
diff --git a/tensorflow/python/BUILD b/tensorflow/python/BUILD
index 40667dc92d..9a5f059061 100644
--- a/tensorflow/python/BUILD
+++ b/tensorflow/python/BUILD
@@ -267,7 +267,7 @@ cc_library(
cc_binary(
name = "framework/test_file_system.so",
srcs = ["framework/test_file_system.cc"],
- copts = ["-Wno-sign-compare"],
+ copts = if_not_windows(["-Wno-sign-compare"]),
linkopts = select({
"//conditions:default": [
"-lm",
@@ -2689,7 +2689,7 @@ cc_library(
name = "cpp_shape_inference",
srcs = ["framework/cpp_shape_inference.cc"],
hdrs = ["framework/cpp_shape_inference.h"],
- copts = ["-Wno-sign-compare"],
+ copts = if_not_windows(["-Wno-sign-compare"]),
visibility = ["//visibility:public"],
deps = [
":cpp_shape_inference_proto_cc",
diff --git a/tensorflow/python/client/tf_session_helper.cc b/tensorflow/python/client/tf_session_helper.cc
index 0e89ae2426..5c04a8c2a5 100644
--- a/tensorflow/python/client/tf_session_helper.cc
+++ b/tensorflow/python/client/tf_session_helper.cc
@@ -690,7 +690,7 @@ void TF_SessionRun_wrapper_helper(TF_Session* session, const char* handle,
// Convert outputs to ndarrays (in scoped containers)
std::vector<Safe_PyObjectPtr> py_outputs_safe;
- for (int i = 0; i < outputs.size(); ++i) {
+ for (size_t i = 0; i < outputs.size(); ++i) {
PyObject* py_array;
s = TFTensorToPyArray(std::move(output_vals_safe[i]), &py_array);
if (!s.ok()) {
@@ -702,7 +702,7 @@ void TF_SessionRun_wrapper_helper(TF_Session* session, const char* handle,
// If we reach this point, we have successfully built a list of objects so we
// can release them from the safe container into the return vector.
- for (int i = 0; i < outputs.size(); ++i) {
+ for (size_t i = 0; i < outputs.size(); ++i) {
py_outputs->push_back(py_outputs_safe[i].release());
}
}
diff --git a/tensorflow/python/estimator/canned/linear_testing_utils.py b/tensorflow/python/estimator/canned/linear_testing_utils.py
index 965ac8cbdd..c9bde91f9b 100644
--- a/tensorflow/python/estimator/canned/linear_testing_utils.py
+++ b/tensorflow/python/estimator/canned/linear_testing_utils.py
@@ -124,7 +124,7 @@ def sigmoid(x):
class CheckPartitionerVarHook(session_run_hook.SessionRunHook):
- """A `SessionRunHook` to check a paritioned variable."""
+ """A `SessionRunHook` to check a partitioned variable."""
def __init__(self, test_case, var_name, var_dim, partitions):
self._test_case = test_case
diff --git a/tensorflow/python/framework/ops.py b/tensorflow/python/framework/ops.py
index 7fbbe204b0..638ed7ef4b 100644
--- a/tensorflow/python/framework/ops.py
+++ b/tensorflow/python/framework/ops.py
@@ -3915,6 +3915,9 @@ class _DefaultStack(threading.local):
def reset(self):
self.stack = []
+ def is_cleared(self):
+ return self.stack == []
+
@property
def enforce_nesting(self):
return self._enforce_nesting
@@ -4120,7 +4123,13 @@ def reset_default_graph():
a `tf.Session` or `tf.InteractiveSession` is active will result in undefined
behavior. Using any previously created `tf.Operation` or `tf.Tensor` objects
after calling this function will result in undefined behavior.
+ Raises:
+ AssertionError: If this function is called within a nested graph.
"""
+ if not _default_graph_stack.is_cleared():
+ raise AssertionError("Do not use tf.reset_default_graph() to clear "
+ "nested graphs. If you need a cleared graph, "
+ "exit the nesting and create a new graph.")
_default_graph_stack.reset()
diff --git a/tensorflow/python/framework/ops_test.py b/tensorflow/python/framework/ops_test.py
index 2d0a6cbf8a..01841e6306 100644
--- a/tensorflow/python/framework/ops_test.py
+++ b/tensorflow/python/framework/ops_test.py
@@ -1315,6 +1315,12 @@ class GraphTest(test_util.TensorFlowTestCase):
def _AssertDefault(self, expected):
self.assertIs(expected, ops.get_default_graph())
+ def testResetDefaultGraphNesting(self):
+ g0 = ops.Graph()
+ with self.assertRaises(AssertionError):
+ with g0.as_default():
+ ops.reset_default_graph()
+
def testGraphContextManager(self):
g0 = ops.Graph()
with g0.as_default() as g1:
diff --git a/tensorflow/python/framework/tensor_shape.py b/tensorflow/python/framework/tensor_shape.py
index 155fa4719b..66c05335b4 100644
--- a/tensorflow/python/framework/tensor_shape.py
+++ b/tensorflow/python/framework/tensor_shape.py
@@ -365,7 +365,7 @@ class Dimension(object):
def as_dimension(value):
"""Converts the given value to a Dimension.
- A Dimenson input will be returned unmodified.
+ A Dimension input will be returned unmodified.
An input of `None` will be converted to an unknown Dimension.
An integer input will be converted to a Dimension with that value.
diff --git a/tensorflow/python/framework/test_util.py b/tensorflow/python/framework/test_util.py
index 71328a7f88..5ba226ce07 100644
--- a/tensorflow/python/framework/test_util.py
+++ b/tensorflow/python/framework/test_util.py
@@ -266,6 +266,13 @@ class TensorFlowTestCase(googletest.TestCase):
self._ClearCachedSession()
random.seed(random_seed.DEFAULT_GRAPH_SEED)
np.random.seed(random_seed.DEFAULT_GRAPH_SEED)
+ # Note: The following line is necessary because some test methods may error
+ # out from within nested graph contexts (e.g., via assertRaises and
+ # assertRaisesRegexp), which may leave ops._default_graph_stack non-empty
+ # under certain versions of Python. That would cause
+ # ops.reset_default_graph() to throw an exception if the stack were not
+ # cleared first.
+ ops._default_graph_stack.reset() # pylint: disable=protected-access
ops.reset_default_graph()
ops.get_default_graph().seed = random_seed.DEFAULT_GRAPH_SEED
diff --git a/tensorflow/python/kernel_tests/BUILD b/tensorflow/python/kernel_tests/BUILD
index dc52cedb80..17b646d17c 100644
--- a/tensorflow/python/kernel_tests/BUILD
+++ b/tensorflow/python/kernel_tests/BUILD
@@ -729,6 +729,18 @@ tf_py_test(
)
tf_py_test(
+ name = "sparse_slice_op_test",
+ size = "small",
+ srcs = ["sparse_slice_op_test.py"],
+ additional_deps = [
+ "//third_party/py/numpy",
+ "//tensorflow/python:client_testlib",
+ "//tensorflow/python:framework",
+ "//tensorflow/python:sparse_ops",
+ ],
+)
+
+tf_py_test(
name = "sparse_to_dense_op_py_test",
size = "small",
srcs = ["sparse_to_dense_op_py_test.py"],
diff --git a/tensorflow/python/kernel_tests/basic_gpu_test.py b/tensorflow/python/kernel_tests/basic_gpu_test.py
index b5b17ff80a..155aad8bd9 100644
--- a/tensorflow/python/kernel_tests/basic_gpu_test.py
+++ b/tensorflow/python/kernel_tests/basic_gpu_test.py
@@ -107,9 +107,12 @@ class MathBuiltinUnaryTest(test.TestCase):
def _testDtype(self, dtype, use_gpu):
data = (np.arange(-3, 3) / 4.).reshape([1, 3, 2]).astype(dtype)
+ data_gt_1 = data + 2 # for x > 1
self._compare(data, np.abs, math_ops.abs, use_gpu)
self._compare(data, np.arccos, math_ops.acos, use_gpu)
self._compare(data, np.arcsin, math_ops.asin, use_gpu)
+ self._compare(data, np.arcsinh, math_ops.asinh, use_gpu)
+ self._compare(data_gt_1, np.arccosh, math_ops.acosh, use_gpu)
self._compare(data, np.arctan, math_ops.atan, use_gpu)
self._compare(data, np.ceil, math_ops.ceil, use_gpu)
self._compare(data, np.cos, math_ops.cos, use_gpu)
@@ -126,6 +129,7 @@ class MathBuiltinUnaryTest(test.TestCase):
self._compare(data, np.square, math_ops.square, use_gpu)
self._compare(data, np.tan, math_ops.tan, use_gpu)
self._compare(data, np.tanh, math_ops.tanh, use_gpu)
+ self._compare(data, np.arctanh, math_ops.atanh, use_gpu)
def testTypes(self):
for dtype in [np.float32]:
diff --git a/tensorflow/python/kernel_tests/cast_op_test.py b/tensorflow/python/kernel_tests/cast_op_test.py
index 17771e0572..c785f2358d 100644
--- a/tensorflow/python/kernel_tests/cast_op_test.py
+++ b/tensorflow/python/kernel_tests/cast_op_test.py
@@ -20,6 +20,7 @@ from __future__ import print_function
import numpy as np
import sys
+import platform
from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
@@ -146,9 +147,16 @@ class CastOpTest(test.TestCase):
if sys.byteorder == "big":
self._compare(np.inf, np.int32, i4.max, False)
self._compare(np.inf, np.int64, i8.max, False)
- else:
- self._compare(np.inf, np.int32, i4.min, False)
- self._compare(np.inf, np.int64, i8.min, False)
+ else:
+ # np.float64("np.inf").astype(np.int32) is negative on x86 but positive on ppc64le
+ # Numpy link to relevant discussion - https://github.com/numpy/numpy/issues/9040
+ # Tensorflow link to relevant discussion - https://github.com/tensorflow/tensorflow/issues/9360
+ if platform.machine() == "ppc64le":
+ self._compare(-np.inf, np.int32, i4.min, False)
+ self._compare(-np.inf, np.int64, i8.min, False)
+ else:
+ self._compare(np.inf, np.int32, i4.min, False)
+ self._compare(np.inf, np.int64, i8.min, False)
self._compare(-np.inf, np.float32, -np.inf, False)
self._compare(-np.inf, np.float64, -np.inf, False)
self._compare(-np.inf, np.int32, i4.min, False)
diff --git a/tensorflow/python/kernel_tests/cwise_ops_test.py b/tensorflow/python/kernel_tests/cwise_ops_test.py
index b47139e6b8..5a0fb1879a 100644
--- a/tensorflow/python/kernel_tests/cwise_ops_test.py
+++ b/tensorflow/python/kernel_tests/cwise_ops_test.py
@@ -184,6 +184,7 @@ class UnaryOpTest(test.TestCase):
def testFloatBasic(self):
x = np.arange(-3, 3).reshape(1, 3, 2).astype(np.float32)
+ w = x - x.min() + 1.01 # all greater than 1
y = (x + .5).astype(np.float32) # no zero
z = (x + 15.5).astype(np.float32) # all positive
k = np.arange(-0.90, 0.90, 0.25).astype(np.float32) # between -1 and 1
@@ -203,6 +204,10 @@ class UnaryOpTest(test.TestCase):
self._compareBoth(x, np.sinh, math_ops.sinh)
self._compareBoth(x, np.cosh, math_ops.cosh)
self._compareBoth(x, np.tanh, math_ops.tanh)
+ # b/63457572: failing under CUDA.
+ # self._compareBoth(x, np.arcsinh, math_ops.asinh)
+ # self._compareBoth(w, np.arccosh, math_ops.acosh)
+ # self._compareBoth(k, np.arctanh, math_ops.atanh)
self._compareBoth(x, self._sigmoid, math_ops.sigmoid)
self._compareBoth(x, self._log_sigmoid, math_ops.log_sigmoid)
self._compareBoth(y, np.sign, math_ops.sign)
@@ -248,6 +253,8 @@ class UnaryOpTest(test.TestCase):
self._compareBoth(x, np.log, math_ops.log)
self._compareBoth(x, np.log1p, math_ops.log1p)
self._compareBoth(x, np.sinh, math_ops.sinh)
+ # b/63457572.
+ # self._compareBoth(x, np.arcsinh, math_ops.asinh)
self._compareBoth(x, np.cosh, math_ops.cosh)
self._compareBoth(x, np.tanh, math_ops.tanh)
self._compareBoth(x, self._sigmoid, math_ops.sigmoid)
@@ -273,6 +280,7 @@ class UnaryOpTest(test.TestCase):
def testDoubleBasic(self):
x = np.arange(-3, 3).reshape(1, 3, 2).astype(np.float64)
+ w = x - x.min() + 1.01 # all greater than 1
y = (x + .5).astype(np.float64) # no zero
z = (x + 15.5).astype(np.float64) # all positive
k = np.arange(-0.90, 0.90, 0.35).reshape(1, 3, 2).astype(
@@ -292,6 +300,10 @@ class UnaryOpTest(test.TestCase):
self._compareBoth(x, np.sinh, math_ops.sinh)
self._compareBoth(x, np.cosh, math_ops.cosh)
self._compareBoth(x, np.tanh, math_ops.tanh)
+ # b/63457572: failing under CUDA.
+ # self._compareBoth(x, np.arcsinh, math_ops.asinh)
+ # self._compareBoth(w, np.arccosh, math_ops.acosh)
+ # self._compareBoth(k, np.arctanh, math_ops.atanh)
self._compareBoth(x, self._sigmoid, math_ops.sigmoid)
self._compareBoth(y, np.sign, math_ops.sign)
self._compareBoth(x, np.sin, math_ops.sin)
@@ -398,6 +410,10 @@ class UnaryOpTest(test.TestCase):
self._compareCpu(x, np.sinh, math_ops.sinh)
self._compareCpu(x, np.cosh, math_ops.cosh)
self._compareCpu(x, np.tanh, math_ops.tanh)
+ # b/63457572: failing under CUDA.
+ # self._compareCpu(x, np.arcsinh, math_ops.asinh)
+ # self._compareCpu(x, np.arccosh, math_ops.acosh)
+ # self._compareCpu(x, np.arctanh, math_ops.atanh)
self._compareCpu(x, self._sigmoid, math_ops.sigmoid)
self._compareCpu(x, np.sin, math_ops.sin)
self._compareCpu(x, np.cos, math_ops.cos)
@@ -434,6 +450,10 @@ class UnaryOpTest(test.TestCase):
self._compareCpu(x, np.sinh, math_ops.sinh)
self._compareCpu(x, np.cosh, math_ops.cosh)
self._compareCpu(x, np.tanh, math_ops.tanh)
+ # b/63457572, failing under CUDA.
+ # self._compareCpu(x, np.arcsinh, math_ops.asinh)
+ # self._compareCpu(x, np.arccosh, math_ops.acosh)
+ # self._compareCpu(x, np.arctanh, math_ops.atanh)
self._compareCpu(x, self._sigmoid, math_ops.sigmoid)
self._compareCpu(x, np.sin, math_ops.sin)
self._compareCpu(x, np.cos, math_ops.cos)
diff --git a/tensorflow/python/kernel_tests/map_stage_op_test.py b/tensorflow/python/kernel_tests/map_stage_op_test.py
index 4ceb24862f..64f8f4bb6d 100644
--- a/tensorflow/python/kernel_tests/map_stage_op_test.py
+++ b/tensorflow/python/kernel_tests/map_stage_op_test.py
@@ -108,8 +108,8 @@ class MapStageTest(test.TestCase):
with ops.device(gpu_dev):
stager = data_flow_ops.MapStagingArea([dtypes.float32])
y = stager.put(1, [v], [0])
- self.assertEqual(y.device, '/device:GPU:0' if gpu_dev
- else gpu_dev)
+ expected_name = gpu_dev if 'gpu' not in gpu_dev else '/device:GPU:0'
+ self.assertEqual(y.device, expected_name)
with ops.device('/cpu:0'):
_, x = stager.get(1)
y = stager.peek(1)
diff --git a/tensorflow/python/kernel_tests/pooling_ops_test.py b/tensorflow/python/kernel_tests/pooling_ops_test.py
index 1b6c8bef98..f5fb7e4e03 100644
--- a/tensorflow/python/kernel_tests/pooling_ops_test.py
+++ b/tensorflow/python/kernel_tests/pooling_ops_test.py
@@ -521,7 +521,7 @@ class PoolingTest(test.TestCase):
padding="SAME").eval()
# The following are tests that verify that the CPU and GPU implementations
- # produce the same resuts.
+ # produce the same results.
def _CompareMaxPoolingFwd(self, input_shape, ksize, strides, padding):
for dtype in np.float64, np.float32, np.float16:
tensor_input = np.random.rand(*input_shape).astype(dtype)
diff --git a/tensorflow/python/kernel_tests/reader_ops_test.py b/tensorflow/python/kernel_tests/reader_ops_test.py
index c7e1d88360..5630259b7b 100644
--- a/tensorflow/python/kernel_tests/reader_ops_test.py
+++ b/tensorflow/python/kernel_tests/reader_ops_test.py
@@ -350,13 +350,11 @@ class FixedLengthRecordReaderTest(test.TestCase):
def setUp(self):
super(FixedLengthRecordReaderTest, self).setUp()
self._num_files = 2
- self._num_records = 7
self._header_bytes = 5
self._record_bytes = 3
self._footer_bytes = 2
self._hop_bytes = 2
- self._num_overlapped_records = 3
def _Record(self, f, r):
return compat.as_bytes(str(f * 2 + r) * self._record_bytes)
@@ -369,19 +367,24 @@ class FixedLengthRecordReaderTest(test.TestCase):
])
return compat.as_bytes(record_str)
- def _CreateFiles(self):
+ # gap_bytes=hop_bytes-record_bytes
+ def _CreateFiles(self, num_records, gap_bytes):
filenames = []
for i in range(self._num_files):
fn = os.path.join(self.get_temp_dir(), "fixed_length_record.%d.txt" % i)
filenames.append(fn)
with open(fn, "wb") as f:
f.write(b"H" * self._header_bytes)
- for j in range(self._num_records):
+ if num_records > 0:
+ f.write(self._Record(i, 0))
+ for j in range(1, num_records):
+ if gap_bytes > 0:
+ f.write(b"G" * gap_bytes)
f.write(self._Record(i, j))
f.write(b"F" * self._footer_bytes)
return filenames
- def _CreateOverlappedRecordFiles(self):
+ def _CreateOverlappedRecordFiles(self, num_overlapped_records):
filenames = []
for i in range(self._num_files):
fn = os.path.join(self.get_temp_dir(),
@@ -389,23 +392,104 @@ class FixedLengthRecordReaderTest(test.TestCase):
filenames.append(fn)
with open(fn, "wb") as f:
f.write(b"H" * self._header_bytes)
- all_records_str = "".join([
- str(i)[0]
- for i in range(self._record_bytes + self._hop_bytes *
- (self._num_overlapped_records - 1))
- ])
- f.write(compat.as_bytes(all_records_str))
+ if num_overlapped_records > 0:
+ all_records_str = "".join([
+ str(i)[0]
+ for i in range(self._record_bytes + self._hop_bytes *
+ (num_overlapped_records - 1))
+ ])
+ f.write(compat.as_bytes(all_records_str))
f.write(b"F" * self._footer_bytes)
return filenames
- def testOneEpoch(self):
- files = self._CreateFiles()
+ # gap_bytes=hop_bytes-record_bytes
+ def _CreateGzipFiles(self, num_records, gap_bytes):
+ filenames = []
+ for i in range(self._num_files):
+ fn = os.path.join(self.get_temp_dir(), "fixed_length_record.%d.txt" % i)
+ filenames.append(fn)
+ with gzip.GzipFile(fn, "wb") as f:
+ f.write(b"H" * self._header_bytes)
+ if num_records > 0:
+ f.write(self._Record(i, 0))
+ for j in range(1, num_records):
+ if gap_bytes > 0:
+ f.write(b"G" * gap_bytes)
+ f.write(self._Record(i, j))
+ f.write(b"F" * self._footer_bytes)
+ return filenames
+
+ # gap_bytes=hop_bytes-record_bytes
+ def _CreateZlibFiles(self, num_records, gap_bytes):
+ filenames = []
+ for i in range(self._num_files):
+ fn = os.path.join(self.get_temp_dir(), "fixed_length_record.%d.txt" % i)
+ filenames.append(fn)
+ with open(fn+".tmp", "wb") as f:
+ f.write(b"H" * self._header_bytes)
+ if num_records > 0:
+ f.write(self._Record(i, 0))
+ for j in range(1, num_records):
+ if gap_bytes > 0:
+ f.write(b"G" * gap_bytes)
+ f.write(self._Record(i, j))
+ f.write(b"F" * self._footer_bytes)
+ with open(fn+".tmp", "rb") as f:
+ cdata = zlib.compress(f.read())
+ with open(fn, "wb") as zf:
+ zf.write(cdata)
+ return filenames
+
+ def _CreateGzipOverlappedRecordFiles(self, num_overlapped_records):
+ filenames = []
+ for i in range(self._num_files):
+ fn = os.path.join(self.get_temp_dir(),
+ "fixed_length_overlapped_record.%d.txt" % i)
+ filenames.append(fn)
+ with gzip.GzipFile(fn, "wb") as f:
+ f.write(b"H" * self._header_bytes)
+ if num_overlapped_records > 0:
+ all_records_str = "".join([
+ str(i)[0]
+ for i in range(self._record_bytes + self._hop_bytes *
+ (num_overlapped_records - 1))
+ ])
+ f.write(compat.as_bytes(all_records_str))
+ f.write(b"F" * self._footer_bytes)
+ return filenames
+
+ def _CreateZlibOverlappedRecordFiles(self, num_overlapped_records):
+ filenames = []
+ for i in range(self._num_files):
+ fn = os.path.join(self.get_temp_dir(),
+ "fixed_length_overlapped_record.%d.txt" % i)
+ filenames.append(fn)
+ with open(fn+".tmp", "wb") as f:
+ f.write(b"H" * self._header_bytes)
+ if num_overlapped_records > 0:
+ all_records_str = "".join([
+ str(i)[0]
+ for i in range(self._record_bytes + self._hop_bytes *
+ (num_overlapped_records - 1))
+ ])
+ f.write(compat.as_bytes(all_records_str))
+ f.write(b"F" * self._footer_bytes)
+ with open(fn+".tmp", "rb") as f:
+ cdata = zlib.compress(f.read())
+ with open(fn, "wb") as zf:
+ zf.write(cdata)
+ return filenames
+
+ # gap_bytes=hop_bytes-record_bytes
+ def _TestOneEpoch(self, files, num_records, gap_bytes, encoding=None):
+ hop_bytes = 0 if gap_bytes == 0 else self._record_bytes + gap_bytes
with self.test_session() as sess:
reader = io_ops.FixedLengthRecordReader(
header_bytes=self._header_bytes,
record_bytes=self._record_bytes,
footer_bytes=self._footer_bytes,
- hop_bytes=0,
+ hop_bytes=hop_bytes,
+ encoding=encoding,
name="test_reader")
queue = data_flow_ops.FIFOQueue(99, [dtypes.string], shapes=())
key, value = reader.read(queue)
@@ -413,7 +497,7 @@ class FixedLengthRecordReaderTest(test.TestCase):
queue.enqueue_many([files]).run()
queue.close().run()
for i in range(self._num_files):
- for j in range(self._num_records):
+ for j in range(num_records):
k, v = sess.run([key, value])
self.assertAllEqual("%s:%d" % (files[i], j), compat.as_text(k))
self.assertAllEqual(self._Record(i, j), v)
@@ -422,14 +506,14 @@ class FixedLengthRecordReaderTest(test.TestCase):
"\\(requested 1, current size 0\\)"):
k, v = sess.run([key, value])
- def testOneEpochWithHopBytes(self):
- files = self._CreateOverlappedRecordFiles()
+ def _TestOneEpochWithHopBytes(self, files, num_overlapped_records, encoding=None):
with self.test_session() as sess:
reader = io_ops.FixedLengthRecordReader(
header_bytes=self._header_bytes,
record_bytes=self._record_bytes,
footer_bytes=self._footer_bytes,
hop_bytes=self._hop_bytes,
+ encoding=encoding,
name="test_reader")
queue = data_flow_ops.FIFOQueue(99, [dtypes.string], shapes=())
key, value = reader.read(queue)
@@ -437,7 +521,7 @@ class FixedLengthRecordReaderTest(test.TestCase):
queue.enqueue_many([files]).run()
queue.close().run()
for i in range(self._num_files):
- for j in range(self._num_overlapped_records):
+ for j in range(num_overlapped_records):
k, v = sess.run([key, value])
print(v)
self.assertAllEqual("%s:%d" % (files[i], j), compat.as_text(k))
@@ -447,6 +531,45 @@ class FixedLengthRecordReaderTest(test.TestCase):
"\\(requested 1, current size 0\\)"):
k, v = sess.run([key, value])
+ def testOneEpoch(self):
+ for num_records in [0, 7]:
+ # gap_bytes=0: hop_bytes=0
+ # gap_bytes=1: hop_bytes=record_bytes+1
+ for gap_bytes in [0, 1]:
+ files = self._CreateFiles(num_records, gap_bytes)
+ self._TestOneEpoch(files, num_records, gap_bytes)
+
+ def testGzipOneEpoch(self):
+ for num_records in [0, 7]:
+ # gap_bytes=0: hop_bytes=0
+ # gap_bytes=1: hop_bytes=record_bytes+1
+ for gap_bytes in [0, 1]:
+ files = self._CreateGzipFiles(num_records, gap_bytes)
+ self._TestOneEpoch(files, num_records, gap_bytes, encoding="GZIP")
+
+ def testZlibOneEpoch(self):
+ for num_records in [0, 7]:
+ # gap_bytes=0: hop_bytes=0
+ # gap_bytes=1: hop_bytes=record_bytes+1
+ for gap_bytes in [0, 1]:
+ files = self._CreateZlibFiles(num_records, gap_bytes)
+ self._TestOneEpoch(files, num_records, gap_bytes, encoding="ZLIB")
+
+ def testOneEpochWithHopBytes(self):
+ for num_overlapped_records in [0, 2]:
+ files = self._CreateOverlappedRecordFiles(num_overlapped_records)
+ self._TestOneEpochWithHopBytes(files, num_overlapped_records)
+
+ def testGzipOneEpochWithHopBytes(self):
+ for num_overlapped_records in [0, 2]:
+ files = self._CreateGzipOverlappedRecordFiles(num_overlapped_records, )
+ self._TestOneEpochWithHopBytes(files, num_overlapped_records, encoding="GZIP")
+
+ def testZlibOneEpochWithHopBytes(self):
+ for num_overlapped_records in [0, 2]:
+ files = self._CreateZlibOverlappedRecordFiles(num_overlapped_records)
+ self._TestOneEpochWithHopBytes(files, num_overlapped_records, encoding="ZLIB")
+
class TFRecordReaderTest(test.TestCase):
diff --git a/tensorflow/python/kernel_tests/sparse_slice_op_test.py b/tensorflow/python/kernel_tests/sparse_slice_op_test.py
new file mode 100644
index 0000000000..762e400447
--- /dev/null
+++ b/tensorflow/python/kernel_tests/sparse_slice_op_test.py
@@ -0,0 +1,251 @@
+# 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 SparseReorder."""
+
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
+import numpy as np
+
+from tensorflow.python.framework import sparse_tensor
+from tensorflow.python.ops import sparse_ops
+from tensorflow.python.platform import test
+
+
+class SparseSliceOpTest(test.TestCase):
+
+ def _SparseTensor_4x6(self):
+ # [0 | |2 | |4 |5 ]
+ # [ |11| |13|14| ]
+ # [20| | |23| |25]
+ # [30| |32|33| |35]
+ ind = np.array([[0, 0], [0, 2], [0, 4], [0, 5], [1, 1], [1, 3], [1, 4],
+ [2, 0], [2, 3], [2, 5], [3, 0], [3, 2], [3, 3],
+ [3, 5]]).astype(np.int64)
+ val = np.array(
+ [0, 2, 4, 5, 11, 13, 14, 20, 23, 25, 30, 32, 33, 35]).astype(np.int64)
+ shape = np.array([4, 6]).astype(np.int64)
+ return sparse_tensor.SparseTensor(ind, val, shape)
+
+ def _SparseTensor_5x7(self):
+ # [0 | |2 | |4 |5 | ]
+ # [ |11| |13|14| |16]
+ # [20| | |23| |25| ]
+ # [30| |32|33| |35| ]
+ # [ |41| | |44| |46]
+ ind = np.array([[0, 0], [0, 2], [0, 4], [0, 5], [1, 1], [1, 3], [1, 4],
+ [1, 6], [2, 0], [2, 3], [2, 5], [3, 0], [3, 2], [3, 3],
+ [3, 5], [4, 1], [4, 4], [4, 6]]).astype(np.int64)
+ val = np.array(
+ [0, 2, 4, 5, 11, 13, 14, 16, 20, 23, 25, 30, 32, 33, 35, 41, 44,
+ 46]).astype(np.int64)
+ shape = np.array([5, 7]).astype(np.int64)
+ return sparse_tensor.SparseTensor(ind, val, shape)
+
+ def _SparseTensorValue_3x4x2(self):
+ # slice(:,:, 0)
+ # ['a0'| |'b0'| ]
+ # [ |'c0'| |'d0']
+ # [ | |'e0'| ]
+ # slice(:,:, 1)
+ # ['a1'| |'b1'| ]
+ # [ |'c1'| |'d1']
+ # [ | |'e1'| ]
+ ind = np.array([[0, 0, 0], [0, 0, 1], [0, 2, 0], [0, 2, 1], [1, 1, 0],
+ [1, 1, 1], [1, 3, 0], [1, 3, 1], [2, 2, 0],
+ [2, 2, 1]]).astype(np.int64)
+ val = np.array(['a0', 'a1', 'b0', 'b1', 'c0', 'c1', 'd0', 'd1', 'e0', 'e1'])
+ shape = np.array([3, 4, 2]).astype(np.int64)
+ return sparse_tensor.SparseTensorValue(ind, val, shape)
+
+ def _SparseTensor_3x4x2(self):
+ return sparse_tensor.SparseTensor.from_value(self._SparseTensorValue_3x4x2(
+ ))
+
+ def testSliceMatrixRows(self):
+ with self.test_session(use_gpu=False):
+ sp_input=self._SparseTensor_4x6()
+ sp_tensor0 = sparse_ops.sparse_slice(sp_input, [0, 0], [2, 6])
+ sp_tensor1 = sparse_ops.sparse_slice(sp_input, [2, 0], [3, 7])
+ self.assertAllEqual(sp_tensor0.indices.eval(), [[0, 0], [0, 2], [0, 4],
+ [0, 5], [1, 1], [1, 3],
+ [1, 4]])
+ self.assertAllEqual(sp_tensor0.values.eval(), [0, 2, 4, 5, 11, 13, 14])
+ self.assertAllEqual(sp_tensor0.dense_shape.eval(), [2, 6])
+ self.assertAllEqual(sp_tensor1.indices.eval(), [[0, 0], [0, 3], [0, 5],
+ [1, 0], [1, 2], [1, 3],
+ [1, 5]])
+ self.assertAllEqual(sp_tensor1.values.eval(),
+ [20, 23, 25, 30, 32, 33, 35])
+ self.assertAllEqual(sp_tensor1.dense_shape.eval(), [2, 6])
+
+ def testSliceMatrixUnevenCols(self):
+ with self.test_session(use_gpu=False):
+ sp_input=self._SparseTensor_5x7()
+ sp_tensor0 = sparse_ops.sparse_slice(sp_input, [0, 0], [5, 3])
+ sp_tensor1 = sparse_ops.sparse_slice(sp_input, [0, 3], [5, 2])
+ sp_tensor2 = sparse_ops.sparse_slice(sp_input, [0, 5], [5, 2])
+
+ self.assertAllEqual(sp_tensor0.indices.eval(),
+ [[0, 0], [0, 2], [1, 1], [2, 0], [3, 0], [3, 2],
+ [4, 1]])
+ self.assertAllEqual(sp_tensor0.values.eval(),
+ [0, 2, 11, 20, 30, 32, 41])
+ self.assertAllEqual(sp_tensor0.dense_shape.eval(), [5, 3])
+ self.assertAllEqual(sp_tensor1.indices.eval(),
+ [[0, 1], [1, 0], [1, 1], [2, 0], [3, 0], [4, 1]])
+ self.assertAllEqual(sp_tensor1.values.eval(),
+ [4, 13, 14, 23, 33, 44])
+ self.assertAllEqual(sp_tensor1.dense_shape.eval(), [5, 2])
+ self.assertAllEqual(sp_tensor2.indices.eval(),
+ [[0, 0], [1, 1], [2, 0], [3, 0], [4, 1]])
+ self.assertAllEqual(sp_tensor2.values.eval(), [5, 16, 25, 35, 46])
+ self.assertAllEqual(sp_tensor2.dense_shape.eval(), [5, 2])
+
+ sp_tensor0 = sparse_ops.sparse_slice(sp_input, [0, 0], [5, 2])
+ sp_tensor1 = sparse_ops.sparse_slice(sp_input, [0, 2], [5, 2])
+ sp_tensor2 = sparse_ops.sparse_slice(sp_input, [0, 4], [5, 2])
+ sp_tensor3 = sparse_ops.sparse_slice(sp_input, [0, 6], [5, 2])
+ self.assertAllEqual(sp_tensor0.indices.eval(),
+ [[0, 0], [1, 1], [2, 0], [3, 0], [4, 1]])
+ self.assertAllEqual(sp_tensor0.values.eval(), [0, 11, 20, 30, 41])
+ self.assertAllEqual(sp_tensor0.dense_shape.eval(), [5, 2])
+ self.assertAllEqual(sp_tensor1.indices.eval(),
+ [[0, 0], [1, 1], [2, 1], [3, 0], [3, 1]])
+ self.assertAllEqual(sp_tensor1.values.eval(), [2, 13, 23, 32, 33])
+ self.assertAllEqual(sp_tensor1.dense_shape.eval(), [5, 2])
+ self.assertAllEqual(sp_tensor2.indices.eval(),
+ [[0, 0], [0, 1], [1, 0], [2, 1], [3, 1], [4, 0]])
+ self.assertAllEqual(sp_tensor2.values.eval(), [4, 5, 14, 25, 35, 44])
+ self.assertAllEqual(sp_tensor2.dense_shape.eval(), [5, 2])
+ self.assertAllEqual(sp_tensor3.indices.eval(), [[1, 0], [4, 0]])
+ self.assertAllEqual(sp_tensor3.values.eval(), [16, 46])
+ self.assertAllEqual(sp_tensor3.dense_shape.eval(), [5, 1])
+
+ def testSliceMatrixUnevenRows(self):
+ with self.test_session(use_gpu=False):
+ sp_input=self._SparseTensor_5x7()
+ sp_tensor0 = sparse_ops.sparse_slice(sp_input, [0, 0], [3, 7])
+ sp_tensor1 = sparse_ops.sparse_slice(sp_input, [3, 0], [3, 7])
+ self.assertAllEqual(sp_tensor0.indices.eval(),
+ [[0, 0], [0, 2], [0, 4], [0, 5], [1, 1], [1, 3],
+ [1, 4], [1, 6], [2, 0], [2, 3], [2, 5]])
+ self.assertAllEqual(sp_tensor0.values.eval(),
+ [0, 2, 4, 5, 11, 13, 14, 16, 20, 23, 25])
+ self.assertAllEqual(sp_tensor0.dense_shape.eval(), [3, 7])
+ self.assertAllEqual(sp_tensor1.indices.eval(),
+ [[0, 0], [0, 2], [0, 3], [0, 5], [1, 1], [1, 4],
+ [1, 6]])
+ self.assertAllEqual(sp_tensor1.values.eval(),
+ [30, 32, 33, 35, 41, 44, 46])
+ self.assertAllEqual(sp_tensor1.dense_shape.eval(), [2, 7])
+
+ sp_tensor0 = sparse_ops.sparse_slice(sp_input, [0, 0], [2, 7])
+ sp_tensor1 = sparse_ops.sparse_slice(sp_input, [2, 0], [2, 7])
+ sp_tensor2 = sparse_ops.sparse_slice(sp_input, [4, 0], [2, 7])
+ self.assertAllEqual(sp_tensor0.indices.eval(),
+ [[0, 0], [0, 2], [0, 4], [0, 5], [1, 1], [1, 3],
+ [1, 4], [1, 6]])
+ self.assertAllEqual(sp_tensor0.values.eval(),
+ [0, 2, 4, 5, 11, 13, 14, 16])
+ self.assertAllEqual(sp_tensor0.dense_shape.eval(), [2, 7])
+
+ self.assertAllEqual(sp_tensor1.values.eval(),
+ [20, 23, 25, 30, 32, 33, 35])
+ self.assertAllEqual(sp_tensor1.dense_shape.eval(), [2, 7])
+ self.assertAllEqual(sp_tensor2.indices.eval(), [[0, 1], [0, 4],
+ [0, 6]])
+ self.assertAllEqual(sp_tensor2.values.eval(), [41, 44, 46])
+ self.assertAllEqual(sp_tensor2.dense_shape.eval(), [1, 7])
+ return
+
+ def testSliceAllRows(self):
+ with self.test_session(use_gpu=False):
+ sp_input=self._SparseTensor_4x6()
+ sp_tensor0 = sparse_ops.sparse_slice(sp_input, [0, 0], [1, 6])
+ sp_tensor1 = sparse_ops.sparse_slice(sp_input, [1, 0], [1, 6])
+ sp_tensor2 = sparse_ops.sparse_slice(sp_input, [2, 0], [1, 7])
+ sp_tensor3 = sparse_ops.sparse_slice(sp_input, [3, 0], [2, 7])
+ self.assertAllEqual(sp_tensor0.indices.eval(), [[0, 0], [0, 2], [0, 4],
+ [0, 5]])
+ self.assertAllEqual(sp_tensor0.values.eval(), [0, 2, 4, 5])
+ self.assertAllEqual(sp_tensor0.dense_shape.eval(), [1, 6])
+ self.assertAllEqual(sp_tensor1.indices.eval(), [[0, 1], [0, 3], [0,
+ 4]])
+ self.assertAllEqual(sp_tensor1.values.eval(), [11, 13, 14])
+ self.assertAllEqual(sp_tensor1.dense_shape.eval(), [1, 6])
+ self.assertAllEqual(sp_tensor2.indices.eval(), [[0, 0], [0, 3], [0,
+ 5]])
+ self.assertAllEqual(sp_tensor2.values.eval(), [20, 23, 25])
+ self.assertAllEqual(sp_tensor2.dense_shape.eval(), [1, 6])
+ self.assertAllEqual(sp_tensor3.indices.eval(), [[0, 0], [0, 2], [0, 3],
+ [0, 5]])
+ self.assertAllEqual(sp_tensor3.values.eval(), [30, 32, 33, 35])
+ self.assertAllEqual(sp_tensor3.dense_shape.eval(), [1, 6])
+
+ def testSliceColumns(self):
+ with self.test_session(use_gpu=False):
+ sp_input=self._SparseTensor_4x6()
+ sparse_tensor0 = sparse_ops.sparse_slice(sp_input, [0, 0], [4, 2])
+ sparse_tensor1 = sparse_ops.sparse_slice(sp_input, [0, 2], [5, 2])
+ sparse_tensor2 = sparse_ops.sparse_slice(sp_input, [0, 4], [5, 3])
+
+ self.assertAllEqual(sparse_tensor0.indices.eval(), [[0, 0], [1, 1],
+ [2, 0], [3, 0]])
+ self.assertAllEqual(sparse_tensor0.values.eval(), [0, 11, 20, 30])
+ self.assertAllEqual(sparse_tensor0.dense_shape.eval(), [4, 2])
+ self.assertAllEqual(sparse_tensor1.indices.eval(),
+ [[0, 0], [1, 1], [2, 1], [3, 0], [3, 1]])
+ self.assertAllEqual(sparse_tensor1.values.eval(), [2, 13, 23, 32, 33])
+ self.assertAllEqual(sparse_tensor1.dense_shape.eval(), [4, 2])
+ self.assertAllEqual(sparse_tensor2.indices.eval(),
+ [[0, 0], [0, 1], [1, 0], [2, 1], [3, 1]])
+ self.assertAllEqual(sparse_tensor2.values.eval(), [4, 5, 14, 25, 35])
+ self.assertAllEqual(sparse_tensor2.dense_shape.eval(), [4, 2])
+
+ def testSliceAllColumns(self):
+ with self.test_session(use_gpu=False):
+ sp_input=self._SparseTensor_4x6()
+ sparse_tensor0 = sparse_ops.sparse_slice(sp_input, [0, 0], [4, 1])
+ sparse_tensor1 = sparse_ops.sparse_slice(sp_input, [0, 1], [4, 1])
+ sparse_tensor2 = sparse_ops.sparse_slice(sp_input, [0, 2], [4, 1])
+ sparse_tensor3 = sparse_ops.sparse_slice(sp_input, [0, 3], [4, 1])
+ sparse_tensor4 = sparse_ops.sparse_slice(sp_input, [0, 4], [5, 1])
+ sparse_tensor5 = sparse_ops.sparse_slice(sp_input, [0, 5], [6, 3])
+ self.assertAllEqual(sparse_tensor0.indices.eval(), [[0, 0], [2, 0],
+ [3, 0]])
+ self.assertAllEqual(sparse_tensor0.values.eval(), [0, 20, 30])
+ self.assertAllEqual(sparse_tensor0.dense_shape.eval(), [4, 1])
+ self.assertAllEqual(sparse_tensor1.indices.eval(), [[1, 0]])
+ self.assertAllEqual(sparse_tensor1.values.eval(), [11])
+ self.assertAllEqual(sparse_tensor1.dense_shape.eval(), [4, 1])
+ self.assertAllEqual(sparse_tensor2.indices.eval(), [[0, 0], [3, 0]])
+ self.assertAllEqual(sparse_tensor2.values.eval(), [2, 32])
+ self.assertAllEqual(sparse_tensor2.dense_shape.eval(), [4, 1])
+ self.assertAllEqual(sparse_tensor3.indices.eval(), [[1, 0], [2, 0],
+ [3, 0]])
+ self.assertAllEqual(sparse_tensor3.dense_shape.eval(), [4, 1])
+ self.assertAllEqual(sparse_tensor3.values.eval(), [13, 23, 33])
+ self.assertAllEqual(sparse_tensor4.indices.eval(), [[0, 0], [1, 0]])
+ self.assertAllEqual(sparse_tensor4.values.eval(), [4, 14])
+ self.assertAllEqual(sparse_tensor4.dense_shape.eval(), [4, 1])
+ self.assertAllEqual(sparse_tensor5.indices.eval(), [[0, 0], [2, 0],
+ [3, 0]])
+ self.assertAllEqual(sparse_tensor5.values.eval(), [5, 25, 35])
+ self.assertAllEqual(sparse_tensor5.dense_shape.eval(), [4, 1])
+
+if __name__ == '__main__':
+ test.main()
diff --git a/tensorflow/python/kernel_tests/stage_op_test.py b/tensorflow/python/kernel_tests/stage_op_test.py
index 1a6a869e3d..4073fc6b79 100644
--- a/tensorflow/python/kernel_tests/stage_op_test.py
+++ b/tensorflow/python/kernel_tests/stage_op_test.py
@@ -102,8 +102,8 @@ class StageTest(test.TestCase):
with ops.device(gpu_dev):
stager = data_flow_ops.StagingArea([dtypes.float32])
y = stager.put([v])
- self.assertEqual(y.device, '/device:GPU:0' if gpu_dev
- else gpu_dev)
+ expected_name = gpu_dev if 'gpu' not in gpu_dev else '/device:GPU:0'
+ self.assertEqual(y.device, expected_name)
with ops.device('/cpu:0'):
x = stager.get()
self.assertEqual(x.device, '/device:CPU:0')
diff --git a/tensorflow/python/layers/base.py b/tensorflow/python/layers/base.py
index 36491fc9c7..ebf108d8ca 100644
--- a/tensorflow/python/layers/base.py
+++ b/tensorflow/python/layers/base.py
@@ -27,6 +27,7 @@ import collections
import copy
import functools
import re
+import weakref
from six.moves import xrange # pylint: disable=redefined-builtin
import numpy as np
@@ -681,8 +682,7 @@ def _object_list_uid(object_list):
# A global dictionary mapping graph objects to an index of counters used
# for various layer names in each graph.
# Allows to give unique autogenerated names to layers, in a graph-specific way.
-PER_GRAPH_LAYER_NAME_UIDS = collections.defaultdict(
- lambda: collections.defaultdict(int))
+PER_GRAPH_LAYER_NAME_UIDS = weakref.WeakKeyDictionary()
def _unique_layer_name(name):
@@ -704,6 +704,8 @@ def _unique_layer_name(name):
```
"""
graph = ops.get_default_graph()
+ if graph not in PER_GRAPH_LAYER_NAME_UIDS:
+ PER_GRAPH_LAYER_NAME_UIDS[graph] = collections.defaultdict(int)
layer_name_uids = PER_GRAPH_LAYER_NAME_UIDS[graph]
layer_name_uids[name] += 1
return name + '_' + str(layer_name_uids[name])
diff --git a/tensorflow/python/layers/convolutional.py b/tensorflow/python/layers/convolutional.py
index 5967180f5b..3594ced259 100644
--- a/tensorflow/python/layers/convolutional.py
+++ b/tensorflow/python/layers/convolutional.py
@@ -741,7 +741,7 @@ class SeparableConv2D(Conv2D):
filters: Integer, the dimensionality of the output space (i.e. the number
of filters in the convolution).
kernel_size: A tuple or list of 2 integers specifying the spatial
- dimensions of of the filters. Can be a single integer to specify the same
+ dimensions of the filters. Can be a single integer to specify the same
value for all spatial dimensions.
strides: A tuple or list of 2 positive integers specifying the strides
of the convolution. Can be a single integer to specify the same value for
@@ -950,7 +950,7 @@ def separable_conv2d(inputs,
filters: Integer, the dimensionality of the output space (i.e. the number
of filters in the convolution).
kernel_size: A tuple or list of 2 integers specifying the spatial
- dimensions of of the filters. Can be a single integer to specify the same
+ dimensions of the filters. Can be a single integer to specify the same
value for all spatial dimensions.
strides: A tuple or list of 2 positive integers specifying the strides
of the convolution. Can be a single integer to specify the same value for
@@ -1033,7 +1033,7 @@ class Conv2DTranspose(Conv2D):
filters: Integer, the dimensionality of the output space (i.e. the number
of filters in the convolution).
kernel_size: A tuple or list of 2 positive integers specifying the spatial
- dimensions of of the filters. Can be a single integer to specify the same
+ dimensions of the filters. Can be a single integer to specify the same
value for all spatial dimensions.
strides: A tuple or list of 2 positive integers specifying the strides
of the convolution. Can be a single integer to specify the same value for
@@ -1233,7 +1233,7 @@ def conv2d_transpose(inputs,
filters: Integer, the dimensionality of the output space (i.e. the number
of filters in the convolution).
kernel_size: A tuple or list of 2 positive integers specifying the spatial
- dimensions of of the filters. Can be a single integer to specify the same
+ dimensions of the filters. Can be a single integer to specify the same
value for all spatial dimensions.
strides: A tuple or list of 2 positive integers specifying the strides
of the convolution. Can be a single integer to specify the same value for
@@ -1516,7 +1516,7 @@ def conv3d_transpose(inputs,
filters: Integer, the dimensionality of the output space (i.e. the number
of filters in the convolution).
kernel_size: A tuple or list of 3 positive integers specifying the spatial
- dimensions of of the filters. Can be a single integer to specify the same
+ dimensions of the filters. Can be a single integer to specify the same
value for all spatial dimensions.
strides: A tuple or list of 3 positive integers specifying the strides
of the convolution. Can be a single integer to specify the same value for
@@ -1525,8 +1525,9 @@ def conv3d_transpose(inputs,
data_format: A string, one of `channels_last` (default) or `channels_first`.
The ordering of the dimensions in the inputs.
`channels_last` corresponds to inputs with shape
- `(batch, height, width, channels)` while `channels_first` corresponds to
- inputs with shape `(batch, channels, height, width)`.
+ `(batch, depth, height, width, channels)` while `channels_first`
+ corresponds to inputs with shape
+ `(batch, channels, depth, height, width)`.
activation: Activation function. Set it to None to maintain a
linear activation.
use_bias: Boolean, whether the layer uses a bias.
diff --git a/tensorflow/python/ops/data_flow_ops.py b/tensorflow/python/ops/data_flow_ops.py
index 1dc5eb2f90..3ff93b61c5 100644
--- a/tensorflow/python/ops/data_flow_ops.py
+++ b/tensorflow/python/ops/data_flow_ops.py
@@ -537,6 +537,25 @@ class QueueBase(object):
self._queue_ref, cancel_pending_enqueues=cancel_pending_enqueues,
name=name)
+ def is_closed(self, name=None):
+ """ Returns true if queue is closed.
+
+ This operation returns true if the queue is closed and false if the queue
+ is open.
+
+ Args:
+ name: A name for the operation (optional).
+
+ Returns:
+ True if the queue is closed and false if the queue is open.
+ """
+ if name is None:
+ name = "%s_Is_Closed" % self._name
+ if self._queue_ref.dtype == _dtypes.resource:
+ return gen_data_flow_ops.queue_is_closed_v2(self._queue_ref,name=name)
+ else:
+ return gen_data_flow_ops.queue_is_closed_(self._queue_ref,name=name)
+
def size(self, name=None):
"""Compute the number of elements in this queue.
diff --git a/tensorflow/python/ops/distributions/dirichlet_multinomial.py b/tensorflow/python/ops/distributions/dirichlet_multinomial.py
index f1b005f418..d792e9fe52 100644
--- a/tensorflow/python/ops/distributions/dirichlet_multinomial.py
+++ b/tensorflow/python/ops/distributions/dirichlet_multinomial.py
@@ -95,7 +95,7 @@ class DirichletMultinomial(distribution.Distribution):
The last `concentration` dimension parametrizes a single Dirichlet-Multinomial
distribution. When calling distribution functions (e.g., `dist.prob(counts)`),
`concentration`, `total_count` and `counts` are broadcast to the same shape.
- The last dimension of of `counts` corresponds single Dirichlet-Multinomial
+ The last dimension of `counts` corresponds single Dirichlet-Multinomial
distributions.
Distribution parameters are automatically broadcast in all functions; see
diff --git a/tensorflow/python/ops/distributions/distribution.py b/tensorflow/python/ops/distributions/distribution.py
index a0be433a61..1684e85cc7 100644
--- a/tensorflow/python/ops/distributions/distribution.py
+++ b/tensorflow/python/ops/distributions/distribution.py
@@ -176,7 +176,7 @@ class _DistributionMeta(abc.ABCMeta):
class ReparameterizationType(object):
"""Instances of this class represent how sampling is reparameterized.
- Two static instances exist in the distritributions library, signifying
+ Two static instances exist in the distributions library, signifying
one of two possible properties for samples from a distribution:
`FULLY_REPARAMETERIZED`: Samples from the distribution are fully
diff --git a/tensorflow/python/ops/distributions/multinomial.py b/tensorflow/python/ops/distributions/multinomial.py
index aa691c565b..9b15d4c76e 100644
--- a/tensorflow/python/ops/distributions/multinomial.py
+++ b/tensorflow/python/ops/distributions/multinomial.py
@@ -213,7 +213,7 @@ class Multinomial(distribution.Distribution):
@property
def probs(self):
- """Probability of of drawing a `1` in that coordinate."""
+ """Probability of drawing a `1` in that coordinate."""
return self._probs
def _batch_shape_tensor(self):
diff --git a/tensorflow/python/ops/distributions/util.py b/tensorflow/python/ops/distributions/util.py
index 2caa341cd2..c808f1fa7a 100644
--- a/tensorflow/python/ops/distributions/util.py
+++ b/tensorflow/python/ops/distributions/util.py
@@ -37,7 +37,7 @@ from tensorflow.python.ops import nn
def assert_close(
x, y, data=None, summarize=None, message=None, name="assert_close"):
- """Assert that that x and y are within machine epsilon of each other.
+ """Assert that x and y are within machine epsilon of each other.
Args:
x: Floating-point `Tensor`
diff --git a/tensorflow/python/ops/gradients_impl.py b/tensorflow/python/ops/gradients_impl.py
index 52ce451238..e073dbc640 100644
--- a/tensorflow/python/ops/gradients_impl.py
+++ b/tensorflow/python/ops/gradients_impl.py
@@ -917,7 +917,7 @@ def hessians(ys, xs, name="hessians", colocate_gradients_with_ops=False,
aggregation_method: See `gradients()` documentation for details.
Returns:
- A list of Hessian matrices of `sum(y)` for each `x` in `xs`.
+ A list of Hessian matrices of `sum(ys)` for each `x` in `xs`.
Raises:
LookupError: if one of the operations between `xs` and `ys` does not
diff --git a/tensorflow/python/ops/hidden_ops.txt b/tensorflow/python/ops/hidden_ops.txt
index bec6b82a4c..28817e99e8 100644
--- a/tensorflow/python/ops/hidden_ops.txt
+++ b/tensorflow/python/ops/hidden_ops.txt
@@ -162,6 +162,8 @@ ResizeBilinearGrad
ResizeNearestNeighborGrad
AdjustContrastv2
ScaleImageGrad
+SampleDistortedBoundingBox
+SampleDistortedBoundingBoxV2
# io_ops
FixedLengthRecordReader
diff --git a/tensorflow/python/ops/image_ops_impl.py b/tensorflow/python/ops/image_ops_impl.py
index 65a1399c5b..2be92fac63 100644
--- a/tensorflow/python/ops/image_ops_impl.py
+++ b/tensorflow/python/ops/image_ops_impl.py
@@ -47,6 +47,7 @@ ops.NotDifferentiable('RGBToHSV')
ops.NotDifferentiable('HSVToRGB')
ops.NotDifferentiable('DrawBoundingBoxes')
ops.NotDifferentiable('SampleDistortedBoundingBox')
+ops.NotDifferentiable('SampleDistortedBoundingBoxV2')
# TODO(bsteiner): Implement the gradient function for extract_glimpse
# TODO(b/31222613): This op may be differentiable, and there may be
# latent bugs here.
@@ -1472,3 +1473,104 @@ def total_variation(images, name=None):
math_ops.reduce_sum(math_ops.abs(pixel_dif2), axis=sum_axis))
return tot_var
+
+
+def sample_distorted_bounding_box(image_size, bounding_boxes, seed=None,
+ seed2=None, min_object_covered=None,
+ aspect_ratio_range=None, area_range=None,
+ max_attempts=None,
+ use_image_if_no_bounding_boxes=None,
+ name=None):
+ """Generate a single randomly distorted bounding box for an image.
+
+ Bounding box annotations are often supplied in addition to ground-truth labels
+ in image recognition or object localization tasks. A common technique for
+ training such a system is to randomly distort an image while preserving
+ its content, i.e. *data augmentation*. This Op outputs a randomly distorted
+ localization of an object, i.e. bounding box, given an `image_size`,
+ `bounding_boxes` and a series of constraints.
+
+ The output of this Op is a single bounding box that may be used to crop the
+ original image. The output is returned as 3 tensors: `begin`, `size` and
+ `bboxes`. The first 2 tensors can be fed directly into `tf.slice` to crop the
+ image. The latter may be supplied to `tf.image.draw_bounding_boxes` to visualize
+ what the bounding box looks like.
+
+ Bounding boxes are supplied and returned as `[y_min, x_min, y_max, x_max]`. The
+ bounding box coordinates are floats in `[0.0, 1.0]` relative to the width and
+ height of the underlying image.
+
+ For example,
+
+ ```python
+ # Generate a single distorted bounding box.
+ begin, size, bbox_for_draw = tf.image.sample_distorted_bounding_box(
+ tf.shape(image),
+ bounding_boxes=bounding_boxes)
+
+ # Draw the bounding box in an image summary.
+ image_with_box = tf.image.draw_bounding_boxes(tf.expand_dims(image, 0),
+ bbox_for_draw)
+ tf.image_summary('images_with_box', image_with_box)
+
+ # Employ the bounding box to distort the image.
+ distorted_image = tf.slice(image, begin, size)
+ ```
+
+ Note that if no bounding box information is available, setting
+ `use_image_if_no_bounding_boxes = true` will assume there is a single implicit
+ bounding box covering the whole image. If `use_image_if_no_bounding_boxes` is
+ false and no bounding boxes are supplied, an error is raised.
+
+ Args:
+ image_size: A `Tensor`. Must be one of the following types: `uint8`, `int8`, `int16`, `int32`, `int64`.
+ 1-D, containing `[height, width, channels]`.
+ bounding_boxes: A `Tensor` of type `float32`.
+ 3-D with shape `[batch, N, 4]` describing the N bounding boxes
+ associated with the image.
+ seed: An optional `int`. Defaults to `0`.
+ If either `seed` or `seed2` are set to non-zero, the random number
+ generator is seeded by the given `seed`. Otherwise, it is seeded by a random
+ seed.
+ seed2: An optional `int`. Defaults to `0`.
+ A second seed to avoid seed collision.
+ min_object_covered: An optional `float`. Defaults to `0.1`.
+ The cropped area of the image must contain at least this
+ fraction of any bounding box supplied. The value of this parameter should be
+ non-negative. In the case of 0, the cropped area does not need to overlap
+ any of the bounding boxes supplied.
+ aspect_ratio_range: An optional list of `floats`. Defaults to `[0.75, 1.33]`.
+ The cropped area of the image must have an aspect ratio =
+ width / height within this range.
+ area_range: An optional list of `floats`. Defaults to `[0.05, 1]`.
+ The cropped area of the image must contain a fraction of the
+ supplied image within in this range.
+ max_attempts: An optional `int`. Defaults to `100`.
+ Number of attempts at generating a cropped region of the image
+ of the specified constraints. After `max_attempts` failures, return the entire
+ image.
+ use_image_if_no_bounding_boxes: An optional `bool`. Defaults to `False`.
+ Controls behavior if no bounding boxes supplied.
+ If true, assume an implicit bounding box covering the whole input. If false,
+ raise an error.
+ name: A name for the operation (optional).
+
+ Returns:
+ A tuple of `Tensor` objects (begin, size, bboxes).
+
+ begin: A `Tensor`. Has the same type as `image_size`. 1-D, containing `[offset_height, offset_width, 0]`. Provide as input to
+ `tf.slice`.
+ size: A `Tensor`. Has the same type as `image_size`. 1-D, containing `[target_height, target_width, -1]`. Provide as input to
+ `tf.slice`.
+ bboxes: A `Tensor` of type `float32`. 3-D with shape `[1, 1, 4]` containing the distorted bounding box.
+ Provide as input to `tf.image.draw_bounding_boxes`.
+ """
+ with ops.name_scope(name, 'sample_distorted_bounding_box'):
+ # TODO (yongtang): Need to switch to v2 after 3 weeks.
+ return gen_image_ops._sample_distorted_bounding_box(image_size,
+ bounding_boxes, seed=seed,
+ seed2=seed2, min_object_covered=min_object_covered,
+ aspect_ratio_range=aspect_ratio_range, area_range=area_range,
+ max_attempts=max_attempts,
+ use_image_if_no_bounding_boxes=use_image_if_no_bounding_boxes,
+ name=name)
diff --git a/tensorflow/python/ops/image_ops_test.py b/tensorflow/python/ops/image_ops_test.py
index 5588d18ef1..5564194ea1 100644
--- a/tensorflow/python/ops/image_ops_test.py
+++ b/tensorflow/python/ops/image_ops_test.py
@@ -1501,16 +1501,41 @@ class SelectDistortedCropBoxTest(test_util.TensorFlowTestCase):
image_size_np, shape=image_size_np.shape)
bounding_box_tf = constant_op.constant(
bounding_box_np, dtype=dtypes.float32, shape=bounding_box_np.shape)
- begin, size, _ = image_ops.sample_distorted_bounding_box(
+
+ # sample_distorted_bounding_box and sample_distorted_bounding_box_v2
+ for op in [image_ops.sample_distorted_bounding_box,
+ gen_image_ops._sample_distorted_bounding_box_v2]:
+ begin, size, _ = op(
+ image_size=image_size_tf,
+ bounding_boxes=bounding_box_tf,
+ min_object_covered=min_object_covered,
+ aspect_ratio_range=aspect_ratio_range,
+ area_range=area_range)
+ y = array_ops.strided_slice(image_tf, begin, begin + size)
+
+ for _ in xrange(num_iter):
+ y_tf = y.eval()
+ crop_height = y_tf.shape[0]
+ crop_width = y_tf.shape[1]
+ aspect_ratio = float(crop_width) / float(crop_height)
+ area = float(crop_width * crop_height)
+
+ aspect_ratios.append(aspect_ratio)
+ area_ratios.append(area / original_area)
+ fraction_object_covered.append(float(np.sum(y_tf)) / bounding_box_area)
+
+ # sample_distorted_bounding_box_v2
+ min_object_covered_placeholder = array_ops.placeholder(dtypes.float32)
+ begin, size, _ = gen_image_ops._sample_distorted_bounding_box_v2(
image_size=image_size_tf,
bounding_boxes=bounding_box_tf,
- min_object_covered=min_object_covered,
+ min_object_covered=min_object_covered_placeholder,
aspect_ratio_range=aspect_ratio_range,
area_range=area_range)
y = array_ops.strided_slice(image_tf, begin, begin + size)
for _ in xrange(num_iter):
- y_tf = y.eval()
+ y_tf = y.eval(feed_dict={min_object_covered_placeholder: min_object_covered})
crop_height = y_tf.shape[0]
crop_width = y_tf.shape[1]
aspect_ratio = float(crop_width) / float(crop_height)
@@ -1605,10 +1630,24 @@ class SelectDistortedCropBoxTest(test_util.TensorFlowTestCase):
[0.0, 0.0, 1.0, 1.0],
shape=[4],
dtype=dtypes.float32,)
- begin, end, bbox_for_drawing = image_ops.sample_distorted_bounding_box(
+ for op in [image_ops.sample_distorted_bounding_box,
+ gen_image_ops._sample_distorted_bounding_box_v2]:
+ begin, end, bbox_for_drawing = op(
+ image_size=image_size,
+ bounding_boxes=bounding_box,
+ min_object_covered=0.1,
+ aspect_ratio_range=(0.75, 1.33),
+ area_range=(0.05, 1.0))
+
+ # Test that the shapes are correct.
+ self.assertAllEqual([3], begin.get_shape().as_list())
+ self.assertAllEqual([3], end.get_shape().as_list())
+ self.assertAllEqual([1, 1, 4], bbox_for_drawing.get_shape().as_list())
+
+ begin, end, bbox_for_drawing = op(
image_size=image_size,
bounding_boxes=bounding_box,
- min_object_covered=0.1,
+ min_object_covered=array_ops.placeholder(dtypes.float32),
aspect_ratio_range=(0.75, 1.33),
area_range=(0.05, 1.0))
diff --git a/tensorflow/python/ops/io_ops.py b/tensorflow/python/ops/io_ops.py
index 8f5d0e5cd4..975494e45f 100644
--- a/tensorflow/python/ops/io_ops.py
+++ b/tensorflow/python/ops/io_ops.py
@@ -397,7 +397,8 @@ class FixedLengthRecordReader(ReaderBase):
header_bytes=None,
footer_bytes=None,
hop_bytes=None,
- name=None):
+ name=None,
+ encoding=None):
"""Create a FixedLengthRecordReader.
Args:
@@ -406,12 +407,14 @@ class FixedLengthRecordReader(ReaderBase):
footer_bytes: An optional int. Defaults to 0.
hop_bytes: An optional int. Defaults to 0.
name: A name for the operation (optional).
+ encoding: The type of encoding for the file. Defaults to none.
"""
rr = gen_io_ops._fixed_length_record_reader_v2(
record_bytes=record_bytes,
header_bytes=header_bytes,
footer_bytes=footer_bytes,
hop_bytes=hop_bytes,
+ encoding=encoding,
name=name)
super(FixedLengthRecordReader, self).__init__(rr)
diff --git a/tensorflow/python/ops/math_grad.py b/tensorflow/python/ops/math_grad.py
index a0f505e47b..b8266a527d 100644
--- a/tensorflow/python/ops/math_grad.py
+++ b/tensorflow/python/ops/math_grad.py
@@ -122,8 +122,10 @@ def _ProdGrad(op, grad):
# so we need to cast here. We put all the shape-related ops on CPU to avoid
# copying back and forth, and since listdiff is CPU only.
with ops.device("/cpu:0"):
+ rank = array_ops.rank(op.inputs[0])
+ reduction_indices = (reduction_indices + rank) % rank
reduced = math_ops.cast(reduction_indices, dtypes.int32)
- idx = math_ops.range(0, array_ops.rank(op.inputs[0]))
+ idx = math_ops.range(0, rank)
other, _ = array_ops.setdiff1d(idx, reduced)
perm = array_ops.concat([reduced, other], 0)
reduced_num = math_ops.reduce_prod(array_ops.gather(input_shape, reduced))
@@ -397,6 +399,36 @@ def _TanhGrad(op, grad):
return gen_math_ops._tanh_grad(y, grad)
+@ops.RegisterGradient("Asinh")
+def _AsinhGrad(op, grad):
+ """Returns grad * 1/cosh(y)."""
+ y = op.outputs[0]
+ with ops.control_dependencies([grad.op]):
+ y = math_ops.conj(y)
+ return grad / math_ops.cosh(y)
+
+
+@ops.RegisterGradient("Acosh")
+def _AcoshGrad(op, grad):
+ """Returns grad * 1/sinh(y)."""
+ y = op.outputs[0]
+ with ops.control_dependencies([grad.op]):
+ y = math_ops.conj(y)
+ return grad / math_ops.sinh(y)
+
+
+@ops.RegisterGradient("Atanh")
+def _AtanhGrad(op, grad):
+ """Returns grad * 1/ (1 - x^2)."""
+ x = op.inputs[0]
+ with ops.control_dependencies([grad.op]):
+ x = math_ops.conj(x)
+ x2 = math_ops.square(x)
+ one = constant_op.constant(1, dtype=grad.dtype)
+ inv = math_ops.reciprocal(math_ops.subtract(one, x2))
+ return grad * inv
+
+
@ops.RegisterGradient("TanhGrad")
def _TanhGradGrad(op, grad):
with ops.control_dependencies([grad.op]):
diff --git a/tensorflow/python/ops/math_grad_test.py b/tensorflow/python/ops/math_grad_test.py
index 1fa15957b0..da3e0d7294 100644
--- a/tensorflow/python/ops/math_grad_test.py
+++ b/tensorflow/python/ops/math_grad_test.py
@@ -113,6 +113,29 @@ class MinOrMaxGradientTest(test.TestCase):
self.assertLess(error, 1e-4)
+class ProdGradientTest(test.TestCase):
+
+ def testProdGradient(self):
+ inputs = constant_op.constant([[1., 2.], [3., 4.]],
+ dtype=dtypes.float32)
+ outputs = math_ops.reduce_prod(inputs)
+ with self.test_session():
+ error = gradient_checker.compute_gradient_error(
+ inputs, inputs.get_shape().as_list(),
+ outputs, outputs.get_shape().as_list())
+ self.assertLess(error, 1e-4)
+
+ def testProdGradientForNegativeAxis(self):
+ inputs = constant_op.constant([[1., 2.], [3., 4.]],
+ dtype=dtypes.float32)
+ outputs = math_ops.reduce_prod(inputs, -1)
+ with self.test_session():
+ error = gradient_checker.compute_gradient_error(
+ inputs, inputs.get_shape().as_list(),
+ outputs, outputs.get_shape().as_list())
+ self.assertLess(error, 1e-4)
+
+
class SegmentMinOrMaxGradientTest(test.TestCase):
def testSegmentMinGradient(self):
diff --git a/tensorflow/python/ops/math_ops.py b/tensorflow/python/ops/math_ops.py
index bf46bbdcc2..7edd1c47d2 100644
--- a/tensorflow/python/ops/math_ops.py
+++ b/tensorflow/python/ops/math_ops.py
@@ -47,6 +47,9 @@ See the @{$python/math_ops} guide.
@@log1p
@@sinh
@@cosh
+@@asinh
+@@acosh
+@@atanh
@@ceil
@@floor
@@maximum
@@ -1691,8 +1694,8 @@ def matmul(a,
name=None):
"""Multiplies matrix `a` by matrix `b`, producing `a` * `b`.
- The inputs must, following any transpositions, be tensors of rank >= 2
- where the inner 2 dimensions specify valid matrix multiplication arguments,
+ The inputs must, following any transpositions, be tensors of rank >= 2
+ where the inner 2 dimensions specify valid matrix multiplication arguments,
and any further outer dimensions match.
Both matrices must be of the same type. The supported types are:
diff --git a/tensorflow/python/ops/sets_impl.py b/tensorflow/python/ops/sets_impl.py
index f3b52636d4..e623c4f2ee 100644
--- a/tensorflow/python/ops/sets_impl.py
+++ b/tensorflow/python/ops/sets_impl.py
@@ -99,7 +99,7 @@ def _set_operation(a, b, set_operation, validate_indices=True):
b: `Tensor` or `SparseTensor` of the same type as `a`. Must be
`SparseTensor` if `a` is `SparseTensor`. If sparse, indices must be
sorted in row-major order.
- set_operation: String indicating set operaiton. See
+ set_operation: String indicating set operation. See
SetOperationOp::SetOperationFromContext for valid values.
validate_indices: Whether to validate the order and range of sparse indices
in `a` and `b`.
diff --git a/tensorflow/python/ops/sparse_ops.py b/tensorflow/python/ops/sparse_ops.py
index 93a9656950..d05fabce86 100644
--- a/tensorflow/python/ops/sparse_ops.py
+++ b/tensorflow/python/ops/sparse_ops.py
@@ -25,6 +25,7 @@
@@sparse_concat
@@sparse_reorder
@@sparse_reshape
+@@sparse_slice
@@sparse_split
@@sparse_retain
@@sparse_reset_shape
@@ -657,6 +658,50 @@ def sparse_split(keyword_required=KeywordRequired(),
return sparse_tensors
+def sparse_slice(sp_input, start, size, name=None):
+ """Slice a `SparseTensor` based on the `start` and `size.
+
+ For example, if the input is
+
+ input_tensor = shape = [2, 7]
+ [ a d e ]
+ [b c ]
+
+ Graphically the output tensors are:
+
+ sparse_slice([0, 0], [2, 4]) = shape = [2, 4]
+ [ a ]
+ [b c ]
+
+ sparse_slice([0, 4], [2, 3]) = shape = [2, 3]
+ [ d e ]
+ [ ]
+
+ Args:
+ sp_input: The `SparseTensor` to split.
+ start: 1-D. tensor represents the start of the slice.
+ size: 1-D. tensor represents the size of the slice.
+ name: A name for the operation (optional).
+
+ Returns:
+ A `SparseTensor` objects resulting from splicing.
+
+ Raises:
+ TypeError: If `sp_input` is not a `SparseTensor`.
+ """
+ sp_input = _convert_to_sparse_tensor(sp_input)
+ start = ops.convert_to_tensor(start, dtypes.int64)
+ size = ops.convert_to_tensor(size, dtypes.int64)
+
+ with ops.name_scope(name, "SparseSlice", [sp_input]) as name:
+ output_indices, output_values, output_shape = gen_sparse_ops.sparse_slice(
+ sp_input.indices, sp_input.values, sp_input.dense_shape, start, size, name=name)
+
+ return sparse_tensor.SparseTensor(
+ output_indices,
+ output_values,
+ output_shape)
+
def sparse_to_dense(sparse_indices,
output_shape,
sparse_values,
diff --git a/tensorflow/python/ops/summary_op_util.py b/tensorflow/python/ops/summary_op_util.py
index a3f6616902..06ea63704d 100644
--- a/tensorflow/python/ops/summary_op_util.py
+++ b/tensorflow/python/ops/summary_op_util.py
@@ -78,7 +78,7 @@ def summary_scope(name, family=None, default_name=None, values=None):
If `family` is set, then the tag name will be '<family>/<scope_name>', where
`scope_name` is `<outer_scope>/<family>/<name>`. This ensures that `family`
is always the prefix of the tag (and unmodified), while ensuring the scope
- respects the outer scope from this this summary was created.
+ respects the outer scope from this summary was created.
Args:
name: A name for the generated summary node.
diff --git a/tensorflow/python/training/adam.py b/tensorflow/python/training/adam.py
index 459c735ea3..796402425a 100644
--- a/tensorflow/python/training/adam.py
+++ b/tensorflow/python/training/adam.py
@@ -31,7 +31,7 @@ from tensorflow.python.training import training_ops
class AdamOptimizer(optimizer.Optimizer):
"""Optimizer that implements the Adam algorithm.
- See [Kingma et. al., 2014](http://arxiv.org/abs/1412.6980)
+ See [Kingma et al., 2014](http://arxiv.org/abs/1412.6980)
([pdf](http://arxiv.org/pdf/1412.6980.pdf)).
"""
diff --git a/tensorflow/python/util/deprecation_test.py b/tensorflow/python/util/deprecation_test.py
index e2d9a594a3..16d246c4df 100644
--- a/tensorflow/python/util/deprecation_test.py
+++ b/tensorflow/python/util/deprecation_test.py
@@ -608,7 +608,7 @@ class DeprecatedArgsTest(test.TestCase):
self._assert_subset(set(["after " + date, instructions, "d2"]),
set(args2[1:]))
- # Assert calls with the deprecated arguments dont log warnings if
+ # Assert calls with the deprecated arguments don't log warnings if
# the value matches the 'ok_val'.
mock_warning.reset_mock()
self.assertEqual(3, _fn(1, None, 2, d2="my_ok_val"))
diff --git a/tensorflow/python/util/nest.py b/tensorflow/python/util/nest.py
index 8d77f8c845..b93842b3a7 100644
--- a/tensorflow/python/util/nest.py
+++ b/tensorflow/python/util/nest.py
@@ -180,7 +180,7 @@ def assert_same_structure(nest1, nest2, check_types=True):
nest1: an arbitrarily nested structure.
nest2: an arbitrarily nested structure.
check_types: if `True` (default) types of sequences are checked as
- well, incuding the keys of dictionaries. If set to `False`, for example
+ well, including the keys of dictionaries. If set to `False`, for example
a list and a tuple of objects will look the same if they have the same
size.
@@ -333,9 +333,9 @@ def map_structure(func, *structure, **check_types_dict):
and the return value will contain the results in the same structure.
Args:
- func: A callable that acceps as many arguments are there are structures.
+ func: A callable that accepts as many arguments as there are structures.
*structure: scalar, or tuple or list of constructed scalars and/or other
- tuples/lists, or scalars. Note: numpy arrays are considered scalars.
+ tuples/lists, or scalars. Note: numpy arrays are considered as scalars.
**check_types_dict: only valid keyword argument is `check_types`. If set to
`True` (default) the types of iterables within the structures have to be
same (e.g. `map_structure(func, [1], (1,))` raises a `TypeError`
diff --git a/tensorflow/python/util/tfprof.i b/tensorflow/python/util/tfprof.i
index 3949fec4e6..45105298e5 100644
--- a/tensorflow/python/util/tfprof.i
+++ b/tensorflow/python/util/tfprof.i
@@ -47,7 +47,6 @@ using tensorflow::int64;
%unignore tensorflow::tfprof::DeleteProfiler;
%unignore tensorflow::tfprof::AddStep;
%unignore tensorflow::tfprof::Profile;
-%unignore tensorflow::tfprof::Advise;
%include "tensorflow/core/profiler/internal/print_model_analysis.h"
diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl
index 5b1d9a517e..83a9313e50 100644
--- a/tensorflow/tensorflow.bzl
+++ b/tensorflow/tensorflow.bzl
@@ -138,16 +138,20 @@ WIN_COPTS = [
"/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
]
# LINT.IfChange
def tf_copts():
- return ([
+ return (if_not_windows([
"-DEIGEN_AVOID_STL_ARRAY",
"-Iexternal/gemmlowp",
"-Wno-sign-compare",
"-fno-exceptions",
- ] + if_cuda(["-DGOOGLE_CUDA=1"]) + if_mkl(["-DINTEL_MKL=1", "-fopenmp",]) + if_android_arm(
+ ]) + if_cuda(["-DGOOGLE_CUDA=1"]) + if_mkl(["-DINTEL_MKL=1", "-fopenmp",]) + if_android_arm(
["-mfpu=neon"]) + if_x86(["-msse3"]) + select({
clean_dep("//tensorflow:android"): [
"-std=c++11",
@@ -1021,9 +1025,9 @@ def tf_py_wrap_cc(name,
native.cc_binary(
name=cc_library_name,
srcs=[module_name + ".cc"],
- copts=(copts + [
+ copts=(copts + if_not_windows([
"-Wno-self-assign", "-Wno-sign-compare", "-Wno-write-strings"
- ] + tf_extension_copts()),
+ ]) + tf_extension_copts()),
linkopts=tf_extension_linkopts() + extra_linkopts,
linkstatic=1,
linkshared=1,
diff --git a/tensorflow/tools/api/golden/tensorflow.-f-i-f-o-queue.pbtxt b/tensorflow/tools/api/golden/tensorflow.-f-i-f-o-queue.pbtxt
index 72cc532447..a095616c00 100644
--- a/tensorflow/tools/api/golden/tensorflow.-f-i-f-o-queue.pbtxt
+++ b/tensorflow/tools/api/golden/tensorflow.-f-i-f-o-queue.pbtxt
@@ -56,6 +56,10 @@ tf_class {
argspec: "args=[\'index\', \'queues\'], varargs=None, keywords=None, defaults=None"
}
member_method {
+ name: "is_closed"
+ argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
+ }
+ member_method {
name: "size"
argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
}
diff --git a/tensorflow/tools/api/golden/tensorflow.-fixed-length-record-reader.pbtxt b/tensorflow/tools/api/golden/tensorflow.-fixed-length-record-reader.pbtxt
index 5c77b3dd5c..260c796fd6 100644
--- a/tensorflow/tools/api/golden/tensorflow.-fixed-length-record-reader.pbtxt
+++ b/tensorflow/tools/api/golden/tensorflow.-fixed-length-record-reader.pbtxt
@@ -13,7 +13,7 @@ tf_class {
}
member_method {
name: "__init__"
- argspec: "args=[\'self\', \'record_bytes\', \'header_bytes\', \'footer_bytes\', \'hop_bytes\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], "
+ argspec: "args=[\'self\', \'record_bytes\', \'header_bytes\', \'footer_bytes\', \'hop_bytes\', \'name\', \'encoding\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\', \'None\'], "
}
member_method {
name: "num_records_produced"
diff --git a/tensorflow/tools/api/golden/tensorflow.-padding-f-i-f-o-queue.pbtxt b/tensorflow/tools/api/golden/tensorflow.-padding-f-i-f-o-queue.pbtxt
index 1bfe723ce7..8fed133561 100644
--- a/tensorflow/tools/api/golden/tensorflow.-padding-f-i-f-o-queue.pbtxt
+++ b/tensorflow/tools/api/golden/tensorflow.-padding-f-i-f-o-queue.pbtxt
@@ -56,6 +56,10 @@ tf_class {
argspec: "args=[\'index\', \'queues\'], varargs=None, keywords=None, defaults=None"
}
member_method {
+ name: "is_closed"
+ argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
+ }
+ member_method {
name: "size"
argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
}
diff --git a/tensorflow/tools/api/golden/tensorflow.-priority-queue.pbtxt b/tensorflow/tools/api/golden/tensorflow.-priority-queue.pbtxt
index dbe25f3a5b..ebb017e81b 100644
--- a/tensorflow/tools/api/golden/tensorflow.-priority-queue.pbtxt
+++ b/tensorflow/tools/api/golden/tensorflow.-priority-queue.pbtxt
@@ -56,6 +56,10 @@ tf_class {
argspec: "args=[\'index\', \'queues\'], varargs=None, keywords=None, defaults=None"
}
member_method {
+ name: "is_closed"
+ argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
+ }
+ member_method {
name: "size"
argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
}
diff --git a/tensorflow/tools/api/golden/tensorflow.-queue-base.pbtxt b/tensorflow/tools/api/golden/tensorflow.-queue-base.pbtxt
index 9263d73a51..761f90989f 100644
--- a/tensorflow/tools/api/golden/tensorflow.-queue-base.pbtxt
+++ b/tensorflow/tools/api/golden/tensorflow.-queue-base.pbtxt
@@ -55,6 +55,10 @@ tf_class {
argspec: "args=[\'index\', \'queues\'], varargs=None, keywords=None, defaults=None"
}
member_method {
+ name: "is_closed"
+ argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
+ }
+ member_method {
name: "size"
argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
}
diff --git a/tensorflow/tools/api/golden/tensorflow.-random-shuffle-queue.pbtxt b/tensorflow/tools/api/golden/tensorflow.-random-shuffle-queue.pbtxt
index ec783ffe5a..f3ca841393 100644
--- a/tensorflow/tools/api/golden/tensorflow.-random-shuffle-queue.pbtxt
+++ b/tensorflow/tools/api/golden/tensorflow.-random-shuffle-queue.pbtxt
@@ -56,6 +56,10 @@ tf_class {
argspec: "args=[\'index\', \'queues\'], varargs=None, keywords=None, defaults=None"
}
member_method {
+ name: "is_closed"
+ argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
+ }
+ member_method {
name: "size"
argspec: "args=[\'self\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
}
diff --git a/tensorflow/tools/api/golden/tensorflow.pbtxt b/tensorflow/tools/api/golden/tensorflow.pbtxt
index cb0b383934..8cf40e3c4b 100644
--- a/tensorflow/tools/api/golden/tensorflow.pbtxt
+++ b/tensorflow/tools/api/golden/tensorflow.pbtxt
@@ -517,6 +517,10 @@ tf_module {
argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
}
member_method {
+ name: "acosh"
+ argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
+ }
+ member_method {
name: "add"
argspec: "args=[\'x\', \'y\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
}
@@ -565,6 +569,10 @@ tf_module {
argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
}
member_method {
+ name: "asinh"
+ argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
+ }
+ member_method {
name: "assert_equal"
argspec: "args=[\'x\', \'y\', \'data\', \'summarize\', \'message\', \'name\'], varargs=None, keywords=None, defaults=[\'None\', \'None\', \'None\', \'None\'], "
}
@@ -657,6 +665,10 @@ tf_module {
argspec: "args=[\'y\', \'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
}
member_method {
+ name: "atanh"
+ argspec: "args=[\'x\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
+ }
+ member_method {
name: "batch_to_space"
argspec: "args=[\'input\', \'crops\', \'block_size\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
}
@@ -1765,6 +1777,10 @@ tf_module {
argspec: "args=[\'data\', \'indices\', \'segment_ids\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
}
member_method {
+ name: "sparse_slice"
+ argspec: "args=[\'sp_input\', \'start\', \'size\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
+ }
+ member_method {
name: "sparse_softmax"
argspec: "args=[\'sp_input\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
}
diff --git a/tensorflow/tools/dist_test/python/mnist_replica.py b/tensorflow/tools/dist_test/python/mnist_replica.py
index f7dbfea7fb..e40ecb43f9 100644
--- a/tensorflow/tools/dist_test/python/mnist_replica.py
+++ b/tensorflow/tools/dist_test/python/mnist_replica.py
@@ -17,7 +17,7 @@
A simple softmax model with one hidden layer is defined. The parameters
(weights and biases) are located on one parameter server (ps), while the ops
-are executed on two worker nodes by default. The TF sessions also run on the
+are executed on two worker nodes by default. The TF sessions also run on the
worker node.
Multiple invocations of this script can be done in parallel, with different
values for --task_index. There should be exactly one invocation with
@@ -123,9 +123,7 @@ def main(unused_argv):
is_chief = (FLAGS.task_index == 0)
if FLAGS.num_gpus > 0:
- if FLAGS.num_gpus < num_workers:
- raise ValueError("number of gpus is less than number of workers")
- # Avoid gpu allocation conflict: now allocate task_num -> #gpu
+ # Avoid gpu allocation conflict: now allocate task_num -> #gpu
# for each worker in the corresponding machine
gpu = (FLAGS.task_index % FLAGS.num_gpus)
worker_device = "/job:worker/task:%d/gpu:%d" % (FLAGS.task_index, gpu)
diff --git a/tensorflow/tools/docker/Dockerfile.devel-gpu b/tensorflow/tools/docker/Dockerfile.devel-gpu
index d0a038a9db..e10565a064 100644
--- a/tensorflow/tools/docker/Dockerfile.devel-gpu
+++ b/tensorflow/tools/docker/Dockerfile.devel-gpu
@@ -19,6 +19,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
zlib1g-dev \
openjdk-8-jdk \
openjdk-8-jre-headless \
+ wget \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
diff --git a/tensorflow/tools/docker/README.md b/tensorflow/tools/docker/README.md
index 6d5a9bdc4c..3780bde2be 100644
--- a/tensorflow/tools/docker/README.md
+++ b/tensorflow/tools/docker/README.md
@@ -55,7 +55,7 @@ for additional containers, such as release candidates or nightly builds.
## Rebuilding the containers
Building TensorFlow Docker containers should be done through the
-[parameterized_docker_build.sh](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/tools/docker/README.md)
+[parameterized_docker_build.sh](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/tools/docker/parameterized_docker_build.sh)
script. The raw Dockerfiles should not be used directly as they contain strings
to be replaced by the script during the build.
diff --git a/tensorflow/tools/docs/generate_lib.py b/tensorflow/tools/docs/generate_lib.py
index a8ac9f13b1..bbeb3921d7 100644
--- a/tensorflow/tools/docs/generate_lib.py
+++ b/tensorflow/tools/docs/generate_lib.py
@@ -449,7 +449,7 @@ class DocGenerator(object):
'--base_dir',
type=str,
default=default_base_dir,
- help='Base directory to to strip from file names referenced in docs.')
+ help='Base directory to strip from file names referenced in docs.')
def parse_known_args(self):
flags, _ = self.argument_parser.parse_known_args()
diff --git a/tensorflow/tools/docs/parser.py b/tensorflow/tools/docs/parser.py
index 1bf8a2979c..18c3c98dc2 100644
--- a/tensorflow/tools/docs/parser.py
+++ b/tensorflow/tools/docs/parser.py
@@ -54,7 +54,7 @@ class _Errors(object):
"""Add an error to the collection.
Args:
- full_name: The path to the file in which the error occured.
+ full_name: The path to the file in which the error occurred.
message: The message to display with the error.
"""
self._errors.append((full_name, message))
diff --git a/tensorflow/tools/pip_package/setup.py b/tensorflow/tools/pip_package/setup.py
index 54ba8064e8..39499e1775 100644
--- a/tensorflow/tools/pip_package/setup.py
+++ b/tensorflow/tools/pip_package/setup.py
@@ -29,7 +29,7 @@ from setuptools.dist import Distribution
# This version string is semver compatible, but incompatible with pip.
# For pip, we will remove all '-' characters from this string, and use the
# result for pip.
-_VERSION = '1.2.0'
+_VERSION = '1.2.1'
REQUIRED_PACKAGES = [
'numpy >= 1.11.0',
diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl
index bb5a28bab1..20d45a7fdc 100644
--- a/tensorflow/workspace.bzl
+++ b/tensorflow/workspace.bzl
@@ -520,7 +520,7 @@ def tf_workspace(path_prefix="", tf_repo_name=""):
actual = "@jsoncpp_git//:jsoncpp",
)
- native.http_archive(
+ patched_http_archive(
name = "boringssl",
urls = [
"http://mirror.bazel.build/github.com/google/boringssl/archive/bbcaa15b0647816b9a1a9b9e0d209cd6712f0105.tar.gz",
@@ -528,6 +528,9 @@ def tf_workspace(path_prefix="", tf_repo_name=""):
],
sha256 = "025264d6e9a7ad371f2f66d17a28b6627de0c9592dc2eb54afd062f68f1f9aa3",
strip_prefix = "boringssl-bbcaa15b0647816b9a1a9b9e0d209cd6712f0105",
+
+ # Add patch to boringssl code to support s390x
+ patch_file = str(Label("//third_party/boringssl:add_boringssl_s390x.patch")),
)
native.new_http_archive(
diff --git a/third_party/lmdb.BUILD b/third_party/lmdb.BUILD
index 7c6e3dc3f0..9b3e1d97c8 100644
--- a/third_party/lmdb.BUILD
+++ b/third_party/lmdb.BUILD
@@ -19,8 +19,8 @@ cc_library(
"-w",
],
linkopts = select({
- ":windows": ["-Wl,advapi32.lib"], # InitializeSecurityDescriptor, SetSecurityDescriptorDacl
- ":windows_msvc": ["-Wl,advapi32.lib"],
+ ":windows": ["-DEFAULTLIB:advapi32.lib"], # InitializeSecurityDescriptor, SetSecurityDescriptorDacl
+ ":windows_msvc": ["-DEFAULTLIB:advapi32.lib"],
"//conditions:default": ["-lpthread"],
}),
visibility = ["//visibility:public"],
diff --git a/third_party/snappy.BUILD b/third_party/snappy.BUILD
index 120028dc52..9c00b7068a 100644
--- a/third_party/snappy.BUILD
+++ b/third_party/snappy.BUILD
@@ -4,6 +4,18 @@ licenses(["notice"]) # BSD 3-Clause
exports_files(["COPYING"])
+config_setting(
+ name = "windows",
+ values = {"cpu": "x64_windows"},
+ visibility = ["//visibility:public"],
+)
+
+config_setting(
+ name = "windows_msvc",
+ values = {"cpu": "x64_windows_msvc"},
+ visibility = ["//visibility:public"],
+)
+
cc_library(
name = "snappy",
srcs = [
@@ -19,10 +31,14 @@ cc_library(
"snappy-stubs-public.h",
],
hdrs = ["snappy.h"],
- copts = [
- "-Wno-shift-negative-value",
- "-Wno-implicit-function-declaration",
- ],
+ copts = select({
+ ":windows": [],
+ ":windows_msvc": [],
+ "//conditions:default": [
+ "-Wno-shift-negative-value",
+ "-Wno-implicit-function-declaration",
+ ],
+ }),
)
genrule(
diff --git a/third_party/sycl/crosstool/computecpp.tpl b/third_party/sycl/crosstool/computecpp.tpl
index 8b0a7a7d4a..c699eabb6f 100755
--- a/third_party/sycl/crosstool/computecpp.tpl
+++ b/third_party/sycl/crosstool/computecpp.tpl
@@ -73,7 +73,7 @@ def main():
bc_out = filename + '.sycl'
# strip asan for the device
- computecpp_device_compiler_flags = ['-sycl-compress-name', '-Wno-unused-variable',
+ computecpp_device_compiler_flags = ['-sycl-compress-name', '-Wno-unused-variable', '-Wno-c++11-narrowing',
'-I', COMPUTECPP_INCLUDE, '-isystem', COMPUTECPP_INCLUDE,
'-std=c++11', '-sycl', '-emit-llvm', '-no-serial-memop',
'-Xclang', '-cl-denorms-are-zero', '-Xclang', '-cl-fp32-correctly-rounded-divide-sqrt']
diff --git a/third_party/toolchains/cpus/CROSSTOOL b/third_party/toolchains/cpus/CROSSTOOL
index 0e2d0119af..0fff8191e0 100644
--- a/third_party/toolchains/cpus/CROSSTOOL
+++ b/third_party/toolchains/cpus/CROSSTOOL
@@ -374,12 +374,15 @@ toolchain {
action: 'c++-header-preprocessing'
action: 'c++-module-compile'
flag_group {
+ iterate_over: 'quote_include_paths'
flag: '/I%{quote_include_paths}'
}
flag_group {
+ iterate_over: 'include_paths'
flag: '/I%{include_paths}'
}
flag_group {
+ iterate_over: 'system_include_paths'
flag: '/I%{system_include_paths}'
}
}
@@ -630,6 +633,7 @@ toolchain {
action: 'c++-link-dynamic-library'
expand_if_all_available: 'linkstamp_paths'
flag_group {
+ iterate_over: 'linkstamp_paths'
flag: '%{linkstamp_paths}'
}
}
@@ -671,6 +675,7 @@ toolchain {
action: 'c++-link-pic-static-library'
action: 'c++-link-alwayslink-pic-static-library'
flag_group {
+ iterate_over: 'libopts'
flag: '%{libopts}'
}
}
@@ -770,6 +775,7 @@ toolchain {
action: 'c++-link-executable'
action: 'c++-link-dynamic-library'
flag_group {
+ iterate_over: 'legacy_link_flags'
flag: '%{legacy_link_flags}'
}
}
diff --git a/third_party/zlib.BUILD b/third_party/zlib.BUILD
index 279e6395b0..8509668891 100644
--- a/third_party/zlib.BUILD
+++ b/third_party/zlib.BUILD
@@ -2,6 +2,18 @@ package(default_visibility = ["//visibility:public"])
licenses(["notice"]) # BSD/MIT-like license (for zlib)
+config_setting(
+ name = "windows",
+ values = {"cpu": "x64_windows"},
+ visibility = ["//visibility:public"],
+)
+
+config_setting(
+ name = "windows_msvc",
+ values = {"cpu": "x64_windows_msvc"},
+ visibility = ["//visibility:public"],
+)
+
cc_library(
name = "zlib",
srcs = [
@@ -32,9 +44,13 @@ cc_library(
"zutil.h",
],
hdrs = ["zlib.h"],
- copts = [
- "-Wno-shift-negative-value",
- "-Wno-implicit-function-declaration",
- ],
+ copts = select({
+ ":windows": [],
+ ":windows_msvc": [],
+ "//conditions:default": [
+ "-Wno-shift-negative-value",
+ "-Wno-implicit-function-declaration",
+ ],
+ }),
includes = ["."],
)