ttnn.addcmul
- ttnn.addcmul(input_a: ttnn.Tensor, input_b: ttnn.Tensor, input_c: ttnn.Tensor, *, value: float = 1.0, memory_config: ttnn.MemoryConfig = None, output_tensor: ttnn.Tensor = None) ttnn.Tensor
-
Computes addcmul: output = input_a + value * input_b * input_c
- Parameters:
-
input_a (ttnn.Tensor) – the first input tensor.
input_b (ttnn.Tensor) – the second input tensor.
input_c (ttnn.Tensor) – the third input tensor.
- Keyword Arguments:
-
value (float, optional) – scalar value to multiply with input_b * input_c. Defaults to 1.0.
memory_config (ttnn.MemoryConfig, optional) – memory configuration for the operation. Defaults to None.
output_tensor (ttnn.Tensor, optional) – preallocated output tensor. Defaults to None.
- Returns:
-
ttnn.Tensor – the output tensor.
Note
Supported dtypes, layouts, and ranks:
Dtypes
Layouts
Ranks
FLOAT32, BFLOAT16, BFLOAT8_B, INT32
TILE
2, 3, 4
Only TTT (tensor-tensor-tensor) variant is supported.
Example
# Create three tensors and a value for the operation value = 1.0 tensor1 = ttnn.from_torch( torch.tensor([[1, 2], [3, 4]], 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 addcmul operation: tensor1 + value * (tensor2 * tensor3) output = ttnn.addcmul(tensor1, tensor2, tensor3, value=value) logger.info(f"Addcmul result: {output}")