From 906cbe30b2244abd43c2d0d52137aafbc11cf96c Mon Sep 17 00:00:00 2001 From: Ping Yu <4018+pyu10055@users.noreply.github.com> Date: Fri, 13 Oct 2023 15:13:45 -0700 Subject: [PATCH] support string dtype input generation (#8003) FEATURE --- e2e/benchmarks/benchmark_util.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/e2e/benchmarks/benchmark_util.js b/e2e/benchmarks/benchmark_util.js index 414489d780b..d6a9d249d56 100644 --- a/e2e/benchmarks/benchmark_util.js +++ b/e2e/benchmarks/benchmark_util.js @@ -107,6 +107,11 @@ function generateInputFromDef(inputDefs, isForGraphModel = false) { // the data generated maybe outside of [min, max]. inputTensor = tf.clipByValue(generatedRaw, min, max); generatedRaw.dispose(); + } else if (inputDef.dtype === 'string') { + size = tf.util.sizeFromShape(inputDef.shape); + data = [...Array(size)].map( + () => Math.random().toString(36).substring(2, 7)); + inputTensor = tf.tensor(data, inputShape, inputDef.dtype); } else { throw new Error( `The ${inputDef.dtype} dtype of '${inputDef.name}' input ` +