mirror of
https://github.com/huggingface/candle.git
synced 2025-06-16 18:48:51 +00:00
Support cuda in to_vec3.
This commit is contained in:
@ -359,8 +359,7 @@ impl Tensor {
|
||||
|
||||
pub fn to_vec3<S: crate::WithDType>(&self) -> Result<Vec<Vec<Vec<S>>>> {
|
||||
let (dim1, dim2, dim3) = self.shape().r3()?;
|
||||
match &self.storage {
|
||||
Storage::Cpu(cpu_storage) => {
|
||||
let from_cpu_storage = |cpu_storage: &crate::CpuStorage| {
|
||||
let data = S::cpu_storage_as_slice(cpu_storage)?;
|
||||
let mut top_rows = vec![];
|
||||
let mut src_index = self.strided_index();
|
||||
@ -374,8 +373,10 @@ impl Tensor {
|
||||
}
|
||||
assert!(src_index.next().is_none());
|
||||
Ok(top_rows)
|
||||
}
|
||||
Storage::Cuda { .. } => todo!(),
|
||||
};
|
||||
match &self.storage {
|
||||
Storage::Cpu(storage) => from_cpu_storage(storage),
|
||||
Storage::Cuda(storage) => from_cpu_storage(&storage.to_cpu_storage()?),
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user