From 2c191b7845948dc91732efb62cdf84e1d26084fb Mon Sep 17 00:00:00 2001 From: Xu Xing Date: Thu, 3 Nov 2022 08:59:33 +0800 Subject: [PATCH] Remove throw at promise --- e2e/benchmarks/model_config.js | 5 ++--- tfjs-converter/src/executor/graph_executor.ts | 7 +++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/e2e/benchmarks/model_config.js b/e2e/benchmarks/model_config.js index 08c59468a27..f346b5de0b0 100644 --- a/e2e/benchmarks/model_config.js +++ b/e2e/benchmarks/model_config.js @@ -220,7 +220,6 @@ const benchmarks = { }, 'Coco-SSD': { type: 'GraphModel', - supportDump: false, // The model has has the dynamic ops, so it is supposed to use executeAsync. architectures: ['MobileNetV2', 'MobileNetV1', 'liteMobileNetV2'], load: async (inputResolution = 227, modelArchitecture = 'MobileNetV2') => { @@ -329,7 +328,6 @@ const benchmarks = { }, 'AutoML Object': { type: 'GraphModel', - supportDump: false, load: async () => { const url = 'https://storage.googleapis.com/tfjs-testing/tfjs-automl/object_detection/model.json'; @@ -370,7 +368,6 @@ const benchmarks = { }, 'TextToxicity': { type: 'GraphModel', - supportDump: false, // The model has has the dynamic ops, so it is supposed to use executeAsync. load: async () => { const url = @@ -478,6 +475,8 @@ const benchmarks = { } }, 'speech-commands': { + // Sequential model doesn't support dump. + supportDump: false, load: async () => { const recognizer = speechCommands.create('BROWSER_FFT'); await recognizer.ensureModelLoaded(); diff --git a/tfjs-converter/src/executor/graph_executor.ts b/tfjs-converter/src/executor/graph_executor.ts index a1e71fe288c..cc861dfcf78 100644 --- a/tfjs-converter/src/executor/graph_executor.ts +++ b/tfjs-converter/src/executor/graph_executor.ts @@ -185,6 +185,9 @@ export class GraphExecutor implements FunctionExecutor { Object.entries(tensorsMap).map(([name, tensorsList]) => { return [ name, tensorsList.map(tensor => { + if (tensor == null) { + return null; + } const clone = tensor.clone(); keep(clone); return clone; @@ -557,10 +560,6 @@ export class GraphExecutor implements FunctionExecutor { } const currentContext = context.currentContext; if (util.isPromise(tensors)) { - if (this.keepIntermediateTensors) { - throw new Error( - 'Keep intermediate tensors is not supported for operator returns promises!'); - } promises.push(tensors.then(t => { tensorMap[nodeName] = t; context.currentContext = currentContext;