From 3a9f30df468812d604b53ca1e0a01fa5d9fd103e Mon Sep 17 00:00:00 2001 From: xkszltl Date: Tue, 17 Jan 2023 08:59:20 +0800 Subject: [PATCH] Compatibility patch for nlohmann/json < 3.9.0. (#12394) This is required on CentOS 7 if using distro-provided json-devel 3.6.1. Regression introduced in: - https://github.com/microsoft/onnxruntime/pull/11775 Related upstream commit: - https://github.com/nlohmann/json/commit/74520d8bb0aa62374e5c5465b5b0f3b43d75d956 Fixed https://github.com/microsoft/onnxruntime/issues/12393 --- onnxruntime/test/onnx/main.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/onnxruntime/test/onnx/main.cc b/onnxruntime/test/onnx/main.cc index 3abe682c1e..82298db819 100644 --- a/onnxruntime/test/onnx/main.cc +++ b/onnxruntime/test/onnx/main.cc @@ -75,7 +75,12 @@ static TestTolerances LoadTestTolerances(bool enable_cuda, bool enable_openvino) } const auto overrides_json = nlohmann::json::parse( overrides_ifstream, - /*cb=*/nullptr, /*allow_exceptions=*/true, /*ignore_comments=*/true); + /*cb=*/nullptr, /*allow_exceptions=*/true + // Comment support is added in 3.9.0 with breaking change to default behavior. + #if NLOHMANN_JSON_VERSION_MAJOR * 1000 + NLOHMANN_JSON_VERSION_MINOR >= 3009 + , /*ignore_comments=*/true + #endif + ); overrides_json["atol_overrides"].get_to(absolute_overrides); overrides_json["rtol_overrides"].get_to(relative_overrides); return TestTolerances(