Skip to content

Commit

Permalink
support string dtype input generation (#8003)
Browse files Browse the repository at this point in the history
FEATURE
  • Loading branch information
pyu10055 committed Oct 13, 2023
1 parent 6b539e8 commit 906cbe3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions e2e/benchmarks/benchmark_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ` +
Expand Down

0 comments on commit 906cbe3

Please sign in to comment.