Skip to content
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

[autodiff] change truncdiv to div in EliminateDivModMutator #7943

Merged
merged 1 commit into from
Apr 30, 2021

Conversation

hgt312
Copy link
Contributor

@hgt312 hgt312 commented Apr 29, 2021

With this change, I can use te.gradient on roi_align. Otherwise, there will be:

TVMError:
---------------------------------------------------------------
An internal invariant was violated during the execution of TVM.
Please read TVM's error reporting guidelines.
More details can be found here: https://discuss.tvm.ai/t/error-reporting/7793.
---------------------------------------------------------------
  Check failed: (a.dtype().is_int() || a.dtype().is_uint()) is false: ((float32(rv) + 0.5f)*(max((placeholder[i, 4] - placeholder[i, 2]), 1f)*0.142857f))
Stack trace:
  File "../3rdparty/tvm/src/tir/op/op.cc", line 343
  [bt] (0) 1   libtvm.dylib                        0x00000001275ea4ce tvm::runtime::Backtrace() + 30
  [bt] (1) 2   libtvm.dylib                        0x00000001245cc7c5 tvm::runtime::detail::LogFatal::Entry::Finalize() + 149
  [bt] (2) 3   libtvm.dylib                        0x00000001245cc71d tvm::runtime::detail::LogFatal::~LogFatal() + 29
  [bt] (3) 4   libtvm.dylib                        0x00000001245ca465 tvm::runtime::detail::LogFatal::~LogFatal() + 21
  [bt] (4) 5   libtvm.dylib                        0x00000001255a7e1e tvm::truncdiv(tvm::PrimExpr, tvm::PrimExpr, tvm::Span) + 318
  [bt] (5) 6   libtvm.dylib                        0x0000000125017b46 tvm::te::EliminateDivModMutator::VisitExpr_(tvm::tir::DivNode const*) + 1670
  [bt] (6) 7   libtvm.dylib                        0x000000012462f59f tvm::tir::ExprFunctor<tvm::PrimExpr (tvm::PrimExpr const&)>::InitVTable()::'lambda9'(tvm::runtime::ObjectRef const&, tvm::tir::ExprFunctor<tvm::PrimExpr (tvm::PrimExpr const&)>*)::operator()(tvm::runtime::ObjectRef const&, tvm::tir::ExprFunctor<tvm::PrimExpr (tvm::PrimExpr const&)>*) const + 79
  [bt] (7) 8   libtvm.dylib                        0x000000012462f544 tvm::tir::ExprFunctor<tvm::PrimExpr (tvm::PrimExpr const&)>::InitVTable()::'lambda9'(tvm::runtime::ObjectRef const&, tvm::tir::ExprFunctor<tvm::PrimExpr (tvm::PrimExpr const&)>*)::__invoke(tvm::runtime::ObjectRef const&, tvm::tir::ExprFunctor<tvm::PrimExpr (tvm::PrimExpr const&)>*) + 36
  [bt] (8) 9   libtvm.dylib                        0x0000000124629740 tvm::NodeFunctor<tvm::PrimExpr (tvm::runtime::ObjectRef const&, tvm::tir::ExprFunctor<tvm::PrimExpr (tvm::PrimExpr const&)>*)>::operator()(tvm::runtime::ObjectRef const&, tvm::tir::ExprFunctor<tvm::PrimExpr (tvm::PrimExpr const&)>*) const + 464

@yzhliu

Copy link
Member

@yzhliu yzhliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we change truncmod->mod in visit(mod) as well?
@sergei-grechanik could you double check?

@sergei-grechanik
Copy link
Contributor

So the problem is that DivNode may be used for both integers and floats, but truncdiv checks that its arguments are actually integers. The change looks correct. I don't think that we need to change the ModNode case, I guess it cannot be used with floats, although I'm not 100% sure about that (but it seems, truncmod doesn't check if the arguments are integers, at least not directly).

@yzhliu yzhliu merged commit 49ffab1 into apache:main Apr 30, 2021
@yzhliu
Copy link
Member

yzhliu commented Apr 30, 2021

Thanks @hgt312 @sergei-grechanik

umangyadav pushed a commit to umangyadav/tvm that referenced this pull request May 5, 2021
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request May 6, 2021
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request May 6, 2021
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request May 6, 2021
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request May 11, 2021
@hgt312 hgt312 deleted the fix_ad_simplify branch December 12, 2021 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants