From 61051396e883e9496b37ffcd84b18386856daad0 Mon Sep 17 00:00:00 2001 From: Moshe David Date: Fri, 11 Sep 2020 01:03:34 +0300 Subject: [PATCH] [TensorRT] Align naming convention and remove redundant code (#5094) --- .../tensorrt/tensorrt_execution_provider.cc | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc b/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc index 617e02d473..d546f63ded 100644 --- a/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc +++ b/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc @@ -774,14 +774,13 @@ common::Status TensorrtExecutionProvider::Provider_Compile(const std::vector engine_buf{new char[engine_size]}; - planFile.read((char*)engine_buf.get(), engine_size); - planFile.close(); + plan_file.read((char*)engine_buf.get(), engine_size); trt_engine = tensorrt_ptr::unique_pointer(runtime_->deserializeCudaEngine(engine_buf.get(), engine_size, nullptr)); LOGS_DEFAULT(VERBOSE) << "[TensorRT EP] DeSerialized " + cached_path; } else { @@ -1026,14 +1025,13 @@ common::Status TensorrtExecutionProvider::Provider_Compile(const std::vectortrt_node_name_with_precision + "_" + GetVecHash(input_shapes); std::string cached_path = GetEnginePath(trt_state->engine_cache_path, trt_node_name_with_precision_shape); - std::ifstream planFile(cached_path, std::ios::binary | std::ios::in); - if (planFile && trt_state->engine_cache_enable) { - planFile.seekg(0, std::ios::end); - int engine_size = planFile.tellg(); - planFile.seekg(0, std::ios::beg); + std::ifstream plan_file(cached_path, std::ios::binary | std::ios::in); + if (plan_file && trt_state->engine_cache_enable) { + plan_file.seekg(0, std::ios::end); + int engine_size = plan_file.tellg(); + plan_file.seekg(0, std::ios::beg); std::unique_ptr engine_buf{new char[engine_size]}; - planFile.read((char*)engine_buf.get(), engine_size); - planFile.close(); + plan_file.read((char*)engine_buf.get(), engine_size); auto runtime_ = trt_state->runtime; trt_state->engine->reset();