Skip to content

[Relax] Clean up deprecated void-dtype sentinel usage#19908

Merged
tqchen merged 3 commits into
apache:mainfrom
guan404ming:relax-dtype-cleanup
Jun 30, 2026
Merged

[Relax] Clean up deprecated void-dtype sentinel usage#19908
tqchen merged 3 commits into
apache:mainfrom
guan404ming:relax-dtype-cleanup

Conversation

@guan404ming

Copy link
Copy Markdown
Member

Why

After #19890 moved Relax dtype to optional, two spots still used the deprecated DLDataType{kDLOpaqueHandle, 0, 0} void sentinel.

How

  • Drop the now-unreachable unknown-dtype branch in IsBoolType (handled earlier by IsUnknownDtype()).
  • Replace the raw void-sentinel comparison in ones/zeros with PrimType::IsVoid().

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

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.

Code Review

This pull request refactors void data type checks in the ones and zeros operators and simplifies boolean type matching in IsBoolType. The reviewer suggested optimizing the void checks in ones and zeros by using DataType(dtype).is_void() instead of PrimType(dtype).IsVoid(), which avoids unnecessary heap allocation and reference counting overhead.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/relax/op/tensor/create.cc Outdated
Comment thread src/relax/op/tensor/create.cc Outdated
Comment thread src/relax/op/tensor/create.cc Outdated
Expr ones(Expr shape, DLDataType dtype) {
TVM_FFI_ICHECK((dtype != DLDataType{kDLOpaqueHandle, 0, 0}))
<< "Ones op expects the input dtype not to be void";
TVM_FFI_ICHECK(!PrimType(dtype).IsVoid()) << "Ones op expects the input dtype not to be void";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we can simply drop is void check here for now

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sure, just removed.

Comment thread src/relax/op/tensor/create.cc Outdated
Expr zeros(Expr shape, DLDataType dtype) {
TVM_FFI_ICHECK((dtype != DLDataType{kDLOpaqueHandle, 0, 0}))
<< "Zeros op expects the input dtype not to be void";
TVM_FFI_ICHECK(!PrimType(dtype).IsVoid()) << "Zeros op expects the input dtype not to be void";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we can simply drop is voidcheck hre for now

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ditto.

Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>
Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>
@guan404ming guan404ming force-pushed the relax-dtype-cleanup branch from d3f925e to 7a58808 Compare June 30, 2026 01:37
Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>
@guan404ming guan404ming force-pushed the relax-dtype-cleanup branch from 7a58808 to a0a266b Compare June 30, 2026 08:17
@tqchen tqchen merged commit ad694c4 into apache:main Jun 30, 2026
9 checks passed
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.

2 participants