\brief Sets computation precision for network layers
| 218 | //! \brief Sets computation precision for network layers |
| 219 | //! |
| 220 | void 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. |
nothing calls this directly
no test coverage detected