singe-kernel 0.1.0-alpha.4

Reusable CPU and GPU kernels.
Documentation
// @generated by cargo xtask gen-cutile-dtype-kernels
// Do not edit generated entries by hand.

#[cutile::module]
mod kernels {
    use cutile::core::*;
    #[cutile::entry()]
    pub fn quantize_f64_u8<const B: i32>(
        out: &mut Tensor<u8, { [B] }>,
        input: &Tensor<f64, { [-1] }>,
        scale: f64,
        zero_point: f64,
    ) {
        let values: Tile<f64, { [B] }> = load_tile_like(input, out);
        let raw = values / broadcast_scalar(scale, out.shape())
            + broadcast_scalar(zero_point, out.shape());
        let low = constant(0.0f64, out.shape());
        let high = constant(255.0f64, out.shape());
        out.store(ftoi(
            min_tile(max_tile(raw, low), high),
            rounding::NearestEven,
        ));
    }
    #[cutile::entry()]
    pub fn quantize_f64_i8<const B: i32>(
        out: &mut Tensor<i8, { [B] }>,
        input: &Tensor<f64, { [-1] }>,
        scale: f64,
        zero_point: f64,
    ) {
        let values: Tile<f64, { [B] }> = load_tile_like(input, out);
        let raw = values / broadcast_scalar(scale, out.shape())
            + broadcast_scalar(zero_point, out.shape());
        let low = constant(-128.0f64, out.shape());
        let high = constant(127.0f64, out.shape());
        out.store(ftoi(
            min_tile(max_tile(raw, low), high),
            rounding::NearestEven,
        ));
    }
}
pub use crate::cuda::cutile::kernel::f64::utility::dequantize_i8_f64;
pub use crate::cuda::cutile::kernel::f64::utility::dequantize_u8_f64;
pub use kernels::*;