APIs

Device

ttnn.open_device

Open a device with the given device_id.

ttnn.close_device

Close the device and remove it from the device cache.

ttnn.manage_device

Context manager for opening and closing a device.

ttnn.synchronize_device

Overloaded function.

ttnn.SetDefaultDevice

Sets the default device to use for operations when inputs are not on the device.

ttnn.GetDefaultDevice

Gets the default device to use for ops when inputs aren't on device.

ttnn.format_input_tensor

Formats tensor to target layout and pads to padded shape.

ttnn.format_output_tensor

Formats tensor to target layout and unpads to shape.

ttnn.pad_to_tile_shape

Pads the given shape to tile shape based on specified padding options.

Memory Config

ttnn.create_sharded_memory_config

Creates a MemoryConfig object with a sharding spec, required for sharded ops.

Operations

Core

ttnn.as_tensor

Converts the torch.Tensor tensor into a ttnn.Tensor.

ttnn.from_torch

Converts the torch.Tensor tensor into a ttnn.Tensor.

ttnn.to_torch

Converts the ttnn.Tensor tensor into a torch.Tensor.

ttnn.to_device

Overloaded function.

ttnn.from_device

Copy tensor from device to host.

ttnn.to_layout

Organizes the ttnn.Tensor tensor into either ttnn.ROW_MAJOR_LAYOUT or ttnn.TILE_LAYOUT.

ttnn.dump_tensor

Dump tensor to a file.

ttnn.load_tensor

Load tensor from a file.

ttnn.deallocate

Deallocates device tensor.

ttnn.reallocate

Deallocates device tensor and returns a reallocated tensor.

ttnn.to_memory_config

Converts a tensor to the desired memory configuration.

Tensor Creation

ttnn.arange

Creates a tensor with values ranging from start (inclusive) to end (exclusive) with a specified step size.

ttnn.empty

Creates a device tensor with uninitialized values of the specified shape, data type, layout, and memory configuration.

ttnn.empty_like

Creates a new tensor with the same shape as the given reference, but without initializing its values.

ttnn.zeros

Creates a tensor with the specified shape and fills it with the value of 0.0.

ttnn.zeros_like

Creates a tensor of the same shape as the input tensor and fills it with the value of 0.0.

ttnn.ones

Creates a tensor with the specified shape and fills it with the value of 1.0.

ttnn.ones_like

Creates a tensor of the same shape as the input tensor and fills it with the value of 1.0.

ttnn.full

Creates a tensor of the specified shape and fills it with the specified scalar value.

ttnn.full_like

Creates a tensor of the same shape as the input tensor and fills it with the specified scalar value.

Matrix Multiplication

ttnn.matmul

Returns the matrix product of two tensors.

ttnn.linear

Returns the linear transformation of the inputs.

Pointwise Unary

ttnn.abs

Applies abs to input_tensor element-wise.

ttnn.acos

Applies acos to input_tensor element-wise.

ttnn.acosh

Performs acosh function on input_tensor.

ttnn.asin

Applies asin to input_tensor element-wise.

ttnn.asinh

Performs asinh function on input_tensor.

ttnn.atan

Applies atan to input_tensor element-wise.

ttnn.atanh

Performs atanh function on input_tensor.

ttnn.bitwise_not

Applies bitwise_not to input_tensor element-wise.

ttnn.bitwise_left_shift

Perform bitwise_left_shift operation on input_tensor_a by input_tensor_b and returns the tensor with the same layout as input_tensor_a.

ttnn.bitwise_right_shift

Perform bitwise_right_shift operation on input_tensor_a by input_tensor_b and returns the tensor with the same layout as input_tensor_a.

ttnn.cbrt

Performs cbrt function on input_tensor.

ttnn.ceil

Applies ceil to input_tensor element-wise.

ttnn.celu

Performs celu function on input_tensor, alpha.

ttnn.clamp

Performs clamp function on input_tensor, min, max.

ttnn.clip

Performs clip function on input_tensor, min, max.

ttnn.clone

