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

Function loadFromFile

samples/common/sampleUtils.cpp:75–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75void loadFromFile(std::string const& fileName, char* dst, size_t size)
76{
77 ASSERT(dst);
78
79 std::ifstream file(fileName, std::ios::in | std::ios::binary);
80 if (file.is_open())
81 {
82 file.read(dst, size);
83 size_t const nbBytesRead = file.gcount();
84 file.close();
85 if (nbBytesRead != size)
86 {
87 std::ostringstream msg;
88 msg << "Unexpected file size for input file: " << fileName << ". Note: Expected: " << size
89 << " bytes but only read: " << nbBytesRead << " bytes";
90 throw std::invalid_argument(msg.str());
91 }
92 }
93 else
94 {
95 std::ostringstream msg;
96 msg << "Cannot open file " << fileName << "!";
97 throw std::invalid_argument(msg.str());
98 }
99}
100
101std::vector<std::string> splitToStringVec(std::string const& s, char separator)
102{

Callers 2

setUpInferenceFunction · 0.85
fillMethod · 0.85

Calls 1

readMethod · 0.80

Tested by

no test coverage detected