Skip to content

Commit b2692ca

Browse files
committed
ggml-cpu : rework weak alias on apple targets
1 parent e2c0b6e commit b2692ca

File tree

4 files changed

+7
-49
lines changed

4 files changed

+7
-49
lines changed

ggml/src/ggml-cpu/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,6 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
450450
list (APPEND GGML_CPU_SOURCES ggml-cpu/arch/wasm/quants.c)
451451
else()
452452
message(WARNING "Unknown CPU architecture. Falling back to generic implementations.")
453-
list(APPEND ARCH_FLAGS -DGGML_CPU_GENERIC)
454453
endif()
455454

456455
if (GGML_CPU_REPACK)

ggml/src/ggml-cpu/ggml-cpu-impl.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -509,12 +509,14 @@ void ggml_barrier(struct ggml_threadpool * tp);
509509

510510
#define GGML_DO_PRAGMA_(x) _Pragma (#x)
511511
#define GGML_DO_PRAGMA(x) GGML_DO_PRAGMA_(x)
512-
#if defined(GGML_CPU_GENERIC) || defined(__HIPCC__)
513-
// Note for Apple targets:
514-
// - clang: aliases are not supported on darwin
515-
// - all native kernels need to be implemented in both x86 and arm files
516-
// - on iOS, tvOS, and visionOS, if cmake cannot determine the target architecture, all `_generic` names are replaced by defines
512+
#if defined(__HIPCC__)
517513
# define GGML_WEAK_ALIAS(name, alias)
514+
#elif defined(__APPLE__)
515+
// ref: https://groups.google.com/g/llvm-dev/c/wTxkhHj2cZc/m/gSPgzQ79AwAJ
516+
# define GGML_WEAK_ALIAS(old, new) \
517+
__asm__(".globl _" #new); \
518+
__asm__("_" #new " = _" #old); \
519+
extern __typeof(old) new __attribute__((weak_import));
518520
#elif defined(__GNUC__)
519521
// GCC/Clang on *nix
520522
# define GGML_WEAK_ALIAS(name, alias) GGML_DO_PRAGMA(weak name = alias) // NOLINT

ggml/src/ggml-cpu/quants.h

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -84,33 +84,6 @@ void ggml_vec_dot_iq1_m_q8_K_generic(int n, float * GGML_RESTRICT s, size_t bs,
8484
void ggml_vec_dot_iq4_nl_q8_0_generic(int n, float * GGML_RESTRICT s, size_t bs, const void * GGML_RESTRICT vx, size_t bx, const void * GGML_RESTRICT vy, size_t by, int nrc);
8585
void ggml_vec_dot_iq4_xs_q8_K_generic(int n, float * GGML_RESTRICT s, size_t bs, const void * GGML_RESTRICT vx, size_t bx, const void * GGML_RESTRICT vy, size_t by, int nrc);
8686

87-
#if defined(GGML_CPU_GENERIC)
88-
#define quantize_row_q8_0_generic quantize_row_q8_0
89-
#define quantize_row_q8_1_generic quantize_row_q8_1
90-
#define quantize_row_q8_K_generic quantize_row_q8_K
91-
#define ggml_vec_dot_q4_0_q8_0_generic ggml_vec_dot_q4_0_q8_0
92-
#define ggml_vec_dot_q4_1_q8_1_generic ggml_vec_dot_q4_1_q8_1
93-
#define ggml_vec_dot_q5_0_q8_0_generic ggml_vec_dot_q5_0_q8_0
94-
#define ggml_vec_dot_q5_1_q8_1_generic ggml_vec_dot_q5_1_q8_1
95-
#define ggml_vec_dot_q8_0_q8_0_generic ggml_vec_dot_q8_0_q8_0
96-
#define ggml_vec_dot_tq1_0_q8_K_generic ggml_vec_dot_tq1_0_q8_K
97-
#define ggml_vec_dot_tq2_0_q8_K_generic ggml_vec_dot_tq2_0_q8_K
98-
#define ggml_vec_dot_q2_K_q8_K_generic ggml_vec_dot_q2_K_q8_K
99-
#define ggml_vec_dot_q3_K_q8_K_generic ggml_vec_dot_q3_K_q8_K
100-
#define ggml_vec_dot_q4_K_q8_K_generic ggml_vec_dot_q4_K_q8_K
101-
#define ggml_vec_dot_q5_K_q8_K_generic ggml_vec_dot_q5_K_q8_K
102-
#define ggml_vec_dot_q6_K_q8_K_generic ggml_vec_dot_q6_K_q8_K
103-
#define ggml_vec_dot_iq2_xxs_q8_K_generic ggml_vec_dot_iq2_xxs_q8_K
104-
#define ggml_vec_dot_iq2_xs_q8_K_generic ggml_vec_dot_iq2_xs_q8_K
105-
#define ggml_vec_dot_iq2_s_q8_K_generic ggml_vec_dot_iq2_s_q8_K
106-
#define ggml_vec_dot_iq3_xxs_q8_K_generic ggml_vec_dot_iq3_xxs_q8_K
107-
#define ggml_vec_dot_iq3_s_q8_K_generic ggml_vec_dot_iq3_s_q8_K
108-
#define ggml_vec_dot_iq1_s_q8_K_generic ggml_vec_dot_iq1_s_q8_K
109-
#define ggml_vec_dot_iq1_m_q8_K_generic ggml_vec_dot_iq1_m_q8_K
110-
#define ggml_vec_dot_iq4_nl_q8_0_generic ggml_vec_dot_iq4_nl_q8_0
111-
#define ggml_vec_dot_iq4_xs_q8_K_generic ggml_vec_dot_iq4_xs_q8_K
112-
#endif
113-
11487
#ifdef __cplusplus
11588
}
11689
#endif

ggml/src/ggml-cpu/repack.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,6 @@ void ggml_gemm_q4_0_8x8_q8_0_generic(int n, float * GGML_RESTRICT s, size_t bs,
9898
void ggml_gemm_q4_K_8x8_q8_K_generic(int n, float * GGML_RESTRICT s, size_t bs, const void * GGML_RESTRICT vx, const void * GGML_RESTRICT vy, int nr, int nc);
9999
void ggml_gemm_iq4_nl_4x4_q8_0_generic(int n, float * GGML_RESTRICT s, size_t bs, const void * GGML_RESTRICT vx, const void * GGML_RESTRICT vy, int nr, int nc);
100100

101-
#if defined(GGML_CPU_GENERIC)
102-
#define ggml_quantize_mat_q8_0_4x4_generic ggml_quantize_mat_q8_0_4x4
103-
#define ggml_quantize_mat_q8_0_4x8_generic ggml_quantize_mat_q8_0_4x8
104-
#define ggml_quantize_mat_q8_K_4x8_generic ggml_quantize_mat_q8_K_4x8
105-
#define ggml_gemv_q4_0_4x4_q8_0_generic ggml_gemv_q4_0_4x4_q8_0
106-
#define ggml_gemv_q4_0_4x8_q8_0_generic ggml_gemv_q4_0_4x8_q8_0
107-
#define ggml_gemv_q4_0_8x8_q8_0_generic ggml_gemv_q4_0_8x8_q8_0
108-
#define ggml_gemv_q4_K_8x8_q8_K_generic ggml_gemv_q4_K_8x8_q8_K
109-
#define ggml_gemv_iq4_nl_4x4_q8_0_generic ggml_gemv_iq4_nl_4x4_q8_0
110-
#define ggml_gemm_q4_0_4x4_q8_0_generic ggml_gemm_q4_0_4x4_q8_0
111-
#define ggml_gemm_q4_0_4x8_q8_0_generic ggml_gemm_q4_0_4x8_q8_0
112-
#define ggml_gemm_q4_0_8x8_q8_0_generic ggml_gemm_q4_0_8x8_q8_0
113-
#define ggml_gemm_q4_K_8x8_q8_K_generic ggml_gemm_q4_K_8x8_q8_K
114-
#define ggml_gemm_iq4_nl_4x4_q8_0_generic ggml_gemm_iq4_nl_4x4_q8_0
115-
#endif
116-
117101
#if defined(__cplusplus)
118102
} // extern "C"
119103
#endif

0 commit comments

Comments
 (0)