From dfaf18928ab585d99be3bfd605f67beb862a2756 Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Mon, 15 Jul 2024 10:47:02 -0700 Subject: [PATCH] Fix a path problem in onnxruntime_perf_test (#21341) ### Description Resolve #21267 . onnxruntime_perf_test does not work properly if the input model path url is just a single filename without any path separator. For example, ``` ./onnxruntime_perf_test -t 10 model.onnx ``` The problem was introduced in #19196 by me. --- onnxruntime/test/onnx/TestCase.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/onnxruntime/test/onnx/TestCase.h b/onnxruntime/test/onnx/TestCase.h index 0cb92056d3..745a1fe9ee 100644 --- a/onnxruntime/test/onnx/TestCase.h +++ b/onnxruntime/test/onnx/TestCase.h @@ -53,7 +53,8 @@ class TestModelInfo { public: virtual const std::filesystem::path& GetModelUrl() const = 0; virtual std::filesystem::path GetDir() const { - return GetModelUrl().parent_path(); + const auto& p = GetModelUrl(); + return p.has_parent_path() ? p.parent_path() : std::filesystem::current_path(); } virtual const std::string& GetNodeName() const = 0; virtual const ONNX_NAMESPACE::ValueInfoProto* GetInputInfoFromModel(size_t i) const = 0;