summaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/features
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@oath.com>2021-08-10 12:53:32 +0000
committerHåvard Pettersen <havardpe@oath.com>2021-08-11 10:13:40 +0000
commitda4e0c4a0d22c614b028c83b9106328996eca36a (patch)
tree1e91989bb6407fb401db1b2a0df36e37674c8cd9 /searchlib/src/tests/features
parent0211f5238b1919a39ff2ed904809ec98e7d8b87e (diff)
avoid crash on run-time onnx errors
- warn about onnx model dry-run being disabled - catch and report onnx errors during ranking - zero-fill failed results to avoid re-using previous results - use explicit output size in fragile model (output became float[2] instead of float[batch] anyways)
Diffstat (limited to 'searchlib/src/tests/features')
-rw-r--r--searchlib/src/tests/features/onnx_feature/fragile.onnx11
-rwxr-xr-xsearchlib/src/tests/features/onnx_feature/fragile.py2
-rw-r--r--searchlib/src/tests/features/onnx_feature/onnx_feature_test.cpp8
3 files changed, 12 insertions, 9 deletions
diff --git a/searchlib/src/tests/features/onnx_feature/fragile.onnx b/searchlib/src/tests/features/onnx_feature/fragile.onnx
index 2a05500e95b..dc650154f83 100644
--- a/searchlib/src/tests/features/onnx_feature/fragile.onnx
+++ b/searchlib/src/tests/features/onnx_feature/fragile.onnx
@@ -1,5 +1,5 @@

-fragile.py:b
+fragile.py:]

in1
in2out"AddfragileZ
@@ -9,7 +9,8 @@ fragile.py:b
Z
in2

-batchb
-out
- 
-batchB \ No newline at end of file
+batchb
+out
+
+
+B \ No newline at end of file
diff --git a/searchlib/src/tests/features/onnx_feature/fragile.py b/searchlib/src/tests/features/onnx_feature/fragile.py
index e4eaf168e14..fe5851f5a63 100755
--- a/searchlib/src/tests/features/onnx_feature/fragile.py
+++ b/searchlib/src/tests/features/onnx_feature/fragile.py
@@ -6,7 +6,7 @@ from onnx import helper, TensorProto
INPUT1 = helper.make_tensor_value_info('in1', TensorProto.FLOAT, [2])
INPUT2 = helper.make_tensor_value_info('in2', TensorProto.FLOAT, ['batch'])
-OUTPUT = helper.make_tensor_value_info('out', TensorProto.FLOAT, ['batch'])
+OUTPUT = helper.make_tensor_value_info('out', TensorProto.FLOAT, [2])
nodes = [
helper.make_node(
diff --git a/searchlib/src/tests/features/onnx_feature/onnx_feature_test.cpp b/searchlib/src/tests/features/onnx_feature/onnx_feature_test.cpp
index c07ebc48604..7e80d9fc335 100644
--- a/searchlib/src/tests/features/onnx_feature/onnx_feature_test.cpp
+++ b/searchlib/src/tests/features/onnx_feature/onnx_feature_test.cpp
@@ -147,20 +147,22 @@ TEST_F(OnnxFeatureTest, input_features_and_output_names_can_be_specified) {
TEST_F(OnnxFeatureTest, fragile_model_can_be_evaluated) {
add_expr("in1", "tensor<float>(x[2]):[docid,5]");
add_expr("in2", "tensor<float>(x[2]):[docid,10]");
- add_onnx(OnnxModel("fragile", fragile_model));
+ add_onnx(OnnxModel("fragile", fragile_model).dry_run_on_setup(true));
EXPECT_TRUE(try_compile(onnx_feature("fragile")));
EXPECT_EQ(get(1), TensorSpec::from_expr("tensor<float>(d0[2]):[2,15]"));
EXPECT_EQ(get(3), TensorSpec::from_expr("tensor<float>(d0[2]):[6,15]"));
}
-TEST_F(OnnxFeatureTest, runtime_broken_model_can_be_set_up_without_dry_run) {
+TEST_F(OnnxFeatureTest, broken_model_evaluates_to_all_zeros) {
add_expr("in1", "tensor<float>(x[2]):[docid,5]");
add_expr("in2", "tensor<float>(x[3]):[docid,10,31515]");
add_onnx(OnnxModel("fragile", fragile_model).dry_run_on_setup(false));
EXPECT_TRUE(try_compile(onnx_feature("fragile")));
+ EXPECT_EQ(get(1), TensorSpec::from_expr("tensor<float>(d0[2]):[0,0]"));
+ EXPECT_EQ(get(3), TensorSpec::from_expr("tensor<float>(d0[2]):[0,0]"));
}
-TEST_F(OnnxFeatureTest, runtime_broken_model_fails_with_dry_run) {
+TEST_F(OnnxFeatureTest, broken_model_fails_with_dry_run) {
add_expr("in1", "tensor<float>(x[2]):[docid,5]");
add_expr("in2", "tensor<float>(x[3]):[docid,10,31515]");
add_onnx(OnnxModel("fragile", fragile_model).dry_run_on_setup(true));