mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 14:25:49 +00:00
Bug 1892933 [wpt PR 45845] - webnn: Migrate Pad validation tests to WPTs, a=testonly
Automatic update from web-platform-tests webnn: Migrate Pad validation tests to WPTs This CL adds WPT tests for pad and removes the unit tests `MLGraphBuilderTest.PadTest`, `MLGraphTestMojo.PadTest` and `MLGraphTest.PadTest`. Bug: 327337526, 328026885 Change-Id: Ic24215dea7c4b995719df168000e107064bef3a4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5476427 Reviewed-by: Austin Sullivan <asully@chromium.org> Commit-Queue: Shanxing Mei <shanxing.mei@intel.com> Reviewed-by: ningxin hu <ningxin.hu@intel.com> Cr-Commit-Position: refs/heads/main@{#1293535} -- wpt-commits: 722942181d5c231bda75561c05c44564800a1e42 wpt-pr: 45845
This commit is contained in:
parent
77b4095f8b
commit
1e4714c0c2
@ -15,3 +15,73 @@ multi_builder_test(async (t, builder, otherBuilder) => {
|
||||
() =>
|
||||
builder.pad(inputFromOtherBuilder, beginningPadding, endingPadding));
|
||||
}, '[pad] throw if input is from another builder');
|
||||
|
||||
const tests = [
|
||||
{
|
||||
name:
|
||||
'[pad] Test with default options, beginningPadding=[1, 2] and endingPadding=[1, 2].',
|
||||
input: {dataType: 'float32', dimensions: [2, 3]},
|
||||
beginningPadding: [1, 2],
|
||||
endingPadding: [1, 2],
|
||||
options: {
|
||||
mode: 'constant',
|
||||
value: 0,
|
||||
},
|
||||
output: {dataType: 'float32', dimensions: [4, 7]}
|
||||
},
|
||||
{
|
||||
name: '[pad] Throw if building pad for scalar input.',
|
||||
input: {dataType: 'float32', dimensions: []},
|
||||
beginningPadding: [],
|
||||
endingPadding: [],
|
||||
},
|
||||
{
|
||||
name:
|
||||
'[pad] Throw if the length of beginningPadding is not equal to the input rank.',
|
||||
input: {dataType: 'float32', dimensions: [2, 3]},
|
||||
beginningPadding: [1],
|
||||
endingPadding: [1, 2],
|
||||
options: {
|
||||
mode: 'edge',
|
||||
value: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
name:
|
||||
'[pad] Throw if the length of endingPadding is not equal to the input rank.',
|
||||
input: {dataType: 'float32', dimensions: [2, 3]},
|
||||
beginningPadding: [1, 0],
|
||||
endingPadding: [1, 2, 0],
|
||||
options: {
|
||||
mode: 'reflection',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: '[pad] Throw if the padding of one dimension is too large.',
|
||||
input: {dataType: 'float32', dimensions: [2, 3]},
|
||||
beginningPadding: [2294967295, 0],
|
||||
endingPadding: [3294967295, 2],
|
||||
options: {
|
||||
mode: 'reflection',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
tests.forEach(
|
||||
test => promise_test(async t => {
|
||||
const input = builder.input(
|
||||
'input',
|
||||
{dataType: test.input.dataType, dimensions: test.input.dimensions});
|
||||
if (test.output) {
|
||||
const output = builder.pad(
|
||||
input, test.beginningPadding, test.endingPadding, test.options);
|
||||
assert_equals(output.dataType(), test.output.dataType);
|
||||
assert_array_equals(output.shape(), test.output.dimensions);
|
||||
} else {
|
||||
assert_throws_js(
|
||||
TypeError,
|
||||
() => builder.pad(
|
||||
input, test.beginningPadding, test.endingPadding,
|
||||
test.options));
|
||||
}
|
||||
}, test.name));
|
||||
|
Loading…
x
Reference in New Issue
Block a user