This document is relevant for: Inf2
, Trn1
, Trn2
nki.isa.scalar_tensor_tensor#
- nki.isa.scalar_tensor_tensor(*, data, op0, operand0, op1, operand1, reverse0=False, reverse1=False, dtype=None, mask=None, **kwargs)[source]#
Apply up to two math operators using Vector Engine:
(data <op0> operand0) <op1> operand1
.data
input can be an SBUF or PSUM tile of 2D shape.operand0
can be SBUF or PSUM tile of shape(data.shape[0], 1)
, i.e., vector, or a compile-time constant scalar.operand1
can be SBUF or PSUM tile of shape(data.shape[0], data.shape[1])
(i.e., has to matchdata
shape), note thatoperand1
anddata
can’t both be on PSUM.Estimated instruction cost:
Cost (Vector Engine Cycles)
Condition
N
data
andoperand1
are bothbfloat16
,op0=nl.subtract
andop1=nl.multiply
, andN
is even2*N
otherwise
where,
N
is the number of elements per partition indata
.
- Parameters:
data – the input tile
op0 – the first math operator used with operand0 (see Supported Math Operators for NKI ISA for supported operators)
operand0 – a scalar constant or a tile of shape
(data.shape[0], 1)
, where data.shape[0] is the partition axis size of the inputdata
tile.reverse0 – reverse ordering of inputs to
op0
; if false,operand0
is the rhs ofop0
; if true,operand0
is the lhs ofop0
.op1 – the second math operator used with operand1 (see Supported Math Operators for NKI ISA for supported operators).
operand1 – a tile of shape with the same partition and free dimension as
data
input.reverse1 – reverse ordering of inputs to
op1
; if false,operand1
is the rhs ofop1
; if true,operand1
is the lhs ofop1
.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.
mask – (optional) a compile-time constant predicate that controls whether/how this instruction is executed (see NKI API Masking for details)
- Returns:
an output tile of
(data <op0> operand0) <op1> operand1
computation
This document is relevant for: Inf2
, Trn1
, Trn2