31 lines
940 B
Rust
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
|
|
}
|