summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/main.rs b/src/main.rs
index a16af93..828654a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -25,37 +25,29 @@ fn main() {
// .into_dyn() replaces .reshape(DynRank::from_dims(&[2, 3])).into():
let mut c: mdarray::Tensor<f64> = tensor![[0.0; 2]; 3].into_dyn();
- dbg!(std::any::type_name_of_val(&a));
- dbg!(std::any::type_name_of_val(&b));
- dbg!(std::any::type_name_of_val(&c));
-
matmul(&a.reshape((3, Const::<2>)), &b, &mut c.remap_mut());
assert_eq!(c, view![[4.0, 5.0], [5.0, 7.0], [6.0, 9.0]]);
// slice
- let d = a.view(1, ..);
- dbg!(std::any::type_name_of_val(&d));
+ let _ = a.view(1, ..);
// index
- let e = c[4];
- dbg!(std::any::type_name_of_val(&e));
+ let _ = c[4];
// permute
- let f = c.permute([1, 0]);
- dbg!(std::any::type_name_of_val(&f));
+ let _ = c.permute([1, 0]);
// Arrays with rank > 6:
- let x: Vec<f64> = (0..128).map(|x| x as f64).collect();
- let x: md::DTensor<f64, 1> = x.into();
- let x = x.into_dyn();
- let x = x.reshape(&[2; 7]);
- let x = x.permute(&[6, 5, 4, 3, 2, 1, 0]);
- dbg!(std::any::type_name_of_val(&x));
+ let d: Vec<f64> = (0..128).map(|x| x as f64).collect();
+ let d: md::DTensor<f64, 1> = d.into();
+ let d = d.into_dyn();
+ let d = d.reshape(&[2; 7]);
+ let d = d.permute(&[6, 5, 4, 3, 2, 1, 0]);
// Indexing
for i in 0..2 {
let index = [0, i, 0, 0, i, 0, 0];
- println!("{} {} {} {}", a[i], a[[i, 0]], c[&index[..2]], x[index]);
+ println!("{} {} {} {}", a[i], a[[i, 0]], c[&index[..2]], d[index]);
}
}