use nanoglia_core::backend::Backend;
#[derive(Clone, Copy)]
pub struct Registry<'r> {
backends: &'r [&'r dyn Backend],
}
impl core::fmt::Debug for Registry<'_> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_list()
.entries(self.backends.iter().map(|b| b.name()))
.finish()
}
}
static DEFAULT_BACKENDS: &[&dyn Backend] = &[
#[cfg(feature = "esp-nn")]
&nanoglia_esp_nn::BACKEND,
#[cfg(feature = "cmsis-nn")]
&nanoglia_cmsis_nn::BACKEND,
#[cfg(feature = "kernels")]
&nanoglia_kernels::BACKEND,
];
impl<'r> Registry<'r> {
pub const fn new(backends: &'r [&'r dyn Backend]) -> Self {
Self { backends }
}
pub fn backends(&self) -> &'r [&'r dyn Backend] {
self.backends
}
}
impl Default for Registry<'static> {
fn default() -> Self {
Self::new(DEFAULT_BACKENDS)
}
}