ruda-tensor-device 0.21.12

Ruda device tensor backend and domain-library dispatch.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::{DeviceBackend, DeviceRuntime, FloatElement, IntElement, element::BoolElement};
use ruda_tensor::{DType, ops::{ActivationOps, FloatTensorOps}, tensor::FloatTensor};

impl<R, F, I, BT> ActivationOps<Self> for DeviceBackend<R, F, I, BT>
where
    R: DeviceRuntime,
    F: FloatElement,
    I: IntElement,
    BT: BoolElement,
{
    fn silu(tensor: FloatTensor<Self>) -> FloatTensor<Self> {
        if matches!(tensor.dtype, DType::F32 | DType::F16 | DType::BF16) {
            ruprim::elementwise::unary::silu::launch(tensor)
        } else {
            Self::float_mul(tensor.clone(), Self::sigmoid(tensor))
        }
    }
}