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

[QNN][TFLite] Parsing TFLite quantized models. #3900

Open
wants to merge 1 commit into
base: master
from

Conversation

@anijain2305
Copy link
Contributor

commented Sep 5, 2019

As of now, QNN dialect has enough QNN ops for Inception model. This PR takes the TFLite Pre-quantized model and parses it for a handful of QNN operators.

@jackwish @FrozenGene @apivovarov @zhiics @shoubhik

@anijain2305 anijain2305 force-pushed the anijain2305:tflite_parser branch 2 times, most recently from a6d2fb2 to 0f75650 Sep 5, 2019

@anijain2305 anijain2305 force-pushed the anijain2305:tflite_parser branch from 0f75650 to a0e7be2 Sep 5, 2019

@@ -1030,4 +1153,6 @@ def from_tflite(model, shape_dict, dtype_dict):
outputs = [exp_tab.get_expr(get_tensor_name(subgraph, i)) for i in model_outputs]
outputs = outputs[0] if len(outputs) == 1 else _expr.Tuple(outputs)
func = _expr.Function(analysis.free_vars(outputs), outputs)
return _module.Module.from_expr(func), params
mod = _module.Module.from_expr(func)
mod = tvm.relay.qnn.transform.CanonicalizeOps()(mod)

This comment has been minimized.

Copy link
@anijain2305

anijain2305 Sep 5, 2019

Author Contributor

@zhiics @vinx13 @tqchen Should we remove this from here and make it a part of build_module.cc?

@anijain2305 anijain2305 marked this pull request as ready for review Sep 5, 2019

@@ -848,6 +848,25 @@ def test_forward_inception_v4_net():
tvm.testing.assert_allclose(np.squeeze(tvm_output[0]), np.squeeze(tflite_output[0]),
rtol=1e-5, atol=1e-5)

def test_forward_quantized_inception_v1_net():

This comment has been minimized.

Copy link
@shoubhik

shoubhik Sep 9, 2019

Contributor

can we rename it to test_forward_qnn_inception_v1_net

qnn_params = dict()
qnn_params['scale'] = float(tflite_qnn_params.ScaleAsNumpy())
qnn_params['zero_point'] = int(tflite_qnn_params.ZeroPointAsNumpy())
if qnn_params['scale'] == 0 and qnn_params['zero_point'] == 0:

This comment has been minimized.

Copy link
@shoubhik

shoubhik Sep 9, 2019

Contributor

can you add a comment what this case means?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.