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
webgpu: update dataToGPU doc #6810
Conversation
resource: { | ||
buffer: data.buffer, | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to add ...
here to imply that there are other entries. And it will be good if you can also show the shader snippet about how to use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data.buffer
is normal GPUBuffer object, and the shader could treat it as other GPUBuffer objects, and the shader does not know that it comes from dataToGPU, so I think it does not need to add the shader usage here. Do you think so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the hard part is not how to use the buffer. But how to calculate the expected buffer index and then get the buffer data in the pixel shader. And also in the shader, the user should be careful that the binding point should be same with binding
in API side. I'm just worried users may be not familiar with webgpu and don't know how to use it. But since you already provided the example code link, I am ok if want to keep it simple here.
|
||
The dataToGPU exports a GPUBuffer object, whose content and size is the same as | ||
the source tensor on the webgpu backend, it is user's responsibility to parse | ||
the content and size on the downsream webgpu processing steps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: downsream
-> downstream
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
# For webgpu backend | ||
The example below shows how to get the tensor buffer by calling | ||
`datatoGPU`. Also see this [example code](https://github.com/tensorflow/tfjs-examples/tree/master/gpu-pipeline/webgpu) for details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be "dataToGPU", and WebGL also has this typo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
// bufSize: the size of the buffer. | ||
// tensorRef: the tensor associated with the buffer. | ||
// | ||
// Unlike webgl backend, There is no parameter for dataGPU api on the webgpu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dataGPU -> dataToGPU
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
api -> API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
The dataToGPU exports a GPUBuffer object, whose content and size is the same as | ||
the source tensor on the webgpu backend, it is user's responsibility to parse | ||
the content and size on the downstream webgpu processing steps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why we need this paragraph. In addition, bufSize is returned, but there is no mention how to use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
// data has below fields: | ||
// {buffer, bufSize, tensorRef} | ||
// buffer: A GPUBuffer. | ||
// bufSize: the size of the buffer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So my left open is why we need bufSize.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I had explicitly used bufSize
in the sample.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.
This change is