(backendName: string)
| 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); |
no test coverage detected