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

Function resetBackend

e2e/benchmarks/benchmark_util.js:661–684  ·  view source on GitHub ↗

* Reset the target backend. * * @param backendName The name of the backend to be reset.

(backendName)

Source from the content-addressed store, hash-verified

659 * @param backendName The name of the backend to be reset.
660 */
661async function resetBackend(backendName) {
662 const ENGINE = tf.engine();
663 if (!(backendName in ENGINE.registryFactory)) {
664 throw new Error(`${backendName} backend is not registed.`);
665 }
666
667 const currentBackend = tf.getBackend();
668
669 if (backendName in ENGINE.registry) {
670 const backendFactory = tf.findBackendFactory(backendName);
671 tf.removeBackend(backendName);
672 tf.registerBackend(backendName, backendFactory);
673 }
674
675 if (currentBackend === backendName) {
676 const isSuccessful = await tf.setBackend(backendName);
677 if (!isSuccessful) {
678 showMsg(`Failed to set backend ${backendName}.`);
679 return false;
680 }
681 }
682
683 return true;
684}
685
686/**
687 * Get the renderer info from the WebGL backend.

Callers 2

setEnvFlagsFunction · 0.85

Calls 4

findBackendFactoryMethod · 0.80
removeBackendMethod · 0.80
registerBackendMethod · 0.80
setBackendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…