mirror of
https://github.com/huggingface/candle.git
synced 2025-06-19 03:54:56 +00:00
feat: enhance linear algebra operations (#2972)
- Add `dot()` for vector/matrix products - Implement the `Frobenius` norm - Add `mv()` for matrix-vector multiply
This commit is contained in:
@ -1880,3 +1880,11 @@ fn tensor_new() -> Result<()> {
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tensor_norm() -> Result<()> {
|
||||
let t = Tensor::new(&[[3., 4.], [0., 0.]], &Device::Cpu)?;
|
||||
let norm = t.norm()?;
|
||||
assert_eq!(norm.to_scalar::<f64>()?, 5.);
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user