Skip to content

Commit 5c8ced3

Browse files
committed
onnx
1 parent 2a882dd commit 5c8ced3

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

tensorrt/trt_dep.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void SemanticSegmentTrt::parse_to_engine(string onnx_pth,
9595
profile->setDimensions(input->getName(), OptProfileSelector::kMAX, dmax);
9696
config->addOptimizationProfile(profile);
9797

98-
if (quant == "fp16") { // fp16
98+
if (quant == "fp16" or quant == "int8") { // fp16
9999
if (builder->platformHasFastFp16() == false) {
100100
cout << "fp16 is set, but platform does not support, so we ignore this\n";
101101
} else {
@@ -275,6 +275,7 @@ void SemanticSegmentTrt::test_speed_fps() {
275275

276276
cout << "\ntest with cropsize of (" << iH << ", " << iW << "), "
277277
<< "and batch size of " << batchsize << " ...\n";
278+
context->executeV2(buffs.data()); // run one batch ahead
278279
auto start = std::chrono::steady_clock::now();
279280
const int n_loops{2000};
280281
for (int i{0}; i < n_loops; ++i) {

tools/export_onnx.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@
3535
dummy_input = torch.randn(1, 3, 1024, 2048)
3636
input_names = ['input_image']
3737
output_names = ['preds',]
38+
dynamic_axes = {'input_image': {0: 'batch'}, 'preds': {0: 'batch'}}
3839

3940
torch.onnx.export(net, dummy_input, args.out_pth,
4041
input_names=input_names, output_names=output_names,
41-
verbose=False, opset_version=11, )
42+
verbose=False, opset_version=18,
43+
dynamic_axes=dynamic_axes)
4244

0 commit comments

Comments
 (0)