oneflow.mul¶
-
oneflow.
mul
()¶ Computes the multiplication of input by other for each element, scalar and broadcast promotation are supported.
The formula is:
\[\text{out}_i = \text{input}_i \times \text{other}_i\]For example:
>>> import numpy as np >>> import oneflow as flow # element-wise multiply >>> input = flow.tensor(np.random.randn(2,3), dtype=flow.float32) >>> other = flow.tensor(np.random.randn(2,3), dtype=flow.float32) >>> out = flow.mul(input,other).numpy() >>> out.shape (2, 3) # scalar mutiply >>> input = 5 >>> other = flow.tensor(np.random.randn(2,3), dtype=flow.float32) >>> out = flow.mul(input,other).numpy() >>> out.shape (2, 3) # broadcast mutiply >>> input = flow.tensor(np.random.randn(1,1), dtype=flow.float32) >>> other = flow.tensor(np.random.randn(2,3), dtype=flow.float32) >>> out = flow.mul(input,other).numpy() >>> out.shape (2, 3)