ferrite/tensor/storage/
utils.rs1use crate::*;
2use std::fmt;
3
4impl fmt::Display for Storage {
5 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
6 match self {
7 Storage::Cpu(cpu) => cpu.fmt(f),
8 _ => write!(f, "Tensor on unsupported device")
9 }
10 }
11}
12
13impl fmt::Debug for Storage {
14 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15 match self {
16 Storage::Cpu(cpu) => cpu.fmt(f),
17 _ => write!(f, "Tensor on unsupported device")
18 }
19 }
20}
21
22impl Display for Storage {
23 fn print(&self) {
24 match self {
25 Storage::Cpu(cpu) => cpu.print(),
26 _ => println!("Tensor on unsupported device")
27 }
28 }
29
30 fn print_data_recursive<'a>(data: &'a [f32], shape: &'a [usize], stride: &'a [usize]) -> String {
31 unimplemented!()
32 }
33
34 fn print_data(&self) {
35 match self {
36 Storage::Cpu(cpu) => cpu.print_data(),
37 _ => println!("Tensor on unsupported device")
38 }
39 }
40}