From 6fd403fb141285c6453e9adb71d15d0541c40f3a Mon Sep 17 00:00:00 2001 From: Wanming Lin Date: Wed, 29 Nov 2023 09:43:47 +0800 Subject: [PATCH] Drop null for reshape op --- face_recognition/facenet_nhwc.js | 2 +- facial_landmark_detection/face_landmark_nchw.js | 2 +- facial_landmark_detection/face_landmark_nhwc.js | 2 +- image_classification/mobilenet_nchw.js | 2 +- image_classification/mobilenet_nhwc.js | 2 +- image_classification/resnet50v2_nchw.js | 4 ++-- image_classification/resnet50v2_nhwc.js | 2 +- image_classification/squeezenet_nchw.js | 2 +- image_classification/squeezenet_nhwc.js | 2 +- lenet/lenet.js | 4 ++-- rnnoise/rnnoise.js | 6 +++--- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/face_recognition/facenet_nhwc.js b/face_recognition/facenet_nhwc.js index b2dd7f8d..b365439d 100644 --- a/face_recognition/facenet_nhwc.js +++ b/face_recognition/facenet_nhwc.js @@ -109,7 +109,7 @@ export class FaceNetNhwc { } async buildFullyConnected_(input) { - input = this.builder_.reshape(input, [1, null]); + input = this.builder_.reshape(input, [1, 1792]); const weights = await buildConstantByNpy(this.builder_, `${this.weightsUrl_}/Bottleneck_kernel_transpose.npy`); const bias = await buildConstantByNpy(this.builder_, diff --git a/facial_landmark_detection/face_landmark_nchw.js b/facial_landmark_detection/face_landmark_nchw.js index 59481c8b..16c1aba8 100644 --- a/facial_landmark_detection/face_landmark_nchw.js +++ b/facial_landmark_detection/face_landmark_nchw.js @@ -54,7 +54,7 @@ export class FaceLandmarkNchw { if (reshapeSize !== undefined) { gemm = this.builder_.gemm(this.builder_.reshape( this.builder_.transpose(await input, {permutation: [0, 2, 3, 1]}), - [null, reshapeSize]), await weights, options); + [1, reshapeSize]), await weights, options); } else { gemm = this.builder_.gemm(await input, await weights, options); } diff --git a/facial_landmark_detection/face_landmark_nhwc.js b/facial_landmark_detection/face_landmark_nhwc.js index 1e5f791c..3c9d6ba1 100644 --- a/facial_landmark_detection/face_landmark_nhwc.js +++ b/facial_landmark_detection/face_landmark_nhwc.js @@ -55,7 +55,7 @@ export class FaceLandmarkNhwc { let fc; if (reshapeSize !== undefined) { fc = this.builder_.gemm(this.builder_.reshape( - await input, [null, reshapeSize]), await weights, options); + await input, [1, reshapeSize]), await weights, options); } else { fc = this.builder_.gemm(await input, await weights, options); } diff --git a/image_classification/mobilenet_nchw.js b/image_classification/mobilenet_nchw.js index c5b6b294..efbbcba9 100644 --- a/image_classification/mobilenet_nchw.js +++ b/image_classification/mobilenet_nchw.js @@ -123,7 +123,7 @@ export class MobileNetV2Nchw { const conv3 = await this.buildConv_(bottleneck15, '95', true); const pool = this.builder_.averagePool2d(conv3); - const reshape = this.builder_.reshape(pool, [1, null]); + const reshape = this.builder_.reshape(pool, [1, 1280]); const gemm = await this.buildGemm_(reshape, '104'); return this.builder_.softmax(gemm); } diff --git a/image_classification/mobilenet_nhwc.js b/image_classification/mobilenet_nhwc.js index e1c4ec31..cce96cfb 100644 --- a/image_classification/mobilenet_nhwc.js +++ b/image_classification/mobilenet_nhwc.js @@ -121,7 +121,7 @@ export class MobileNetV2Nhwc { conv3, {windowDimensions: [7, 7], layout: 'nhwc'}); const conv4 = await this.buildConv_( averagePool2d, '222', 'Logits_Conv2d_1c_1x1_Conv2D', false, {autoPad, filterLayout}); - const reshape = this.builder_.reshape(conv4, [1, null]); + const reshape = this.builder_.reshape(conv4, [1, 1001]); return this.builder_.softmax(reshape); } diff --git a/image_classification/resnet50v2_nchw.js b/image_classification/resnet50v2_nchw.js index 5ff362ae..ceba8bb9 100644 --- a/image_classification/resnet50v2_nchw.js +++ b/image_classification/resnet50v2_nchw.js @@ -63,7 +63,7 @@ export class ResNet50V2Nchw { const biasName = prefix + '_bias.npy'; const bias = await buildConstantByNpy(this.builder_, biasName); const options = - {c: this.builder_.reshape(bias, [1, null]), bTranspose: true}; + {c: this.builder_.reshape(bias, [1, 1000]), bTranspose: true}; return this.builder_.gemm(input, weight, options); } @@ -148,7 +148,7 @@ export class ResNet50V2Nchw { const bn3 = await this.buildBatchNorm_(bottleneck16, '2', ''); const pool2 = await this.builder_.averagePool2d(bn3); - const reshape = this.builder_.reshape(pool2, [1, null]); + const reshape = this.builder_.reshape(pool2, [1, 2048]); const gemm = await this.buildGemm_(reshape, '0'); return this.builder_.softmax(gemm); } diff --git a/image_classification/resnet50v2_nhwc.js b/image_classification/resnet50v2_nhwc.js index 9f224293..7118baf0 100644 --- a/image_classification/resnet50v2_nhwc.js +++ b/image_classification/resnet50v2_nhwc.js @@ -154,7 +154,7 @@ export class ResNet50V2Nhwc { const mean = this.builder_.averagePool2d(fusedBn, {layout}); const conv2 = await this.buildConv_( mean, ['', '', 'logits'], {autoPad}, false); - const reshape = this.builder_.reshape(conv2, [1, null]); + const reshape = this.builder_.reshape(conv2, [1, 1001]); return this.builder_.softmax(reshape); } diff --git a/image_classification/squeezenet_nchw.js b/image_classification/squeezenet_nchw.js index 1e4884ea..5373f53c 100644 --- a/image_classification/squeezenet_nchw.js +++ b/image_classification/squeezenet_nchw.js @@ -65,7 +65,7 @@ export class SqueezeNetNchw { const conv25 = await this.buildConv_(fire7, 'conv25'); const pool3 = this.builder_.averagePool2d( conv25, {windowDimensions: [13, 13], strides: [13, 13]}); - const reshape0 = this.builder_.reshape(pool3, [1, null]); + const reshape0 = this.builder_.reshape(pool3, [1, 1000]); return this.builder_.softmax(reshape0); } diff --git a/image_classification/squeezenet_nhwc.js b/image_classification/squeezenet_nhwc.js index 6f73394c..5f186457 100644 --- a/image_classification/squeezenet_nhwc.js +++ b/image_classification/squeezenet_nhwc.js @@ -69,7 +69,7 @@ export class SqueezeNetNhwc { const conv10 = await this.buildConv_(fire9, 'conv10'); const averagePool2d = this.builder_.averagePool2d( conv10, {windowDimensions: [13, 13], layout}); - const reshape = this.builder_.reshape(averagePool2d, [1, null]); + const reshape = this.builder_.reshape(averagePool2d, [1, 1001]); return this.builder_.softmax(reshape); } diff --git a/lenet/lenet.js b/lenet/lenet.js index 2b9657e3..2cc2c54f 100644 --- a/lenet/lenet.js +++ b/lenet/lenet.js @@ -77,7 +77,7 @@ export class LeNet { this.builder_.maxPool2d(add2, {windowDimensions: pool2WindowShape, strides: pool2Strides}); - const reshape1Shape = [1, null]; + const reshape1Shape = [1, 800]; const reshape1 = this.builder_.reshape(pool2, reshape1Shape); // skip the new shape, 2 int64 values @@ -100,7 +100,7 @@ export class LeNet { const relu = this.builder_.relu(add3); - const reshape2Shape = [1, null]; + const reshape2Shape = [1, 500]; const reshape2 = this.builder_.reshape(relu, reshape2Shape); const matmul2Shape = [10, 500]; diff --git a/rnnoise/rnnoise.js b/rnnoise/rnnoise.js index 382c7e13..441d79cb 100644 --- a/rnnoise/rnnoise.js +++ b/rnnoise/rnnoise.js @@ -84,7 +84,7 @@ export class RNNoise { const vadGruYTransposed = this.builder_.transpose( vadGruY, {permutation: [2, 0, 1, 3]}); const vadGruTranspose1 = this.builder_.reshape( - vadGruYTransposed, [null, this.frames_, this.vadGruHiddenSize]); + vadGruYTransposed, [1, this.frames_, this.vadGruHiddenSize]); const concatenate1 = this.builder_.concat( [inputDenseTanh0, vadGruTranspose1, input], 2); const noiseGruX = this.builder_.transpose( @@ -112,7 +112,7 @@ export class RNNoise { const noiseGruYTransposed = this.builder_.transpose( noiseGruY, {permutation: [2, 0, 1, 3]}); const noiseGruTranspose1 = this.builder_.reshape( - noiseGruYTransposed, [null, this.frames_, this.noiseGruHiddenSize]); + noiseGruYTransposed, [1, this.frames_, this.noiseGruHiddenSize]); const concatenate2 = this.builder_.concat( [vadGruTranspose1, noiseGruTranspose1, input], 2); const denoiseGruX = this.builder_.transpose( @@ -140,7 +140,7 @@ export class RNNoise { const denoiseGruYTransposed = this.builder_.transpose( denoiseGruY, {permutation: [2, 0, 1, 3]}); const denoiseGruTranspose1 = this.builder_.reshape( - denoiseGruYTransposed, [null, this.frames_, this.denoiseGruHiddenSize]); + denoiseGruYTransposed, [1, this.frames_, this.denoiseGruHiddenSize]); const denoiseOutput0 = this.builder_.matmul( denoiseGruTranspose1, denoiseOutputKernel0); const biasedTensorName = this.builder_.add(