Apollo 11.0
自动驾驶开放平台
batch_stream.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#pragma once
18
19#include <NvInferVersion.h>
20
21#ifdef NV_TENSORRT_MAJOR
22 #if NV_TENSORRT_MAJOR == 8
24 #endif
25#endif
26
27#include <string>
28#include <vector>
29
30#include "NvInfer.h"
31
32namespace apollo {
33namespace perception {
34namespace inference {
35
37 public:
38 BatchStream(int batchSize, int maxBatches, std::string data_path);
40
41 // @brief reset current batch id
42 void reset(int firstBatch);
43
44 // @brief get next batch
45 bool next();
46
47 // @brief skip `skipCount` batches
48 void skip(int skipCount);
49
50 float *getBatch() { return &mBatch[0]; }
51 int getBatchesRead() const { return mBatchCount; }
52 int getBatchSize() const { return mBatchSize; }
53 nvinfer1::DimsNCHW getDims() const { return mDims; }
54
55 private:
56 float *getFileBatch() { return &mFileBatch[0]; }
57
58 bool update();
59
60 int mBatchSize{0};
61 int mMaxBatches{0};
62 int mBatchCount{0};
63
64 int mFileCount{0};
65 int mFileBatchPos{0};
66 int mImageSize{0};
67
69 std::vector<float> mBatch;
70 std::vector<float> mFileBatch;
71 std::string mPath;
72};
73
74} // namespace inference
75} // namespace perception
76} // namespace apollo
class register implement
Definition arena_queue.h:37