Clones the input, creating a copy with the specified memory_config and converting its data type to dtype.

ttnn.cos

Applies cos to input_tensor element-wise.

ttnn.cosh

Performs cosh function on input_tensor.

ttnn.deg2rad

Performs deg2rad function on input_tensor.

ttnn.digamma

Performs digamma function on input_tensor.

ttnn.experimental.dropout

Applies dropout to input_tensor element-wise.

ttnn.experimental.gelu_bw

Applies the backward pass of the GELU function using ttnn experimental kernels.

ttnn.elu

Applies elu to input_tensor element-wise with alpha.

ttnn.eqz

Applies eqz to input_tensor element-wise.

ttnn.erf

Applies erf to input_tensor element-wise.

ttnn.erfc

Applies erfc to input_tensor element-wise.

ttnn.erfinv

Applies erfinv to input_tensor element-wise.

ttnn.exp

Applies exp to input_tensor element-wise.

ttnn.exp2

Applies exp2 to input_tensor element-wise.

ttnn.expm1

Applies expm1 to input_tensor element-wise.

ttnn.fill

Applies fill to input_tensor element-wise with fill_value.

ttnn.floor

Applies floor to input_tensor element-wise.

ttnn.frac

Performs frac function on input_tensor.

ttnn.geglu

Applies geglu to input_tensor element-wise.

ttnn.gelu

Applies gelu to input_tensor element-wise.

ttnn.glu

Applies glu to input_tensor element-wise.

ttnn.gez

Applies gez to input_tensor element-wise.

ttnn.gtz

Applies gtz to input_tensor element-wise.

ttnn.hardshrink

Performs hardshrink function on input_tensor, lambd.

ttnn.hardsigmoid

Performs hardsigmoid function on input_tensor, scale, shift.

ttnn.hardswish

Performs hardswish function on input_tensor, scale, shift.

ttnn.hardtanh

Performs hardtanh function on input_tensor, min_val, max_val.

ttnn.heaviside

Applies heaviside to input_tensor element-wise with value.

ttnn.i0

Applies i0 to input_tensor element-wise.

ttnn.identity

Returns a copy of the input_tensor; useful for profiling the SFPU.

ttnn.isfinite

Applies isfinite to input_tensor element-wise.

ttnn.isinf

Applies isinf to input_tensor element-wise.

ttnn.isnan

Applies isnan to input_tensor element-wise.

ttnn.isneginf

Applies isneginf to input_tensor element-wise.

ttnn.isposinf

Applies isposinf to input_tensor element-wise.

ttnn.leaky_relu

Applies leaky_relu to input_tensor element-wise with negative_slope.

ttnn.lez

Applies lez to input_tensor element-wise.

ttnn.lgamma

Performs lgamma function on input_tensor.

ttnn.log

Applies log to input_tensor element-wise.

ttnn.log10

Applies log10 to input_tensor element-wise.

ttnn.log1p

Performs log1p function on input_tensor.

ttnn.log2

Applies log2 to input_tensor element-wise.

ttnn.log_sigmoid

Applies log_sigmoid to input_tensor element-wise.

ttnn.logical_not

Applies logical_not to input_tensor element-wise.

ttnn.logical_not_

Performs logical_not inplace function on input_tensor.

ttnn.logit

Performs logit function on input_tensor, eps.

ttnn.ltz

Applies ltz to input_tensor element-wise.

ttnn.mish

Performs mish function on input_tensor.

ttnn.multigammaln

Performs multigammaln function on input_tensor.

ttnn.neg

Applies neg to input_tensor element-wise.

ttnn.nez

Applies nez to input_tensor element-wise.

ttnn.normalize_global

Performs normalize_global function on input_tensor.

ttnn.normalize_hw

Performs normalize_hw function on input_tensor.

ttnn.polygamma

Performs polygamma function on input_tensor, decimals.

ttnn.prelu

Perform an eltwise-prelu operation.

ttnn.rad2deg

Performs rad2deg function on input_tensor.

ttnn.rdiv

