From 3725a34e67b1b622758b31fa1f7eac87c487d99f Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sat, 21 Mar 2026 10:33:10 +0000 Subject: [PATCH] onnxruntime: 1.23.2 -> 1.24.4 Diff: https://github.com/microsoft/onnxruntime/compare/v1.23.2...v1.24.4 Changelog: https://github.com/microsoft/onnxruntime/releases/tag/v1.24.4 --- pkgs/by-name/on/onnxruntime/package.nix | 108 +++++-------- .../on/onnxruntime/protobuf34-nodiscard.patch | 148 +++++++++++++++--- .../remove-MATH_NO_EXCEPT-macro.patch | 37 +++++ 3 files changed, 197 insertions(+), 96 deletions(-) create mode 100644 pkgs/by-name/on/onnxruntime/remove-MATH_NO_EXCEPT-macro.patch diff --git a/pkgs/by-name/on/onnxruntime/package.nix b/pkgs/by-name/on/onnxruntime/package.nix index 859adff2f720..b01633221af1 100644 --- a/pkgs/by-name/on/onnxruntime/package.nix +++ b/pkgs/by-name/on/onnxruntime/package.nix @@ -3,10 +3,7 @@ config, stdenv, fetchFromGitHub, - applyPatches, - fetchpatch, - fetchurl, - abseil-cpp_202407, + abseil-cpp_202508, cmake, cpuinfo, eigen, @@ -59,39 +56,20 @@ let hash = "sha256-pjwjrqq6dfiVsXIhbBtbolhiysiFlFTnx5XcX77f+C0="; }; - onnx-src = applyPatches { + onnx-src = fetchFromGitHub { name = "onnx-src"; - src = fetchFromGitHub { - owner = "onnx"; - repo = "onnx"; - tag = "v1.18.0"; - hash = "sha256-UhtF+CWuyv5/Pq/5agLL4Y95YNP63W2BraprhRqJOag="; - }; - - patches = [ - # Fix "error: conversion from 'onnx::OpSchema' to non-scalar type 'onnx::OpSchemaRegistry::OpSchemaRegisterOnce'" - # https://github.com/microsoft/onnxruntime/issues/26229 - # Fix from https://github.com/onnx/onnx/pull/7390 - (fetchpatch { - url = "https://github.com/onnx/onnx/commit/595a069aaac07586f111681245bc808ee63551f8.patch"; - includes = [ "onnx/defs/schema.h" ]; - hash = "sha256-FFAJuJse4nmNT3ixvEdlqzbr3edY46SqEFv7z/oo6m0="; - }) - - # Fix "undefined reference to `onnx::RNNShapeInference(onnx::InferenceContext&)'" - (fetchpatch { - url = "https://github.com/onnx/onnx/commit/6769c41ad64ebca0358da8c7211d2c6d0e627b2b.patch"; - hash = "sha256-VlTHs0om20kTNvSVQaasSsa5JROliQy4k9BECTsBtbU="; - }) - ]; + owner = "onnx"; + repo = "onnx"; + tag = "v1.20.1"; + hash = "sha256-XZJXD6sBvVJ6cLPyDkKOW8oSkjqcw9whUqDWd7dxY3c="; }; cutlass-src = fetchFromGitHub { name = "cutlass-src"; owner = "NVIDIA"; repo = "cutlass"; - tag = "v3.9.2"; - hash = "sha256-teziPNA9csYvhkG5t2ht8W8x5+1YGGbHm8VKx4JoxgI="; + tag = "v4.2.1"; + hash = "sha256-iP560D5Vwuj6wX1otJhwbvqe/X4mYVeKTpK533Wr5gY="; }; dlpack-src = fetchFromGitHub { @@ -106,30 +84,17 @@ let in effectiveStdenv.mkDerivation (finalAttrs: { pname = "onnxruntime"; - version = "1.23.2"; + version = "1.24.4"; src = fetchFromGitHub { owner = "microsoft"; repo = "onnxruntime"; tag = "v${finalAttrs.version}"; fetchSubmodules = true; - hash = "sha256-hZ2L5+0Enkw4rGDKVpRECnKXP87w6Kbiyp6Fdxwt6hk="; + hash = "sha256-CjPgRkPyp7dUPAOo3cePWQvucOlQAwtT4NO5w3NkV+E="; }; patches = [ - # Missing cstdint include (GCC 15 compatibility) - (fetchpatch { - url = "https://github.com/microsoft/onnxruntime/commit/d6e712c5b7b6260a61e54d1fe40107cf5366ee77.patch"; - hash = "sha256-FSuPybX8f2VoxvLhcYx4rdChaiK8bSUDR32sN3Efwfc="; - }) - - # Correct maybe-uninitialized and range-loop-construct warnings - # https://github.com/microsoft/onnxruntime/pull/26201 - (fetchpatch { - url = "https://github.com/microsoft/onnxruntime/commit/8ebd0bf1cf02414584d15d7244b07fa97d65ba02.patch"; - hash = "sha256-vX+kaFiNdmqWI91JELcLpoaVIHBb5EPbI7rCAMYAx04="; - }) - # Skip execinfo include on musl # https://github.com/microsoft/onnxruntime/pull/25726 ./musl-execinfo.patch @@ -139,16 +104,36 @@ effectiveStdenv.mkDerivation (finalAttrs: { # Fix build of unit tests with musl libc # https://github.com/microsoft/onnxruntime/issues/9155 - (fetchurl { - url = "https://gitlab.alpinelinux.org/alpine/aports/-/raw/462dfe0eb4b66948fe48de44545cc22bb64fdf9f/community/onnxruntime/0001-Remove-MATH_NO_EXCEPT-macro.patch"; - hash = "sha256-BdeGYevZExWWCuJ1lSw0Roy3h+9EbJgFF8qMwVxSn1A="; - }) + # Patch adapted from https://gitlab.alpinelinux.org/alpine/aports/-/raw/462dfe0eb4b66948fe48de44545cc22bb64fdf9f/community/onnxruntime/0001-Remove-MATH_NO_EXCEPT-macro.patch + ./remove-MATH_NO_EXCEPT-macro.patch # Fix build of ignored outputs after Protobuf 34 added `[[nodiscard]]` to # many functions. ./protobuf34-nodiscard.patch ]; + postPatch = '' + substituteInPlace cmake/libonnxruntime.pc.cmake.in \ + --replace-fail '$'{prefix}/@CMAKE_INSTALL_ @CMAKE_INSTALL_ + echo "find_package(cudnn_frontend REQUIRED)" > cmake/external/cudnn_frontend.cmake + '' + + '' + substituteInPlace onnxruntime/core/platform/posix/env.cc --replace-fail \ + "return PathString{};" \ + "return PathString(\"$out/lib/\");" + '' + + lib.optionalString rocmSupport '' + patchShebangs tools/ci_build/hipify-perl + '' + # https://github.com/NixOS/nixpkgs/pull/226734#issuecomment-1663028691 + + lib.optionalString (effectiveStdenv.hostPlatform.system == "aarch64-linux") '' + rm -v onnxruntime/test/optimizer/nhwc_transformer_test.cc + ''; + + postBuild = lib.optionalString pythonSupport '' + ${python3Packages.python.interpreter} ../setup.py bdist_wheel + ''; + nativeBuildInputs = [ cmake pkg-config @@ -261,7 +246,7 @@ effectiveStdenv.mkDerivation (finalAttrs: { (lib.cmakeFeature "CMAKE_CXX_FLAGS" "-Wno-error=unused-variable") (lib.cmakeBool "FETCHCONTENT_FULLY_DISCONNECTED" true) (lib.cmakeBool "FETCHCONTENT_QUIET" false) - (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_ABSEIL_CPP" "${abseil-cpp_202407.src}") + (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_ABSEIL_CPP" "${abseil-cpp_202508.src}") (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_DLPACK" "${dlpack-src}") (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_FLATBUFFERS" "${flatbuffers_23.src}") (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_MP11" "${mp11-src}") @@ -344,29 +329,6 @@ effectiveStdenv.mkDerivation (finalAttrs: { ]; hardeningDisable = lib.optional effectiveStdenv.hostPlatform.isMusl "fortify"; - postPatch = '' - substituteInPlace cmake/libonnxruntime.pc.cmake.in \ - --replace-fail '$'{prefix}/@CMAKE_INSTALL_ @CMAKE_INSTALL_ - echo "find_package(cudnn_frontend REQUIRED)" > cmake/external/cudnn_frontend.cmake - '' - # https://github.com/microsoft/onnxruntime/blob/c4f3742bb456a33ee9c826ce4e6939f8b84ce5b0/onnxruntime/core/platform/env.h#L249 - + '' - substituteInPlace onnxruntime/core/platform/env.h --replace-fail \ - "GetRuntimePath() const { return PathString(); }" \ - "GetRuntimePath() const { return PathString(\"$out/lib/\"); }" - '' - + lib.optionalString rocmSupport '' - patchShebangs tools/ci_build/hipify-perl - '' - # https://github.com/NixOS/nixpkgs/pull/226734#issuecomment-1663028691 - + lib.optionalString (effectiveStdenv.hostPlatform.system == "aarch64-linux") '' - rm -v onnxruntime/test/optimizer/nhwc_transformer_test.cc - ''; - - postBuild = lib.optionalString pythonSupport '' - ${python3Packages.python.interpreter} ../setup.py bdist_wheel - ''; - # perform parts of `tools/ci_build/github/linux/copy_strip_binary.sh` postInstall = '' install -m644 -Dt $out/include \ diff --git a/pkgs/by-name/on/onnxruntime/protobuf34-nodiscard.patch b/pkgs/by-name/on/onnxruntime/protobuf34-nodiscard.patch index 874a819bf06c..9735e6607b21 100644 --- a/pkgs/by-name/on/onnxruntime/protobuf34-nodiscard.patch +++ b/pkgs/by-name/on/onnxruntime/protobuf34-nodiscard.patch @@ -1,8 +1,8 @@ diff --git a/onnxruntime/core/framework/graph_partitioner.cc b/onnxruntime/core/framework/graph_partitioner.cc -index 43caf4766d..fabc2a26a0 100644 +index 9cb2111670..8a3ec5bab9 100644 --- a/onnxruntime/core/framework/graph_partitioner.cc +++ b/onnxruntime/core/framework/graph_partitioner.cc -@@ -957,7 +957,7 @@ +@@ -966,7 +966,7 @@ static Status CreateEpContextModel(const ExecutionProviders& execution_providers AllocatorPtr allocator = output_buffer_holder->buffer_allocator; IAllocatorUniquePtr buffer = IAllocator::MakeUniquePtr(allocator, buffer_size); @@ -11,7 +11,7 @@ index 43caf4766d..fabc2a26a0 100644 *output_buffer_holder->buffer_size_ptr = buffer_size; *output_buffer_holder->buffer_ptr = buffer.release(); -@@ -970,7 +970,7 @@ +@@ -979,7 +979,7 @@ static Status CreateEpContextModel(const ExecutionProviders& execution_providers auto out_stream_buf = std::make_unique(*output_write_func_holder); std::ostream out_stream(out_stream_buf.get()); @@ -21,10 +21,10 @@ index 43caf4766d..fabc2a26a0 100644 ORT_RETURN_IF_ERROR(out_stream_buf->GetStatus()); } else { diff --git a/onnxruntime/python/onnxruntime_pybind_schema.cc b/onnxruntime/python/onnxruntime_pybind_schema.cc -index cd1d2a8da1..05da1a1447 100644 +index 8cb617fe52..254fc1abf9 100644 --- a/onnxruntime/python/onnxruntime_pybind_schema.cc +++ b/onnxruntime/python/onnxruntime_pybind_schema.cc -@@ -169,7 +169,7 @@ +@@ -163,7 +163,7 @@ void addOpSchemaSubmodule(py::module& m) { "_default_value", [](ONNX_NAMESPACE::OpSchema::Attribute* attr) -> py::bytes { std::string out; @@ -34,10 +34,10 @@ index cd1d2a8da1..05da1a1447 100644 }) .def_readonly("required", &ONNX_NAMESPACE::OpSchema::Attribute::required); diff --git a/onnxruntime/test/ep_graph/test_ep_graph.cc b/onnxruntime/test/ep_graph/test_ep_graph.cc -index 7e6d157799..f08b09990d 100644 +index 055b255132..3925db8ac7 100644 --- a/onnxruntime/test/ep_graph/test_ep_graph.cc +++ b/onnxruntime/test/ep_graph/test_ep_graph.cc -@@ -232,7 +232,7 @@ +@@ -261,7 +261,7 @@ TEST(EpGraphTest, SerializeToProto_InputModelHasExternalIni) { handle_initializer_data)); std::ofstream ofs(serialized_model_path, std::ios::binary); @@ -46,7 +46,7 @@ index 7e6d157799..f08b09990d 100644 ofs.flush(); ASSERT_TRUE(std::filesystem::exists(serialized_model_path)); -@@ -357,7 +357,7 @@ +@@ -395,7 +395,7 @@ TEST(EpGraphTest, SerializeToProto_Mnist) { handle_initializer_data)); std::ofstream ofs(serialized_model_path, std::ios::binary); @@ -55,7 +55,7 @@ index 7e6d157799..f08b09990d 100644 ofs.flush(); ASSERT_TRUE(std::filesystem::exists(serialized_model_path)); -@@ -487,7 +487,7 @@ +@@ -525,7 +525,7 @@ TEST(EpGraphTest, SerializeToProto_ConstantOfShape) { handle_initializer_data)); std::ofstream ofs(serialized_model_path, std::ios::binary); @@ -64,7 +64,7 @@ index 7e6d157799..f08b09990d 100644 ofs.flush(); ASSERT_TRUE(std::filesystem::exists(serialized_model_path)); -@@ -552,7 +552,7 @@ +@@ -590,7 +590,7 @@ TEST(EpGraphTest, SerializeToProto_3LayerSubgraphs) { ASSERT_CXX_ORTSTATUS_OK(OrtEpUtils::OrtGraphToProto(test_graph->GetOrtGraph(), model_proto)); std::ofstream ofs(serialized_model_path, std::ios::binary); @@ -73,24 +73,73 @@ index 7e6d157799..f08b09990d 100644 ofs.flush(); ASSERT_TRUE(std::filesystem::exists(serialized_model_path)); -diff --git a/onnxruntime/test/optimizer/graph_transform_test_builder.cc b/onnxruntime/test/optimizer/graph_transform_test_builder.cc -index 756cc4159e..8323851385 100644 ---- a/onnxruntime/test/optimizer/graph_transform_test_builder.cc -+++ b/onnxruntime/test/optimizer/graph_transform_test_builder.cc -@@ -158,7 +158,7 @@ +diff --git a/onnxruntime/test/framework/inference_session_test.cc b/onnxruntime/test/framework/inference_session_test.cc +index 1c4e7800b7..8ceb05f0f6 100644 +--- a/onnxruntime/test/framework/inference_session_test.cc ++++ b/onnxruntime/test/framework/inference_session_test.cc +@@ -1045,7 +1045,7 @@ static void TestBindHelper(const std::string& log_str, + CreateMatMulModel(p_model, run_provider_type); - // Serialize the model to a string. - std::string model_data; -- model.ToProto().SerializeToString(&model_data); -+ ASSERT_TRUE(model.ToProto().SerializeToString(&model_data)); - std::shared_ptr ep_shared = ep ? std::move(ep) : nullptr; + std::string s1; +- p_model->ToProto().SerializeToString(&s1); ++ ASSERT_TRUE(p_model->ToProto().SerializeToString(&s1)); + std::stringstream sstr(s1); + ASSERT_STATUS_OK(session_object.Load(sstr)); + ASSERT_STATUS_OK(session_object.Initialize()); +@@ -1078,7 +1078,7 @@ TEST(InferenceSessionTests, TestIOBindingReuse) { + CreateMatMulModel(p_model, kCpuExecutionProvider); - auto run_model = [&](TransformerLevel level, std::vector& fetches, + std::string s1; +- p_model->ToProto().SerializeToString(&s1); ++ ASSERT_TRUE(p_model->ToProto().SerializeToString(&s1)); + std::stringstream sstr(s1); + ASSERT_TRUE(session_object.Load(sstr).IsOK()); + ASSERT_STATUS_OK(session_object.Initialize()); +diff --git a/onnxruntime/test/ir/graph_test.cc b/onnxruntime/test/ir/graph_test.cc +index 4d80cb7047..c69ac46c05 100644 +--- a/onnxruntime/test/ir/graph_test.cc ++++ b/onnxruntime/test/ir/graph_test.cc +@@ -1244,7 +1244,7 @@ TEST_F(GraphTest, GraphConstruction_CheckGraphInputOutputOrderMaintained) { + auto proto = model.ToProto(); + std::string s1; + // std::stringstream s1; +- model.ToProto().SerializeToString(&s1); ++ ASSERT_TRUE(model.ToProto().SerializeToString(&s1)); + + ModelProto model_proto; + // const bool result = model_proto.ParseFromIstream(&s1); +@@ -1313,7 +1313,7 @@ TEST_F(GraphTest, UnusedInitializerAndNodeArgsAreIgnored) { + auto proto = model.ToProto(); + std::string s1; + // std::stringstream s1; +- model.ToProto().SerializeToString(&s1); ++ ASSERT_TRUE(model.ToProto().SerializeToString(&s1)); + + ModelProto model_proto; + const bool result = model_proto.ParseFromString(s1); +@@ -1342,7 +1342,7 @@ TEST_F(GraphTest, UnusedSparseInitializerIsIgnored) { + ConstructASimpleAddGraph(*m_graph, nullptr); + auto* m_sparse_initializer = m_graph->add_sparse_initializer(); + ConstructSparseTensor("unused_sparse_initializer", *m_sparse_initializer); +- model_proto.SerializeToString(&s1); ++ ASSERT_TRUE(model_proto.SerializeToString(&s1)); + } + + ModelProto model_proto_1; +@@ -1940,7 +1940,7 @@ TEST_F(GraphTest, SparseInitializerHandling) { + ConstructASimpleAddGraph(*m_graph, nullptr); + auto* m_sparse_initializer = m_graph->add_sparse_initializer(); + ConstructSparseTensor(input_initializer_name, *m_sparse_initializer); +- model_proto.SerializeToString(&s1); ++ ASSERT_TRUE(model_proto.SerializeToString(&s1)); + } + + ModelProto model_proto_sparse; diff --git a/onnxruntime/test/optimizer/nchwc_optimizer_test.cc b/onnxruntime/test/optimizer/nchwc_optimizer_test.cc -index 538f600404..111692d4ca 100644 +index fc0ba86c7f..b086040212 100644 --- a/onnxruntime/test/optimizer/nchwc_optimizer_test.cc +++ b/onnxruntime/test/optimizer/nchwc_optimizer_test.cc -@@ -185,7 +185,7 @@ +@@ -185,7 +185,7 @@ void NchwcOptimizerTester(const std::function& bu // Serialize the model to a string. std::string model_data; @@ -99,3 +148,56 @@ index 538f600404..111692d4ca 100644 auto run_model = [&](TransformerLevel level, std::vector& fetches) { SessionOptions session_options; +diff --git a/onnxruntime/test/providers/compare_provider_test_utils.cc b/onnxruntime/test/providers/compare_provider_test_utils.cc +index 6312014387..578d72cb09 100644 +--- a/onnxruntime/test/providers/compare_provider_test_utils.cc ++++ b/onnxruntime/test/providers/compare_provider_test_utils.cc +@@ -83,7 +83,7 @@ void CompareOpTester::CompareWithCPU(const std::string& target_provider_type, + + // first run with cpu + std::string s1; +- model.ToProto().SerializeToString(&s1); ++ ASSERT_TRUE(model.ToProto().SerializeToString(&s1)); + std::istringstream model_proto_str(s1); + + ASSERT_STATUS_OK(cpu_session_object.Load(model_proto_str)); +@@ -104,7 +104,7 @@ void CompareOpTester::CompareWithCPU(const std::string& target_provider_type, + ASSERT_STATUS_OK(target_session_object.RegisterExecutionProvider(std::move(target_execution_provider))); + + std::string s2; +- tp_model.ToProto().SerializeToString(&s2); ++ ASSERT_TRUE(tp_model.ToProto().SerializeToString(&s2)); + std::istringstream model_proto_str1(s2); + ASSERT_STATUS_OK(target_session_object.Load(model_proto_str1)); + +@@ -159,7 +159,7 @@ void CompareOpTester::CompareEPs(const std::shared_ptr& sour + + // first run with source provider + std::string s1; +- model.ToProto().SerializeToString(&s1); ++ ASSERT_TRUE(model.ToProto().SerializeToString(&s1)); + std::istringstream model_proto_str(s1); + + ASSERT_STATUS_OK(source_session_object.Load(model_proto_str)); +@@ -181,7 +181,7 @@ void CompareOpTester::CompareEPs(const std::shared_ptr& sour + ASSERT_STATUS_OK(target_session_object.RegisterExecutionProvider(target_execution_provider)); + + std::string s2; +- tp_model.ToProto().SerializeToString(&s2); ++ ASSERT_TRUE(tp_model.ToProto().SerializeToString(&s2)); + std::istringstream model_proto_str1(s2); + ASSERT_STATUS_OK(target_session_object.Load(model_proto_str1)); + +diff --git a/onnxruntime/test/unittest_util/graph_transform_test_builder.cc b/onnxruntime/test/unittest_util/graph_transform_test_builder.cc +index 5caafa0f37..327463c615 100644 +--- a/onnxruntime/test/unittest_util/graph_transform_test_builder.cc ++++ b/onnxruntime/test/unittest_util/graph_transform_test_builder.cc +@@ -158,7 +158,7 @@ void TransformerTester(const std::function& buil + + // Serialize the model to a string. + std::string model_data; +- model.ToProto().SerializeToString(&model_data); ++ ASSERT_TRUE(model.ToProto().SerializeToString(&model_data)); + std::shared_ptr ep_shared = ep ? std::move(ep) : nullptr; + + auto run_model = [&](TransformerLevel level, std::vector& fetches, diff --git a/pkgs/by-name/on/onnxruntime/remove-MATH_NO_EXCEPT-macro.patch b/pkgs/by-name/on/onnxruntime/remove-MATH_NO_EXCEPT-macro.patch new file mode 100644 index 000000000000..c10f49929731 --- /dev/null +++ b/pkgs/by-name/on/onnxruntime/remove-MATH_NO_EXCEPT-macro.patch @@ -0,0 +1,37 @@ +diff --git a/onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc b/onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc +index 3fb8cc3e15..ccc9bd543e 100644 +--- a/onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc ++++ b/onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc +@@ -3797,13 +3797,7 @@ TEST(MathOpTest, Mean_8) { + test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider}); // TensorRT: Input batch size is inconsistent + } + +-#ifdef _LIBCPP_VERSION +-#define MATH_NO_EXCEPT +-#else +-#define MATH_NO_EXCEPT noexcept +-#endif +- +-template ++template + void TrigFloatTest(OpTester& test, std::initializer_list input, float abs_error = -1.0f) { + std::vector dims{static_cast(input.size())}; + +@@ -3821,7 +3815,7 @@ void TrigFloatTest(OpTester& test, std::initializer_list input, float abs + test.Run(); + } + +-template ++template + void TrigDoubleTest(OpTester& test, std::initializer_list input, + const std::unordered_set excluded_provider_types = {}) { + std::vector dims{static_cast(input.size())}; +@@ -3835,7 +3829,7 @@ void TrigDoubleTest(OpTester& test, std::initializer_list input, + test.Run(OpTester::ExpectResult::kExpectSuccess, "", excluded_provider_types); + } + +-template ++template + void TrigFloat16Test(OpTester& test, std::initializer_list input) { + std::vector dims{static_cast(input.size())}; +