cohere-transcribe 0.1.0

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.
Files changed (480) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +21 -0
  3. data/LICENSE.txt +201 -0
  4. data/NOTICE +5 -0
  5. data/README.md +265 -0
  6. data/THIRD_PARTY_NOTICES.md +67 -0
  7. data/exe/cohere-transcribe +8 -0
  8. data/exe/cohere-transcribe-doctor +8 -0
  9. data/ext/cohere_transcribe_native/CMakeLists.txt +262 -0
  10. data/ext/cohere_transcribe_native/README.md +26 -0
  11. data/ext/cohere_transcribe_native/audio_abi.cpp +1416 -0
  12. data/ext/cohere_transcribe_native/audio_exports.macos +5 -0
  13. data/ext/cohere_transcribe_native/audio_exports.map +10 -0
  14. data/ext/cohere_transcribe_native/cohere_abi.cpp +1209 -0
  15. data/ext/cohere_transcribe_native/exports.macos +40 -0
  16. data/ext/cohere_transcribe_native/exports.map +45 -0
  17. data/ext/cohere_transcribe_native/extconf.rb +89 -0
  18. data/ext/cohere_transcribe_native/test/abi_smoke.rb +232 -0
  19. data/ext/cohere_transcribe_native/test/audio_matrix_smoke.cpp +121 -0
  20. data/ext/cohere_transcribe_native/test/audio_reliability_smoke.cpp +198 -0
  21. data/ext/cohere_transcribe_native/test/native_abi_reliability_smoke.cpp +186 -0
  22. data/ext/cohere_transcribe_native/test/native_batch_projection_probe.rb +81 -0
  23. data/ext/cohere_transcribe_native/test/native_cancellation_smoke.cpp +194 -0
  24. data/lib/cohere/transcribe/alignment/ATTRIBUTION.md +23 -0
  25. data/lib/cohere/transcribe/alignment/LICENSE.ctc-forced-aligner +407 -0
  26. data/lib/cohere/transcribe/alignment/LICENSE.torchaudio +25 -0
  27. data/lib/cohere/transcribe/alignment/LICENSE.uroman +26 -0
  28. data/lib/cohere/transcribe/alignment/aligner.rb +476 -0
  29. data/lib/cohere/transcribe/alignment/ctc.rb +224 -0
  30. data/lib/cohere/transcribe/alignment/text.rb +237 -0
  31. data/lib/cohere/transcribe/alignment/uroman_data.rb +4950 -0
  32. data/lib/cohere/transcribe/api.rb +173 -0
  33. data/lib/cohere/transcribe/asr/batching.rb +472 -0
  34. data/lib/cohere/transcribe/asr/failure_policy.rb +112 -0
  35. data/lib/cohere/transcribe/asr/native.rb +676 -0
  36. data/lib/cohere/transcribe/audio/ATTRIBUTION.md +8 -0
  37. data/lib/cohere/transcribe/audio/LICENSE.auditok +21 -0
  38. data/lib/cohere/transcribe/audio/decoder.rb +315 -0
  39. data/lib/cohere/transcribe/audio/ffmpeg_native.rb +248 -0
  40. data/lib/cohere/transcribe/audio/segmentation.rb +260 -0
  41. data/lib/cohere/transcribe/cli.rb +727 -0
  42. data/lib/cohere/transcribe/configuration.rb +282 -0
  43. data/lib/cohere/transcribe/constants.rb +14 -0
  44. data/lib/cohere/transcribe/dense_converter.rb +548 -0
  45. data/lib/cohere/transcribe/doctor.rb +576 -0
  46. data/lib/cohere/transcribe/errors.rb +57 -0
  47. data/lib/cohere/transcribe/gguf_writer.rb +268 -0
  48. data/lib/cohere/transcribe/hub.rb +436 -0
  49. data/lib/cohere/transcribe/input.rb +110 -0
  50. data/lib/cohere/transcribe/licenses/crispasr.txt +21 -0
  51. data/lib/cohere/transcribe/loader.rb +128 -0
  52. data/lib/cohere/transcribe/model_identity.rb +440 -0
  53. data/lib/cohere/transcribe/output/publication.rb +1118 -0
  54. data/lib/cohere/transcribe/output/rendering.rb +105 -0
  55. data/lib/cohere/transcribe/output/timing.rb +86 -0
  56. data/lib/cohere/transcribe/python_text.rb +70 -0
  57. data/lib/cohere/transcribe/pytorch_checkpoint.rb +1180 -0
  58. data/lib/cohere/transcribe/runtime/engine.rb +1676 -0
  59. data/lib/cohere/transcribe/runtime/model_provider.rb +390 -0
  60. data/lib/cohere/transcribe/runtime/precision.rb +57 -0
  61. data/lib/cohere/transcribe/runtime/preparation.rb +215 -0
  62. data/lib/cohere/transcribe/runtime/resources.rb +165 -0
  63. data/lib/cohere/transcribe/runtime/word_pipeline.rb +364 -0
  64. data/lib/cohere/transcribe/safetensors.rb +579 -0
  65. data/lib/cohere/transcribe/state/checkpoint.rb +224 -0
  66. data/lib/cohere/transcribe/state/contracts.rb +141 -0
  67. data/lib/cohere/transcribe/state/io.rb +727 -0
  68. data/lib/cohere/transcribe/state/locking.rb +211 -0
  69. data/lib/cohere/transcribe/state/manifest.rb +155 -0
  70. data/lib/cohere/transcribe/state.rb +7 -0
  71. data/lib/cohere/transcribe/types.rb +535 -0
  72. data/lib/cohere/transcribe/vad/ATTRIBUTION.md +14 -0
  73. data/lib/cohere/transcribe/vad/LICENSE.faster-whisper +21 -0
  74. data/lib/cohere/transcribe/vad/LICENSE.silero-vad +21 -0
  75. data/lib/cohere/transcribe/vad/silero.rb +344 -0
  76. data/lib/cohere/transcribe/vad/silero_vad_v6.onnx +0 -0
  77. data/lib/cohere/transcribe/vad/timestamps.rb +219 -0
  78. data/lib/cohere/transcribe/version.rb +7 -0
  79. data/lib/cohere/transcribe.rb +26 -0
  80. data/sig/cohere/transcribe.rbs +250 -0
  81. data/vendor/crispasr/AUTHORS +510 -0
  82. data/vendor/crispasr/LICENSE +21 -0
  83. data/vendor/crispasr/UPSTREAM.md +9 -0
  84. data/vendor/crispasr/VERSION +1 -0
  85. data/vendor/crispasr/ggml/AUTHORS +335 -0
  86. data/vendor/crispasr/ggml/CMakeLists.txt +512 -0
  87. data/vendor/crispasr/ggml/LICENSE +21 -0
  88. data/vendor/crispasr/ggml/README.md +49 -0
  89. data/vendor/crispasr/ggml/cmake/FindNCCL.cmake +36 -0
  90. data/vendor/crispasr/ggml/cmake/GitVars.cmake +22 -0
  91. data/vendor/crispasr/ggml/cmake/common.cmake +50 -0
  92. data/vendor/crispasr/ggml/cmake/ggml-config.cmake.in +191 -0
  93. data/vendor/crispasr/ggml/ggml.pc.in +10 -0
  94. data/vendor/crispasr/ggml/include/ggml-alloc.h +85 -0
  95. data/vendor/crispasr/ggml/include/ggml-backend.h +431 -0
  96. data/vendor/crispasr/ggml/include/ggml-blas.h +25 -0
  97. data/vendor/crispasr/ggml/include/ggml-cann.h +123 -0
  98. data/vendor/crispasr/ggml/include/ggml-cpp.h +39 -0
  99. data/vendor/crispasr/ggml/include/ggml-cpu.h +151 -0
  100. data/vendor/crispasr/ggml/include/ggml-cuda.h +50 -0
  101. data/vendor/crispasr/ggml/include/ggml-hexagon.h +19 -0
  102. data/vendor/crispasr/ggml/include/ggml-metal.h +61 -0
  103. data/vendor/crispasr/ggml/include/ggml-opencl.h +26 -0
  104. data/vendor/crispasr/ggml/include/ggml-openvino.h +37 -0
  105. data/vendor/crispasr/ggml/include/ggml-opt.h +256 -0
  106. data/vendor/crispasr/ggml/include/ggml-rpc.h +35 -0
  107. data/vendor/crispasr/ggml/include/ggml-sycl.h +49 -0
  108. data/vendor/crispasr/ggml/include/ggml-virtgpu.h +14 -0
  109. data/vendor/crispasr/ggml/include/ggml-vulkan.h +29 -0
  110. data/vendor/crispasr/ggml/include/ggml-webgpu.h +19 -0
  111. data/vendor/crispasr/ggml/include/ggml-zdnn.h +17 -0
  112. data/vendor/crispasr/ggml/include/ggml-zendnn.h +22 -0
  113. data/vendor/crispasr/ggml/include/ggml.h +2887 -0
  114. data/vendor/crispasr/ggml/include/gguf.h +204 -0
  115. data/vendor/crispasr/ggml/src/CMakeLists.txt +493 -0
  116. data/vendor/crispasr/ggml/src/ggml-alloc.c +1323 -0
  117. data/vendor/crispasr/ggml/src/ggml-backend-dl.cpp +48 -0
  118. data/vendor/crispasr/ggml/src/ggml-backend-dl.h +44 -0
  119. data/vendor/crispasr/ggml/src/ggml-backend-impl.h +275 -0
  120. data/vendor/crispasr/ggml/src/ggml-backend-meta.cpp +2145 -0
  121. data/vendor/crispasr/ggml/src/ggml-backend-reg.cpp +586 -0
  122. data/vendor/crispasr/ggml/src/ggml-backend.cpp +2437 -0
  123. data/vendor/crispasr/ggml/src/ggml-common.h +1900 -0
  124. data/vendor/crispasr/ggml/src/ggml-cpu/CMakeLists.txt +718 -0
  125. data/vendor/crispasr/ggml/src/ggml-cpu/amx/amx.cpp +249 -0
  126. data/vendor/crispasr/ggml/src/ggml-cpu/amx/amx.h +8 -0
  127. data/vendor/crispasr/ggml/src/ggml-cpu/amx/common.h +115 -0
  128. data/vendor/crispasr/ggml/src/ggml-cpu/amx/mmq.cpp +2512 -0
  129. data/vendor/crispasr/ggml/src/ggml-cpu/amx/mmq.h +10 -0
  130. data/vendor/crispasr/ggml/src/ggml-cpu/arch/arm/cpu-feats.cpp +98 -0
  131. data/vendor/crispasr/ggml/src/ggml-cpu/arch/arm/quants.c +4244 -0
  132. data/vendor/crispasr/ggml/src/ggml-cpu/arch/arm/repack.cpp +5156 -0
  133. data/vendor/crispasr/ggml/src/ggml-cpu/arch/loongarch/quants.c +2158 -0
  134. data/vendor/crispasr/ggml/src/ggml-cpu/arch/powerpc/cpu-feats.cpp +82 -0
  135. data/vendor/crispasr/ggml/src/ggml-cpu/arch/powerpc/quants.c +2304 -0
  136. data/vendor/crispasr/ggml/src/ggml-cpu/arch/riscv/cpu-feats.cpp +38 -0
  137. data/vendor/crispasr/ggml/src/ggml-cpu/arch/riscv/quants.c +4455 -0
  138. data/vendor/crispasr/ggml/src/ggml-cpu/arch/riscv/repack.cpp +1703 -0
  139. data/vendor/crispasr/ggml/src/ggml-cpu/arch/s390/cpu-feats.cpp +50 -0
  140. data/vendor/crispasr/ggml/src/ggml-cpu/arch/s390/quants.c +1465 -0
  141. data/vendor/crispasr/ggml/src/ggml-cpu/arch/wasm/quants.c +1220 -0
  142. data/vendor/crispasr/ggml/src/ggml-cpu/arch/x86/cpu-feats.cpp +327 -0
  143. data/vendor/crispasr/ggml/src/ggml-cpu/arch/x86/quants.c +3970 -0
  144. data/vendor/crispasr/ggml/src/ggml-cpu/arch/x86/repack.cpp +6407 -0
  145. data/vendor/crispasr/ggml/src/ggml-cpu/arch-fallback.h +349 -0
  146. data/vendor/crispasr/ggml/src/ggml-cpu/binary-ops.cpp +154 -0
  147. data/vendor/crispasr/ggml/src/ggml-cpu/binary-ops.h +16 -0
  148. data/vendor/crispasr/ggml/src/ggml-cpu/cmake/FindSIMD.cmake +100 -0
  149. data/vendor/crispasr/ggml/src/ggml-cpu/common.h +95 -0
  150. data/vendor/crispasr/ggml/src/ggml-cpu/ggml-cpu-impl.h +539 -0
  151. data/vendor/crispasr/ggml/src/ggml-cpu/ggml-cpu.c +3791 -0
  152. data/vendor/crispasr/ggml/src/ggml-cpu/ggml-cpu.cpp +703 -0
  153. data/vendor/crispasr/ggml/src/ggml-cpu/hbm.cpp +55 -0
  154. data/vendor/crispasr/ggml/src/ggml-cpu/hbm.h +8 -0
  155. data/vendor/crispasr/ggml/src/ggml-cpu/kleidiai/kernels.cpp +939 -0
  156. data/vendor/crispasr/ggml/src/ggml-cpu/kleidiai/kernels.h +90 -0
  157. data/vendor/crispasr/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp +1513 -0
  158. data/vendor/crispasr/ggml/src/ggml-cpu/kleidiai/kleidiai.h +17 -0
  159. data/vendor/crispasr/ggml/src/ggml-cpu/llamafile/sgemm.cpp +4051 -0
  160. data/vendor/crispasr/ggml/src/ggml-cpu/llamafile/sgemm.h +25 -0
  161. data/vendor/crispasr/ggml/src/ggml-cpu/ops.cpp +11662 -0
  162. data/vendor/crispasr/ggml/src/ggml-cpu/ops.h +121 -0
  163. data/vendor/crispasr/ggml/src/ggml-cpu/quants.c +1288 -0
  164. data/vendor/crispasr/ggml/src/ggml-cpu/quants.h +103 -0
  165. data/vendor/crispasr/ggml/src/ggml-cpu/repack.cpp +4836 -0
  166. data/vendor/crispasr/ggml/src/ggml-cpu/repack.h +245 -0
  167. data/vendor/crispasr/ggml/src/ggml-cpu/simd-gemm.h +226 -0
  168. data/vendor/crispasr/ggml/src/ggml-cpu/simd-mappings.h +1329 -0
  169. data/vendor/crispasr/ggml/src/ggml-cpu/spacemit/ime.cpp +1025 -0
  170. data/vendor/crispasr/ggml/src/ggml-cpu/spacemit/ime.h +13 -0
  171. data/vendor/crispasr/ggml/src/ggml-cpu/spacemit/ime1_kernels.cpp +3196 -0
  172. data/vendor/crispasr/ggml/src/ggml-cpu/spacemit/ime_kernels.h +26 -0
  173. data/vendor/crispasr/ggml/src/ggml-cpu/traits.cpp +36 -0
  174. data/vendor/crispasr/ggml/src/ggml-cpu/traits.h +38 -0
  175. data/vendor/crispasr/ggml/src/ggml-cpu/unary-ops.cpp +336 -0
  176. data/vendor/crispasr/ggml/src/ggml-cpu/unary-ops.h +35 -0
  177. data/vendor/crispasr/ggml/src/ggml-cpu/vec.cpp +681 -0
  178. data/vendor/crispasr/ggml/src/ggml-cpu/vec.h +1606 -0
  179. data/vendor/crispasr/ggml/src/ggml-cuda/CMakeLists.txt +272 -0
  180. data/vendor/crispasr/ggml/src/ggml-cuda/acc.cu +61 -0
  181. data/vendor/crispasr/ggml/src/ggml-cuda/acc.cuh +5 -0
  182. data/vendor/crispasr/ggml/src/ggml-cuda/add-id.cu +58 -0
  183. data/vendor/crispasr/ggml/src/ggml-cuda/add-id.cuh +3 -0
  184. data/vendor/crispasr/ggml/src/ggml-cuda/arange.cu +34 -0
  185. data/vendor/crispasr/ggml/src/ggml-cuda/arange.cuh +5 -0
  186. data/vendor/crispasr/ggml/src/ggml-cuda/argmax.cu +91 -0
  187. data/vendor/crispasr/ggml/src/ggml-cuda/argmax.cuh +3 -0
  188. data/vendor/crispasr/ggml/src/ggml-cuda/argsort.cu +265 -0
  189. data/vendor/crispasr/ggml/src/ggml-cuda/argsort.cuh +19 -0
  190. data/vendor/crispasr/ggml/src/ggml-cuda/binbcast.cu +534 -0
  191. data/vendor/crispasr/ggml/src/ggml-cuda/binbcast.cuh +12 -0
  192. data/vendor/crispasr/ggml/src/ggml-cuda/clamp.cu +45 -0
  193. data/vendor/crispasr/ggml/src/ggml-cuda/clamp.cuh +5 -0
  194. data/vendor/crispasr/ggml/src/ggml-cuda/col2im-1d.cu +81 -0
  195. data/vendor/crispasr/ggml/src/ggml-cuda/col2im-1d.cuh +3 -0
  196. data/vendor/crispasr/ggml/src/ggml-cuda/common.cuh +1489 -0
  197. data/vendor/crispasr/ggml/src/ggml-cuda/concat.cu +204 -0
  198. data/vendor/crispasr/ggml/src/ggml-cuda/concat.cuh +5 -0
  199. data/vendor/crispasr/ggml/src/ggml-cuda/conv-transpose-1d.cu +97 -0
  200. data/vendor/crispasr/ggml/src/ggml-cuda/conv-transpose-1d.cuh +5 -0
  201. data/vendor/crispasr/ggml/src/ggml-cuda/conv2d-dw.cu +161 -0
  202. data/vendor/crispasr/ggml/src/ggml-cuda/conv2d-dw.cuh +5 -0
  203. data/vendor/crispasr/ggml/src/ggml-cuda/conv2d-transpose.cu +115 -0
  204. data/vendor/crispasr/ggml/src/ggml-cuda/conv2d-transpose.cuh +5 -0
  205. data/vendor/crispasr/ggml/src/ggml-cuda/conv2d.cu +166 -0
  206. data/vendor/crispasr/ggml/src/ggml-cuda/conv2d.cuh +5 -0
  207. data/vendor/crispasr/ggml/src/ggml-cuda/convert.cu +892 -0
  208. data/vendor/crispasr/ggml/src/ggml-cuda/convert.cuh +66 -0
  209. data/vendor/crispasr/ggml/src/ggml-cuda/count-equal.cu +64 -0
  210. data/vendor/crispasr/ggml/src/ggml-cuda/count-equal.cuh +5 -0
  211. data/vendor/crispasr/ggml/src/ggml-cuda/cp-async.cuh +57 -0
  212. data/vendor/crispasr/ggml/src/ggml-cuda/cpy-utils.cuh +217 -0
  213. data/vendor/crispasr/ggml/src/ggml-cuda/cpy.cu +581 -0
  214. data/vendor/crispasr/ggml/src/ggml-cuda/cpy.cuh +7 -0
  215. data/vendor/crispasr/ggml/src/ggml-cuda/cross-entropy-loss.cu +177 -0
  216. data/vendor/crispasr/ggml/src/ggml-cuda/cross-entropy-loss.cuh +7 -0
  217. data/vendor/crispasr/ggml/src/ggml-cuda/cumsum.cu +307 -0
  218. data/vendor/crispasr/ggml/src/ggml-cuda/cumsum.cuh +5 -0
  219. data/vendor/crispasr/ggml/src/ggml-cuda/dequantize.cuh +99 -0
  220. data/vendor/crispasr/ggml/src/ggml-cuda/diag.cu +77 -0
  221. data/vendor/crispasr/ggml/src/ggml-cuda/diag.cuh +5 -0
  222. data/vendor/crispasr/ggml/src/ggml-cuda/diagmask.cu +40 -0
  223. data/vendor/crispasr/ggml/src/ggml-cuda/diagmask.cuh +5 -0
  224. data/vendor/crispasr/ggml/src/ggml-cuda/fattn-common.cuh +1212 -0
  225. data/vendor/crispasr/ggml/src/ggml-cuda/fattn-mma-f16.cuh +1860 -0
  226. data/vendor/crispasr/ggml/src/ggml-cuda/fattn-tile.cu +57 -0
  227. data/vendor/crispasr/ggml/src/ggml-cuda/fattn-tile.cuh +1309 -0
  228. data/vendor/crispasr/ggml/src/ggml-cuda/fattn-vec.cuh +600 -0
  229. data/vendor/crispasr/ggml/src/ggml-cuda/fattn-wmma-f16.cu +696 -0
  230. data/vendor/crispasr/ggml/src/ggml-cuda/fattn-wmma-f16.cuh +51 -0
  231. data/vendor/crispasr/ggml/src/ggml-cuda/fattn.cu +620 -0
  232. data/vendor/crispasr/ggml/src/ggml-cuda/fattn.cuh +5 -0
  233. data/vendor/crispasr/ggml/src/ggml-cuda/fill.cu +37 -0
  234. data/vendor/crispasr/ggml/src/ggml-cuda/fill.cuh +3 -0
  235. data/vendor/crispasr/ggml/src/ggml-cuda/gated_delta_net.cu +273 -0
  236. data/vendor/crispasr/ggml/src/ggml-cuda/gated_delta_net.cuh +4 -0
  237. data/vendor/crispasr/ggml/src/ggml-cuda/getrows.cu +332 -0
  238. data/vendor/crispasr/ggml/src/ggml-cuda/getrows.cuh +15 -0
  239. data/vendor/crispasr/ggml/src/ggml-cuda/ggml-cuda.cu +5580 -0
  240. data/vendor/crispasr/ggml/src/ggml-cuda/gla.cu +93 -0
  241. data/vendor/crispasr/ggml/src/ggml-cuda/gla.cuh +3 -0
  242. data/vendor/crispasr/ggml/src/ggml-cuda/im2col.cu +274 -0
  243. data/vendor/crispasr/ggml/src/ggml-cuda/im2col.cuh +6 -0
  244. data/vendor/crispasr/ggml/src/ggml-cuda/mean.cu +75 -0
  245. data/vendor/crispasr/ggml/src/ggml-cuda/mean.cuh +3 -0
  246. data/vendor/crispasr/ggml/src/ggml-cuda/mma.cuh +1333 -0
  247. data/vendor/crispasr/ggml/src/ggml-cuda/mmf.cu +191 -0
  248. data/vendor/crispasr/ggml/src/ggml-cuda/mmf.cuh +908 -0
  249. data/vendor/crispasr/ggml/src/ggml-cuda/mmid.cu +164 -0
  250. data/vendor/crispasr/ggml/src/ggml-cuda/mmid.cuh +5 -0
  251. data/vendor/crispasr/ggml/src/ggml-cuda/mmq.cu +372 -0
  252. data/vendor/crispasr/ggml/src/ggml-cuda/mmq.cuh +4175 -0
  253. data/vendor/crispasr/ggml/src/ggml-cuda/mmvf.cu +862 -0
  254. data/vendor/crispasr/ggml/src/ggml-cuda/mmvf.cuh +14 -0
  255. data/vendor/crispasr/ggml/src/ggml-cuda/mmvq.cu +1161 -0
  256. data/vendor/crispasr/ggml/src/ggml-cuda/mmvq.cuh +16 -0
  257. data/vendor/crispasr/ggml/src/ggml-cuda/norm.cu +756 -0
  258. data/vendor/crispasr/ggml/src/ggml-cuda/norm.cuh +20 -0
  259. data/vendor/crispasr/ggml/src/ggml-cuda/opt-step-adamw.cu +78 -0
  260. data/vendor/crispasr/ggml/src/ggml-cuda/opt-step-adamw.cuh +5 -0
  261. data/vendor/crispasr/ggml/src/ggml-cuda/opt-step-sgd.cu +49 -0
  262. data/vendor/crispasr/ggml/src/ggml-cuda/opt-step-sgd.cuh +5 -0
  263. data/vendor/crispasr/ggml/src/ggml-cuda/out-prod.cu +68 -0
  264. data/vendor/crispasr/ggml/src/ggml-cuda/out-prod.cuh +3 -0
  265. data/vendor/crispasr/ggml/src/ggml-cuda/pad.cu +106 -0
  266. data/vendor/crispasr/ggml/src/ggml-cuda/pad.cuh +5 -0
  267. data/vendor/crispasr/ggml/src/ggml-cuda/pad_reflect_1d.cu +91 -0
  268. data/vendor/crispasr/ggml/src/ggml-cuda/pad_reflect_1d.cuh +5 -0
  269. data/vendor/crispasr/ggml/src/ggml-cuda/pool2d.cu +94 -0
  270. data/vendor/crispasr/ggml/src/ggml-cuda/pool2d.cuh +5 -0
  271. data/vendor/crispasr/ggml/src/ggml-cuda/quantize.cu +443 -0
  272. data/vendor/crispasr/ggml/src/ggml-cuda/quantize.cuh +41 -0
  273. data/vendor/crispasr/ggml/src/ggml-cuda/reduce_rows.cuh +39 -0
  274. data/vendor/crispasr/ggml/src/ggml-cuda/roll.cu +67 -0
  275. data/vendor/crispasr/ggml/src/ggml-cuda/roll.cuh +5 -0
  276. data/vendor/crispasr/ggml/src/ggml-cuda/rope.cu +665 -0
  277. data/vendor/crispasr/ggml/src/ggml-cuda/rope.cuh +9 -0
  278. data/vendor/crispasr/ggml/src/ggml-cuda/scale.cu +34 -0
  279. data/vendor/crispasr/ggml/src/ggml-cuda/scale.cuh +5 -0
  280. data/vendor/crispasr/ggml/src/ggml-cuda/set-rows.cu +330 -0
  281. data/vendor/crispasr/ggml/src/ggml-cuda/set-rows.cuh +7 -0
  282. data/vendor/crispasr/ggml/src/ggml-cuda/set.cu +39 -0
  283. data/vendor/crispasr/ggml/src/ggml-cuda/set.cuh +7 -0
  284. data/vendor/crispasr/ggml/src/ggml-cuda/softcap.cu +34 -0
  285. data/vendor/crispasr/ggml/src/ggml-cuda/softcap.cuh +5 -0
  286. data/vendor/crispasr/ggml/src/ggml-cuda/softmax.cu +472 -0
  287. data/vendor/crispasr/ggml/src/ggml-cuda/softmax.cuh +7 -0
  288. data/vendor/crispasr/ggml/src/ggml-cuda/solve_tri.cu +275 -0
  289. data/vendor/crispasr/ggml/src/ggml-cuda/solve_tri.cuh +3 -0
  290. data/vendor/crispasr/ggml/src/ggml-cuda/ssm-conv.cu +197 -0
  291. data/vendor/crispasr/ggml/src/ggml-cuda/ssm-conv.cuh +3 -0
  292. data/vendor/crispasr/ggml/src/ggml-cuda/ssm-scan.cu +342 -0
  293. data/vendor/crispasr/ggml/src/ggml-cuda/ssm-scan.cuh +3 -0
  294. data/vendor/crispasr/ggml/src/ggml-cuda/sum.cu +41 -0
  295. data/vendor/crispasr/ggml/src/ggml-cuda/sum.cuh +5 -0
  296. data/vendor/crispasr/ggml/src/ggml-cuda/sumrows.cu +43 -0
  297. data/vendor/crispasr/ggml/src/ggml-cuda/sumrows.cuh +4 -0
  298. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_1-ncols2_16.cu +5 -0
  299. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_1-ncols2_32.cu +6 -0
  300. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_1-ncols2_8.cu +11 -0
  301. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_1.cu +10 -0
  302. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_2.cu +10 -0
  303. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_4.cu +12 -0
  304. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_16.cu +5 -0
  305. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_32.cu +6 -0
  306. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_4.cu +12 -0
  307. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_8.cu +11 -0
  308. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_32-ncols2_1.cu +10 -0
  309. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_32-ncols2_2.cu +10 -0
  310. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_16.cu +5 -0
  311. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_2.cu +10 -0
  312. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_4.cu +12 -0
  313. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_8.cu +11 -0
  314. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_64-ncols2_1.cu +10 -0
  315. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_1.cu +10 -0
  316. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_2.cu +10 -0
  317. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_4.cu +12 -0
  318. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_8.cu +11 -0
  319. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq112-dv112.cu +5 -0
  320. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq128-dv128.cu +5 -0
  321. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq256-dv256.cu +5 -0
  322. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq320-dv256.cu +5 -0
  323. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq40-dv40.cu +5 -0
  324. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq512-dv512.cu +5 -0
  325. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq576-dv512.cu +5 -0
  326. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq64-dv64.cu +5 -0
  327. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq72-dv72.cu +5 -0
  328. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq80-dv80.cu +5 -0
  329. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq96-dv96.cu +5 -0
  330. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-bf16.cu +7 -0
  331. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-f16.cu +7 -0
  332. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q4_0.cu +7 -0
  333. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q4_1.cu +7 -0
  334. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q5_0.cu +7 -0
  335. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q5_1.cu +7 -0
  336. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q8_0.cu +7 -0
  337. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-bf16.cu +7 -0
  338. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-f16.cu +7 -0
  339. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q4_0.cu +7 -0
  340. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q4_1.cu +7 -0
  341. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q5_0.cu +7 -0
  342. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q5_1.cu +7 -0
  343. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q8_0.cu +7 -0
  344. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-bf16.cu +7 -0
  345. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-f16.cu +7 -0
  346. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q4_0.cu +7 -0
  347. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q4_1.cu +7 -0
  348. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q5_0.cu +7 -0
  349. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q5_1.cu +7 -0
  350. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q8_0.cu +7 -0
  351. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-bf16.cu +7 -0
  352. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-f16.cu +7 -0
  353. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q4_0.cu +7 -0
  354. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q4_1.cu +7 -0
  355. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q5_0.cu +7 -0
  356. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q5_1.cu +7 -0
  357. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q8_0.cu +7 -0
  358. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-bf16.cu +7 -0
  359. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-f16.cu +7 -0
  360. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q4_0.cu +7 -0
  361. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q4_1.cu +7 -0
  362. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q5_0.cu +7 -0
  363. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q5_1.cu +7 -0
  364. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q8_0.cu +7 -0
  365. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-bf16.cu +7 -0
  366. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-f16.cu +7 -0
  367. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q4_0.cu +7 -0
  368. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q4_1.cu +7 -0
  369. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q5_0.cu +7 -0
  370. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q5_1.cu +7 -0
  371. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q8_0.cu +7 -0
  372. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-bf16.cu +7 -0
  373. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-f16.cu +7 -0
  374. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q4_0.cu +7 -0
  375. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q4_1.cu +7 -0
  376. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q5_0.cu +7 -0
  377. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q5_1.cu +7 -0
  378. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q8_0.cu +7 -0
  379. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_1.cu +5 -0
  380. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_10.cu +5 -0
  381. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_11.cu +5 -0
  382. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_12.cu +5 -0
  383. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_13.cu +5 -0
  384. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_14.cu +5 -0
  385. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_15.cu +5 -0
  386. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_16.cu +5 -0
  387. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_2.cu +5 -0
  388. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_3.cu +5 -0
  389. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_4.cu +5 -0
  390. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_5.cu +5 -0
  391. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_6.cu +5 -0
  392. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_7.cu +5 -0
  393. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_8.cu +5 -0
  394. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_9.cu +5 -0
  395. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq1_s.cu +5 -0
  396. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_s.cu +5 -0
  397. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_xs.cu +5 -0
  398. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_xxs.cu +5 -0
  399. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq3_s.cu +5 -0
  400. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq3_xxs.cu +5 -0
  401. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq4_nl.cu +5 -0
  402. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq4_xs.cu +5 -0
  403. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-mxfp4.cu +5 -0
  404. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-nvfp4.cu +5 -0
  405. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q1_0.cu +5 -0
  406. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q2_k.cu +5 -0
  407. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q3_k.cu +5 -0
  408. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_0.cu +5 -0
  409. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_1.cu +5 -0
  410. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_k.cu +5 -0
  411. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_0.cu +5 -0
  412. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_1.cu +5 -0
  413. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_k.cu +5 -0
  414. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q6_k.cu +5 -0
  415. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q8_0.cu +5 -0
  416. data/vendor/crispasr/ggml/src/ggml-cuda/top-k.cu +95 -0
  417. data/vendor/crispasr/ggml/src/ggml-cuda/top-k.cuh +3 -0
  418. data/vendor/crispasr/ggml/src/ggml-cuda/topk-moe.cu +415 -0
  419. data/vendor/crispasr/ggml/src/ggml-cuda/topk-moe.cuh +27 -0
  420. data/vendor/crispasr/ggml/src/ggml-cuda/tri.cu +136 -0
  421. data/vendor/crispasr/ggml/src/ggml-cuda/tri.cuh +5 -0
  422. data/vendor/crispasr/ggml/src/ggml-cuda/tsembd.cu +47 -0
  423. data/vendor/crispasr/ggml/src/ggml-cuda/tsembd.cuh +5 -0
  424. data/vendor/crispasr/ggml/src/ggml-cuda/unary.cu +644 -0
  425. data/vendor/crispasr/ggml/src/ggml-cuda/unary.cuh +116 -0
  426. data/vendor/crispasr/ggml/src/ggml-cuda/upscale.cu +293 -0
  427. data/vendor/crispasr/ggml/src/ggml-cuda/upscale.cuh +5 -0
  428. data/vendor/crispasr/ggml/src/ggml-cuda/vecdotq.cuh +1317 -0
  429. data/vendor/crispasr/ggml/src/ggml-cuda/vendors/cuda.h +28 -0
  430. data/vendor/crispasr/ggml/src/ggml-cuda/vendors/hip.h +306 -0
  431. data/vendor/crispasr/ggml/src/ggml-cuda/vendors/musa.h +148 -0
  432. data/vendor/crispasr/ggml/src/ggml-cuda/wkv.cu +199 -0
  433. data/vendor/crispasr/ggml/src/ggml-cuda/wkv.cuh +7 -0
  434. data/vendor/crispasr/ggml/src/ggml-impl.h +783 -0
  435. data/vendor/crispasr/ggml/src/ggml-metal/CMakeLists.txt +124 -0
  436. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-common.cpp +457 -0
  437. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-common.h +52 -0
  438. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-context.h +41 -0
  439. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-context.m +778 -0
  440. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-device.cpp +2117 -0
  441. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-device.h +299 -0
  442. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-device.m +2093 -0
  443. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-impl.h +1267 -0
  444. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-ops.cpp +5023 -0
  445. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-ops.h +111 -0
  446. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal.cpp +954 -0
  447. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal.metal +11756 -0
  448. data/vendor/crispasr/ggml/src/ggml-opt.cpp +1094 -0
  449. data/vendor/crispasr/ggml/src/ggml-quants.c +5491 -0
  450. data/vendor/crispasr/ggml/src/ggml-quants.h +112 -0
  451. data/vendor/crispasr/ggml/src/ggml-threading.cpp +12 -0
  452. data/vendor/crispasr/ggml/src/ggml-threading.h +14 -0
  453. data/vendor/crispasr/ggml/src/ggml.c +7925 -0
  454. data/vendor/crispasr/ggml/src/ggml.cpp +26 -0
  455. data/vendor/crispasr/ggml/src/gguf.cpp +1556 -0
  456. data/vendor/crispasr/src/cohere-arch.h +137 -0
  457. data/vendor/crispasr/src/cohere.cpp +5642 -0
  458. data/vendor/crispasr/src/cohere.h +327 -0
  459. data/vendor/crispasr/src/cohere_batch_planner.h +82 -0
  460. data/vendor/crispasr/src/cohere_chunking.h +64 -0
  461. data/vendor/crispasr/src/cohere_decoder_batch_layout.h +60 -0
  462. data/vendor/crispasr/src/cohere_encoder_padded_layout.h +27 -0
  463. data/vendor/crispasr/src/cohere_frontend.cpp +189 -0
  464. data/vendor/crispasr/src/cohere_frontend.h +31 -0
  465. data/vendor/crispasr/src/cohere_ragged_controller.h +149 -0
  466. data/vendor/crispasr/src/cohere_token_renderer.h +181 -0
  467. data/vendor/crispasr/src/core/attention.h +924 -0
  468. data/vendor/crispasr/src/core/audio_chunking.h +97 -0
  469. data/vendor/crispasr/src/core/beam_decode.h +486 -0
  470. data/vendor/crispasr/src/core/cpu_ops.h +135 -0
  471. data/vendor/crispasr/src/core/gguf_loader.cpp +1021 -0
  472. data/vendor/crispasr/src/core/gguf_loader.h +216 -0
  473. data/vendor/crispasr/src/core/gpu_backend_pref.h +119 -0
  474. data/vendor/crispasr/src/core/mel.cpp +519 -0
  475. data/vendor/crispasr/src/core/mel.h +265 -0
  476. data/vendor/crispasr/src/core/ngram_loop_fix.h +173 -0
  477. data/vendor/crispasr/src/core/repetition_loop_guard.h +54 -0
  478. data/vendor/crispasr/src/crispasr_imatrix.cpp +255 -0
  479. data/vendor/crispasr/src/crispasr_imatrix.h +38 -0
  480. metadata +596 -0
