Thrsu opened a new issue, #15393:
URL: https://github.com/apache/tvm/issues/15393
When the `beta` parameter of `torch.nn.Softplus` is set to 0, the TVMError:
"Check failed: fb->value != 0 (0 vs. 0) : Divide by zero" is raised.
### Expected behavior
TVM get the same output with the PyTorch output, PyTorch output is as below:
```
tensor([[inf, inf, inf, inf, inf, inf, inf],
[inf, inf, inf, inf, inf, inf, inf],
[inf, inf, inf, inf, inf, inf, inf],
[inf, inf, inf, inf, inf, inf, inf],
[inf, inf, inf, inf, inf, inf, inf],
[inf, inf, inf, inf, inf, inf, inf],
[inf, inf, inf, inf, inf, inf, inf],
[inf, inf, inf, inf, inf, inf, inf],
[inf, inf, inf, inf, inf, inf, inf],
[inf, inf, inf, inf, inf, inf, inf],
[inf, inf, inf, inf, inf, inf, inf],
[inf, inf, inf, inf, inf, inf, inf],
[inf, inf, inf, inf, inf, inf, inf],
[inf, inf, inf, inf, inf, inf, inf]], dtype=torch.float64)
```
### Actual behavior
```
Traceback (most recent call last):
File "1_repro.py", line 20, in <module>
exe = relay.create_executor('graph', mod=mod, params=params,
device=tvm.device('llvm', 0), target='llvm').evaluate()
File
"/workplace/software/tvm/tvm_/python/tvm/relay/backend/interpreter.py", line
171, in evaluate
return self._make_executor()
File "/workplace/software/tvm/tvm_/python/tvm/relay/build_module.py", line
519, in _make_executor
mod = build(self.mod, target=self.target)
File "/workplace/software/tvm/tvm_/python/tvm/relay/build_module.py", line
372, in build
mod_name=mod_name,
File "/workplace/software/tvm/tvm_/python/tvm/relay/build_module.py", line
169, in build
mod_name,
File
"/workplace/software/tvm/tvm_/python/tvm/_ffi/_ctypes/packed_func.py", line
237, in __call__
raise get_last_ffi_error()
tvm._ffi.base.TVMError: Traceback (most recent call last):
78: TVMFuncCall
77:
tvm::relay::backend::RelayBuildModule::GetFunction(std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&,
tvm::runtime::ObjectPtr<tvm::runtime::Object>
const&)::{lambda(tvm::runtime::TVMArgs,
tvm::runtime::TVMRetValue*)#3}::operator()(tvm::runtime::TVMArgs,
tvm::runtime::TVMRetValue*) const
76: tvm::relay::backend::RelayBuildModule::Build(tvm::IRModule,
tvm::runtime::Array<tvm::Target, void> const&, tvm::Target const&,
tvm::relay::Executor const&, tvm::relay::Runtime const&,
tvm::WorkspaceMemoryPools const&, tvm::ConstantMemoryPools const&,
tvm::runtime::String)
75: tvm::relay::backend::RelayBuildModule::BuildRelay(tvm::IRModule,
tvm::runtime::String const&)
74: tvm::relay::backend::ExecutorCodegen::Codegen(tvm::IRModule,
tvm::relay::Function const&, tvm::runtime::String)
73: void tvm::relay::backend::ExecutorCodegen::CallFunc<tvm::IRModule,
tvm::relay::Function, tvm::runtime::String>(std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&, tvm::IRModule,
tvm::relay::Function, tvm::runtime::String)
72:
tvm::relay::backend::GraphExecutorCodegenModule::GetFunction(std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&,
tvm::runtime::ObjectPtr<tvm::runtime::Object>
const&)::{lambda(tvm::runtime::TVMArgs,
tvm::runtime::TVMRetValue*)#2}::operator()(tvm::runtime::TVMArgs,
tvm::runtime::TVMRetValue*) const
71: tvm::relay::backend::GraphExecutorCodegen::Codegen(tvm::IRModule,
tvm::relay::Function, tvm::runtime::String)
70: tvm::transform::Pass::operator()(tvm::IRModule) const
69: tvm::transform::Pass::operator()(tvm::IRModule,
tvm::transform::PassContext const&) const
68: tvm::transform::SequentialNode::operator()(tvm::IRModule,
tvm::transform::PassContext const&) const
67: tvm::transform::Pass::operator()(tvm::IRModule,
tvm::transform::PassContext const&) const
66: tvm::transform::ModulePassNode::operator()(tvm::IRModule,
tvm::transform::PassContext const&) const
65:
tvm::runtime::PackedFuncObj::Extractor<tvm::runtime::PackedFuncSubObj<tvm::runtime::TypedPackedFunc<tvm::IRModule
(tvm::IRModule,
tvm::transform::PassContext)>::AssignTypedLambda<tvm::relay::tec::LowerTE(tvm::runtime::String,
tvm::CompilationConfig, std::function<void
(tvm::BaseFunc)>)::$_8>(tvm::relay::tec::LowerTE(tvm::runtime::String,
tvm::CompilationConfig, std::function<void
(tvm::BaseFunc)>)::$_8)::{lambda(tvm::runtime::TVMArgs const&,
tvm::runtime::TVMRetValue*)#1}> >::Call(tvm::runtime::PackedFuncObj const*,
tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)
64: tvm::relay::tec::LowerTE(tvm::IRModule const&, tvm::runtime::String
const&, std::function<void (tvm::BaseFunc)>, tvm::CompilationConfig)
63: tvm::transform::Pass::operator()(tvm::IRModule) const
62: tvm::transform::Pass::operator()(tvm::IRModule,
tvm::transform::PassContext const&) const
61: tvm::relay::transform::FunctionPassNode::operator()(tvm::IRModule,
tvm::transform::PassContext const&) const
60:
tvm::runtime::PackedFuncObj::Extractor<tvm::runtime::PackedFuncSubObj<tvm::runtime::TypedPackedFunc<tvm::relay::Function
(tvm::relay::Function, tvm::IRModule,
tvm::transform::PassContext)>::AssignTypedLambda<tvm::relay::tec::LowerTensorExpr(tvm::relay::tec::TECompiler,
std::function<void (tvm::BaseFunc)>,
tvm::CompilationConfig)::$_7>(tvm::relay::tec::LowerTensorExpr(tvm::relay::tec::TECompiler,
std::function<void (tvm::BaseFunc)>,
tvm::CompilationConfig)::$_7)::{lambda(tvm::runtime::TVMArgs const&,
tvm::runtime::TVMRetValue*)#1}> >::Call(tvm::runtime::PackedFuncObj const*,
tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)
59: tvm::relay::ExprMutator::VisitExpr(tvm::RelayExpr const&)
58: tvm::relay::ExprFunctor<tvm::RelayExpr (tvm::RelayExpr
const&)>::VisitExpr(tvm::RelayExpr const&)
57: tvm::NodeFunctor<tvm::RelayExpr (tvm::runtime::ObjectRef const&,
tvm::relay::ExprFunctor<tvm::RelayExpr (tvm::RelayExpr
const&)>*)>::operator()(tvm::runtime::ObjectRef const&,
tvm::relay::ExprFunctor<tvm::RelayExpr (tvm::RelayExpr const&)>*) const
56: _ZZN3tvm5relay11ExprFunc
55:
tvm::relay::transform::DeviceAwareExprMutator::VisitExpr_(tvm::relay::FunctionNode
const*)
54:
tvm::relay::tec::LowerTensorExprMutator::DeviceAwareVisitExpr_(tvm::relay::FunctionNode
const*)
53: _ZN3tvm5relay9
52: tvm::relay::ExprMutator::VisitExpr_(tvm::relay::FunctionNode const*)
51: tvm::relay::ExprMutator::VisitExpr(tvm::RelayExpr const&)
50: tvm::relay::ExprFunctor<tvm::RelayExpr (tvm::RelayExpr
const&)>::VisitExpr(tvm::RelayExpr const&)
49: tvm::NodeFunctor<tvm::RelayExpr (tvm::runtime::ObjectRef const&,
tvm::relay::ExprFunctor<tvm::RelayExpr (tvm::RelayExpr
const&)>*)>::operator()(tvm::runtime::ObjectRef const&,
tvm::relay::ExprFunctor<tvm::RelayExpr (tvm::RelayExpr const&)>*) const
48: _ZZN3tvm5relay11ExprFunc
47:
tvm::relay::transform::DeviceAwareExprMutator::VisitExpr_(tvm::relay::CallNode
const*)
46:
tvm::relay::tec::LowerTensorExprMutator::DeviceAwareVisitExpr_(tvm::relay::CallNode
const*)
45: tvm::relay::tec::TECompilerImpl::Lower(tvm::relay::tec::CCacheKey
const&)
44:
tvm::relay::tec::TECompilerImpl::LowerInternal(tvm::relay::tec::CCacheKey
const&, tvm::GlobalVarSupply)
43: tvm::LowerSchedule(tvm::te::Schedule,
tvm::runtime::Array<tvm::te::Tensor, void> const&,
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >
const&, std::unordered_map<tvm::te::Tensor, tvm::tir::Buffer,
std::hash<tvm::te::Tensor>, std::equal_to<tvm::te::Tensor>,
std::allocator<std::pair<tvm::te::Tensor const, tvm::tir::Buffer> > > const&,
tvm::GlobalVarSupply, bool)
42: tvm::LowerSchedule(tvm::te::Schedule,
tvm::runtime::Array<tvm::runtime::ObjectRef, void> const&,
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >
const&, std::unordered_map<tvm::te::Tensor, tvm::tir::Buffer,
std::hash<tvm::te::Tensor>, std::equal_to<tvm::te::Tensor>,
std::allocator<std::pair<tvm::te::Tensor const, tvm::tir::Buffer> > > const&,
tvm::GlobalVarSupply, bool)
41: tvm::LowerWithPassList(tvm::IRModule,
tvm::runtime::Array<tvm::transform::Pass, void>)
40: tvm::transform::Pass::operator()(tvm::IRModule) const
39: tvm::transform::Pass::operator()(tvm::IRModule,
tvm::transform::PassContext const&) const
38: tvm::transform::SequentialNode::operator()(tvm::IRModule,
tvm::transform::PassContext const&) const
37: tvm::transform::Pass::operator()(tvm::IRModule,
tvm::transform::PassContext const&) const
36: tvm::tir::transform::PrimFuncPassNode::operator()(tvm::IRModule,
tvm::transform::PassContext const&) const
35:
tvm::runtime::PackedFuncObj::Extractor<tvm::runtime::PackedFuncSubObj<tvm::runtime::TypedPackedFunc<tvm::tir::PrimFunc
(tvm::tir::PrimFunc, tvm::IRModule,
tvm::transform::PassContext)>::AssignTypedLambda<tvm::tir::transform::Simplify()::$_1>(tvm::tir::transform::Simplify()::$_1)::{lambda(tvm::runtime::TVMArgs
const&, tvm::runtime::TVMRetValue*)#1}> >::Call(tvm::runtime::PackedFuncObj
const*, tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)
34: tvm::arith::StmtSimplifier::Apply(tvm::tir::Stmt,
tvm::arith::Analyzer*, tvm::runtime::Optional<tvm::arith::SimplifyConfig>)
33: tvm::arith::StmtSimplifier::VisitStmt(tvm::tir::Stmt const&)
32: tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt
const&)>::VisitStmt(tvm::tir::Stmt const&)
31: tvm::NodeFunctor<tvm::tir::Stmt (tvm::runtime::ObjectRef const&,
tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt
const&)>*)>::operator()(tvm::runtime::ObjectRef const&,
tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt const&)>*) const
30: _ZZN3tvm3tir11StmtFuncto
29: tvm::arith::StmtSimplifier::VisitStmt_(tvm::tir::ForNode const*)
28: tvm::arith::IRMutatorWithAnalyzer::VisitStmt_(tvm::tir::ForNode const*)
27: tvm::tir::StmtMutator::VisitStmt_(tvm::tir::ForNode const*)
26: tvm::arith::StmtSimplifier::VisitStmt(tvm::tir::Stmt const&)
25: tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt
const&)>::VisitStmt(tvm::tir::Stmt const&)
24: tvm::NodeFunctor<tvm::tir::Stmt (tvm::runtime::ObjectRef const&,
tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt
const&)>*)>::operator()(tvm::runtime::ObjectRef const&,
tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt const&)>*) const
23: _ZZN3tvm3tir11StmtFuncto
22: tvm::arith::StmtSimplifier::VisitStmt_(tvm::tir::ForNode const*)
21: tvm::arith::IRMutatorWithAnalyzer::VisitStmt_(tvm::tir::ForNode const*)
20: tvm::tir::StmtMutator::VisitStmt_(tvm::tir::ForNode const*)
19: tvm::arith::StmtSimplifier::VisitStmt(tvm::tir::Stmt const&)
18: tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt
const&)>::VisitStmt(tvm::tir::Stmt const&)
17: tvm::NodeFunctor<tvm::tir::Stmt (tvm::runtime::ObjectRef const&,
tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt
const&)>*)>::operator()(tvm::runtime::ObjectRef const&,
tvm::tir::StmtFunctor<tvm::tir::Stmt (tvm::tir::Stmt const&)>*) const
16: _ZZN3tvm3tir11StmtFuncto
15: tvm::arith::StmtSimplifier::VisitStmt_(tvm::tir::BufferStoreNode
const*)
14: tvm::tir::StmtMutator::VisitStmt_(tvm::tir::BufferStoreNode const*)
13: tvm::arith::StmtSimplifier::VisitExpr(tvm::PrimExpr const&)
12: tvm::arith::Analyzer::Simplify(tvm::PrimExpr const&, int)
11: tvm::arith::CanonicalSimplifier::operator()(tvm::PrimExpr const&)
10: tvm::arith::CanonicalSimplifier::Impl::CanonicalSimplify(tvm::PrimExpr)
9: _ZThn16_N3tvm5arit
8: tvm::arith::CanonicalSimplifier::Impl::VisitExpr(tvm::PrimExpr const&)
7: tvm::tir::ExprFunctor<tvm::PrimExpr (tvm::PrimExpr
const&)>::VisitExpr(tvm::PrimExpr const&)
6: 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
5: _ZZN3tvm3tir11ExprFuncto
4: _ZThn16_N3tvm5arit
3: tvm::arith::CanonicalSimplifier::Impl::VisitExpr_(tvm::tir::DivNode
const*)
2: tvm::arith::RewriteSimplifier::Impl::VisitExpr_(tvm::tir::DivNode
const*)
1: tvm::runtime::Optional<tvm::PrimExpr>
tvm::arith::TryConstFold<tvm::tir::Div>(tvm::PrimExpr, tvm::PrimExpr)
0: _ZN3tvm7runtime6detail
File "/workplace/software/tvm/tvm_/src/arith/const_fold.h", line 245
TVMError:
---------------------------------------------------------------
An error occurred during the execution of TVM.
For more information, please see: https://tvm.apache.org/docs/errors.html
---------------------------------------------------------------
Check failed: fb->value != 0 (0 vs. 0) : Divide by zero
```
### Environment
- TVM: latest
- Pytorch: 1.13.1+cu117
### Steps to reproduce
```Python
import torch
from tvm import relay
import tvm
import numpy as np
m = torch.nn.Softplus(beta=0,)
input_data = torch.tensor(torch.randn([14, 7], dtype=torch.float64))
torch_outputs = m(input_data)
trace = torch.jit.trace(m, input_data)
input_shapes = [('input0', torch.Size([14, 7]))]
mod, params = relay.frontend.from_pytorch(trace, input_shapes)
input_data_np = input_data.numpy()
with tvm.transform.PassContext(opt_level=3):
exe = relay.create_executor('graph', mod=mod, params=params,
device=tvm.device('llvm', 0), target='llvm').evaluate()
input_tvm = {'input0': tvm.nd.array(input_data_np.astype(np.float64))}
tvm_outputs = exe(**input_tvm).asnumpy()
np.testing.assert_allclose(torch_outputs, tvm_outputs, rtol=1e-3, atol=1e-3)
```
### Triage
* needs-triage
* frontend:torch
Is this a bug in TVM?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]