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

webgpu: Enable importExternalTexture #7976

Merged
merged 2 commits into from
Sep 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions tfjs-backend-webgpu/src/from_pixels_webgpu_test.ts
Original file line number Diff line number Diff line change
@@ -50,7 +50,6 @@ describeWebGPU('fromPixels', () => {
document.body.appendChild(video);
await test_util.play(video);

// importExternalTexture is temporarily disabled
{
tf.env().set('WEBGPU_IMPORT_EXTERNAL_TEXTURE', true);
const res = tf.browser.fromPixels(video);
@@ -59,7 +58,7 @@ describeWebGPU('fromPixels', () => {
expect(data.length).toEqual(90 * 160 * 3);
const freeTexturesAfterFromPixels =
textureManager.getNumFreeTextures();
expect(freeTexturesAfterFromPixels).toEqual(1);
expect(freeTexturesAfterFromPixels).toEqual(0);
const usedTexturesAfterFromPixels =
textureManager.getNumUsedTextures();
expect(usedTexturesAfterFromPixels).toEqual(0);
4 changes: 1 addition & 3 deletions tfjs-backend-webgpu/src/kernels/FromPixels.ts
Original file line number Diff line number Diff line change
@@ -63,10 +63,8 @@ export function fromPixels(args: {
[pixels.width, pixels.height];
const outputShape = [height, width, numChannels];

// Disable importExternalTexture temporarily as it has problem in spec and
// browser impl
const importVideo =
false && env().getBool('WEBGPU_IMPORT_EXTERNAL_TEXTURE') && isVideo;
env().getBool('WEBGPU_IMPORT_EXTERNAL_TEXTURE') && isVideo;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember we have a related test case. Do you need to change the corresponding test?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I just added the fix to the test case. Thanks!

const isVideoOrImage = isVideo || isImage;
if (isImageBitmap || isCanvas || isVideoOrImage) {
let resource;