-
Notifications
You must be signed in to change notification settings - Fork 250
/
Copy pathdtype.rs
39 lines (36 loc) · 1.14 KB
/
dtype.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use std::fmt;
#[cfg(feature = "clap")]
use clap::ValueEnum;
#[derive(Debug, PartialEq)]
#[cfg_attr(feature = "clap", derive(Clone, ValueEnum))]
pub enum DType {
// Float16 is not available on accelerate
#[cfg(any(
feature = "python",
all(feature = "candle", not(feature = "accelerate"))
))]
Float16,
// Float32 is not available on candle cuda
#[cfg(any(feature = "python", feature = "candle"))]
Float32,
// #[cfg(feature = "candle")]
// Q6K,
}
impl fmt::Display for DType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
// Float16 is not available on accelerate
#[cfg(any(
feature = "python",
all(feature = "candle", not(feature = "accelerate"))
))]
DType::Float16 => write!(f, "float16"),
// Float32 is not available on candle cuda
#[cfg(any(feature = "python", feature = "candle"))]
DType::Float32 => write!(f, "float32"),
// #[cfg(feature = "candle")]
// DType::Q6K => write!(f, "q6k"),
_ => unreachable!()
}
}
}