mod generic_blas;
pub use generic_blas::*;
#[cfg(feature = "no-std")]
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct Ident {
pub idx: usize,
pub len: usize,
}
#[cfg(not(feature = "no-std"))]
mod addons;
#[cfg(not(feature = "no-std"))]
pub use addons::*;
use crate::{flag::AllocFlag, shape::Shape, AddGraph, Alloc, Buffer, Device};
#[cfg(not(feature = "no-std"))]
pub mod cache;
#[cfg(not(feature = "no-std"))]
#[cfg(feature = "autograd")]
pub(crate) mod borrowing_cache;
#[cfg(not(feature = "no-std"))]
pub use cache::*;
#[cfg(feature = "cpu")]
pub mod cpu;
#[cfg(feature = "cuda")]
pub mod cuda;
#[cfg(feature = "opencl")]
pub mod opencl;
#[cfg(feature = "stack")]
pub mod stack;
#[cfg(feature = "wgpu")]
pub mod wgpu;
#[cfg(feature = "network")]
pub mod network;
mod stack_array;
pub use stack_array::*;
mod cdatatype;
pub use cdatatype::*;
#[cfg(all(any(feature = "cpu", feature = "stack"), feature = "macro"))]
mod cpu_stack_ops;
#[cfg(not(feature = "no-std"))]
mod ident;
#[cfg(not(feature = "no-std"))]
pub use ident::*;
pub trait PtrConv: Device {
unsafe fn convert<T, IS: Shape, Conv, OS: Shape>(
ptr: &Self::Ptr<T, IS>,
flag: AllocFlag,
) -> Self::Ptr<Conv, OS>;
}
pub trait CacheAble<D: Device> {
#[cfg_attr(all(feature = "cpu", not(feature = "realloc")), doc = "```")]
#[cfg_attr(all(not(feature = "cpu"), feature = "realloc"), doc = "```ignore")]
fn retrieve<T, S: Shape>(device: &D, len: usize, add_node: impl AddGraph) -> Buffer<T, D, S>
where
for<'a> D: Alloc<'a, T, S>;
#[cfg(not(feature = "no-std"))]
unsafe fn get_existing_buf<T, S: Shape>(device: &D, id: Ident) -> Option<Buffer<T, D, S>>;
#[cfg(not(feature = "no-std"))]
fn remove(device: &D, ident: Ident);
#[cfg(not(feature = "no-std"))]
fn add_to_cache<T, S: Shape>(device: &D, ptr: &D::Ptr<T, S>) -> Option<Ident>;
}
impl<D: Device> CacheAble<D> for () {
#[inline]
fn retrieve<T, S: Shape>(device: &D, len: usize, _add_node: impl AddGraph) -> Buffer<T, D, S>
where
for<'a> D: Alloc<'a, T, S>,
{
Buffer::new(device, len)
}
#[cfg(not(feature = "no-std"))]
#[inline]
fn remove(_device: &D, _ident: Ident) {}
#[cfg(not(feature = "no-std"))]
#[inline]
fn add_to_cache<T, S: Shape>(_device: &D, _ptr: &<D as Device>::Ptr<T, S>) -> Option<Ident> {
None
}
#[cfg(not(feature = "no-std"))]
#[inline]
unsafe fn get_existing_buf<T, S: Shape>(_device: &D, _id: Ident) -> Option<Buffer<T, D, S>> {
None
}
}