2023-07-08 19:43:56 +08:00
|
|
|
#[cfg(feature = "mkl")]
|
|
|
|
extern crate intel_mkl_src;
|
|
|
|
|
|
|
|
use anyhow::Result;
|
2023-08-02 15:20:22 +08:00
|
|
|
use candle_core::{Device, Tensor};
|
2023-07-08 19:43:56 +08:00
|
|
|
|
|
|
|
fn main() -> Result<()> {
|
|
|
|
let device = Device::new_cuda(0)?;
|
|
|
|
let t = Tensor::new(&[[1f32, 2., 3., 4.2]], &device)?;
|
2023-07-14 15:22:08 +08:00
|
|
|
let sum = t.sum_keepdim(0)?;
|
2023-07-08 19:43:56 +08:00
|
|
|
println!("{sum}");
|
2023-07-14 15:22:08 +08:00
|
|
|
let sum = t.sum_keepdim(1)?;
|
2023-07-08 19:43:56 +08:00
|
|
|
println!("{sum}");
|
|
|
|
Ok(())
|
|
|
|
}
|