I met a tool version incompatibility problem when I used from_dlpack
and to_dlpack
to speed up the memory copy. Hope this helps you.
I used PyTorch 1.13.1 and TVM 0.11.1. I wanted to use dlpack .
My code:
input_tvm = tvm.nd.from_dlpack(torch.utils.dlpack.to_dlpack(example_input_tensor))
Then I got the error message:
Check failed: ret == 0 (-1 vs. 0) :
Assert fail: ((((1 == int32(arg.input.strides[3]))
&& (32 == int32(arg.input.strides[2])))
&& (1024 == int32(arg.input.strides[1])))
&& (16384 == int32(arg.input.strides[0]))),
arg.input.strides: expected to be compact array
I checked the strides of the torch tensor like this:
assert example_input_tensor.stride() == torch.utils.dlpack.from_dlpack(input_tvm.to_dlpack()).stride()
They are not equal. In another two-dimension input case (input shape (1, 32)
), the stride values are (32, 1) and (1, 1), respectively. That’s why we got the bug shown above.
When I changed the input shape to (2, 32)
, then they were both (32, 1).
I downgraded the PyTorch version to 1.12.0, and the problem is gone.