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.datainput can be an SBUF or PSUM tile of 2D shape.operand0can be SBUF or PSUM tile of shape(data.shape[0], 1), i.e., vector, or a compile-time constant scalar.operand1can be SBUF or PSUM tile of shape(data.shape[0], data.shape[1])(i.e., has to matchdatashape), note thatoperand1anddatacan’t both be on PSUM.Estimated instruction cost:
Cost (Vector Engine Cycles)
Condition
Ndataandoperand1are bothbfloat16,op0=nl.subtractandop1=nl.multiply, andNis even2*Notherwise
where,
Nis 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 inputdatatile.reverse0 – reverse ordering of inputs to
op0; if false,operand0is the rhs ofop0; if true,operand0is 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
datainput.reverse1 – reverse ordering of inputs to
op1; if false,operand1is the rhs ofop1; if true,operand1is 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> operand1computation
This document is relevant for: Inf2, Trn1, Trn2