Skip to content
21 changes: 21 additions & 0 deletions webnn/concat.https.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// META: title=test WebNN API concat operation
// META: global=window,dedicatedworker
// META: script=./resources/utils.js
// META: timeout=long

'use strict';

// https://webmachinelearning.github.io/webnn/#api-mlgraphbuilder-concat

const buildConcat = (builder, resources) => {
// MLOperand concat(sequence<MLOperand> inputs, long axis);
const namedOutputOperand = {};
const inputOperands = [];
for (let input of resources.inputs) {
inputOperands.push(builder.input(input.name, {type: input.type, dimensions: input.shape}));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code that sets inputOperands and inputs look common for other operator tests. Could they be extract to utils.js?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@huningxin Thanks for your suggestions, I will try to optimize setting inputOperands, inputs and outputs in the next PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Building inputs from JSON looks good.

namedOutputOperand[resources.expected.name] = builder.concat(inputOperands, resources.axis);
return namedOutputOperand;
};

testWebNNOperation('concat', '/webnn/resources/test_data/concat.json', buildConcat);
Loading