{"record":{"id":"905c86eb81c5d95b","repo":"tracel-ai/burn","slug":"can-read-the-data-without-error","errorCode":null,"errorMessage":"Can read the data without error","messagePattern":"Can read the data without error","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-backend/src/backend/ops/bool_tensor.rs","lineNumber":579,"sourceCode":"    ///\n    /// * `tensor` - The input tensor.\n    /// * `out_dtype` - The output tensor dtype.\n    ///\n    /// # Returns\n    ///\n    /// A 2D tensor containing the indices of all non-zero elements of the given tensor.\n    /// Each row contains the indices of a non-zero element.\n    fn bool_argwhere(\n        tensor: BoolTensor<B>,\n        out_dtype: IntDType,\n    ) -> impl Future<Output = IntTensor<B>> + 'static + Send {\n        async move {\n            // Size of each output tensor is variable (= number of nonzero elements in the tensor).\n            // Reading the data to count the number of truth values might cause sync but is required.\n            let device = &tensor.device();\n            let data = B::bool_into_data(tensor)\n                .await\n                .expect(\"Can read the data without error\");\n            argwhere_data::<B>(data, device, out_dtype)\n        }\n    }\n\n    /// Broadcasts the bool `tensor` to the given `shape`.\n    fn bool_expand(tensor: BoolTensor<B>, shape: Shape) -> BoolTensor<B>;\n\n    /// Unfold windows along a dimension.\n    ///\n    /// Returns a view of the tensor with all complete windows of size `size` in dimension `dim`;\n    /// where windows are advanced by `step` at each index.\n    ///\n    /// The number of windows is `0` when `shape[dim] < size`, and otherwise\n    /// `(shape[dim] - size) / step + 1`.\n    ///\n    /// # Arguments\n    ///\n    /// * `tensor` - The input tensor to unfold; of shape ``[pre=..., dim shape, post=...]``","sourceCodeStart":561,"sourceCodeEnd":597,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-backend/src/backend/ops/bool_tensor.rs#L561-L597","documentation":"This panic occurs in bool_argwhere after awaiting B::bool_into_data(tensor), which materializes a boolean tensor's data on the host to count nonzero elements for the argwhere (indices of true values) operation. The expect fires if the backend's data-read future returns an error — i.e. the tensor data could not be transferred/computed into a readable Data struct.","triggerScenarios":"The underlying backend read fails during bool_into_data — e.g. the tensor handle is invalid (freed or created on a device that errored), a backend kernel fails during the async read, or a remote/communication-backed backend loses its peer connection mid-transfer.","commonSituations":"Calling argwhere on a tensor whose device connection dropped (distributed/WebSocket tensor transfer failed); using a tensor that was already consumed/freed by another op; GPU driver or OOM errors surfacing through the into_data read.","solutions":["Check the tensor's device is reachable and healthy before argwhere (device logs, connection state for remote backends).","Verify the tensor handle is still valid — not consumed or dropped elsewhere in the graph.","Look for a root-cause backend error (CUDA OOM, driver reset) reported before this expect fires.","For remote/communication backends, re-establish the peer connection and retry the operation."],"exampleFix":"// before\nlet data = B::bool_into_data(tensor).await.expect(\"Can read the data without error\");\n// after\nlet data = B::bool_into_data(tensor).await\n    .context(\"failed to read bool tensor data in argwhere; check device health\")?;","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"let data = B::bool_into_data(tensor).await\n    .map_err(|e| anyhow::anyhow!(\"argwhere: bool_into_data failed: {e}\"))?;","preventionTips":["Confirm the tensor device is healthy and connected before data reads.","Avoid reusing tensor handles after ownership transfer into other ops.","Watch GPU memory/driver logs; OOM often surfaces at into_data."],"tags":["backend","tensor-data","panic","async"],"backgroundTag":"tensor-read-failed","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"}