Add documentation for InPlace return behaviours
@@ -506,12 +506,16 @@ public class Nd4jDoubleTensor implements DoubleTensor {
return this;
}
+ /**
+ * @param that Right operand.
+ * @return A new DoubleTensor instance only if <i>this</i> has a length of 1 and right operand has a length greater than 1.
+ * Otherwise return <i>this</i>.
+ */
@Override
public DoubleTensor minusInPlace(DoubleTensor that) {
if (that.isScalar()) {
tensor.subi(that.scalar());
} else if (this.isScalar()) {
- // Temporary fix: Scalar can't be subtracted by tensor inplace
return this.minus(that);
} else {
INDArrayShim.subi(tensor, unsafeGetNd4J(that), tensor);
@@ -519,12 +523,16 @@ public class Nd4jDoubleTensor implements DoubleTensor {
return this;
}
+ /**
+ * @param that Right operand.
+ * @return A new DoubleTensor instance only if <i>this</i> has a length of 1 and right operand has a length greater than 1.
+ * Otherwise return <i>this</i>.
+ */
@Override
public DoubleTensor plusInPlace(DoubleTensor that) {
if (that.isScalar()) {
tensor.addi(that.scalar());
} else if (this.isScalar()) {
- // Temporary fix: Scalar can't be added by tensor inplace
return this.plus(that);
} else {
INDArrayShim.addi(tensor, unsafeGetNd4J(that), tensor);
@@ -532,12 +540,16 @@ public class Nd4jDoubleTensor implements DoubleTensor {
return this;
}
+ /**
+ * @param that Right operand.
+ * @return A new DoubleTensor instance only if <i>this</i> has a length of 1 and right operand has a length greater than 1.
+ * Otherwise return <i>this</i>.
+ */
@Override
public DoubleTensor timesInPlace(DoubleTensor that) {
if (that.isScalar()) {
tensor.muli(that.scalar());
} else if (this.isScalar()) {
- // Temporary fix: Scalar can't be multiplied by tensor inplace
return this.times(that);
} else {
INDArrayShim.muli(tensor, unsafeGetNd4J(that), tensor);
@@ -545,12 +557,16 @@ public class Nd4jDoubleTensor implements DoubleTensor {
return this;
}
+ /**
+ * @param that Right operand.
+ * @return A new DoubleTensor instance only if <i>this</i> has a length of 1 and right operand has a length greater than 1.
+ * Otherwise return <i>this</i>.
+ */
@Override
public DoubleTensor divInPlace(DoubleTensor that) {
if (that.isScalar()) {
tensor.divi(that.scalar());
} else if (this.isScalar()) {
- // Temporary fix: Scalar can't be divided by tensor inplace
return this.div(that);
} else {
INDArrayShim.divi(tensor, unsafeGetNd4J(that), tensor);
