onnxruntime
21fbd6ca - Use c++17 to simplify the AllocatorDefaultAllocAligned function (#24984)

Commit
202 days ago
Use c++17 to simplify the AllocatorDefaultAllocAligned function (#24984) # Description This pull request refactors the default aligned memory allocation functions (AllocatorDefaultAllocAligned and AllocatorDefaultFreeAligned) to use modern C++17 standard features, removing the need for platform-specific preprocessor directives. # Motivation The existing implementation relies on #ifdef _MSC_VER to switch between _aligned_malloc/_aligned_free on Windows and posix_memalign/free on other platforms. While functional, this approach has several drawbacks: It increases code complexity and reduces readability. It relies on legacy C functions instead of standard C++ features. It requires manual error handling for each platform-specific path. By switching to C++17's type-safe aligned allocation, we can achieve the same functionality with a single, portable, and more maintainable implementation. --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Author
Changming Sun
Parents
Loading