Skip to content

[Relax] Legalize nn.dropout as inference no-op#19841

Open
guan404ming wants to merge 1 commit into
apache:mainfrom
guan404ming:fix/legalize-nn-dropout
Open

[Relax] Legalize nn.dropout as inference no-op#19841
guan404ming wants to merge 1 commit into
apache:mainfrom
guan404ming:fix/legalize-nn-dropout

Conversation

@guan404ming

Copy link
Copy Markdown
Member

Related Issue

Closed #19695

Why

Building any module containing relax.nn.dropout crashed in VM codegen because the op had no real legalization, and the ONNX frontend could not import it

How

  • Legalize nn.dropout to pass the input through with an all-ones mask, matching its (output, mask) tuple result.
  • Add and register a Dropout converter in the ONNX frontend.
  • Add legalize structural and ONNX onnxruntime-parity tests.

@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 adds support for converting ONNX Dropout nodes to Relax expressions and legalizes the relax.nn.dropout operator as a no-op during inference (returning the input and an all-ones mask). It also includes corresponding tests for both the ONNX frontend and the legalization transformation. The reviewer pointed out that in ONNX Opset 12 and later, the ratio parameter is passed as an optional second input tensor rather than an attribute, meaning the current implementation would ignore custom ratios in newer models. A code suggestion was provided to handle both cases.

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 python/tvm/relax/frontend/onnx/onnx_frontend.py
Signed-off-by: Guan-Ming (Wesley) Chiu <105915352+guan404ming@users.noreply.github.com>
@guan404ming guan404ming force-pushed the fix/legalize-nn-dropout branch from 1495351 to 54108cf Compare June 19, 2026 15:09
@guan404ming guan404ming requested a review from tlopex June 19, 2026 15:11
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][Relax] nn.dropout legalize is a no-op, causing opaque VM codegen crash even at rate=0

1 participant