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: fix: conditionally call deprecated GPUAdapter.requestAdapterInfo #8392

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mattvr
Copy link

@mattvr mattvr commented Oct 2, 2024

Context

GPUAdapter.requestAdapterInfo is deprecated and non-standard.

It's in use by tfjs-backend-webgpu, but the result is optional, and only used for a single optimization. Yet if called in an environment which doesn't support it, it will throw.

By checking the feature's available before calling it, this unbreaks Deno runtime support for tfjs-backend-webgpu, which doesn't support this feature and throws.

Testing/Verification

yarn test and yarn lint succeed. Verified basic example now works in Deno.

import * as tf from "@tensorflow/tfjs-core";
import "@tensorflow/tfjs-backend-webgpu";

await tf.ready();
tf.randomGamma([2, 2], 1).print();

Related

denoland/deno#22029

Copy link

google-cla bot commented Oct 2, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Comment on lines +61 to +63
'requestAdapterInfo' in adapter
? await adapter.requestAdapterInfo()
: undefined;

Choose a reason for hiding this comment

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

Suggested change
'requestAdapterInfo' in adapter
? await adapter.requestAdapterInfo()
: undefined;
'info' in adapter
? adapter.info
: await adapter.requestAdapterInfo();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants