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

Added MinMax algorithm for OpenVINO backend #1444

Merged
merged 33 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix tests
  • Loading branch information
l-bat committed Jan 18, 2023
commit a4208d0b925e2093b57e8abe39781d465c8a01fb
29 changes: 13 additions & 16 deletions tests/openvino/native/test_metatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
limitations under the License.
"""

from collections import Counter

import pytest
from collections import Counter

from nncf.common.graph.operator_metatypes import InputNoopMetatype
from nncf.common.graph.operator_metatypes import OutputNoopMetatype
Expand All @@ -27,8 +26,6 @@
from nncf.experimental.openvino_native.graph.metatypes.openvino_metatypes import OVReshapeMetatype
from nncf.experimental.openvino_native.graph.metatypes.openvino_metatypes import OVSubtractMetatype
from nncf.experimental.openvino_native.graph.metatypes.openvino_metatypes import OVTransposeMetatype
from nncf.experimental.openvino_native.graph.metatypes.openvino_metatypes import GENERAL_WEIGHT_LAYER_METATYPES

from nncf.experimental.openvino_native.graph.nncf_graph_builder import GraphConverter

from tests.openvino.native.models import ConvModel
Expand Down Expand Up @@ -56,19 +53,19 @@ def test_mapping_openvino_metatypes(model_creator_func, ref_metatypes):


REF_WEIGHTS_PORT_IDS = {
'Conv': 1,
'Conv_backprop': 1,
'MatMul_1': 1,
'MatMul_0': 0,
'Conv': 1,
'Conv_backprop': 1,
'MatMul_1': 1,
'MatMul_0': 0,
}


def test_determining_weights_port():
model = WeightsModel().ov_model
nncf_graph = GraphConverter.create_nncf_graph(model)
counter = 0
for node in nncf_graph.get_all_nodes():
if node.layer_attributes is not None:
counter += 1
assert node.layer_attributes.weight_port_id == REF_WEIGHTS_PORT_IDS[node.node_name]
assert counter == len(REF_WEIGHTS_PORT_IDS)
model = WeightsModel().ov_model
nncf_graph = GraphConverter.create_nncf_graph(model)
counter = 0
for node in nncf_graph.get_all_nodes():
if node.layer_attributes is not None:
counter += 1
assert node.layer_attributes.weight_port_id == REF_WEIGHTS_PORT_IDS[node.node_name]
assert counter == len(REF_WEIGHTS_PORT_IDS)
17 changes: 6 additions & 11 deletions tests/openvino/native/test_statistics_aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,13 @@
"""

import pytest

from typing import List, Tuple

import numpy as np

from nncf import Dataset

from nncf.quantization.algorithms.definitions import RangeType
from nncf.quantization.algorithms.min_max.algorithm import MinMaxQuantizationParameters
from nncf.quantization.algorithms.min_max.algorithm import MinMaxQuantization
from nncf.quantization.algorithms.post_training.algorithm import PostTrainingQuantization
from nncf.quantization.algorithms.post_training.algorithm import PostTrainingQuantizationParameters
from nncf.experimental.openvino_native.statistics.aggregator import OVStatisticsAggregator

from tests.openvino.native.models import LinearModel
Expand All @@ -34,14 +29,14 @@
np.zeros(INPUT_SHAPE, dtype=np.float32),
np.zeros(INPUT_SHAPE, dtype=np.float32)]

DATASET_SAMPLES[0][0][0, 0, 0, 0] = 128 # max
DATASET_SAMPLES[0][0][0, 0, 0, 1] = -128 # min
DATASET_SAMPLES[0][0, 0, 0, 0] = 128 # max
DATASET_SAMPLES[0][0, 0, 0, 1] = -128 # min

DATASET_SAMPLES[1][0][0, 0, 0, 0] = 1 # max
DATASET_SAMPLES[1][0][0, 0, 0, 1] = -10 # min
DATASET_SAMPLES[1][0, 0, 0, 0] = 1 # max
DATASET_SAMPLES[1][0, 0, 0, 1] = -10 # min

DATASET_SAMPLES[2][0][0, 0, 0, 0] = 0.1 # max
DATASET_SAMPLES[2][0][0, 0, 0, 1] = -1 # min
DATASET_SAMPLES[2][0, 0, 0, 0] = 0.1 # max
DATASET_SAMPLES[2][0, 0, 0, 1] = -1 # min


class TestParameters:
Expand Down