burn_ndarray/ops/
activations.rs

1use crate::{
2    NdArray,
3    element::{FloatNdArrayElement, IntNdArrayElement, QuantElement},
4    execute_with_float_dtype,
5    ops::NdArrayMathOps,
6};
7use burn_tensor::{
8    ElementConversion,
9    ops::{ActivationOps, FloatTensor},
10};
11
12impl<E: FloatNdArrayElement, I: IntNdArrayElement, Q: QuantElement> ActivationOps<Self>
13    for NdArray<E, I, Q>
14{
15    fn relu(tensor: FloatTensor<Self>) -> FloatTensor<Self> {
16        execute_with_float_dtype!(tensor, |tensor| NdArrayMathOps::clamp_min(tensor, 0.elem()))
17    }
18}