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

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)