Skip to content

Commit 3ff4c45

Browse files
committed
improve error message
1 parent ebf64f9 commit 3ff4c45

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/io/bioimage/modelrunner/onnx/tensor/TensorBuilder.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private static OnnxTensor buildByte(RandomAccessibleInterval<ByteType> tensor, O
126126
long[] ogShape = tensor.dimensionsAsLongArray();
127127
if (CommonUtils.int32Overflows(ogShape, 1))
128128
throw new IllegalArgumentException("Provided tensor with shape " + Arrays.toString(ogShape)
129-
+ " is too big. Max number of elements per tensor supported: " + Integer.MAX_VALUE);
129+
+ " is too big. Max number of elements per byte tensor supported: " + Integer.MAX_VALUE);
130130
tensor = Utils.transpose(tensor);
131131
long[] tensorShape = tensor.dimensionsAsLongArray();
132132
int size = 1;
@@ -164,7 +164,7 @@ private static OnnxTensor buildInt(RandomAccessibleInterval<IntType> tensor, Ort
164164
long[] ogShape = tensor.dimensionsAsLongArray();
165165
if (CommonUtils.int32Overflows(ogShape, 4))
166166
throw new IllegalArgumentException("Provided tensor with shape " + Arrays.toString(ogShape)
167-
+ " is too big. Max number of elements per tensor supported: " + Integer.MAX_VALUE / 4);
167+
+ " is too big. Max number of elements per int tensor supported: " + Integer.MAX_VALUE / 4);
168168
tensor = Utils.transpose(tensor);
169169
long[] tensorShape = tensor.dimensionsAsLongArray();
170170
int size = 1;
@@ -202,7 +202,7 @@ private static OnnxTensor buildFloat(RandomAccessibleInterval<FloatType> tensor,
202202
long[] ogShape = tensor.dimensionsAsLongArray();
203203
if (CommonUtils.int32Overflows(ogShape, 4))
204204
throw new IllegalArgumentException("Provided tensor with shape " + Arrays.toString(ogShape)
205-
+ " is too big. Max number of elements per tensor supported: " + Integer.MAX_VALUE / 4);
205+
+ " is too big. Max number of elements per float tensor supported: " + Integer.MAX_VALUE / 4);
206206
tensor = Utils.transpose(tensor);
207207
long[] tensorShape = tensor.dimensionsAsLongArray();
208208
int size = 1;
@@ -240,7 +240,7 @@ private static OnnxTensor buildDouble(RandomAccessibleInterval<DoubleType> tenso
240240
long[] ogShape = tensor.dimensionsAsLongArray();
241241
if (CommonUtils.int32Overflows(ogShape, 8))
242242
throw new IllegalArgumentException("Provided tensor with shape " + Arrays.toString(ogShape)
243-
+ " is too big. Max number of elements per tensor supported: " + Integer.MAX_VALUE / 8);
243+
+ " is too big. Max number of elements per double tensor supported: " + Integer.MAX_VALUE / 8);
244244
tensor = Utils.transpose(tensor);
245245
long[] tensorShape = tensor.dimensionsAsLongArray();
246246
int size = 1;

0 commit comments

Comments
 (0)