Convert single layer caffe tests to onnx format#25581
Convert single layer caffe tests to onnx format#25581WanliZhong wants to merge 1 commit intoopencv:5.xfrom
Conversation
|
I removed some layer tests because ONNX doesn't support them. Please leave comments if I should try to keep some of them. |
|
Please restore cafe-specific tests for now. |
|
Friendly reminder. |
0346cb5 to
7e4a326
Compare
| class Test_Caffe_layers : public DNNTestLayer | ||
| { | ||
| public: | ||
| void testLayerUsingOnnxModels(const String& basename, bool useCommonInputBlob = true, double l1 = 0.0, double lInf = 0.0, |
There was a problem hiding this comment.
It's misleading change. Test naming and hierarchy defines that the test are Caffe tests. I proposed to extract base class and 2 derivatives: Test_Caffe_Layers and Test_ONNX_Layers or just have TestLayers as common class. @vpisarev What do you think?
There was a problem hiding this comment.
Onnx layers tests should be in test_onnx_importer.cpp. If we want to extract the tests for Caffe layer, I think we should move them to test_onnx_importer.cpp.
There was a problem hiding this comment.
Keep tests as simple as possible. There are no tests for tests so test code should avoid complications.
It makes sense to create new set of ONNX tests. At least we don't break already existed tests.
Merged with: opencv/opencv_extra#1176 (testdata also should be review)
part of #25314
This PR is used to convert all caffe tests with 'single' layer to onnx format. Tests in
test_int8_layer.cppandtest_caffe_importer.cppwill be removed in #25323Most layers converted by caffe2onnx
Some of them are generated by
pytorchandonnxruntimeSome of them are wrong after converting, so I use onnx-modifier to correct it.
EXTRA NOTE
UPDATE(2024-08): All below tests are kept because we decide to keep Caffe platform.
Remove
layer_lrn_spatial: norm_region isWITHIN_CHANNEL, but ONNX defines the default mode asACROSS_CHANNELS, and if users want it, they may tryBatchNormalization. (ref: LRN in ONNX)Change
layer_deconvolution: onnx doesn't definedeconvolutionoperator, useConvTransposeto replace. (ref: ConvTranspose in ONNX)Remove
InnerProduct: ONNX doesn't define this layer, user may convert it to GEMM or MatMulChange
layer_mvn: onnx doesn't defineMVNoperator, useInstanceNormalizationto replace.Remove
layer_batch_norm_local_stats:use_global_stats: falseis useless in ONNX. (ref: BatchNormalization in ONNX)Remove
layer_eltwise: the model has a node with 2 inputs but from the same layer, which then causes an error. However, we have enough eltwise tests.Remove
accumandaccum_ref: they use1x2x2x4accum1x3x8x12, we can't useADDoperator to replace it.Remove
flow_wrap: ONNX doesn't define this operator.Remove
DataAugmentation: ONNX doesn't define this operator.Remove
nearest_2inpsandnearest: ONNX doesn't defineResampleoperator.Remove
Correlation: ONNX doesn't define this operator.Remove
conv_2_inps: ONNX doesn't support this defination, no need to test it in ONNX.Remove
layer_interp: ONNX doesn't defineInterpoperator.Disabled
net_roi_pooling: can be replaced byRoiAlignoperator in ONNX, but OpenCV dnn doesn't support.Remove
reshape_splice_split: Can't be converted to ONNX format. Because there are many re-use layers in caffe format.Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.