vyre 0.4.0

GPU compute intermediate representation with a standard operation library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::ir::model::types::DataType;

#[inline]
pub(crate) fn wgsl_zero_value(dt: DataType) -> Result<&'static str, crate::lower::wgsl::Error> {
    match dt {
        DataType::U32 | DataType::Bool | DataType::Bytes | DataType::Array { .. } => Ok("0u"),
        DataType::I32 => Ok("0i"),
        DataType::F32 => Ok("0.0f"),
        DataType::U64 | DataType::Vec2U32 => Ok("vec2<u32>(0u, 0u)"),
        DataType::Vec4U32 => Ok("vec4<u32>(0u, 0u, 0u, 0u)"),
        DataType::F16 | DataType::BF16 | DataType::F64 | DataType::Tensor => Err(crate::lower::wgsl::Error::lowering(
            "Fix: DataType F16/BF16/F64/Tensor zero-value lowering is not implemented. Use F32 or implement the lowering in core/src/lower/wgsl/emit/wgsl_zero_value.rs.".to_string(),
        )),
    }
}