Skip to content

Commit

Permalink
feat: add a unit test to avoid forgetting about mixed dt with q8/fp a…
Browse files Browse the repository at this point in the history
…nd relu operator
  • Loading branch information
JulienBalianSonos committed Feb 13, 2024
1 parent 7f72268 commit 20ba006
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 0 deletions.
17 changes: 17 additions & 0 deletions harness/nnef-test-cases/relu_quant/expected/graph.nnef
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version 1.0;

extension tract_registry tract_core;

fragment tract_core_properties(
) -> (properties: (string, tensor<scalar>)[])
{
properties = [("tract_nnef_ser_version", "0.21.2-pre"), ("tract_nnef_format_version", "beta1")];
}

graph network(input) -> (output) {
input = external(shape = [2, 1, 3]);
output_relu_y_3 = variable<scalar>(label = "output_relu_y_3", shape = [1, 1, 1]);
output_raw = max(input, output_relu_y_3);
foo = tract_core_cast(output_raw, to = "u8");
output = foo;
}
4 changes: 4 additions & 0 deletions harness/nnef-test-cases/relu_quant/expected/graph.quant
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"foo": zero_point_linear_quantize(zero_point = 2, scale = 0.003906250, bits = 8, signed = false, symmetric = false);
"input": zero_point_linear_quantize(zero_point = 128, scale = 0.007812500, bits = 8, signed = false, symmetric = false);
"output_raw": zero_point_linear_quantize(zero_point = 128, scale = 0.007812500, bits = 8, signed = false, symmetric = false);
"output_relu_y_3": zero_point_linear_quantize(zero_point = 128, scale = 0.007812500, bits = 8, signed = false, symmetric = false);
Binary file not shown.
7 changes: 7 additions & 0 deletions harness/nnef-test-cases/relu_quant/model/graph.nnef
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version 1.0;

graph softmax_quant(input) -> (output)
{
input = external<scalar>(shape = [2, 1, 3]);
output = relu(input);
}
2 changes: 2 additions & 0 deletions harness/nnef-test-cases/relu_quant/model/graph.quant
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"input": zero_point_linear_quantize(zero_point = 128, scale = 0.0078125, bits = 8, signed = false, symmetric = false);
"output": zero_point_linear_quantize(zero_point = 2, scale = 0.00390625, bits = 8, signed = false, symmetric = false);
14 changes: 14 additions & 0 deletions harness/nnef-test-cases/relu_quant/runme.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

cd $(dirname $0)
set -ex

: ${TRACT_RUN:=cargo run -p tract $CARGO_OPTS --}

rm -rf found
$TRACT_RUN --nnef-tract-core ./model dump -q --nnef-dir found

version=$(cargo metadata --format-version 1 | jq -r '.packages | map(select( (.name) == "tract-core") | .version) | .[] ')
perl -pi -e "s/$version/0.21.2-pre/" found/graph.nnef

diff expected found

0 comments on commit 20ba006

Please sign in to comment.