Skip to content

Commit

Permalink
webgpu: upgrade webgpu/types (#7528)
Browse files Browse the repository at this point in the history
  • Loading branch information
qjia7 authored Mar 29, 2023
1 parent 95a2873 commit ab53a8f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@types/semver": "^7.3.9",
"@types/shelljs": "^0.8.7",
"@types/webgl-ext": "0.0.30",
"@webgpu/types": "0.1.21",
"@webgpu/types": "0.1.30",
"ajv": "~6.12.3",
"argparse": "^1.0.10",
"chalk": "~2.4.2",
Expand Down
1 change: 1 addition & 0 deletions tfjs-backend-webgpu/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ if (isWebGPUSupported()) {
'maxComputeWorkgroupsPerDimension':
adapterLimits.maxComputeWorkgroupsPerDimension,
'maxStorageBufferBindingSize': adapterLimits.maxStorageBufferBindingSize,
'maxBufferSize': adapterLimits.maxBufferSize,
};

const device: GPUDevice = await adapter.requestDevice(deviceDescriptor);
Expand Down
18 changes: 4 additions & 14 deletions tfjs-backend-webgpu/src/kernels/FromPixels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const fromPixelsConfig: KernelConfig = {

let fromPixels2DContext: CanvasRenderingContext2D;
let willReadFrequently = env().getBool('CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU');
const videoToTextureMap = new Map<object, object>();

export function fromPixels(args: {
inputs: FromPixelsInputs,
Expand Down Expand Up @@ -72,21 +71,13 @@ export function fromPixels(args: {
if (isImageBitmap || isCanvas || isVideoOrImage) {
let textureInfo: TextureInfo;
if (importVideo) {
const videoElement = pixels as HTMLVideoElement;
if (!(videoToTextureMap.has(videoElement)) ||
(videoToTextureMap.get(videoElement) as GPUExternalTexture).expired) {
const externalTextureDescriptor = {source: videoElement};
videoToTextureMap.set(
videoElement,
backend.device.importExternalTexture(externalTextureDescriptor));
}

textureInfo = {
width,
height,
format: null,
usage: null,
texture: videoToTextureMap.get(videoElement) as GPUExternalTexture
texture: backend.device.importExternalTexture(
{source: pixels as HTMLVideoElement})
};
} else {
if (isVideoOrImage) {
Expand All @@ -95,9 +86,8 @@ export function fromPixels(args: {
if (fromPixels2DContext == null ||
newWillReadFrequently !== willReadFrequently) {
willReadFrequently = newWillReadFrequently;
fromPixels2DContext =
document.createElement('canvas').getContext(
'2d', {willReadFrequently});
fromPixels2DContext = document.createElement('canvas').getContext(
'2d', {willReadFrequently});
}
fromPixels2DContext.canvas.width = width;
fromPixels2DContext.canvas.height = height;
Expand Down
2 changes: 1 addition & 1 deletion tfjs-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@types/offscreencanvas": "~2019.7.0",
"@types/seedrandom": "^2.4.28",
"@types/webgl-ext": "0.0.30",
"@webgpu/types": "0.1.21",
"@webgpu/types": "0.1.30",
"long": "4.0.0",
"node-fetch": "~2.6.1",
"seedrandom": "^3.0.5"
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,10 @@
resolved "https://registry.yarnpkg.com/@verdaccio/ui-theme/-/ui-theme-6.0.0-6-next.23.tgz#268da5091e1e9264fe87b8b94c0ac596e9e54879"
integrity sha512-GXpEPdZJm6o+2VAxzUsKaiDriS+5enqr7Gjrb2Bttcd+IkOuC8lDsoFHxIv0ib4JudZJ/aKsRYL3TN2AetPFjw==

"@webgpu/[email protected].21":
version "0.1.21"
resolved "https://registry.yarnpkg.com/@webgpu/types/-/types-0.1.21.tgz#b181202daec30d66ccd67264de23814cfd176d3a"
integrity sha512-pUrWq3V5PiSGFLeLxoGqReTZmiiXwY3jRkIG5sLLKjyqNxrwm/04b4nw7LSmGWJcKk59XOM/YRTUwOzo4MMlow==
"@webgpu/[email protected].30":
version "0.1.30"
resolved "https://registry.npmmirror.com/@webgpu/types/-/types-0.1.30.tgz#b6406dc4a1c1e0d469028ceb30ddffbbd2fa706c"
integrity sha512-9AXJSmL3MzY8ZL//JjudA//q+2kBRGhLBFpkdGksWIuxrMy81nFrCzj2Am+mbh8WoU6rXmv7cY5E3rdlyru2Qg==

"@xmldom/xmldom@^0.7.3":
version "0.7.5"
Expand Down

0 comments on commit ab53a8f

Please sign in to comment.