mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-10 04:26:00 +08:00
[Bugfix] Ensure tensors are contiguous during serialisation (#18860)
Signed-off-by: Lukas Geiger <lukas.geiger94@gmail.com>
This commit is contained in:
parent
24d0ef8970
commit
0b1447f890
@ -158,8 +158,8 @@ class MsgpackEncoder:
|
||||
self, obj: torch.Tensor
|
||||
) -> tuple[str, tuple[int, ...], Union[int, memoryview]]:
|
||||
assert self.aux_buffers is not None
|
||||
# view the tensor as a 1D array of bytes
|
||||
arr = obj.flatten().view(torch.uint8).numpy()
|
||||
# view the tensor as a contiguous 1D array of bytes
|
||||
arr = obj.flatten().contiguous().view(torch.uint8).numpy()
|
||||
if obj.nbytes < self.size_threshold:
|
||||
# Smaller tensors are encoded inline, just like ndarrays.
|
||||
data = msgpack.Ext(CUSTOM_TYPE_RAW_VIEW, arr.data)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user