1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use super::DefaultCollate;
use crate::collate::Collate;

/// We think it makes no sense to but a bench of reference into a Tensor. That's why if the dataset yield reference a
/// we clone them them.
/// It is useful for having a non-consuming `Iterator` over the `Dataloader`.
impl<T> Collate<&T> for DefaultCollate
where
    T: Clone,
    Self: Collate<T>,
{
    type Output = <Self as Collate<T>>::Output;
    fn collate(&self, batch: Vec<&T>) -> Self::Output {
        DefaultCollate::default().collate(batch.into_iter().cloned().collect())
    }
}