MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / saveEngine

Function saveEngine

samples/common/sampleEngines.cpp:1371–1389  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1369}
1370
1371bool 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
1391bool getEngineBuildEnv(
1392 const ModelOptions& model, BuildOptions const& build, SystemOptions& sys, BuildEnvironment& env, std::ostream& err)

Callers 1

buildMethod · 0.85

Calls 4

writeMethod · 0.80
serializeMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected