diff options
author | 2018-01-03 07:54:54 -0800 | |
---|---|---|
committer | 2018-01-03 07:58:09 -0800 | |
commit | ca19540ebdb827c9ac9a237bde97065e787dbe4f (patch) | |
tree | b54019c962d8ee95fefe6165d58a01dcc4cb2de5 /tensorflow/core/ops/state_ops.cc | |
parent | 961be409bbb0d3febf8a1005e67cb6750b75806d (diff) |
Removing doc strings from REGISTER_OP calls in core/ops.
PiperOrigin-RevId: 180670333
Diffstat (limited to 'tensorflow/core/ops/state_ops.cc')
-rw-r--r-- | tensorflow/core/ops/state_ops.cc | 520 |
1 files changed, 19 insertions, 501 deletions
diff --git a/tensorflow/core/ops/state_ops.cc b/tensorflow/core/ops/state_ops.cc index 5b1f5d2477..7a524b60c0 100644 --- a/tensorflow/core/ops/state_ops.cc +++ b/tensorflow/core/ops/state_ops.cc @@ -28,22 +28,7 @@ REGISTER_OP("VariableV2") .Attr("container: string = ''") .Attr("shared_name: string = ''") .SetIsStateful() - .SetShapeFn(shape_inference::ExplicitShape) - .Doc(R"doc( -Holds state in the form of a tensor that persists across steps. - -Outputs a ref to the tensor state so it may be read or modified. -TODO(zhifengc/mrry): Adds a pointer to a more detail document -about sharing states in tensorflow. - -ref: A reference to the variable tensor. -shape: The shape of the variable tensor. -dtype: The type of elements in the variable tensor. -container: If non-empty, this variable is placed in the given container. - Otherwise, a default container is used. -shared_name: If non-empty, this variable is named in the given bucket - with this shared_name. Otherwise, the node name is used instead. -)doc"); + .SetShapeFn(shape_inference::ExplicitShape); REGISTER_OP("Variable") .Output("ref: Ref(dtype)") @@ -67,23 +52,14 @@ REGISTER_OP("Variable") TF_RETURN_IF_ERROR(c->MakeShapeFromPartialTensorShape(shape, &out)); c->set_output(0, out); return Status::OK(); - }) - .Doc("Use VariableV2 instead."); + }); REGISTER_OP("IsVariableInitialized") .Input("ref: Ref(dtype)") .Output("is_initialized: bool") .Attr("dtype: type") .SetAllowsUninitializedInput() - .SetShapeFn(shape_inference::ScalarShape) - .Doc(R"doc( -Checks whether a tensor has been initialized. - -Outputs boolean scalar indicating whether the tensor has been initialized. - -ref: Should be from a `Variable` node. May be uninitialized. -dtype: The type of elements in the variable tensor. -)doc"); + .SetShapeFn(shape_inference::ScalarShape); REGISTER_OP("TemporaryVariable") .Output("ref: Ref(dtype)") @@ -91,53 +67,14 @@ REGISTER_OP("TemporaryVariable") .Attr("dtype: type") .Attr("var_name: string = ''") .SetIsStateful() - .SetShapeFn(shape_inference::ExplicitShape) - .Doc(R"doc( -Returns a tensor that may be mutated, but only persists within a single step. - -This is an experimental op for internal use only and it is possible to use this -op in unsafe ways. DO NOT USE unless you fully understand the risks. - -It is the caller's responsibility to ensure that 'ref' is eventually passed to a -matching 'DestroyTemporaryVariable' op after all other uses have completed. - -Outputs a ref to the tensor state so it may be read or modified. - - E.g. - var = state_ops._temporary_variable([1, 2], types.float_) - var_name = var.op.name - var = state_ops.assign(var, [[4.0, 5.0]]) - var = state_ops.assign_add(var, [[6.0, 7.0]]) - final = state_ops._destroy_temporary_variable(var, var_name=var_name) - -ref: A reference to the variable tensor. -shape: The shape of the variable tensor. -dtype: The type of elements in the variable tensor. -var_name: Overrides the name used for the temporary variable resource. Default -value is the name of the 'TemporaryVariable' op (which is guaranteed unique). -)doc"); + .SetShapeFn(shape_inference::ExplicitShape); REGISTER_OP("DestroyTemporaryVariable") .Input("ref: Ref(T)") .Output("value: T") .Attr("T: type") .Attr("var_name: string") - .SetShapeFn(shape_inference::UnchangedShape) - .Doc(R"doc( -Destroys the temporary variable and returns its final value. - -Sets output to the value of the Tensor pointed to by 'ref', then destroys -the temporary variable called 'var_name'. -All other uses of 'ref' *must* have executed before this op. -This is typically achieved by chaining the ref through each assign op, or by -using control dependencies. - -Outputs the final value of the tensor pointed to by 'ref'. - -ref: A reference to the temporary variable tensor. -var_name: Name of the temporary variable, usually the name of the matching -'TemporaryVariable' op. -)doc"); + .SetShapeFn(shape_inference::UnchangedShape); REGISTER_OP("Assign") .Input("ref: Ref(T)") @@ -156,23 +93,7 @@ REGISTER_OP("Assign") c->set_output(0, c->input(1)); return Status::OK(); - }) - .Doc(R"doc( -Update 'ref' by assigning 'value' to it. - -This operation outputs "ref" after the assignment is done. -This makes it easier to chain operations that need to use the reset value. - -ref: Should be from a `Variable` node. May be uninitialized. -value: The value to be assigned to the variable. -validate_shape: If true, the operation will validate that the shape - of 'value' matches the shape of the Tensor being assigned to. If false, - 'ref' will take on the shape of 'value'. -use_locking: If True, the assignment will be protected by a lock; - otherwise the behavior is undefined, but may exhibit less contention. -output_ref:= Same as "ref". Returned as a convenience for operations that want - to use the new value after the variable has been reset. -)doc"); + }); REGISTER_OP("AssignAdd") .Input("ref: Ref(T)") @@ -180,20 +101,7 @@ REGISTER_OP("AssignAdd") .Output("output_ref: Ref(T)") .Attr("T: numbertype") .Attr("use_locking: bool = false") - .SetShapeFn(shape_inference::MergeBothInputsShapeFn) - .Doc(R"doc( -Update 'ref' by adding 'value' to it. - -This operation outputs "ref" after the update is done. -This makes it easier to chain operations that need to use the reset value. - -ref: Should be from a `Variable` node. -value: The value to be added to the variable. -use_locking: If True, the addition will be protected by a lock; - otherwise the behavior is undefined, but may exhibit less contention. -output_ref:= Same as "ref". Returned as a convenience for operations that want - to use the new value after the variable has been updated. -)doc"); + .SetShapeFn(shape_inference::MergeBothInputsShapeFn); REGISTER_OP("AssignSub") .Input("ref: Ref(T)") @@ -201,20 +109,7 @@ REGISTER_OP("AssignSub") .Output("output_ref: Ref(T)") .Attr("T: numbertype") .Attr("use_locking: bool = false") - .SetShapeFn(shape_inference::MergeBothInputsShapeFn) - .Doc(R"doc( -Update 'ref' by subtracting 'value' from it. - -This operation outputs "ref" after the update is done. -This makes it easier to chain operations that need to use the reset value. - -ref: Should be from a `Variable` node. -value: The value to be subtracted to the variable. -use_locking: If True, the subtraction will be protected by a lock; - otherwise the behavior is undefined, but may exhibit less contention. -output_ref:= Same as "ref". Returned as a convenience for operations that want - to use the new value after the variable has been updated. -)doc"); + .SetShapeFn(shape_inference::MergeBothInputsShapeFn); namespace { @@ -243,44 +138,7 @@ REGISTER_OP("ScatterUpdate") .Attr("T: type") .Attr("Tindices: {int32, int64}") .Attr("use_locking: bool = true") - .SetShapeFn(ScatterUpdateShape) - .Doc(R"doc( -Applies sparse updates to a variable reference. - -This operation computes - -```python - # Scalar indices - ref[indices, ...] = updates[...] - - # Vector indices (for each i) - ref[indices[i], ...] = updates[i, ...] - - # High rank indices (for each i, ..., j) - ref[indices[i, ..., j], ...] = updates[i, ..., j, ...] -``` - -This operation outputs `ref` after the update is done. -This makes it easier to chain operations that need to use the reset value. - -If values in `ref` is to be updated more than once, because there are -duplicate entries in `indices`, the order at which the updates happen -for each value is undefined. - -Requires `updates.shape = indices.shape + ref.shape[1:]`. - -<div style="width:70%; margin:auto; margin-bottom:10px; margin-top:20px;"> -<img style="width:100%" src="https://www.tensorflow.org/images/ScatterUpdate.png" alt> -</div> - -ref: Should be from a `Variable` node. -indices: A tensor of indices into the first dimension of `ref`. -updates: A tensor of updated values to store in `ref`. -output_ref:= Same as `ref`. Returned as a convenience for operations that want - to use the updated values after the update is done. -use_locking: If True, the assignment will be protected by a lock; - otherwise the behavior is undefined, but may exhibit less contention. -)doc"); + .SetShapeFn(ScatterUpdateShape); REGISTER_OP("ScatterAdd") .Input("ref: Ref(T)") @@ -290,41 +148,7 @@ REGISTER_OP("ScatterAdd") .Attr("T: numbertype") .Attr("Tindices: {int32, int64}") .Attr("use_locking: bool = false") - .SetShapeFn(ScatterUpdateShape) - .Doc(R"doc( -Adds sparse updates to a variable reference. - -This operation computes - - # Scalar indices - ref[indices, ...] += updates[...] - - # Vector indices (for each i) - ref[indices[i], ...] += updates[i, ...] - - # High rank indices (for each i, ..., j) - ref[indices[i, ..., j], ...] += updates[i, ..., j, ...] - -This operation outputs `ref` after the update is done. -This makes it easier to chain operations that need to use the reset value. - -Duplicate entries are handled correctly: if multiple `indices` reference -the same location, their contributions add. - -Requires `updates.shape = indices.shape + ref.shape[1:]`. - -<div style="width:70%; margin:auto; margin-bottom:10px; margin-top:20px;"> -<img style="width:100%" src="https://www.tensorflow.org/images/ScatterAdd.png" alt> -</div> - -ref: Should be from a `Variable` node. -indices: A tensor of indices into the first dimension of `ref`. -updates: A tensor of updated values to add to `ref`. -output_ref:= Same as `ref`. Returned as a convenience for operations that want - to use the updated values after the update is done. -use_locking: If True, the addition will be protected by a lock; - otherwise the behavior is undefined, but may exhibit less contention. -)doc"); + .SetShapeFn(ScatterUpdateShape); REGISTER_OP("ScatterSub") .Input("ref: Ref(T)") @@ -334,41 +158,7 @@ REGISTER_OP("ScatterSub") .Attr("T: numbertype") .Attr("Tindices: {int32, int64}") .Attr("use_locking: bool = false") - .SetShapeFn(ScatterUpdateShape) - .Doc(R"doc( -Subtracts sparse updates to a variable reference. - -```python - # Scalar indices - ref[indices, ...] -= updates[...] - - # Vector indices (for each i) - ref[indices[i], ...] -= updates[i, ...] - - # High rank indices (for each i, ..., j) - ref[indices[i, ..., j], ...] -= updates[i, ..., j, ...] -``` - -This operation outputs `ref` after the update is done. -This makes it easier to chain operations that need to use the reset value. - -Duplicate entries are handled correctly: if multiple `indices` reference -the same location, their (negated) contributions add. - -Requires `updates.shape = indices.shape + ref.shape[1:]`. - -<div style="width:70%; margin:auto; margin-bottom:10px; margin-top:20px;"> -<img style="width:100%" src="https://www.tensorflow.org/images/ScatterSub.png" alt> -</div> - -ref: Should be from a `Variable` node. -indices: A tensor of indices into the first dimension of `ref`. -updates: A tensor of updated values to subtract from `ref`. -output_ref:= Same as `ref`. Returned as a convenience for operations that want - to use the updated values after the update is done. -use_locking: If True, the subtraction will be protected by a lock; - otherwise the behavior is undefined, but may exhibit less contention. -)doc"); + .SetShapeFn(ScatterUpdateShape); REGISTER_OP("ScatterMul") .Input("ref: Ref(T)") @@ -378,39 +168,7 @@ REGISTER_OP("ScatterMul") .Attr("T: numbertype") .Attr("Tindices: {int32, int64}") .Attr("use_locking: bool = false") - .SetShapeFn(ScatterUpdateShape) - .Doc(R"doc( -Multiplies sparse updates into a variable reference. - -This operation computes - -```python - # Scalar indices - ref[indices, ...] *= updates[...] - - # Vector indices (for each i) - ref[indices[i], ...] *= updates[i, ...] - - # High rank indices (for each i, ..., j) - ref[indices[i, ..., j], ...] *= updates[i, ..., j, ...] -``` - -This operation outputs `ref` after the update is done. -This makes it easier to chain operations that need to use the reset value. - -Duplicate entries are handled correctly: if multiple `indices` reference -the same location, their contributions multiply. - -Requires `updates.shape = indices.shape + ref.shape[1:]`. - -ref: Should be from a `Variable` node. -indices: A tensor of indices into the first dimension of `ref`. -updates: A tensor of updated values to multiply to `ref`. -output_ref:= Same as `ref`. Returned as a convenience for operations that want - to use the updated values after the update is done. -use_locking: If True, the operation will be protected by a lock; - otherwise the behavior is undefined, but may exhibit less contention. -)doc"); + .SetShapeFn(ScatterUpdateShape); REGISTER_OP("ScatterDiv") .Input("ref: Ref(T)") @@ -420,39 +178,7 @@ REGISTER_OP("ScatterDiv") .Attr("T: numbertype") .Attr("Tindices: {int32, int64}") .Attr("use_locking: bool = false") - .SetShapeFn(ScatterUpdateShape) - .Doc(R"doc( -Divides a variable reference by sparse updates. - -This operation computes - -```python - # Scalar indices - ref[indices, ...] /= updates[...] - - # Vector indices (for each i) - ref[indices[i], ...] /= updates[i, ...] - - # High rank indices (for each i, ..., j) - ref[indices[i, ..., j], ...] /= updates[i, ..., j, ...] -``` - -This operation outputs `ref` after the update is done. -This makes it easier to chain operations that need to use the reset value. - -Duplicate entries are handled correctly: if multiple `indices` reference -the same location, their contributions divide. - -Requires `updates.shape = indices.shape + ref.shape[1:]`. - -ref: Should be from a `Variable` node. -indices: A tensor of indices into the first dimension of `ref`. -updates: A tensor of values that `ref` is divided by. -output_ref:= Same as `ref`. Returned as a convenience for operations that want - to use the updated values after the update is done. -use_locking: If True, the operation will be protected by a lock; - otherwise the behavior is undefined, but may exhibit less contention. -)doc"); + .SetShapeFn(ScatterUpdateShape); REGISTER_OP("ScatterNdUpdate") .Input("ref: Ref(T)") @@ -462,56 +188,7 @@ REGISTER_OP("ScatterNdUpdate") .Attr("T: type") .Attr("Tindices: {int32, int64}") .Attr("use_locking: bool = true") - .SetShapeFn(shape_inference::ScatterNdUpdateShape) - .Doc(R"doc( -Applies sparse `updates` to individual values or slices within a given -variable according to `indices`. - -`ref` is a `Tensor` with rank `P` and `indices` is a `Tensor` of rank `Q`. - -`indices` must be integer tensor, containing indices into `ref`. -It must be shape `[d_0, ..., d_{Q-2}, K]` where `0 < K <= P`. - -The innermost dimension of `indices` (with length `K`) corresponds to -indices into elements (if `K = P`) or slices (if `K < P`) along the `K`th -dimension of `ref`. - -`updates` is `Tensor` of rank `Q-1+P-K` with shape: - -``` -[d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]]. -``` - -For example, say we want to update 4 scattered elements to a rank-1 tensor to -8 elements. In Python, that update would look like this: - -```python - ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8]) - indices = tf.constant([[4], [3], [1] ,[7]]) - updates = tf.constant([9, 10, 11, 12]) - update = tf.scatter_nd_update(ref, indices, updates) - with tf.Session() as sess: - print sess.run(update) -``` - -The resulting update to ref would look like this: - - [1, 11, 3, 10, 9, 6, 7, 12] - -See @{tf.scatter_nd} for more details about how to make updates to -slices. - -ref: A mutable Tensor. Should be from a Variable node. -indices: A Tensor. Must be one of the following types: int32, int64. - A tensor of indices into ref. -updates: A Tensor. Must have the same type as ref. A tensor of updated - values to add to ref. -use_locking: An optional bool. Defaults to True. If True, the assignment will - be protected by a lock; otherwise the behavior is undefined, - but may exhibit less contention. -output_ref: Same as ref. Returned as a convenience for operations that want to - use the updated values after the update is done. -)doc"); + .SetShapeFn(shape_inference::ScatterNdUpdateShape); REGISTER_OP("ResourceScatterNdUpdate") .Input("ref: resource") @@ -520,54 +197,7 @@ REGISTER_OP("ResourceScatterNdUpdate") .Attr("T: type") .Attr("Tindices: {int32, int64}") .Attr("use_locking: bool = true") - .SetShapeFn(shape_inference::ScatterNdUpdateShape) - .Doc(R"doc( -Applies sparse `updates` to individual values or slices within a given -variable according to `indices`. - -`ref` is a `Tensor` with rank `P` and `indices` is a `Tensor` of rank `Q`. - -`indices` must be integer tensor, containing indices into `ref`. -It must be shape `[d_0, ..., d_{Q-2}, K]` where `0 < K <= P`. - -The innermost dimension of `indices` (with length `K`) corresponds to -indices into elements (if `K = P`) or slices (if `K < P`) along the `K`th -dimension of `ref`. - -`updates` is `Tensor` of rank `Q-1+P-K` with shape: - -``` -[d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]]. -``` - -For example, say we want to update 4 scattered elements to a rank-1 tensor to -8 elements. In Python, that update would look like this: - -```python - ref = tfe.Variable([1, 2, 3, 4, 5, 6, 7, 8]) - indices = tf.constant([[4], [3], [1] ,[7]]) - updates = tf.constant([9, 10, 11, 12]) - update = tf.scatter_nd_update(ref, indices, updates) - with tf.Session() as sess: - print sess.run(update) -``` - -The resulting update to ref would look like this: - - [1, 11, 3, 10, 9, 6, 7, 12] - -See @{tf.scatter_nd} for more details about how to make updates to -slices. - -ref: A resource handle. Must be from a VarHandleOp. -indices: A Tensor. Must be one of the following types: int32, int64. - A tensor of indices into ref. -updates: A Tensor. Must have the same type as ref. A tensor of updated - values to add to ref. -use_locking: An optional bool. Defaults to True. If True, the assignment will - be protected by a lock; otherwise the behavior is undefined, - but may exhibit less contention. -)doc"); + .SetShapeFn(shape_inference::ScatterNdUpdateShape); REGISTER_OP("ScatterNdAdd") .Input("ref: Ref(T)") @@ -577,54 +207,7 @@ REGISTER_OP("ScatterNdAdd") .Attr("T: numbertype") .Attr("Tindices: {int32, int64}") .Attr("use_locking: bool = false") - .SetShapeFn(shape_inference::ScatterNdUpdateShape) - .Doc(R"doc( -Applies sparse addition between `updates` and individual values or slices -within a given variable according to `indices`. - -`ref` is a `Tensor` with rank `P` and `indices` is a `Tensor` of rank `Q`. - -`indices` must be integer tensor, containing indices into `ref`. -It must be shape `[d_0, ..., d_{Q-2}, K]` where `0 < K <= P`. - -The innermost dimension of `indices` (with length `K`) corresponds to -indices into elements (if `K = P`) or slices (if `K < P`) along the `K`th -dimension of `ref`. - -`updates` is `Tensor` of rank `Q-1+P-K` with shape: - -``` -[d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]]. -``` - -For example, say we want to add 4 scattered elements to a rank-1 tensor to 8 -elements. In Python, that addition would look like this: - - ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8]) - indices = tf.constant([[4], [3], [1], [7]]) - updates = tf.constant([9, 10, 11, 12]) - add = tf.scatter_nd_add(ref, indices, updates) - with tf.Session() as sess: - print sess.run(add) - -The resulting update to ref would look like this: - - [1, 13, 3, 14, 14, 6, 7, 20] - -See @{tf.scatter_nd} for more details about how to make updates to -slices. - -ref: A mutable Tensor. Should be from a Variable node. -indices: A Tensor. Must be one of the following types: int32, int64. - A tensor of indices into ref. -updates: A Tensor. Must have the same type as ref. A tensor of updated values - to add to ref. -use_locking: An optional bool. Defaults to True. If True, the assignment will - be protected by a lock; otherwise the behavior is undefined, - but may exhibit less contention. -output_ref: Same as ref. Returned as a convenience for operations that want - to use the updated values after the update is done. -)doc"); + .SetShapeFn(shape_inference::ScatterNdUpdateShape); REGISTER_OP("ScatterNdSub") .Input("ref: Ref(T)") @@ -634,54 +217,7 @@ REGISTER_OP("ScatterNdSub") .Attr("T: numbertype") .Attr("Tindices: {int32, int64}") .Attr("use_locking: bool = false") - .SetShapeFn(shape_inference::ScatterNdUpdateShape) - .Doc(R"doc( -Applies sparse subtraction between `updates` and individual values or slices -within a given variable according to `indices`. - -`ref` is a `Tensor` with rank `P` and `indices` is a `Tensor` of rank `Q`. - -`indices` must be integer tensor, containing indices into `ref`. -It must be shape `[d_0, ..., d_{Q-2}, K]` where `0 < K <= P`. - -The innermost dimension of `indices` (with length `K`) corresponds to -indices into elements (if `K = P`) or slices (if `K < P`) along the `K`th -dimension of `ref`. - -`updates` is `Tensor` of rank `Q-1+P-K` with shape: - -``` -[d_0, ..., d_{Q-2}, ref.shape[K], ..., ref.shape[P-1]]. -``` - -For example, say we want to subtract 4 scattered elements from a rank-1 tensor -with 8 elements. In Python, that subtraction would look like this: - - ref = tf.Variable([1, 2, 3, 4, 5, 6, 7, 8]) - indices = tf.constant([[4], [3], [1], [7]]) - updates = tf.constant([9, 10, 11, 12]) - sub = tf.scatter_nd_sub(ref, indices, updates) - with tf.Session() as sess: - print sess.run(sub) - -The resulting update to ref would look like this: - - [1, -9, 3, -6, -4, 6, 7, -4] - -See @{tf.scatter_nd} for more details about how to make updates to -slices. - -ref: A mutable Tensor. Should be from a Variable node. -indices: A Tensor. Must be one of the following types: int32, int64. - A tensor of indices into ref. -updates: A Tensor. Must have the same type as ref. A tensor of updated values - to subtract from ref. -use_locking: An optional bool. Defaults to True. If True, the assignment will - be protected by a lock; otherwise the behavior is undefined, - but may exhibit less contention. -output_ref: Same as ref. Returned as a convenience for operations that want - to use the updated values after the update is done. -)doc"); + .SetShapeFn(shape_inference::ScatterNdUpdateShape); REGISTER_OP("CountUpTo") .Input("ref: Ref(T)") @@ -693,16 +229,7 @@ REGISTER_OP("CountUpTo") TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 0, &output)); c->set_output(0, output); return Status::OK(); - }) - .Doc(R"doc( -Increments 'ref' until it reaches 'limit'. - -ref: Should be from a scalar `Variable` node. -limit: If incrementing ref would bring it above limit, instead generates an - 'OutOfRange' error. -output: A copy of the input before increment. If nothing else modifies the - input, the values produced will all be distinct. -)doc"); + }); REGISTER_OP("ResourceCountUpTo") .Input("resource: resource") @@ -726,15 +253,6 @@ REGISTER_OP("ResourceCountUpTo") TF_RETURN_IF_ERROR(c->WithRank(shape_and_type.shape, 0, &output)); c->set_output(0, output); return Status::OK(); - }) - .Doc(R"doc( -Increments variable pointed to by 'resource' until it reaches 'limit'. - -resource: Should be from a scalar `Variable` node. -limit: If incrementing ref would bring it above limit, instead generates an - 'OutOfRange' error. -output: A copy of the input before increment. If nothing else modifies the - input, the values produced will all be distinct. -)doc"); + }); } // namespace tensorflow |