APIs
Device
Open a device with the given device_id. |
|
Close the device and remove it from the device cache. |
|
Context manager for opening and closing a device. |
|
Overloaded function. |
|
Sets the default device to use for operations when inputs are not on the device. |
|
Gets the default device to use for ops when inputs aren't on device. |
|
Formats tensor to target layout and pads to padded shape. |
|
Formats tensor to target layout and unpads to shape. |
|
Pads the given shape to tile shape based on specified padding options. |
Memory Config
Creates a MemoryConfig object with a sharding spec, required for sharded ops. |
Operations
Core
Converts the torch.Tensor tensor into a ttnn.Tensor. |
|
Converts the torch.Tensor tensor into a ttnn.Tensor. |
|
Converts the ttnn.Tensor tensor into a torch.Tensor. |
|
Overloaded function. |
|
Copy tensor from device to host. |
|
Organizes the ttnn.Tensor tensor into either ttnn.ROW_MAJOR_LAYOUT or ttnn.TILE_LAYOUT. |
|
Dump tensor to a file. |
|
Load tensor from a file. |
|
Deallocates device tensor. |
|
Deallocates device tensor and returns a reallocated tensor. |
|
Converts a tensor to the desired memory configuration. |
Tensor Creation
Creates a tensor with values ranging from start (inclusive) to end (exclusive) with a specified step size. |
|
Creates a device tensor with uninitialized values of the specified shape, data type, layout, and memory configuration. |
|
Creates a new tensor with the same shape as the given reference, but without initializing its values. |
|
Creates a tensor with the specified shape and fills it with the value of 0.0. |
|
Creates a tensor of the same shape as the input tensor and fills it with the value of 0.0. |
|
Creates a tensor with the specified shape and fills it with the value of 1.0. |
|
Creates a tensor of the same shape as the input tensor and fills it with the value of 1.0. |
|
Creates a tensor of the specified shape and fills it with the specified scalar value. |
|
Creates a tensor of the same shape as the input tensor and fills it with the specified scalar value. |
Matrix Multiplication
Returns the matrix product of two tensors. |
|
Returns the linear transformation of the inputs. |
Pointwise Unary
Applies abs to |
|
Applies acos to |
|
Performs acosh function on |
|
Applies asin to |
|
Performs asinh function on |
|
Applies atan to |
|
Performs atanh function on |
|
Applies bitwise_not to |
|
Perform bitwise_left_shift operation on |
|
Perform bitwise_right_shift operation on |
|
Performs cbrt function on |
|
Applies ceil to |
|
Performs celu function on |
|
Performs clamp function on |
|
Performs clip function on |
|
Clones the input, creating a copy with the specified memory_config and converting its data type to dtype. |
|
Applies cos to |
|
Performs cosh function on |
|
Performs deg2rad function on |
|
Performs digamma function on |
|
Applies dropout to |
|
Applies the backward pass of the GELU function using ttnn experimental kernels. |
|
Applies elu to |
|
Applies eqz to |
|
Applies erf to |
|
Applies erfc to |
|
Applies erfinv to |
|
Applies exp to |
|
Applies exp2 to |
|
Applies expm1 to |
|
Applies fill to |
|
Applies floor to |
|
Performs frac function on |
|
Applies geglu to |
|
Applies gelu to |
|
Applies glu to |
|
Applies gez to |
|
Applies gtz to |
|
Performs hardshrink function on |
|
Performs hardsigmoid function on |
|
Performs hardswish function on |
|
Performs hardtanh function on |
|
Applies heaviside to |
|
Applies i0 to |
|
Returns a copy of the |
|
Applies isfinite to |
|
Applies isinf to |
|
Applies isnan to |
|
Applies isneginf to |
|
Applies isposinf to |
|
Applies leaky_relu to |
|
Applies lez to |
|
Performs lgamma function on |
|
Applies log to |
|
Applies log10 to |
|
Performs log1p function on |
|
Applies log2 to |
|
Applies log_sigmoid to |
|
Applies logical_not to |
|
Performs logical_not inplace function on |
|
Performs logit function on |
|
Applies ltz to |
|
Performs mish function on |
|
Performs multigammaln function on |
|
Applies neg to |
|
Applies nez to |
|
Performs normalize_global function on |
|
Performs normalize_hw function on |
|
Performs polygamma function on |
|
Perform an eltwise-prelu operation. |
|
Performs rad2deg function on |
|
Performs the element-wise division of a scalar |
|
Applies reciprocal to |
|
Applies reglu to |
|
Applies relu to |
|
Applies relu_max to |
|
Applies relu_min to |
|
Applies relu6 to |
|
Performs an eltwise-modulus operation. |
|
Applies round to |
|
Applies rsqrt to |
|
Performs selu function on |
|
Applies sigmoid to |
|
Applies sigmoid_accurate to |
|
Applies sign to |
|
Applies signbit to |
|
Applies silu to |
|
Applies sin to |
|
Performs sinh function on |
|
Compute softmax over |
|
Applies softplus to |
|
Performs softshrink function on |
|
Performs softsign function on |
|
Applies sqrt to |
|
Applies square to |
|
Applies swiglu to |
|
Performs swish function on |
|
Applies tan to |
|
Applies tanh to |
|
Performs tanhshrink function on |
|
Performs threshold function on |
|
Performs tril function on |
|
Performs triu function on |
|
Applies trunc to |
|
Applies unary_chain to |
|
Performs backward operations for clamp on |
|
Performs backward operations for clip on |
|
Performs backward operations for hardtanh activation function on |
|
Performs backward operations for threshold on |
|
Performs backward operations for softplus on |
|
Performs backward operations for Unary rdiv on |
|
Performs backward operations for power on |
|
Performs backward operations for exponential function on |
|
Performs backward operations for hyperbolic tangent (tanh) function on |
|
Performs backward operations for square-root on |
|
Performs backward operations for multivariate logarithmic gamma function (also referred to as mvlgamma) on |
|
Performs backward operations for lgamma on |
|
Performs backward operations for fill on |
|
Performs backward operations for hardsigmoid on |
|
Performs backward operations for cosine on |
|
Performs backward operations for inverse hyperbolic cosine (acosh) on |
|
Performs backward operations for inverse cosine (acos) on |
|
Performs backward operations for inverse tangenr (atan) on |
|
Performs backward operations for radian to degree conversion (rad2deg) on |
|
Performs backward operations for frac on |
|
Performs backward operations for truncation on |
|
Performs backward operations for log sigmoid on |
|
Performs backward operations for fill zero on |
|
Performs backward operations for i0 on |
|
Performs backward operations for tan on |
|
Performs backward operations for sigmoid on |
|
Performs backward operations for reciprocal of square-root on |
|
Performs backward operations for neg on |
|
Performs backward operations for relu on |
|
Performs backward operations for logit on |
|
Performs backward operations for hardshrink on |
|
Performs backward operations for softshrink on |
|
Performs backward operations for leaky_relu on |
|
Performs backward operations for elu on |
|
Performs backward operations for celu on |
|
Performs backward operations for rpow on |
|
Performs backward operations for floor on |
|
Performs backward operations for round on |
|
Performs backward operations for logarithm on |
|
Performs backward operations for relu6 on |
|
Performs backward operations for abs on |
|
Performs backward operations for silu on |
|
Performs backward operations for selu on |
|
Performs backward operations for square on |
|
Performs backward operations for prod on |
|
Performs backward operations for hardswish on |
|
Performs backward operations for tanhshrink on |
|
Performs backward operations for inverse hyperbolic tangent (atanh) on |
|
Performs backward operations for inverse sine (asin) on |
|
Performs backward operations for inverse hyperbolic sine (asinh) on |
|
Performs backward operations for sin on |
|
Performs backward operations for hyperbolic sine (sinh) on |
|
Performs backward operations for log10 on |
|
Performs backward operations for log1p on |
|
Performs backward operations for erfc on |
|
Performs backward operations for ceil on |
|
Performs backward operations for softsign on |
|
Performs backward operations for hyperbolic cosine (cosh) on |
|
Performs backward operations for logiteps on |
|
Performs backward operations for log2 on |
|
Performs backward operations for sign on |
|
Performs backward operations for div_no_nan on |
|
Performs backward operations for exp2 on |
|
Performs backward operations for expm1 on |
|
Performs backward operations for reciprocal on |
|
Performs backward operations for digamma on |
|
Performs backward operations for erfinv on |
|
Performs backward operations for erf on |
|
Performs backward operations for degree to radian conversion (deg2rad) on |
|
Performs backward operations for polygamma on |
|
Performs backward operations for gelu on |
|
Performs backward operations for repeat on |
|
Performs complex operations for real of |
|
Performs complex operations for imag of |
|
Performs complex operations for angle of |
|
Returns boolean tensor if value of |
|
Returns boolean tensor if value of |
|
Performs backward operations for complex polar function on |
|
Performs backward operations for complex imaginary function on |
|
Performs backward operations for complex real function on |
|
Performs backward operations for complex angle function on |
|
Performs backward operations for complex conj function on |
|
Returns complex conjugate value of complex tensor |
|
Perform an polar to Cartesian transformation on |
Pointwise Binary
Adds |
|
Computes addalpha for |
|
Computes subalpha for |
|
Multiplies |
|
Subtracts |
|
Computes div for |
|
Computes div_no_nan for |
|
Computes floor division for |
|
Performs an eltwise-modulus operation. |
|
Performs an eltwise-fmod operation. |
|
Computes Greatest common divisor of |
|
Computes Least common multiple of |
|
Computes inplace logical AND of |
|
Computes inplace logical OR of |
|
Computes inplace logical XOR of |
|
Performs rpow function on |
|
Subtracts |
|
Computes ldexp of |
|
Computes logical AND of |
|
Computes logical OR of |
|
Compute logical_xor |
|
Perform bitwise_and operation on |
|
Perform bitwise_or operation on |
|
Perform bitwise_xor operation on |
|
Computes logaddexp of |
|
Computes logaddexp2 of |
|
Computes hypot |
|
Computes xlogy |
|
Computes squared difference of |
|
Compares if |
|
Performs Greater than in-place operation on |
|
Performs Less than in-place operation on |
|
Performs Greater than or equal to in-place operation on |
|
Performs Less than or equal to in-place operation on |
|
Performs Equal to in-place operation on |
|
Performs Not equal to in-place operation on |
|
Compares if |
|
Compares if |
|
Compares if |
|
Compares if |
|
Compares if |
|
Computes isclose for |
|
Computes nextafter |
|
Computes maximum for |
|
Computes minimum for |
|
Computes outer for |
|
Perform element-wise pow operation on |
|
Computes polyval of all elements of |
|
Computes scatter for |
|
Computes atan2 |
|
Performs backward operations for add of |
|
Performs backward operations for assign of |
|
Performs backward operations for atan2 of |
|
Performs backward operations for bias_gelu on |
|
Performs backward operations for divide on |
|
Returns the input gradients of the output gradients tensor with respect to the input indices. |
|
Performs backward operations for fmod of |
|
Performs backward operations for remainder of |
|
Performs backward operations for addalpha on |
|
Performs backward operations for subalpha of |
|
Performs backward operations for xlogy of |
|
Performs backward operations for hypot of |
|
Performs backward operations for ldexp of |
|
Performs backward operations for logaddexp of |
|
Performs backward operations for logaddexp2 of |
|
Performs backward operations for multiply on |
|
Performs backward operations for subtract of |
|
Performs backward operations for squared_difference of |
|
Performs backward operations for concat on |
|
Performs backward operations for subraction of |
|
Performs backward operations for minimum of |
|
Performs backward operations for maximum of |
Pointwise Ternary
Computes Addcdiv on |
|
Computes Addcmul on |
|
Computes Mac on |
|
Computes Where on |
|
Computes Lerp on |
|
Performs backward operations for addcmul of |
|
Performs backward operations for addcdiv of |
|
Performs backward operations for where of |
|
Performs backward operations for lerp of |
Losses
Returns mean absolute error loss function for input_reference and input_prediction |
|
Returns mean squared error loss function for input_reference and input_prediction |
Reduction
|
|
|
|
|
|
|
|
|
|
|
|
Returns the indices of the maximum value of elements in the |
|
Computes the prod function along specified |
|
Returns the |
Data Movement
|
|
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. |
|
Returns a padded tensor, with a specified value at the specified location. |
|
Permutes the dimensions of the input tensor according to the specified permutation. |
|
Note: for a 0 cost view, the following conditions must be met: |
|
Returns a new tensor filled with repetition of input |
|
Repeats elements of a |
|
Returns a sliced tensor. |
|
Changes data layout of input tensor to TILE. |
|
Changes data layout of input tensor to TILE. |
|
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. |
|
Same as |
|
Changes data layout of input tensor to ROW_MAJOR. |
|
Changes data layout of input tensor to ROW_MAJOR and unpads/removes elements from the tensor. |
|
Replaces batch of input in input_b denoted by batch_ids into input_a. |
Normalization
Compute group_norm over |
|
Compute layer_norm over |
|
Compute rms_norm over |
|
Applies Spatial Batch Normalization over each channel on |
Moreh Operations
Moreh Sum Operation |
Transformer
Splits |
|
Takes in a tensor of shape |
|
Divides |
|
In-Place divides |
|
Applies the rotary embedding to the input_tensor tensor using the cos_cache and sin_cache tensors. |
|
Causal scaled dot product attention. |
|
A version of scaled dot product attention specifically for decode. |
CCL
Performs an all-gather operation on multi-device |
|
Performs an reduce_scatter operation on multi-device |
|
Performs an all_reduce operation on multi-device |
Embedding
Retrieves word embeddings using input_tensor. |
Pooling
Applies global_avg_pool2d to |
|
Applies a max pool convolution to the input tensor. |
Vision
Upsamples a given multi-channel 2D (spatial) data. |
|
Downsamples a given multi-channel 2D (spatial) data. |
KV Cache
Populates the |
|
Updates the |
Model Conversion
Preprocess modules and parameters of a given model. |
|
Preprocess parameters of a given model. |
Reports
Set print options for tensor output. |
Operation Hooks
register_pre_operation_hook is a context manager that registers a pre-operation hook. |
|
register_post_operation_hook is a context manager that registers a post-operation hook. |