Commit 31a43973 authored by Paul Michel's avatar Paul Michel Committed by Facebook Github Bot
Browse files

Fix backtranslation dataset on IndexedCachedDataset (#410)

Summary:
BacktranslationDataset would throw an error when the underlying dataset was an IndexedCachedDataset because prefetching was not handled correctly. This fixes the error.
Pull Request resolved: https://github.com/pytorch/fairseq/pull/410

Differential Revision: D13557539

Pulled By: myleott

fbshipit-source-id: 398ab59a3ebdbf1c666d862b9f905654eece800c
parent 8ce6499d
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -166,3 +166,11 @@ class BacktranslationDataset(FairseqDataset):
        """
        tgt_size = self.tgt_dataset.size(index)[0]
        return (tgt_size, tgt_size)
    
    @property
    def supports_prefetch(self):
        return self.tgt_dataset.supports_prefetch()

    def prefetch(self, indices):
        return self.tgt_dataset.prefetch(indices)