use nove::tensor::Device;
#[test]
fn test_eq() {
let device1 = Device::cpu();
let device2 = Device::cpu();
assert_eq!(device1, device2);
}
#[cfg(feature = "cuda")]
#[test]
fn test_cuda_with_invalid_index() {
let device = Device::cuda(usize::MAX);
assert_eq!(device.is_err(), true);
}
#[cfg(feature = "cuda")]
#[test]
fn test_cuda_if_available() {
let cuda_if_available = Device::cuda_if_available(0);
let cpu = Device::cpu();
match Device::cuda(0) {
Ok(cuda) => assert_eq!(cuda, cuda_if_available),
Err(_) => assert_eq!(cuda_if_available, cpu),
}
}
#[cfg(feature = "metal")]
#[test]
fn test_metal_with_invalid_index() {
let device = Device::metal(usize::MAX);
assert_eq!(device.is_err(), true);
}
#[cfg(feature = "metal")]
#[test]
fn test_metal_if_available() {
let metal_if_available = Device::metal_if_available(0);
let cpu = Device::cpu();
match Device::metal(0) {
Ok(metal) => assert_eq!(metal, metal_if_available),
Err(_) => assert_eq!(metal_if_available, cpu),
}
}