Performs the element-wise division of a scalar value by a tensor input and rounds the result using round_mode.

ttnn.reciprocal

Applies reciprocal to input_tensor element-wise.

ttnn.reglu

Applies reglu to input_tensor element-wise.

ttnn.relu

Applies relu to input_tensor element-wise.

ttnn.relu_max

Applies relu_max to input_tensor element-wise with upper_limit.

ttnn.relu_min

Applies relu_min to input_tensor element-wise with lower_limit.

ttnn.relu6

Applies relu6 to input_tensor element-wise.

ttnn.remainder

Performs an eltwise-modulus operation.

ttnn.round

Applies round to input_tensor element-wise with decimals.

ttnn.rsqrt

Applies rsqrt to input_tensor element-wise.

ttnn.selu

Performs selu function on input_tensor, scale, alpha.

ttnn.sigmoid

Applies sigmoid to input_tensor element-wise.

ttnn.sigmoid_accurate

Applies sigmoid_accurate to input_tensor element-wise.

ttnn.sign

Applies sign to input_tensor element-wise.

ttnn.signbit

Applies signbit to input_tensor element-wise.

ttnn.silu

Applies silu to input_tensor element-wise.

ttnn.sin

Applies sin to input_tensor element-wise.

ttnn.sinh

Performs sinh function on input_tensor.

ttnn.softmax

Compute softmax over input_tensor along dim.

ttnn.softplus

Applies softplus to input_tensor element-wise.

ttnn.softshrink

Performs softshrink function on input_tensor, lambd.

ttnn.softsign

Performs softsign function on input_tensor.

ttnn.sqrt

Applies sqrt to input_tensor element-wise.

ttnn.square

Applies square to input_tensor element-wise.

ttnn.swiglu

Applies swiglu to input_tensor element-wise.

ttnn.swish

Performs swish function on input_tensor.

ttnn.tan

Applies tan to input_tensor element-wise.

ttnn.tanh

Applies tanh to input_tensor element-wise.

ttnn.tanhshrink

Performs tanhshrink function on input_tensor.

ttnn.threshold

Performs threshold function on input_tensor, threshold, value.

ttnn.tril

Performs tril function on input_tensor, diagonal.

ttnn.triu

Performs triu function on input_tensor, diagonal.

ttnn.trunc

Applies trunc to input_tensor element-wise.

ttnn.unary_chain

Applies unary_chain to input_tensor element-wise.

ttnn.clamp_bw

Performs backward operations for clamp on input_tensor, min, max with given grad_tensor.

ttnn.clip_bw

Performs backward operations for clip on input_tensor, min, max with given grad_tensor.

ttnn.hardtanh_bw

Performs backward operations for hardtanh activation function on input_tensor, min, max with given grad_tensor.

ttnn.threshold_bw

Performs backward operations for threshold on input_tensor, threshold, value with given grad_tensor.

ttnn.softplus_bw

Performs backward operations for softplus on input_tensor, beta, threshold with given grad_tensor.

ttnn.rdiv_bw

Performs backward operations for Unary rdiv on input_tensor, scalar with given grad_tensor using given round_mode.

ttnn.pow_bw

Performs backward operations for power on input_tensor, exponent with given grad_tensor.

ttnn.exp_bw

Performs backward operations for exponential function on input_tensor with given grad_tensor.

ttnn.tanh_bw

Performs backward operations for hyperbolic tangent (tanh) function on input_tensor with given grad_tensor.

ttnn.sqrt_bw

Performs backward operations for square-root on input_tensor with given grad_tensor.

ttnn.multigammaln_bw

Performs backward operations for multivariate logarithmic gamma function (also referred to as mvlgamma) on input_tensor with given grad_tensor.

ttnn.lgamma_bw

Performs backward operations for lgamma on input_tensor with given grad_tensor.

ttnn.fill_bw

Performs backward operations for fill on input_tensor with given grad_tensor.

ttnn.hardsigmoid_bw

Performs backward operations for hardsigmoid on input_tensor with given grad_tensor.

