-
Notifications
You must be signed in to change notification settings - Fork 246
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
Added MinMax algorithm for OpenVINO backend #1444
Conversation
@@ -31,18 +31,42 @@ def get_all_aliases(cls) -> List[str]: | |||
return cls.op_names | |||
|
|||
|
|||
@dataclass | |||
class OpWeightDef: |
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.
I wonder if this is needed at all to keep only one property of operation? If not, maybe it is more reasonable just to keep his inside operation, e.g. to have weight_channel_axis
within the operation.
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.
deleted
""" | ||
Contains the information about the weight of the operation. | ||
|
||
:param weight_channel_axis: Axis for weight per-channel quantization, meaning the number of output filters. |
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.
I would suggest using the plural term, like weights
and activations
everywhere because this is what we use to describe the DL model content, not weight and activation of the model
.
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.
Class has been deleted
@@ -44,14 +45,19 @@ def transform(self, transformation_layout: TransformationLayout) -> ov.Model: | |||
:param transformations: lisf of the TransformationCommand transformations. | |||
""" | |||
output_insert_transformations = [] | |||
quantizer_insert_transformations = [] |
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.
following the name below _apply_quantizer_insertion_transformations
, you should call it like quantizer_insertion_transformations
.
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.
fixed
:param graph: NNCFGraph. | ||
""" | ||
ov_dtype = node.get_element_type().get_type_name() | ||
nncf_dtype = GraphConverter.convert_ov_dtype_to_nncf_dtype(ov_dtype) |
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.
Suggest renaming convert_ov_dtype_to_nncf_dtype
to convert_to_nncf_dtype
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.
Renamed
ov_dtype = node.get_element_type().get_type_name() | ||
nncf_dtype = GraphConverter.convert_ov_dtype_to_nncf_dtype(ov_dtype) | ||
node_type = node.get_type_name() | ||
metatype = OV_OPERATION_METATYPES.get_operator_metatype_by_op_name(node_type) |
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.
Some discrepancy between the naming operation
and operator
.
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
model_type: Optional[ModelType] = None, | ||
ignored_scope: Optional[IgnoredScope] = None) -> ov.Model: | ||
""" | ||
Implementation of the `quantize()` method for the OpenVINO backend via the Model API. |
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.
Model API
is something that exists in OMZ. I would call it like ...for the OpenVINO backend via the OpenVINO Runtime API.
from nncf.experimental.openvino_native.statistics.statistics import OVMeanTensorStatistic | ||
|
||
|
||
class OVNNCFCollectorTensorProcessor(NNCFCollectorTensorProcessor): |
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.
Did I get right that we use an external statistic collection mechanism now? Any plans for the in-place statistics?
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.
@l-bat, could you file a ticket based on this comment?
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.
ticket: 100927
nncf/experimental/openvino_native/quantization/algorithms/min_max/openvino_backend.py
Show resolved
Hide resolved
51d3503
to
7a38b99
Compare
7107431
to
d73e13d
Compare
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.
Cool staff! Please rebase your PR on develop.
from nncf.experimental.openvino_native.statistics.statistics import OVMeanTensorStatistic | ||
|
||
|
||
class OVNNCFCollectorTensorProcessor(NNCFCollectorTensorProcessor): |
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.
@l-bat, could you file a ticket based on this comment?
nncf/experimental/openvino_native/quantization/quantizer_parameters.py
Outdated
Show resolved
Hide resolved
eddd407
to
2393314
Compare
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.
Looks great 👍
d6efded
to
bd20cc9
Compare
from dataclasses import dataclass | ||
import numpy as np |
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.
from dataclasses import dataclass | |
import numpy as np | |
from dataclasses import dataclass | |
import numpy as np |
@@ -11,15 +11,20 @@ | |||
limitations under the License. | |||
""" | |||
import os | |||
import json |
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.
Imports should be grouped in the following order:
- Standard library imports.
- Related third-party imports.
- Local application/library-specific imports.
You should put a blank line between each group of imports.
https://github.com/openvinotoolkit/nncf/blob/develop/docs/styleguide/PyGuide.md#22-imports
9a38c1b
to
803b9fc
Compare
803b9fc
to
40d14d4
Compare
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. Please, reply on minor comments from my side.
nncf/experimental/openvino_native/quantization/algorithms/min_max/openvino_backend.py
Outdated
Show resolved
Hide resolved
run tensorflow pre-commit tests |
@@ -37,27 +52,40 @@ def __init__(self, model: ov.Model): | |||
super().__init__(model) | |||
self._model = model.clone() | |||
self.name_to_node_mapping = {op.get_friendly_name(): op for op in self._model.get_ops()} | |||
self._model_precision = ModelPrecision.FP32 |
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.
Even after MO we can have mixed precision when some subgraphs can be still in FP32 while most of the model is in FP16. I wonder why precision is so important on the model level.
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.
I found the answer below but still, I am not sure that we can judge based on the type of the first constant.
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.
ticket: 101738
return nncf_graph | ||
|
||
|
||
class OVWeightedLayerAttributes(BaseLayerAttributes): |
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 name does not reflect the content. It can be OVConstPortId
or so.
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.
I promise I will rename it in the next PR
Changes
Reason for changes
Related tickets
Tests