()
| 209 | } |
| 210 | |
| 211 | get backend(): KernelBackend { |
| 212 | if (this.pendingBackendInit != null) { |
| 213 | throw new Error( |
| 214 | `Backend '${this.backendName}' has not yet been initialized. Make ` + |
| 215 | `sure to await tf.ready() or await tf.setBackend() before calling ` + |
| 216 | `other methods`); |
| 217 | } |
| 218 | if (this.backendInstance == null) { |
| 219 | const {name, asyncInit} = this.initializeBackendsAndReturnBest(); |
| 220 | if (asyncInit) { |
| 221 | throw new Error( |
| 222 | `The highest priority backend '${name}' has not yet been ` + |
| 223 | `initialized. Make sure to await tf.ready() or ` + |
| 224 | `await tf.setBackend() before calling other methods`); |
| 225 | } |
| 226 | this.setBackend(name); |
| 227 | } |
| 228 | return this.backendInstance; |
| 229 | } |
| 230 | |
| 231 | backendNames(): string[] { |
| 232 | return Object.keys(this.registryFactory); |
no test coverage detected