diff options
author | Jon Bratseth <bratseth@verizonmedia.com> | 2019-04-03 22:41:18 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@verizonmedia.com> | 2019-04-03 22:41:18 +0200 |
commit | 8c23296c0feb1c418706f847c7b78ae926180859 (patch) | |
tree | 86cc0a3708f1cc026d2ab174d62bdb178f7b09e4 /vespajlib | |
parent | 437e4869d430aa30e4c1c9829b64c358bfc812fd (diff) |
Infer value type
Diffstat (limited to 'vespajlib')
-rw-r--r-- | vespajlib/abi-spec.json | 1 | ||||
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/tensor/TensorType.java | 12 | ||||
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/tensor/functions/Concat.java | 4 |
3 files changed, 8 insertions, 9 deletions
diff --git a/vespajlib/abi-spec.json b/vespajlib/abi-spec.json index b071566ae31..43388e4e18d 100644 --- a/vespajlib/abi-spec.json +++ b/vespajlib/abi-spec.json @@ -1164,7 +1164,6 @@ "public void <init>()", "public void <init>(com.yahoo.tensor.TensorType$Value)", "public varargs void <init>(com.yahoo.tensor.TensorType[])", - "public varargs void <init>(com.yahoo.tensor.TensorType$Value, com.yahoo.tensor.TensorType[])", "public void <init>(java.lang.Iterable)", "public void <init>(com.yahoo.tensor.TensorType$Value, java.lang.Iterable)", "public int rank()", diff --git a/vespajlib/src/main/java/com/yahoo/tensor/TensorType.java b/vespajlib/src/main/java/com/yahoo/tensor/TensorType.java index aaa25a0b058..df78f3dfc3a 100644 --- a/vespajlib/src/main/java/com/yahoo/tensor/TensorType.java +++ b/vespajlib/src/main/java/com/yahoo/tensor/TensorType.java @@ -4,6 +4,7 @@ package com.yahoo.tensor; import com.google.common.collect.ImmutableList; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.LinkedHashMap; @@ -410,7 +411,7 @@ public class TensorType { private final Value valueType; - /** Creates an empty builder with cells of type double*/ + /** Creates an empty builder with cells of type double */ public Builder() { this(Value.DOUBLE); } @@ -425,17 +426,16 @@ public class TensorType { * If the same dimension is indexed with different size restrictions the largest size will be used. * If it is size restricted in one argument but not the other it will not be size restricted. * If it is indexed in one and mapped in the other it will become mapped. + * + * The value type will be the largest of the value types of the input types */ public Builder(TensorType ... types) { - this(Value.DOUBLE, types); - } - public Builder(Value valueType, TensorType ... types) { - this.valueType = valueType; + this.valueType = TensorType.Value.largestOf(Arrays.stream(types).map(type -> type.valueType()).collect(Collectors.toList())); for (TensorType type : types) addDimensionsOf(type); } - /** Creates a builder from the given dimensions */ + /** Creates a builder from the given dimensions, having double as the value type */ public Builder(Iterable<Dimension> dimensions) { this(Value.DOUBLE, dimensions); } 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 a0a257bb909..a48ac19fbff 100644 --- a/vespajlib/src/main/java/com/yahoo/tensor/functions/Concat.java +++ b/vespajlib/src/main/java/com/yahoo/tensor/functions/Concat.java @@ -73,8 +73,8 @@ public class Concat extends PrimitiveTensorFunction { MutableLong concatSize = new MutableLong(0); a.sizeOfDimension(dimension).ifPresent(concatSize::add); b.sizeOfDimension(dimension).ifPresent(concatSize::add); - builder.set(TensorType.Dimension.indexed(dimension, concatSize.get())); - */ + builder.set(TensorType.Dimension.indexed(dimension, concatSize.get())); + */ } return builder.build(); } |