T3: rayon-backed concurrency (opt-in) #2
@@ -332,10 +332,23 @@ impl<T: Time, D: Drift<T>, O: Observer<T>, K: Eq + Hash + Clone> History<T, D, O
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn log_evidence_internal(&mut self, forward: bool, targets: &[Index]) -> f64 {
|
pub(crate) fn log_evidence_internal(&mut self, forward: bool, targets: &[Index]) -> f64 {
|
||||||
self.time_slices
|
#[cfg(feature = "rayon")]
|
||||||
.iter()
|
{
|
||||||
.map(|ts| ts.log_evidence(self.online, targets, forward, &self.agents))
|
use rayon::prelude::*;
|
||||||
.sum()
|
let per_slice: Vec<f64> = self
|
||||||
|
.time_slices
|
||||||
|
.par_iter()
|
||||||
|
.map(|ts| ts.log_evidence(self.online, targets, forward, &self.agents))
|
||||||
|
.collect();
|
||||||
|
per_slice.into_iter().sum()
|
||||||
|
}
|
||||||
|
#[cfg(not(feature = "rayon"))]
|
||||||
|
{
|
||||||
|
self.time_slices
|
||||||
|
.iter()
|
||||||
|
.map(|ts| ts.log_evidence(self.online, targets, forward, &self.agents))
|
||||||
|
.sum()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Total log-evidence across the history.
|
/// Total log-evidence across the history.
|
||||||
|
|||||||
Reference in New Issue
Block a user