Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move call to MLAS_CPUIDINFO::GetCPUIDInfo() out of MlasSQNBitGemmDispatchNeon initialization. #24018

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

edgchen1
Copy link
Contributor

Description

Move call to MLAS_CPUIDINFO::GetCPUIDInfo() out of MlasSQNBitGemmDispatchNeon initialization.

Motivation and Context

Reduce binary size when MatMulNBits op is not included in the build.

I believe the side effect of MLAS_CPUIDINFO::GetCPUIDInfo() (e.g., initializing a static object) prevents the linker from discarding the code in a build where the associated MLAS functions are unused.

bloaty diff output of Android minimal build with no ops:

baseline: 06482c2, updated: 8f5d213

$ bloaty -d compileunits ${UPDATED_DIR}/libonnxruntime.stripped.so --debug-file=${UPDATED_DIR}/libonnxruntime.so -- ${BASELINE_DIR}/libonnxruntime.stripped.so --debug-file=${BASELINE_DIR}/libonnxruntime.so
    FILE SIZE        VM SIZE
 --------------  --------------
  +0.1%     +85  +0.1%     +85    [section .rodata]
   +12%     +60   +12%     +60    D:/source/onnxruntime_2/build/android.minimal_baseline/MinSizeRel/_deps/pytorch_cpuinfo-src/src/linux/multiline.c
  +3.5%     +44  +3.5%     +44    D:/source/onnxruntime_2/build/android.minimal_baseline/MinSizeRel/_deps/pytorch_cpuinfo-src/src/arm/linux/aarch64-isa.c
  -0.8%     -24  -0.8%     -24    [section .dynsym]
 -33.3%     -32 -33.3%     -32    [section .gnu.version_r]
  -0.1%     -53  -0.1%     -53    D:/source/onnxruntime_2/onnxruntime/core/session/onnxruntime_c_api.cc
 -100.1%     -96 -100.1%     -88    [11 Others]
  -4.9%     -96  -4.9%     -96    [section .got]
  -3.8%    -104  -3.8%    -104    D:/source/onnxruntime_2/build/android.minimal_baseline/MinSizeRel/_deps/protobuf-src/src/google/protobuf/arena.cc
  [DEL]    -224  [DEL]    -224    D:/source/onnxruntime_2/onnxruntime/core/mlas/lib/threading.cpp
  -0.6%    -244  -0.6%    -244    [section .eh_frame]
  [ = ]       0 -65.4%    -257    [section .tbss]
  -1.4%    -360  -1.4%    -360    [section .data.rel.ro]
  [ = ]       0 -25.8%    -456    [section .relro_padding]
  [DEL]    -876  [DEL]    -988    D:/source/onnxruntime_2/onnxruntime/core/mlas/lib/qnbitgemm_kernel_neon.cpp
  -1.6% -1.08Ki  -1.6% -1.08Ki    [section .rela.dyn]
  -0.8% -1.71Ki  -0.8% -1.71Ki    [section .text]
 -15.6% -2.62Ki -15.6% -2.62Ki    D:/source/onnxruntime_2/onnxruntime/core/common/threadpool.cc
  [DEL] -6.97Ki  [DEL] -6.97Ki    D:/source/onnxruntime_2/onnxruntime/core/mlas/lib/sqnbitgemm_kernel_neon_fp32.cpp
  [DEL] -7.18Ki  [DEL] -7.18Ki    D:/source/onnxruntime_2/onnxruntime/core/mlas/lib/hqnbitgemm_kernel_neon_fp16.cpp
  [DEL] -10.1Ki  [DEL] -10.1Ki    D:/source/onnxruntime_2/onnxruntime/core/mlas/lib/sqnbitgemm_kernel_neon_int8.cpp
  -2.6% -31.6Ki  -2.6% -32.4Ki    TOTAL

@edgchen1 edgchen1 marked this pull request as ready for review March 13, 2025 03:29
@edgchen1 edgchen1 requested a review from a team as a code owner March 13, 2025 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant