Skip to content

[BugFix] Fix type annotations for T.reshape and T.view (#1768)Fix type annotations for T.reshape and T.view#1773

Closed
ShaobinChen-AH wants to merge 1 commit intotile-ai:mainfrom
ShaobinChen-AH:fix-issue-1768
Closed

[BugFix] Fix type annotations for T.reshape and T.view (#1768)Fix type annotations for T.reshape and T.view#1773
ShaobinChen-AH wants to merge 1 commit intotile-ai:mainfrom
ShaobinChen-AH:fix-issue-1768

Conversation

@ShaobinChen-AH
Copy link
Contributor

@ShaobinChen-AH ShaobinChen-AH commented Feb 2, 2026

Fixes #1768

Problem:
The type annotations for T.reshape and T.view were too strict, causing type checkers (like mypy/Pylance) to incorrectly flag valid code:

T.reshape(x, (32, 2))  # tuple is valid but type checker complained
T.view(x, (32, 2), T.float)  # tuple and T.dtype are valid but flagged


<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Enhancements**
  * `reshape` and `view` operations now accept both list and tuple formats for shape parameters.
  * `view` operations now support expanded dtype parameter options including string and object types.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

👋 Hi! Thank you for contributing to the TileLang project.

Please remember to run pre-commit run --all-files in the root directory of the project to ensure your changes are properly linted and formatted. This will help ensure your contribution passes the format check.

We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work! 🚀

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 2, 2026

📝 Walkthrough

Walkthrough

The PR updates type annotations in customize.py for the reshape and view methods to accept both list and tuple arguments, and broadens the view method's dtype parameter to accept string, object, or None types. No functional changes or runtime behavior modifications.

Changes

Cohort / File(s) Summary
Type Annotation Updates
tilelang/language/customize.py
Expanded type hints for reshape() to accept list[PrimExpr] | tuple[PrimExpr, ...] and for view() to accept shapes as list[PrimExpr] | tuple[PrimExpr, ...] | None and dtype as str | object | None.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 Whiskers twitching with delight,
Tuples and lists now both just right!
Types align with what was meant,
Reshape and view now more extent!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: fixing overly strict type annotations for T.reshape and T.view functions to accept tuple shapes and T.dtype values.
Linked Issues check ✅ Passed The PR successfully addresses all objectives from #1768: it broadens type annotations for reshape to accept list and tuple shapes, expands view to accept both list and tuple shapes plus str/object/None for dtype, and resolves the false-positive type checker errors.
Out of Scope Changes check ✅ Passed All changes are narrowly scoped to fixing type annotations in tilelang/language/customize.py for reshape and view functions, directly addressing the linked issue with no extraneous modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@SiriusNEO
Copy link
Collaborator

@ShaobinChen-AH Thank you for contributing to TileLang! We are planning a systematic overhaul of our type annotations, so this issue will be resolved as part of that larger effort. I'll close this PR for now, but thanks again.

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] Inappropriate type annotation for T.view and T.reshape

2 participants