From 65ff18383a641e2d760b56e0eb4884ca1f9cc20b Mon Sep 17 00:00:00 2001 From: Alex Black Date: Fri, 16 Aug 2019 14:19:06 +1000 Subject: [PATCH] InferenceSession additional validation for shape calc (#122) Signed-off-by: Alex Black --- .../org/nd4j/autodiff/samediff/internal/InferenceSession.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/internal/InferenceSession.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/internal/InferenceSession.java index a98b03566..3d40e205a 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/internal/InferenceSession.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/autodiff/samediff/internal/InferenceSession.java @@ -682,6 +682,8 @@ public class InferenceSession extends AbstractSession outShape = customOp.calculateOutputShape(); Preconditions.checkState(outShape != null && outShape.size() > 0, "Failed to calculate output shapes for op %s (%s) - no shapes were returned by calculateOutputShape()", customOp.opName(), customOp.getOwnName()); String[] outNames = df.outputVariablesNames(); + Preconditions.checkState(outNames.length == outShape.size(), "Error in operation shape calculation for op \"%s\": Got %s op output shapes for an operation" + + " with %s outputs (number of shapes and outputs must be equal)", df.opName(), outShape.size(), outNames.length); for( int i=0; i