MCPcopy
hub / github.com/tensorflow/tfjs / serialNext

Method serialNext

tfjs-data/src/iterators/lazy_iterator.ts:584–598  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

582 }
583
584 private async serialNext(): Promise<IteratorResult<T>> {
585 // TODO(soergel): consider tradeoffs of reading in parallel, eg.
586 // collecting next() promises in an Array and then waiting for
587 // Promise.all() of those. Benefit: pseudo-parallel execution. Drawback:
588 // maybe delayed GC.
589 while (this.count++ < this.maxCount) {
590 const skipped = await this.upstream.next();
591 // short-circuit if upstream is already empty
592 if (skipped.done) {
593 return skipped;
594 }
595 tf.dispose(skipped.value as {});
596 }
597 return this.upstream.next();
598 }
599}
600
601class TakeIterator<T> extends LazyIterator<T> {

Callers 2

nextMethod · 0.95
nextFunction · 0.45

Calls 2

nextMethod · 0.45
disposeMethod · 0.45

Tested by

no test coverage detected