Skip to content

Commit

Permalink
[onnxruntime] Update to 1.18.0 (#215)
Browse files Browse the repository at this point in the history
* [onnxruntime] update to 1.18.0

* remove existing features to rework

* [onnxruntime] OFF the DISABLE_ABSEIL

* [onnxruntime] use onnx without static registration

* ci: resurrect onnxruntime test

* [onnx] change protoc search, pb.h generation

* [onnxruntime] source patch for DISABLE_ABSEIL

* ci: try onnxruntime[test]

* run flatc for test schema
* use FULL_PROTOBUF option for tml.proto
* update baseline

* [onnxruntime] fixing test targets' build

* ci: change port test commands

* [onnxruntime] relocate onnx_test_runner
  • Loading branch information
luncliff authored Jun 29, 2024
1 parent d8758ae commit 18e264d
Show file tree
Hide file tree
Showing 16 changed files with 239 additions and 554 deletions.
1 change: 1 addition & 0 deletions .circleci/port-linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ grpc[codegen]
flatbuffers
abseil
liblzma
onnxruntime
1 change: 1 addition & 0 deletions .circleci/port-windows.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
onnxruntime
openssl3[tools]:x64-windows
6 changes: 5 additions & 1 deletion ports/onnx/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ else()
set(USE_PROTOBUF_SHARED OFF)
endif()

find_program(PROTOC NAMES protoc PATHS "${CURRENT_HOST_INSTALLED_DIR}/tools/protobuf" REQUIRED)
find_program(PROTOC NAMES protoc
PATHS "${CURRENT_HOST_INSTALLED_DIR}/tools/protobuf"
REQUIRED NO_DEFAULT_PATH NO_CMAKE_PATH
)
message(STATUS "Using protoc: ${PROTOC}")

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
Expand Down Expand Up @@ -65,6 +68,7 @@ vcpkg_cmake_configure(
-DPYTHON_EXECUTABLE:FILEPATH=${PYTHON3}
-DProtobuf_PROTOC_EXECUTABLE=${PROTOC}
-DONNX_CUSTOM_PROTOC_EXECUTABLE=${PROTOC}
-DONNX_VERIFY_PROTO3=ON # --protoc_path for gen_proto.py
-DONNX_ML=ON
-DONNX_GEN_PB_TYPE_STUBS=ON
-DONNX_USE_PROTOBUF_SHARED_LIBS=${USE_PROTOBUF_SHARED}
Expand Down
2 changes: 1 addition & 1 deletion ports/onnx/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "onnx",
"version-semver": "1.16.0",
"port-version": 1,
"port-version": 2,
"description": "Open standard for machine learning interoperability",
"homepage": "https://onnx.ai",
"license": "Apache-2.0",
Expand Down
277 changes: 80 additions & 197 deletions ports/onnxruntime/fix-cmake.patch

Large diffs are not rendered by default.

78 changes: 26 additions & 52 deletions ports/onnxruntime/fix-sources.patch
Original file line number Diff line number Diff line change
@@ -1,52 +1,26 @@
diff --git a/onnxruntime/core/framework/kernel_type_str_resolver_utils.h b/onnxruntime/core/framework/kernel_type_str_resolver_utils.h
index 3d06013..4121534 100644
--- a/onnxruntime/core/framework/kernel_type_str_resolver_utils.h
+++ b/onnxruntime/core/framework/kernel_type_str_resolver_utils.h
@@ -10,9 +10,7 @@
#include "core/framework/kernel_type_str_resolver.h"
#include "core/graph/op_identifier.h"

-namespace flatbuffers {
-class DetachedBuffer;
-}
+#include <flatbuffers/flatbuffers.h>

namespace onnxruntime::kernel_type_str_resolver_utils {

diff --git a/onnxruntime/core/optimizer/compute_optimizer/upstream_gather_actors.h b/onnxruntime/core/optimizer/compute_optimizer/upstream_gather_actors.h
index 0c21be1..3ee6061 100644
--- a/onnxruntime/core/optimizer/compute_optimizer/upstream_gather_actors.h
+++ b/onnxruntime/core/optimizer/compute_optimizer/upstream_gather_actors.h
@@ -5,6 +5,8 @@
// while so far we mainly validate training during cooking the optimization.
#ifdef ENABLE_TRAINING
#pragma once
+#include <variant>
+#include <unordered_map>

#include "core/optimizer/compute_optimizer/shared_utils.h"

diff --git a/onnxruntime/core/optimizer/compute_optimizer/upstream_transformer_base.h b/onnxruntime/core/optimizer/compute_optimizer/upstream_transformer_base.h
index 6e22fc7..79c8ac1 100644
--- a/onnxruntime/core/optimizer/compute_optimizer/upstream_transformer_base.h
+++ b/onnxruntime/core/optimizer/compute_optimizer/upstream_transformer_base.h
@@ -15,6 +15,7 @@
#include <memory>
#include <string>
#include <vector>
+#include <deque>

namespace onnxruntime::optimizer::compute_optimizer {

diff --git a/orttraining/orttraining/core/optimizer/memory_optimizer/transformer_specific.cc b/orttraining/orttraining/core/optimizer/memory_optimizer/transformer_specific.cc
index 04f2679..9c4de02 100644
--- a/orttraining/orttraining/core/optimizer/memory_optimizer/transformer_specific.cc
+++ b/orttraining/orttraining/core/optimizer/memory_optimizer/transformer_specific.cc
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

+#include <deque>
#include <charconv>
#include <vector>
#include <utility>
diff --git a/onnxruntime/core/framework/kernel_type_str_resolver.cc b/onnxruntime/core/framework/kernel_type_str_resolver.cc
index d05e02e..6f8a47c 100644
--- a/onnxruntime/core/framework/kernel_type_str_resolver.cc
+++ b/onnxruntime/core/framework/kernel_type_str_resolver.cc
@@ -50,7 +50,7 @@ Status KernelTypeStrResolver::ResolveKernelTypeStr(const Node& node, std::string
// TODO(edgchen1) maybe we can use transparent hash/eq to enable lookup with string_view
const auto type_str_it = type_str_map.find(std::string(kernel_type_str));
#else
- const auto type_str_it = type_str_map.find(kernel_type_str);
+ const auto type_str_it = type_str_map.find(std::string(kernel_type_str));
#endif

ORT_RETURN_IF(type_str_it == type_str_map.end(),
diff --git a/onnxruntime/core/framework/ort_value_name_idx_map.h b/onnxruntime/core/framework/ort_value_name_idx_map.h
index 1b5f6bc..b721205 100644
--- a/onnxruntime/core/framework/ort_value_name_idx_map.h
+++ b/onnxruntime/core/framework/ort_value_name_idx_map.h
@@ -36,7 +36,7 @@ class OrtValueNameIdxMap {
#ifdef DISABLE_ABSEIL
auto it = map_.find(std::string(name));
#else
- auto it = map_.find(name);
+ auto it = map_.find(std::string(name));
#endif
if (it == map_.end()) {
return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "Could not find OrtValue with name '", name, "'");
169 changes: 0 additions & 169 deletions ports/onnxruntime/fix-xnnpack.patch

This file was deleted.

42 changes: 40 additions & 2 deletions ports/onnxruntime/onnxruntime_vcpkg_deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,30 @@ message(STATUS "Using Dependencies from vcpkg...")

# ABSL should be included before protobuf because protobuf may use absl
find_package(absl CONFIG REQUIRED)
list(APPEND onnxruntime_EXTERNAL_LIBRARIES absl::base)
list(APPEND ABSEIL_LIBS
absl::base
absl::city
absl::core_headers
absl::fixed_array
absl::flags
absl::flat_hash_map
absl::flat_hash_set
absl::hash
absl::inlined_vector
absl::low_level_hash
absl::node_hash_map
absl::node_hash_set
absl::optional
absl::raw_hash_set
absl::raw_logging_internal
absl::span
absl::str_format
absl::strings
absl::synchronization
absl::throw_delegate
absl::time
)
list(APPEND onnxruntime_EXTERNAL_LIBRARIES ${ABSEIL_LIBS})

find_package(re2 CONFIG REQUIRED) # re2::re2
list(APPEND onnxruntime_EXTERNAL_LIBRARIES re2::re2)
Expand Down Expand Up @@ -53,24 +76,39 @@ if (onnxruntime_ENABLE_CPUINFO)
endif()

if (NOT WIN32)
find_package(nsync CONFIG REQUIRED)
find_library(NSYNC_CPP_LIBRARY NAMES nsync_cpp REQUIRED)
add_library(nsync_cpp INTERFACE IMPORTED GLOBAL)
set_target_properties(nsync_cpp PROPERTIES INTERFACE_LINK_LIBRARIES "${NSYNC_CPP_LIBRARY}")
add_library(nsync::nsync_cpp ALIAS nsync_cpp)
list(APPEND onnxruntime_EXTERNAL_LIBRARIES nsync::nsync_cpp)
endif()

find_package(Microsoft.GSL CONFIG REQUIRED)
list(APPEND onnxruntime_EXTERNAL_LIBRARIES Microsoft.GSL::GSL)
set(GSL_TARGET Microsoft.GSL::GSL) # see onnxruntime_mlas

# ONNX
find_package(ONNX CONFIG REQUIRED)
if(TARGET ONNX::onnx AND NOT TARGET onnx)
add_library(onnx ALIAS ONNX::onnx)
endif()
if(TARGET ONNX::onnx_proto AND NOT TARGET onnx_proto)
add_library(onnx_proto ALIAS ONNX::onnx_proto)
endif()
list(APPEND onnxruntime_EXTERNAL_LIBRARIES onnx onnx_proto)

find_package(Eigen3 CONFIG REQUIRED)
list(APPEND onnxruntime_EXTERNAL_LIBRARIES Eigen3::Eigen)
get_property(eigen_INCLUDE_DIRS TARGET Eigen3::Eigen PROPERTY INTERFACE_INCLUDE_DIRECTORIES)

find_package(wil CONFIG REQUIRED)
list(APPEND onnxruntime_EXTERNAL_LIBRARIES WIL::WIL)

find_path(SAFEINT_INCLUDE_DIRS "SafeInt.hpp" REQUIRED)
add_library(safeint_interface IMPORTED INTERFACE GLOBAL)
set_target_properties(safeint_interface PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SAFEINT_INCLUDE_DIRS}"
)

# XNNPACK EP
if (onnxruntime_USE_XNNPACK)
Expand Down
Loading

0 comments on commit 18e264d

Please sign in to comment.