Open FL33TW00D opened 5 months ago
If we store the webgpu aligned Uint8Array, can't we just pass it through when loading?
@sigma-andex There is just no way to provide a Uint8Array
to wgpu
as of now, we need to add it
Hi, I am also interested in this issue.
I found a method wgpu::BufferSlice::get_mapped_range_as_array_buffer
.
It seems to be available only in the webgpu feature. Would this be of any help to you?
wgpu::BufferSlice::get_mapped_range_as_array_buffer
@ikorin24 It looks like that method was added in this PR: https://github.com/gfx-rs/wgpu/pull/4042
It seems to help only in the other direction (i.e getting data from WebGPU land -> JS land with less copies). We need the other direction to be added!
Currently in
wgpu
, there is no way to create awgpu::Buffer
directly fromUint8Array
.This means that our tensor data does something like this:
IndexedDB
->Uint8Array
->Vec<u8>
~~>Uint8Array
->WebGPU
Judging by this: https://developer.mozilla.org/en-US/docs/Web/API/GPUBuffer
I think the optimal is:
IndexedDB
->Uint8Array
->WebGPU
Reference: https://github.com/gfx-rs/wgpu/blob/trunk/wgpu/src/backend/webgpu.rs#L1821