diff options
Diffstat (limited to 'tensorflow/core/ops/sparse_ops.cc')
-rw-r--r-- | tensorflow/core/ops/sparse_ops.cc | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/tensorflow/core/ops/sparse_ops.cc b/tensorflow/core/ops/sparse_ops.cc index 9722f0ee9a..6aca2c3b01 100644 --- a/tensorflow/core/ops/sparse_ops.cc +++ b/tensorflow/core/ops/sparse_ops.cc @@ -710,6 +710,75 @@ a_shape: 1-D. The `shape` of the `SparseTensor`, with shape `[ndims]`. b: `ndims`-D Tensor. With shape `a_shape`. )doc"); +REGISTER_OP("SparseReduceMax") + .Input("input_indices: int64") + .Input("input_values: T") + .Input("input_shape: int64") + .Input("reduction_axes: int32") + .Attr("keep_dims: bool = False") + .Output("output: T") + .Attr("T: realnumbertype") + .SetShapeFn(shape_inference::UnknownShape) + .Doc(R"doc( +Computes the max of elements across dimensions of a SparseTensor. + +This Op takes a SparseTensor and is the sparse counterpart to +`tf.reduce_max()`. In particular, this Op also returns a dense `Tensor` +instead of a sparse one. + +Reduces `sp_input` along the dimensions given in `reduction_axes`. Unless +`keep_dims` is true, the rank of the tensor is reduced by 1 for each entry in +`reduction_axes`. If `keep_dims` is true, the reduced dimensions are retained +with length 1. + +If `reduction_axes` has no entries, all dimensions are reduced, and a tensor +with a single element is returned. Additionally, the axes can be negative, +which are interpreted according to the indexing rules in Python. + +input_indices: 2-D. `N x R` matrix with the indices of non-empty values in a + SparseTensor, possibly not in canonical ordering. +input_values: 1-D. `N` non-empty values corresponding to `input_indices`. +input_shape: 1-D. Shape of the input SparseTensor. +reduction_axes: 1-D. Length-`K` vector containing the reduction axes. +keep_dims: If true, retain reduced dimensions with length 1. +output: `R-K`-D. The reduced Tensor. +)doc"); + +REGISTER_OP("SparseReduceMaxSparse") + .Input("input_indices: int64") + .Input("input_values: T") + .Input("input_shape: int64") + .Input("reduction_axes: int32") + .Attr("keep_dims: bool = False") + .Output("output_indices: int64") + .Output("output_values: T") + .Output("output_shape: int64") + .Attr("T: realnumbertype") + .SetShapeFn(shape_inference::UnknownShape) + .Doc(R"doc( +Computes the max of elements across dimensions of a SparseTensor. + +This Op takes a SparseTensor and is the sparse counterpart to +`tf.reduce_max()`. In contrast to SparseReduceMax, this Op returns a +SparseTensor. + +Reduces `sp_input` along the dimensions given in `reduction_axes`. Unless +`keep_dims` is true, the rank of the tensor is reduced by 1 for each entry in +`reduction_axes`. If `keep_dims` is true, the reduced dimensions are retained +with length 1. + +If `reduction_axes` has no entries, all dimensions are reduced, and a tensor +with a single element is returned. Additionally, the axes can be negative, +which are interpreted according to the indexing rules in Python. + +input_indices: 2-D. `N x R` matrix with the indices of non-empty values in a + SparseTensor, possibly not in canonical ordering. +input_values: 1-D. `N` non-empty values corresponding to `input_indices`. +input_shape: 1-D. Shape of the input SparseTensor. +reduction_axes: 1-D. Length-`K` vector containing the reduction axes. +keep_dims: If true, retain reduced dimensions with length 1. +)doc"); + REGISTER_OP("SparseReduceSum") .Input("input_indices: int64") .Input("input_values: T") |