Пример #1
0
    def __init__(self, dtype, shape):
        self.host_accessor = None
        if impl.current_cfg().ndarray_use_torch:
            assert has_pytorch(
            ), "PyTorch must be available if you want to create a Taichi ndarray with PyTorch as its underlying storage."
            # pylint: disable=E1101
            self.arr = torch.zeros(shape,
                                   dtype=to_pytorch_type(cook_dtype(dtype)))
            if impl.current_cfg().arch == _ti_core.Arch.cuda:
                self.arr = self.arr.cuda()

        else:
            self.arr = _ti_core.Ndarray(impl.get_runtime().prog,
                                        cook_dtype(dtype), shape)
Пример #2
0
 def __init__(self, dtype, arr_shape):
     self.host_accessor = None
     self.dtype = cook_dtype(dtype)
     self.arr = _ti_core.Ndarray(impl.get_runtime().prog, cook_dtype(dtype),
                                 arr_shape)