Skip to content
fn

cross_entropy_op

→TensorImplPtr
int cross_entropy_op(const int & input, const int & target, const int & weight_or_null, int reduction, double eps, int ignore_index)

Python wrappers

Public Python APIs implemented by this engine symbol.

Public cross-entropy (fused log-softmax + NLL) entry point.

Parameters

inputTensorImplPtr
Logits of shape (N, C) or (N, C, d_1, ...).
targetTensorImplPtr
Integer class labels of shape (N,) or (N, d_1, ...).
weight_or_nullTensorImplPtr
Optional per-class weight vector of length CC; pass null when unused.
reductionint
0 (None), 1 (Mean), or 2 (Sum).
epsdouble
Numerical clamp passed through to the backend.
ignore_indexint
Class index excluded from the loss and gradient.

Returns

TensorImplPtr

Scalar (Mean / Sum) or per-sample (None) loss tensor.