From c61c39614a4780464037226d9d3c28101f7e8e46 Mon Sep 17 00:00:00 2001 From: Vijay Vasudevan Date: Tue, 10 Nov 2015 15:23:01 -0800 Subject: [PATCH] TensorFlow: upstream changes to git (doc fixes). Changes: - Fix typos across several files contributed by Erik Erwitt, and Michael R. Berstein - Fix bug in translate example (fr->en typo) by schuster - Updates to some documentation (mcoram,shlens,vrv,joshl) - Fix to Android camera demo app window size detection (andrewharp) - Fix to support lookup table of high rank tensors (yleon) - Fix invalid op names for parse_example (dga) Base CL: 107531031 --- tensorflow/core/kernels/lookup_table_op.cc | 6 +- tensorflow/core/ops/data_flow_ops.cc | 52 ++++---- tensorflow/core/public/tensor.h | 2 +- tensorflow/core/util/events_writer.cc | 2 +- tensorflow/examples/android/README.md | 31 +++-- .../demo/CameraConnectionFragment.java | 9 +- tensorflow/g3doc/api_docs/cc/ClassTensor.md | 2 +- .../g3doc/api_docs/cc/ClassTensorBuffer.md | 52 -------- .../g3doc/api_docs/cc/ClassTensorShapeIter.md | 45 ------- tensorflow/g3doc/api_docs/cc/index.md | 12 +- .../g3doc/api_docs/python/constant_op.md | 2 +- tensorflow/g3doc/api_docs/python/state_ops.md | 14 +- tensorflow/g3doc/api_docs/python/train.md | 10 +- tensorflow/g3doc/get_started/os_setup.md | 2 +- .../summaries_and_tensorboard/index.md | 11 +- tensorflow/g3doc/how_tos/variables/index.md | 2 +- tensorflow/g3doc/tutorials/deep_cnn/index.md | 21 +-- .../g3doc/tutorials/mnist/beginners/index.md | 2 +- tensorflow/g3doc/tutorials/seq2seq/index.md | 2 +- tensorflow/models/rnn/translate/data_utils.py | 2 +- .../kernel_tests/lookup_table_op_test.py | 19 +++ .../python/kernel_tests/parsing_ops_test.py | 16 ++- tensorflow/python/ops/constant_op.py | 2 +- tensorflow/python/ops/data_flow_ops.py | 43 +++---- tensorflow/python/ops/parsing_ops.py | 120 +++++++++--------- 25 files changed, 209 insertions(+), 272 deletions(-) delete mode 100644 tensorflow/g3doc/api_docs/cc/ClassTensorBuffer.md delete mode 100644 tensorflow/g3doc/api_docs/cc/ClassTensorShapeIter.md diff --git a/tensorflow/core/kernels/lookup_table_op.cc b/tensorflow/core/kernels/lookup_table_op.cc index 2bab4df94f0..2d647d8ed4d 100644 --- a/tensorflow/core/kernels/lookup_table_op.cc +++ b/tensorflow/core/kernels/lookup_table_op.cc @@ -109,9 +109,6 @@ class LookupTableFindOp : public OpKernel { OP_REQUIRES_OK(ctx, ctx->MatchSignature(expected_inputs, expected_outputs)); const Tensor& input = ctx->input(1); - OP_REQUIRES(ctx, TensorShapeUtils::IsVector(input.shape()), - errors::InvalidArgument("Input must be a vector, not ", - input.shape().DebugString())); const Tensor& default_value = ctx->input(2); OP_REQUIRES(ctx, TensorShapeUtils::IsScalar(default_value.shape()), @@ -119,8 +116,7 @@ class LookupTableFindOp : public OpKernel { default_value.shape().DebugString())); Tensor* out; - OP_REQUIRES_OK(ctx, - ctx->allocate_output("output_values", input.shape(), &out)); + OP_REQUIRES_OK(ctx, ctx->allocate_output("values", input.shape(), &out)); OP_REQUIRES_OK(ctx, table->Find(input, out, default_value)); } diff --git a/tensorflow/core/ops/data_flow_ops.cc b/tensorflow/core/ops/data_flow_ops.cc index 49eba33188d..ed61c3cc10e 100644 --- a/tensorflow/core/ops/data_flow_ops.cc +++ b/tensorflow/core/ops/data_flow_ops.cc @@ -284,29 +284,28 @@ handle: The handle to a queue. size: The number of elements in the given queue. )doc"); - // -------------------------------------------------------------------------- REGISTER_OP("LookupTableFind") .Input("table_handle: Ref(string)") - .Input("input_values: Tin") + .Input("keys: Tin") .Input("default_value: Tout") - .Output("output_values: Tout") + .Output("values: Tout") .Attr("Tin: type") .Attr("Tout: type") .Doc(R"doc( -Maps elements of a tensor into associated values given a lookup table. +Looks up keys in a table, outputs the corresponding values. -If an element of the input_values is not present in the table, the -specified default_value is used. +The tensor `keys` must of the same type as the keys of the table. +The output `values` is of the type of the table values. -The table needs to be initialized and the input and output types correspond -to the table key and value types. +The scalar `default_value` is the value output for keys not present in the +table. It must also be of the same type as the table values. -table_handle: A handle for a lookup table. -input_values: A vector of key values. -default_value: A scalar to return if the input is not found in the table. -output_values: A vector of values associated to the inputs. +table_handle: Handle to the table. +keys: Any shape. Keys to look up. +values: Same shape as `keys`. Values found in the table, or `default_values` + for missing keys. )doc"); REGISTER_OP("LookupTableSize") @@ -315,8 +314,8 @@ REGISTER_OP("LookupTableSize") .Doc(R"doc( Computes the number of elements in the given table. -table_handle: The handle to a lookup table. -size: The number of elements in the given table. +table_handle: Handle to the table. +size: Scalar that contains number of elements in the table. )doc"); REGISTER_OP("HashTable") @@ -326,18 +325,19 @@ REGISTER_OP("HashTable") .Attr("key_dtype: type") .Attr("value_dtype: type") .Doc(R"doc( -Creates and holds an immutable hash table. +Creates a non-initialized hash table. -The key and value types can be specified. After initialization, the table -becomes immutable. +This op creates a hash table, specifying the type of its keys and values. +Before using the table you will have to initialize it. After initialization the +table will be immutable. -table_handle: a handle of a the lookup table. -container: If non-empty, this hash table is placed in the given container. - Otherwise, a default container is used. -shared_name: If non-empty, this hash table is shared under the given name across +table_handle: Handle to a table. +container: If non-empty, this table is placed in the given container. + Otherwise, a default container is used. +shared_name: If non-empty, this table is shared under the given name across multiple sessions. -key_dtype: the type of the table key. -value_dtype: the type of the table value. +key_dtype: Type of the table keys. +value_dtype: Type of the table values. )doc"); REGISTER_OP("InitializeTable") @@ -349,9 +349,9 @@ REGISTER_OP("InitializeTable") .Doc(R"doc( Table initializer that takes two tensors for keys and values respectively. -table_handle: a handle of the lookup table to be initialized. -keys: a vector of keys of type Tkey. -values: a vector of values of type Tval. +table_handle: Handle to a table which will be initialized. +keys: Keys of type Tkey. +values: Values of type Tval. Same shape as `keys`. )doc"); } // namespace tensorflow diff --git a/tensorflow/core/public/tensor.h b/tensorflow/core/public/tensor.h index 446f5537000..bcb556345aa 100644 --- a/tensorflow/core/public/tensor.h +++ b/tensorflow/core/public/tensor.h @@ -93,7 +93,7 @@ class Tensor { /// \brief Slice this tensor along the 1st dimension. - /// I.e., the returned tensor satisifies + /// I.e., the returned tensor satisfies /// returned[i, ...] == this[dim0_start + i, ...]. /// The returned tensor shares the underlying tensor buffer with this /// tensor. diff --git a/tensorflow/core/util/events_writer.cc b/tensorflow/core/util/events_writer.cc index 1b34a365778..39fdddf178b 100644 --- a/tensorflow/core/util/events_writer.cc +++ b/tensorflow/core/util/events_writer.cc @@ -25,7 +25,7 @@ bool EventsWriter::Init() { if (FileHasDisappeared()) { // Warn user of data loss and let .reset() below do basic cleanup. if (num_outstanding_events_ > 0) { - LOG(WARNING) << "Re-intialization, attempting to open a new file, " + LOG(WARNING) << "Re-initialization, attempting to open a new file, " << num_outstanding_events_ << " events will be lost."; } } else { diff --git a/tensorflow/examples/android/README.md b/tensorflow/examples/android/README.md index a7c90fed977..e115c0a6098 100644 --- a/tensorflow/examples/android/README.md +++ b/tensorflow/examples/android/README.md @@ -6,41 +6,46 @@ This folder contains a simple camera-based demo application utilizing Tensorflow This demo uses a Google Inception model to classify camera frames in real-time, displaying the top results in an overlay on the camera image. See -assets/imagenet_comp_graph_label_strings.txt for the possible classificiations. +[`assets/imagenet_comp_graph_label_strings.txt`](assets/imagenet_comp_graph_label_strings.txt) +for the possible classifications. ## To build/install/run -As a pre-requisite, Bazel, the Android NDK, and the Android SDK must all be +As a prerequisite, Bazel, the Android NDK, and the Android SDK must all be installed on your system. The Android build tools may be obtained from: https://developer.android.com/tools/revisions/build-tools.html -The Android entries in [/WORKSPACE](../../WORKSPACE) must be +The Android entries in [`/WORKSPACE`](../../WORKSPACE) must be uncommented with the paths filled in appropriately depending on where you installed the NDK and SDK. Otherwise an error such as: "The external label '//external:android/sdk' is not bound to anything" will be reported. To build the APK, run this from your workspace root: + +```bash +$ bazel build //tensorflow/examples/android:tensorflow_demo -c opt --copt=-mfpu=neon ``` -bazel build //tensorflow/examples/android:tensorflow_demo -c opt --copt=-mfpu=neon -``` -Note that "-c opt" is currently required; if not set, an assert (for an + +Note that `-c opt` is currently required; if not set, an assert (for an otherwise non-problematic issue) in Eigen will halt the application during execution. This issue will be corrected in an upcoming release. If adb debugging is enabled on your Android 5.0 or later device, you may then use the following command from your workspace root to install the APK once built: -''' -adb install -r -g bazel-bin/tensorflow/examples/android/tensorflow_demo_incremental.apk -''' + +```bash +$ adb install -r -g bazel-bin/tensorflow/examples/android/tensorflow_demo_incremental.apk +``` Alternatively, a streamlined means of building, installing and running in one command is: -``` -bazel mobile-install //tensorflow/examples/android:tensorflow_demo -c opt --start_app --copt=-mfpu=neon + +```bash +$ bazel mobile-install //tensorflow/examples/android:tensorflow_demo -c opt --start_app --copt=-mfpu=neon ``` If camera permission errors are encountered (possible on Android Marshmallow or -above), then the adb install command above should be used instead, as it -automatically grants the required camera permissions with '-g'. +above), then the `adb install` command above should be used instead, as it +automatically grants the required camera permissions with `-g`. diff --git a/tensorflow/examples/android/src/org/tensorflow/demo/CameraConnectionFragment.java b/tensorflow/examples/android/src/org/tensorflow/demo/CameraConnectionFragment.java index d9a696d9bbd..28dadb9ddf5 100644 --- a/tensorflow/examples/android/src/org/tensorflow/demo/CameraConnectionFragment.java +++ b/tensorflow/examples/android/src/org/tensorflow/demo/CameraConnectionFragment.java @@ -63,6 +63,12 @@ import java.util.concurrent.TimeUnit; public class CameraConnectionFragment extends Fragment { private static final Logger LOGGER = new Logger(); + /** + * The camera preview size will be chosen to be the smallest frame by pixel size capable of + * containing a DESIRED_SIZE x DESIRED_SIZE square. + */ + private static final int MINIMUM_PREVIEW_SIZE = 320; + private RecognitionScoreView scoreView; /** @@ -227,8 +233,7 @@ public class CameraConnectionFragment extends Fragment { // Collect the supported resolutions that are at least as big as the preview Surface final List bigEnough = new ArrayList<>(); for (final Size option : choices) { - // TODO(andrewharp): Choose size intelligently. - if (option.getHeight() == 320 && option.getWidth() == 480) { + if (option.getHeight() >= MINIMUM_PREVIEW_SIZE && option.getWidth() >= MINIMUM_PREVIEW_SIZE) { LOGGER.i("Adding size: " + option.getWidth() + "x" + option.getHeight()); bigEnough.add(option); } else { diff --git a/tensorflow/g3doc/api_docs/cc/ClassTensor.md b/tensorflow/g3doc/api_docs/cc/ClassTensor.md index d04a24d530f..9bc97fe1d74 100644 --- a/tensorflow/g3doc/api_docs/cc/ClassTensor.md +++ b/tensorflow/g3doc/api_docs/cc/ClassTensor.md @@ -178,7 +178,7 @@ This tensor shares other's underlying storage. Returns `true` iff `other.sh Slice this tensor along the 1st dimension. -I.e., the returned tensor satisifies returned[i, ...] == this[dim0_start + i, ...]. The returned tensor shares the underlying tensor buffer with this tensor. +I.e., the returned tensor satisfies returned[i, ...] == this[dim0_start + i, ...]. The returned tensor shares the underlying tensor buffer with this tensor. NOTE: The returned tensor may not satisfies the same alignment requirement as this tensor depending on the shape. The caller must check the returned tensor's alignment before calling certain methods that have alignment requirement (e.g., ` flat() `, `tensor()`). diff --git a/tensorflow/g3doc/api_docs/cc/ClassTensorBuffer.md b/tensorflow/g3doc/api_docs/cc/ClassTensorBuffer.md deleted file mode 100644 index 493d4da9897..00000000000 --- a/tensorflow/g3doc/api_docs/cc/ClassTensorBuffer.md +++ /dev/null @@ -1,52 +0,0 @@ -# Class `tensorflow::TensorBuffer` - - - - - -##Member Summary - -* [`tensorflow::TensorBuffer::~TensorBuffer() override`](#tensorflow_TensorBuffer_TensorBuffer) -* [`virtual void* tensorflow::TensorBuffer::data() const =0`](#virtual_void_tensorflow_TensorBuffer_data) -* [`virtual size_t tensorflow::TensorBuffer::size() const =0`](#virtual_size_t_tensorflow_TensorBuffer_size) -* [`virtual TensorBuffer* tensorflow::TensorBuffer::root_buffer()=0`](#virtual_TensorBuffer_tensorflow_TensorBuffer_root_buffer) -* [`virtual void tensorflow::TensorBuffer::FillAllocationDescription(AllocationDescription *proto) const =0`](#virtual_void_tensorflow_TensorBuffer_FillAllocationDescription) -* [`T* tensorflow::TensorBuffer::base() const`](#T_tensorflow_TensorBuffer_base) - -##Member Details - -#### `tensorflow::TensorBuffer::~TensorBuffer() override` - - - - - -#### `virtual void* tensorflow::TensorBuffer::data() const =0` - - - - - -#### `virtual size_t tensorflow::TensorBuffer::size() const =0` - - - - - -#### `virtual TensorBuffer* tensorflow::TensorBuffer::root_buffer()=0` - - - - - -#### `virtual void tensorflow::TensorBuffer::FillAllocationDescription(AllocationDescription *proto) const =0` - - - - - -#### `T* tensorflow::TensorBuffer::base() const` - - - - diff --git a/tensorflow/g3doc/api_docs/cc/ClassTensorShapeIter.md b/tensorflow/g3doc/api_docs/cc/ClassTensorShapeIter.md deleted file mode 100644 index ada68f238ad..00000000000 --- a/tensorflow/g3doc/api_docs/cc/ClassTensorShapeIter.md +++ /dev/null @@ -1,45 +0,0 @@ -# Class `tensorflow::TensorShapeIter` - - - - - -##Member Summary - -* [`tensorflow::TensorShapeIter::TensorShapeIter(const TensorShape *shape, int d)`](#tensorflow_TensorShapeIter_TensorShapeIter) -* [`bool tensorflow::TensorShapeIter::operator==(const TensorShapeIter &rhs)`](#bool_tensorflow_TensorShapeIter_operator_) -* [`bool tensorflow::TensorShapeIter::operator!=(const TensorShapeIter &rhs)`](#bool_tensorflow_TensorShapeIter_operator_) -* [`void tensorflow::TensorShapeIter::operator++()`](#void_tensorflow_TensorShapeIter_operator_) -* [`TensorShapeDim tensorflow::TensorShapeIter::operator*()`](#TensorShapeDim_tensorflow_TensorShapeIter_operator_) - -##Member Details - -#### `tensorflow::TensorShapeIter::TensorShapeIter(const TensorShape *shape, int d)` - - - - - -#### `bool tensorflow::TensorShapeIter::operator==(const TensorShapeIter &rhs)` - - - - - -#### `bool tensorflow::TensorShapeIter::operator!=(const TensorShapeIter &rhs)` - - - - - -#### `void tensorflow::TensorShapeIter::operator++()` - - - - - -#### `TensorShapeDim tensorflow::TensorShapeIter::operator*()` - - - - diff --git a/tensorflow/g3doc/api_docs/cc/index.md b/tensorflow/g3doc/api_docs/cc/index.md index c4bd0cd32a6..e30022d9c2c 100644 --- a/tensorflow/g3doc/api_docs/cc/index.md +++ b/tensorflow/g3doc/api_docs/cc/index.md @@ -27,17 +27,15 @@ write the graph to a file. ##Classes * [tensorflow::Env](../../api_docs/cc/ClassEnv.md) -* [tensorflow::EnvWrapper](../../api_docs/cc/ClassEnvWrapper.md) * [tensorflow::RandomAccessFile](../../api_docs/cc/ClassRandomAccessFile.md) +* [tensorflow::WritableFile](../../api_docs/cc/ClassWritableFile.md) +* [tensorflow::EnvWrapper](../../api_docs/cc/ClassEnvWrapper.md) * [tensorflow::Session](../../api_docs/cc/ClassSession.md) * [tensorflow::Status](../../api_docs/cc/ClassStatus.md) * [tensorflow::Tensor](../../api_docs/cc/ClassTensor.md) -* [tensorflow::TensorBuffer](../../api_docs/cc/ClassTensorBuffer.md) * [tensorflow::TensorShape](../../api_docs/cc/ClassTensorShape.md) -* [tensorflow::TensorShapeIter](../../api_docs/cc/ClassTensorShapeIter.md) * [tensorflow::TensorShapeUtils](../../api_docs/cc/ClassTensorShapeUtils.md) * [tensorflow::Thread](../../api_docs/cc/ClassThread.md) -* [tensorflow::WritableFile](../../api_docs/cc/ClassWritableFile.md) ##Structs @@ -50,17 +48,15 @@ write the graph to a file.