mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-30 20:18:08 +00:00
Adding test case for conv per channel with QDQ format (#13041)
**Description**: Adding test case for conv per channel with QDQ format
This commit is contained in:
parent
2ae33b3613
commit
44c14e8cbb
1 changed files with 13 additions and 1 deletions
|
|
@ -236,6 +236,15 @@ class TestQDQExtraOptions(unittest.TestCase):
|
|||
|
||||
|
||||
class TestQDQFormatConv(TestQDQFormat):
|
||||
def check_per_channel_counts(self, model_path, channel_count: int, axis: int = 0):
|
||||
model = onnx.load(Path(model_path))
|
||||
for initializer in model.graph.initializer:
|
||||
dims = initializer.dims
|
||||
# skip if initializer is not a weight
|
||||
if len(dims) > 0:
|
||||
self.assertGreater(len(dims), axis)
|
||||
self.assertEqual(channel_count, dims[axis])
|
||||
|
||||
def construct_model_conv(self, output_model_path, input_shape, weight_shape, output_shape, has_bias):
|
||||
# (input)
|
||||
# |
|
||||
|
|
@ -281,8 +290,9 @@ class TestQDQFormatConv(TestQDQFormat):
|
|||
model_fp32_path = "conv_fp32.{}.{}.onnx".format(has_bias, per_channel)
|
||||
model_int8_qdq_path = "conv_quant_qdq.{}.{}.onnx".format(has_bias, per_channel)
|
||||
model_int8_qop_path = "conv_quant_qop.{}.{}.onnx".format(has_bias, per_channel)
|
||||
channel_count = 16
|
||||
data_reader = self.input_feeds(1, {"input": [1, 8, 33, 33]})
|
||||
self.construct_model_conv(model_fp32_path, [1, 8, 33, 33], [16, 8, 3, 3], [1, 16, 31, 31], has_bias)
|
||||
self.construct_model_conv(model_fp32_path, [1, 8, 33, 33], [channel_count, 8, 3, 3], [1, 16, 31, 31], has_bias)
|
||||
quantize_static(
|
||||
model_fp32_path,
|
||||
model_int8_qdq_path,
|
||||
|
|
@ -301,6 +311,8 @@ class TestQDQFormatConv(TestQDQFormat):
|
|||
"DequantizeLinear": 4 if has_bias else 3,
|
||||
}
|
||||
check_op_type_count(self, model_int8_qdq_path, **qdq_nodes)
|
||||
if per_channel:
|
||||
self.check_per_channel_counts(model_int8_qdq_path, channel_count)
|
||||
check_model_correctness(self, model_fp32_path, model_int8_qdq_path, data_reader.get_next())
|
||||
|
||||
data_reader.rewind()
|
||||
|
|
|
|||
Loading…
Reference in a new issue