From 537bd9560613bb3c688e9a2fc342196caebc9f26 Mon Sep 17 00:00:00 2001 From: Maximilian Mueller Date: Wed, 17 Jul 2024 12:13:39 +0200 Subject: [PATCH] casting tellg to size_type correctly --- onnxruntime/test/perftest/ort_test_session.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/onnxruntime/test/perftest/ort_test_session.cc b/onnxruntime/test/perftest/ort_test_session.cc index 4ccf318e988b6..fa0876be70be9 100644 --- a/onnxruntime/test/perftest/ort_test_session.cc +++ b/onnxruntime/test/perftest/ort_test_session.cc @@ -820,11 +820,12 @@ select from 'TF8', 'TF16', 'UINT8', 'FLOAT', 'ITENSOR'. \n)"); if (!performance_test_config.model_info.load_via_path) { session_ = Ort::Session(env, performance_test_config.model_info.model_file_path.c_str(), session_options); } else { - std::fstream file(performance_test_config.model_info.model_file_path.c_str(), std::fstream::binary | std::fstream::in | std::fstream::ate); + std::ifstream file(performance_test_config.model_info.model_file_path.c_str(), + std::ios::binary | std::ios::in | std::ios::ate); if (file.is_open()) { - const size_t fsize = file.tellg(); + const std::streamsize fsize = file.tellg(); file.seekg(0, std::ios_base::beg); - std::vector model_bytes(fsize); + std::vector model_bytes(narrow(fsize)); file.read(model_bytes.data(), fsize); session_ = Ort::Session(env, model_bytes.data(), model_bytes.size(), session_options); } else {