diff options
author | Lester Solbakken <lesters@yahoo-inc.com> | 2017-11-16 10:54:01 +0100 |
---|---|---|
committer | Lester Solbakken <lesters@yahoo-inc.com> | 2017-11-16 10:54:01 +0100 |
commit | ac09f9c90be29e19583d78649807a9587118741b (patch) | |
tree | 1fc7bd1779012abe0fe9b1a6c8bd60ca54e69456 /vespajlib | |
parent | 05adec4027b7af6954f42b5172792caf1d912827 (diff) |
Java tensors: support unequal size when concatenating
Diffstat (limited to 'vespajlib')
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/tensor/functions/Concat.java | 4 | ||||
-rw-r--r-- | vespajlib/src/test/java/com/yahoo/tensor/functions/ConcatTestCase.java | 7 |
2 files changed, 2 insertions, 9 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/tensor/functions/Concat.java b/vespajlib/src/main/java/com/yahoo/tensor/functions/Concat.java index 401f9a10eda..1dbb94fdb20 100644 --- a/vespajlib/src/main/java/com/yahoo/tensor/functions/Concat.java +++ b/vespajlib/src/main/java/com/yahoo/tensor/functions/Concat.java @@ -134,9 +134,7 @@ public class Concat extends PrimitiveTensorFunction { if (currentDimension.equals(concatDimension)) concatSizes.set(i, aSize + bSize); else if (aSize != 0 && bSize != 0 && aSize!=bSize ) - throw new IllegalArgumentException("Dimension " + currentDimension + " must be of the same size when " + - "concatenating " + a.type() + " and " + b.type() + " along dimension " + - concatDimension + ", but was " + aSize + " and " + bSize); + concatSizes.set(i, Math.min(aSize, bSize)); else concatSizes.set(i, Math.max(aSize, bSize)); } diff --git a/vespajlib/src/test/java/com/yahoo/tensor/functions/ConcatTestCase.java b/vespajlib/src/test/java/com/yahoo/tensor/functions/ConcatTestCase.java index a653ef97734..7e1f292eb7b 100644 --- a/vespajlib/src/test/java/com/yahoo/tensor/functions/ConcatTestCase.java +++ b/vespajlib/src/test/java/com/yahoo/tensor/functions/ConcatTestCase.java @@ -43,12 +43,7 @@ public class ConcatTestCase { Tensor a = Tensor.from("tensor(x[]):{ {x:0}:1, {x:1}:2 }"); Tensor b = Tensor.from("tensor(x[]):{ {x:0}:4, {x:1}:5, {x:2}:6 }"); assertEquals(Tensor.from("tensor(x[5]):{ {x:0}:1, {x:1}:2, {x:2}:4, {x:3}:5, {x:4}:6 }"), a.concat(b, "x")); - try { - a.concat(b, "y"); - fail("Expected exception"); - } catch (IllegalArgumentException expected) { - // success - } + assertEquals(Tensor.from("tensor(x[2],y[2]):{ {x:0,y:0}:1, {x:1,y:0}:2, {x:0,y:1}:4, {x:1,y:1}:5 }"), a.concat(b, "y")); } @Test |