ttnn.cos_bw

Performs backward operations for cosine on input_tensor with given grad_tensor.

ttnn.acosh_bw

Performs backward operations for inverse hyperbolic cosine (acosh) on input_tensor with given grad_tensor.

ttnn.acos_bw

Performs backward operations for inverse cosine (acos) on input_tensor with given grad_tensor.

ttnn.atan_bw

Performs backward operations for inverse tangenr (atan) on input_tensor with given grad_tensor.

ttnn.rad2deg_bw

Performs backward operations for radian to degree conversion (rad2deg) on input_tensor with given grad_tensor.

ttnn.frac_bw

Performs backward operations for frac on input_tensor with given grad_tensor.

ttnn.trunc_bw

Performs backward operations for truncation on input_tensor with given grad_tensor.

ttnn.log_sigmoid_bw

Performs backward operations for log sigmoid on input_tensor with given grad_tensor.

ttnn.fill_zero_bw

Performs backward operations for fill zero on input_tensor with given grad_tensor.

ttnn.i0_bw

Performs backward operations for i0 on input_tensor with given grad_tensor.

ttnn.tan_bw

Performs backward operations for tan on input_tensor with given grad_tensor.

ttnn.sigmoid_bw

Performs backward operations for sigmoid on input_tensor with given grad_tensor.

ttnn.rsqrt_bw

Performs backward operations for reciprocal of square-root on input_tensor with given grad_tensor.

ttnn.neg_bw

Performs backward operations for neg on input_tensor with given grad_tensor.

ttnn.relu_bw

Performs backward operations for relu on input_tensor with given grad_tensor.

ttnn.logit_bw

Performs backward operations for logit on input_tensor with given grad_tensor.

ttnn.hardshrink_bw

Performs backward operations for hardshrink on input_tensor, lambd, with given grad_tensor.

ttnn.softshrink_bw

Performs backward operations for softshrink on input_tensor, lambd, with given grad_tensor.

ttnn.leaky_relu_bw

Performs backward operations for leaky_relu on input_tensor, negative_slope, with given grad_tensor.

ttnn.elu_bw

Performs backward operations for elu on input_tensor, alpha, with given grad_tensor.

ttnn.celu_bw

Performs backward operations for celu on input_tensor, alpha, with given grad_tensor.

ttnn.rpow_bw

Performs backward operations for rpow on input_tensor, exponent with given grad_tensor.

ttnn.floor_bw

Performs backward operations for floor on input_tensor with given grad_tensor

ttnn.round_bw

Performs backward operations for round on input_tensor with given grad_tensor.

ttnn.log_bw

Performs backward operations for logarithm on input_tensor with given grad_tensor

ttnn.relu6_bw

Performs backward operations for relu6 on input_tensor with given grad_tensor

ttnn.abs_bw

Performs backward operations for abs on input_tensor with given grad_tensor

ttnn.silu_bw

Performs backward operations for silu on input_tensor with given grad_tensor

ttnn.selu_bw

Performs backward operations for selu on input_tensor with given grad_tensor

ttnn.square_bw

Performs backward operations for square on input_tensor with given grad_tensor

ttnn.prod_bw

Performs backward operations for prod on input_tensor with given grad_tensor along all_dimensions or a particular dim.

ttnn.hardswish_bw

Performs backward operations for hardswish on input_tensor with given grad_tensor

ttnn.tanhshrink_bw

Performs backward operations for tanhshrink on input_tensor with given grad_tensor

ttnn.atanh_bw

Performs backward operations for inverse hyperbolic tangent (atanh) on input_tensor with given grad_tensor

ttnn.asin_bw

Performs backward operations for inverse sine (asin) on input_tensor with given grad_tensor

ttnn.asinh_bw

Performs backward operations for inverse hyperbolic sine (asinh) on input_tensor with given grad_tensor

ttnn.sin_bw

Performs backward operations for sin on input_tensor with given grad_tensor

ttnn.sinh_bw

