diff options
author | Jo Kristian Bergum <bergum@yahooinc.com> | 2023-10-26 22:14:11 +0200 |
---|---|---|
committer | Jo Kristian Bergum <bergum@yahooinc.com> | 2023-10-26 22:14:11 +0200 |
commit | 14b16ae550784fed98910e04188429579e289f2d (patch) | |
tree | ffe5d2b64cbe079f03f22ce8f379b20d040f9979 /model-integration/src | |
parent | bce3b8e926bf9da880172acbe1ba4b12d5e026d6 (diff) |
Add support for bfloat16 and float16
Diffstat (limited to 'model-integration/src')
4 files changed, 82 insertions, 0 deletions
diff --git a/model-integration/src/test/models/onnx/add_float16.onnx b/model-integration/src/test/models/onnx/add_float16.onnx new file mode 100644 index 00000000000..df0f7fdcdba --- /dev/null +++ b/model-integration/src/test/models/onnx/add_float16.onnx @@ -0,0 +1,19 @@ +add_float16.py:f + +input1 +input2output"AddaddZ +input1 + + + +Z +input2 + + + +b +output + + + +B
\ No newline at end of file diff --git a/model-integration/src/test/models/onnx/add_float16.py b/model-integration/src/test/models/onnx/add_float16.py new file mode 100755 index 00000000000..a637cf8b0dd --- /dev/null +++ b/model-integration/src/test/models/onnx/add_float16.py @@ -0,0 +1,27 @@ +# Copyright Vespa.ai. 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.FLOAT16, [1]) +INPUT_2 = helper.make_tensor_value_info('input2', TensorProto.FLOAT16, [1]) +OUTPUT = helper.make_tensor_value_info('output', TensorProto.FLOAT16, [1]) + +nodes = [ + helper.make_node( + 'Add', + ['input1', 'input2'], + ['output'], + ), +] +graph_def = helper.make_graph( + nodes, + 'add', + [ + INPUT_1, + INPUT_2 + ], + [OUTPUT], +) +model_def = helper.make_model(graph_def, producer_name='add_float16.py', opset_imports=[onnx.OperatorSetIdProto(version=12)]) +onnx.save(model_def, 'add_float16.onnx') diff --git a/model-integration/src/test/models/onnx/sign_bfloat16.onnx b/model-integration/src/test/models/onnx/sign_bfloat16.onnx new file mode 100644 index 00000000000..176451108ba --- /dev/null +++ b/model-integration/src/test/models/onnx/sign_bfloat16.onnx @@ -0,0 +1,11 @@ +sign_bfloat16.py:J + +input1output"SignsignZ +input1 + + +b +output + + +B
\ No newline at end of file diff --git a/model-integration/src/test/models/onnx/sign_bfloat16.py b/model-integration/src/test/models/onnx/sign_bfloat16.py new file mode 100755 index 00000000000..b74e48e91c8 --- /dev/null +++ b/model-integration/src/test/models/onnx/sign_bfloat16.py @@ -0,0 +1,25 @@ +# Copyright Vespa.ai. 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.BFLOAT16, [1]) +OUTPUT = helper.make_tensor_value_info('output', TensorProto.BFLOAT16, [1]) + +nodes = [ + helper.make_node( + 'Sign', + ['input1'], + ['output'], + ), +] +graph_def = helper.make_graph( + nodes, + 'sign', + [ + INPUT_1 + ], + [OUTPUT], +) +model_def = helper.make_model(graph_def, producer_name='sign_bfloat16.py', opset_imports=[onnx.OperatorSetIdProto(version=19)]) +onnx.save(model_def, 'sign_bfloat16.onnx') |