Skip to content

Commit 93cd77b

Browse files
authored
Fix termux/android build (#336)
* Attempt fix * Attempt fix 2 * Attempt fix 3 * Attempt fix 4 * Attempt fix 5 * Attempt fix 6 * Attempt fix 7 * Attempt fix 8 * Attempt fix 9 * Attempt fix 10 * Attempt fix 11 * Attempt fix 12 * Attempt fix 13
1 parent 3bb64d9 commit 93cd77b

File tree

4 files changed

+33
-17
lines changed

4 files changed

+33
-17
lines changed

ggml/src/iqk/iqk_config.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@
1414
#define IQK_IMPLEMENT
1515
#endif
1616

17+
#ifdef GGML_SHARED
18+
# if defined(_WIN32) && !defined(__MINGW32__)
19+
# ifdef GGML_BUILD
20+
# define IQK_API __declspec(dllexport)
21+
# else
22+
# define IQK_API __declspec(dllimport)
23+
# endif
24+
# else
25+
# define IQK_API __attribute__ ((visibility ("default")))
26+
# endif
27+
#else
28+
# define IQK_API
29+
#endif
30+
1731
#ifdef _MSC_VER
1832
#define IQK_NOINLINE __declspec(noinline)
1933
#define IQK_ALWAYS_INLINE inline

ggml/src/iqk/iqk_flash_attn.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ inline uint32_t simple_gcd(uint32_t a, uint32_t b) {
2929

3030
// TODO: get the ggml_type enum here without polution
3131
//
32-
bool iqk_flash_attn_noalibi(int type_q, int type_mask, float max_bias,
32+
extern "C" IQK_API bool iqk_flash_attn_noalibi(int type_q, int type_mask, float max_bias,
3333
int neq3, int neq2, long nbq3, long nbq2,
3434
int nek3, int nek2, long nbk3, long nbk2,
3535
int nev3, int nev2, long nbv3, long nbv2,
@@ -258,9 +258,10 @@ bool iqk_flash_attn_noalibi([[maybe_unused]] int type_q, [[maybe_unused]] int ty
258258
[[maybe_unused]] int nek3, [[maybe_unused]] int nek2, [[maybe_unused]] long nbk3, [[maybe_unused]] long nbk2,
259259
[[maybe_unused]] int nev3, [[maybe_unused]] int nev2, [[maybe_unused]] long nbv3, [[maybe_unused]] long nbv2,
260260
[[maybe_unused]] int ne2, [[maybe_unused]] int ne1, [[maybe_unused]] long nb1,
261-
[[maybe_unused]] int int_type_k, // type of k
262-
[[maybe_unused]] int int_type_v, // type of v
263-
[[maybe_unused]] int D, // head size
261+
[[maybe_unused]] int type_k, // type of k
262+
[[maybe_unused]] int type_v, // type of v
263+
[[maybe_unused]] int Dk, // K head size
264+
[[maybe_unused]] int Dv, // V head size
264265
[[maybe_unused]] int nq, // number of columns in q
265266
[[maybe_unused]] int nk, // number of rows in k
266267
[[maybe_unused]] int stride_q, // distance between q columns in bytes

ggml/src/iqk/iqk_mul_mat.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ struct MulMat {
403403

404404
}
405405

406-
bool iqk_mul_mat(long Nx, long Ny, long ne00,
406+
extern "C" IQK_API bool iqk_mul_mat(long Nx, long Ny, long ne00,
407407
int typeA, const void * A, long strideA,
408408
int typeB, const void * B, long strideB,
409409
float * C, long stride_C, int ith, int nth) {
@@ -440,7 +440,7 @@ inline uint32_t simple_gcd(uint32_t a, uint32_t b) {
440440
}
441441
}
442442

443-
bool iqk_mul_mat_4d(long Nx, long Ny, long ne00,
443+
extern "C" IQK_API bool iqk_mul_mat_4d(long Nx, long Ny, long ne00,
444444
long ne02, long ne03, long ne12, long ne13,
445445
long nb02, long nb03, long nb12, long nb13, long nb2, long nb3,
446446
int typeA, const void * A, long strideA,
@@ -545,7 +545,7 @@ bool iqk_mul_mat_4d(long Nx, long Ny, long ne00,
545545
return true;
546546
}
547547

548-
bool iqk_mul_mat_moe(long Nx, long Ny, long ne00, int ne11,
548+
extern "C" IQK_API bool iqk_mul_mat_moe(long Nx, long Ny, long ne00, int ne11,
549549
int typeA, const void * A, long strideA,
550550
int typeB, const void * B, long strideB,
551551
float * C, long nb1, long nb2, const void * vrow_mapping, int ith, int nth) {
@@ -571,7 +571,7 @@ bool iqk_mul_mat_moe(long Nx, long Ny, long ne00, int ne11,
571571
return true;
572572
}
573573

574-
bool iqk_moe_fused_up_gate(long Nx, long Ny, long ne00, int ne11, int unary_op,
574+
extern "C" IQK_API bool iqk_moe_fused_up_gate(long Nx, long Ny, long ne00, int ne11, int unary_op,
575575
int typeA, const void * Aup, const void * Agate, long strideA,
576576
int typeB, const void * B, long strideB,
577577
float * C, long nb1, long nb2, const void * vrow_mapping, int ith, int nth) {
@@ -17550,11 +17550,11 @@ bool iqk_flash_attn_impl(int int_type_k, // type of k
1755017550

1755117551
#else // IQK_IMPLEMENT
1755217552

17553-
bool iqk_mul_mat(int, long, long, long, int, const void *, long, int, const void *, long, float *, long, int, int) {
17553+
extern "C" IQK_API bool iqk_mul_mat(int, long, long, long, int, const void *, long, int, const void *, long, float *, long, int, int) {
1755417554
return false;
1755517555
}
1755617556

17557-
bool iqk_mul_mat_4d(long /*Nx*/, long /*Ny*/, long /*ne00*/,
17557+
extern "C" IQK_API bool iqk_mul_mat_4d(long /*Nx*/, long /*Ny*/, long /*ne00*/,
1755817558
long /*ne02*/, long /*ne03*/, long /*ne12*/, long /*ne13*/,
1755917559
long /*nb02*/, long /*nb03*/, long /*nb12*/, long /*nb13*/, long /*nb2*/, long /*nb3*/,
1756017560
int /*typeA*/, const void * /*A*/, long /*strideA*/,
@@ -17563,12 +17563,12 @@ bool iqk_mul_mat_4d(long /*Nx*/, long /*Ny*/, long /*ne00*/,
1756317563
return false;
1756417564
}
1756517565

17566-
bool iqk_mul_mat_moe(long, long, long, int, int, const void *, long, int, const void *, long, float *, long, long,
17566+
extern "C" IQK_API bool iqk_mul_mat_moe(long, long, long, int, int, const void *, long, int, const void *, long, float *, long, long,
1756717567
const void *, int, int) {
1756817568
return false;
1756917569
}
1757017570

17571-
bool iqk_moe_fused_up_gate(long /*Nx*/, long /*Ny*/, long /*ne00*/, int /*ne11*/, int /*unary_op*/,
17571+
extern "C" IQK_API bool iqk_moe_fused_up_gate(long /*Nx*/, long /*Ny*/, long /*ne00*/, int /*ne11*/, int /*unary_op*/,
1757217572
int /*typeA*/, const void * /*Aup*/, const void * /*Agate*/, long /*strideA*/,
1757317573
int /*typeB*/, const void * /*B*/, long /*strideB*/,
1757417574
float * /*C*/, long /*nb1*/, long /*nb2*/, const void * /*vrow_mapping*/, int /*ith*/, int /*nth*/) {

ggml/src/iqk/iqk_mul_mat.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,36 @@
77
#pragma once
88
#include <stdint.h>
99
#include <stdbool.h>
10+
#include "iqk_config.h"
1011
#ifdef __cplusplus
1112
extern "C" {
1213
#endif
1314

14-
bool iqk_mul_mat(long Nx, long Ny, long ne00,
15+
IQK_API bool iqk_mul_mat(long Nx, long Ny, long ne00,
1516
int typeA, const void * A, long strideA,
1617
int typeB, const void * B, long strideB,
1718
float * C, long stride_C, int ith, int nth);
1819

19-
bool iqk_mul_mat_4d(long Nx, long Ny, long ne00,
20+
IQK_API bool iqk_mul_mat_4d(long Nx, long Ny, long ne00,
2021
long ne02, long ne03, long ne12, long ne13,
2122
long nb02, long nb03, long nb12, long nb13, long nb2, long nb3,
2223
int typeA, const void * A, long strideA,
2324
int typeB, const void * B, long strideB,
2425
float * C, long stride_C, int ith, int nth);
2526

26-
bool iqk_mul_mat_moe(long Nx, long Ny, long ne00, int ne11,
27+
IQK_API bool iqk_mul_mat_moe(long Nx, long Ny, long ne00, int ne11,
2728
int typeA, const void * A, long strideA,
2829
int typeB, const void * B, long strideB,
2930
float * C, long nb1, long nb2, const void * vrow_mapping, int ith, int nth);
3031

31-
bool iqk_moe_fused_up_gate(long Nx, long Ny, long ne00, int ne11, int unary_op,
32+
IQK_API bool iqk_moe_fused_up_gate(long Nx, long Ny, long ne00, int ne11, int unary_op,
3233
int typeA, const void * Aup, const void * Agate, long strideA,
3334
int typeB, const void * B, long strideB,
3435
float * C, long nb1, long nb2, const void * vrow_mapping, int ith, int nth);
3536

3637
typedef void (*barrier_t) (void *);
3738

38-
bool iqk_flash_attn_noalibi(int type_q, int type_mask, float max_bias,
39+
IQK_API bool iqk_flash_attn_noalibi(int type_q, int type_mask, float max_bias,
3940
int neq3, int neq2, long nbq3, long nbq2,
4041
int nek3, int nek2, long nbk3, long nbk2,
4142
int nev3, int nev2, long nbv3, long nbv2,

0 commit comments

Comments
 (0)