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: export webgpu utilities #6707

Merged
merged 1 commit into from
Aug 9, 2022
Merged

Conversation

xhcao
Copy link
Contributor

@xhcao xhcao commented Aug 2, 2022

To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.


This change is Reviewable

@xhcao
Copy link
Contributor Author

xhcao commented Aug 2, 2022

@haoyunfeix Please help to review it, thank you.

}
const device: GPUDevice = await adapter.requestDevice(deviceDescriptor);
return new WebGPUBackend(device);
}, 3 /*priority*/);
}

export {webgpu};
export * from './base';
Copy link
Contributor

Choose a reason for hiding this comment

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

why not directly call export * from './webgpu'; here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refer it to webgl backend, we could put all wanted export utilities in base.ts file in future.

Copy link
Member

Choose a reason for hiding this comment

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

The webgl backend puts kernels into the register_all_kernels.ts file and everything else into base.ts. This is for better readability, and makes sure any side effects from setting up the backend happen before kernels are registered (I'm not 100% sure this is necessary). If you want to do the same for webgpu, you could move everything from index.ts into base.ts. However, it's a style choice, and if you prefer to keep everything in index.ts, I think that's fine.

@xhcao
Copy link
Contributor Author

xhcao commented Aug 2, 2022

Hi, @qjia7 I do not know the reason why here uses the base.ts for webgl, why not import and export directly in index.ts. @pyu10055 @lina128 Could you help to answer the question? thank you.

@@ -0,0 +1,19 @@
/**
* @license
* Copyright 2020 Google Inc. All Rights Reserved.
Copy link

Choose a reason for hiding this comment

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

2020 -> 2022

@@ -49,11 +49,12 @@ if (isWebGPUSupported()) {
};

if (supportTimeQuery) {
deviceDescriptor.requiredFeatures = ['timestamp-query' as const];
deviceDescriptor.requiredFeatures = ['timestamp-query' as const ];
Copy link

Choose a reason for hiding this comment

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

Why do we need an extra space here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had noticed this extra space, it was added automatically by vs editor.

@xhcao xhcao force-pushed the exportwebgputs branch 3 times, most recently from ff23db2 to c28e129 Compare August 8, 2022 03:21
Copy link
Contributor

@qjia7 qjia7 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Copy link

@gyagp gyagp left a comment

Choose a reason for hiding this comment

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

LGTM

@xhcao xhcao merged commit 3f812ad into tensorflow:master Aug 9, 2022
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.

4 participants