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

Method setLayerPrecision

samples/sampleINT8API/sampleINT8API.cpp:220–256  ·  view source on GitHub ↗

\brief Sets computation precision for network layers

Source from the content-addressed store, hash-verified

218//! \brief Sets computation precision for network layers
219//!
220void SampleINT8API::setLayerPrecision(SampleUniquePtr<nvinfer1::INetworkDefinition>& network)
221{
222 sample::gLogInfo << "Setting Per Layer Computation Precision" << std::endl;
223 for (int i = 0; i < network->getNbLayers(); ++i)
224 {
225 auto layer = network->getLayer(i);
226 if (mParams.verbose)
227 {
228 std::string layerName = layer->getName();
229 sample::gLogInfo << "Layer: " << layerName << ". Precision: INT8" << std::endl;
230 }
231
232 // Don't set the precision on non-computation layers as they don't support
233 // int8.
234 if (layer->getType() != LayerType::kCONSTANT && layer->getType() != LayerType::kCONCATENATION
235 && layer->getType() != LayerType::kSHAPE)
236 {
237 // set computation precision of the layer
238 layer->setPrecision(nvinfer1::DataType::kINT8);
239 }
240
241 for (int j = 0; j < layer->getNbOutputs(); ++j)
242 {
243 std::string tensorName = layer->getOutput(j)->getName();
244 if (mParams.verbose)
245 {
246 std::string tensorName = layer->getOutput(j)->getName();
247 sample::gLogInfo << "Tensor: " << tensorName << ". OutputType: INT8" << std::endl;
248 }
249 // set output type of execution tensors and not shape tensors.
250 if (layer->getOutput(j)->isExecutionTensor())
251 {
252 layer->setOutputType(j, nvinfer1::DataType::kINT8);
253 }
254 }
255 }
256}
257
258//!
259//! \brief Write network tensor names to a file.

Callers

nothing calls this directly

Calls 9

getLayerMethod · 0.80
setPrecisionMethod · 0.80
isExecutionTensorMethod · 0.80
setOutputTypeMethod · 0.80
getNbLayersMethod · 0.45
getNameMethod · 0.45
getTypeMethod · 0.45
getNbOutputsMethod · 0.45
getOutputMethod · 0.45

Tested by

no test coverage detected