From f9d5705db488266bfe51acbf22e78fc95edc7596 Mon Sep 17 00:00:00 2001 From: Yifan Li <109183385+yf711@users.noreply.github.com> Date: Thu, 2 Nov 2023 08:05:08 -0700 Subject: [PATCH] [EP Perf] Fix sort (#18174) ### Description Existing sort can't handle the index within test data folders/inputs name string correctly, when index is larger than 10 Update the logic to sort based on index fetched by regex --- onnxruntime/python/tools/tensorrt/perf/benchmark.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/onnxruntime/python/tools/tensorrt/perf/benchmark.py b/onnxruntime/python/tools/tensorrt/perf/benchmark.py index 966c360a3a..0f06676641 100644 --- a/onnxruntime/python/tools/tensorrt/perf/benchmark.py +++ b/onnxruntime/python/tools/tensorrt/perf/benchmark.py @@ -89,7 +89,13 @@ TRT_ENGINE_CACHE_DIR_NAME = "engine_cache" def split_and_sort_output(string_list): string_list = string_list.split("\n") - string_list.sort() + + def custom_sort(item): + # Parse digits + numbers = re.findall(r"\d+", item) + return int(numbers[0]) if numbers else float("inf") + + string_list.sort(key=custom_sort) return string_list