oa::ml::loss::cross_entropy_masked
Compute mean cross-entropy over the rows selected by a floating FP32 mask. logits has shape [N, C]; targets and mask have shape [N]. A zero mask value excludes its row and produces an exact-zero logits adjoint. valid_count is the caller-provided normalization denominator and must be in 1..=N; it is not read back or recomputed from device storage. Reverse mode differentiates only logits. Errors Returns an error when ranks, shapes, dtypes, ownership, valid_count, allocation, or runtime recording are invalid.
Function Documentation
Compute mean cross-entropy over the rows selected by a floating FP32 mask. logits has shape [N, C]; targets and mask have shape [N]. A zero mask value excludes its row and produces an exact-zero logits adjoint. valid_count is the caller-provided normalization denominator and must be in 1..=N; it is not read back or recomputed from device storage. Reverse mode differentiates only logits. Errors Returns an error when ranks, shapes, dtypes, ownership, valid_count, allocation, or runtime recording are invalid.