# tensorflow::ops::SparseReduceSum Class Reference

# tensorflow::
ops::
SparseReduceSum

`
#include <sparse_ops.h>
`


Computes the sum of elements across dimensions of a SparseTensor.

## Summary


This Op takes a SparseTensor and is the sparse counterpart to
`
tf.reduce_sum()
`
. In particular, this Op also returns a dense
`
https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_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.


Args:

- scope: A [Scope](https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object
- 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.

<br />


Optional attributes (see
`
https://www.tensorflow.org/versions/r2.5/api_docs/cc/struct/tensorflow/ops/sparse-reduce-sum/attrs#structtensorflow_1_1ops_1_1_sparse_reduce_sum_1_1_attrs
`
):

- keep_dims: If true, retain reduced dimensions with length 1.

<br />


Returns:

- `
  https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output
  ` : `
  R-K
  ` -D. The reduced [Tensor](https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) .

<br />

| ### Constructors and Destructors ||
|---|---|
| ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/sparse-reduce-sum#classtensorflow_1_1ops_1_1_sparse_reduce_sum_1a31f677c3b19d0710fb02fab6474e8f18 (const :: https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope & scope, :: https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input input_indices, :: https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input input_values, :: https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input input_shape, :: https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input reduction_axes) ` ||
| ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/sparse-reduce-sum#classtensorflow_1_1ops_1_1_sparse_reduce_sum_1a8d3151db2dd2eaf6a347aed70d3bb7ec (const :: https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope & scope, :: https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input input_indices, :: https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input input_values, :: https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input input_shape, :: https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input reduction_axes, const https://www.tensorflow.org/versions/r2.5/api_docs/cc/struct/tensorflow/ops/sparse-reduce-sum/attrs#structtensorflow_1_1ops_1_1_sparse_reduce_sum_1_1_attrs & attrs) ` ||

| ### Public attributes ||
|---|---|
| ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/sparse-reduce-sum#classtensorflow_1_1ops_1_1_sparse_reduce_sum_1a4d9aa91a20be8c1e507dbbaf92bc5fee ` | ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation ` |
| ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/sparse-reduce-sum#classtensorflow_1_1ops_1_1_sparse_reduce_sum_1a7e00bc9e8f78ba705bbdcb0c00ccafb4 ` | ` :: https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output ` |

| ### Public functions ||
|---|---|
| ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/sparse-reduce-sum#classtensorflow_1_1ops_1_1_sparse_reduce_sum_1a61bca8cf985cd2ede755ad70f8a24159 () const ` | ` ::tensorflow::Node * ` |
| ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/sparse-reduce-sum#classtensorflow_1_1ops_1_1_sparse_reduce_sum_1a07a158d5f8094c296f78a42957ca9618 () const ` | ` ` |
| ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/sparse-reduce-sum#classtensorflow_1_1ops_1_1_sparse_reduce_sum_1a49009e1c5d20e23d3069807f419177ac () const ` | ` ` |

| ### Public static functions ||
|---|---|
| ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/sparse-reduce-sum#classtensorflow_1_1ops_1_1_sparse_reduce_sum_1a673e06d6ba6fee5fe24fa8044a62ca1c (bool x) ` | ` https://www.tensorflow.org/versions/r2.5/api_docs/cc/struct/tensorflow/ops/sparse-reduce-sum/attrs#structtensorflow_1_1ops_1_1_sparse_reduce_sum_1_1_attrs ` |

| ### Structs ||
|---|---|
| [tensorflow:: ops:: SparseReduceSum:: Attrs](https://www.tensorflow.org/versions/r2.5/api_docs/cc/struct/tensorflow/ops/sparse-reduce-sum/attrs) | Optional attribute setters for [SparseReduceSum](https://www.tensorflow.org/versions/r2.5/api_docs/cc/class/tensorflow/ops/sparse-reduce-sum#classtensorflow_1_1ops_1_1_sparse_reduce_sum) . |

## Public attributes

### operation

```
Operation operation
```

### output

```
::tensorflow::Output output
```

## Public functions

### SparseReduceSum

```
 SparseReduceSum(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input_indices,
  ::tensorflow::Input input_values,
  ::tensorflow::Input input_shape,
  ::tensorflow::Input reduction_axes
)
```

### SparseReduceSum

```
 SparseReduceSum(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input_indices,
  ::tensorflow::Input input_values,
  ::tensorflow::Input input_shape,
  ::tensorflow::Input reduction_axes,
  const SparseReduceSum::Attrs & attrs
)
```

### node

```
::tensorflow::Node * node() const 
```

### operator::tensorflow::Input

```
 operator::tensorflow::Input() const 
```

### operator::tensorflow::Output

```
 operator::tensorflow::Output() const 
```

## Public static functions

### KeepDims

```
Attrs KeepDims(
  bool x
)
```