oneflow.ones_like

oneflow.ones_like(input) is equivalent to flow.ones(input.shape, dtype=input.dtype)
Parameters

other (Tensor) – The size of input will determine size of the output tensor.

For example:

>>> import oneflow as flow
>>> import numpy as np
>>> x = flow.tensor(np.random.rand(5), dtype=flow.float32)
>>> y = flow.ones_like(x)
>>> y
tensor([1., 1., 1., 1., 1.], dtype=oneflow.float32)