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
[quant][graphmode][fx] Add support for dynamic quant for RNN and RNNCell #49126
Changes from 2 commits
ad64e84
2dbfead
ff4353e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,6 +124,19 @@ def get_static_quant_module_class(float_module_class, additional_static_quant_ma | |
" does not have a corresponding quantized module class" | ||
return static_quant_module_class | ||
|
||
def get_dynamic_quant_module_class(float_module_class, additional_dynamic_quant_mapping=None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would be great to add types to function I/O There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can add it in a separate PR I think, all other functions in this file are not typed yet There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's not blocking this PR, but would be awesome if we started adding these as we go, at least to function I/O. We don't have to wait for a file to have existing type annots to add more. This also distributes the cost of adding them to everyone, as opposed to one person. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, fully agree that we should add types as we change code. I'm saying I plan to add it in a separate PR, or are you suggesting to add the type annotations for the functions in this file in this PR? |
||
r"""n Get the dynamically quantized module class corresponding to | ||
the floating point module class | ||
""" | ||
if additional_dynamic_quant_mapping is None: | ||
additional_dynamic_quant_mapping = {} | ||
all_mappings = get_combined_dict(DEFAULT_DYNAMIC_QUANT_MODULE_MAPPINGS, additional_dynamic_quant_mapping) | ||
dynamic_quant_module_class = all_mappings.get(float_module_class, None) | ||
assert dynamic_quant_module_class is not None, \ | ||
"Floating point module class {}".format(str(float_module_class)) + \ | ||
" does not have a corresponding quantized module class" | ||
return dynamic_quant_module_class | ||
|
||
def get_default_qat_module_mappings(): | ||
''' Get default module mapping for quantization aware training | ||
''' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to test for serialization here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be the same as eager mode module, I'm not very familiar, are we using state_dict?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or are you referring to checkScriptable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added checkScriptable here, but in general we'll do e2e test in TestQuantizeFxModels