Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,19 @@
". Please make sure engine cache is in the same directory or sub-directory of context model.");
}

std::ifstream engine_file(engine_cache_path.string(), std::ios::binary | std::ios::in);
engine_file.seekg(0, std::ios::end);
size_t engine_size = engine_file.tellg();
engine_file.seekg(0, std::ios::beg);
std::unique_ptr<char[]> engine_buf{new char[engine_size]};
engine_file.read((char*)engine_buf.get(), engine_size);
*(trt_engine_) = std::unique_ptr<nvinfer1::ICudaEngine>(trt_runtime_->deserializeCudaEngine(engine_buf.get(), engine_size));
size_t file_length = 0;
auto path_str = ToPathString(engine_cache_path.string());

Env::MappedMemoryPtr engine_buf;
const auto& env = GetDefaultEnv();
ORT_RETURN_IF_ERROR(env.GetFileLength(path_str.c_str(), file_length));
if (!file_length) {
return ORT_MAKE_STATUS(ONNXRUNTIME, EP_FAIL,
"Nv EP could not read engine from cache: " + engine_cache_path.string());
}
ORT_RETURN_IF_ERROR(env.MapFileIntoMemory(path_str.c_str(), 0, file_length, engine_buf));

*(trt_engine_) = std::unique_ptr<nvinfer1::ICudaEngine>(trt_runtime_->deserializeCudaEngine(engine_buf.get(), file_length));

Check warning on line 326 in onnxruntime/core/providers/nv_tensorrt_rtx/onnx_ctx_model_helper.cc

View workflow job for this annotation

GitHub Actions / Optional Lint C++

[cpplint] reported by reviewdog 🐶 Add #include <memory> for unique_ptr<> [build/include_what_you_use] [4] Raw Output: onnxruntime/core/providers/nv_tensorrt_rtx/onnx_ctx_model_helper.cc:326: Add #include <memory> for unique_ptr<> [build/include_what_you_use] [4]
if (!(*trt_engine_)) {
return ORT_MAKE_STATUS(ONNXRUNTIME, EP_FAIL,
"Nv EP could not deserialize engine from cache: " + engine_cache_path.string());
Expand Down
Loading