aboutsummaryrefslogtreecommitdiffstats
path: root/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/Merge.java
blob: e2b5930f1140092a049d6a829f460fcd6cd8f90b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.rankingexpression.importer.operations;

import ai.vespa.rankingexpression.importer.OrderedTensorType;
import com.yahoo.searchlib.rankingexpression.Reference;
import com.yahoo.tensor.functions.TensorFunction;

import java.util.List;

public class Merge extends IntermediateOperation {

    public Merge(String modelName, String nodeName, List<IntermediateOperation> inputs) {
        super(modelName, nodeName, inputs);
    }

    @Override
    protected OrderedTensorType lazyGetType() {
        for (IntermediateOperation operation : inputs) {
            if (operation.type().isPresent()) {
                return operation.type().get();
            }
        }
        return null;
    }

    @Override
    protected TensorFunction<Reference> lazyGetFunction() {
        for (IntermediateOperation operation : inputs) {
            if (operation.function().isPresent()) {
                return operation.function().get();
            }
        }
        return null;
    }

    @Override
    public Merge withInputs(List<IntermediateOperation> inputs) {
        return new Merge(modelName(), name(), inputs);
    }

    @Override
    public String operationName() { return "Merge"; }

}