Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimum number of copies from Uint8Array to wgpu::Buffer #171

Open
FL33TW00D opened this issue Apr 18, 2024 · 4 comments
Open

Minimum number of copies from Uint8Array to wgpu::Buffer #171

FL33TW00D opened this issue Apr 18, 2024 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@FL33TW00D
Copy link
Collaborator

FL33TW00D commented Apr 18, 2024

Currently in wgpu, there is no way to create a wgpu::Buffer directly from Uint8Array.

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

@FL33TW00D FL33TW00D added the help wanted Extra attention is needed label Apr 18, 2024
@sigma-andex
Copy link
Collaborator

If we store the webgpu aligned Uint8Array, can't we just pass it through when loading?

@FL33TW00D
Copy link
Collaborator Author

@sigma-andex There is just no way to provide a Uint8Array to wgpu as of now, we need to add it

@ikorin24
Copy link

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?

@FL33TW00D
Copy link
Collaborator Author

wgpu::BufferSlice::get_mapped_range_as_array_buffer

@ikorin24 It looks like that method was added in this PR: gfx-rs/wgpu#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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants