mirror of
https://github.com/huggingface/candle.git
synced 2025-06-16 10:38:54 +00:00

* Add more tracing to the whisper example. * Support accelerate in more examples. * Use accelerate for pointwise functions. * Use accelerate for binary operations too. * Bugfix for binary operation: use the rhs before the lhs.
19 lines
419 B
Rust
19 lines
419 B
Rust
#[cfg(feature = "accelerate")]
|
|
extern crate accelerate_src;
|
|
|
|
#[cfg(feature = "mkl")]
|
|
extern crate intel_mkl_src;
|
|
|
|
use anyhow::Result;
|
|
use candle_core::{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_keepdim(0)?;
|
|
println!("{sum}");
|
|
let sum = t.sum_keepdim(1)?;
|
|
println!("{sum}");
|
|
Ok(())
|
|
}
|