# tf.convert_to_tensor_or_indexed_slices

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/framework/indexed_slices.py#L249-L271) |

Converts the given object to a `Tensor` or an `IndexedSlices`.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.convert_to_tensor_or_indexed_slices`](https://www.tensorflow.org/api_docs/python/tf/compat/v1/convert_to_tensor_or_indexed_slices)

<br />

    tf.convert_to_tensor_or_indexed_slices(
        value, dtype=None, name=None
    )

If `value` is an `IndexedSlices` or `SparseTensor` it is returned
unmodified. Otherwise, it is converted to a `Tensor` using
`convert_to_tensor()`.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `value` | An `IndexedSlices`, `SparseTensor`, or an object that can be consumed by `convert_to_tensor()`. |
| `dtype` | (Optional.) The required `DType` of the returned `Tensor` or `IndexedSlices`. |
| `name` | (Optional.) A name to use if a new `Tensor` is created. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `Tensor`, `IndexedSlices`, or `SparseTensor` based on `value`. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If `dtype` does not match the element type of `value`. |

<br />