mirror of
https://github.com/huggingface/candle.git
synced 2025-06-18 19:47:12 +00:00
Allow for uniform initialization in a single step. (#136)
This commit is contained in:
@ -109,14 +109,20 @@ impl Device {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn rand_uniform(&self, shape: &Shape, dtype: DType) -> Result<Storage> {
|
||||
pub(crate) fn rand_uniform(
|
||||
&self,
|
||||
shape: &Shape,
|
||||
dtype: DType,
|
||||
lo: f64,
|
||||
up: f64,
|
||||
) -> Result<Storage> {
|
||||
match self {
|
||||
Device::Cpu => {
|
||||
let storage = CpuStorage::rand_uniform(shape, dtype)?;
|
||||
let storage = CpuStorage::rand_uniform(shape, dtype, lo, up)?;
|
||||
Ok(Storage::Cpu(storage))
|
||||
}
|
||||
Device::Cuda(device) => {
|
||||
let storage = device.rand_uniform(shape, dtype)?;
|
||||
let storage = device.rand_uniform(shape, dtype, lo, up)?;
|
||||
Ok(Storage::Cuda(storage))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user