[BugFix][TOPI] Fix get_const_tuple hanging indefinitely when passed a te.Tensor#19380
[BugFix][TOPI] Fix get_const_tuple hanging indefinitely when passed a te.Tensor#19380tlopex wants to merge 1 commit intoapache:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a type check in the get_const_tuple function within python/tvm/topi/utils.py to ensure it receives a tuple-like shape rather than a te.Tensor object, providing a more helpful error message for common usage mistakes. The review feedback suggests using the more idiomatic te.Tensor reference instead of te.tensor.Tensor to maintain consistency with the TVM codebase and avoid potential attribute errors.
| out_tuple : tuple of int | ||
| The output. | ||
| """ | ||
| if isinstance(in_tuple, te.tensor.Tensor): |
There was a problem hiding this comment.
For consistency with other parts of this file (e.g., line 272) and the error message itself (line 192), please use te.Tensor instead of te.tensor.Tensor. This is more idiomatic in the TVM codebase when te is imported from tvm, and avoids potential AttributeError if the tensor submodule is not explicitly exported in the te namespace.
| if isinstance(in_tuple, te.tensor.Tensor): | |
| if isinstance(in_tuple, te.Tensor): |
This pr fixes #18765:
topi.get_const_tuplehangs indefinitely when passed ate.Tensorinstead of a shape tuple and adds a type check to raise a clearTypeErrorwith a helpful message suggestingget_const_tuple(tensor.shape)instead