mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
Merge pull request #20535 from SamFC10:onnx-q
dnn : int8 quantized layers support in onnx importer * added quantized layers support in onnx importer * added more cases in eltwise node, some more checks * added tests for quantized nodes * relax thresholds for failed tests, address review comments * refactoring based on review comments * added support for unsupported cases and pre-quantized resnet50 test * relax thresholds due to int8 resize layer
This commit is contained in:
@@ -991,6 +991,112 @@ TEST_P(Test_ONNX_layers, ConvResizePool1d)
|
||||
testONNXModels("conv_resize_pool_1d");
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_layers, Quantized_Convolution)
|
||||
{
|
||||
testONNXModels("quantized_conv_uint8_weights", npy, 0.004, 0.02);
|
||||
testONNXModels("quantized_conv_int8_weights", npy, 0.03, 0.5);
|
||||
testONNXModels("quantized_conv_per_channel_weights", npy, 0.06, 0.4);
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_layers, Quantized_MatMul)
|
||||
{
|
||||
testONNXModels("quantized_matmul_uint8_weights", npy, 0.005, 0.007);
|
||||
testONNXModels("quantized_matmul_int8_weights", npy, 0.06, 0.2);
|
||||
testONNXModels("quantized_matmul_per_channel_weights", npy, 0.06, 0.22);
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_layers, Quantized_MatMul_Variable_Weights)
|
||||
{
|
||||
// Unsupported
|
||||
EXPECT_THROW(
|
||||
{
|
||||
testONNXModels("quantized_matmul_variable_inputs");
|
||||
}, cv::Exception);
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_layers, Quantized_Eltwise)
|
||||
{
|
||||
testONNXModels("quantized_eltwise");
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_layers, Quantized_Eltwise_Scalar)
|
||||
{
|
||||
testONNXModels("quantized_eltwise_scalar");
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_layers, Quantized_Eltwise_Broadcast)
|
||||
{
|
||||
testONNXModels("quantized_eltwise_broadcast");
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_layers, Quantized_LeakyReLU)
|
||||
{
|
||||
testONNXModels("quantized_leaky_relu");
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_layers, Quantized_Sigmoid)
|
||||
{
|
||||
testONNXModels("quantized_sigmoid");
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_layers, Quantized_MaxPool)
|
||||
{
|
||||
testONNXModels("quantized_maxpool");
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_layers, Quantized_AvgPool)
|
||||
{
|
||||
testONNXModels("quantized_avgpool");
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_layers, Quantized_Split)
|
||||
{
|
||||
testONNXModels("quantized_split");
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_layers, Quantized_Pad)
|
||||
{
|
||||
testONNXModels("quantized_padding");
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_layers, Quantized_Reshape)
|
||||
{
|
||||
testONNXModels("quantized_reshape");
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_layers, Quantized_Transpose)
|
||||
{
|
||||
testONNXModels("quantized_transpose");
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_layers, Quantized_Squeeze)
|
||||
{
|
||||
testONNXModels("quantized_squeeze");
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_layers, Quantized_Unsqueeze)
|
||||
{
|
||||
testONNXModels("quantized_unsqueeze");
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_layers, Quantized_Resize)
|
||||
{
|
||||
testONNXModels("quantized_resize_nearest");
|
||||
testONNXModels("quantized_resize_bilinear", npy, 2e-4, 0.003);
|
||||
testONNXModels("quantized_resize_bilinear_align", npy, 3e-4, 0.003);
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_layers, Quantized_Concat)
|
||||
{
|
||||
testONNXModels("quantized_concat");
|
||||
testONNXModels("quantized_concat_const_blob");
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_layers, Quantized_Constant)
|
||||
{
|
||||
testONNXModels("quantized_constant", npy, 0.002, 0.008);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(/*nothing*/, Test_ONNX_layers, dnnBackendsAndTargets());
|
||||
|
||||
class Test_ONNX_nets : public Test_ONNX_layers
|
||||
@@ -1127,6 +1233,11 @@ TEST_P(Test_ONNX_nets, ResNet50v1)
|
||||
testONNXModels("resnet50v1", pb, default_l1, default_lInf, true, target != DNN_TARGET_MYRIAD);
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_nets, ResNet50_Int8)
|
||||
{
|
||||
testONNXModels("resnet50_int8", pb, default_l1, default_lInf, true);
|
||||
}
|
||||
|
||||
TEST_P(Test_ONNX_nets, ResNet101_DUC_HDC)
|
||||
{
|
||||
applyTestTag(CV_TEST_TAG_VERYLONG);
|
||||
|
||||
Reference in New Issue
Block a user