Merge pull request #14959 from dvd42:onnx_clip
authorDiego <diegovd0296@gmail.com>
Thu, 4 Jul 2019 05:56:00 +0000 (07:56 +0200)
committerAlexander Alekhin <alexander.a.alekhin@gmail.com>
Thu, 4 Jul 2019 05:56:00 +0000 (08:56 +0300)
* onnx clip operation

modules/dnn/src/onnx/onnx_importer.cpp
modules/dnn/test/test_onnx_importer.cpp

index 696588c..b9fb0be 100644 (file)
@@ -530,6 +530,13 @@ void ONNXImporter::populateNet(Net dstNet)
                 layerParams.type = "Power";
             }
         }
+        else if (layer_type == "Clip")
+        {
+            layerParams.type = "ReLU6";
+            replaceLayerParam(layerParams, "min", "min_value");
+            replaceLayerParam(layerParams, "max", "max_value");
+
+        }
         else if (layer_type == "LeakyRelu")
         {
             layerParams.type = "ReLU";
index c99b8cf..1862394 100644 (file)
@@ -136,6 +136,11 @@ TEST_P(Test_ONNX_layers, ReLU)
     testONNXModels("ReLU");
 }
 
+TEST_P(Test_ONNX_layers, Clip)
+{
+    testONNXModels("clip", npy);
+}
+
 TEST_P(Test_ONNX_layers, MaxPooling_Sigmoid)
 {
     testONNXModels("maxpooling_sigmoid");