mirror of
https://github.com/huggingface/candle.git
synced 2025-06-19 03:54:56 +00:00
Avoid some duplication using a macro + add some basic example to make debugging easier.
This commit is contained in:
9
examples/basics.rs
Normal file
9
examples/basics.rs
Normal file
@ -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(())
|
||||
}
|
Reference in New Issue
Block a user