Skip to main content

bce_loss_forward

Function bce_loss_forward 

Source
pub fn bce_loss_forward<T: Triton, const BLOCK_SIZE: i32>(
    input_ptr: T::Pointer<f32>,
    target_ptr: T::Pointer<f32>,
    out_ptr: T::Pointer<f32>,
    n_elements: i32,
)
where T::I32Tensor: Tensor<i32, 1> + Comparison<i32, BoolTensor = T::BoolTensor>, T::Pointer<f32>: AddOffsets<i32, 1, T::I32Tensor, Output = T::Tensor<T::Pointer<f32>>>,
Expand description

Element-wise binary cross-entropy forward.

Assumes input is already a probability (sigmoid output), i.e. in (0, 1).

out = -(target * log(input) + (1 - target) * log(1 - input))

Grid: [ceil(n / BLOCK_SIZE), 1, 1], block [128, 1, 1].