-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[Relay, Topi, TF Frontend] Isfinite operator #4981
Conversation
Please help in reviewing this: @jwfromm, @huajsj, @yzhliu, @zxy844288792 |
@@ -38,6 +38,8 @@ | |||
from tvm import te | |||
from tvm import relay | |||
import tvm.relay.testing.tf as tf_testing | |||
from tensorflow.python.framework import dtypes |
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.
We don't need to import this, just use tf.float32
and tf.float64
instead.
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.
removed
include/tvm/tir/op.h
Outdated
@@ -58,6 +58,13 @@ TVM_DLL PrimExpr max_value(const DataType& dtype); | |||
*/ | |||
TVM_DLL PrimExpr min_value(const DataType& dtype); | |||
|
|||
/*! | |||
* Get the infinity. |
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.
"Get the value of infinity."
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.
corrected
@@ -829,6 +829,7 @@ class CallNode : public PrimExprNode { | |||
static constexpr const char* glsl_texture_store = "glsl_texture_store"; | |||
static constexpr const char* prefetch = "prefetch"; | |||
static constexpr const char* isnan = "isnan"; |
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.
Is it worth adding an isinf
operator to this PR? That way we can check for both halves of isfinite separately if needed. I'm not sure if you'd ever need to check for just infinity rather than both nan and infinity though.
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.
Added support for isinf as well.
@jwfromm Thanks for the review and comments. I have added support for isinf op as well. |
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.
Thanks for the changes! LGTM
@jwfromm could you help in merging this? |
@masahi, @tqchen, @FrozenGene, I think this PR is ready to merge. Can one of you take a quick look and pull the trigger? |
What is the use case of this op in tensorflow? Having to check finite-ness inside DL models seems very weird to me. If there is indeed a possibility of infinity to show up, something (model or data) is broken anyway, so it is not a problem for us. Error handling should be done in earlier layers before TVM. |
@masahi, Yes generally it does not make sense to use finiteness check inside DL model. It can be generally used in preprocessing input data etc but not in the model. We had received a model from the customer which was using this operator. We do not know the exact use case though. But there is a possibility that this operator appears in the DL models. Also, will it be useful considering training support in TVM? |
If it is only TF frontend change, it is totally fine. But you also added a new relay/topi op, and even added new TIR intrinsics, just to support that customer's model. That makes me concerned. TVM is supposed to support other frameworks not just TF, and if we start adding these framework specific corner case ops, it quickly leads to code bloat. I prefer adding new ops only if they could be useful across different frameworks. People use TVM because they want to go fast. Having finteness check doesn't help with that. You should talk to your customer if they can remove it, or if it is fine for us to ignore
I don't know if it is useful to training. Maybe @MarisaKirisame can comment. |
@maheshambule also check out the proposal by @soiferj below. If you need to support TF models, this should be a good solution. |
Generally speaking, I think |
I also found Still not sure what the use case is. We have to use VM runtime, which has some overhead, if these ops are used together with if/else. |
@FrozenGene I grepped through the Halide code base, isinf/isnan don't seem to be in Halide's IR, but they use |
halide/Halide@697b4be this commit add |
@maheshambule There is a conflict, please rebase |
Merging it for now, thanks @maheshambule @jwfromm @FrozenGene |
Thanks @masahi. |
* isfinite doc update * isfinit expr * isfinit expr * isfinite schedule reg * isfinite python binding * isfinite python binding * relay register isfinite * isfinite type relation * intrin isfinite * topi isfinite * testcase topi isfinite * tf frontend isfinite * tf frontend isfinite testcase * test case relay isfinite * small fixes * test forward tf isfinite * test cases injective for cuda * remove float16 test case * add support for isinf * remove unwanted import * fix conflict
* isfinite doc update * isfinit expr * isfinit expr * isfinite schedule reg * isfinite python binding * isfinite python binding * relay register isfinite * isfinite type relation * intrin isfinite * topi isfinite * testcase topi isfinite * tf frontend isfinite * tf frontend isfinite testcase * test case relay isfinite * small fixes * test forward tf isfinite * test cases injective for cuda * remove float16 test case * add support for isinf * remove unwanted import * fix conflict
Added support for isfinite operator.
@yongwww, @zhiics, @kevinthesun, @FrozenGene
Could you please review the PR?