Performs backward operations for hyperbolic sine (sinh) on input_tensor with given grad_tensor

ttnn.log10_bw

Performs backward operations for log10 on input_tensor with given grad_tensor

ttnn.log1p_bw

Performs backward operations for log1p on input_tensor with given grad_tensor

ttnn.erfc_bw

Performs backward operations for erfc on input_tensor with given grad_tensor

ttnn.ceil_bw

Performs backward operations for ceil on input_tensor with given grad_tensor

ttnn.softsign_bw

Performs backward operations for softsign on input_tensor with given grad_tensor

ttnn.cosh_bw

Performs backward operations for hyperbolic cosine (cosh) on input_tensor with given grad_tensor.

ttnn.logiteps_bw

Performs backward operations for logiteps on input_tensor, eps, with given grad_tensor.

ttnn.log2_bw

Performs backward operations for log2 on input_tensor with given grad_tensor.

ttnn.sign_bw

Performs backward operations for sign on input_tensor with given grad_tensor.

ttnn.div_no_nan_bw

Performs backward operations for div_no_nan on input_tensor, scalar with given grad_tensor.

ttnn.exp2_bw

Performs backward operations for exp2 on input_tensor with given grad_tensor

ttnn.expm1_bw

Performs backward operations for expm1 on input_tensor with given grad_tensor

ttnn.reciprocal_bw

Performs backward operations for reciprocal on input_tensor with given grad_tensor

ttnn.digamma_bw

Performs backward operations for digamma on input_tensor with given grad_tensor

ttnn.erfinv_bw

Performs backward operations for erfinv on input_tensor with given grad_tensor

ttnn.erf_bw

Performs backward operations for erf on input_tensor with given grad_tensor

ttnn.deg2rad_bw

Performs backward operations for degree to radian conversion (deg2rad) on input_tensor with given grad_tensor

ttnn.polygamma_bw

Performs backward operations for polygamma on input_tensor, scalar with given grad_tensor.

ttnn.gelu_bw

Performs backward operations for gelu on input_tensor, with given grad_tensor using given approximate mode.

ttnn.repeat_bw

Performs backward operations for repeat on input_tensor, with given grad_tensor using given shape.

ttnn.real

Performs complex operations for real of input_tensor.

ttnn.imag

Performs complex operations for imag of input_tensor.

ttnn.angle

Performs complex operations for angle of input_tensor.

ttnn.is_imag

Returns boolean tensor if value of input_tensor is imag.

ttnn.is_real

Returns boolean tensor if value of input_tensor is real.

ttnn.polar_bw

Performs backward operations for complex polar function on input_tensor with given grad_tensor.

ttnn.imag_bw

Performs backward operations for complex imaginary function on input_tensor with given grad_tensor.

ttnn.real_bw

Performs backward operations for complex real function on input_tensor with given grad_tensor.

ttnn.angle_bw

Performs backward operations for complex angle function on input_tensor with given grad_tensor.

ttnn.conj_bw

Performs backward operations for complex conj function on input_tensor with given grad_tensor.

ttnn.conj

Returns complex conjugate value of complex tensor input_tensor.

ttnn.polar

Perform an polar to Cartesian transformation on input_tensor, input_tensor.real(r), input_tensor.imag(theta) into x + i*y generating a complex tensor.

Pointwise Binary

ttnn.add

Adds input_tensor_a to input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.addalpha

Computes addalpha for input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a.

ttnn.subalpha

Computes subalpha for input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.multiply

Multiplies input_tensor_a by input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.subtract

Subtracts input_tensor_b from input_tensor_a and returns the tensor with the same layout as input_tensor_a

ttnn.div

Computes div for input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.div_no_nan

Computes div_no_nan for input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.floor_div

Computes floor division for input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.remainder

Performs an eltwise-modulus operation.

ttnn.fmod

Performs an eltwise-fmod operation.

ttnn.gcd

Computes Greatest common divisor of input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a.

ttnn.lcm

Computes Least common multiple of input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a.

ttnn.logical_and_

