-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Model optimizer does not accept float16 model as input #145
Comments
Dear @ed-alertedh According to that document https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/framework/types.proto Thanks, Shubha |
I've re-run the same conversion with debug logging and From what I have gathered exploring the codebase, I also stumbled on what I believe is a latent bug here: https://github.com/opencv/dldt/blob/e206d06f18f9d3c3db29f22c3d496cb3627a16c7/model-optimizer/mo/front/tf/extractors/utils.py#L83
I've decided I will just train in FP32 and convert to FP16 for inference as that appears to be the tested pathway. Tensorflow currently has issues around training in FP16 anyway. I probably won't be attempting a PR for this as it looks like a non-trivial refactor, but I'm happy to clarify any of the comments above if somebody else does end up taking a look at this. |
Dearest @ed-alertedh Thank you for all your careful debugging. I really appreciate it. I will file a bug on your behalf. Sincerely, Shubha |
@ed-alertedh Sorry about this. Hope it helps. Thanks, Shubha |
That's less than ideal, given that the NCS 2 does not support int8 models (according to none other than yourself!) https://software.intel.com/en-us/forums/computer-vision/topic/807527 Actually, one of the reasons I found the NCS 2 device easier to use compared to Google Coral is that quantization isn't required. For now rounding weights from fp32 to fp16 will be OK for my purposes but it is disappointing that Intel isn't willing to support more advanced methods like mixed-precision training or finetuning post-training to make the most of the Myriad hardware which exclusively supports FP16. |
Since I'm targeting an NCS 2 device that only supports FP16 inference, I thought I would try training the model as FP16 in the first place. I trained a relatively simple model with tensorflow and tried to convert from checkpoint with this command:
python $mo_path --input_meta_graph eval_graph/checkpoint-data.meta --output_dir ir_model --data_type FP16
I then got this error message:
According to the proto definition data type 19 is float16. So it seems like the converter does not support fp16->fp16 and will only do fp32->fp16. Am I doing something wrong? If this use-case is unsupported are there plans to support it?
edit: I have done a small amount of experimenting, making notes here in case I need to prepare a PR later
model_optimizer/mo/front/tf/common.py
:('DT_HALF', np.float16, lambda pb: pb.half_val, lambda x: np.float16(x)),
ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (288,) and requested shape (9,1,32)
. Editingmodel_optimizer/mo/front/tf/extractors/utils.py
seemed to make it work enough to produce an output IR model, unsure if this is valid for all cases though:The text was updated successfully, but these errors were encountered: