ttnn.div
- ttnn.div = Operation(python_fully_qualified_name='ttnn.div', function=<ttnn._ttnn.operations.binary.div_t object>, preprocess_golden_function_inputs=<function default_preprocess_golden_function_inputs>, golden_function=<function _golden_function_div>, postprocess_golden_function_outputs=<function default_postprocess_golden_function_outputs>, is_cpp_operation=True, is_experimental=False)
-
Computes div for
input_tensor_a
andinput_tensor_b
and returns the tensor with the same layout asinput_tensor_a
\[\begin{split}\mathrm{output}_i = \begin{cases} \mathrm{\left(\frac{\mathrm{input\_tensor\_a}_i}{\mathrm{input\_tensor\_b}_i}\right)}, & \text{if } \mathrm{round\_mode} = \mathrm{None} \\ \mathrm{\text{floor}\left(\frac{\mathrm{input\_tensor\_a}_i}{\mathrm{input\_tensor\_b}_i}\right)}, & \text{if } \mathrm{round\_mode} = \mathrm{floor} \\ \mathrm{\text{trunc}\left(\frac{\mathrm{input\_tensor\_a}_i}{\mathrm{input\_tensor\_b}_i}\right)}, & \text{if } \mathrm{round\_mode} = \mathrm{trunc} \end{cases}\end{split}\]- Parameters:
-
input_tensor_a (ttnn.Tensor) – the input tensor.
input_tensor_b (ttnn.Tensor or Number) – the input tensor.
- Keyword Arguments:
-
memory_config (ttnn.MemoryConfig, optional) – memory configuration for the operation. Defaults to None.
accurate_mode (bool, optional) – false if input_tensor_b is non-zero, else true (Only if the input tensor is not ComplexTensor). Defaults to false.
round_mode (string, optional) – can be None, floor and trunc (only if the input tensor is not ComplexTensor). Defaults to None.
output_tensor (ttnn.Tensor, optional) – preallocated output tensor. Defaults to None.
queue_id (int, optional) – command queue id. Defaults to 0.
- Returns:
-
ttnn.Tensor – the output tensor.
Note
Supported dtypes, layouts, and ranks:
Dtypes
Layouts
Ranks
BFLOAT16
TILE
2, 3, 4
Example
>>> 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) >>> output = ttnn.div(tensor1, tensor2, accurate_mode = false, round_mode = None)
>>> tensor = ttnn.from_torch(torch.tensor(([[1, 2], [3, 4]], dtype=torch.bfloat16), layout=ttnn.TILE_LAYOUT, device=device) >>> scalar = 3 >>> output = ttnn.div(tensor, scalar, round_mode = "floor")