docs: fix Task 6 min/max API — candle min(D)/max(D) returns Tensor not tuple

In candle-core (git 671de1d), min(D) and max(D) return Result<Tensor>,
not Result<(Tensor, Tensor)>. Use flatten_all() then min(0)/max(0) for
scalar reduction instead of the tuple destructuring pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jgrusewski
2026-03-11 09:38:12 +01:00
parent b704af9112
commit 33bcc44bd4

View File

@@ -721,9 +721,12 @@ fn compute_q_diagnostics_gpu(
// Batch all gap stats into a single tensor to minimize readbacks:
// [mean_gap, min_gap, max_gap] — one to_vec1 instead of three to_scalar
let mean_gap = gaps.mean_all()?; // [1]
let min_gap = gaps.min(0)?.0.min(0)?.0; // scalar tensor
let max_gap = gaps.max(0)?.0.max(0)?.0; // scalar tensor
// Note: In candle-core (git 671de1d), min(D)/max(D) return Result<Tensor>,
// NOT Result<(Tensor, Tensor)>. Flatten first for scalar reduction.
let gaps_flat = gaps.flatten_all()?;
let mean_gap = gaps_flat.mean_all()?; // scalar tensor
let min_gap = gaps_flat.min(0)?; // scalar tensor
let max_gap = gaps_flat.max(0)?; // scalar tensor
let gap_stats = Tensor::cat(
&[&mean_gap.unsqueeze(0)?, &min_gap.unsqueeze(0)?, &max_gap.unsqueeze(0)?], 0
)?;