{"record":{"id":"e1391fe517663b12","repo":"tracel-ai/burn","slug":"other-reduction-is-not-supported-e1391f","errorCode":null,"errorMessage":"{other:?} reduction is not supported","messagePattern":"(.+?) reduction is not supported","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-nn/src/loss/gaussian_nll.rs","lineNumber":91,"sourceCode":"    ///\n    /// # Shapes\n    ///\n    /// - input:  `[...dims]` (predicted mean)\n    /// - target: `[...dims]`\n    /// - var:    `[...dims]` (predicted variance, positive)\n    /// - output: `[1]`\n    pub fn forward<const D: usize>(\n        &self,\n        input: Tensor<D>,\n        target: Tensor<D>,\n        var: Tensor<D>,\n        reduction: Reduction,\n    ) -> Tensor<1> {\n        let loss = self.forward_no_reduction(input, target, var);\n        match reduction {\n            Reduction::Mean | Reduction::Auto => loss.mean(),\n            Reduction::Sum => loss.sum(),\n            other => panic!(\"{other:?} reduction is not supported\"),\n        }\n    }\n\n    /// Compute the loss element-wise.\n    ///\n    /// # Shapes\n    ///\n    /// - input:  `[...dims]` (predicted mean)\n    /// - target: `[...dims]`\n    /// - var:    `[...dims]` (predicted variance, positive)\n    /// - output: `[...dims]`\n    pub fn forward_no_reduction<const D: usize>(\n        &self,\n        input: Tensor<D>,\n        target: Tensor<D>,\n        var: Tensor<D>,\n    ) -> Tensor<D> {\n        // Clamp the variance for numerical stability.","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-nn/src/loss/gaussian_nll.rs#L73-L109","documentation":"GaussianNllLoss::forward accepts only Mean, Auto, and Sum reductions and panics on any other variant. It computes the element-wise loss via forward_no_reduction and then reduces; unknown reductions are rejected with this panic.","triggerScenarios":"Calling GaussianNllLoss::forward(input, target, var, reduction) where reduction is Reduction::None or any variant outside Mean/Auto/Sum.","commonSituations":"Translating PyTorch GaussianNLLLoss(reduction='none') usage to burn; a shared LossReduction config field flowing into this loss; typos or stale enum values from older burn versions.","solutions":["Pass Reduction::Mean, Reduction::Sum, or Reduction::Auto.","Use forward_no_reduction to get the element-wise loss and apply your own reduction.","Sanitize reduction values at config parsing time with a whitelist of supported variants."],"exampleFix":"// before\nlet loss = criterion.forward(pred, target, var, Reduction::None); // panics\n// after\nlet elem = criterion.forward_no_reduction(pred, target, var);\nlet loss = elem.sum();","handlingStrategy":"validation","validationCode":"fn ensure_supported(r: &Reduction) -> Result<(), String> {\n    match r {\n        Reduction::Mean | Reduction::Auto | Reduction::Sum => Ok(()),\n        other => Err(format!(\"unsupported reduction for gaussian NLL: {other:?}\")),\n    }\n}","typeGuard":"fn is_supported_reduction(r: &Reduction) -> bool {\n    matches!(r, Reduction::Mean | Reduction::Auto | Reduction::Sum)\n}","tryCatchPattern":"let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(||\n    criterion.forward(input, target, var, reduction.clone())));","preventionTips":["Only pass Mean/Auto/Sum to GaussianNllLoss::forward.","Use forward_no_reduction plus custom reduction for per-element needs.","Normalize config reduction values centrally.","Test all reduction enum values your pipeline can emit."],"tags":["rust","burn","loss","gaussian-nll","reduction"],"backgroundTag":"unsupported-reduction","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"}