whisper.rn 0.5.1 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/jni.cpp +12 -3
- package/cpp/ggml-alloc.c +49 -18
- package/cpp/ggml-backend-impl.h +0 -3
- package/cpp/ggml-backend-reg.cpp +8 -0
- package/cpp/ggml-backend.cpp +0 -2
- package/cpp/ggml-backend.h +2 -0
- package/cpp/ggml-cpu/amx/amx.cpp +1 -0
- package/cpp/ggml-cpu/arch/arm/quants.c +428 -26
- package/cpp/ggml-cpu/ggml-cpu-impl.h +4 -2
- package/cpp/ggml-cpu/ggml-cpu.c +67 -24
- package/cpp/ggml-cpu/ops.cpp +489 -364
- package/cpp/ggml-cpu/ops.h +4 -4
- package/cpp/ggml-cpu/repack.cpp +143 -29
- package/cpp/ggml-cpu/simd-mappings.h +25 -25
- package/cpp/ggml-cpu/unary-ops.cpp +151 -0
- package/cpp/ggml-cpu/unary-ops.h +7 -0
- package/cpp/ggml-cpu/vec.cpp +83 -0
- package/cpp/ggml-cpu/vec.h +20 -8
- package/cpp/ggml-impl.h +67 -2
- package/cpp/ggml-metal/ggml-metal-common.cpp +2 -2
- package/cpp/ggml-metal/ggml-metal-context.m +5 -6
- package/cpp/ggml-metal/ggml-metal-device.cpp +300 -14
- package/cpp/ggml-metal/ggml-metal-device.h +26 -1
- package/cpp/ggml-metal/ggml-metal-device.m +243 -28
- package/cpp/ggml-metal/ggml-metal-impl.h +177 -9
- package/cpp/ggml-metal/ggml-metal-ops.cpp +843 -157
- package/cpp/ggml-metal/ggml-metal-ops.h +8 -0
- package/cpp/ggml-metal/ggml-metal.cpp +8 -3
- package/cpp/ggml-metal/ggml-metal.metal +12436 -0
- package/cpp/ggml.c +317 -4
- package/cpp/ggml.h +139 -0
- package/cpp/jsi/RNWhisperJSI.cpp +7 -2
- package/cpp/rn-whisper.h +1 -0
- package/cpp/whisper.cpp +8 -2
- package/ios/RNWhisperContext.mm +3 -1
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-backend-impl.h +0 -3
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-backend.h +2 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-impl.h +67 -2
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml.h +139 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/rn-whisper.h +1 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Info.plist +0 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/ggml-metal.metal +12436 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/rnwhisper +0 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend-impl.h +0 -3
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend.h +2 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-impl.h +67 -2
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml.h +139 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-whisper.h +1 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Info.plist +0 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/_CodeSignature/CodeResources +1 -1
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/ggml-metal.metal +12436 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/rnwhisper +0 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-backend-impl.h +0 -3
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-backend.h +2 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-impl.h +67 -2
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml.h +139 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/rn-whisper.h +1 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Info.plist +0 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/ggml-metal.metal +12436 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/rnwhisper +0 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend-impl.h +0 -3
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend.h +2 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-impl.h +67 -2
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml.h +139 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-whisper.h +1 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Info.plist +0 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/_CodeSignature/CodeResources +1 -1
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/ggml-metal.metal +12436 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/rnwhisper +0 -0
- package/lib/commonjs/NativeRNWhisper.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/NativeRNWhisper.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/NativeRNWhisper.d.ts +2 -0
- package/lib/typescript/NativeRNWhisper.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/NativeRNWhisper.ts +2 -0
- package/src/version.json +1 -1
- package/whisper-rn.podspec +1 -1
- package/cpp/ggml-metal/ggml-whisper-sim.metallib +0 -0
- package/cpp/ggml-metal/ggml-whisper.metallib +0 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/ggml-whisper.metallib +0 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/ggml-whisper-sim.metallib +0 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/ggml-whisper.metallib +0 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/ggml-whisper-sim.metallib +0 -0
package/cpp/ggml-cpu/ggml-cpu.c
CHANGED
|
@@ -689,8 +689,13 @@ bool wsp_ggml_is_numa(void) {
|
|
|
689
689
|
#endif
|
|
690
690
|
|
|
691
691
|
static void wsp_ggml_init_arm_arch_features(void) {
|
|
692
|
-
#if defined(
|
|
692
|
+
#if defined(__aarch64__) && defined(__ARM_FEATURE_SVE)
|
|
693
|
+
#if defined(__linux__)
|
|
693
694
|
wsp_ggml_arm_arch_features.sve_cnt = PR_SVE_VL_LEN_MASK & prctl(PR_SVE_GET_VL);
|
|
695
|
+
#else
|
|
696
|
+
// TODO: add support of SVE for non-linux systems
|
|
697
|
+
#error "TODO: SVE is not supported on this platform. To use SVE, sve_cnt needs to be initialized here."
|
|
698
|
+
#endif
|
|
694
699
|
#endif
|
|
695
700
|
}
|
|
696
701
|
|
|
@@ -1608,13 +1613,8 @@ static void wsp_ggml_compute_forward_mul_mat_id(
|
|
|
1608
1613
|
chunk_size = 64;
|
|
1609
1614
|
}
|
|
1610
1615
|
|
|
1611
|
-
#if defined(__aarch64__)
|
|
1612
|
-
// disable for ARM
|
|
1613
|
-
const bool disable_chunking = true;
|
|
1614
|
-
#else
|
|
1615
1616
|
// disable for NUMA
|
|
1616
1617
|
const bool disable_chunking = wsp_ggml_is_numa();
|
|
1617
|
-
#endif // defined(__aarch64__)
|
|
1618
1618
|
|
|
1619
1619
|
int64_t nchunk0 = (nr0 + chunk_size - 1) / chunk_size;
|
|
1620
1620
|
int64_t nchunk1 = (nr1 + chunk_size - 1) / chunk_size;
|
|
@@ -1731,6 +1731,10 @@ static void wsp_ggml_compute_forward(struct wsp_ggml_compute_params * params, st
|
|
|
1731
1731
|
{
|
|
1732
1732
|
wsp_ggml_compute_forward_sum_rows(params, tensor);
|
|
1733
1733
|
} break;
|
|
1734
|
+
case WSP_GGML_OP_CUMSUM:
|
|
1735
|
+
{
|
|
1736
|
+
wsp_ggml_compute_forward_cumsum(params, tensor);
|
|
1737
|
+
} break;
|
|
1734
1738
|
case WSP_GGML_OP_MEAN:
|
|
1735
1739
|
{
|
|
1736
1740
|
wsp_ggml_compute_forward_mean(params, tensor);
|
|
@@ -1807,22 +1811,6 @@ static void wsp_ggml_compute_forward(struct wsp_ggml_compute_params * params, st
|
|
|
1807
1811
|
{
|
|
1808
1812
|
wsp_ggml_compute_forward_cont(params, tensor);
|
|
1809
1813
|
} break;
|
|
1810
|
-
case WSP_GGML_OP_RESHAPE:
|
|
1811
|
-
{
|
|
1812
|
-
wsp_ggml_compute_forward_reshape(params, tensor);
|
|
1813
|
-
} break;
|
|
1814
|
-
case WSP_GGML_OP_VIEW:
|
|
1815
|
-
{
|
|
1816
|
-
wsp_ggml_compute_forward_view(params, tensor);
|
|
1817
|
-
} break;
|
|
1818
|
-
case WSP_GGML_OP_PERMUTE:
|
|
1819
|
-
{
|
|
1820
|
-
wsp_ggml_compute_forward_permute(params, tensor);
|
|
1821
|
-
} break;
|
|
1822
|
-
case WSP_GGML_OP_TRANSPOSE:
|
|
1823
|
-
{
|
|
1824
|
-
wsp_ggml_compute_forward_transpose(params, tensor);
|
|
1825
|
-
} break;
|
|
1826
1814
|
case WSP_GGML_OP_GET_ROWS:
|
|
1827
1815
|
{
|
|
1828
1816
|
wsp_ggml_compute_forward_get_rows(params, tensor);
|
|
@@ -1943,6 +1931,14 @@ static void wsp_ggml_compute_forward(struct wsp_ggml_compute_params * params, st
|
|
|
1943
1931
|
{
|
|
1944
1932
|
wsp_ggml_compute_forward_leaky_relu(params, tensor);
|
|
1945
1933
|
} break;
|
|
1934
|
+
case WSP_GGML_OP_TRI:
|
|
1935
|
+
{
|
|
1936
|
+
wsp_ggml_compute_forward_tri(params, tensor);
|
|
1937
|
+
} break;
|
|
1938
|
+
case WSP_GGML_OP_FILL:
|
|
1939
|
+
{
|
|
1940
|
+
wsp_ggml_compute_forward_fill(params, tensor);
|
|
1941
|
+
} break;
|
|
1946
1942
|
case WSP_GGML_OP_FLASH_ATTN_EXT:
|
|
1947
1943
|
{
|
|
1948
1944
|
wsp_ggml_compute_forward_flash_attn_ext(params, tensor);
|
|
@@ -1998,6 +1994,10 @@ static void wsp_ggml_compute_forward(struct wsp_ggml_compute_params * params, st
|
|
|
1998
1994
|
{
|
|
1999
1995
|
wsp_ggml_compute_forward_rwkv_wkv7(params, tensor);
|
|
2000
1996
|
} break;
|
|
1997
|
+
case WSP_GGML_OP_SOLVE_TRI:
|
|
1998
|
+
{
|
|
1999
|
+
wsp_ggml_compute_forward_solve_tri(params, tensor);
|
|
2000
|
+
} break;
|
|
2001
2001
|
case WSP_GGML_OP_MAP_CUSTOM1:
|
|
2002
2002
|
{
|
|
2003
2003
|
wsp_ggml_compute_forward_map_custom1(params, tensor);
|
|
@@ -2042,6 +2042,22 @@ static void wsp_ggml_compute_forward(struct wsp_ggml_compute_params * params, st
|
|
|
2042
2042
|
{
|
|
2043
2043
|
// nop
|
|
2044
2044
|
} break;
|
|
2045
|
+
case WSP_GGML_OP_RESHAPE:
|
|
2046
|
+
{
|
|
2047
|
+
// nop
|
|
2048
|
+
} break;
|
|
2049
|
+
case WSP_GGML_OP_PERMUTE:
|
|
2050
|
+
{
|
|
2051
|
+
// nop
|
|
2052
|
+
} break;
|
|
2053
|
+
case WSP_GGML_OP_VIEW:
|
|
2054
|
+
{
|
|
2055
|
+
// nop
|
|
2056
|
+
} break;
|
|
2057
|
+
case WSP_GGML_OP_TRANSPOSE:
|
|
2058
|
+
{
|
|
2059
|
+
// nop
|
|
2060
|
+
} break;
|
|
2045
2061
|
case WSP_GGML_OP_COUNT:
|
|
2046
2062
|
{
|
|
2047
2063
|
WSP_GGML_ABORT("fatal error");
|
|
@@ -2140,6 +2156,9 @@ static int wsp_ggml_get_n_tasks(struct wsp_ggml_tensor * node, int n_threads) {
|
|
|
2140
2156
|
case WSP_GGML_OP_ADD_ID:
|
|
2141
2157
|
case WSP_GGML_OP_ADD1:
|
|
2142
2158
|
case WSP_GGML_OP_ACC:
|
|
2159
|
+
case WSP_GGML_OP_CUMSUM:
|
|
2160
|
+
case WSP_GGML_OP_TRI:
|
|
2161
|
+
case WSP_GGML_OP_FILL:
|
|
2143
2162
|
{
|
|
2144
2163
|
n_tasks = n_threads;
|
|
2145
2164
|
} break;
|
|
@@ -2157,6 +2176,7 @@ static int wsp_ggml_get_n_tasks(struct wsp_ggml_tensor * node, int n_threads) {
|
|
|
2157
2176
|
n_tasks = 1;
|
|
2158
2177
|
} break;
|
|
2159
2178
|
case WSP_GGML_OP_COUNT_EQUAL:
|
|
2179
|
+
case WSP_GGML_OP_SOLVE_TRI:
|
|
2160
2180
|
{
|
|
2161
2181
|
n_tasks = n_threads;
|
|
2162
2182
|
} break;
|
|
@@ -2179,6 +2199,12 @@ static int wsp_ggml_get_n_tasks(struct wsp_ggml_tensor * node, int n_threads) {
|
|
|
2179
2199
|
case WSP_GGML_UNARY_OP_HARDSWISH:
|
|
2180
2200
|
case WSP_GGML_UNARY_OP_HARDSIGMOID:
|
|
2181
2201
|
case WSP_GGML_UNARY_OP_EXP:
|
|
2202
|
+
case WSP_GGML_UNARY_OP_SOFTPLUS:
|
|
2203
|
+
case WSP_GGML_UNARY_OP_EXPM1:
|
|
2204
|
+
case WSP_GGML_UNARY_OP_FLOOR:
|
|
2205
|
+
case WSP_GGML_UNARY_OP_CEIL:
|
|
2206
|
+
case WSP_GGML_UNARY_OP_ROUND:
|
|
2207
|
+
case WSP_GGML_UNARY_OP_TRUNC:
|
|
2182
2208
|
{
|
|
2183
2209
|
n_tasks = 1;
|
|
2184
2210
|
} break;
|
|
@@ -2187,6 +2213,7 @@ static int wsp_ggml_get_n_tasks(struct wsp_ggml_tensor * node, int n_threads) {
|
|
|
2187
2213
|
case WSP_GGML_UNARY_OP_GELU_ERF:
|
|
2188
2214
|
case WSP_GGML_UNARY_OP_GELU_QUICK:
|
|
2189
2215
|
case WSP_GGML_UNARY_OP_SILU:
|
|
2216
|
+
case WSP_GGML_UNARY_OP_XIELU:
|
|
2190
2217
|
{
|
|
2191
2218
|
n_tasks = n_threads;
|
|
2192
2219
|
} break;
|
|
@@ -2879,6 +2906,11 @@ static thread_ret_t wsp_ggml_graph_compute_thread(void * data) {
|
|
|
2879
2906
|
for (int node_n = 0; node_n < cgraph->n_nodes && atomic_load_explicit(&tp->abort, memory_order_relaxed) != node_n; node_n++) {
|
|
2880
2907
|
struct wsp_ggml_tensor * node = cgraph->nodes[node_n];
|
|
2881
2908
|
|
|
2909
|
+
if (wsp_ggml_op_is_empty(node->op)) {
|
|
2910
|
+
// skip NOPs
|
|
2911
|
+
continue;
|
|
2912
|
+
}
|
|
2913
|
+
|
|
2882
2914
|
wsp_ggml_compute_forward(¶ms, node);
|
|
2883
2915
|
|
|
2884
2916
|
if (state->ith == 0 && cplan->abort_callback &&
|
|
@@ -3264,6 +3296,13 @@ void wsp_ggml_cpu_fp16_to_fp32(const wsp_ggml_fp16_t * x, float * y, int64_t n)
|
|
|
3264
3296
|
__m128 y_vec = _mm_cvtph_ps(x_vec);
|
|
3265
3297
|
_mm_storeu_ps(y + i, y_vec);
|
|
3266
3298
|
}
|
|
3299
|
+
#elif defined(__riscv_zvfh)
|
|
3300
|
+
for (int vl; i < n; i += vl) {
|
|
3301
|
+
vl = __riscv_vsetvl_e16m1(n - i);
|
|
3302
|
+
vfloat16m1_t vx = __riscv_vle16_v_f16m1((_Float16 *)&x[i], vl);
|
|
3303
|
+
vfloat32m2_t vy = __riscv_vfwcvt_f_f_v_f32m2(vx, vl);
|
|
3304
|
+
__riscv_vse32_v_f32m2(&y[i], vy, vl);
|
|
3305
|
+
}
|
|
3267
3306
|
#endif
|
|
3268
3307
|
|
|
3269
3308
|
for (; i < n; ++i) {
|
|
@@ -3557,13 +3596,17 @@ void wsp_ggml_cpu_init(void) {
|
|
|
3557
3596
|
#ifdef WSP_GGML_USE_OPENMP
|
|
3558
3597
|
//if (!getenv("OMP_WAIT_POLICY")) {
|
|
3559
3598
|
// // set the wait policy to active, so that OpenMP threads don't sleep
|
|
3560
|
-
//
|
|
3599
|
+
// setenv("OMP_WAIT_POLICY", "active", 0)
|
|
3561
3600
|
//}
|
|
3562
3601
|
|
|
3563
3602
|
if (!getenv("KMP_BLOCKTIME")) {
|
|
3564
3603
|
// set the time to wait before sleeping a thread
|
|
3565
3604
|
// this is less aggressive than setting the wait policy to active, but should achieve similar results in most cases
|
|
3566
|
-
|
|
3605
|
+
#ifdef _WIN32
|
|
3606
|
+
_putenv_s("KMP_BLOCKTIME", "200"); // 200ms
|
|
3607
|
+
#else
|
|
3608
|
+
setenv("KMP_BLOCKTIME", "200", 0); // 200ms
|
|
3609
|
+
#endif
|
|
3567
3610
|
}
|
|
3568
3611
|
#endif
|
|
3569
3612
|
}
|