Computes inplace logical AND of input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.logical_or_

Computes inplace logical OR of input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.logical_xor_

Computes inplace logical XOR of input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.rpow

Performs rpow function on input_tensor, exponent.

ttnn.rsub

Subtracts input_tensor_a from input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.ldexp

Computes ldexp of input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.logical_and

Computes logical AND of input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.logical_or

Computes logical OR of input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.logical_xor

Compute logical_xor input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.bitwise_and

Perform bitwise_and operation on input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.bitwise_or

Perform bitwise_or operation on input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.bitwise_xor

Perform bitwise_xor operation on input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.logaddexp

Computes logaddexp of input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.logaddexp2

Computes logaddexp2 of input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.hypot

Computes hypot input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.xlogy

Computes xlogy input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.squared_difference

Computes squared difference of input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.gt

Compares if input_tensor_a is greater than input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.gt_

Performs Greater than in-place operation on input_a and input_b and returns the tensor with the same layout as input_tensor

ttnn.lt_

Performs Less than in-place operation on input_a and input_b and returns the tensor with the same layout as input_tensor

ttnn.ge_

Performs Greater than or equal to in-place operation on input_a and input_b and returns the tensor with the same layout as input_tensor

ttnn.le_

Performs Less than or equal to in-place operation on input_a and input_b and returns the tensor with the same layout as input_tensor

ttnn.eq_

Performs Equal to in-place operation on input_a and input_b and returns the tensor with the same layout as input_tensor

ttnn.ne_

Performs Not equal to in-place operation on input_a and input_b and returns the tensor with the same layout as input_tensor

ttnn.ge

Compares if input_tensor_a is greater than or equal to input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.lt

Compares if input_tensor_a is less than input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.le

Compares if input_tensor_a is less than or equal to input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.eq

Compares if input_tensor_a is equal to input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.ne

Compares if input_tensor_a is not equal to input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.isclose

Computes isclose for input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.nextafter

Computes nextafter input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.maximum

Computes maximum for input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.minimum

Computes minimum for input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.outer

Computes outer for input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.pow

Perform element-wise pow operation on input_tensor with exponent.

ttnn.polyval

Computes polyval of all elements of input_tensor_a with coefficients coeffs and returns the tensor with the same layout as input_tensor_a

ttnn.scatter

Computes scatter for input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.atan2

Computes atan2 input_tensor_a and input_tensor_b and returns the tensor with the same layout as input_tensor_a

ttnn.add_bw

Performs backward operations for add of input_tensor_a and input_tensor_b or scalar with given grad_tensor.

ttnn.assign_bw

Performs backward operations for assign of input_tensor_a, input_tensor_b with given grad_tensor.

ttnn.atan2_bw

Performs backward operations for atan2 of input_tensor_a and input_tensor_b with given grad_tensor.

ttnn.bias_gelu_bw

Performs backward operations for bias_gelu on input_tensor_a and input_tensor_b or input_tensor and bias, with given grad_tensor using given approximate mode.

ttnn.div_bw

Performs backward operations for divide on input_tensor, alpha or input_tensor_a, input_tensor_b, round_mode, with given grad_tensor.

ttnn.embedding_bw

Returns the input gradients of the output gradients tensor with respect to the input indices.

ttnn.fmod_bw

Performs backward operations for fmod of input_tensor_a, scalar or input_tensor_b with given grad_tensor.

ttnn.remainder_bw

Performs backward operations for remainder of input_tensor_a, scalar or input_tensor_b with given grad_tensor.

ttnn.addalpha_bw

Performs backward operations for addalpha on input_tensor_b , input_tensor_a and alpha with given grad_tensor.

ttnn.subalpha_bw

Performs backward operations for subalpha of input_tensor_a and input_tensor_b with given grad_tensor.

ttnn.xlogy_bw

Performs backward operations for xlogy of input_tensor_a and input_tensor_b with given grad_tensor.

ttnn.hypot_bw

Performs backward operations for hypot of input_tensor_a and input_tensor_b with given grad_tensor.

