Loss function kernels (cross-entropy, etc.) More...
Go to the source code of this file.
Functions | |
| static int | ce_legacy_mode_enabled (void) |
| static int | ce_targets_all_valid_no_ignore (const int32_t *targets, int tokens, int vocab_size) |
| static int | parse_env_bool_on (const char *name) |
| void | softmax_cross_entropy_loss (const float *logits, const int32_t *targets, int tokens, int vocab_size, float *d_logits, float *loss_out) |
| static void | softmax_cross_entropy_loss_index_mean_impl (const float *logits, const int32_t *targets, int tokens, int vocab_size, float *d_logits, float *loss_out, int force_strict_math) |
| static void | softmax_cross_entropy_loss_legacy_mean_impl (const float *logits, const int32_t *targets, int tokens, int vocab_size, float *d_logits, float *loss_out) |
| void | softmax_cross_entropy_loss_ptref (const float *logits, const int32_t *targets, int tokens, int vocab_size, float *d_logits, float *loss_out) |
| static void | zero_row_f32 (float *row, int cols) |
Loss function kernels (cross-entropy, etc.)
After changes: make test && make llamacpp-parity-full
Cross-entropy: L = -log(softmax(logits)[target])
Definition in file loss_kernels.c.
|
static |
Definition at line 46 of file loss_kernels.c.
References parse_env_bool_on().
Referenced by softmax_cross_entropy_loss().
|
static |
Definition at line 248 of file loss_kernels.c.
References vocab_size.
Referenced by softmax_cross_entropy_loss().
|
static |
Definition at line 29 of file loss_kernels.c.
Referenced by ce_legacy_mode_enabled().
| void softmax_cross_entropy_loss | ( | const float * | logits, |
| const int32_t * | targets, | ||
| int | tokens, | ||
| int | vocab_size, | ||
| float * | d_logits, | ||
| float * | loss_out | ||
| ) |
Definition at line 259 of file loss_kernels.c.
References ce_legacy_mode_enabled(), ce_targets_all_valid_no_ignore(), softmax_cross_entropy_loss_index_mean_impl(), softmax_cross_entropy_loss_legacy_mean_impl(), and vocab_size.
Referenced by softmax_cross_entropy_loss_bf16().
|
static |
Definition at line 64 of file loss_kernels.c.
References ck_strict_parity_enabled(), vocab_size, and zero_row_f32().
Referenced by softmax_cross_entropy_loss(), and softmax_cross_entropy_loss_ptref().
|
static |
Definition at line 169 of file loss_kernels.c.
References ck_strict_parity_enabled(), and vocab_size.
Referenced by softmax_cross_entropy_loss().
| void softmax_cross_entropy_loss_ptref | ( | const float * | logits, |
| const int32_t * | targets, | ||
| int | tokens, | ||
| int | vocab_size, | ||
| float * | d_logits, | ||
| float * | loss_out | ||
| ) |
Definition at line 292 of file loss_kernels.c.
References softmax_cross_entropy_loss_index_mean_impl(), and vocab_size.
|
static |
Definition at line 22 of file loss_kernels.c.
Referenced by softmax_cross_entropy_loss_index_mean_impl().