-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
Added IsInf layer to new DNN engine #27660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 5.x
Are you sure you want to change the base?
Conversation
// Copyright (C) 2025, BigVision LLC, all rights reserved. | ||
// Third party copyrights are property of their respective owners. | ||
|
||
#include "../precomp.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please, put the link to description of the operation at onnx.ai and also specify, which opsets are supported.
for (size_t i = 0; i < count; ++i) | ||
{ | ||
const T v = src[i]; | ||
const bool pos = cvIsInf(v) && (v > 0) && detectPositive; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would split this into different loops:
if (detectPositive && detectNegative) {
for (...) ... // just check for cvIsInf()
} else if (detectPositive) {
for (...) ... // cvIsInf(v) && v > 0
} else if (detectNegative) {
for (...) ... // cvIsInf(v) && v < 0
} else {
// report error?
}
template <typename T> | ||
static inline void computeIsInfMask(const T* src, uchar* dst, const size_t count, const bool detectPositive, const bool detectNegative) | ||
{ | ||
for (size_t i = 0; i < count; ++i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be nice to make this loop parallel just to eliminate possible bottlenecks when everything else in the model graph is parallel
|
||
switch (depth) { | ||
case CV_32F: computeIsInfMask<float>(X.ptr<float>(), dst, total, detect_pos, detect_neg); break; | ||
case CV_64F: computeIsInfMask<double>(X.ptr<double>(), dst, total, detect_pos, detect_neg); break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bfloat and hfloat should be supported as well. 1) Add optional WT=T parameter to computeIsInfMask. 2) Change T v = src[i];
to WT v = WT(src[i]);
. 3) use WT=float for hfloat and bfloat
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.