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();
}
Aggregations