ttnn.lerp
- ttnn.lerp(input: ttnn.Tensor, end: ttnn.Tensor, weight: ttnn.Tensor or float, *, memory_config: ttnn.MemoryConfig = None, output_tensor: ttnn.Tensor = None) None
-
Computes Lerp on
input,endandweightand returns the tensor with the same layout asinput\[\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.
output_tensor (ttnn.Tensor, optional) – preallocated output tensor. Defaults to None.
Note
Supported dtypes and layouts:
Dtypes
Layouts
BFLOAT16, BFLOAT8_B, FLOAT32
TILE
bfloat8_b/bfloat4_b supports only on TILE_LAYOUT
end, weight tensors should have same dtype as input
output_tensor dtype must match input dtype, or be FLOAT32 when inputs are BFLOAT16, or be BFLOAT16 when inputs are FLOAT32
Example
# Create three tensors 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 ) # Perform the lerp operation output = ttnn.lerp(tensor1, tensor2, tensor3) logger.info(f"Lerp result: {output}")