use crate::nn::cuda_graph::{GpuGraph, MemPoolId, gpu_graph_capture, gpu_graph_pool_handle};
use crate::tensor::cuda_event::GpuEvent as GpuEventInner;
use crate::tensor::cuda_event::GpuEventFlags as GpuEventFlagsInner;
use crate::tensor::cuda_stream::GpuStream as GpuStreamInner;
use crate::tensor::{
Device, DeviceInfo, Result, current_gpu_device, gpu_active_bytes, gpu_active_bytes_idx,
gpu_allocated_bytes, gpu_allocated_bytes_idx, gpu_available, gpu_device_count, gpu_device_name,
gpu_device_name_idx, gpu_devices, gpu_empty_cache, gpu_has_primary_context,
gpu_manual_seed_all, gpu_memory_info, gpu_memory_info_idx, gpu_peak_active_bytes,
gpu_peak_active_bytes_idx, gpu_peak_reserved_bytes, gpu_peak_reserved_bytes_idx,
gpu_reset_peak_stats, gpu_reset_peak_stats_idx, gpu_smi_memory_info_idx, gpu_synchronize,
gpu_utilization, gpu_utilization_idx, set_current_gpu_device, usable_gpu_devices,
};
#[deprecated(note = "renamed to `GpuStream` — the type is not NVIDIA-specific")]
pub type CudaStream = GpuStreamInner;
#[deprecated(note = "renamed to `GpuEvent` — the type is not NVIDIA-specific")]
pub type CudaEvent = GpuEventInner;
#[deprecated(note = "renamed to `GpuEventFlags` — the type is not NVIDIA-specific")]
pub type CudaEventFlags = GpuEventFlagsInner;
#[deprecated(note = "renamed to `GpuGraph` — ROCm calls the same construct a HIP graph")]
pub type CudaGraph = GpuGraph;
#[deprecated(note = "renamed to `gpu_available`")]
pub fn cuda_available() -> bool {
gpu_available()
}
#[deprecated(note = "renamed to `gpu_device_count`")]
pub fn cuda_device_count() -> i32 {
gpu_device_count()
}
#[deprecated(note = "renamed to `gpu_memory_info`")]
pub fn cuda_memory_info() -> Result<(u64, u64)> {
gpu_memory_info()
}
#[deprecated(note = "renamed to `gpu_memory_info_idx`")]
pub fn cuda_memory_info_idx(device_index: i32) -> Result<(u64, u64)> {
gpu_memory_info_idx(device_index)
}
#[deprecated(note = "renamed to `gpu_allocated_bytes`")]
pub fn cuda_allocated_bytes() -> Result<u64> {
gpu_allocated_bytes()
}
#[deprecated(note = "renamed to `gpu_allocated_bytes_idx`")]
pub fn cuda_allocated_bytes_idx(device_index: i32) -> Result<u64> {
gpu_allocated_bytes_idx(device_index)
}
#[deprecated(note = "renamed to `gpu_active_bytes`")]
pub fn cuda_active_bytes() -> Result<u64> {
gpu_active_bytes()
}
#[deprecated(note = "renamed to `gpu_active_bytes_idx`")]
pub fn cuda_active_bytes_idx(device_index: i32) -> Result<u64> {
gpu_active_bytes_idx(device_index)
}
#[deprecated(note = "renamed to `gpu_peak_active_bytes`")]
pub fn cuda_peak_active_bytes() -> Result<u64> {
gpu_peak_active_bytes()
}
#[deprecated(note = "renamed to `gpu_peak_active_bytes_idx`")]
pub fn cuda_peak_active_bytes_idx(device_index: i32) -> Result<u64> {
gpu_peak_active_bytes_idx(device_index)
}
#[deprecated(note = "renamed to `gpu_peak_reserved_bytes`")]
pub fn cuda_peak_reserved_bytes() -> Result<u64> {
gpu_peak_reserved_bytes()
}
#[deprecated(note = "renamed to `gpu_peak_reserved_bytes_idx`")]
pub fn cuda_peak_reserved_bytes_idx(device_index: i32) -> Result<u64> {
gpu_peak_reserved_bytes_idx(device_index)
}
#[deprecated(note = "renamed to `gpu_reset_peak_stats`")]
pub fn cuda_reset_peak_stats() {
gpu_reset_peak_stats()
}
#[deprecated(note = "renamed to `gpu_reset_peak_stats_idx`")]
pub fn cuda_reset_peak_stats_idx(device_index: i32) {
gpu_reset_peak_stats_idx(device_index)
}
#[deprecated(note = "renamed to `gpu_empty_cache`")]
pub fn cuda_empty_cache() {
gpu_empty_cache()
}
#[deprecated(note = "renamed to `gpu_utilization`")]
pub fn cuda_utilization() -> Option<u32> {
gpu_utilization()
}
#[deprecated(note = "renamed to `gpu_utilization_idx`")]
pub fn cuda_utilization_idx(device_index: i32) -> Option<u32> {
gpu_utilization_idx(device_index)
}
#[deprecated(note = "renamed to `gpu_device_name`")]
pub fn cuda_device_name() -> Option<String> {
gpu_device_name()
}
#[deprecated(note = "renamed to `gpu_device_name_idx`")]
pub fn cuda_device_name_idx(device: i32) -> Option<String> {
gpu_device_name_idx(device)
}
#[deprecated(note = "renamed to `gpu_devices`")]
pub fn cuda_devices() -> Vec<DeviceInfo> {
gpu_devices()
}
#[deprecated(note = "renamed to `usable_gpu_devices`")]
pub fn usable_cuda_devices() -> Vec<Device> {
usable_gpu_devices()
}
#[deprecated(note = "renamed to `set_current_gpu_device`")]
pub fn set_current_cuda_device(device_index: u8) {
set_current_gpu_device(device_index)
}
#[deprecated(note = "renamed to `current_gpu_device`")]
pub fn current_cuda_device() -> u8 {
current_gpu_device()
}
#[deprecated(note = "renamed to `gpu_synchronize`")]
pub fn cuda_synchronize(device_index: u8) {
gpu_synchronize(device_index)
}
#[deprecated(note = "renamed to `gpu_manual_seed_all`")]
pub fn cuda_manual_seed_all(seed: u64) {
gpu_manual_seed_all(seed)
}
#[deprecated(note = "renamed to `gpu_has_primary_context`")]
pub fn cuda_has_primary_context(device_index: i32) -> bool {
gpu_has_primary_context(device_index)
}
#[deprecated(note = "renamed to `gpu_graph_pool_handle`")]
pub fn cuda_graph_pool_handle() -> MemPoolId {
gpu_graph_pool_handle()
}
#[deprecated(note = "renamed to `gpu_smi_memory_info_idx`")]
pub fn cuda_nvml_memory_info_idx(physical_index: i32) -> Option<(u64, u64)> {
gpu_smi_memory_info_idx(physical_index)
}
#[deprecated(note = "renamed to `gpu_graph_capture`")]
pub fn cuda_graph_capture<F>(warmup_runs: usize, pool: Option<MemPoolId>, f: F) -> Result<GpuGraph>
where
F: FnMut() -> Result<()>,
{
gpu_graph_capture(warmup_runs, pool, f)
}
#[cfg(test)]
mod tests {
#![allow(deprecated)]
use super::*;
#[test]
fn deprecated_aliases_forward_to_their_replacements() {
assert_eq!(cuda_available(), gpu_available());
assert_eq!(cuda_device_count(), gpu_device_count());
if gpu_available() {
assert_eq!(current_cuda_device(), current_gpu_device());
}
assert_eq!(cuda_devices().len(), gpu_devices().len());
assert_eq!(usable_cuda_devices().len(), usable_gpu_devices().len());
}
#[test]
fn deprecated_type_aliases_resolve() {
fn _assert_same(s: CudaStream) -> crate::GpuStream {
s
}
fn _assert_event(e: CudaEvent) -> crate::GpuEvent {
e
}
fn _assert_flags(f: CudaEventFlags) -> crate::GpuEventFlags {
f
}
fn _assert_graph(g: CudaGraph) -> crate::GpuGraph {
g
}
}
}