summaryrefslogtreecommitdiffstats
path: root/vespajlib
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-12-13 11:26:10 +0100
committerJon Bratseth <bratseth@yahoo-inc.com>2016-12-13 11:26:10 +0100
commitfc0e1c6a4060f6786d885778aac5e3d68ec765b1 (patch)
treeb63572758cf14c0cf284afde00e91334ac2405d7 /vespajlib
parent8fae5c29b9e0e25229e8e62de7cdc65b6d6efc1d (diff)
Minor cleanup
Diffstat (limited to 'vespajlib')
-rw-r--r--vespajlib/src/test/java/com/yahoo/tensor/TensorFunctionBenchmark.java12
1 files changed, 2 insertions, 10 deletions
diff --git a/vespajlib/src/test/java/com/yahoo/tensor/TensorFunctionBenchmark.java b/vespajlib/src/test/java/com/yahoo/tensor/TensorFunctionBenchmark.java
index 230a9a89ba9..ccc43c3e73a 100644
--- a/vespajlib/src/test/java/com/yahoo/tensor/TensorFunctionBenchmark.java
+++ b/vespajlib/src/test/java/com/yahoo/tensor/TensorFunctionBenchmark.java
@@ -36,7 +36,6 @@ public class TensorFunctionBenchmark {
private double dotProduct(Tensor tensor, List<Tensor> tensors) {
double largest = Double.MIN_VALUE;
- // TODO: Build function before applying, support context
TensorFunction dotProductFunction = new Reduce(new Join(new ConstantTensor(tensor),
new VariableTensor("argument"), (a, b) -> a * b),
Reduce.Aggregator.max).toPrimitive();
@@ -45,9 +44,6 @@ public class TensorFunctionBenchmark {
for (Tensor tensorElement : tensors) { // tensors.size() = 1 for larger tensor
context.put("argument", tensorElement);
double dotProduct = dotProductFunction.evaluate(context).asDouble();
- // Tensor result = tensor.join(tensorElement, (a, b) -> a * b).reduce(Reduce.Aggregator.sum, "x");
-
- //double dotProduct = result.reduce(Reduce.Aggregator.max).asDouble(); // for larger tensor
if (dotProduct > largest) {
largest = dotProduct;
}
@@ -81,7 +77,6 @@ public class TensorFunctionBenchmark {
private static List<Tensor> generateMatrix(int vectorCount, int vectorSize,
TensorType.Dimension.Type dimensionType) {
- List<Tensor> tensors = new ArrayList<>();
TensorType type = new TensorType.Builder().dimension("i", dimensionType).dimension("x", dimensionType).build();
// TODO: Avoid this by creating a (type independent) Tensor.Builder
if (dimensionType == TensorType.Dimension.Type.mapped) {
@@ -94,7 +89,7 @@ public class TensorFunctionBenchmark {
.value(random.nextDouble());
}
}
- tensors.add(builder.build());
+ return Collections.singletonList(builder.build());
}
else {
IndexedTensor.Builder builder = new IndexedTensor.Builder(type);
@@ -103,13 +98,10 @@ public class TensorFunctionBenchmark {
builder.set(random.nextDouble(), i, j);
}
}
- tensors.add(builder.build());
+ return Collections.singletonList(builder.build());
}
- return tensors; // only one tensor in the list.
}
-
-
public static void main(String[] args) {
double time;