mirror of
https://github.com/huggingface/candle.git
synced 2025-06-19 19:58:35 +00:00
Use a macro to handle the dtype pattern matching. (#215)
This commit is contained in:
@ -1660,3 +1660,13 @@ impl BackendDevice for CpuDevice {
|
||||
Ok(storage)
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! map_dtype {
|
||||
($name:expr, $storage:ident, $fn:expr, ($($dtypes:ident),+)) => {
|
||||
match $storage {
|
||||
$(CpuStorage::$dtypes(__e) => CpuStorage::$dtypes($fn(__e)),)*
|
||||
s => Err(Error::UnsupportedDTypeForOp(s.dtype(), $name).bt())?,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user