<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.21.0/tensorflow/python/ops/check_ops.py#L2184-L2217) |

Asserts that the given `tensor` is a scalar (i.e. zero-dimensional).

#### View aliases


**Compat aliases for migration**

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

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

<br />

    tf.compat.v1.assert_scalar(
        tensor, name=None, message=None
    )

This function raises `ValueError` unless it can be certain that the given
`tensor` is a scalar. `ValueError` is also raised if the shape of `tensor` is
unknown.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `tensor` | A `Tensor`. |
| `name` | A name for this operation. Defaults to "assert_scalar" |
| `message` | A string to prefix to the default message. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| The input tensor (potentially converted to a `Tensor`). ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If the tensor is not scalar (rank 0), or if its shape is unknown. |

<br />