mirror of
https://github.com/huggingface/candle.git
synced 2025-06-16 10:38:54 +00:00
15 lines
464 B
Rust
15 lines
464 B
Rust
use anyhow::Result;
|
|
use candle::{DType, Device, Tensor};
|
|
|
|
fn main() -> Result<()> {
|
|
let device = Device::new_cuda(0)?;
|
|
let x = Tensor::new(&[3f32, 1., 4., 1., 5.], &device)?;
|
|
println!("{:?}", x.to_vec1::<f32>()?);
|
|
let x = Tensor::new(&[2f32, 7., 1., 8., 2.], &device)?;
|
|
let y = (x * 3.)?;
|
|
println!("{:?}", y.to_vec1::<f32>()?);
|
|
let x = Tensor::ones((3, 2), DType::F32, &device)?;
|
|
println!("{:?}", x.to_vec2::<f32>()?);
|
|
Ok(())
|
|
}
|