{"record":{"id":"d698f335ce13bf66","repo":"tracel-ai/burn","slug":"same-padding-with-an-even-kernel-size-is-not-suppo","errorCode":null,"errorMessage":"Same padding with an even kernel size is not supported","messagePattern":"Same padding with an even kernel size is not supported","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-nn/src/modules/conv/checks.rs","lineNumber":19,"sourceCode":"pub(crate) fn checks_channels_div_groups(channels_in: usize, channels_out: usize, groups: usize) {\n    let channels_in_div_by_group = channels_in.is_multiple_of(groups);\n    let channels_out_div_by_group = channels_out.is_multiple_of(groups);\n\n    if !channels_in_div_by_group || !channels_out_div_by_group {\n        panic!(\n            \"Both channels must be divisible by the number of groups. Got \\\n             channels_in={channels_in}, channels_out={channels_out}, groups={groups}\"\n        );\n    }\n}\n\n// https://github.com/tracel-ai/burn/issues/2676\n/// Only symmetric padding is currently supported. As such, using `Same` padding with an even kernel\n/// size is not supported as it will not produce the same output size.\npub(crate) fn check_same_padding_support(kernel_size: &[usize]) {\n    for k in kernel_size.iter() {\n        if k % 2 == 0 {\n            unimplemented!(\"Same padding with an even kernel size is not supported\");\n        }\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-nn/src/modules/conv/checks.rs#L1-L23","documentation":"Configuration guard in conv layer checks: `padding: SamePadding` was requested with an even kernel size, which burn's conv implementation cannot express as symmetric padding (see burn issue #2676); construction of the layer panics.","triggerScenarios":"Thrown at crates/burn-nn/src/modules/conv/checks.rs:19 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use an odd kernel size (e.g., 3 instead of 2) with SamePadding","Switch to explicit numeric padding that yields the desired output size","Pad the input manually before the convolution"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}