Same tensor check on integer tensors
@@ -338,7 +338,10 @@ public class Nd4jIntegerTensor implements IntegerTensor {
if (that.isScalar()) {
tensor.subi(that.scalar());
} else {
- return new Nd4jIntegerTensor(INDArrayShim.subi(tensor, unsafeGetNd4J(that)));
+ INDArray result = INDArrayShim.subi(tensor, unsafeGetNd4J(that));
+ if (result != tensor) {
+ return new Nd4jIntegerTensor(result);
+ }
}
return this;
}
@@ -348,7 +351,10 @@ public class Nd4jIntegerTensor implements IntegerTensor {
if (that.isScalar()) {
tensor.addi(that.scalar());
} else {
- return new Nd4jIntegerTensor(INDArrayShim.addi(tensor, unsafeGetNd4J(that)));
+ INDArray result = INDArrayShim.addi(tensor, unsafeGetNd4J(that));
+ if (result != tensor) {
+ return new Nd4jIntegerTensor(result);
+ }
}
return this;
}
@@ -358,7 +364,10 @@ public class Nd4jIntegerTensor implements IntegerTensor {
if (that.isScalar()) {
tensor.muli(that.scalar());
} else {
- return new Nd4jIntegerTensor(INDArrayShim.muli(tensor, unsafeGetNd4J(that)));
+ INDArray result = INDArrayShim.muli(tensor, unsafeGetNd4J(that));
+ if (result != tensor) {
+ return new Nd4jIntegerTensor(result);
+ }
}
return this;
}
