diff options
author | Lester Solbakken <lesters@oath.com> | 2021-06-28 09:36:37 +0200 |
---|---|---|
committer | Lester Solbakken <lesters@oath.com> | 2021-06-28 09:36:37 +0200 |
commit | 0b53632d1ce373aa18ed53b1be6dc362a003260e (patch) | |
tree | 2c820888d7778a34205cfa3c0e8bba2dc8b85fef /config-model/src/test/cfg/application | |
parent | d713569989c88b541305e79ac531b0fc8a8bceaa (diff) |
Add unit testing of ModelsEvaluator in applications
Diffstat (limited to 'config-model/src/test/cfg/application')
5 files changed, 84 insertions, 0 deletions
diff --git a/config-model/src/test/cfg/application/stateless_eval/constant1asLarge.json b/config-model/src/test/cfg/application/stateless_eval/constant1asLarge.json new file mode 100644 index 00000000000..d2944d255af --- /dev/null +++ b/config-model/src/test/cfg/application/stateless_eval/constant1asLarge.json @@ -0,0 +1,7 @@ +{ + "cells": [ + { "address": { "x": "0" }, "value": 0.5 }, + { "address": { "x": "1" }, "value": 1.5 }, + { "address": { "x": "2" }, "value": 2.5 } + ] +}
\ No newline at end of file diff --git a/config-model/src/test/cfg/application/stateless_eval/example.model b/config-model/src/test/cfg/application/stateless_eval/example.model new file mode 100644 index 00000000000..af1c85be4f0 --- /dev/null +++ b/config-model/src/test/cfg/application/stateless_eval/example.model @@ -0,0 +1,34 @@ +model example { + + # All inputs that are not scalar (aka 0-dimensional tensor) must be declared + input1: tensor(name{}, x[3]) + input2: tensor(x[3]) + + constants { + constant1: tensor(x[3]):{{x:0}:0.5, {x:1}:1.5, {x:2}:2.5} + constant2: 3.0 + } + + constant constant1asLarge { + type: tensor(x[3]) + file: constant1asLarge.json + } + + function foo1() { + expression: file:test.expression + } + + function foo2() { + expression: reduce(sum(input1 * input2, name) * constant(constant1asLarge), max, x) * constant2 + # expression: input1 * input2 + } + + function my_input1() { + expression: tensor(d0[1]):[2] + } + + function my_input2() { + expression: tensor(d0[1]):[3] + } + +}
\ No newline at end of file diff --git a/config-model/src/test/cfg/application/stateless_eval/mul.onnx b/config-model/src/test/cfg/application/stateless_eval/mul.onnx new file mode 100644 index 00000000000..087e2c3427f --- /dev/null +++ b/config-model/src/test/cfg/application/stateless_eval/mul.onnx @@ -0,0 +1,16 @@ +mul.py:f + +input1 +input2output"MulmulZ +input1 + + +Z +input2 + + +b +output + + +B
\ No newline at end of file diff --git a/config-model/src/test/cfg/application/stateless_eval/mul.py b/config-model/src/test/cfg/application/stateless_eval/mul.py new file mode 100755 index 00000000000..db01561c355 --- /dev/null +++ b/config-model/src/test/cfg/application/stateless_eval/mul.py @@ -0,0 +1,26 @@ +# Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +import onnx +from onnx import helper, TensorProto + +INPUT_1 = helper.make_tensor_value_info('input1', TensorProto.FLOAT, [1]) +INPUT_2 = helper.make_tensor_value_info('input2', TensorProto.FLOAT, [1]) +OUTPUT = helper.make_tensor_value_info('output', TensorProto.FLOAT, [1]) + +nodes = [ + helper.make_node( + 'Mul', + ['input1', 'input2'], + ['output'], + ), +] +graph_def = helper.make_graph( + nodes, + 'mul', + [ + INPUT_1, + INPUT_2 + ], + [OUTPUT], +) +model_def = helper.make_model(graph_def, producer_name='mul.py', opset_imports=[onnx.OperatorSetIdProto(version=12)]) +onnx.save(model_def, 'mul.onnx') diff --git a/config-model/src/test/cfg/application/stateless_eval/test.expression b/config-model/src/test/cfg/application/stateless_eval/test.expression new file mode 100644 index 00000000000..5db8a720498 --- /dev/null +++ b/config-model/src/test/cfg/application/stateless_eval/test.expression @@ -0,0 +1 @@ +reduce(sum(input1 * input2, name) * constant1, max, x) * constant2
\ No newline at end of file |