Program: 3162
Project: 3162
Buggy source:
@Test public void testMulGradient(){
  INDArray arr1=Nd4j.linspace(1,4,4).reshape(2,2);
  INDArray arr2=Nd4j.linspace(1,4,4).reshape(2,2);
  INDArray gradAssertion=Nd4j.ones(arr1.shape());
  INDArray scalar=Nd4j.scalar(1.0);
  INDArray aGradAssertion=Nd4j.create(new double[][]{{1,4},{9,16}});
  INDArray cGradAssertion=Nd4j.create(new double[][]{{1,2},{3,4}});
  INDArray wGradAssertion=Nd4j.create(new double[][]{{2,8},{18,32}});
  INDArray dGradAssertion=Nd4j.ones(2,2);
  SameDiff sameDiff=SameDiff.create();
  SDVariable sdVariable=sameDiff.var("String_Node_Str",arr1);
  SDVariable sdVariable1=sameDiff.var("String_Node_Str",arr2);
  SDVariable varMulPre=sdVariable.mul("String_Node_Str",sdVariable1);
  SDVariable varMul=varMulPre.mul("String_Node_Str",sdVariable1);
  SDVariable sum=sameDiff.sum("String_Node_Str",varMul,Integer.MAX_VALUE);
  sameDiff.execBackwards();
  SDVariable finalResult=sameDiff.grad(sum.getVarName());
  SDVariable cGrad=sameDiff.grad(varMulPre.getVarName());
  SDVariable mulGradResult=sameDiff.grad(varMul.getVarName());
  SDVariable aGrad=sameDiff.grad(sdVariable.getVarName());
  SDVariable wGrad=sameDiff.grad(sdVariable1.getVarName());
  SDVariable dGrad=sameDiff.grad(varMul.getVarName());
  INDArray scalarGradTest=finalResult.getArr();
  assertEquals(scalar,scalarGradTest);
  INDArray gradTest=mulGradResult.getArr();
  assertEquals(gradAssertion,gradTest);
  INDArray aGradTest=aGrad.getArr();
  assertEquals(aGradAssertion,aGradTest);
  INDArray cGradTest=cGrad.getArr();
  assertEquals(cGradAssertion,cGradTest);
  INDArray wGradTest=wGrad.getArr();
  assertEquals(wGradAssertion,wGradTest);
  INDArray dGradTest=dGrad.getArr();
  assertEquals(dGradAssertion,dGradTest);
}

Fixed version (ground truth):
@Test public void testMulGradient(){
  INDArray arr1=Nd4j.linspace(1,4,4).reshape(2,2);
  INDArray arr2=Nd4j.linspace(1,4,4).reshape(2,2);
  INDArray gradAssertion=Nd4j.ones(arr1.shape());
  INDArray scalar=Nd4j.scalar(1.0);
  INDArray aGradAssertion=Nd4j.create(new double[][]{{1,4},{9,16}});
  INDArray cGradAssertion=Nd4j.create(new double[][]{{1,2},{3,4}});
  INDArray wGradAssertion=Nd4j.create(new double[][]{{2,8},{18,32}});
  INDArray dGradAssertion=Nd4j.ones(2,2);
  SameDiff sameDiff=SameDiff.create();
  SDVariable sdVariable=sameDiff.var("String_Node_Str",arr1);
  SDVariable sdVariable1=sameDiff.var("String_Node_Str",arr2);
  SDVariable varMulPre=sdVariable.mul("String_Node_Str",sdVariable1);
  SDVariable varMul=varMulPre.mul("String_Node_Str",sdVariable1);
  SDVariable sum=sameDiff.sum("String_Node_Str",varMul,Integer.MAX_VALUE);
  Pair<Map<SDVariable,Op>,List<Op>> mapListPair=sameDiff.execBackwards();
  SDVariable finalResult=sameDiff.grad(sum.getVarName());
  SDVariable cGrad=sameDiff.grad(varMulPre.getVarName());
  SDVariable mulGradResult=sameDiff.grad(varMul.getVarName());
  SDVariable aGrad=sameDiff.grad(sdVariable.getVarName());
  SDVariable wGrad=sameDiff.grad(sdVariable1.getVarName());
  SDVariable dGrad=sameDiff.grad(varMul.getVarName());
  INDArray scalarGradTest=finalResult.getArr();
  assertEquals(scalar,scalarGradTest);
  INDArray gradTest=mulGradResult.getArr();
  assertEquals(gradAssertion,gradTest);
  INDArray aGradTest=aGrad.getArr();
  assertEquals(aGradAssertion,aGradTest);
  INDArray cGradTest=cGrad.getArr();
  assertEquals(cGradAssertion,cGradTest);
  INDArray wGradTest=wGrad.getArr();
  assertEquals(wGradAssertion,wGradTest);
  INDArray dGradTest=dGrad.getArr();
  assertEquals(dGradAssertion,dGradTest);
}