Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ if(OCOS_ENABLE_VISION)
if (NOT OCOS_ENABLE_DLIB)
message(FATAL_ERROR "Vision operators require DLIB to be enabled.") # for now, we need dlib for image processing
endif()
include(ext_imgcodecs)
include(ext_imgcodecs)
target_include_directories(ocos_operators PUBLIC ${libPNG_SOURCE_DIR} ${libJPEG_SOURCE_DIR})
target_link_libraries(ocos_operators PUBLIC ${PNG_LIBRARY} ${JPEG_LIBRARY})
endif()
Expand Down Expand Up @@ -763,9 +763,14 @@ if(OCOS_BUILD_SHARED_LIB)
source_group(TREE ${PROJECT_SOURCE_DIR} FILES ${shared_TARGET_SRC})
standardize_output_folder(extensions_shared)

if(LINUX OR ANDROID)
set_property(TARGET extensions_shared APPEND_STRING PROPERTY LINK_FLAGS
" -Wl,--version-script -Wl,${PROJECT_SOURCE_DIR}/shared/ortcustomops.ver")
if(LINUX OR ANDROID OR CMAKE_SYSTEM_NAME STREQUAL "AIX")
if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
set_property(TARGET extensions_shared APPEND_STRING PROPERTY LINK_FLAGS
" -Wl,-bE:${PROJECT_SOURCE_DIR}/shared/ortcustomops.exp")
else()
set_property(TARGET extensions_shared APPEND_STRING PROPERTY LINK_FLAGS
" -Wl,--version-script -Wl,${PROJECT_SOURCE_DIR}/shared/ortcustomops.ver")
endif()
# strip if not a debug build
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set_property(TARGET extensions_shared APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-s")
Expand Down
34 changes: 34 additions & 0 deletions cmake/externals/blingfire-aix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--- ./blingfireclient.library/inc/FAConfig_orig.h 2026-05-19 03:27:38.241882009 -0500
+++ ./blingfireclient.library/inc/FAConfig.h 2026-05-19 03:29:23.720979389 -0500
@@ -11,6 +11,7 @@
#define NEW new
#endif

+#include <stdio.h>
#if _MSC_VER < 1400
# ifndef fopen_s
# define fopen_s(ppF,pN,pA) int(0); *ppF = fopen(pN,pA);
@@ -23,13 +24,12 @@
#include <ctype.h>
#include <fcntl.h>

-#ifdef BLING_FIRE_MAC
+#if defined(BLING_FIRE_MAC) || defined(_AIX)
#include <string>
#else
#include <malloc.h>
#endif

-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cmath>
@@ -79,7 +79,7 @@

#include <stdint.h>

-/* because we have stdint.h
+/* because we have stdint.h
#ifndef __int32
#define __int32 int32_t
#endif
5 changes: 3 additions & 2 deletions cmake/externals/blingfire.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ FetchContent_Declare(
GIT_REPOSITORY https://github.com/microsoft/BlingFire.git
GIT_TAG 0831265c1aca95ca02eca5bf1155e4251e545328
EXCLUDE_FROM_ALL
PATCH_COMMAND git checkout . && git apply --ignore-space-change --ignore-whitespace ${PROJECT_SOURCE_DIR}/cmake/externals/blingfire_cmake.patch)

PATCH_COMMAND git checkout . && git apply --ignore-space-change --ignore-whitespace ${PROJECT_SOURCE_DIR}/cmake/externals/blingfire_cmake.patch && git apply --ignore-space-change --ignore-whitespace ${PROJECT_SOURCE_DIR}/cmake/externals/blingfire-aix.patch
)
FetchContent_MakeAvailable(Blingfire)

set_target_properties(bingfirtinydll_static PROPERTIES FOLDER
externals/bingfire)
set_target_properties(fsaClientTiny PROPERTIES FOLDER externals/bingfire)
14 changes: 13 additions & 1 deletion cmake/externals/blingfire_cmake.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ index 5d47b3a..dd36aaf 100644
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.0)
+cmake_minimum_required (VERSION 3.5)

set (BLING_FIRE_VERSION_MAJOR 1)
set (BLING_FIRE_VERSION_MINOR 0)

--- ./CMakeLists_orig.txt 2026-05-23 03:43:50.580750573 -0500
+++ ./CMakeLists.txt 2026-05-23 03:44:19.454763579 -0500
@@ -107,7 +107,7 @@
IF(${dirname} STREQUAL "any_test")
target_link_libraries(${dirname} ${CMAKE_DL_LIBS})
ENDIF()
- IF (APPLE)
+ IF (APPLE OR CMAKE_SYSTEM_NAME MATCHES "AIX")
target_link_libraries(${dirname} iconv)
ENDIF()
ENDIF()
1 change: 1 addition & 0 deletions cmake/externals/dr_libs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FetchContent_Declare(dr_libs
URL https://github.com/mackron/dr_libs/archive/660795b2834aebb2217c9849d668b6e4bd4ef810.zip
URL_HASH SHA1=af554b21dcd1ab3c7c8d946638682a2cbccf3e16
SOURCE_SUBDIR not_set
PATCH_COMMAND git apply --whitespace=fix --ignore-space-change --ignore-whitespace ${CMAKE_CURRENT_SOURCE_DIR}/cmake/externals/dr_libs_aix.patch
)

FetchContent_MakeAvailable(dr_libs)
13 changes: 13 additions & 0 deletions cmake/externals/dr_libs_aix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- ./dr_mp3.h 2026-03-28 10:41:13.180505219 -0500
+++ ./dr_mp3.h 2026-03-28 10:41:06.567807627 -0500
@@ -86,6 +86,10 @@
#ifndef dr_mp3_h
#define dr_mp3_h

+#if defined(_AIX) && defined(hz)
+#undef hz
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
2 changes: 1 addition & 1 deletion cmake/externals/opencv.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ FetchContent_Declare(
-DBUILD_TESTS:BOOL=FALSE
-DBUILD_SHARED_LIBS:BOOL=FALSE
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/opencv
PATCH_COMMAND git checkout . && git apply --whitespace=fix --ignore-space-change --ignore-whitespace ${CMAKE_CURRENT_SOURCE_DIR}/cmake/externals/opencv-no-rtti.patch
EXCLUDE_FROM_ALL
PATCH_COMMAND git checkout . && git apply --whitespace=fix --ignore-space-change --ignore-whitespace ${CMAKE_CURRENT_SOURCE_DIR}/cmake/externals/opencv-no-rtti.patch && git apply --whitespace=fix --ignore-space-change --ignore-whitespace ${CMAKE_CURRENT_SOURCE_DIR}/cmake/externals/rand_aix.patch && git apply --whitespace=fix --ignore-space-change --ignore-whitespace ${CMAKE_CURRENT_SOURCE_DIR}/cmake/externals/opencv_libpng_aix.patch
)

FetchContent_MakeAvailable(opencv)
Expand Down
19 changes: 19 additions & 0 deletions cmake/externals/opencv_libpng_aix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--- a/3rdparty/libpng/CMakeLists.txt
+++ b/3rdparty/libpng/CMakeLists.txt
@@ -56,11 +56,12 @@ else()
endif()

-if(PPC64LE OR PPC64)
- # VSX3 features are backwards compatible
- if(";${CPU_BASELINE_FINAL};" MATCHES "VSX.*"
- AND NOT PPC64)
+# Enable PowerPC VSX optimizations on PowerPC systems (Linux) and AIX
+if(PPC64LE OR PPC64 OR CMAKE_SYSTEM_NAME MATCHES "AIX")
+ # Enable VSX on PowerPC (AIX and Linux)
+ if(";${CPU_BASELINE_FINAL};" MATCHES "VSX.*" OR CMAKE_SYSTEM_NAME MATCHES "AIX")
list(APPEND lib_srcs powerpc/powerpc_init.c powerpc/filter_vsx_intrinsics.c)
add_definitions(-DPNG_POWERPC_VSX_OPT=2)
+ message(STATUS "libpng: PowerPC VSX optimizations enabled")
else()
add_definitions(-DPNG_POWERPC_VSX_OPT=0)
endif()
46 changes: 46 additions & 0 deletions cmake/externals/rand_aix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

--- ./modules/core/src/rand.cpp 2026-03-25 07:34:27.666925971 -0500
+++ ./modules/core/src/rand.cpp 2026-03-25 07:40:40.661543262 -0500
@@ -48,6 +48,10 @@

#include "precomp.hpp"

+#if defined(_AIX) && defined(hz)
+#undef hz
+#endif
+
namespace cv
{

--- ./modules/core/src/system.cpp 2026-03-25 07:50:38.785508231 -0500
+++ ./modules/core/src/system.cpp 2026-03-25 07:50:25.791118063 -0500
@@ -130,7 +130,7 @@
# include <fcntl.h>
#if defined __QNXNTO__
# include <sys/elf.h>
-#else
+#elif !defined (_AIX)
# include <elf.h>
#endif
#if defined __ANDROID__ || defined __linux__
@@ -146,8 +146,8 @@
#endif


-#if (defined __ppc64__ || defined __PPC64__) && defined __unix__
+#if (defined __ppc64__ || defined __PPC64__) && defined __unix__ && !defined _AIX
# include "sys/auxv.h"
# ifndef AT_HWCAP2
# define AT_HWCAP2 26
# endif
@@ -615,7 +615,7 @@
#ifdef __mips_msa
have[CV_CPU_MSA] = true;
#endif

- #if (defined __ppc64__ || defined __PPC64__) && defined __unix__
+ #if (defined __ppc64__ || defined __PPC64__) && defined __unix__ && !defined _AIX
unsigned int hwcap = getauxval(AT_HWCAP);
if (hwcap & PPC_FEATURE_HAS_VSX) {
hwcap = getauxval(AT_HWCAP2);

4 changes: 3 additions & 1 deletion cmake/externals/sentencepieceproject.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ endif()
# PB files was seperated as another patch file to avoid the patch file too large to be reviewed.
set(spm_patches
"${PROJECT_SOURCE_DIR}/cmake/externals/sentencepieceproject_cmake.patch"
"${PROJECT_SOURCE_DIR}/cmake/externals/sentencepieceproject_pb.patch")
"${PROJECT_SOURCE_DIR}/cmake/externals/sentencepieceproject_pb.patch"
"${PROJECT_SOURCE_DIR}/cmake/externals/sentencepieceproject_aix.patch"
"${PROJECT_SOURCE_DIR}/cmake/externals/sentencepieceproject_enum.patch")

set(spm_patch_command git checkout . && git apply --ignore-space-change --ignore-whitespace ${spm_patches})

Expand Down
13 changes: 13 additions & 0 deletions cmake/externals/sentencepieceproject_aix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- ./src/util.h_orig 2026-03-13 04:45:26.898234633 -0500
+++ ./src/util.h 2026-03-13 05:08:47.892826822 -0500
@@ -36,7 +36,9 @@
#include <pthread.h>
#endif

-#if !defined(__APPLE__) && !defined(_WIN32)
+#if defined(_AIX)
+#define IS_BIG_ENDIAN
+#elif !defined(__APPLE__) && !defined(_WIN32)
#include <endian.h>
#if BYTE_ORDER == __BIG_ENDIAN
#define IS_BIG_ENDIAN
11 changes: 11 additions & 0 deletions cmake/externals/sentencepieceproject_enum.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- ./src/unicode_script.h_orig 2026-04-06 23:28:59.276085358 -0500
+++ ./src/unicode_script.h 2026-04-06 23:29:39.906085511 -0500
@@ -19,7 +19,7 @@

namespace sentencepiece {
namespace unicode_script {
-enum ScriptType {
+enum ScriptType : int32_t {
U_Adlam,
U_Ahom,
U_Anatolian_Hieroglyphs,
2 changes: 1 addition & 1 deletion operators/text/vector_to_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace std {

template <class T>
struct hash<std::vector<T>> {
size_t operator()(const vector<T>& __vector) const noexcept;
size_t operator()(const vector<T>& __vec) const noexcept;
};
Comment on lines 13 to 17
} // namespace std

Expand Down
24 changes: 20 additions & 4 deletions operators/tokenizer/ugm_kernels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,22 @@ struct SpmUgmTokenizer {
// std::cout << int(charsmap_data_[i]) << " ";
// }

if (charsmap_data_.size() < sizeof(uint32_t)) {
return OrtxStatus(extError_t::kOrtxErrorCorruptData, "Precompiled charsmap is too short to contain XCDA header.");
}
size_t charsmap_offset = 0;

// First four bytes of precompiled_charsmap contains length of binary
// blob containing XOR-compressed compact double array (XCDA) entries
uint32_t xcda_blob_size = *(const uint32_t*)&charsmap_data_[0];
// The data is stored in little-endian format, so we need to convert on big-endian systems
uint32_t xcda_blob_size;
std::memcpy(&xcda_blob_size, &charsmap_data_[0], sizeof(xcda_blob_size));
Comment on lines +100 to +101

// Convert from little-endian to host byte order
#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
xcda_blob_size = __builtin_bswap32(xcda_blob_size);
#endif

charsmap_offset += sizeof(xcda_blob_size);
if (xcda_blob_size + charsmap_offset >= charsmap_data_.size()) {
return OrtxStatus(extError_t::kOrtxErrorCorruptData, "Index out of array bounds in precompiled charsmap!");
Expand Down Expand Up @@ -296,7 +307,7 @@ struct SpmUgmTokenizer {
"Invalid UTF-8 encoding detected in input string at position " +
std::to_string(-validation_result));
}

std::string normalized;
if (case_encoder_) {
normalized = NmtNormalize(input);
Expand Down Expand Up @@ -637,7 +648,12 @@ struct SpmUgmTokenizer {
if (index >= xcda_array_size_) { // Fix #2: off-by-one correction
ORTX_CXX_API_THROW("[UgmTok]Index out of array bounds in XCDA array!", ORT_RUNTIME_EXCEPTION);
}
return xcda_array_[index];
uint32_t value = xcda_array_[index];
// Convert from little-endian to host byte order
#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
value = __builtin_bswap32(value);
#endif
return value;
}
const uint32_t* xcda_array_;
size_t xcda_array_size_;
Expand Down Expand Up @@ -1051,4 +1067,4 @@ class SpmUgmDecoder {
std::set<extTokenId_t> special_token_ids_;
};

} // namespace ort_extensions
} // namespace ort_extensions
4 changes: 4 additions & 0 deletions shared/api/nemo_mel_spectrogram.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#include <utility>
#include <vector>

#if defined _AIX && defined (hz)
#undef hz
#endif

namespace nemo_mel {

struct NemoMelConfig {
Expand Down
3 changes: 3 additions & 0 deletions shared/ortcustomops.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RegisterCustomOps
AddExternalCustomOp
GetActiveOrtAPIVersion
Loading