* Reset the target backend. * * @param backendName The name of the backend to be reset.
(backendName)
| 659 | * @param backendName The name of the backend to be reset. |
| 660 | */ |
| 661 | async 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. |
no test coverage detected
searching dependent graphs…