Template Struct OrderedSequencer¶
Defined in File sequencers.h
Page Contents
Inheritance Relationships¶
Base Type¶
public torch::data::detail::sequencers::Sequencer< Result >(Template Struct Sequencer)
Struct Documentation¶
-
template<typename Result>
struct OrderedSequencer : public torch::data::detail::sequencers::Sequencer<Result>¶ A
Sequencerthat buffers results and returns them in order of their sequence number.The
OrderedSequencermaintains an internal, monotonically incrementing counter for the next sequence number it expects. If it receives a result with a higher sequence number, it will buffer it for later (when the sequence number reaches that of this result). Otherwise, if the sequence numbers match, the result is returned.Implementation note: The
OrderedSequenceris implemented with a fixed-size buffer. Letmbe the maximum number of jobs in the data loader’s queue andsbe the current sequence number. Assumemjobs are scheduled in theDataLoader. Any new result is stored at indexjob.sqn mod min theOrderedSequencer. Why are we sure sequence numbers of new jobs will not collide with sequence numbers of buffered jobs? TheOrderedSequencerwill not return fromnext()until it receives the result with sqns. This means no new jobs can be scheduled in theDataLoaderin the meantime, which enforces that as long as sqnshas not been received,s + m(which would cause a collision in the fixed-size buffer) will not yet be scheduled.Public Functions
-
inline explicit OrderedSequencer(size_t max_jobs)¶
Constructs the
OrderedSequencerwith the maximum number of results it will ever hold at one point in time.
-
inline explicit OrderedSequencer(size_t max_jobs)¶