Skip to content

[BugFix][TOPI] Fix get_const_tuple hanging indefinitely when passed a te.Tensor#19380

Open
tlopex wants to merge 1 commit intoapache:mainfrom
tlopex:fix190
Open

[BugFix][TOPI] Fix get_const_tuple hanging indefinitely when passed a te.Tensor#19380
tlopex wants to merge 1 commit intoapache:mainfrom
tlopex:fix190

Conversation

@tlopex
Copy link
Copy Markdown
Member

@tlopex tlopex commented Apr 10, 2026

This pr fixes #18765: topi.get_const_tuple hangs indefinitely when passed a te.Tensor instead of a shape tuple and adds a type check to raise a clear TypeError with a helpful message suggesting get_const_tuple(tensor.shape) instead

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
if isinstance(in_tuple, te.tensor.Tensor):
if isinstance(in_tuple, te.Tensor):

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.

[Bug] topi.get_const_tuple hangs indefinitely when passed a te.Placeholder

1 participant