From 514cad5ab75c46ed33923fa96b9b4351a38ee12c Mon Sep 17 00:00:00 2001
From: madurais <root@telesto10.in.ibm.com>
Date: Mon, 17 Apr 2023 04:19:01 -0500
Subject: [PATCH 3/7] merged changes to 1.14 release

---
 cmake/onnxruntime.cmake                |  89 ++++++++++++-----
 cmake/onnxruntime_common.cmake         |   2 +-
 cmake/onnxruntime_framework.cmake      |   2 +-
 cmake/onnxruntime_mlas.cmake           |  10 +-
 cmake/onnxruntime_providers.cmake      |   2 +
 cmake/onnxruntime_python.cmake         |   9 +-
 cmake/onnxruntime_unittests.cmake      | 132 +++++++++++++++++++------
 include/onnxruntime/core/graph/graph.h |   1 +
 8 files changed, 185 insertions(+), 62 deletions(-)

diff --git a/cmake/onnxruntime.cmake b/cmake/onnxruntime.cmake
index 307a0f569..88557f06d 100644
--- a/cmake/onnxruntime.cmake
+++ b/cmake/onnxruntime.cmake
@@ -110,6 +110,8 @@ target_compile_definitions(onnxruntime PRIVATE FILE_NAME=\"onnxruntime.dll\")
 if(UNIX)
   if (APPLE)
     set(ONNXRUNTIME_SO_LINK_FLAG " -Xlinker -dead_strip")
+  elseif(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+    set(ONNXRUNTIME_SO_LINK_FLAG " -Xlinker -bE:${SYMBOL_FILE}")
   else()
     set(ONNXRUNTIME_SO_LINK_FLAG " -Xlinker --version-script=${SYMBOL_FILE} -Xlinker --no-undefined -Xlinker --gc-sections -z noexecstack")
   endif()
@@ -130,6 +132,8 @@ if (NOT WIN32)
     else()
         set_target_properties(onnxruntime PROPERTIES INSTALL_RPATH "@loader_path")
     endif()
+  elseif (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-L${ORIGIN}")
   elseif (NOT onnxruntime_BUILD_WEBASSEMBLY)
     set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-rpath='$ORIGIN'")
   endif()
@@ -170,33 +174,64 @@ endif()
 
 # This list is a reversed topological ordering of library dependencies.
 # Earlier entries may depend on later ones. Later ones should not depend on earlier ones.
-set(onnxruntime_INTERNAL_LIBRARIES
-  onnxruntime_session
-  ${onnxruntime_libs}
-  ${PROVIDERS_ACL}
-  ${PROVIDERS_ARMNN}
-  ${PROVIDERS_COREML}
-  ${PROVIDERS_DML}
-  ${PROVIDERS_NNAPI}
-  ${PROVIDERS_SNPE}
-  ${PROVIDERS_TVM}
-  ${PROVIDERS_RKNPU}
-  ${PROVIDERS_ROCM}
-  ${PROVIDERS_VITISAI}
-  ${PROVIDERS_XNNPACK}
-  ${PROVIDERS_AZURE}
-  ${PROVIDERS_INTERNAL_TESTING}
-  ${onnxruntime_winml}
-  onnxruntime_optimizer
-  onnxruntime_providers
-  ${onnxruntime_tvm_libs}
-  onnxruntime_framework
-  onnxruntime_graph
-  onnxruntime_util
-  ${ONNXRUNTIME_MLAS_LIBS}
-  onnxruntime_common
-  onnxruntime_flatbuffers
-)
+if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+  set(onnxruntime_INTERNAL_LIBRARIES
+    onnxruntime_session
+    ${onnxruntime_libs}
+    ${PROVIDERS_ACL}
+    ${PROVIDERS_ARMNN}
+    ${PROVIDERS_COREML}
+    ${PROVIDERS_DML}
+    ${PROVIDERS_NNAPI}
+    ${PROVIDERS_SNPE}
+    ${PROVIDERS_TVM}
+    ${PROVIDERS_RKNPU}
+    ${PROVIDERS_ROCM}
+    ${PROVIDERS_VITISAI}
+    ${PROVIDERS_XNNPACK}
+    ${PROVIDERS_AZURE}
+    ${PROVIDERS_INTERNAL_TESTING}
+    ${onnxruntime_winml}
+    onnxruntime_optimizer
+    onnxruntime_providers
+    ${onnxruntime_tvm_libs}
+    onnxruntime_framework
+    onnxruntime_graph
+    onnxruntime_util
+    ${ONNXRUNTIME_MLAS_LIBS}
+    onnxruntime_common
+    onnxruntime_flatbuffers
+    iconv
+  )
+else()
+  set(onnxruntime_INTERNAL_LIBRARIES
+    onnxruntime_session
+    ${onnxruntime_libs}
+    ${PROVIDERS_ACL}
+    ${PROVIDERS_ARMNN}
+    ${PROVIDERS_COREML}
+    ${PROVIDERS_DML}
+    ${PROVIDERS_NNAPI}
+    ${PROVIDERS_SNPE}
+    ${PROVIDERS_TVM}
+    ${PROVIDERS_RKNPU}
+    ${PROVIDERS_ROCM}
+    ${PROVIDERS_VITISAI}
+    ${PROVIDERS_XNNPACK}
+    ${PROVIDERS_AZURE}
+    ${PROVIDERS_INTERNAL_TESTING}
+    ${onnxruntime_winml}
+    onnxruntime_optimizer
+    onnxruntime_providers
+    ${onnxruntime_tvm_libs}
+    onnxruntime_framework
+    onnxruntime_graph
+    onnxruntime_util
+    ${ONNXRUNTIME_MLAS_LIBS}
+    onnxruntime_common
+    onnxruntime_flatbuffers
+  )
+endif()
 
 if (onnxruntime_ENABLE_LANGUAGE_INTEROP_OPS)
   list(APPEND onnxruntime_INTERNAL_LIBRARIES
diff --git a/cmake/onnxruntime_common.cmake b/cmake/onnxruntime_common.cmake
index 0e02ad9da..5aabf6eee 100644
--- a/cmake/onnxruntime_common.cmake
+++ b/cmake/onnxruntime_common.cmake
@@ -115,7 +115,7 @@ target_include_directories(onnxruntime_common
         ${OPTIONAL_LITE_INCLUDE_DIR})
 
 
-target_link_libraries(onnxruntime_common PUBLIC safeint_interface ${GSL_TARGET} ${ABSEIL_LIBS})
+target_link_libraries(onnxruntime_common PUBLIC Boost::mp11 safeint_interface ${GSL_TARGET} ${ABSEIL_LIBS})
 
 add_dependencies(onnxruntime_common ${onnxruntime_EXTERNAL_DEPENDENCIES})
 
diff --git a/cmake/onnxruntime_framework.cmake b/cmake/onnxruntime_framework.cmake
index 6a33100d2..122c3fc77 100644
--- a/cmake/onnxruntime_framework.cmake
+++ b/cmake/onnxruntime_framework.cmake
@@ -103,7 +103,7 @@ add_dependencies(onnxruntime_framework ${onnxruntime_EXTERNAL_DEPENDENCIES})
 # For the shared onnxruntime library, this is set in onnxruntime.cmake through CMAKE_SHARED_LINKER_FLAGS
 # But our test files don't use the shared library so this must be set for them.
 # For Win32 it generates an absolute path for shared providers based on the location of the executable/onnxruntime.dll
-if (UNIX AND NOT APPLE AND NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_BUILD_WEBASSEMBLY)
+if (UNIX AND NOT APPLE AND NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_BUILD_WEBASSEMBLY AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
   set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath='$ORIGIN'")
 endif()
 
diff --git a/cmake/onnxruntime_mlas.cmake b/cmake/onnxruntime_mlas.cmake
index 1f9b71299..0218bf070 100644
--- a/cmake/onnxruntime_mlas.cmake
+++ b/cmake/onnxruntime_mlas.cmake
@@ -359,12 +359,20 @@ else()
           )
           if(COMPILES_P10)
             check_cxx_source_compiles("
+              #ifdef _AIX
+              #include <sys/systemcfg.h>
+              int main() {
+                bool HasP10 = (__power_10_andup() && __power_mma_version() == MMA_V31);
+                return 0;
+              }
+              #else
               #include <sys/auxv.h>
               int main() {
                 unsigned long hwcap2 = getauxval(AT_HWCAP2);
                 bool HasP10 = ((hwcap2 & PPC_FEATURE2_MMA) && (hwcap2 & PPC_FEATURE2_ARCH_3_1));
                 return 0;
-              }"
+              }
+              #endif"
               HAS_P10_RUNTIME
             )
             if (HAS_P10_RUNTIME)
diff --git a/cmake/onnxruntime_providers.cmake b/cmake/onnxruntime_providers.cmake
index ca6d12291..6ee83a15b 100644
--- a/cmake/onnxruntime_providers.cmake
+++ b/cmake/onnxruntime_providers.cmake
@@ -336,6 +336,8 @@ if (NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD
 
   if(APPLE)
   set_property(TARGET onnxruntime_providers_shared APPEND_STRING PROPERTY LINK_FLAGS "-Xlinker -exported_symbols_list ${ONNXRUNTIME_ROOT}/core/providers/shared/exported_symbols.lst")
+  elseif(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+  set_property(TARGET onnxruntime_providers_shared APPEND_STRING PROPERTY LINK_FLAGS "-Xlinker -bE:${ONNXRUNTIME_ROOT}/core/providers/shared/symbols.exp")
   elseif(UNIX)
   set_property(TARGET onnxruntime_providers_shared APPEND_STRING PROPERTY LINK_FLAGS "-Xlinker --version-script=${ONNXRUNTIME_ROOT}/core/providers/shared/version_script.lds -Xlinker --gc-sections")
   elseif(WIN32)
diff --git a/cmake/onnxruntime_python.cmake b/cmake/onnxruntime_python.cmake
index c24b6b9be..177dbc72a 100644
--- a/cmake/onnxruntime_python.cmake
+++ b/cmake/onnxruntime_python.cmake
@@ -128,9 +128,9 @@ if(APPLE)
   set(ONNXRUNTIME_SO_LINK_FLAG "-Xlinker -exported_symbols_list ${ONNXRUNTIME_ROOT}/python/exported_symbols.lst")
 elseif(UNIX)
   if (onnxruntime_ENABLE_EXTERNAL_CUSTOM_OP_SCHEMAS)
-    set(ONNXRUNTIME_SO_LINK_FLAG "-Xlinker --version-script=${ONNXRUNTIME_ROOT}/python/version_script_expose_onnx_protobuf.lds -Xlinker --gc-sections")
+    #set(ONNXRUNTIME_SO_LINK_FLAG "-Xlinker --version-script=${ONNXRUNTIME_ROOT}/python/version_script_expose_onnx_protobuf.lds -Xlinker --gc-sections")
   else()
-    set(ONNXRUNTIME_SO_LINK_FLAG "-Xlinker --version-script=${ONNXRUNTIME_ROOT}/python/version_script.lds -Xlinker --gc-sections")
+    #set(ONNXRUNTIME_SO_LINK_FLAG "-Xlinker --version-script=${ONNXRUNTIME_ROOT}/python/version_script.lds -Xlinker --gc-sections")
   endif()
 else()
   set(ONNXRUNTIME_SO_LINK_FLAG "-DEF:${ONNXRUNTIME_ROOT}/python/pybind.def")
@@ -143,6 +143,7 @@ endif()
 
 if (onnxruntime_ENABLE_TRAINING)
   target_include_directories(onnxruntime_pybind11_state PRIVATE ${ORTTRAINING_ROOT})
+  target_include_directories(onnxruntime_pybind11_state PRIVATE ${PROJECT_SOURCE_DIR}/external/dlpack/include)
   target_link_libraries(onnxruntime_pybind11_state PRIVATE onnxruntime_training)
 endif()
 
@@ -223,6 +224,8 @@ target_link_libraries(onnxruntime_pybind11_state PRIVATE
     onnxruntime_common
     onnxruntime_flatbuffers
     ${pybind11_lib}
+    iconv
+    python3.7m
 )
 
 if (onnxruntime_ENABLE_LANGUAGE_INTEROP_OPS)
@@ -260,7 +263,7 @@ elseif (APPLE)
     BUILD_WITH_INSTALL_RPATH TRUE
     INSTALL_RPATH_USE_LINK_PATH FALSE)
 else()
-  set_property(TARGET onnxruntime_pybind11_state APPEND_STRING PROPERTY LINK_FLAGS " -Xlinker -rpath=\\$ORIGIN")
+  #set_property(TARGET onnxruntime_pybind11_state APPEND_STRING PROPERTY LINK_FLAGS " -Xlinker -rpath=\\$ORIGIN")
 endif()
 
 if (onnxruntime_ENABLE_EXTERNAL_CUSTOM_OP_SCHEMAS)
diff --git a/cmake/onnxruntime_unittests.cmake b/cmake/onnxruntime_unittests.cmake
index 00c017298..95111000f 100644
--- a/cmake/onnxruntime_unittests.cmake
+++ b/cmake/onnxruntime_unittests.cmake
@@ -13,6 +13,10 @@ if (onnxruntime_USE_TVM)
   list(APPEND TEST_INC_DIR ${TVM_INCLUDES})
 endif()
 
+if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+  list(APPEND TEST_INC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/onnx")
+endif()
+
 set(disabled_warnings)
 function(AddTest)
   cmake_parse_arguments(_UT "DYN" "TARGET" "LIBS;SOURCES;DEPENDS;TEST_ARGS" ${ARGN})
@@ -98,6 +102,9 @@ function(AddTest)
     target_compile_options(${_UT_TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:-Xcompiler -Wno-error=sign-compare>"
             "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:-Wno-error=sign-compare>")
     target_compile_options(${_UT_TARGET} PRIVATE "-Wno-error=uninitialized")
+    if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+      target_compile_options(${_UT_TARGET} PRIVATE "-Wno-error") 
+    endif()
   endif()
 
   set(TEST_ARGS ${_UT_TEST_ARGS})
@@ -512,32 +519,63 @@ if (onnxruntime_ENABLE_LANGUAGE_INTEROP_OPS)
   set(ONNXRUNTIME_INTEROP_TEST_LIBS PRIVATE onnxruntime_language_interop onnxruntime_pyop)
 endif()
 
-set(ONNXRUNTIME_TEST_LIBS
-    onnxruntime_session
-    ${ONNXRUNTIME_INTEROP_TEST_LIBS}
-    ${onnxruntime_libs}
-    # CUDA, ROCM, TENSORRT, MIGRAPHX, DNNL, and OpenVINO are dynamically loaded at runtime
-    ${PROVIDERS_NNAPI}
-    ${PROVIDERS_SNPE}
-    ${PROVIDERS_RKNPU}
-    ${PROVIDERS_DML}
-    ${PROVIDERS_ACL}
-    ${PROVIDERS_ARMNN}
-    ${PROVIDERS_COREML}
-    # ${PROVIDERS_TVM}
-    ${PROVIDERS_XNNPACK}
-    ${PROVIDERS_AZURE}
-    onnxruntime_optimizer
-    onnxruntime_providers
-    onnxruntime_util
-    ${onnxruntime_tvm_libs}
-    onnxruntime_framework
-    onnxruntime_util
-    onnxruntime_graph
-    ${ONNXRUNTIME_MLAS_LIBS}
-    onnxruntime_common
-    onnxruntime_flatbuffers
-)
+if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+  set(ONNXRUNTIME_TEST_LIBS
+      onnxruntime_session
+      ${ONNXRUNTIME_INTEROP_TEST_LIBS}
+      ${onnxruntime_libs}
+      # CUDA, ROCM, TENSORRT, MIGRAPHX, DNNL, and OpenVINO are dynamically loaded at runtime
+      ${PROVIDERS_NNAPI}
+      ${PROVIDERS_SNPE}
+      ${PROVIDERS_RKNPU}
+      ${PROVIDERS_DML}
+      ${PROVIDERS_ACL}
+      ${PROVIDERS_ARMNN}
+      ${PROVIDERS_COREML}
+      # ${PROVIDERS_TVM}
+      ${PROVIDERS_XNNPACK}
+      ${PROVIDERS_AZURE}
+      onnxruntime_optimizer
+      onnxruntime_providers
+      onnxruntime_util
+      ${onnxruntime_tvm_libs}
+      onnxruntime_framework
+      onnxruntime_util
+      onnxruntime_graph
+      ${ONNXRUNTIME_MLAS_LIBS}
+      onnxruntime_common
+      onnxruntime_flatbuffers
+      iconv
+      gtest
+  )
+else()
+  set(ONNXRUNTIME_TEST_LIBS
+      onnxruntime_session
+      ${ONNXRUNTIME_INTEROP_TEST_LIBS}
+      ${onnxruntime_libs}
+      # CUDA, ROCM, TENSORRT, MIGRAPHX, DNNL, and OpenVINO are dynamically loaded at runtime
+      ${PROVIDERS_NNAPI}
+      ${PROVIDERS_SNPE}
+      ${PROVIDERS_RKNPU}
+      ${PROVIDERS_DML}
+      ${PROVIDERS_ACL}
+      ${PROVIDERS_ARMNN}
+      ${PROVIDERS_COREML}
+      # ${PROVIDERS_TVM}
+      ${PROVIDERS_XNNPACK}
+      ${PROVIDERS_AZURE}
+      onnxruntime_optimizer
+      onnxruntime_providers
+      onnxruntime_util
+      ${onnxruntime_tvm_libs}
+      onnxruntime_framework
+      onnxruntime_util
+      onnxruntime_graph
+      ${ONNXRUNTIME_MLAS_LIBS}
+      onnxruntime_common
+      onnxruntime_flatbuffers
+  )
+endif()
 
 if (onnxruntime_ENABLE_TRAINING)
   set(ONNXRUNTIME_TEST_LIBS onnxruntime_training_runner onnxruntime_training ${ONNXRUNTIME_TEST_LIBS})
@@ -773,6 +811,14 @@ if (MSVC AND onnxruntime_ENABLE_STATIC_ANALYSIS)
 target_compile_options(onnxruntime_test_all PRIVATE  "/analyze:stacksize 131072")
 endif()
 
+if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+  target_link_options(onnxruntime_test_all PRIVATE "-Wl,-bkeepfile:CMakeFiles/onnxruntime_test_all.dir${TEST_SRC_DIR}/common/logging/logging_test.cc.o")
+  target_link_options(onnxruntime_test_all PRIVATE "-Wl,-bkeepfile:CMakeFiles/onnxruntime_test_all.dir${TEST_SRC_DIR}/common/logging/sinks_test.cc.o")
+  target_link_options(onnxruntime_test_all PRIVATE "-Wl,-bkeepfile:CMakeFiles/onnxruntime_test_all.dir${TEST_SRC_DIR}/quantization/quantization_test.cc.o")
+  target_link_options(onnxruntime_test_all PRIVATE "-Wl,-bkeepfile:CMakeFiles/onnxruntime_test_all.dir${TEST_SRC_DIR}/framework/tensor_test.cc.o")
+  target_link_options(onnxruntime_test_all PRIVATE "-Wl,-bkeepfile:CMakeFiles/onnxruntime_test_all.dir${TEST_SRC_DIR}/framework/bfc_arena_test.cc.o")
+endif()
+
 # the default logger tests conflict with the need to have an overall default logger
 # so skip in this type of
 target_compile_definitions(onnxruntime_test_all PUBLIC -DSKIP_DEFAULT_LOGGER_TESTS)
@@ -936,6 +982,10 @@ if (onnxruntime_USE_TVM)
   endif()
 endif()
 
+if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+   target_link_options(onnx_test_runner PRIVATE "-Wl,-berok")
+endif()
+
 install(TARGETS onnx_test_runner
         ARCHIVE  DESTINATION ${CMAKE_INSTALL_LIBDIR}
         LIBRARY  DESTINATION ${CMAKE_INSTALL_LIBDIR}
@@ -1104,6 +1154,10 @@ if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
     )
   endif()
 
+  if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+     target_link_options(onnxruntime_perf_test PRIVATE "-Wl,-berok")
+  endif()
+
   if (onnxruntime_BUILD_SHARED_LIB)
     #It will dynamically link to onnxruntime. So please don't add onxruntime_graph/onxruntime_framework/... here.
     #onnxruntime_common is kind of ok because it is thin, tiny and totally stateless.
@@ -1168,6 +1222,10 @@ if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
     if (CMAKE_SYSTEM_NAME STREQUAL "Android")
       list(APPEND onnxruntime_shared_lib_test_LIBS ${android_shared_libs})
     endif()
+    #AIX To do - similar to issue 13554 where symbols expected to be defined though not used by AIX ld
+    if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+       list(APPEND onnxruntime_shared_lib_test_LIBS onnxruntime_graph onnxruntime_session onnxruntime_providers onnxruntime_framework onnxruntime_util onnxruntime_mlas onnxruntime_optimizer onnxruntime_flatbuffers iconv re2)
+    endif()
 
     AddTest(DYN
             TARGET onnxruntime_shared_lib_test
@@ -1184,6 +1242,9 @@ if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
       target_compile_definitions(onnxruntime_shared_lib_test PRIVATE USE_DUMMY_EXA_DEMANGLE=1)
     endif()
 
+    if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+        target_link_options(onnxruntime_shared_lib_test PRIVATE "-Wl,-berok")
+    endif()
     if (CMAKE_SYSTEM_NAME STREQUAL "iOS")
       add_custom_command(
         TARGET onnxruntime_shared_lib_test POST_BUILD
@@ -1200,6 +1261,9 @@ if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
               LIBS ${onnxruntime_shared_lib_test_LIBS}
               DEPENDS ${all_dependencies}
       )
+    if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+        target_link_options(onnxruntime_global_thread_pools_test PRIVATE "-Wl,-berok")
+    endif()
     endif()
 
   # A separate test is needed to test the APIs that don't rely on the env being created first.
@@ -1210,6 +1274,9 @@ if (NOT onnxruntime_ENABLE_TRAINING_TORCH_INTEROP)
               LIBS ${onnxruntime_shared_lib_test_LIBS}
               DEPENDS ${all_dependencies}
       )
+    if (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+        target_link_options(onnxruntime_api_tests_without_env PRIVATE "-Wl,-berok")
+    endif()
     endif()
   endif()
 
@@ -1368,7 +1435,7 @@ if (NOT onnxruntime_BUILD_WEBASSEMBLY)
   if(UNIX)
     if (APPLE)
       set(ONNXRUNTIME_CUSTOM_OP_LIB_LINK_FLAG "-Xlinker -dead_strip")
-    else()
+    elseif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
       set(ONNXRUNTIME_CUSTOM_OP_LIB_LINK_FLAG "-Xlinker --version-script=${TEST_SRC_DIR}/testdata/custom_op_library/custom_op_library.lds -Xlinker --no-undefined -Xlinker --gc-sections -z noexecstack")
     endif()
   else()
@@ -1424,6 +1491,9 @@ if (NOT onnxruntime_BUILD_WEBASSEMBLY)
             LIBS ${onnxruntime_customopregistration_test_LIBS}
             DEPENDS ${all_dependencies}
     )
+    if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+       target_link_options(onnxruntime_customopregistration_test PRIVATE "-Wl,-berok")
+    endif()
 
     if (CMAKE_SYSTEM_NAME STREQUAL "iOS")
       add_custom_command(
@@ -1445,7 +1515,7 @@ if (NOT onnxruntime_BUILD_WEBASSEMBLY AND (NOT onnxruntime_MINIMAL_BUILD OR onnx
   if(UNIX)
     if (APPLE)
       set(ONNXRUNTIME_CUSTOM_OP_INVALID_LIB_LINK_FLAG "-Xlinker -dead_strip")
-    else()
+    elseif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
       string(CONCAT ONNXRUNTIME_CUSTOM_OP_INVALID_LIB_LINK_FLAG
              "-Xlinker --version-script=${TEST_SRC_DIR}/testdata/custom_op_invalid_library/custom_op_library.lds "
              "-Xlinker --no-undefined -Xlinker --gc-sections -z noexecstack")
@@ -1509,7 +1579,11 @@ if (NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD
   if(APPLE)
     set_property(TARGET test_execution_provider APPEND_STRING PROPERTY LINK_FLAGS "-Xlinker -exported_symbols_list ${REPO_ROOT}/onnxruntime/test/testdata/custom_execution_provider_library/exported_symbols.lst")
   elseif(UNIX)
-    set_property(TARGET test_execution_provider APPEND_STRING PROPERTY LINK_FLAGS "-Xlinker --version-script=${REPO_ROOT}/onnxruntime/test/testdata/custom_execution_provider_library/version_script.lds -Xlinker --gc-sections -Xlinker -rpath=\\$ORIGIN")
+     if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+       set_property(TARGET test_execution_provider APPEND_STRING PROPERTY LINK_FLAGS "-Xlinker -bE:${REPO_ROOT}/onnxruntime/test/testdata/custom_execution_provider_library/symbols.exp")
+     else()
+       set_property(TARGET test_execution_provider APPEND_STRING PROPERTY LINK_FLAGS "-Xlinker --version-script=${REPO_ROOT}/onnxruntime/test/testdata/custom_execution_provider_library/version_script.lds -Xlinker --gc-sections -Xlinker -rpath=\\$ORIGIN")
+     endif()
   elseif(WIN32)
     set_property(TARGET test_execution_provider APPEND_STRING PROPERTY LINK_FLAGS "-DEF:${REPO_ROOT}/onnxruntime/test/testdata/custom_execution_provider_library/symbols.def")
   else()
diff --git a/include/onnxruntime/core/graph/graph.h b/include/onnxruntime/core/graph/graph.h
index 0fc2762ca..125502067 100644
--- a/include/onnxruntime/core/graph/graph.h
+++ b/include/onnxruntime/core/graph/graph.h
@@ -31,6 +31,7 @@
 
 #include "core/common/gsl.h"
 
+#include "core/framework/ort_value.h"
 #include "core/common/common.h"
 #include "core/common/const_pointer_container.h"
 #include "core/common/inlined_containers_fwd.h"
-- 
2.38.3

