From db53c2f57712809c45de75a615237ee91c1df906 Mon Sep 17 00:00:00 2001 From: BruceDai Date: Thu, 23 Mar 2023 17:27:57 +0800 Subject: [PATCH] Update newShape with null value for reshape operation --- index.bs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/index.bs b/index.bs index ea1350bd..5c972994 100644 --- a/index.bs +++ b/index.bs @@ -1187,7 +1187,7 @@ partial interface MLGraphBuilder {
The behavior of this operation when the input tensor is 4-D of the *"nchw"* layout and the activation is of operator type *relu* can be generically emulated from the usage of other operations as follow. However, user agents typically have a more efficient implementation for it, therefore its usage is encouraged from the performance standpoint.
-    const shape = [1,-1,1,1];
+    const shape = [1,null,1,1];
     return builder.relu(
       builder.add(
         builder.mul(
@@ -1672,7 +1672,7 @@ partial interface MLGraphBuilder {
             currentHidden[dir], hiddenSize, { bias: currentBias[dir],
             recurrentBias: currentRecurrentBias[dir], resetAfter: options.resetAfter,
             layout: options.layout, activations: options.activations }),
-          [1, -1, hiddenSize]);
+          [1, null, hiddenSize]);
 
         currentOutput = (currentOutput ? builder.concat([currentOutput, result], 0) : result);
       }
@@ -1680,7 +1680,7 @@ partial interface MLGraphBuilder {
       hiddenState = currentOutput;
 
       if (options.returnSequence) {
-        currentOutput = builder.reshape(currentOutput, [1, numDirections, -1, hiddenSize]);
+        currentOutput = builder.reshape(currentOutput, [1, numDirections, null, hiddenSize]);
         sequence = (sequence ? builder.concat([sequence, currentOutput], 0) : currentOutput);
       }
     }
@@ -1941,7 +1941,7 @@ partial interface MLGraphBuilder {
 
     // The scale and bias values are applied per input feature
     // e.g. axis 1 of the input tensor.
-    const shape = [1,-1,1,1];
+    const shape = [1,null,1,1];
     return builder.add(
       builder.mul(
         builder.reshape(options.scale, shape),
@@ -2132,8 +2132,8 @@ partial interface MLGraphBuilder {
           recurrentBias: currentRecurrentBias[dir], peepholeWeight: currentPeepholeWeight[dir],
           layout: options.layout, activations: options.activations });
 
-        let output = builder.reshape(results[0], [1, -1, hiddenSize]);
-        let cell = builder.reshape(results[1], [1, -1, hiddenSize]);
+        let output = builder.reshape(results[0], [1, null, hiddenSize]);
+        let cell = builder.reshape(results[1], [1, null, hiddenSize]);
 
         nextHidden = (nextHidden ? builder.concat([nextHidden, result], 0) : output);
         nextCell = (nextCell ? builder.concat([nextCell, result], 0) : cell);
@@ -2143,7 +2143,7 @@ partial interface MLGraphBuilder {
       cellState = nextCell;
 
       if (options.returnSequence) {
-        nextHidden = builder.reshape(nextHidden, [1, numDirections, -1, hiddenSize]);
+        nextHidden = builder.reshape(nextHidden, [1, numDirections, null, hiddenSize]);
         sequence = (sequence ? builder.concat([sequence, nextHidden], 0) : nextHidden);
       }
     }