Merge pull request #22611 from zihaomu:greaterOrEqual

DNN: support GreaterOrEqual and LessOrEqual op in ONNX
pull/22593/head
Alexander Smorkalov 2 years ago committed by GitHub
commit 3419e64dcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      modules/dnn/src/layers/nary_eltwise_layers.cpp
  2. 6
      modules/dnn/src/onnx/onnx_importer.cpp
  3. 10
      modules/dnn/test/test_onnx_importer.cpp

@ -51,11 +51,11 @@ public:
op = OPERATION::EQUAL;
else if (operation == "greater")
op = OPERATION::GREATER;
else if (operation == "greater_equal")
else if (operation == "greaterorequal")
op = OPERATION::GREATER_EQUAL;
else if (operation == "less")
op = OPERATION::LESS;
else if (operation == "less_equal")
else if (operation == "lessorequal")
op = OPERATION::LESS_EQUAL;
else if (operation == "pow")
op = OPERATION::POW;

@ -2912,7 +2912,7 @@ void ONNXImporter::parseCumSum(LayerParams& layerParams, const opencv_onnx::Node
addLayer(layerParams, node_proto);
}
// "Equal" "Greater" "Less" "Pow" "Add" "Sub" "Mul" "Div" "Sum" "Min" "Max"
// "Equal" "Greater" "Less" "Pow" "Add" "Sub" "Mul" "Div" "Sum" "Min" "Max" "GreaterOrEqual" "LessOrEqual"
void ONNXImporter::parseElementWise(LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto_)
{
opencv_onnx::NodeProto node_proto = node_proto_;
@ -3721,7 +3721,9 @@ void ONNXImporter::buildDispatchMap_ONNX_AI(int opset_version)
dispatch["SpaceToDepth"] = dispatch["DepthToSpace"] = &ONNXImporter::parseDepthToSpace;
dispatch["Equal"] = dispatch["Greater"] = dispatch["Less"] = dispatch["Pow"] = dispatch["Add"] =
dispatch["Sub"] = dispatch["Mul"] = dispatch["Div"] = &ONNXImporter::parseElementWise;
dispatch["Sub"] = dispatch["Mul"] = dispatch["Div"] = dispatch["GreaterOrEqual"] =
dispatch["LessOrEqual"] = &ONNXImporter::parseElementWise;
dispatch["Sum"] = dispatch["Min"] = dispatch["Max"] = &ONNXImporter::parseElementWise;
dispatch["Range"] = &ONNXImporter::parseRange;

@ -682,6 +682,16 @@ TEST_P(Test_ONNX_layers, Compare_LT)
testONNXModels("less");
}
TEST_P(Test_ONNX_layers, Compare_GTorEQ)
{
testONNXModels("greater_or_equal");
}
TEST_P(Test_ONNX_layers, Compare_LEorEQ)
{
testONNXModels("less_or_equal");
}
TEST_P(Test_ONNX_layers, CompareSameDims_EQ)
{
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2022010000)

Loading…
Cancel
Save