`Arc<EventStoreClient>` to `Rc<EventStoreClient>` (#1668)

This commit is contained in:
Alex Errant 2024-04-22 17:21:53 -05:00 committed by GitHub
parent 6c708527b9
commit d62b344d5b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 13 additions and 12 deletions

View File

@ -76,7 +76,7 @@ mod tests {
},
TestBackend,
};
use std::sync::Arc;
use std::rc::Rc;
use super::*;
@ -93,7 +93,7 @@ mod tests {
store.register_logger_train(InMemoryMetricLogger::default());
// Register the loss metric.
metrics.register_train_metric_numeric(LossMetric::<TestBackend>::new());
let store = Arc::new(EventStoreClient::new(store));
let store = Rc::new(EventStoreClient::new(store));
let mut processor = MinimalEventProcessor::new(metrics, store.clone());
// Two points for the first epoch. Mean 0.75

View File

@ -8,6 +8,7 @@ use burn_core::module::Module;
use burn_core::optim::Optimizer;
use burn_core::tensor::backend::Backend;
use burn_core::tensor::Device;
use std::rc::Rc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
@ -26,7 +27,7 @@ pub struct Learner<LC: LearnerComponents> {
pub(crate) interrupter: TrainingInterrupter,
pub(crate) early_stopping: Option<Box<dyn EarlyStoppingStrategy>>,
pub(crate) event_processor: LC::EventProcessor,
pub(crate) event_store: Arc<EventStoreClient>,
pub(crate) event_store: Rc<EventStoreClient>,
pub(crate) summary: Option<LearnerSummaryConfig>,
}

View File

@ -1,5 +1,5 @@
use std::collections::HashSet;
use std::sync::Arc;
use std::rc::Rc;
use super::log::install_file_logger;
use super::Learner;
@ -328,7 +328,7 @@ where
));
}
let event_store = Arc::new(EventStoreClient::new(self.event_store));
let event_store = Rc::new(EventStoreClient::new(self.event_store));
let event_processor = FullEventProcessor::new(self.metrics, renderer, event_store.clone());
let checkpointer = self.checkpointers.map(|(model, optim, scheduler)| {

View File

@ -113,7 +113,7 @@ impl MetricEarlyStoppingStrategy {
#[cfg(test)]
mod tests {
use std::sync::Arc;
use std::rc::Rc;
use crate::{
logger::InMemoryMetricLogger,
@ -197,7 +197,7 @@ mod tests {
store.register_logger_train(InMemoryMetricLogger::default());
metrics.register_train_metric_numeric(LossMetric::<TestBackend>::new());
let store = Arc::new(EventStoreClient::new(store));
let store = Rc::new(EventStoreClient::new(store));
let mut processor = MinimalEventProcessor::new(metrics, store.clone());
let mut epoch = 1;

View File

@ -1,7 +1,7 @@
use super::{Event, EventProcessor, Metrics};
use crate::metric::store::EventStoreClient;
use crate::renderer::{MetricState, MetricsRenderer};
use std::sync::Arc;
use std::rc::Rc;
/// An [event processor](EventProcessor) that handles:
/// - Computing and storing metrics in an [event store](crate::metric::store::EventStore).
@ -9,14 +9,14 @@ use std::sync::Arc;
pub struct FullEventProcessor<T, V> {
metrics: Metrics<T, V>,
renderer: Box<dyn MetricsRenderer>,
store: Arc<EventStoreClient>,
store: Rc<EventStoreClient>,
}
impl<T, V> FullEventProcessor<T, V> {
pub(crate) fn new(
metrics: Metrics<T, V>,
renderer: Box<dyn MetricsRenderer>,
store: Arc<EventStoreClient>,
store: Rc<EventStoreClient>,
) -> Self {
Self {
metrics,

View File

@ -1,13 +1,13 @@
use super::{Event, EventProcessor, Metrics};
use crate::metric::store::EventStoreClient;
use std::sync::Arc;
use std::rc::Rc;
/// An [event processor](EventProcessor) that handles:
/// - Computing and storing metrics in an [event store](crate::metric::store::EventStore).
#[derive(new)]
pub(crate) struct MinimalEventProcessor<T, V> {
metrics: Metrics<T, V>,
store: Arc<EventStoreClient>,
store: Rc<EventStoreClient>,
}
impl<T, V> EventProcessor for MinimalEventProcessor<T, V> {