ttnn.ldexp_bw

Performs backward operations for ldexp of input_tensor_a and input_tensor_b with given grad_tensor.

ttnn.logaddexp_bw

Performs backward operations for logaddexp of input_tensor_a and input_tensor_b with given grad_tensor.

ttnn.logaddexp2_bw

Performs backward operations for logaddexp2 of input_tensor_a and input_tensor_b with given grad_tensor.

ttnn.mul_bw

Performs backward operations for multiply on input_tensor_a, input_tensor_b, with given grad_tensor.

ttnn.sub_bw

Performs backward operations for subtract of input_tensor_a and input_tensor_b or scalar with given grad_tensor.

ttnn.squared_difference_bw

Performs backward operations for squared_difference of input_tensor_a and input_tensor_b with given grad_tensor.

ttnn.concat_bw

Performs backward operations for concat on input_tensor_a and input_tensor_b with given grad_tensor.

ttnn.rsub_bw

Performs backward operations for subraction of input_tensor_a from input_tensor_b with given grad_tensor (reversed order of subtraction operator).

ttnn.min_bw

Performs backward operations for minimum of input_tensor_a and input_tensor_b with given grad_tensor.

ttnn.max_bw

Performs backward operations for maximum of input_tensor_a and input_tensor_b with given grad_tensor.

Pointwise Ternary

ttnn.addcdiv

Computes Addcdiv on input_tensor_a, input_tensor_b and input_tensor_c and returns the tensor with the same layout as input_tensor_a

ttnn.addcmul

Computes Addcmul on input_tensor_a, input_tensor_b and input_tensor_c and returns the tensor with the same layout as input_tensor_a

ttnn.mac

Computes Mac on input_tensor_a, input_tensor_b and input_tensor_c and returns the tensor with the same layout as input_tensor_a

ttnn.where

Computes Where on input_tensor_a, input_tensor_b and input_tensor_c and returns the tensor with the same layout as input_tensor_a

ttnn.lerp

Computes Lerp on input, end and weight and returns the tensor with the same layout as input

ttnn.addcmul_bw

Performs backward operations for addcmul of input_tensor_a, input_tensor_b and input_tensor_c with given grad_tensor.

ttnn.addcdiv_bw

Performs backward operations for addcdiv of input_tensor_a, input_tensor_b and input_tensor_c with given grad_tensor.

ttnn.where_bw

Performs backward operations for where of input_tensor_a, input_tensor_b and input_tensor_c with given grad_tensor.

ttnn.lerp_bw

Performs backward operations for lerp of input_tensor_a, input_tensor_b and input_tensor_c or scalar with given grad_tensor.

Losses

ttnn.l1_loss

Returns mean absolute error loss function for input_reference and input_prediction

ttnn.mse_loss

Returns mean squared error loss function for input_reference and input_prediction

Reduction

ttnn.max

param input_a:

the input tensor.

ttnn.mean

param input_a:

the input tensor.

ttnn.min

param input_a:

the input tensor.

ttnn.std

param input_a:

the input tensor.

ttnn.sum

param input_a:

the input tensor.

ttnn.var

param input_a:

the input tensor.

ttnn.argmax

Returns the indices of the maximum value of elements in the input tensor If no dim is provided, it will return the indices of maximum value of all elements in given input

ttnn.prod

Computes the prod function along specified dim or all dimensions on the input tensor.

ttnn.topk

Returns the k largest or k smallest elements of the given input tensor along a given dimension.

Data Movement

ttnn.concat

param input_tensor:

the input tensors.

ttnn.nonzero

Returns the number of elements (N) that are non-zero as well as a tensor of the same shape as input where the first N elements are the indices of non-zero elements.

ttnn.pad

Returns a padded tensor, with a specified value at the specified location.

ttnn.permute

Permutes the dimensions of the input tensor according to the specified permutation.

ttnn.reshape

Note: for a 0 cost view, the following conditions must be met:

ttnn.repeat

