Skip to main content

burn_core/record/
base.rs

1pub use burn_derive::Record;
2use burn_tensor::backend::Backend;
3
4use super::PrecisionSettings;
5use serde::{Serialize, de::DeserializeOwned};
6
7/// Trait to define a family of types which can be recorded using any [settings](PrecisionSettings).
8pub trait Record<B: Backend>: Send {
9    /// Type of the item that can be serialized and deserialized.
10    type Item<S: PrecisionSettings>: Serialize + DeserializeOwned;
11
12    /// Convert the current record into the corresponding item that follows the given [settings](PrecisionSettings).
13    fn into_item<S: PrecisionSettings>(self) -> Self::Item<S>;
14
15    /// Convert the given item into a record.
16    fn from_item<S: PrecisionSettings>(item: Self::Item<S>, device: &B::Device) -> Self;
17}