MCPcopy Index your code
hub / github.com/apache/tvm / initWebGPU

Method initWebGPU

web/src/runtime.ts:1898–1930  ·  view source on GitHub ↗

* Initialize webgpu in the runtime. * @param device The given GPU device.

(device: GPUDevice)

Source from the content-addressed store, hash-verified

1896 * @param device The given GPU device.
1897 */
1898 initWebGPU(device: GPUDevice): void {
1899 device.addEventListener("uncapturederror", (event) => {
1900 console.error("A WebGPU error was not captured: ", event);
1901 });
1902
1903 device.lost.then((info: any) => {
1904 if (this.deviceLostIsError) {
1905 console.error("Device lost, calling Instance.dispose(). Please initialize again. ", info);
1906 this.dispose();
1907 }
1908 });
1909 this.deviceLostIsError = true;
1910
1911 const webGPUContext = new WebGPUContext(
1912 this.memory, device
1913 );
1914 this.registerFunc("wasm.WebGPUDeviceAPI", (name: string) => {
1915 return webGPUContext.getDeviceAPI(name);
1916 });
1917 this.registerFunc("wasm.WebGPUCreateShader", (info: string, code: string) => {
1918 const finfo = JSON.parse(info) as FunctionInfo;
1919 return webGPUContext.createShader(finfo, code);
1920 });
1921 this.registerAsyncServerFunc("wasm.WebGPUWaitForTasks", async () => {
1922 await webGPUContext.sync();
1923 });
1924 if (this.asyncifyHandler.enabled()) {
1925 this.registerAsyncifyFunc("__asyncify.WebGPUWaitForTasks", async () => {
1926 await webGPUContext.sync();
1927 });
1928 }
1929 this.lib.webGPUContext = webGPUContext;
1930 }
1931
1932 /** Register all object factory */
1933 private registerObjectFactoryFuncs(): void {

Callers 1

asyncInitServerMethod · 0.80

Calls 10

disposeMethod · 0.95
registerFuncMethod · 0.95
getDeviceAPIMethod · 0.95
createShaderMethod · 0.95
syncMethod · 0.95
registerAsyncifyFuncMethod · 0.95
errorMethod · 0.80
parseMethod · 0.80
enabledMethod · 0.45

Tested by

no test coverage detected