{"record":{"id":"a7c5f24ae040acdf","repo":"tracel-ai/burn","slug":"max-pool3d-backward-unsupported-index-dtype-othe","errorCode":null,"errorMessage":"max_pool3d_backward: unsupported index dtype {other:?}","messagePattern":"max_pool3d_backward: unsupported index dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/pool.rs","lineNumber":90,"sourceCode":"/// Generates adaptive_avg_pool3d typed dispatchers.\nmacro_rules! adaptive_avg_pool3d_typed {\n    ($fn_name:ident, $T:ty, $dtype:expr, $zero:expr, $div_fn:expr) => {\n        pub fn $fn_name(x: FlexTensor, output_size: [usize; 3]) -> FlexTensor {\n            adaptive_avg_pool3d_impl::<$T, _>(x, output_size, $dtype, $zero, $div_fn)\n        }\n    };\n}\n\n/// Generates max_pool3d_backward typed dispatchers.\nmacro_rules! max_pool3d_backward_typed {\n    ($fn_name:ident, $T:ty, $dtype:expr, $zero:expr) => {\n        pub fn $fn_name(x: FlexTensor, grad: FlexTensor, indices: FlexTensor) -> FlexTensor {\n            match indices.dtype() {\n                DType::I64 => max_pool3d_backward_impl::<$T, i64>(x, grad, indices, $dtype, $zero),\n                DType::I32 => max_pool3d_backward_impl::<$T, i32>(x, grad, indices, $dtype, $zero),\n                DType::I16 => max_pool3d_backward_impl::<$T, i16>(x, grad, indices, $dtype, $zero),\n                DType::I8 => max_pool3d_backward_impl::<$T, i8>(x, grad, indices, $dtype, $zero),\n                other => panic!(\"max_pool3d_backward: unsupported index dtype {other:?}\",),\n            }\n        }\n    };\n}\n\n/// Generates avg_pool3d_backward typed dispatchers.\nmacro_rules! avg_pool3d_backward_typed {\n    ($fn_name:ident, $T:ty, $dtype:expr, $zero:expr, $div_fn:expr) => {\n        pub fn $fn_name(\n            x: FlexTensor,\n            grad: FlexTensor,\n            kernel_size: [usize; 3],\n            stride: [usize; 3],\n            padding: [usize; 3],\n            count_include_pad: bool,\n        ) -> FlexTensor {\n            avg_pool3d_backward_impl::<$T>(\n                x,","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/pool.rs#L72-L108","documentation":"burn-flex's generated max_pool3d_backward dispatcher matches the pooling `indices` tensor dtype against signed integer types (I64, I32, I16, I8) and panics for anything else. Max-pool backward needs integer argmax indices; an unsigned, float, bool, or quantized index dtype has no kernel, so the autodiff backward pass aborts.","triggerScenarios":"Running backward through `max_pool3d` when the saved indices tensor has a dtype outside I8–I64 — e.g. indices stored/cast as U32 or U8, or a float tensor mistakenly passed as indices.","commonSituations":"Custom checkpointing in burn-autodiff that serializes indices as unsigned; casting indices to unsigned for compact storage and forgetting to restore; hand-constructed grads feeding pool backward directly.","solutions":["Ensure the indices tensor passed to max_pool3d backward has a signed int dtype (I32 is the typical default): `indices.cast(DType::I32)`.","Check any serialization/checkpoint path for casts of indices to unsigned types and keep them signed.","If you control the forward call, leave indices in the backend's default int dtype instead of converting."],"exampleFix":"// before\nlet indices = raw_indices.cast(DType::U32);\nlet grad_x = max_pool3d_backward(x, grad, indices);\n// after\nlet indices = raw_indices.cast(DType::I32);\nlet grad_x = max_pool3d_backward(x, grad, indices);","handlingStrategy":"validation","validationCode":"assert!(matches!(indices.dtype(), DType::I64 | DType::I32 | DType::I16 | DType::I8), \"max_pool3d_backward indices must be signed ints, got {:?}\", indices.dtype());","typeGuard":"fn is_signed_int(d: DType) -> bool {\n    matches!(d, DType::I64 | DType::I32 | DType::I16 | DType::I8)\n}","tryCatchPattern":null,"preventionTips":["Never cast pooling indices to unsigned or float dtypes.","Keep indices in the backend default (I32) through checkpointing.","Audit serialization code for dtype conversions of indices."],"tags":["rust","burn","autodiff","max-pool","dtype","panic"],"backgroundTag":"unsupported-dtype","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"}