This document is relevant for: Trn1, Trn2, Trn3
nki.language.rsqrt#
- nki.language.rsqrt(x, dtype=None)[source]#
Reciprocal of the square-root of the input, element-wise.
((Similar to torch.rsqrt))
Warning
This API is experimental and may change in future releases.
rsqrt(x) = 1 / sqrt(x)- Parameters:
x – a tile.
dtype – (optional) data type to cast the output type to (see Supported Data Types for more information); if not specified, it will default to be the same as the data type of the input tile.
- Returns:
a tile that has reciprocal square-root values of
x.
Examples:
import nki.language as nl # nki.language.rsqrt -- rsqrt(4.0) = 0.5 a = nl.full((128, 512), 4.0, dtype=nl.float32, buffer=nl.sbuf) b = nl.rsqrt(a) expected = nl.full((128, 512), 0.5, dtype=nl.float32, buffer=nl.sbuf) assert nl.equal(b, expected)
This document is relevant for: Trn1, Trn2, Trn3