Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions tfjs-core/src/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,13 @@ export class Engine implements TensorTracker, DataMover {

try {
const backend = registryFactoryEntry.factory();
// Test if the factory returns a promise.
if (Promise.resolve(backend) === backend) {
/* Test if the factory returns a promise.
Done in a more liberal way than
previous 'Promise.resolve(backend)===backend'
as we needed to account for custom Promise
implementations (e.g. Angular) */
if (backend && !(backend instanceof KernelBackend)
&& typeof backend.then === 'function') {
const promiseId = ++this.pendingBackendInitId;
const success =
backend
Expand Down