# tensorflow::ops::SparseAdd Class Reference

# tensorflow::ops::SparseAdd

`#include <sparse_ops.h>`

Adds two `SparseTensor` objects to produce another `SparseTensor`.

## Summary

The input `SparseTensor` objects' indices are assumed ordered in standard lexicographic order. If this is not the case, before this step run `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/sparse-reorder#classtensorflow_1_1ops_1_1_sparse_reorder` to restore index ordering.

By default, if two values sum to zero at some index, the output `SparseTensor` would still include that particular location in its index, storing a zero in the corresponding value slot. To override this, callers can specify `thresh`, indicating that if the sum has a magnitude strictly smaller than `thresh`, its corresponding value and index would then not be included. In particular, `thresh == 0` (default) means everything is kept and actual thresholding happens only for a positive value.

In the following shapes, `nnz` is the count after taking `thresh` into account.

Arguments:

- scope: A [Scope](https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object
- a_indices: 2-D. The `indices` of the first `SparseTensor`, size `[nnz, ndims]` Matrix.
- a_values: 1-D. The `values` of the first `SparseTensor`, size `[nnz]` Vector.
- a_shape: 1-D. The `shape` of the first `SparseTensor`, size `[ndims]` Vector.
- b_indices: 2-D. The `indices` of the second `SparseTensor`, size `[nnz, ndims]` Matrix.
- b_values: 1-D. The `values` of the second `SparseTensor`, size `[nnz]` Vector.
- b_shape: 1-D. The `shape` of the second `SparseTensor`, size `[ndims]` Vector.
- thresh: 0-D. The magnitude threshold that determines if an output value/index pair takes space.

<br />

Returns:

- `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output` sum_indices
- `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output` sum_values
- `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output` sum_shape

<br />

| ### Constructors and Destructors ||
|---|---|
| `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/sparse-add#classtensorflow_1_1ops_1_1_sparse_add_1a07c65af8c10333ec7605e9a7f0a1be2b(const ::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope & scope, ::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input a_indices, ::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input a_values, ::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input a_shape, ::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input b_indices, ::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input b_values, ::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input b_shape, ::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input thresh)` ||

| ### Public attributes ||
|---|---|
| `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/sparse-add#classtensorflow_1_1ops_1_1_sparse_add_1aab871539035af62dcf3df695fc396ba0` | `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation` |
| `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/sparse-add#classtensorflow_1_1ops_1_1_sparse_add_1a935595157260ea9fcff05da3c0341947` | `::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output` |
| `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/sparse-add#classtensorflow_1_1ops_1_1_sparse_add_1a573a3dbb573b8d6fb0172ca669d4685f` | `::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output` |
| `https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/sparse-add#classtensorflow_1_1ops_1_1_sparse_add_1a2cc06856b4695dd0ba3ea4f686160ddf` | `::https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output` |

## Public attributes

### operation

```
Operation operation
```

### sum_indices

```
::tensorflow::Output sum_indices
```

### sum_shape

```
::tensorflow::Output sum_shape
```

### sum_values

```
::tensorflow::Output sum_values
```

## Public functions

### SparseAdd

```
 SparseAdd(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input a_indices,
  ::tensorflow::Input a_values,
  ::tensorflow::Input a_shape,
  ::tensorflow::Input b_indices,
  ::tensorflow::Input b_values,
  ::tensorflow::Input b_shape,
  ::tensorflow::Input thresh
)
```