Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

float 16 inference support #1173

Closed
vsooda opened this issue Jun 6, 2019 · 2 comments
Closed

float 16 inference support #1173

vsooda opened this issue Jun 6, 2019 · 2 comments

Comments

@vsooda
Copy link

vsooda commented Jun 6, 2019

Is your feature request related to a problem? Please describe.
I try to use c-api as this demo, it is ok. but when I try to quantize squeeze.onnx to float 16, and then inference again, it report:

Unexpected input data type. Actual: (N11onnxruntime11NonOnnxTypeIfEE) , expected: (N11onnxruntime11NonOnnxTypeINS_9MLFloat16EEE)

I use the follow script to convert float32 model to float16:

import onnxmltools
from onnxmltools.utils.float16_converter import convert_float_to_float16

input_onnx_model = 'squeezenet/model.onnx'
output_onnx_model = 'squeezenet/model_fp16.onnx'

onnx_model = onnxmltools.utils.load_model(input_onnx_model)
onnx_model = convert_float_to_float16(onnx_model)
onnxmltools.utils.save_model(onnx_model, output_onnx_model)

can onnxruntime support fp16 inference? any plan?

System information
0.4

Describe the solution you'd like
load fp 16 model, input float 32 data, then get float 32 result.

Describe alternatives you've considered
how to convert float32 input to float16 for inference?

@pranavsharma
Copy link
Contributor

Here's a unit test that demonstrates conversion of float32 input to float16 -

values_x.push_back(MLFloat16(math::floatToHalf(i)));
. Let us know if this doesn't work for you.

@vsooda
Copy link
Author

vsooda commented Jun 12, 2019

@pranavsharma thank you. it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants