diff options
author | Arne Juul <arnej@yahooinc.com> | 2023-11-16 14:52:47 +0000 |
---|---|---|
committer | Arne Juul <arnej@yahooinc.com> | 2023-11-16 19:01:17 +0000 |
commit | 16ab76c8e668b90177438c1e793a253f48eb55f0 (patch) | |
tree | ab767179bf346ab49853bcfcc2ab2ab264c1e11f /config-model/src | |
parent | acd4ebf2718a4d80998b87a57c4b046e56f8e3e0 (diff) |
always process with SerializationContext (needed by unpack_bits)
Diffstat (limited to 'config-model/src')
4 files changed, 37 insertions, 6 deletions
diff --git a/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java b/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java index 87b79ddcdc3..8606599f530 100644 --- a/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java +++ b/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java @@ -186,6 +186,7 @@ public class RawRankProfile implements RankProfilesConfig.Producer { private RankingExpression secondPhaseRanking; private RankingExpression globalPhaseRanking; private final int globalPhaseRerankCount; + private final SerializationContext functionSerializationContext; /** * Creates a raw rank profile from the given rank profile @@ -225,7 +226,7 @@ public class RawRankProfile implements RankProfilesConfig.Producer { List<ExpressionFunction> functionExpressions = functions.values().stream().map(RankProfile.RankingExpressionFunction::function).toList(); Map<String, String> functionProperties = new LinkedHashMap<>(); var typeContext = compiled.typeContext(queryProfiles); - SerializationContext functionSerializationContext = new SerializationContext(functionExpressions, Map.of(), typeContext); + this.functionSerializationContext = new SerializationContext(functionExpressions, Map.of(), typeContext); if (firstPhaseRanking != null) { functionProperties.putAll(firstPhaseRanking.getRankProperties(functionSerializationContext)); } @@ -265,8 +266,6 @@ public class RawRankProfile implements RankProfilesConfig.Producer { private void derivePropertiesAndFeaturesFromFunctions(Map<String, RankProfile.RankingExpressionFunction> functions, Map<String, String> functionProperties, SerializationContext functionContext) { - if (functions.isEmpty()) return; - replaceFunctionFeatures(summaryFeatures, functionContext); replaceFunctionFeatures(matchFeatures, functionContext); @@ -556,11 +555,12 @@ public class RawRankProfile implements RankProfilesConfig.Producer { if ("".equals(name)) name = phase; + String expressionAsString = expression.getRoot().toString(functionSerializationContext).toString(); if (expression.getRoot() instanceof ReferenceNode) { - properties.add(new Pair<>("vespa.rank." + phase, expression.getRoot().toString())); + properties.add(new Pair<>("vespa.rank." + phase, expressionAsString)); } else { properties.add(new Pair<>("vespa.rank." + phase, wrapInRankingExpression(name))); - properties.add(new Pair<>(RankingExpression.propertyName(name), expression.getRoot().toString())); + properties.add(new Pair<>(RankingExpression.propertyName(name), expressionAsString)); } return properties; } diff --git a/config-model/src/test/derived/globalphase_onnx_inside/rank-profiles.cfg b/config-model/src/test/derived/globalphase_onnx_inside/rank-profiles.cfg index 4600884b615..b62d7fd239c 100644 --- a/config-model/src/test/derived/globalphase_onnx_inside/rank-profiles.cfg +++ b/config-model/src/test/derived/globalphase_onnx_inside/rank-profiles.cfg @@ -17,6 +17,8 @@ rankprofile[].fef.property[].value "true" rankprofile[].fef.property[].name "vespa.type.attribute.aa" rankprofile[].fef.property[].value "tensor(d1[3])" rankprofile[].name "simple" +rankprofile[].fef.property[].name "vespa.type.feature.attribute(aa)" +rankprofile[].fef.property[].value "tensor(d1[3])" rankprofile[].fef.property[].name "vespa.rank.firstphase" rankprofile[].fef.property[].value "rankingExpression(firstphase)" rankprofile[].fef.property[].name "rankingExpression(firstphase).rankingScript" diff --git a/config-model/src/test/derived/tensor/rank-profiles.cfg b/config-model/src/test/derived/tensor/rank-profiles.cfg index cd8375cb68d..a72e9dc27cd 100644 --- a/config-model/src/test/derived/tensor/rank-profiles.cfg +++ b/config-model/src/test/derived/tensor/rank-profiles.cfg @@ -47,7 +47,7 @@ rankprofile[].name "profile2" rankprofile[].fef.property[].name "vespa.rank.firstphase" rankprofile[].fef.property[].value "rankingExpression(firstphase)" rankprofile[].fef.property[].name "rankingExpression(firstphase).rankingScript" -rankprofile[].fef.property[].value "reduce(reduce(join(attribute(f4), tensor(x[10],y[10],z[3])((x==y)*(y==z)), f(a,b)(a * b)), sum, x), sum)" +rankprofile[].fef.property[].value "reduce(reduce(join(attribute(f4), tensor(x[10],y[10],z[3])(((x == y) * (y == z))), f(a,b)(a * b)), sum, x), sum)" rankprofile[].fef.property[].name "vespa.type.attribute.f7" rankprofile[].fef.property[].value "tensor<int8>(p{},x[5])" rankprofile[].fef.property[].name "vespa.type.attribute.f2" @@ -206,3 +206,22 @@ rankprofile[].fef.property[].name "vespa.type.query.para" rankprofile[].fef.property[].value "tensor<float>(p{})" rankprofile[].fef.property[].name "vespa.type.query.qvec" rankprofile[].fef.property[].value "tensor<float>(x[40])" +rankprofile[].name "with-just-unpack" +rankprofile[].fef.property[].name "vespa.rank.firstphase" +rankprofile[].fef.property[].value "rankingExpression(firstphase)" +rankprofile[].fef.property[].name "rankingExpression(firstphase).rankingScript" +rankprofile[].fef.property[].value "reduce(query(para) * map_subspaces(attribute(f7), f(denseSubspaceInput)(tensor(x[40])((bit(denseSubspaceInput{x:(x / 8)},(x % 8)))))) * query(qvec), sum)" +rankprofile[].fef.property[].name "vespa.type.attribute.f7" +rankprofile[].fef.property[].value "tensor<int8>(p{},x[5])" +rankprofile[].fef.property[].name "vespa.type.attribute.f2" +rankprofile[].fef.property[].value "tensor<float>(x[2],y[1])" +rankprofile[].fef.property[].name "vespa.type.attribute.f3" +rankprofile[].fef.property[].value "tensor(x{})" +rankprofile[].fef.property[].name "vespa.type.attribute.f4" +rankprofile[].fef.property[].value "tensor(x[10],y[10])" +rankprofile[].fef.property[].name "vespa.type.attribute.f5" +rankprofile[].fef.property[].value "tensor<float>(x[10])" +rankprofile[].fef.property[].name "vespa.type.query.para" +rankprofile[].fef.property[].value "tensor(p{})" +rankprofile[].fef.property[].name "vespa.type.query.qvec" +rankprofile[].fef.property[].value "tensor(x[40])" diff --git a/config-model/src/test/derived/tensor/tensor.sd b/config-model/src/test/derived/tensor/tensor.sd index 3a5fda3ac5d..a0f5cd92c56 100644 --- a/config-model/src/test/derived/tensor/tensor.sd +++ b/config-model/src/test/derived/tensor/tensor.sd @@ -135,4 +135,14 @@ schema tensor { } } + rank-profile with-just-unpack { + inputs { + query(para) tensor<double>(p{}) + query(qvec) tensor<double>(x[40]) + } + first-phase { + expression: sum(query(para)*unpack_bits(attribute(f7), double, little)*query(qvec)) + } + } + } |