blob: e2bef0063eab26d91e98457ff24eea9552daeb92 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema.expressiontransforms;
import com.yahoo.searchlib.rankingexpression.rule.CompositeNode;
import com.yahoo.searchlib.rankingexpression.rule.ExpressionNode;
import com.yahoo.searchlib.rankingexpression.rule.ReferenceNode;
import com.yahoo.searchlib.rankingexpression.transform.ExpressionTransformer;
/**
* Replaces instances of the tensorflow(model-path, signature, output)
* pseudofeature with the native Vespa ranking expression implementing
* the same computation.
*
* @author bratseth
*/
public class TensorFlowFeatureConverter extends ExpressionTransformer<RankProfileTransformContext> {
public TensorFlowFeatureConverter() {}
@Override
public ExpressionNode transform(ExpressionNode node, RankProfileTransformContext context) {
if (node instanceof ReferenceNode)
return transformFeature((ReferenceNode) node, context);
else if (node instanceof CompositeNode)
return super.transformChildren((CompositeNode) node, context);
else
return node;
}
private ExpressionNode transformFeature(ReferenceNode feature, RankProfileTransformContext context) {
if ( ! feature.getName().equals("tensorflow")) {
return feature;
}
throw new IllegalArgumentException("Import of TensorFlow models is no longer supported");
}
}
|