Numpy array to tvm nd array is so slow

There is tvm.nd.numpyasarray which returns a TVMArray. I must admit I don’t fully understand the lifetime organization of trying to make an NDArray from it.

Note that 10 iterations are really not that much and I get a significantly faster time per loop when I do 100. Just to see what the speed should be like: going through PyTorch’s zero copy and DLPack gives

a_pt = torch.from_numpy(a_np) 
a_dl = torch.utils.dlpack.to_dlpack(a_pt) 
a_tvm = tvm.nd.from_dlpack(a_dl) 

is about 90x as fast as copying for me.

3 Likes