{"record":{"id":"9b074de4d4ab9681","repo":"tracel-ai/burn","slug":"backend-not-supported-for-custom-op","errorCode":null,"errorMessage":"Backend not supported for custom op `{}`","messagePattern":"Backend not supported for custom op `(.+?)`","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-backend-extension/src/extension.rs","lineNumber":497,"sourceCode":"            bool,\n        ) = {\n            #routing_tensor_init\n            #autodiff_context\n            let __backend_tag = match &__routing_tensor.kind {\n                #ad_tag_arm\n                #( #concrete_tag_arms )*\n                #[allow(unreachable_patterns)]\n                _ => usize::MAX,\n            };\n            (\n                __backend_tag,\n                __ad_ctx,\n                __routing_tensor_is_float,\n            )\n        };\n        match (__burn_backend_tag, __has_float_input) {\n            #( #dispatch_arms )*\n            _ => unimplemented!(\"Backend not supported for custom op `{}`\", stringify!(#name)),\n        }\n    }\n}\n\n/// Generate all context routes for one selected concrete backend.\nfn gen_tensor_input_backend_arm(\n    ir: &Extension,\n    op: &Operation,\n    backend: &Backend,\n    i: usize,\n    ad_cfg_attr: &Option<TokenStream2>,\n) -> TokenStream2 {\n    let cfg_attr = backend.cfg_attr.clone();\n    let routes = routing::extension_backend_routes(\n        op,\n        &backend.ident,\n        ir.backends.autodiff.0,\n        ad_cfg_attr.as_ref(),","sourceCodeStart":479,"sourceCodeEnd":515,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-backend-extension/src/extension.rs#L479-L515","documentation":"The burn-backend-extension codegen's gen_tensor_input_dispatch_body (crates/burn-backend-extension/src/extension.rs:497) generates a match over backend tags for a custom op; if the runtime backend tag does not match any generated dispatch arm, the generated code calls unimplemented!(\"Backend not supported for custom op `{}`\"). This means the custom op was declared without support for the backend actually being used.","triggerScenarios":"Invoking a custom op (via #[burn_extension]) with a backend that was not enabled/declared in the op's backend list, so no dispatch arm matches and the fallback arm panics.","commonSituations":"Declaring a custom op only for wgpu/cubecl backends and then running it with ndarray (CPU), or enabling a backend feature after op registration without re-declaring backend support.","solutions":["Add the missing backend to the custom op's declaration (its backend list / feature gates) so a dispatch arm is generated.","Enable the corresponding crate feature so the backend arm is compiled in.","Route the call to a backend that the op supports."],"exampleFix":"// before\n#[extension(op)]\n#[.backends(wgpu)]\nfn my_op(x: Tensor) -> Tensor { ... }\n// run with NdArray -> panic\n// after\n#[extension(op)]\n#[.backends(wgpu, ndarray)]\nfn my_op(x: Tensor) -> Tensor { ... }","handlingStrategy":"validation","validationCode":"// compile-time: list every backend you run with in the op declaration\n#[.backends(wgpu, ndarray)] // ensure all target backends are declared","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare every backend your app may route to in the custom op's backend list.","Enable all needed backend features at build time so dispatch arms compile in.","Test custom ops on each target backend in CI."],"tags":["rust","burn","custom-op","codegen","backend"],"backgroundTag":"backend-not-supported-for-custom-op","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"}