From a0e1c8e360a455bdd9f8bb01c2ce2dba9760d6c3 Mon Sep 17 00:00:00 2001 From: Ann Yuan Date: Thu, 23 Apr 2020 21:31:23 -0400 Subject: [PATCH 1/2] add test --- tfjs-core/src/ops/conv2d_test.ts | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tfjs-core/src/ops/conv2d_test.ts b/tfjs-core/src/ops/conv2d_test.ts index 4cc8ad49b46..bec2703bece 100644 --- a/tfjs-core/src/ops/conv2d_test.ts +++ b/tfjs-core/src/ops/conv2d_test.ts @@ -328,18 +328,23 @@ describeWithFlags('conv2d', ALL_ENVS, () => { const pad = 'same'; const stride: [number, number] = [2, 2]; - const inputs = generateCaseInputs( - 1 * xSize * xSize * inputDepth, fSize * fSize * inputDepth); - const x = tf.tensor4d(inputs.input, inputShape); - const w = - tf.tensor4d(inputs.filter, [fSize, fSize, inputDepth, outputDepth]); - + const inputData = []; + for (let i = 0; i < xSize * xSize * inputDepth; i++) { + inputData.push(i % 5); + } + + const wData = []; + for (let i = 0; i < fSize * fSize * inputDepth * outputDepth; i++) { + wData.push(i % 5); + } + + const x = tf.tensor4d(inputData, inputShape); + const w = tf.tensor4d(wData, [fSize, fSize, inputDepth, outputDepth]); const result = tf.conv2d(x, w, stride, pad); expect(result.shape).toEqual([1, 4, 4, 1]); expectArraysClose(await result.data(), new Float32Array([ - 2209560, 2543640, 2877720, 1890576, 4882200, 5216280, - 5550360, 3475728, 7554840, 7888920, 8223000, 5060880, - 4153744, 4302736, 4451728, 2551904 + 854, 431, 568, 382, 580, 427, 854, 288, 431, 568, 580, + 289, 285, 570, 285, 258 ])); }); From 2424ee843ee6e07d0024ab648bb0a79114d919c7 Mon Sep 17 00:00:00 2001 From: Ann Yuan Date: Fri, 24 Apr 2020 13:27:44 -0400 Subject: [PATCH 2/2] add issue link --- tfjs-core/src/ops/conv2d_test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tfjs-core/src/ops/conv2d_test.ts b/tfjs-core/src/ops/conv2d_test.ts index bec2703bece..b74f97cd0e5 100644 --- a/tfjs-core/src/ops/conv2d_test.ts +++ b/tfjs-core/src/ops/conv2d_test.ts @@ -328,6 +328,8 @@ describeWithFlags('conv2d', ALL_ENVS, () => { const pad = 'same'; const stride: [number, number] = [2, 2]; + // TODO(annxingyuan): Make this test work with large inputs using + // generateCaseInputs https://github.com/tensorflow/tfjs/issues/3143 const inputData = []; for (let i = 0; i < xSize * xSize * inputDepth; i++) { inputData.push(i % 5);