oneflow.Tensor.type_as¶
-
Tensor.
type_as
()¶ - Returns this tensor cast to the type of the given tensor.
This is a no-op if the tensor is already of the correct type.
- Parameters
For example:
>>> import oneflow as flow >>> import numpy as np >>> input = flow.tensor(np.random.randn(1, 2, 3), dtype=flow.float32) >>> target = flow.tensor(np.random.randn(4, 5, 6), dtype = flow.int32) >>> input = input.type_as(target) >>> input.dtype oneflow.int32