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

Class SampleBuffer

samples/sampleIOFormats/sampleIOFormats.cpp:147–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145};
146
147class SampleBuffer
148{
149public:
150 SampleBuffer()
151 {
152 dims.d[0] = 1;
153 dims.d[1] = 1;
154 dims.d[2] = 1;
155 dims.d[3] = 1;
156 }
157
158 SampleBuffer(nvinfer1::Dims dims, int32_t dataWidth, TensorFormat format, bool isInput)
159 : dims(dims)
160 , dataWidth(dataWidth)
161 , format(format)
162 , isInput(isInput)
163 {
164
165 // Output buffer is unsqueezed to 4D in order to reuse the BufferDesc class
166 if (isInput == false)
167 {
168 dims.d[2] = dims.d[0];
169 dims.d[3] = dims.d[1];
170 dims.d[0] = 1;
171 dims.d[1] = 1;
172 }
173
174 desc = BufferDesc(dims, dataWidth, format);
175
176 if (nullptr == buffer)
177 {
178 buffer = new uint8_t[getBufferSize()]();
179 }
180 }
181
182 ~SampleBuffer()
183 {
184 destroy();
185 }
186
187 SampleBuffer& operator=(SampleBuffer&& sampleBuffer) noexcept
188 {
189 destroy();
190
191 this->dims = sampleBuffer.dims;
192 this->dataWidth = sampleBuffer.dataWidth;
193 this->desc = sampleBuffer.desc;
194 this->format = sampleBuffer.format;
195 this->isInput = sampleBuffer.isInput;
196 this->buffer = sampleBuffer.buffer;
197 sampleBuffer.buffer = nullptr;
198
199 return *this;
200 }
201
202 void destroy()
203 {
204 if (buffer != nullptr)

Callers 2

processFunction · 0.85
runFP32ReferenceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected