diff options
author | Jon Bratseth <bratseth@gmail.com> | 2022-11-09 16:15:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-09 16:15:20 +0100 |
commit | 606bc6b517e09bba9f36a4ef6506a588d1254bd4 (patch) | |
tree | 207c9dc61d3207e4630e73dc51ac5bdff1ac6d40 /config-model | |
parent | df9c6df4d0282a765fd9831eeb3bfd8ac5e38faa (diff) | |
parent | fec896323cb8af7e20c5b7a0ca3fbeba7457b4d2 (diff) |
Merge pull request #24813 from vespa-engine/revert-24773-revert-24760-balder/model-importing-code-in-config-model-3
Revert "Revert "Balder/model importing code in config model [run-systemtest]""
Diffstat (limited to 'config-model')
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/model/VespaModelFactory.java | 13 | ||||
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/model/ml/ConvertedModel.java | 10 |
2 files changed, 15 insertions, 8 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/VespaModelFactory.java b/config-model/src/main/java/com/yahoo/vespa/model/VespaModelFactory.java index e676667ae89..1ba8b470891 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/VespaModelFactory.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/VespaModelFactory.java @@ -2,6 +2,11 @@ package com.yahoo.vespa.model; import ai.vespa.rankingexpression.importer.configmodelview.MlModelImporter; +import ai.vespa.rankingexpression.importer.lightgbm.LightGBMImporter; +import ai.vespa.rankingexpression.importer.onnx.OnnxImporter; +import ai.vespa.rankingexpression.importer.tensorflow.TensorFlowImporter; +import ai.vespa.rankingexpression.importer.vespa.VespaImporter; +import ai.vespa.rankingexpression.importer.xgboost.XGBoostImporter; import com.yahoo.component.annotation.Inject; import com.yahoo.component.Version; import com.yahoo.component.provider.ComponentRegistry; @@ -56,7 +61,6 @@ public class VespaModelFactory implements ModelFactory { /** Creates a factory for Vespa models for this version of the source */ @Inject public VespaModelFactory(ComponentRegistry<ConfigModelPlugin> pluginRegistry, - ComponentRegistry<MlModelImporter> modelImporters, ComponentRegistry<Validator> additionalValidators, Zone zone) { this.version = new Version(VespaVersion.major, VespaVersion.minor, VespaVersion.micro); @@ -67,7 +71,12 @@ public class VespaModelFactory implements ModelFactory { } } this.configModelRegistry = new MapConfigModelRegistry(modelBuilders); - this.modelImporters = modelImporters.allComponents(); + this.modelImporters = List.of( + new VespaImporter(), + new OnnxImporter(), + new TensorFlowImporter(), + new XGBoostImporter(), + new LightGBMImporter()); this.zone = zone; this.additionalValidators = List.copyOf(additionalValidators.allComponents()); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/ml/ConvertedModel.java b/config-model/src/main/java/com/yahoo/vespa/model/ml/ConvertedModel.java index 9ba87fd24bf..96a6b39dc1a 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/ml/ConvertedModel.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/ml/ConvertedModel.java @@ -199,8 +199,8 @@ public class ConvertedModel { ModelStore store) { // Add constants Set<String> constantsReplacedByFunctions = new HashSet<>(); - model.smallConstants().forEach((k, v) -> transformSmallConstant(store, profile, k, v)); - model.largeConstants().forEach((k, v) -> transformLargeConstant(store, profile, queryProfiles, + model.smallConstantTensors().forEach((k, v) -> transformSmallConstant(store, profile, k, v)); + model.largeConstantTensors().forEach((k, v) -> transformLargeConstant(store, profile, queryProfiles, constantsReplacedByFunctions, k, v)); // Add functions @@ -294,8 +294,7 @@ public class ConvertedModel { } private static void transformSmallConstant(ModelStore store, RankProfile profile, String constantName, - String constantValueString) { - Tensor constantValue = Tensor.from(constantValueString); + Tensor constantValue) { store.writeSmallConstant(constantName, constantValue); Reference name = FeatureNames.asConstantFeature(constantName); profile.add(new RankProfile.Constant(name, constantValue)); @@ -306,8 +305,7 @@ public class ConvertedModel { QueryProfileRegistry queryProfiles, Set<String> constantsReplacedByFunctions, String constantName, - String constantValueString) { - Tensor constantValue = Tensor.from(constantValueString); + Tensor constantValue) { RankProfile.RankingExpressionFunction rankingExpressionFunctionOverridingConstant = profile.getFunctions().get(constantName); if (rankingExpressionFunctionOverridingConstant != null) { TensorType functionType = rankingExpressionFunctionOverridingConstant.function().getBody().type(profile.typeContext(queryProfiles)); |