1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

Merge pull request #28248 from ramukhsuya:tflite-minimum-support

DNN: Add TFLite Minimum layer support
This commit is contained in:
Alexander Smorkalov
2025-12-20 13:18:33 +03:00
committed by GitHub
2 changed files with 32 additions and 1 deletions
+4 -1
View File
@@ -288,7 +288,7 @@ TFLiteImporter::DispatchMap TFLiteImporter::buildDispatchMap()
dispatch["ADD"] = dispatch["MUL"] = dispatch["SUB"] =
dispatch["SQRT"] = dispatch["DIV"] = dispatch["NEG"] =
dispatch["RSQRT"] = dispatch["SQUARED_DIFFERENCE"] =
dispatch["MAXIMUM"] = &TFLiteImporter::parseEltwise;
dispatch["MAXIMUM"] = dispatch["MINIMUM"]= &TFLiteImporter::parseEltwise;
dispatch["RELU"] = dispatch["PRELU"] = dispatch["HARD_SWISH"] =
dispatch["LOGISTIC"] = dispatch["LEAKY_RELU"] = &TFLiteImporter::parseActivation;
dispatch["MAX_POOL_2D"] = dispatch["AVERAGE_POOL_2D"] = &TFLiteImporter::parsePooling;
@@ -581,6 +581,9 @@ void TFLiteImporter::parseEltwise(const Operator& op, const std::string& opcode,
}
else if (opcode == "MAXIMUM" && !isOpInt8) {
layerParams.set("operation", "max");
}
else if (opcode == "MINIMUM" && !isOpInt8) {
layerParams.set("operation", "min");
}else {
CV_Error(Error::StsNotImplemented, cv::format("DNN/TFLite: Unknown opcode for %s Eltwise layer '%s'", isOpInt8 ? "INT8" : "FP32", opcode.c_str()));
}
+28
View File
@@ -311,6 +311,34 @@ TEST_P(Test_TFLite, maximum)
normAssert(ref, out, "", l1, lInf);
}
TEST_P(Test_TFLite, minimum)
{
Net net = readNetFromTFLite(findDataFile("dnn/tflite/minimum.tflite"));
net.setPreferableBackend(backend);
net.setPreferableTarget(target);
Mat input_x = blobFromNPY(findDataFile("dnn/tflite/minimum_input_x.npy"));
Mat input_y = blobFromNPY(findDataFile("dnn/tflite/minimum_input_y.npy"));
net.setInput(input_x, "x");
net.setInput(input_y, "y");
Mat out = net.forward();
Mat ref = blobFromNPY(findDataFile("dnn/tflite/minimum_output.npy"));
double l1 = 1e-5;
double lInf = 1e-4;
if (target == DNN_TARGET_CUDA_FP16 || target == DNN_TARGET_OPENCL_FP16)
{
l1 = 1e-3;
lInf = 1e-3;
}
normAssert(ref, out, "", l1, lInf);
}
INSTANTIATE_TEST_CASE_P(/**/, Test_TFLite, dnnBackendsAndTargets());
}} // namespace