diff options
author | Laurent Mazare <laurent.mazare@gmail.com> | 2023-07-27 07:40:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-27 07:40:36 +0100 |
commit | 6475bfadfebcd02dd58adc60452f492f8dc11a39 (patch) | |
tree | 60e7ba3b02b1ebd26854f4e6adfec76df0617f48 /candle-core/examples/basics.rs | |
parent | 89ba005962495f2bfbda286e185e9c3c7f5300a3 (diff) | |
download | candle-6475bfadfebcd02dd58adc60452f492f8dc11a39.tar.gz candle-6475bfadfebcd02dd58adc60452f492f8dc11a39.tar.bz2 candle-6475bfadfebcd02dd58adc60452f492f8dc11a39.zip |
Simplify Tensor::randn. (#255)
* Simplify Tensor::randn.
* Also switch Tensor::rand to use a generic dtype.
* Support sampling for f16.
* Cleanup.
Diffstat (limited to 'candle-core/examples/basics.rs')
-rw-r--r-- | candle-core/examples/basics.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/candle-core/examples/basics.rs b/candle-core/examples/basics.rs index a5e2b24e..88b110e0 100644 --- a/candle-core/examples/basics.rs +++ b/candle-core/examples/basics.rs @@ -5,6 +5,11 @@ use anyhow::Result; use candle::{Device, Tensor}; fn main() -> Result<()> { + let a = Tensor::randn(0f32, 1., (2, 3), &Device::Cpu)?; + let b = Tensor::randn(0f32, 1., (3, 4), &Device::Cpu)?; + let c = a.matmul(&b)?; + println!("{a} {b} {c}"); + let data = &[[3f32, 1., 4., 1., 5.], [2., 7., 1., 8., 2.]]; let t1 = Tensor::new(data, &Device::Cpu)?; let data2 = &[[5f32, 5., 5., 5., 5.], [2., 7., 1., 8., 2.]]; |