mirror of
https://github.com/huggingface/candle.git
synced 2025-06-17 11:08:52 +00:00
Add some 'cuda-if-available' helper function. (#172)
This commit is contained in:
@ -109,6 +109,14 @@ impl Device {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cuda_if_available(ordinal: usize) -> Result<Self> {
|
||||
if crate::utils::cuda_is_available() {
|
||||
Self::new_cuda(ordinal)
|
||||
} else {
|
||||
Ok(Self::Cpu)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn rand_uniform(
|
||||
&self,
|
||||
shape: &Shape,
|
||||
|
Reference in New Issue
Block a user