Search in sources :

Example 1 with TensorFlowModel

use of com.yahoo.searchlib.rankingexpression.integration.tensorflow.TensorFlowModel in project vespa by vespa-engine.

the class TensorFlowFeatureConverter method transformFromTensorFlowModel.

private ExpressionNode transformFromTensorFlowModel(ModelStore store, RankProfile profile, QueryProfileRegistry queryProfiles) {
    TensorFlowModel model = importedModels.computeIfAbsent(store.arguments().modelPath(), k -> tensorFlowImporter.importModel(store.arguments().modelName(), store.tensorFlowModelDir()));
    // Add constants
    Set<String> constantsReplacedByMacros = new HashSet<>();
    model.smallConstants().forEach((k, v) -> transformSmallConstant(store, profile, k, v));
    model.largeConstants().forEach((k, v) -> transformLargeConstant(store, profile, queryProfiles, constantsReplacedByMacros, k, v));
    // Find the specified expression
    Signature signature = chooseSignature(model, store.arguments().signature());
    String output = chooseOutput(signature, store.arguments().output());
    RankingExpression expression = model.expressions().get(output);
    expression = replaceConstantsByMacros(expression, constantsReplacedByMacros);
    verifyRequiredMacros(expression, model, profile, queryProfiles);
    addGeneratedMacros(model, profile);
    reduceBatchDimensions(expression, model, profile, queryProfiles);
    model.macros().forEach((k, v) -> transformGeneratedMacro(store, profile, constantsReplacedByMacros, k, v));
    store.writeConverted(expression);
    return expression.getRoot();
}
Also used : TensorFlowModel(com.yahoo.searchlib.rankingexpression.integration.tensorflow.TensorFlowModel) RankingExpression(com.yahoo.searchlib.rankingexpression.RankingExpression) Signature(com.yahoo.searchlib.rankingexpression.integration.tensorflow.TensorFlowModel.Signature) HashSet(java.util.HashSet)

Aggregations

RankingExpression (com.yahoo.searchlib.rankingexpression.RankingExpression)1 TensorFlowModel (com.yahoo.searchlib.rankingexpression.integration.tensorflow.TensorFlowModel)1 Signature (com.yahoo.searchlib.rankingexpression.integration.tensorflow.TensorFlowModel.Signature)1 HashSet (java.util.HashSet)1