cubecl_core/frontend/options.rs
1use serde::{Deserialize, Serialize};
2
3bitflags::bitflags! {
4 /// Unchecked optimizations for float operations. May cause precision differences, or undefined
5 /// behaviour if the relevant conditions are not followed.
6 #[derive(Default, Clone, Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
7 pub struct FastMath: u32 {
8 /// Disable unsafe optimizations
9 const None = 0;
10 /// Assume values are never `NaN`. If they are, the result is considered undefined behaviour.
11 const NotNaN = 1;
12 /// Assume values are never `Inf`/`-Inf`. If they are, the result is considered undefined
13 /// behaviour.
14 const NotInf = 1 << 1;
15 /// Ignore sign on zero values.
16 const UnsignedZero = 1 << 2;
17 /// Allow swapping float division with a reciprocal, even if that swap would change precision.
18 const AllowReciprocal = 1 << 3;
19 /// Allow contracting float operations into fewer operations, even if the precision could
20 /// change.
21 const AllowContraction = 1 << 4;
22 /// Allow reassociation for float operations, even if the precision could change.
23 const AllowReassociation = 1 << 5;
24 /// Allow all mathematical transformations for float operations, including contraction and
25 /// reassociation, even if the precision could change.
26 const AllowTransform = 1 << 6;
27 /// Allow using slightly lower precision intrinsics (CUDA `--use_fast_math`)
28 const ReducedPrecision = 1 << 7;
29 }
30}