# tf.math.scalar_mul

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 1 version](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/math/scalar_mul) | [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/ops/math_ops.py#L427-L431) |

Multiplies a scalar times a `Tensor` or `IndexedSlices` object.

#### View aliases


**Main aliases**

[`tf.scalar_mul`](https://www.tensorflow.org/api_docs/python/tf/math/scalar_mul)

<br />

    tf.math.scalar_mul(
        scalar, x, name=None
    )

Intended for use in gradient code which might deal with `IndexedSlices`
objects, which are easy to multiply by a scalar but more expensive to
multiply with arbitrary tensors.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `scalar` | A 0-D scalar `Tensor`. Must have known shape. |
| `x` | A `Tensor` or `IndexedSlices` to be scaled. |
| `name` | A name for the operation (optional). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| `scalar * x` of the same type (`Tensor` or `IndexedSlices`) as `x`. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | if scalar is not a 0-D `scalar`. |

<br />