@@ -0,0 +1,40 @@
1
+ _crispasr_bf16_to_fp32_row
2
+ _crispasr_fp16_to_fp32_row
3
+ _crispasr_fp32_to_fp16_row
4
+ _crispasr_fp32_to_bf16_row
5
+ _crispasr_last_error_kind
6
+ _crispasr_last_error_message
7
+ _crispasr_runtime_resolve_device
8
+ _crispasr_runtime_supports_bf16
9
+ _crispasr_set_gpu_backend
10
+ _crispasr_session_open_with_params
11
+ _crispasr_session_backend
12
+ _crispasr_session_compute_backend
13
+ _crispasr_session_memory
14
+ _crispasr_session_batch_capacity
15
+ _crispasr_session_cancel
16
+ _crispasr_session_transcribe_lang
17
+ _crispasr_session_transcribe_batch_lang
18
+ _crispasr_session_batch_result_count
19
+ _crispasr_session_batch_result_stats_v1
20
+ _crispasr_session_batch_result_at
21
+ _crispasr_session_batch_result_free
22
+ _crispasr_session_result_n_segments
23
+ _crispasr_session_result_segment_text
24
+ _crispasr_session_result_segment_t0
25
+ _crispasr_session_result_segment_t1
26
+ _crispasr_session_result_n_words
27
+ _crispasr_session_result_word_text
28
+ _crispasr_session_result_word_t0
29
+ _crispasr_session_result_word_t1
30
+ _crispasr_session_result_word_p
31
+ _crispasr_session_result_generated_tokens
32
+ _crispasr_session_result_generation_limit
33
+ _crispasr_session_result_generation_capacity
34
+ _crispasr_session_result_stopped_by_max_tokens
35
+ _crispasr_session_result_repetition_stopped
36
+ _crispasr_session_result_free
37
+ _crispasr_session_close
38
+ _crispasr_session_set_max_new_tokens
39
+ _crispasr_session_set_beam_size
40
+ _crispasr_session_set_repetition_loop_guard
@@ -0,0 +1,45 @@
1
+ {
2
+ global:
3
+ crispasr_bf16_to_fp32_row;
4
+ crispasr_fp16_to_fp32_row;
5
+ crispasr_fp32_to_fp16_row;
6
+ crispasr_fp32_to_bf16_row;
7
+ crispasr_last_error_kind;
8
+ crispasr_last_error_message;
9
+ crispasr_runtime_resolve_device;
10
+ crispasr_runtime_supports_bf16;
11
+ crispasr_set_gpu_backend;
12
+ crispasr_session_open_with_params;
13
+ crispasr_session_backend;
14
+ crispasr_session_compute_backend;
15
+ crispasr_session_memory;
16
+ crispasr_session_batch_capacity;
17
+ crispasr_session_cancel;
18
+ crispasr_session_transcribe_lang;
19
+ crispasr_session_transcribe_batch_lang;
20
+ crispasr_session_batch_result_count;
21
+ crispasr_session_batch_result_stats_v1;
22
+ crispasr_session_batch_result_at;
23
+ crispasr_session_batch_result_free;
24
+ crispasr_session_result_n_segments;
25
+ crispasr_session_result_segment_text;
26
+ crispasr_session_result_segment_t0;
27
+ crispasr_session_result_segment_t1;
28
+ crispasr_session_result_n_words;
29
+ crispasr_session_result_word_text;
30
+ crispasr_session_result_word_t0;
31
+ crispasr_session_result_word_t1;
32
+ crispasr_session_result_word_p;
33
+ crispasr_session_result_generated_tokens;
34
+ crispasr_session_result_generation_limit;
35
+ crispasr_session_result_generation_capacity;
36
+ crispasr_session_result_stopped_by_max_tokens;
37
+ crispasr_session_result_repetition_stopped;
38
+ crispasr_session_result_free;
39
+ crispasr_session_close;
40
+ crispasr_session_set_max_new_tokens;
41
+ crispasr_session_set_beam_size;
42
+ crispasr_session_set_repetition_loop_guard;
43
+ local:
44
+ *;
45
+ };
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
4
+ require "rbconfig"
5
+ require "shellwords"
6
+
7
+ EXTENSION_DIR = File.expand_path(__dir__)
8
+ GEM_ROOT = File.expand_path("../..", EXTENSION_DIR)
9
+
10
+ def enabled?(name)
11
+ value = ENV.fetch(name, nil)
12
+ value && !value.empty? && !%w[0 false no off].include?(value.downcase)
13
+ end
14
+
15
+ host_os = RbConfig::CONFIG.fetch("host_os")
16
+ abort "cohere-transcribe's vendored native runtime currently supports Linux and macOS source builds" unless host_os.match?(/linux|darwin/)
17
+
18
+ cuda = enabled?("COHERE_TRANSCRIBE_CUDA")
19
+ metal = enabled?("COHERE_TRANSCRIBE_METAL")
20
+ abort "COHERE_TRANSCRIBE_METAL=1 is only supported on macOS" if metal && !host_os.match?(/darwin/)
21
+ abort "COHERE_TRANSCRIBE_CUDA=1 is only supported on Linux" if cuda && !host_os.match?(/linux/)
22
+ abort "enable either CUDA or Metal, not both" if cuda && metal
23
+
24
+ cmake = ENV.fetch("CMAKE", "cmake")
25
+ unless system(cmake, "--version", out: File::NULL, err: File::NULL)
26
+ abort "cmake 3.14 or newer is required to build cohere-transcribe's native runtime"
27
+ end
28
+
29
+ build_dir = File.expand_path(
30
+ ENV.fetch("COHERE_TRANSCRIBE_NATIVE_BUILD_DIR", File.join(GEM_ROOT, "tmp", "cohere_transcribe_native"))
31
+ )
32
+ output_dir = File.expand_path(
33
+ ENV.fetch(
34
+ "COHERE_TRANSCRIBE_NATIVE_OUTPUT",
35
+ File.join(GEM_ROOT, "lib", "cohere", "transcribe", "native")
36
+ )
37
+ )
38
+ build_type = ENV.fetch("COHERE_TRANSCRIBE_BUILD_TYPE", "Release")
39
+
40
+ cmake_options = {
41
+ "COHERE_TRANSCRIBE_CUDA" => cuda,
42
+ "COHERE_TRANSCRIBE_METAL" => metal,
43
+ "COHERE_TRANSCRIBE_NATIVE" => enabled?("COHERE_TRANSCRIBE_NATIVE"),
44
+ "COHERE_TRANSCRIBE_OPENMP" => enabled?("COHERE_TRANSCRIBE_OPENMP")
45
+ }
46
+
47
+ configure = [
48
+ cmake,
49
+ "-S", EXTENSION_DIR,
50
+ "-B", build_dir,
51
+ "-DCMAKE_BUILD_TYPE=#{build_type}",
52
+ *cmake_options.map { |name, value| "-D#{name}=#{value ? "ON" : "OFF"}" },
53
+ *Shellwords.split(ENV.fetch("COHERE_TRANSCRIBE_CMAKE_ARGS", ""))
54
+ ]
55
+ build = [cmake, "--build", build_dir, "--config", build_type, "--target", "crispasr", "cohere_audio"]
56
+ jobs = ENV.fetch("COHERE_TRANSCRIBE_NATIVE_JOBS", nil)
57
+ build.push("--parallel", Integer(jobs, 10).to_s) if jobs && !jobs.empty?
58
+ install = [
59
+ cmake,
60
+ "--install", build_dir,
61
+ "--config", build_type,
62
+ "--prefix", output_dir,
63
+ "--component", "cohere_transcribe_runtime"
64
+ ]
65
+ smoke = [RbConfig.ruby, File.join(EXTENSION_DIR, "test", "abi_smoke.rb"), output_dir]
66
+
67
+ FileUtils.mkdir_p(build_dir)
68
+
69
+ makefile = <<~MAKEFILE
70
+ .PHONY: all install check clean distclean
71
+
72
+ all:
73
+ \t#{Shellwords.join(configure)}
74
+ \t#{Shellwords.join(build)}
75
+ \t#{Shellwords.join(install)}
76
+
77
+ install: all
78
+
79
+ check: all
80
+ \t#{Shellwords.join(smoke)}
81
+
82
+ clean:
83
+ \t#{Shellwords.join([cmake, "-E", "remove_directory", build_dir])}
84
+
85
+ distclean: clean
86
+ MAKEFILE
87
+
88
+ File.write(File.join(EXTENSION_DIR, "Makefile"), makefile)
89
+ puts "Native runtime will be installed in #{output_dir}"
@@ -0,0 +1,232 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fiddle"
4
+ require "rbconfig"
5
+ require "tmpdir"
6
+
7
+ directory = File.expand_path(ARGV.fetch(0))
8
+ patterns = case RbConfig::CONFIG.fetch("host_os")
9
+ when /darwin/ then ["libcrispasr*.dylib"]
10
+ when /mswin|mingw/ then ["crispasr*.dll", "libcrispasr*.dll"]
11
+ else ["libcrispasr.so", "libcrispasr.so.*"]
12
+ end
13
+ library = patterns.flat_map { |pattern| Dir.glob(File.join(directory, pattern)) }.min
14
+ abort "no packaged libcrispasr found in #{directory}" unless library
15
+
16
+ handle = Fiddle::Handle.new(library, Fiddle::RTLD_NOW | Fiddle::RTLD_GLOBAL)
17
+ symbols = %w[
18
+ crispasr_bf16_to_fp32_row
19
+ crispasr_fp16_to_fp32_row
20
+ crispasr_fp32_to_fp16_row
21
+ crispasr_fp32_to_bf16_row
22
+ crispasr_last_error_kind
23
+ crispasr_last_error_message
24
+ crispasr_set_gpu_backend
25
+ crispasr_runtime_resolve_device
26
+ crispasr_runtime_supports_bf16
27
+ crispasr_session_open_with_params
28
+ crispasr_session_backend
29
+ crispasr_session_compute_backend
30
+ crispasr_session_memory
31
+ crispasr_session_batch_capacity
32
+ crispasr_session_cancel
33
+ crispasr_session_transcribe_lang
34
+ crispasr_session_transcribe_batch_lang
35
+ crispasr_session_batch_result_count
36
+ crispasr_session_batch_result_stats_v1
37
+ crispasr_session_batch_result_at
38
+ crispasr_session_batch_result_free
39
+ crispasr_session_result_n_segments
40
+ crispasr_session_result_segment_text
41
+ crispasr_session_result_segment_t0
42
+ crispasr_session_result_segment_t1
43
+ crispasr_session_result_n_words
44
+ crispasr_session_result_word_text
45
+ crispasr_session_result_word_t0
46
+ crispasr_session_result_word_t1
47
+ crispasr_session_result_word_p
48
+ crispasr_session_result_generated_tokens
49
+ crispasr_session_result_generation_limit
50
+ crispasr_session_result_generation_capacity
51
+ crispasr_session_result_stopped_by_max_tokens
52
+ crispasr_session_result_repetition_stopped
53
+ crispasr_session_result_free
54
+ crispasr_session_close
55
+ crispasr_session_set_max_new_tokens
56
+ crispasr_session_set_beam_size
57
+ crispasr_session_set_repetition_loop_guard
58
+ ]
59
+ symbols.each { |symbol| handle[symbol] }
60
+
61
+ backend = Fiddle::Function.new(handle["crispasr_session_backend"], [Fiddle::TYPE_VOIDP], Fiddle::TYPE_VOIDP)
62
+ compute_backend = Fiddle::Function.new(
63
+ handle["crispasr_session_compute_backend"],
64
+ [Fiddle::TYPE_VOIDP],
65
+ Fiddle::TYPE_VOIDP
66
+ )
67
+ resolve_device = Fiddle::Function.new(
68
+ handle["crispasr_runtime_resolve_device"],
69
+ [Fiddle::TYPE_VOIDP],
70
+ Fiddle::TYPE_VOIDP
71
+ )
72
+ supports_bf16 = Fiddle::Function.new(
73
+ handle["crispasr_runtime_supports_bf16"],
74
+ [Fiddle::TYPE_VOIDP],
75
+ Fiddle::TYPE_INT
76
+ )
77
+ segments = Fiddle::Function.new(
78
+ handle["crispasr_session_result_n_segments"],
79
+ [Fiddle::TYPE_VOIDP],
80
+ Fiddle::TYPE_INT
81
+ )
82
+ batch_capacity = Fiddle::Function.new(
83
+ handle["crispasr_session_batch_capacity"],
84
+ [Fiddle::TYPE_VOIDP],
85
+ Fiddle::TYPE_INT
86
+ )
87
+ cancel_session = Fiddle::Function.new(
88
+ handle["crispasr_session_cancel"],
89
+ [Fiddle::TYPE_VOIDP],
90
+ Fiddle::TYPE_INT
91
+ )
92
+ last_error_kind = Fiddle::Function.new(
93
+ handle["crispasr_last_error_kind"],
94
+ [],
95
+ Fiddle::TYPE_INT
96
+ )
97
+ last_error_message = Fiddle::Function.new(
98
+ handle["crispasr_last_error_message"],
99
+ [],
100
+ Fiddle::TYPE_VOIDP
101
+ )
102
+ batch_transcribe = Fiddle::Function.new(
103
+ handle["crispasr_session_transcribe_batch_lang"],
104
+ [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT, Fiddle::TYPE_VOIDP],
105
+ Fiddle::TYPE_VOIDP
106
+ )
107
+ max_tokens = Fiddle::Function.new(
108
+ handle["crispasr_session_set_max_new_tokens"],
109
+ [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT],
110
+ Fiddle::TYPE_INT
111
+ )
112
+ raise "initial native error kind must be zero" unless last_error_kind.call.zero?
113
+ raise "initial native error message must be empty" unless Fiddle::Pointer.new(
114
+ last_error_message.call
115
+ ).to_s.empty?
116
+ raise "null session backend must be an empty C string" unless Fiddle::Pointer.new(backend.call(0)).to_s.empty?
117
+ raise "null session compute backend must be an empty C string" unless Fiddle::Pointer.new(
118
+ compute_backend.call(0)
119
+ ).to_s.empty?
120
+
121
+ cpu = Fiddle::Pointer["cpu\0"]
122
+ auto = Fiddle::Pointer["auto\0"]
123
+ raise "CPU must always resolve" unless Fiddle::Pointer.new(resolve_device.call(cpu)).to_s == "cpu"
124
+ raise "CPU precision contract must use FP32" unless supports_bf16.call(cpu).zero?
125
+ unless %w[cpu cuda mps].include?(Fiddle::Pointer.new(resolve_device.call(auto)).to_s)
126
+ raise "auto device resolution returned an unsupported value"
127
+ end
128
+ raise "null result must contain no segments" unless segments.call(0).zero?
129
+ raise "null session must have no batch capacity" unless batch_capacity.call(0).zero?
130
+ raise "null session cancellation must fail" unless cancel_session.call(0) == -1
131
+ raise "null session setter must fail" unless max_tokens.call(0, 1) == -1
132
+
133
+ failed, failure_kind, failure_message = Thread.new do
134
+ result = batch_transcribe.call(0, 0, 0, 1, 0)
135
+ [result.null?, last_error_kind.call, Fiddle::Pointer.new(last_error_message.call).to_s]
136
+ end.value
137
+ raise "invalid batch arguments must fail" unless failed
138
+ raise "invalid batch arguments must be classified" unless failure_kind == 1
139
+ raise "invalid batch arguments must include a diagnostic message" unless failure_message.include?("invalid batch transcription")
140
+ raise "native diagnostics must remain thread-local" unless last_error_kind.call.zero?
141
+
142
+ puts "verified #{symbols.length} Cohere session ABI symbols in #{File.basename(library)}"
143
+
144
+ audio_patterns = case RbConfig::CONFIG.fetch("host_os")
145
+ when /darwin/ then ["libcohere_audio*.dylib"]
146
+ when /mswin|mingw/ then ["cohere_audio*.dll", "libcohere_audio*.dll"]
147
+ else ["libcohere_audio.so", "libcohere_audio.so.*"]
148
+ end
149
+ audio_library = audio_patterns.flat_map do |pattern|
150
+ Dir.glob(File.join(directory, pattern))
151
+ end.min
152
+ abort "no packaged libcohere_audio found in #{directory}" unless audio_library
153
+
154
+ audio_handle = Fiddle::Handle.new(audio_library, Fiddle::RTLD_NOW)
155
+ audio_symbols = %w[
156
+ cohere_audio_ffmpeg_probe
157
+ cohere_audio_ffmpeg_decode
158
+ cohere_audio_ffmpeg_duration
159
+ cohere_audio_ffmpeg_cancel
160
+ cohere_audio_ffmpeg_free
161
+ ]
162
+ audio_symbols.each { |symbol| audio_handle[symbol] }
163
+ probe = Fiddle::Function.new(
164
+ audio_handle["cohere_audio_ffmpeg_probe"],
165
+ [Fiddle::TYPE_VOIDP, Fiddle::TYPE_SIZE_T],
166
+ Fiddle::TYPE_INT
167
+ )
168
+ diagnostic = Fiddle::Pointer.malloc(1_024, Fiddle::RUBY_FREE)
169
+ diagnostic[0, 1_024] = "\0" * 1_024
170
+ probe_status = probe.call(diagnostic, 1_024)
171
+ raise "audio probe returned an invalid status" unless [0, 1].include?(probe_status)
172
+ raise "audio probe returned no diagnostic" if diagnostic.to_s.empty?
173
+
174
+ if probe_status.zero?
175
+ duration = Fiddle::Function.new(
176
+ audio_handle["cohere_audio_ffmpeg_duration"],
177
+ [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_SIZE_T],
178
+ Fiddle::TYPE_INT
179
+ )
180
+ decode = Fiddle::Function.new(
181
+ audio_handle["cohere_audio_ffmpeg_decode"],
182
+ [
183
+ Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT, Fiddle::TYPE_UINT64_T,
184
+ Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_SIZE_T
185
+ ],
186
+ Fiddle::TYPE_INT
187
+ )
188
+ cancel = Fiddle::Function.new(audio_handle["cohere_audio_ffmpeg_cancel"], [], Fiddle::TYPE_VOID)
189
+ release = Fiddle::Function.new(
190
+ audio_handle["cohere_audio_ffmpeg_free"],
191
+ [Fiddle::TYPE_VOIDP],
192
+ Fiddle::TYPE_VOID
193
+ )
194
+ Dir.mktmpdir("cohere-audio-smoke") do |temporary_directory|
195
+ fixture = File.join(temporary_directory, "fixture.wav")
196
+ frames = 400
197
+ pcm = Array.new(frames) { [16_384, -8_192] }.flatten.pack("s<*")
198
+ header = [
199
+ "RIFF", 36 + pcm.bytesize, "WAVE", "fmt ", 16, 1, 2,
200
+ 16_000, 64_000, 4, 16, "data", pcm.bytesize
201
+ ].pack("a4Va4a4VvvVVvva4V")
202
+ File.binwrite(fixture, header + pcm)
203
+
204
+ duration_slot = Fiddle::Pointer.malloc(Fiddle::SIZEOF_DOUBLE, Fiddle::RUBY_FREE)
205
+ duration_slot[0, Fiddle::SIZEOF_DOUBLE] = [-1.0].pack("d")
206
+ status = duration.call(Fiddle::Pointer["#{fixture}\0"], duration_slot, diagnostic, 1_024)
207
+ raise "audio duration smoke failed: #{diagnostic}" unless status.zero?
208
+
209
+ seconds = duration_slot[0, Fiddle::SIZEOF_DOUBLE].unpack1("d")
210
+ raise "audio duration smoke mismatch: #{seconds}" unless (seconds - 0.025).abs <= 1e-9
211
+
212
+ output_slot = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP, Fiddle::RUBY_FREE)
213
+ output_slot[0, Fiddle::SIZEOF_VOIDP] = [0].pack("J")
214
+ count_slot = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT64_T, Fiddle::RUBY_FREE)
215
+ count_slot[0, Fiddle::SIZEOF_INT64_T] = [0].pack("q")
216
+ cancel.call # A previous cancellation must never poison a newly started operation.
217
+ status = decode.call(
218
+ Fiddle::Pointer["#{fixture}\0"], 16_000, frames * Fiddle::SIZEOF_FLOAT,
219
+ output_slot, count_slot, diagnostic, 1_024
220
+ )
221
+ address = output_slot[0, Fiddle::SIZEOF_VOIDP].unpack1("J")
222
+ count = count_slot[0, Fiddle::SIZEOF_INT64_T].unpack1("q")
223
+ begin
224
+ raise "audio decode smoke failed: #{diagnostic}" unless status.zero?
225
+ raise "audio decode smoke returned #{count} samples" unless count == frames && !address.zero?
226
+ ensure
227
+ release.call(address) unless address.zero?
228
+ end
229
+ end
230
+ end
231
+
232
+ puts "verified #{audio_symbols.length} audio ABI symbols in #{File.basename(audio_library)}: #{diagnostic}"
@@ -0,0 +1,121 @@
1
+ #include <cmath>
2
+ #include <cstddef>
3
+ #include <cstdint>
4
+ #include <cstdio>
5
+ #include <cstring>
6
+ #include <dlfcn.h>
7
+ #include <fstream>
8
+ #include <iostream>
9
+ #include <stdexcept>
10
+ #include <string>
11
+ #include <vector>
12
+
13
+ namespace {
14
+
15
+ template <typename Function>
16
+ Function load(void* library, const char* name) {
17
+ auto function = reinterpret_cast<Function>(dlsym(library, name));
18
+ if (!function)
19
+ throw std::runtime_error(std::string("missing symbol ") + name);
20
+ return function;
21
+ }
22
+
23
+ template <typename Integer>
24
+ void little_endian(std::ofstream& output, Integer value) {
25
+ for (std::size_t index = 0; index < sizeof(value); ++index) {
26
+ output.put(static_cast<char>((static_cast<std::uint64_t>(value) >> (8 * index)) & 0xff));
27
+ }
28
+ }
29
+
30
+ void write_fixture(const char* path) {
31
+ constexpr std::uint32_t frames = 400;
32
+ constexpr std::uint32_t rate = 16'000;
33
+ constexpr std::uint16_t channels = 2;
34
+ constexpr std::uint32_t pcm_bytes = frames * channels * sizeof(std::int16_t);
35
+ std::ofstream output(path, std::ios::binary | std::ios::trunc);
36
+ output.write("RIFF", 4);
37
+ little_endian(output, 36U + pcm_bytes);
38
+ output.write("WAVEfmt ", 8);
39
+ little_endian(output, 16U);
40
+ little_endian(output, static_cast<std::uint16_t>(1));
41
+ little_endian(output, channels);
42
+ little_endian(output, rate);
43
+ little_endian(output, static_cast<std::uint32_t>(rate * channels * sizeof(std::int16_t)));
44
+ little_endian(output, static_cast<std::uint16_t>(channels * sizeof(std::int16_t)));
45
+ little_endian(output, static_cast<std::uint16_t>(16));
46
+ output.write("data", 4);
47
+ little_endian(output, pcm_bytes);
48
+ for (std::uint32_t index = 0; index < frames; ++index) {
49
+ little_endian(output, static_cast<std::uint16_t>(16'384));
50
+ little_endian(output, static_cast<std::uint16_t>(-8'192));
51
+ }
52
+ if (!output)
53
+ throw std::runtime_error("could not write WAV fixture");
54
+ }
55
+
56
+ } // namespace
57
+
58
+ int main(int argc, char** argv) try {
59
+ if (argc != 3)
60
+ throw std::runtime_error("usage: audio_matrix_smoke ADAPTER FIXTURE");
61
+ write_fixture(argv[2]);
62
+ void* library = dlopen(argv[1], RTLD_NOW | RTLD_LOCAL);
63
+ if (!library)
64
+ throw std::runtime_error(dlerror());
65
+
66
+ using Probe = int (*)(char*, std::size_t);
67
+ using Duration = int (*)(const char*, double*, char*, std::size_t);
68
+ using Decode = int (*)(const char*, int, std::uint64_t, float**, std::int64_t*, char*, std::size_t);
69
+ using Free = void (*)(void*);
70
+ const auto probe = load<Probe>(library, "cohere_audio_ffmpeg_probe");
71
+ const auto duration = load<Duration>(library, "cohere_audio_ffmpeg_duration");
72
+ const auto decode = load<Decode>(library, "cohere_audio_ffmpeg_decode");
73
+ const auto release = load<Free>(library, "cohere_audio_ffmpeg_free");
74
+
75
+ char diagnostic[1024] = {};
76
+ if (probe(diagnostic, sizeof(diagnostic)) != 0)
77
+ throw std::runtime_error(diagnostic);
78
+
79
+ float* invalid_samples = reinterpret_cast<float*>(static_cast<std::uintptr_t>(1));
80
+ std::int64_t invalid_count = 17;
81
+ if (decode(nullptr, 16'000, 0, &invalid_samples, &invalid_count,
82
+ diagnostic, sizeof(diagnostic)) != 2 || invalid_samples || invalid_count != 0) {
83
+ throw std::runtime_error("invalid decode did not clear output ownership metadata");
84
+ }
85
+ double invalid_duration = 17.0;
86
+ if (duration(nullptr, &invalid_duration, diagnostic, sizeof(diagnostic)) != 2 ||
87
+ invalid_duration != -1.0) {
88
+ throw std::runtime_error("invalid duration probe did not clear output metadata");
89
+ }
90
+ release(nullptr);
91
+
92
+ double seconds = -1.0;
93
+ std::int64_t count = 0;
94
+ for (int iteration = 0; iteration < 100; ++iteration) {
95
+ if (duration(argv[2], &seconds, diagnostic, sizeof(diagnostic)) != 0)
96
+ throw std::runtime_error(diagnostic);
97
+ if (std::abs(seconds - (400.0 / 16'000.0)) > 1e-9)
98
+ throw std::runtime_error("duration mismatch");
99
+
100
+ float* samples = nullptr;
101
+ count = 0;
102
+ const int status = decode(argv[2], 16'000, 400 * sizeof(float), &samples, &count,
103
+ diagnostic, sizeof(diagnostic));
104
+ if (status != 0) {
105
+ release(samples);
106
+ throw std::runtime_error(diagnostic);
107
+ }
108
+ if (!samples || count != 400 || !std::isfinite(samples[200])) {
109
+ release(samples);
110
+ throw std::runtime_error("decode output mismatch");
111
+ }
112
+ release(samples);
113
+ }
114
+ std::cout << diagnostic << " duration=" << seconds << " samples=" << count << '\n';
115
+ dlclose(library);
116
+ std::remove(argv[2]);
117
+ return 0;
118
+ } catch (const std::exception& error) {
119
+ std::cerr << error.what() << '\n';
120
+ return 1;
121
+ }