def to_numpy(self, dtype=None): if dtype is None: dtype = to_numpy_type(self.dtype) import numpy as np # pylint: disable=C0415 arr = np.zeros(shape=self.shape, dtype=dtype) from taichi._kernels import tensor_to_ext_arr # pylint: disable=C0415 tensor_to_ext_arr(self, arr) taichi.lang.runtime_ops.sync() return arr
def to_torch(self, device=None): import torch # pylint: disable=C0415 # pylint: disable=E1101 arr = torch.zeros(size=self.shape, dtype=to_pytorch_type(self.dtype), device=device) from taichi._kernels import tensor_to_ext_arr # pylint: disable=C0415 tensor_to_ext_arr(self, arr) taichi.lang.runtime_ops.sync() return arr
def to_paddle(self, place=None): """Converts this field to a `paddle.Tensor`. """ import paddle # pylint: disable=C0415 # pylint: disable=E1101 # paddle.empty() doesn't support argument `place`` arr = paddle.to_tensor(paddle.zeros(self.shape, to_paddle_type(self.dtype)), place=place) from taichi._kernels import tensor_to_ext_arr # pylint: disable=C0415 tensor_to_ext_arr(self, arr) taichi.lang.runtime_ops.sync() return arr