whisper.rn 0.5.3 → 0.5.5
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/README.md +1 -1
- package/android/src/main/java/com/rnwhisper/WhisperContext.java +5 -0
- package/android/src/main/jni.cpp +13 -0
- package/cpp/ggml-alloc.c +78 -26
- package/cpp/ggml-alloc.h +9 -0
- package/cpp/ggml-backend-impl.h +1 -1
- package/cpp/ggml-backend-reg.cpp +19 -3
- package/cpp/ggml-backend.cpp +72 -20
- package/cpp/ggml-backend.h +2 -1
- package/cpp/ggml-cpu/arch/arm/cpu-feats.cpp +4 -0
- package/cpp/ggml-cpu/arch/arm/repack.cpp +1004 -0
- package/cpp/ggml-cpu/arch/x86/repack.cpp +6 -6
- package/cpp/ggml-cpu/arch-fallback.h +50 -2
- package/cpp/ggml-cpu/ggml-cpu-impl.h +1 -1
- package/cpp/ggml-cpu/ggml-cpu.c +139 -58
- package/cpp/ggml-cpu/ggml-cpu.cpp +4 -0
- package/cpp/ggml-cpu/ops.cpp +170 -18
- package/cpp/ggml-cpu/ops.h +1 -0
- package/cpp/ggml-cpu/repack.cpp +531 -5
- package/cpp/ggml-cpu/repack.h +14 -0
- package/cpp/ggml-cpu/simd-mappings.h +16 -18
- package/cpp/ggml-cpu/vec.cpp +41 -1
- package/cpp/ggml-cpu/vec.h +241 -138
- package/cpp/ggml-cpu.h +1 -0
- package/cpp/ggml-impl.h +0 -4
- package/cpp/ggml-metal/ggml-metal-context.m +26 -16
- package/cpp/ggml-metal/ggml-metal-device.cpp +452 -371
- package/cpp/ggml-metal/ggml-metal-device.h +87 -65
- package/cpp/ggml-metal/ggml-metal-device.m +263 -104
- package/cpp/ggml-metal/ggml-metal-impl.h +58 -4
- package/cpp/ggml-metal/ggml-metal-ops.cpp +415 -98
- package/cpp/ggml-metal/ggml-metal-ops.h +4 -0
- package/cpp/ggml-metal/ggml-metal.cpp +6 -5
- package/cpp/ggml-metal/ggml-metal.metal +404 -34
- package/cpp/ggml.c +110 -31
- package/cpp/ggml.h +51 -12
- package/cpp/jsi/RNWhisperJSI.cpp +1 -0
- package/cpp/whisper.cpp +17 -4
- package/ios/CMakeLists.txt +21 -1
- package/ios/RNWhisperContext.mm +5 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-alloc.h +9 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-backend-impl.h +1 -1
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-backend.h +2 -1
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-cpu.h +1 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-impl.h +0 -4
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml.h +51 -12
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Info.plist +0 -0
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/ggml-metal.metal +404 -34
- package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/rnwhisper +0 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-alloc.h +9 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend-impl.h +1 -1
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend.h +2 -1
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-cpu.h +1 -0
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-impl.h +0 -4
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml.h +51 -12
- 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 +404 -34
- package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/rnwhisper +0 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-alloc.h +9 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-backend-impl.h +1 -1
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-backend.h +2 -1
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-cpu.h +1 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-impl.h +0 -4
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml.h +51 -12
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Info.plist +0 -0
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/ggml-metal.metal +404 -34
- package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/rnwhisper +0 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-alloc.h +9 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend-impl.h +1 -1
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend.h +2 -1
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-cpu.h +1 -0
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-impl.h +0 -4
- package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml.h +51 -12
- 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 +404 -34
- 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/jest-mock.js +2 -0
- package/lib/commonjs/jest-mock.js.map +1 -1
- package/lib/commonjs/realtime-transcription/RealtimeTranscriber.js +156 -12
- package/lib/commonjs/realtime-transcription/RealtimeTranscriber.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/NativeRNWhisper.js.map +1 -1
- package/lib/module/jest-mock.js +2 -0
- package/lib/module/jest-mock.js.map +1 -1
- package/lib/module/realtime-transcription/RealtimeTranscriber.js +155 -12
- package/lib/module/realtime-transcription/RealtimeTranscriber.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/NativeRNWhisper.d.ts +1 -0
- package/lib/typescript/NativeRNWhisper.d.ts.map +1 -1
- package/lib/typescript/realtime-transcription/RealtimeTranscriber.d.ts +29 -0
- package/lib/typescript/realtime-transcription/RealtimeTranscriber.d.ts.map +1 -1
- package/lib/typescript/realtime-transcription/types.d.ts +7 -0
- package/lib/typescript/realtime-transcription/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/NativeRNWhisper.ts +1 -0
- package/src/jest-mock.ts +2 -0
- package/src/realtime-transcription/RealtimeTranscriber.ts +179 -9
- package/src/realtime-transcription/types.ts +9 -0
- package/src/version.json +1 -1
|
@@ -24,9 +24,6 @@ struct wsp_ggml_metal_command_buffer {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
struct wsp_ggml_metal {
|
|
27
|
-
id<MTLDevice> device;
|
|
28
|
-
id<MTLCommandQueue> queue; // currently a pointer to the device queue, but might become separate queue [TAG_QUEUE_PER_BACKEND]
|
|
29
|
-
|
|
30
27
|
wsp_ggml_metal_device_t dev;
|
|
31
28
|
wsp_ggml_metal_library_t lib;
|
|
32
29
|
|
|
@@ -91,15 +88,15 @@ wsp_ggml_metal_t wsp_ggml_metal_init(wsp_ggml_metal_device_t dev) {
|
|
|
91
88
|
// init context
|
|
92
89
|
wsp_ggml_metal_t res = calloc(1, sizeof(struct wsp_ggml_metal));
|
|
93
90
|
|
|
94
|
-
|
|
91
|
+
id<MTLDevice> device = wsp_ggml_metal_device_get_obj(dev);
|
|
95
92
|
|
|
96
|
-
WSP_GGML_LOG_INFO("%s: picking default device: %s\n", __func__, [[
|
|
93
|
+
WSP_GGML_LOG_INFO("%s: picking default device: %s\n", __func__, [[device name] UTF8String]);
|
|
97
94
|
|
|
98
95
|
// TODO: would it be better to have one queue for the backend and one queue for the device?
|
|
99
96
|
// the graph encoders and async ops would use the backend queue while the sync ops would use the device queue?
|
|
100
97
|
//res->queue = [device newCommandQueue]; [TAG_QUEUE_PER_BACKEND]
|
|
101
|
-
|
|
102
|
-
if (
|
|
98
|
+
id<MTLCommandQueue> queue = wsp_ggml_metal_device_get_queue(dev);
|
|
99
|
+
if (queue == nil) {
|
|
103
100
|
WSP_GGML_LOG_ERROR("%s: error: failed to create command queue\n", __func__);
|
|
104
101
|
return NULL;
|
|
105
102
|
}
|
|
@@ -274,7 +271,8 @@ static struct wsp_ggml_metal_buffer_id wsp_ggml_metal_get_buffer_id(const struct
|
|
|
274
271
|
void wsp_ggml_metal_set_tensor_async(wsp_ggml_metal_t ctx, struct wsp_ggml_tensor * tensor, const void * data, size_t offset, size_t size) {
|
|
275
272
|
@autoreleasepool {
|
|
276
273
|
// wrap the source data into a Metal buffer
|
|
277
|
-
id<
|
|
274
|
+
id<MTLDevice> device = wsp_ggml_metal_device_get_obj(ctx->dev);
|
|
275
|
+
id<MTLBuffer> buf_src = [device newBufferWithBytes:data
|
|
278
276
|
length:size
|
|
279
277
|
options:MTLResourceStorageModeShared];
|
|
280
278
|
|
|
@@ -289,7 +287,8 @@ void wsp_ggml_metal_set_tensor_async(wsp_ggml_metal_t ctx, struct wsp_ggml_tenso
|
|
|
289
287
|
|
|
290
288
|
// queue the copy operation into the queue of the Metal context
|
|
291
289
|
// this will be queued at the end, after any currently ongoing GPU operations
|
|
292
|
-
id<
|
|
290
|
+
id<MTLCommandQueue> queue = wsp_ggml_metal_device_get_queue(ctx->dev);
|
|
291
|
+
id<MTLCommandBuffer> cmd_buf = [queue commandBuffer];
|
|
293
292
|
id<MTLBlitCommandEncoder> encoder = [cmd_buf blitCommandEncoder];
|
|
294
293
|
|
|
295
294
|
[encoder copyFromBuffer:buf_src
|
|
@@ -315,7 +314,8 @@ void wsp_ggml_metal_set_tensor_async(wsp_ggml_metal_t ctx, struct wsp_ggml_tenso
|
|
|
315
314
|
|
|
316
315
|
void wsp_ggml_metal_get_tensor_async(wsp_ggml_metal_t ctx, const struct wsp_ggml_tensor * tensor, void * data, size_t offset, size_t size) {
|
|
317
316
|
@autoreleasepool {
|
|
318
|
-
id<
|
|
317
|
+
id<MTLDevice> device = wsp_ggml_metal_device_get_obj(ctx->dev);
|
|
318
|
+
id<MTLBuffer> buf_dst = [device newBufferWithBytesNoCopy:data
|
|
319
319
|
length:size
|
|
320
320
|
options:MTLResourceStorageModeShared
|
|
321
321
|
deallocator:nil];
|
|
@@ -331,7 +331,8 @@ void wsp_ggml_metal_get_tensor_async(wsp_ggml_metal_t ctx, const struct wsp_ggml
|
|
|
331
331
|
|
|
332
332
|
// queue the copy operation into the queue of the Metal context
|
|
333
333
|
// this will be queued at the end, after any currently ongoing GPU operations
|
|
334
|
-
id<
|
|
334
|
+
id<MTLCommandQueue> queue = wsp_ggml_metal_device_get_queue(ctx->dev);
|
|
335
|
+
id<MTLCommandBuffer> cmd_buf = [queue commandBuffer];
|
|
335
336
|
id<MTLBlitCommandEncoder> encoder = [cmd_buf blitCommandEncoder];
|
|
336
337
|
|
|
337
338
|
[encoder copyFromBuffer:bid_src.metal
|
|
@@ -362,6 +363,9 @@ enum wsp_ggml_status wsp_ggml_metal_graph_compute(wsp_ggml_metal_t ctx, struct w
|
|
|
362
363
|
// number of threads in addition to the main thread
|
|
363
364
|
const int n_cb = ctx->n_cb;
|
|
364
365
|
|
|
366
|
+
// keep the memory wired
|
|
367
|
+
wsp_ggml_metal_device_rsets_keep_alive(ctx->dev);
|
|
368
|
+
|
|
365
369
|
// submit the ggml compute graph to the GPU by creating command buffers and encoding the ops in them
|
|
366
370
|
// the first n_nodes_0 are encoded and submitted for processing directly by the calling thread
|
|
367
371
|
// while these nodes are processing, we start n_cb threads to enqueue the rest of the nodes
|
|
@@ -389,7 +393,8 @@ enum wsp_ggml_status wsp_ggml_metal_graph_compute(wsp_ggml_metal_t ctx, struct w
|
|
|
389
393
|
|
|
390
394
|
if (!ctx->capture_started) {
|
|
391
395
|
// create capture scope
|
|
392
|
-
|
|
396
|
+
id<MTLDevice> device = wsp_ggml_metal_device_get_obj(ctx->dev);
|
|
397
|
+
ctx->capture_scope = [[MTLCaptureManager sharedCaptureManager] newCaptureScopeWithDevice:device];
|
|
393
398
|
|
|
394
399
|
MTLCaptureDescriptor * descriptor = [MTLCaptureDescriptor new];
|
|
395
400
|
descriptor.captureObject = ctx->capture_scope;
|
|
@@ -406,10 +411,13 @@ enum wsp_ggml_status wsp_ggml_metal_graph_compute(wsp_ggml_metal_t ctx, struct w
|
|
|
406
411
|
}
|
|
407
412
|
}
|
|
408
413
|
|
|
414
|
+
// short-hand
|
|
415
|
+
id<MTLCommandQueue> queue = wsp_ggml_metal_device_get_queue(ctx->dev);
|
|
416
|
+
|
|
409
417
|
// the main thread commits the first few commands immediately
|
|
410
418
|
// cmd_buf[n_cb]
|
|
411
419
|
{
|
|
412
|
-
id<MTLCommandBuffer> cmd_buf = [
|
|
420
|
+
id<MTLCommandBuffer> cmd_buf = [queue commandBufferWithUnretainedReferences];
|
|
413
421
|
[cmd_buf retain];
|
|
414
422
|
|
|
415
423
|
if (ctx->cmd_bufs[n_cb].obj) {
|
|
@@ -428,7 +436,7 @@ enum wsp_ggml_status wsp_ggml_metal_graph_compute(wsp_ggml_metal_t ctx, struct w
|
|
|
428
436
|
// prepare the rest of the command buffers asynchronously (optional)
|
|
429
437
|
// cmd_buf[0.. n_cb)
|
|
430
438
|
for (int cb_idx = 0; cb_idx < n_cb; ++cb_idx) {
|
|
431
|
-
id<MTLCommandBuffer> cmd_buf = [
|
|
439
|
+
id<MTLCommandBuffer> cmd_buf = [queue commandBufferWithUnretainedReferences];
|
|
432
440
|
[cmd_buf retain];
|
|
433
441
|
|
|
434
442
|
if (ctx->cmd_bufs[cb_idx].obj) {
|
|
@@ -589,9 +597,11 @@ void wsp_ggml_metal_set_abort_callback(wsp_ggml_metal_t ctx, wsp_ggml_abort_call
|
|
|
589
597
|
}
|
|
590
598
|
|
|
591
599
|
bool wsp_ggml_metal_supports_family(wsp_ggml_metal_t ctx, int family) {
|
|
592
|
-
WSP_GGML_ASSERT(ctx->
|
|
600
|
+
WSP_GGML_ASSERT(ctx->dev != nil);
|
|
601
|
+
|
|
602
|
+
id<MTLDevice> device = wsp_ggml_metal_device_get_obj(ctx->dev);
|
|
593
603
|
|
|
594
|
-
return [
|
|
604
|
+
return [device supportsFamily:(MTLGPUFamilyApple1 + family - 1)];
|
|
595
605
|
}
|
|
596
606
|
|
|
597
607
|
void wsp_ggml_metal_capture_next_compute(wsp_ggml_metal_t ctx) {
|