-
Notifications
You must be signed in to change notification settings - Fork 227
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
[PTQ][OV] Fix inplace statistic reducers names and hashes #1796
[PTQ][OV] Fix inplace statistic reducers names and hashes #1796
Conversation
e1b3883
to
52f5100
Compare
7981448
to
15c38fa
Compare
Conformance tests showed no regressions |
@@ -39,6 +39,7 @@ def __init__(self, reduction_shape: Optional[ReductionShape] = None, inplace: bo | |||
|
|||
""" | |||
self._reduction_shape = reduction_shape | |||
self._init_reduction_shape = reduction_shape |
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.
What is the difference between self._reduction_shape
and self._init_reduction_shape
? They have the same value, as I can see.
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.
The problem is that reduction_shape is needed to calculate reducer hash value to distinguish two different reducer with equal class. In case reduction shape is None at the beginning, it's calculated on first iteration
nncf/nncf/experimental/common/tensor_statistics/collectors.py
Lines 94 to 95 in 16d18e8
if self._reduction_shape is None: | |
self._reduction_shape = tuple(range(len(x[0].shape))) |
TensorCollector
will be invalid after the first iteration. This _init_reduction_shape
doesn't change during reducer life so it's safe for hash calculation
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.
It looks like if reduction_shape is None than the reducer should reduce by all dimensions. I suggest to implement this logic in each reducer not in the base class. You can implement the method to create reduction shape by tensor and use it in any inhered class.
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.
Done, please check
16d18e8
to
e9f9c8d
Compare
@@ -39,6 +39,7 @@ def __init__(self, reduction_shape: Optional[ReductionShape] = None, inplace: bo | |||
|
|||
""" | |||
self._reduction_shape = reduction_shape | |||
self._init_reduction_shape = reduction_shape |
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.
It looks like if reduction_shape is None than the reducer should reduce by all dimensions. I suggest to implement this logic in each reducer not in the base class. You can implement the method to create reduction shape by tensor and use it in any inhered class.
Full check showed on regression on this PR, it safe to merge it to develop and release |
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.
LGTM
…1827) Copy of #1796 ### Changes Names of reducers is used instead of types of reducers to name statistic subnet operations Reducer names now differs one from another if they have different attributes and aren't merged Hash of reducer now take into account reduction_shape ### Reason for changes To fix problem when two different statistics that are instances of one class and share target point have equal name ### Related tickets 109989 ### Tests Test on reducers merging Test with a model that have target point with two different reducers that are instances of one class --------- Co-authored-by: Nikita Savelyev <nikita.savelyev@intel.com>
Changes
reduction_shape
Reason for changes
To fix problem when two different statistics that are instances of one class and share target point have equal name
Related tickets
109989
Tests
TODO: