tracel-ai/burn · error

Can read the data without error

Error message

Can read the data without error

What it means

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.

Solutions

  1. Check the tensor's device is reachable and healthy before argwhere (device logs, connection state for remote backends).
  2. Verify the tensor handle is still valid — not consumed or dropped elsewhere in the graph.
  3. Look for a root-cause backend error (CUDA OOM, driver reset) reported before this expect fires.
  4. For remote/communication backends, re-establish the peer connection and retry the operation.

Example fix

// before
let data = B::bool_into_data(tensor).await.expect("Can read the data without error");
// after
let data = B::bool_into_data(tensor).await
    .context("failed to read bool tensor data in argwhere; check device health")?;
Defensive patterns

Strategy: try-catch

Try / catch

let data = B::bool_into_data(tensor).await
    .map_err(|e| anyhow::anyhow!("argwhere: bool_into_data failed: {e}"))?;

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05). Data as JSON: /api/errors/905c86eb81c5d95b. Report an issue: GitHub.

Appendix: source

Thrown at crates/burn-backend/src/backend/ops/bool_tensor.rs:579

    ///
    /// * `tensor` - The input tensor.
    /// * `out_dtype` - The output tensor dtype.
    ///
    /// # Returns
    ///
    /// A 2D tensor containing the indices of all non-zero elements of the given tensor.
    /// Each row contains the indices of a non-zero element.
    fn bool_argwhere(
        tensor: BoolTensor<B>,
        out_dtype: IntDType,
    ) -> impl Future<Output = IntTensor<B>> + 'static + Send {
        async move {
            // Size of each output tensor is variable (= number of nonzero elements in the tensor).
            // Reading the data to count the number of truth values might cause sync but is required.
            let device = &tensor.device();
            let data = B::bool_into_data(tensor)
                .await
                .expect("Can read the data without error");
            argwhere_data::<B>(data, device, out_dtype)
        }
    }

    /// Broadcasts the bool `tensor` to the given `shape`.
    fn bool_expand(tensor: BoolTensor<B>, shape: Shape) -> BoolTensor<B>;

    /// Unfold windows along a dimension.
    ///
    /// Returns a view of the tensor with all complete windows of size `size` in dimension `dim`;
    /// where windows are advanced by `step` at each index.
    ///
    /// The number of windows is `0` when `shape[dim] < size`, and otherwise
    /// `(shape[dim] - size) / step + 1`.
    ///
    /// # Arguments
    ///
    /// * `tensor` - The input tensor to unfold; of shape ``[pre=..., dim shape, post=...]``

View on GitHub (pinned to d16f7ba2ed)