summaryrefslogtreecommitdiffstats
path: root/model-integration/src
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2024-04-11 15:09:55 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2024-04-11 21:04:22 +0200
commit2d6bbe0b8bff09d105b77161c1d26a00ce43bf0c (patch)
treef9948a9904d837960887e81a956b29f92d918002 /model-integration/src
parent6923743ed320ce339727ad57f6fc2da5f82f5e3f (diff)
Unify on List.of
Diffstat (limited to 'model-integration/src')
-rw-r--r--model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Argument.java3
-rw-r--r--model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Constant.java3
-rw-r--r--model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/IntermediateOperation.java10
-rw-r--r--model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/NoOp.java3
-rw-r--r--model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/OnnxConstant.java3
-rw-r--r--model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Rename.java3
-rw-r--r--model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Softmax.java3
7 files changed, 11 insertions, 17 deletions
diff --git a/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Argument.java b/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Argument.java
index e985b6d2956..dbd17d96d4f 100644
--- a/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Argument.java
+++ b/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Argument.java
@@ -8,7 +8,6 @@ import com.yahoo.tensor.evaluation.VariableTensor;
import com.yahoo.tensor.functions.Rename;
import com.yahoo.tensor.functions.TensorFunction;
-import java.util.Collections;
import java.util.List;
public class Argument extends IntermediateOperation {
@@ -16,7 +15,7 @@ public class Argument extends IntermediateOperation {
private OrderedTensorType standardNamingType; // using standard naming convention: d0, d1, ...
public Argument(String modelName, String nodeName, OrderedTensorType type) {
- super(modelName, nodeName, Collections.emptyList());
+ super(modelName, nodeName, List.of());
this.type = type.rename(vespaName() + "_");
standardNamingType = OrderedTensorType.standardType(type);
}
diff --git a/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Constant.java b/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Constant.java
index 91c46d1232e..1d430611c49 100644
--- a/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Constant.java
+++ b/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Constant.java
@@ -7,14 +7,13 @@ import com.yahoo.searchlib.rankingexpression.Reference;
import com.yahoo.searchlib.rankingexpression.evaluation.Value;
import com.yahoo.tensor.functions.TensorFunction;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
public class Constant extends IntermediateOperation {
public Constant(String modelName, String nodeName, OrderedTensorType type) {
- super(modelName, nodeName, Collections.emptyList());
+ super(modelName, nodeName, List.of());
this.type = type.rename(vespaName() + "_");
}
diff --git a/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/IntermediateOperation.java b/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/IntermediateOperation.java
index 52de27891cf..d9f4a4b7f4c 100644
--- a/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/IntermediateOperation.java
+++ b/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/IntermediateOperation.java
@@ -53,7 +53,7 @@ public abstract class IntermediateOperation {
private final List<String> importWarnings = new ArrayList<>();
private Value constantValue = null;
- private List<IntermediateOperation> controlInputs = Collections.emptyList();
+ private List<IntermediateOperation> controlInputs = List.of();
protected Function<OrderedTensorType, Value> constantValueFunction = null;
@@ -259,7 +259,7 @@ public abstract class IntermediateOperation {
if (result == DoubleValue.NaN) {
if (constantValue != null) {
result = constantValue;
- } else if (inputs.size() == 0) {
+ } else if (inputs.isEmpty()) {
if (getConstantValue().isEmpty()) {
throw new IllegalArgumentException("Error in evaluating constant for " + name);
}
@@ -278,7 +278,7 @@ public abstract class IntermediateOperation {
/** Insert an operation between an input and this one */
public void insert(IntermediateOperation operationToInsert, int inputNumber) {
- if ( operationToInsert.inputs.size() > 0 ) {
+ if (!operationToInsert.inputs.isEmpty()) {
throw new IllegalArgumentException("Operation to insert to '" + name + "' has " +
"existing inputs which is not supported.");
}
@@ -336,7 +336,7 @@ public abstract class IntermediateOperation {
public abstract IntermediateOperation withInputs(List<IntermediateOperation> inputs);
String asString(Optional<OrderedTensorType> type) {
- return type.map(t -> t.toString()).orElse("(unknown)");
+ return type.map(OrderedTensorType::toString).orElse("(unknown)");
}
/**
@@ -373,7 +373,7 @@ public abstract class IntermediateOperation {
public String toFullString() {
return "\t" + type + ":\t" + operationName() + "(" +
- inputs().stream().map(input -> input.toFullString()).collect(Collectors.joining(", ")) +
+ inputs().stream().map(IntermediateOperation::toFullString).collect(Collectors.joining(", ")) +
")";
}
diff --git a/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/NoOp.java b/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/NoOp.java
index ba056d362ac..fa115d8af97 100644
--- a/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/NoOp.java
+++ b/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/NoOp.java
@@ -5,13 +5,12 @@ import ai.vespa.rankingexpression.importer.OrderedTensorType;
import com.yahoo.searchlib.rankingexpression.Reference;
import com.yahoo.tensor.functions.TensorFunction;
-import java.util.Collections;
import java.util.List;
public class NoOp extends IntermediateOperation {
public NoOp(String modelName, String nodeName, List<IntermediateOperation> inputs) {
- super(modelName, nodeName, Collections.emptyList()); // don't propagate inputs
+ super(modelName, nodeName, List.of()); // don't propagate inputs
}
@Override
diff --git a/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/OnnxConstant.java b/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/OnnxConstant.java
index dff548cf319..2e48d65fce2 100644
--- a/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/OnnxConstant.java
+++ b/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/OnnxConstant.java
@@ -9,7 +9,6 @@ import com.yahoo.searchlib.rankingexpression.evaluation.Value;
import com.yahoo.tensor.TensorType;
import com.yahoo.tensor.functions.TensorFunction;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
@@ -31,7 +30,7 @@ public class OnnxConstant extends IntermediateOperation {
if (value instanceof TensorValue) {
type = OrderedTensorType.fromSpec(value.type().toString()).rename(vespaName() + "_");
} else {
- type = OrderedTensorType.fromDimensionList(TensorType.Value.DOUBLE, Collections.emptyList());
+ type = OrderedTensorType.fromDimensionList(TensorType.Value.DOUBLE, List.of());
}
return type;
}
diff --git a/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Rename.java b/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Rename.java
index 5a7bbc95889..068c06acd8c 100644
--- a/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Rename.java
+++ b/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Rename.java
@@ -7,7 +7,6 @@ import com.yahoo.searchlib.rankingexpression.Reference;
import com.yahoo.tensor.TensorType;
import com.yahoo.tensor.functions.TensorFunction;
-import java.util.Collections;
import java.util.List;
/**
@@ -20,7 +19,7 @@ public class Rename extends IntermediateOperation {
private String from, to;
public Rename(String modelName, String from, String to, IntermediateOperation input) {
- super(modelName, "rename", input != null ? List.of(input) : Collections.emptyList());
+ super(modelName, "rename", input != null ? List.of(input) : List.of());
this.from = from;
this.to = to;
}
diff --git a/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Softmax.java b/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Softmax.java
index c4d728e9661..6d0a6c3b04b 100644
--- a/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Softmax.java
+++ b/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Softmax.java
@@ -10,7 +10,6 @@ import com.yahoo.tensor.functions.ScalarFunctions;
import com.yahoo.tensor.functions.TensorFunction;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
/**
@@ -77,7 +76,7 @@ public class Softmax extends IntermediateOperation {
private class SoftmaxPartialOperation extends IntermediateOperation {
private SoftmaxPartialOperation(String modelName, String nodeName, List<IntermediateOperation> inputs) {
- super(modelName, nodeName + "_partial" , inputs != null ? inputs : Collections.emptyList());
+ super(modelName, nodeName + "_partial" , inputs != null ? inputs : List.of());
}
@Override