🔧 Wave 37-1: Fix CUDA example compilation errors

This commit is contained in:
jgrusewski
2025-10-02 08:06:49 +02:00
parent cf9a15c1a4
commit 0b3a9aaa0b

View File

@@ -4,7 +4,7 @@
//! can successfully create tensors and perform basic operations.
use candle_core::{Device, Tensor};
use candle_nn::{Linear, Module, VarBuilder, VarMap};
use candle_nn::{linear, Module, VarBuilder, VarMap};
/// Test basic CUDA tensor operations
pub fn test_cuda_basic() -> Result<(), Box<dyn std::error::Error>> {
@@ -39,14 +39,14 @@ pub fn test_cuda_neural_network() -> Result<(), Box<dyn std::error::Error>> {
match Device::new_cuda(0) {
Ok(device) => {
let mut varmap = VarMap::new();
let varmap = VarMap::new();
let vs = VarBuilder::from_varmap(&varmap, candle_core::DType::F32, &device);
// Create a simple linear layer
let linear = Linear::new(10, 5, vs.pp("linear"))?;
let linear_layer = linear(10, 5, vs.pp("linear"))?;
let input = Tensor::randn(0f32, 1.0, (1, 10), &device)?;
let output = linear.forward(&input)?;
let output = linear_layer.forward(&input)?;
println!(
"✅ Neural network forward pass successful: {:?}",
output.shape()