Repository navigation
Conversation
|
Could someone take a look at the BatchNorm folding guards? The tests check that unsupported cases keep the original graph and that channel-axis folds still work. Jenkins is green. |
|
Hi @javierdejesusda, could you take a look at the BatchNorm folding guards when you get a chance? The tests cover both the supported channel-axis folds and the cases that should keep the original graph. |
javierdejesusda
left a comment
There was a problem hiding this comment.
Thanks for the ping. The guards look correct, but the new tests fail on current main:
check_well_formednow returnsNone(#20793), so drop theassert.tvm.iris gone, so usetvm_tirx.ir.assert_structural_equal.
With those two fixes, all 10 tests pass on main, and the 6 unsupported cases fail without the fix.
Could you add an NHWC case? With an OIHW kernel, batch_norm(axis=3) and H equal to C, main silently folds it into wrong output because the bias broadcasts over H. This PR correctly leaves it alone, but no test covers it.
|
Thanks for checking this, Javier. I updated both test APIs and added the NHWC/OIHW case with height equal to output channels. It fails without the guards, and all 11 tests pass with them. I pushed the update. |
This keeps Conv2D/BatchNorm folding within the contracts supported by its channel-scaling formula:
Unsupported cases retain the original graph. Existing supported channel-axis folds, including a negative channel axis, still run.
Closes #20530
Closes #20531
Closes #20655
Tests:
tests/python/relax/test_transform_fold_batch_norm_to_conv2d.pypassed with the current Python sources and an existing LLVM build.git diff --checkpassed.