This document is relevant for: Trn1, Trn2, Trn3

nki.language.power#

nki.language.power(x, y, dtype=None)[source]#

Elements of x raised to powers of y, element-wise.

((Similar to numpy.power))

Warning

This API is experimental and may change in future releases.

Parameters:
  • x – a tile or a scalar value.

  • y – a tile or a scalar value.

  • 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 tiles, or whichever input type has the highest precision (see NKI Type Promotion for more information);

Returns:

a tile that has values x to the power of y.

Examples:

import nki.language as nl

# nki.language.power -- element-wise exponentiation of two tiles
a = nl.full((128, 512), 3.0, dtype=nl.float32, buffer=nl.sbuf)
b = nl.full((128, 512), 2.0, dtype=nl.float32, buffer=nl.sbuf)
c = nl.power(a, b)
expected = nl.full((128, 512), 9.0, dtype=nl.float32, buffer=nl.sbuf)
assert nl.equal(c, expected)

This document is relevant for: Trn1, Trn2, Trn3