diff options
author | laurent <laurent.mazare@gmail.com> | 2023-06-21 10:08:41 +0100 |
---|---|---|
committer | laurent <laurent.mazare@gmail.com> | 2023-06-21 10:08:41 +0100 |
commit | b3eb57cd0a696ec184e47c7316871b01e0a45aea (patch) | |
tree | da25dd7a4a6675841aa2c91cf8a6267a55f68722 /examples/basics.rs | |
parent | 8cde0c54788d7ae7c676e4f2fad5fcbc16f6980c (diff) | |
download | candle-b3eb57cd0a696ec184e47c7316871b01e0a45aea.tar.gz candle-b3eb57cd0a696ec184e47c7316871b01e0a45aea.tar.bz2 candle-b3eb57cd0a696ec184e47c7316871b01e0a45aea.zip |
Avoid some duplication using a macro + add some basic example to make debugging easier.
Diffstat (limited to 'examples/basics.rs')
-rw-r--r-- | examples/basics.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/examples/basics.rs b/examples/basics.rs new file mode 100644 index 00000000..f01f7871 --- /dev/null +++ b/examples/basics.rs @@ -0,0 +1,9 @@ +use anyhow::Result; +use candle::{Device, Tensor}; + +fn main() -> Result<()> { + let x = Tensor::var(&[3f32, 1., 4.], Device::Cpu)?; + let y = (((&x * &x)? + &x * 5f64)? + 4f64)?; + println!("{:?}", y.to_vec1::<f32>()?); + Ok(()) +} |