Skip to content

Commit 8d7c57b

Browse files
Comments
1 parent aac080e commit 8d7c57b

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

tests/openvino/native/models.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,42 @@ def _create_ov_model(self, is_int8=False, with_multiply=False, n_layers=8):
10651065
return model
10661066

10671067

1068+
class AWQModel(OVReferenceModel):
1069+
OUTPUT_DIM = 32
1070+
HIDDEN_DIM = 16
1071+
INPUT_SHAPE = [1, 24, HIDDEN_DIM] # [B, SeqLen, HiddenDim]
1072+
1073+
def _create_ov_model(
1074+
self,
1075+
transpose_b: bool = True,
1076+
transpose_a: bool = False,
1077+
input_shape: Optional[list[int]] = None,
1078+
is_int8=False,
1079+
):
1080+
self._input_shape = self.INPUT_SHAPE if input_shape is None else input_shape
1081+
hdim_axis = -2 if transpose_a else -1
1082+
self._hidden_dim = self._input_shape[hdim_axis]
1083+
input_1 = opset.parameter(self._input_shape, name="Input")
1084+
weight_shape = self.get_weight_shape(transpose_b)
1085+
data = self._rng.random(weight_shape).astype(np.float32)
1086+
1087+
weights = AWQMatmulModel.get_weights(data, is_int8=is_int8, name="weights_1")
1088+
1089+
matmul = opset.matmul(input_1, weights, transpose_a=transpose_a, transpose_b=transpose_b, name="MatMul")
1090+
1091+
result = opset.result(matmul, name="Result")
1092+
result.get_output_tensor(0).set_names(set(["Result"]))
1093+
model = ov.Model([result], [input_1])
1094+
return model
1095+
1096+
@property
1097+
def hidden_dim(self):
1098+
return self._hidden_dim
1099+
1100+
def get_weight_shape(self, transpose_b: bool = True):
1101+
return [self.OUTPUT_DIM, self.hidden_dim] if transpose_b else [self.hidden_dim, self.OUTPUT_DIM]
1102+
1103+
10681104
class AWQModel_fp16_overlow(OVReferenceModel):
10691105
"""
10701106
Model for testing AWQ algorithm with fp16 overflow fix.

tests/openvino/native/quantization/test_weights_compression.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
from tests.openvino.native.common import get_actual_reference_for_current_openvino
6666
from tests.openvino.native.models import AWQActMatmulModel
6767
from tests.openvino.native.models import AWQMatmulModel
68+
from tests.openvino.native.models import AWQModel
6869
from tests.openvino.native.models import AWQModel_fp16_overlow
6970
from tests.openvino.native.models import DifferentChannelSizeMatmulModel
7071
from tests.openvino.native.models import GatherAndMatmulShareData
@@ -1803,6 +1804,14 @@ def test_compression_with_different_algo_combinations(input_shape, kwargs):
18031804
)
18041805

18051806

1807+
@pytest.mark.parametrize(
1808+
"model_cls",
1809+
[
1810+
(LMLinearModel),
1811+
(AWQModel),
1812+
],
1813+
ids=["lm_linear", "awq_model"],
1814+
)
18061815
@pytest.mark.parametrize(
18071816
("transpose_a", "transpose_b", "raises_error"),
18081817
[
@@ -1827,9 +1836,9 @@ def test_compression_with_different_algo_combinations(input_shape, kwargs):
18271836
],
18281837
ids=["se", "lora", "gptq_se_awq"],
18291838
)
1830-
def test_compression_with_transpose(transpose_a, transpose_b, raises_error, kwargs):
1839+
def test_compression_with_transpose(model_cls, transpose_a, transpose_b, raises_error, kwargs):
18311840
dataset_size = 4
1832-
model = LMLinearModel(transpose_a=transpose_a, transpose_b=transpose_b).ov_model
1841+
model = model_cls(transpose_a=transpose_a, transpose_b=transpose_b).ov_model
18331842
input_data = [np.ones(inp.shape) for inp in model.inputs] * dataset_size
18341843
dataset = Dataset(input_data)
18351844

0 commit comments

Comments
 (0)