MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / next

Method next

samples/common/BatchStream.h:212–235  ·  view source on GitHub ↗

Advance to next batch and return true, or return false if there is no batch left.

Source from the content-addressed store, hash-verified

210
211 // Advance to next batch and return true, or return false if there is no batch left.
212 bool next() override
213 {
214 if (mBatchCount == mMaxBatches)
215 {
216 return false;
217 }
218
219 for (int csize = 1, batchPos = 0; batchPos < mBatchSize; batchPos += csize, mFileBatchPos += csize)
220 {
221 ASSERT(mFileBatchPos > 0 && mFileBatchPos <= mDims.d[0]);
222 if (mFileBatchPos == mDims.d[0] && !update())
223 {
224 return false;
225 }
226
227 // copy the smaller of: elements left to fulfill the request, or elements left in the file buffer.
228 csize = std::min(mBatchSize - batchPos, mDims.d[0] - mFileBatchPos);
229 std::copy_n(
230 getFileBatch() + mFileBatchPos * mImageSize, csize * mImageSize, getBatch() + batchPos * mImageSize);
231 std::copy_n(getFileLabels() + mFileBatchPos, csize, getLabels() + batchPos);
232 }
233 mBatchCount++;
234 return true;
235 }
236
237 // Skips the batches
238 void skip(int skipCount) override

Callers 1

getBatchMethod · 0.45

Calls 3

updateFunction · 0.85
minFunction · 0.85
getBatchFunction · 0.85

Tested by

no test coverage detected