yolov3 add fp16 mode

This commit is contained in:
wang-xinyu 2019-11-28 00:28:33 +08:00
parent 6f776a4d2e
commit 67622f76a3
2 changed files with 7 additions and 0 deletions

View File

@ -13,6 +13,8 @@ Following tricks are used in this yolov3,
- upsample layer is replaced by a deconvolution layer.
- Batchnorm layer, implemented by scale layer.
For FP16 mode, just need add one line `builder->setFp16Mode(true);`. On my TX1, it's 115ms in fp16, while 145ms in fp32.
```
// 1. generate yolov3.wts from [pytorchx/pytorch-yolo-v3](https://github.com/wang-xinyu/pytorchx/tree/master/pytorch-yolo-v3)

View File

@ -12,6 +12,8 @@
#include "yololayer.h"
#include <opencv2/opencv.hpp>
#define USE_FP16 // comment out this if want to use FP32
// stuff we know about the network and the input/output blobs
static const int INPUT_H = 320;
static const int INPUT_W = 320;
@ -383,6 +385,9 @@ ICudaEngine* createEngine(unsigned int maxBatchSize, IBuilder* builder, DataType
// Build engine
builder->setMaxBatchSize(maxBatchSize);
builder->setMaxWorkspaceSize(1 << 20);
#ifdef USE_FP16
builder->setFp16Mode(true);
#endif
ICudaEngine* engine = builder->buildCudaEngine(*network);
std::cout << "build out" << std::endl;