ttnn.lerp

ttnn.lerp = Operation(python_fully_qualified_name='ttnn.lerp', function=<ttnn._ttnn.operations.ternary.lerp_t object>, preprocess_golden_function_inputs=<function default_preprocess_golden_function_inputs>, golden_function=<function _golden_function_lerp>, postprocess_golden_function_outputs=<function default_postprocess_golden_function_outputs>, is_cpp_operation=True, is_experimental=False)

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

\[\mathrm{output\_tensor} = \verb|lerp|(\mathrm{input, end, weight})\]
Parameters:
  • input (ttnn.Tensor) – the input tensor with the starting points.

  • end (ttnn.Tensor) – the tensor with the ending points.

  • weight (ttnn.Tensor or float) – the weight for the interpolation formula.

Keyword Arguments:

memory_config (ttnn.MemoryConfig, optional) – memory configuration for the operation. Defaults to None.

Note

Supported dtypes, layouts, and ranks:

Dtypes

Layouts

Ranks

BFLOAT16, BFLOAT8_B

TILE

2, 3, 4

bfloat8_b/bfloat4_b supports only on TILE_LAYOUT

end, weight tensors should have same dtype as input

Example

>>> tensor1 = ttnn.from_torch(torch.tensor([[1, 0], [1, 0]], dtype=torch.bfloat16), layout=ttnn.TILE_LAYOUT, device=device)
>>> tensor2 = ttnn.from_torch(torch.tensor([[1, 2], [3, 4]], dtype=torch.bfloat16), layout=ttnn.TILE_LAYOUT, device=device)
>>> tensor3 = ttnn.from_torch(torch.tensor([[1, 2], [3, 4]], dtype=torch.bfloat16), layout=ttnn.TILE_LAYOUT, device=device)
>>> output = ttnn.lerp(tensor1, tensor2, tensor3/scalar)