MCPcopy
hub / github.com/tensorflow/tfjs / setBackend

Method setBackend

tfjs-core/src/engine.ts:274–293  ·  view source on GitHub ↗
(backendName: string)

Source from the content-addressed store, hash-verified

272 }
273
274 async setBackend(backendName: string): Promise<boolean> {
275 if (this.registryFactory[backendName] == null) {
276 throw new Error(`Backend name '${backendName}' not found in registry`);
277 }
278 this.backendName = backendName;
279 if (this.registry[backendName] == null) {
280 this.backendInstance = null;
281 const {success, asyncInit} = this.initializeBackend(backendName);
282 const result = asyncInit ? await success : success;
283 if (!result) {
284 return false;
285 }
286 }
287 this.backendInstance = this.registry[backendName];
288 this.setupRegisteredKernels();
289 // Reset the profiler.
290 this.profiler = new Profiler(this.backendInstance);
291
292 return true;
293 }
294
295 private setupRegisteredKernels(): void {
296 const kernels = getKernelsForBackend(this.backendName);

Callers 15

readyMethod · 0.95
backendMethod · 0.95
setBackendFunction · 0.80
componentDidMountMethod · 0.80
timeMatmulFunction · 0.80
setBackendFunction · 0.80
executeTestsFunction · 0.80
engine_test.tsFile · 0.80
draw_test.tsFile · 0.80

Calls 2

initializeBackendMethod · 0.95

Tested by

no test coverage detected