Skip to content

Commit

Permalink
webgpu: Enable importExternalTexture (tensorflow#7976)
Browse files Browse the repository at this point in the history
BUG
* webgpu: Enable importExternalTexture

Issues related to importExternalTexture were fixed in Chrome, so that we
may enable this feature by default again.
Note that its Linux implementation still has problem, and WebGPU support
on Linux hasn't been officially released yet.
Bug tensorflow#7972

* Fix the test case though it's not enabled
  • Loading branch information
Yang Gu authored Sep 25, 2023
1 parent b229842 commit a7bec12
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
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
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions tfjs-backend-webgpu/src/kernels/FromPixels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
const isVideoOrImage = isVideo || isImage;
if (isImageBitmap || isCanvas || isVideoOrImage) {
let resource;
Expand Down

0 comments on commit a7bec12

Please sign in to comment.