#include <batch_stream.h>
◆ BatchStream() [1/2]
| apollo::perception::inference::BatchStream::BatchStream |
( |
int |
batchSize, |
|
|
int |
maxBatches, |
|
|
std::string |
data_path |
|
) |
| |
在文件 batch_stream.cc 第 35 行定义.
36 : mBatchSize(batchSize), mMaxBatches(maxBatches), mPath(dataPath) {
37 FILE *file = fopen((mPath + "Batch0").c_str(), "rb");
38 if (file != nullptr) {
39 int d[4];
40 int fs = static_cast<int>(fread(d, sizeof(int), 4, file));
41 CHECK_EQ(fs, 4);
43 fclose(file);
44 mImageSize = mDims.
c() * mDims.
h() * mDims.
w();
45 mBatch.resize(mBatchSize * mImageSize, 0);
46 mFileBatch.resize(mDims.
n() * mImageSize, 0);
48 }
49}
void reset(int firstBatch)
◆ BatchStream() [2/2]
| apollo::perception::inference::BatchStream::BatchStream |
( |
| ) |
|
◆ getBatch()
| float * apollo::perception::inference::BatchStream::getBatch |
( |
| ) |
|
|
inline |
◆ getBatchesRead()
| int apollo::perception::inference::BatchStream::getBatchesRead |
( |
| ) |
const |
|
inline |
◆ getBatchSize()
| int apollo::perception::inference::BatchStream::getBatchSize |
( |
| ) |
const |
|
inline |
◆ getDims()
◆ next()
| bool apollo::perception::inference::BatchStream::next |
( |
| ) |
|
在文件 batch_stream.cc 第 62 行定义.
62 {
63 if (mBatchCount == mMaxBatches) {
64 return false;
65 }
66
67 for (int csize = 1, batchPos = 0; batchPos < mBatchSize;
68 batchPos += csize, mFileBatchPos += csize) {
69 CHECK_GT(mFileBatchPos, 0);
70 CHECK_LE(mFileBatchPos, mDims.
n());
71
72 if (mFileBatchPos == mDims.
n() && !update()) {
73 return false;
74 }
75
76
77
78 csize = std::min(mBatchSize - batchPos, mDims.
n() - mFileBatchPos);
79 std::copy_n(getFileBatch() + mFileBatchPos * mImageSize, csize * mImageSize,
81 }
82 mBatchCount++;
83 return true;
84}
◆ reset()
| void apollo::perception::inference::BatchStream::reset |
( |
int |
firstBatch | ) |
|
在文件 batch_stream.cc 第 53 行定义.
53 {
54 if (mPath != "") {
55 mBatchCount = 0;
56 mFileCount = 0;
57 mFileBatchPos = mDims.
n();
59 }
60}
◆ skip()
| void apollo::perception::inference::BatchStream::skip |
( |
int |
skipCount | ) |
|
在文件 batch_stream.cc 第 86 行定义.
86 {
87 if (mBatchSize >= mDims.
n() && mBatchSize % mDims.
n() == 0 &&
88 mFileBatchPos == mDims.
n()) {
89 mFileCount += skipCount * mBatchSize / mDims.
n();
90 return;
91 }
92
93 int x = mBatchCount;
94 for (int i = 0; i < skipCount; ++i) {
96 }
97 mBatchCount = x;
98}
该类的文档由以下文件生成: