summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArne Juul <arnej@yahooinc.com>2023-03-20 10:51:03 +0000
committerArne Juul <arnej@yahooinc.com>2023-03-20 12:22:52 +0000
commit5791e60dfcd5f83d0e77e45498318eeb3dd33ee3 (patch)
tree072eda676b406756ddf487e5cf6162d2b7e1c281
parentad2e68e457aa87c508a7e057cc178f1fe6af35d1 (diff)
add unit test
-rw-r--r--config-model/src/test/derived/scalar_constant/rank-profiles.cfg18
-rw-r--r--config-model/src/test/derived/scalar_constant/test.sd20
-rw-r--r--config-model/src/test/derived/vector_constant/ax_plus_b.onnx23
-rw-r--r--config-model/src/test/derived/vector_constant/rank-profiles.cfg26
-rw-r--r--config-model/src/test/derived/vector_constant/ranking-constants.cfg3
-rw-r--r--config-model/src/test/derived/vector_constant/test.sd33
-rw-r--r--config-model/src/test/java/com/yahoo/schema/derived/SmallConstantsTestCase.java27
7 files changed, 150 insertions, 0 deletions
diff --git a/config-model/src/test/derived/scalar_constant/rank-profiles.cfg b/config-model/src/test/derived/scalar_constant/rank-profiles.cfg
new file mode 100644
index 00000000000..5b494fa46fb
--- /dev/null
+++ b/config-model/src/test/derived/scalar_constant/rank-profiles.cfg
@@ -0,0 +1,18 @@
+rankprofile[].name "default"
+rankprofile[].fef.property[].name "rankingExpression(makevector).rankingScript"
+rankprofile[].fef.property[].value "tensor(x[3]):{{x:0}:0.25,{x:1}:0.5,{x:2}:0.75}"
+rankprofile[].fef.property[].name "rankingExpression(makevector).type"
+rankprofile[].fef.property[].value "tensor(x[3])"
+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(rankingExpression(makevector), sum)"
+rankprofile[].name "unranked"
+rankprofile[].fef.property[].name "vespa.rank.firstphase"
+rankprofile[].fef.property[].value "value(0)"
+rankprofile[].fef.property[].name "vespa.hitcollector.heapsize"
+rankprofile[].fef.property[].value "0"
+rankprofile[].fef.property[].name "vespa.hitcollector.arraysize"
+rankprofile[].fef.property[].value "0"
+rankprofile[].fef.property[].name "vespa.dump.ignoredefaultfeatures"
+rankprofile[].fef.property[].value "true"
diff --git a/config-model/src/test/derived/scalar_constant/test.sd b/config-model/src/test/derived/scalar_constant/test.sd
new file mode 100644
index 00000000000..5c05e0ba941
--- /dev/null
+++ b/config-model/src/test/derived/scalar_constant/test.sd
@@ -0,0 +1,20 @@
+# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+schema test {
+ document test {
+ field title type string {
+ indexing: index | summary
+ }
+ }
+ rank-profile default {
+ constants {
+ constant(foobar) double: 0.5
+ }
+ function makevector() {
+ expression: tensor(x[3]):[0.25, constant(foobar), 0.75]
+ }
+ first-phase {
+ expression: sum(makevector())
+ }
+ }
+}
diff --git a/config-model/src/test/derived/vector_constant/ax_plus_b.onnx b/config-model/src/test/derived/vector_constant/ax_plus_b.onnx
new file mode 100644
index 00000000000..17282d13dc3
--- /dev/null
+++ b/config-model/src/test/derived/vector_constant/ax_plus_b.onnx
@@ -0,0 +1,23 @@
+:©
+
+matrix_X
+vector_AXA"MatMul
+
+XA
+vector_Bvector_Y"AddlrZ
+matrix_X
+  
+
+Z
+vector_A
+
+ 
+Z
+vector_B
+
+ 
+b
+vector_Y
+
+ 
+B \ No newline at end of file
diff --git a/config-model/src/test/derived/vector_constant/rank-profiles.cfg b/config-model/src/test/derived/vector_constant/rank-profiles.cfg
new file mode 100644
index 00000000000..87edec6ca24
--- /dev/null
+++ b/config-model/src/test/derived/vector_constant/rank-profiles.cfg
@@ -0,0 +1,26 @@
+rankprofile[].name "default"
+rankprofile[].fef.property[].name "constant(bb).value"
+rankprofile[].fef.property[].value "tensor(d0[2]):[4.0, 5.0]"
+rankprofile[].fef.property[].name "constant(bb).type"
+rankprofile[].fef.property[].value "tensor(d0[2])"
+rankprofile[].fef.property[].name "constant(aa).value"
+rankprofile[].fef.property[].value "tensor(d1[3]):[1.0, 2.0, 3.0]"
+rankprofile[].fef.property[].name "constant(aa).type"
+rankprofile[].fef.property[].value "tensor(d1[3])"
+rankprofile[].fef.property[].name "rankingExpression(indirect_a).rankingScript"
+rankprofile[].fef.property[].value "tensor(d1[3]):{{d1:0}:2.0,{d1:1}:(constant(aa){d1:0}),{d1:2}:(constant(bb){d0:(2.0)})}"
+rankprofile[].fef.property[].name "rankingExpression(indirect_a).type"
+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"
+rankprofile[].fef.property[].value "reduce(onnx(inside).foobar, sum)"
+rankprofile[].name "unranked"
+rankprofile[].fef.property[].name "vespa.rank.firstphase"
+rankprofile[].fef.property[].value "value(0)"
+rankprofile[].fef.property[].name "vespa.hitcollector.heapsize"
+rankprofile[].fef.property[].value "0"
+rankprofile[].fef.property[].name "vespa.hitcollector.arraysize"
+rankprofile[].fef.property[].value "0"
+rankprofile[].fef.property[].name "vespa.dump.ignoredefaultfeatures"
+rankprofile[].fef.property[].value "true"
diff --git a/config-model/src/test/derived/vector_constant/ranking-constants.cfg b/config-model/src/test/derived/vector_constant/ranking-constants.cfg
new file mode 100644
index 00000000000..8637be8f175
--- /dev/null
+++ b/config-model/src/test/derived/vector_constant/ranking-constants.cfg
@@ -0,0 +1,3 @@
+constant[].name "xx"
+constant[].fileref "const_xx.json"
+constant[].type "tensor(d0[2],d1[3])"
diff --git a/config-model/src/test/derived/vector_constant/test.sd b/config-model/src/test/derived/vector_constant/test.sd
new file mode 100644
index 00000000000..508bd6505a7
--- /dev/null
+++ b/config-model/src/test/derived/vector_constant/test.sd
@@ -0,0 +1,33 @@
+schema test {
+ document test {
+ field extra type string {
+ }
+ }
+ constant xx {
+ file: const_xx.json
+ type: tensor(d0[2],d1[3])
+ }
+ rank-profile default {
+ constants {
+ constant(aa) tensor(d1[3]): [1,2,3]
+ bb tensor(d0[2]): [4,5]
+ dd double: 2
+ }
+ function indirect_a() {
+ expression: tensor(d1[3]): [constant(dd), constant(aa){d1:0}, constant(bb){d0:(constant(dd))}]
+ }
+ onnx-model inside {
+ file: ax_plus_b.onnx
+ input vector_A: indirect_a
+ input matrix_X: constant(xx)
+ input vector_B: constant(bb)
+ output vector_Y: foobar
+ }
+ first-phase {
+ expression: sum(onnx(inside).foobar)
+ }
+ # function unused() {
+ # expression: constant(aa)*constant(bb)
+ # }
+ }
+}
diff --git a/config-model/src/test/java/com/yahoo/schema/derived/SmallConstantsTestCase.java b/config-model/src/test/java/com/yahoo/schema/derived/SmallConstantsTestCase.java
new file mode 100644
index 00000000000..09352eb59fa
--- /dev/null
+++ b/config-model/src/test/java/com/yahoo/schema/derived/SmallConstantsTestCase.java
@@ -0,0 +1,27 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.schema.derived;
+
+import com.yahoo.schema.parser.ParseException;
+import org.junit.jupiter.api.Test;
+import java.io.IOException;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * Tests constants in rank-profile
+ *
+ * @author arnej
+ */
+public class SmallConstantsTestCase extends AbstractExportingTestCase {
+
+ @Test
+ void testScalarInRankProfile() throws IOException, ParseException {
+ assertCorrectDeriving("scalar_constant");
+ }
+
+ @Test
+ void testVectorInRankProfile() throws IOException, ParseException {
+ assertCorrectDeriving("vector_constant");
+ }
+
+}