diff options
author | Jon Bratseth <bratseth@verizonmedia.com> | 2019-06-01 21:29:42 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@verizonmedia.com> | 2019-06-01 21:29:42 +0200 |
commit | b0d81ca0f7e3f9f97fcc2d7481adf13db82059f6 (patch) | |
tree | a437dc9e5274457468f0ee682167c7200c7d06c5 /vespajlib | |
parent | aa8f671cfc7a6ab990841fafba3207a6f5181a0f (diff) |
Update ABI spec and add javadocW
Diffstat (limited to 'vespajlib')
4 files changed, 46 insertions, 6 deletions
diff --git a/vespajlib/abi-spec.json b/vespajlib/abi-spec.json index 4f81f3baea8..9264b0a8255 100644 --- a/vespajlib/abi-spec.json +++ b/vespajlib/abi-spec.json @@ -788,7 +788,11 @@ ], "methods": [ "public static com.yahoo.tensor.IndexedTensor$Builder of(com.yahoo.tensor.TensorType)", + "public static com.yahoo.tensor.IndexedTensor$Builder of(com.yahoo.tensor.TensorType, float[])", + "public static com.yahoo.tensor.IndexedTensor$Builder of(com.yahoo.tensor.TensorType, double[])", "public static com.yahoo.tensor.IndexedTensor$Builder of(com.yahoo.tensor.TensorType, com.yahoo.tensor.DimensionSizes)", + "public static com.yahoo.tensor.IndexedTensor$Builder of(com.yahoo.tensor.TensorType, com.yahoo.tensor.DimensionSizes, float[])", + "public static com.yahoo.tensor.IndexedTensor$Builder of(com.yahoo.tensor.TensorType, com.yahoo.tensor.DimensionSizes, double[])", "public varargs abstract com.yahoo.tensor.IndexedTensor$Builder cell(double, long[])", "public varargs abstract com.yahoo.tensor.IndexedTensor$Builder cell(float, long[])", "public com.yahoo.tensor.TensorType type()", diff --git a/vespajlib/src/main/java/com/yahoo/tensor/IndexedDoubleTensor.java b/vespajlib/src/main/java/com/yahoo/tensor/IndexedDoubleTensor.java index e0cb3dca969..e644244178d 100644 --- a/vespajlib/src/main/java/com/yahoo/tensor/IndexedDoubleTensor.java +++ b/vespajlib/src/main/java/com/yahoo/tensor/IndexedDoubleTensor.java @@ -45,7 +45,8 @@ class IndexedDoubleTensor extends IndexedTensor { BoundDoubleBuilder(TensorType type, DimensionSizes sizes) { this(type, sizes, new double[(int)sizes.totalSize()]); } - BoundDoubleBuilder(TensorType type, DimensionSizes sizes, double [] values) { + + BoundDoubleBuilder(TensorType type, DimensionSizes sizes, double[] values) { super(type, sizes); this.values = values; } diff --git a/vespajlib/src/main/java/com/yahoo/tensor/IndexedFloatTensor.java b/vespajlib/src/main/java/com/yahoo/tensor/IndexedFloatTensor.java index 56cb22da7a5..30157d9791a 100644 --- a/vespajlib/src/main/java/com/yahoo/tensor/IndexedFloatTensor.java +++ b/vespajlib/src/main/java/com/yahoo/tensor/IndexedFloatTensor.java @@ -45,7 +45,8 @@ class IndexedFloatTensor extends IndexedTensor { BoundFloatBuilder(TensorType type, DimensionSizes sizes) { this(type, sizes, new float[(int)sizes.totalSize()]); } - BoundFloatBuilder(TensorType type, DimensionSizes sizes, float [] values) { + + BoundFloatBuilder(TensorType type, DimensionSizes sizes, float[] values) { super(type, sizes); if (sizes.totalSize() != values.length) { throw new IllegalArgumentException("Invalid size(" + values.length + ") of supplied value vector." + diff --git a/vespajlib/src/main/java/com/yahoo/tensor/IndexedTensor.java b/vespajlib/src/main/java/com/yahoo/tensor/IndexedTensor.java index b43993be732..a03131f3ec9 100644 --- a/vespajlib/src/main/java/com/yahoo/tensor/IndexedTensor.java +++ b/vespajlib/src/main/java/com/yahoo/tensor/IndexedTensor.java @@ -234,13 +234,29 @@ public abstract class IndexedTensor implements Tensor { else return new UnboundBuilder(type); } - public static Builder of(TensorType type, float [] values) { + + /** + * Creates a builder initialized with the given values + * + * @param type the type of the tensor to build + * @param values the initial values of the tensor. This <b>transfers ownership</b> of the value array - it + * must not be further mutated by the caller + */ + public static Builder of(TensorType type, float[] values) { if (type.dimensions().stream().allMatch(d -> d instanceof TensorType.IndexedBoundDimension)) return of(type, BoundBuilder.dimensionSizesOf(type), values); else return new UnboundBuilder(type); } - public static Builder of(TensorType type, double [] values) { + + /** + * Creates a builder initialized with the given values + * + * @param type the type of the tensor to build + * @param values the initial values of the tensor. This <b>transfers ownership</b> of the value array - it + * must not be further mutated by the caller + */ + public static Builder of(TensorType type, double[] values) { if (type.dimensions().stream().allMatch(d -> d instanceof TensorType.IndexedBoundDimension)) return of(type, BoundBuilder.dimensionSizesOf(type), values); else @@ -262,7 +278,15 @@ public abstract class IndexedTensor implements Tensor { else return new IndexedDoubleTensor.BoundDoubleBuilder(type, sizes); // Default } - public static Builder of(TensorType type, DimensionSizes sizes, float [] values) { + + /** + * Creates a builder initialized with the given values + * + * @param type the type of the tensor to build + * @param values the initial values of the tensor. This <b>transfers ownership</b> of the value array - it + * must not be further mutated by the caller + */ + public static Builder of(TensorType type, DimensionSizes sizes, float[] values) { validate(type, sizes); validateSizes(sizes, values.length); @@ -273,7 +297,15 @@ public abstract class IndexedTensor implements Tensor { else return new IndexedDoubleTensor.BoundDoubleBuilder(type, sizes).fill(values); // Default } - public static Builder of(TensorType type, DimensionSizes sizes, double [] values) { + + /** + * Creates a builder initialized with the given values + * + * @param type the type of the tensor to build + * @param values the initial values of the tensor. This <b>transfers ownership</b> of the value array - it + * must not be further mutated by the caller + */ + public static Builder of(TensorType type, DimensionSizes sizes, double[] values) { validate(type, sizes); validateSizes(sizes, values.length); @@ -284,12 +316,14 @@ public abstract class IndexedTensor implements Tensor { else return new IndexedDoubleTensor.BoundDoubleBuilder(type, sizes, values); // Default } + private static void validateSizes(DimensionSizes sizes, int length) { if (sizes.totalSize() != length) { throw new IllegalArgumentException("Invalid size(" + length + ") of supplied value vector." + " Type specifies that size should be " + sizes.totalSize()); } } + private static void validate(TensorType type, DimensionSizes sizes) { // validate if (sizes.dimensions() != type.dimensions().size()) |