oneflow.div¶
-
oneflow.
div
()¶ Computes the division of input by other for each element, scalar and broadcast promotation are supported. The formula is:
\[out = \frac{input}{other}\]- Parameters
input (Union[int, float, oneflow.Tensor]) – input.
other (Union[int, float, oneflow.Tensor]) – other.
For example:
>>> import numpy as np >>> import oneflow as flow # element-wise divide >>> input = flow.tensor(np.random.randn(2,3), dtype=flow.float32) >>> other = flow.tensor(np.random.randn(2,3), dtype=flow.float32) >>> out = flow.div(input,other).numpy() >>> out.shape (2, 3) # scalar divide >>> input = 5 >>> other = flow.tensor(np.random.randn(2,3), dtype=flow.float32) >>> out = flow.div(input,other).numpy() >>> out.shape (2, 3) # broadcast divide >>> input = flow.tensor(np.random.randn(1,1), dtype=flow.float32) >>> other = flow.tensor(np.random.randn(2,3), dtype=flow.float32) >>> out = flow.div(input,other).numpy() >>> out.shape (2, 3)