Files
rustytorch/crates/models/rtx-vision/tests/randn_shape_test.rs
T
2026-03-04 00:08:42 +00:00

24 lines
684 B
Rust

//! TDD tests for randn shape parameter
//! These tests define expected behavior for creating random tensors
use rtx_tensor::{Device, Tensor};
#[test]
fn test_randn_with_slice_not_vec() {
// randn expects &[usize], not Vec<usize>
let device = Device::cpu();
// Wrong: passing Vec directly
// let tensor = Tensor::randn(vec![2, 3], &device);
// Correct: passing slice reference
let shape = vec![2, 3];
let tensor = Tensor::randn(&shape, &device).unwrap();
// Or directly with array slice
let tensor2 = Tensor::randn(&[2, 3], &device).unwrap();
assert_eq!(tensor.shape().dims(), &[2, 3]);
assert_eq!(tensor2.shape().dims(), &[2, 3]);
}