From 44dd3de98535236dff597db2363dc71004724991 Mon Sep 17 00:00:00 2001 From: Alex Black Date: Thu, 29 Mar 2018 15:10:47 +1100 Subject: [PATCH] Additional util method for Shape class (#2799) --- .../java/org/nd4j/linalg/api/shape/Shape.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/shape/Shape.java b/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/shape/Shape.java index 728c5d1b62..1dabfe3164 100644 --- a/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/shape/Shape.java +++ b/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/shape/Shape.java @@ -2598,4 +2598,19 @@ public static boolean areShapesBroadcastable(@NonNull int[] x, @NonNull int[] y) return true; } + + + public static boolean hasDefaultStridesForShape(INDArray input){ + if(!strideDescendingCAscendingF(input)){ + return false; + } + char order = input.ordering(); + int[] defaultStrides; + if(order == 'f'){ + defaultStrides = ArrayUtil.calcStridesFortran(input.shape()); + } else { + defaultStrides = ArrayUtil.calcStrides(input.shape()); + } + return Arrays.equals(input.stride(), defaultStrides); + } }