jikechao opened a new issue, #14920:
URL: https://github.com/apache/tvm/issues/14920
For the MaxPool2d with 3-dims input, PyTorch can infer it correctly. But,
Load to RealyIR will crash when shape checking and throw: "**Check failed: (0
<= i && i < p->size_) is false: IndexError: indexing 3 on an array of size 3**"
### Actual behavior
```
Traceback (most recent call last):
File "8_index_error.py", line 12, in <module>
mod, params = relay.frontend.from_pytorch(trace, input_shapes)
File "/workplace/software/tvm/tvm/python/tvm/relay/frontend/pytorch.py",
line 4970, in from_pytorch
outputs = converter.convert_operators(operator_nodes, outputs, ret_name)
File "/workplace/software/tvm/tvm/python/tvm/relay/frontend/pytorch.py",
line 4244, in convert_operators
self.record_output_type(relay_out)
File "/workplace/software/tvm/tvm/python/tvm/relay/frontend/pytorch.py",
line 238, in record_output_type
self.infer_type_with_prelude(output)
File "/workplace/software/tvm/tvm/python/tvm/relay/frontend/pytorch.py",
line 174, in infer_type_with_prelude
body = self.infer_type(val, self.prelude.mod)
File "/workplace/software/tvm/tvm/python/tvm/relay/frontend/pytorch.py",
line 167, in infer_type
new_mod = transform.InferType()(new_mod)
File "/workplace/software/tvm/tvm/python/tvm/ir/transform.py", line 160,
in __call__
return _ffi_transform_api.RunPass(self, mod)
File "/workplace/software/tvm/tvm/python/tvm/_ffi/_ctypes/packed_func.py",
line 238, in __call__
raise get_last_ffi_error()
tvm._ffi.base.TVMError: Traceback (most recent call last):
8: TVMFuncCall
7:
tvm::runtime::PackedFuncObj::Extractor<tvm::runtime::PackedFuncSubObj<tvm::runtime::TypedPackedFunc<tvm::IRModule
(tvm::transform::Pass,
tvm::IRModule)>::AssignTypedLambda<tvm::transform::$_6>(tvm::transform::$_6,
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>
>)::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)#1}>
>::Call(tvm::runtime::PackedFuncObj const*, tvm::runtime::TVMArgs,
tvm::runtime::TVMRetValue*)
6: tvm::transform::Pass::operator()(tvm::IRModule) const
5: tvm::transform::Pass::operator()(tvm::IRModule,
tvm::transform::PassContext const&) const
4: tvm::transform::ModulePassNode::operator()(tvm::IRModule,
tvm::transform::PassContext const&) const
3:
tvm::runtime::PackedFuncObj::Extractor<tvm::runtime::PackedFuncSubObj<tvm::runtime::TypedPackedFunc<tvm::IRModule
(tvm::IRModule,
tvm::transform::PassContext)>::AssignTypedLambda<tvm::relay::transform::InferType()::$_2>(tvm::relay::transform::InferType()::$_2)::{lambda(tvm::runtime::TVMArgs
const&, tvm::runtime::TVMRetValue*)#1}> >::Call(tvm::runtime::PackedFuncObj
const*, tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)
2: tvm::relay::TypeInferencer::Infer(tvm::GlobalVar, tvm::relay::Function)
1: tvm::relay::TypeSolver::Solve()
0: _ZN3tvm7runtime6detail
13: TVMFuncCall
12:
tvm::runtime::PackedFuncObj::Extractor<tvm::runtime::PackedFuncSubObj<tvm::runtime::TypedPackedFunc<tvm::IRModule
(tvm::transform::Pass,
tvm::IRModule)>::AssignTypedLambda<tvm::transform::$_6>(tvm::transform::$_6,
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>
>)::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)#1}>
>::Call(tvm::runtime::PackedFuncObj const*, tvm::runtime::TVMArgs,
tvm::runtime::TVMRetValue*)
11: tvm::transform::Pass::operator()(tvm::IRModule) const
10: tvm::transform::Pass::operator()(tvm::IRModule,
tvm::transform::PassContext const&) const
9: tvm::transform::ModulePassNode::operator()(tvm::IRModule,
tvm::transform::PassContext const&) const
8:
tvm::runtime::PackedFuncObj::Extractor<tvm::runtime::PackedFuncSubObj<tvm::runtime::TypedPackedFunc<tvm::IRModule
(tvm::IRModule,
tvm::transform::PassContext)>::AssignTypedLambda<tvm::relay::transform::InferType()::$_2>(tvm::relay::transform::InferType()::$_2)::{lambda(tvm::runtime::TVMArgs
const&, tvm::runtime::TVMRetValue*)#1}> >::Call(tvm::runtime::PackedFuncObj
const*, tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)
7: tvm::relay::TypeInferencer::Infer(tvm::GlobalVar, tvm::relay::Function)
6: tvm::relay::TypeSolver::Solve()
5: tvm::TypedEnvFunc<bool (tvm::runtime::Array<tvm::Type, void> const&,
int, tvm::Attrs const&, tvm::TypeReporter
const&)>::operator()(tvm::runtime::Array<tvm::Type, void> const&, int,
tvm::Attrs const&, tvm::TypeReporter const&) const
4: _ZN3tvm7runtime13Pac
3: tvm::runtime::TypedPackedFunc<bool (tvm::runtime::Array<tvm::Type,
void> const&, int, tvm::Attrs const&, tvm::TypeReporter
const&)>::AssignTypedLambda<bool (*)(tvm::runtime::Array<tvm::Type, void>
const&, int, tvm::Attrs const&, tvm::TypeReporter const&)>(bool
(*)(tvm::runtime::Array<tvm::Type, void> const&, int, tvm::Attrs const&,
tvm::TypeReporter const&))::{lambda(tvm::runtime::TVMArgs const&,
tvm::runtime::TVMRetValue*)#1}::operator()(tvm::runtime::TVMArgs const&,
tvm::runtime::TVMRetValue*) const
2: bool
tvm::relay::Pool2DRel<tvm::relay::MaxPool2DAttrs>(tvm::runtime::Array<tvm::Type,
void> const&, int, tvm::Attrs const&, tvm::TypeReporter const&)
1: tvm::runtime::Array<tvm::PrimExpr, void>::operator[](long) const
0: _ZN3tvm7runtime6detail
File "/workplace/software/tvm/tvm/src/relay/analysis/type_solver.cc", line
643
TVMError:
---------------------------------------------------------------
An error occurred during the execution of TVM.
For more information, please see: https://tvm.apache.org/docs/errors.html
---------------------------------------------------------------
Check failed: (false) is false: [03:09:57]
/workplace/software/tvm/tvm/include/tvm/runtime/container/array.h:414:
---------------------------------------------------------------
An error occurred during the execution of TVM.
For more information, please see: https://tvm.apache.org/docs/errors.html
---------------------------------------------------------------
Check failed: (0 <= i && i < p->size_) is false: IndexError: indexing 3 on
an array of size 3
```
### Steps to reproduce
```
import torch
from tvm import relay
m = torch.nn.MaxPool2d(kernel_size=1)
input_data=[torch.randn([1, 2, 3], dtype=torch.float32)]
torch_outputs = m(*[input.clone() for input in input_data])
trace = torch.jit.trace(m, input_data)
#print(trace.graph)
input_shapes = [('input0', torch.Size([1, 2, 3]))]
mod, params = relay.frontend.from_pytorch(trace, input_shapes)
```
### Triage
* frontend:torch
--
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]