From e7f5a34c80decfaf87288bf38559ed8f45dc9bcb Mon Sep 17 00:00:00 2001 From: WolframRhodium Date: Sun, 26 May 2024 13:51:10 +0800 Subject: [PATCH] vstrt/vs_tensorrt.cpp: cosmetics --- .github/workflows/windows-trt.yml | 2 +- vstrt/vs_tensorrt.cpp | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/windows-trt.yml b/.github/workflows/windows-trt.yml index af116f6..0e20512 100644 --- a/.github/workflows/windows-trt.yml +++ b/.github/workflows/windows-trt.yml @@ -70,7 +70,7 @@ jobs: - name: Configure run: cmake -S . -B build -G Ninja -LA -D CMAKE_BUILD_TYPE=Release - -D CMAKE_CXX_FLAGS="/EHsc /W4 /wd4100 /wd4996" + -D CMAKE_CXX_FLAGS="/EHsc /Wall /wd4100 /wd4625 /wd4626 /wd4996" -D CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -D CUDAToolkit_ROOT="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4" -D VAPOURSYNTH_INCLUDE_DIRECTORY="%cd%\vapoursynth\include" diff --git a/vstrt/vs_tensorrt.cpp b/vstrt/vs_tensorrt.cpp index 15be7d8..5baa7a9 100644 --- a/vstrt/vs_tensorrt.cpp +++ b/vstrt/vs_tensorrt.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -420,15 +421,24 @@ static void VS_CC vsTrtCreate( return set_error("open engine failed"); } - size_t engine_nbytes = engine_stream.tellg(); + auto engine_nbytes = engine_stream.tellg(); + if (engine_nbytes == -1) { + return set_error("open engine failed"); + } + std::unique_ptr engine_data { - (char *) malloc(engine_nbytes), free + (char *) malloc(static_cast(engine_nbytes)), free }; engine_stream.seekg(0, std::ios::beg); - engine_stream.read(engine_data.get(), engine_nbytes); + engine_stream.read(engine_data.get(), static_cast(engine_nbytes)); d->runtime.reset(nvinfer1::createInferRuntime(d->logger)); - auto maybe_engine = initEngine(engine_data.get(), engine_nbytes, d->runtime, !d->flexible_output_prop.empty()); + auto maybe_engine = initEngine( + engine_data.get(), + static_cast(engine_nbytes), + d->runtime, + !d->flexible_output_prop.empty() + ); if (std::holds_alternative>(maybe_engine)) { d->engines.push_back(std::move(std::get>(maybe_engine))); } else {