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
Sequencer
that buffers results and returns them in order of their sequence number.The
OrderedSequencer
maintains 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
OrderedSequencer
is implemented with a fixed-size buffer. Letm
be the maximum number of jobs in the data loader’s queue ands
be the current sequence number. Assumem
jobs are scheduled in theDataLoader
. Any new result is stored at indexjob.sqn mod m
in theOrderedSequencer
. Why are we sure sequence numbers of new jobs will not collide with sequence numbers of buffered jobs? TheOrderedSequencer
will not return fromnext()
until it receives the result with sqns
. This means no new jobs can be scheduled in theDataLoader
in the meantime, which enforces that as long as sqns
has 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
OrderedSequencer
with the maximum number of results it will ever hold at one point in time.
-
inline explicit OrderedSequencer(size_t max_jobs)¶