add a better validator on index
@@ -112,6 +112,11 @@ public class TensorShapeValidation {
}
public static void checkIndexIsValid(int[] shape, int... index) {
+ if (shape.length != index.length) {
+ throw new IllegalArgumentException(
+ "Length of desired index " + Arrays.toString(index) + " must match the length of the shape " + Arrays.toString(shape));
+ }
+
for (int i = 0; i < index.length; i++) {
if (index[i] >= shape[i]) {
