summaryrefslogtreecommitdiff
path: root/candle-core/examples/cuda_basics.rs
blob: 6a3aaacc6001bc110df7806b3f46f45e4bd02ab9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#[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::rand(-1f32, 1f32, 96, &device)?;
    println!("{t}");

    let t = Tensor::randn(0f32, 1f32, (2, 4, 96, 96), &device)?;
    let w = Tensor::randn(0f32, 1f32, (320, 4, 3, 3), &device)?;
    let res = t.conv2d(&w, 1, 1, 1)?;
    println!("{res:?}");
    Ok(())
}