[Java] Allow 0 value dimension
authorYelin Jeong <yelini.jeong@samsung.com>
Fri, 29 Mar 2024 07:19:44 +0000 (16:19 +0900)
committerwooksong <wook16.song@samsung.com>
Fri, 29 Mar 2024 08:28:36 +0000 (17:28 +0900)
This patch allows 0 value dimension in setDimension function.

Signed-off-by: Yelin Jeong <yelini.jeong@samsung.com>
java/android/nnstreamer/src/main/java/org/nnsuite/nnstreamer/TensorsInfo.java

index e93ab5f..956d13d 100644 (file)
@@ -272,7 +272,7 @@ public final class TensorsInfo implements AutoCloseable, Cloneable {
             }
 
             for (int dim : dimension) {
-                if (dim <= 0) {
+                if (dim < 0) {
                     throw new IllegalArgumentException("The dimension should be a positive value");
                 }
             }
@@ -281,7 +281,7 @@ public final class TensorsInfo implements AutoCloseable, Cloneable {
 
             /* fill default value */
             for (int i = rank; i < NNStreamer.TENSOR_RANK_LIMIT; i++) {
-                this.dimension[i] = 1;
+                this.dimension[i] = 0;
             }
         }
 
@@ -317,6 +317,8 @@ public final class TensorsInfo implements AutoCloseable, Cloneable {
             }
 
             for (int i = 0; i < NNStreamer.TENSOR_RANK_LIMIT; i++) {
+                if (this.dimension[i] == 0)
+                    break;
                 size *= this.dimension[i];
             }