Files
rustytorch/crates/training/rtx-automeasure/tests/scalar_tensor_test.rs
T
2026-03-04 00:08:42 +00:00

31 lines
940 B
Rust

//! TDD tests for scalar tensor creation
//! These tests define expected behavior for creating scalar tensors
use rtx_tensor::{DType, Device, Tensor};
#[test]
fn test_scalar_tensor_creation() {
// Creating a scalar tensor from a float value
let device = Device::cpu();
// Instead of Tensor::from_f32(value, device)
// Use Tensor::scalar(value, dtype, device)
let scalar_tensor = Tensor::scalar(5.0, DType::F32, &device).unwrap();
// The shape should be [] or [1]
assert!(scalar_tensor.shape().dims().len() <= 1);
}
#[test]
fn test_scalar_operations() {
let device = Device::cpu();
let tensor = Tensor::zeros(&[3, 4], &device).unwrap();
// Create scalar for operations
let scalar = Tensor::scalar(2.0, DType::F32, &device).unwrap();
// Should be able to use in broadcast operations
// Note: broadcast operations might need different method names
assert!(true); // Placeholder
}