mirror of
https://github.com/huggingface/candle.git
synced 2025-06-17 02:58:50 +00:00

* Sketch a fast cuda kernel for reduce-sum. * Sketch the rust support code for the fast sum kernel. * More work on the fast kernel. * Add some testing ground. * A couple fixes for the fast sum kernel.
16 lines
343 B
Rust
16 lines
343 B
Rust
#[cfg(feature = "mkl")]
|
|
extern crate intel_mkl_src;
|
|
|
|
use anyhow::Result;
|
|
use candle::{Device, Tensor};
|
|
|
|
fn main() -> Result<()> {
|
|
let device = Device::new_cuda(0)?;
|
|
let t = Tensor::new(&[[1f32, 2., 3., 4.2]], &device)?;
|
|
let sum = t.sum(&[0])?;
|
|
println!("{sum}");
|
|
let sum = t.sum(&[1])?;
|
|
println!("{sum}");
|
|
Ok(())
|
|
}
|