Returns a new tensor filled with repetition of input input_tensor according to number of times specified in shape.

ttnn.repeat_interleave

Repeats elements of a tensor in the given dim.

ttnn.slice

Returns a sliced tensor.

ttnn.tilize

Changes data layout of input tensor to TILE.

ttnn.tilize_with_val_padding

Changes data layout of input tensor to TILE.

ttnn.fill_rm

Generates an NCHW row-major tensor and fill it with high values up to hOnes, wOnes in each HW tile with the rest padded with high values.

ttnn.fill_ones_rm

Same as fill_rm, but val_hi is set to 1 and val_lo is 0.

ttnn.untilize

Changes data layout of input tensor to ROW_MAJOR.

ttnn.untilize_with_unpadding

Changes data layout of input tensor to ROW_MAJOR and unpads/removes elements from the tensor.

ttnn.indexed_fill

Replaces batch of input in input_b denoted by batch_ids into input_a.

Normalization

ttnn.group_norm

Compute group_norm over input_tensor.

ttnn.layer_norm

Compute layer_norm over input_tensor.

ttnn.rms_norm

Compute rms_norm over input_tensor.

ttnn.batch_norm

Applies Spatial Batch Normalization over each channel on input_tensor. Inputs must be must be tilized and interleaved.

Moreh Operations

ttnn.moreh_sum

Moreh Sum Operation

Transformer

ttnn.transformer.split_query_key_value_and_split_heads

Splits input_tensor of shape [batch_size, sequence_size, 3 * hidden_size] into 3 tensors (Query, Key, Value) of shape [batch_size, sequence_size, hidden_size].

ttnn.transformer.concatenate_heads

Takes in a tensor of shape [batch_size, num_heads, sequence_size, head_size], concatenates heads back along the width dimension and returns the tensor of shape [batch_size, sequence_size, num_heads * head_size]

ttnn.transformer.attention_softmax

Divides tensor by the square root of head_size, adds attention_mask (optionally) and computes softmax.

ttnn.transformer.attention_softmax_

In-Place divides tensor by the square root of head_size, adds attention_mask (optionally) and computes softmax.

ttnn.experimental.rotary_embedding

Applies the rotary embedding to the input_tensor tensor using the cos_cache and sin_cache tensors.

ttnn.transformer.scaled_dot_product_attention

Causal scaled dot product attention.

ttnn.transformer.scaled_dot_product_attention_decode

A version of scaled dot product attention specifically for decode.

CCL

ttnn.all_gather

Performs an all-gather operation on multi-device input_tensor across all devices.

ttnn.reduce_scatter

Performs an reduce_scatter operation on multi-device input_tensor across all devices.

ttnn.experimental.all_reduce

Performs an all_reduce operation on multi-device input_tensor across all devices.

Embedding

ttnn.embedding

Retrieves word embeddings using input_tensor.

Pooling

ttnn.global_avg_pool2d

Applies global_avg_pool2d to input_tensor by performing a 2D adaptive average pooling over an input signal composed of several input planes.

ttnn.max_pool2d

Applies a max pool convolution to the input tensor.

Vision

ttnn.upsample

Upsamples a given multi-channel 2D (spatial) data.

ttnn.downsample

Downsamples a given multi-channel 2D (spatial) data.

KV Cache

ttnn.kv_cache.fill_cache_for_user_

Populates the cache tensor in-place with values sourced from input at batch_index.

ttnn.kv_cache.update_cache_for_token_

Updates the cache tensor in-place with values from input at update_index and batch_offset.

Model Conversion

ttnn.model_preprocessing.preprocess_model

Preprocess modules and parameters of a given model.

ttnn.model_preprocessing.preprocess_model_parameters

Preprocess parameters of a given model.

Reports

ttnn.set_printoptions

Set print options for tensor output.

Operation Hooks

ttnn.register_pre_operation_hook

register_pre_operation_hook is a context manager that registers a pre-operation hook.

ttnn.register_post_operation_hook

register_post_operation_hook is a context manager that registers a post-operation hook.