oneflow.utils.tensor.from_torch¶
-
oneflow.utils.tensor.
from_torch
(torch_tensor) → Tensor¶ Create a oneflow tensor from torch tensor.
The returned tensor and torch tensor share the same memory.
Note
This function can be used in special data processing stages, torch’s some cpu ops can be used.
- Parameters
input (torch.Tensor) – Input Tensor
- Returns
oneflow.Tensor
For example:
import oneflow as flow import torch torch_t = torch.tensor([[1, 2, 3], [4, 5, 6]]) flow_t = flow.utils.tensor.from_torch(torch_t)
This feature
from_torch
is at Alpha Stage.