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

Recover the default backend #7709

Merged
merged 1 commit into from
May 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tfjs-core/src/ops/tensor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import {makeTensor} from './tensor_ops_util';
* const customBackend = new tf.MathBackendWebGL(customCanvas);
* tf.registerBackend('custom-webgl', () => customBackend);
* }
* const savedBackend = tf.getBackend();
* await tf.setBackend('custom-webgl');
* const gl = tf.backend().gpgpu.gl;
* const texture = gl.createTexture();
Expand Down Expand Up @@ -94,6 +95,7 @@ import {makeTensor} from './tensor_ops_util';
* // so:
*
* const tex = a.dataToGPU();
* await tf.setBackend(savedBackend);
* ```
*
* ```js
Expand Down Expand Up @@ -146,6 +148,7 @@ import {makeTensor} from './tensor_ops_util';
* return gpuReadBuffer;
* }
*
* const savedBackend = tf.getBackend();
* await tf.setBackend('webgpu').catch(
* () => {throw new Error(
* 'Failed to use WebGPU backend. Please use Chrome Canary to run.')});
Expand All @@ -166,6 +169,7 @@ import {makeTensor} from './tensor_ops_util';
* b.dispose();
* result.dispose();
* aBuffer.destroy();
* await tf.setBackend(savedBackend);
* ```
* @param values The values of the tensor. Can be nested array of numbers,
* or a flat array, or a `TypedArray`, or a `WebGLData` object, or a
Expand Down