-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserialize.cpp
More file actions
executable file
·31 lines (28 loc) · 1.17 KB
/
Copy pathserialize.cpp
File metadata and controls
executable file
·31 lines (28 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "deeplabv3plus.h"
int main(int argc, char** argv){
std::string engine_name = "deeplabv3plus.engine";
std::string weights_name = "./bareSimple2.wts";
std::string fir_name = "/home/ylc/GMP/trt7/baresoil_v2/build/output";
// std::string weights_name = "/data/gmp/TensorRT_EVN/projects/baresoil/deeplabv3plus/build/bareSimple2.wts";
// std::string fir_name = "/data/gmp/TensorRT_EVN/projects/baresoil/deeplabv3plus/build/output";
char *trtModelStream{nullptr};
size_t size{0};
if(argc == 2 && std::string(argv[1]) == "-s"){
//serialize engine file
IHostMemory* modelStream{nullptr};
APIToModel(BATCH_SIZE, &modelStream, weights_name);
assert(modelStream != nullptr);
std::ofstream p(engine_name, std::ios::binary);
if (!p) {
std::cerr << "could not open plan output file" << std::endl;
return -1;
}
p.write(reinterpret_cast<const char*>(modelStream->data()), modelStream->size());
modelStream->destroy();
return 0;
}
else{
std::cerr << "./serialize -s // serialize model to plan file" << std::endl;
return -1;
}
}