[tmva][sofie] Account for dilation in Conv2D same padding calculation#21685
[tmva][sofie] Account for dilation in Conv2D same padding calculation#21685harz05 wants to merge 4 commits intoroot-project:masterfrom
Conversation
sanjibansg
left a comment
There was a problem hiding this comment.
Hi @harz05,
Thanks for this PR. Can you add a test so that we can verify this patch?
Test Results 22 files 22 suites 3d 7h 32m 39s ⏱️ Results for commit 345e072. ♻️ This comment has been updated with latest results. |
|
Hello @sanjibansg, I tried adding a numerical test with Conv2D(kernel=3, padding='same', dilation_rate=2) on 8×8 input and on testing locally I found that the output shape was correct (8x8x4=256 vs 144 before the fix), confirming the padding calculation works. |
Hi @harz05, |
|
hello @sanjibansg |
|
There was a clang and ruff formatting issue during the run, I fixed that. CI was also getting Windows x86 failure but i'm not really sure what's the issue in that. |
69ba440 to
31adb8d
Compare
|
hello @sanjibansg ,sorry for the noisy commit history, I was trying to fix the ruff formatting issue and accidentally did a rebase that pulled in a ton of upstream master commits into the branch. I've force pushed a clean branch with just the 4 PR commits now |
Changes
The
padding='same'calculation in the Keras Conv2D parser was using the raw kernel size instead of the effective kernel size, which for dilated convolutions isdilation * (kernel - 1) + 1.fAttrDilationswas extracted from the layer attributes but never factored into the padding formula.For
dilation=2, kernel=3, input=8, stride=1the old formula produced padding=2 while the correct value is 4, causing the generated inference code to operate on tensors with wrong spatial dimensions. Withdilation=1the effective kernel size reduces to the raw kernel size, so existing models are unaffected.Checklist
This PR fixes #21684