* Execute a kernel with the given name and return the output tensor. * * @param kernelName The name of the kernel to execute. * @param inputs A map of input names to tensors. * @param attrs A map of attribute names to their values. An attribute is a * primitive (non-tensor) input
(
kernelName: string, inputs: NamedTensorMap, attrs?: NamedAttrMap)
| 537 | * tensors are not visible to the user. |
| 538 | */ |
| 539 | runKernel<T extends Tensor|Tensor[]>( |
| 540 | kernelName: string, inputs: NamedTensorMap, attrs?: NamedAttrMap): T { |
| 541 | if (this.backendName == null) { |
| 542 | // backend has not been initialized yet (backend initialization is lazy |
| 543 | // can be deferred until an op/ kernel is run). |
| 544 | // The below getter has side effects that will try to initialize the |
| 545 | // backend and set properties like this.backendName |
| 546 | // tslint:disable-next-line: no-unused-expression |
| 547 | this.backend; |
| 548 | } |
| 549 | const hasKernel = getKernel(kernelName, this.backendName) != null; |
| 550 | if (!hasKernel) { |
| 551 | throw new Error(`Kernel '${kernelName}' not registered for backend '${ |
| 552 | this.backendName}'`); |
| 553 | } |
| 554 | return this.runKernelFunc({kernelName, inputs, attrs}); |
| 555 | } |
| 556 | |
| 557 | private shouldCheckForMemLeaks(): boolean { |
| 558 | return this.ENV.getBool('IS_TEST'); |
no test coverage detected