You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As you just mentioned, "torch-scalar" is a "zero-dimension" tensor, so basically you still need to treat it as a Ndarray in Taichi:
import torch
import taichi as ti
ti.init(arch=ti.cpu)
@ti.kernel
def fill(out: ti.types.ndarray(), value: ti.types.ndarray()):
for I in ti.grouped(out):
out[I] = value[None]
out = torch.empty((10,), dtype=torch.int32)
value = torch.tensor(2, dtype=torch.int32) # torch scalar
fill(out, value)
Torch scalars are 0-dimensional tensors.
Currently taichi cannot convert a zero dimensional tensor (e.g.
torch.tensor(2, dtype=torch.int32)
) to taichi scalar (e.g.ti.int32
).Example
Suppose you have this
fill
kernel:We can pass a python scalar
We can also pass a
numpy
scalarbut we cannot pass a
torch
scalarThe text was updated successfully, but these errors were encountered: