| 1369 | } |
| 1370 | |
| 1371 | bool saveEngine(const ICudaEngine& engine, std::string const& fileName, std::ostream& err) |
| 1372 | { |
| 1373 | std::ofstream engineFile(fileName, std::ios::binary); |
| 1374 | if (!engineFile) |
| 1375 | { |
| 1376 | err << "Cannot open engine file: " << fileName << std::endl; |
| 1377 | return false; |
| 1378 | } |
| 1379 | |
| 1380 | std::unique_ptr<IHostMemory> serializedEngine{engine.serialize()}; |
| 1381 | if (serializedEngine == nullptr) |
| 1382 | { |
| 1383 | err << "Engine serialization failed" << std::endl; |
| 1384 | return false; |
| 1385 | } |
| 1386 | |
| 1387 | engineFile.write(static_cast<char*>(serializedEngine->data()), serializedEngine->size()); |
| 1388 | return !engineFile.fail(); |
| 1389 | } |
| 1390 | |
| 1391 | bool getEngineBuildEnv( |
| 1392 | const ModelOptions& model, BuildOptions const& build, SystemOptions& sys, BuildEnvironment& env, std::ostream& err) |