Add support for new whisper.cpp project structure

Remove opencl feature, removed in whisper.cpp
Add openmp feature and enable by default as in whisper.cpp
Update bindings
This commit is contained in:
arizhih 2024-08-08 15:55:47 +02:00
parent 744804a8aa
commit ec609f18ff
10 changed files with 164 additions and 371 deletions

View file

@ -1,4 +1,4 @@
/* automatically generated by rust-bindgen 0.69.1 */
/* automatically generated by rust-bindgen 0.69.4 */
pub const __bool_true_false_are_defined: u32 = 1;
pub const true_: u32 = 1;
@ -161,8 +161,10 @@ pub const GGML_KQ_MASK_PAD: u32 = 32;
pub const GGML_N_TASKS_MAX: i32 = -1;
pub const WHISPER_SAMPLE_RATE: u32 = 16000;
pub const WHISPER_N_FFT: u32 = 400;
pub const WHISPER_N_FFT_HALF: u32 = 201;
pub const WHISPER_HOP_LENGTH: u32 = 160;
pub const WHISPER_CHUNK_SIZE: u32 = 30;
pub const WHISPER_N_SAMPLES: u32 = 480000;
pub type wchar_t = ::std::os::raw::c_int;
#[repr(C)]
#[repr(align(16))]
@ -1475,28 +1477,26 @@ pub const ggml_op_GGML_OP_ARANGE: ggml_op = 51;
pub const ggml_op_GGML_OP_TIMESTEP_EMBEDDING: ggml_op = 52;
pub const ggml_op_GGML_OP_ARGSORT: ggml_op = 53;
pub const ggml_op_GGML_OP_LEAKY_RELU: ggml_op = 54;
pub const ggml_op_GGML_OP_FLASH_ATTN: ggml_op = 55;
pub const ggml_op_GGML_OP_FLASH_ATTN_EXT: ggml_op = 56;
pub const ggml_op_GGML_OP_FLASH_FF: ggml_op = 57;
pub const ggml_op_GGML_OP_FLASH_ATTN_BACK: ggml_op = 58;
pub const ggml_op_GGML_OP_SSM_CONV: ggml_op = 59;
pub const ggml_op_GGML_OP_SSM_SCAN: ggml_op = 60;
pub const ggml_op_GGML_OP_WIN_PART: ggml_op = 61;
pub const ggml_op_GGML_OP_WIN_UNPART: ggml_op = 62;
pub const ggml_op_GGML_OP_GET_REL_POS: ggml_op = 63;
pub const ggml_op_GGML_OP_ADD_REL_POS: ggml_op = 64;
pub const ggml_op_GGML_OP_UNARY: ggml_op = 65;
pub const ggml_op_GGML_OP_MAP_UNARY: ggml_op = 66;
pub const ggml_op_GGML_OP_MAP_BINARY: ggml_op = 67;
pub const ggml_op_GGML_OP_MAP_CUSTOM1_F32: ggml_op = 68;
pub const ggml_op_GGML_OP_MAP_CUSTOM2_F32: ggml_op = 69;
pub const ggml_op_GGML_OP_MAP_CUSTOM3_F32: ggml_op = 70;
pub const ggml_op_GGML_OP_MAP_CUSTOM1: ggml_op = 71;
pub const ggml_op_GGML_OP_MAP_CUSTOM2: ggml_op = 72;
pub const ggml_op_GGML_OP_MAP_CUSTOM3: ggml_op = 73;
pub const ggml_op_GGML_OP_CROSS_ENTROPY_LOSS: ggml_op = 74;
pub const ggml_op_GGML_OP_CROSS_ENTROPY_LOSS_BACK: ggml_op = 75;
pub const ggml_op_GGML_OP_COUNT: ggml_op = 76;
pub const ggml_op_GGML_OP_FLASH_ATTN_EXT: ggml_op = 55;
pub const ggml_op_GGML_OP_FLASH_ATTN_BACK: ggml_op = 56;
pub const ggml_op_GGML_OP_SSM_CONV: ggml_op = 57;
pub const ggml_op_GGML_OP_SSM_SCAN: ggml_op = 58;
pub const ggml_op_GGML_OP_WIN_PART: ggml_op = 59;
pub const ggml_op_GGML_OP_WIN_UNPART: ggml_op = 60;
pub const ggml_op_GGML_OP_GET_REL_POS: ggml_op = 61;
pub const ggml_op_GGML_OP_ADD_REL_POS: ggml_op = 62;
pub const ggml_op_GGML_OP_UNARY: ggml_op = 63;
pub const ggml_op_GGML_OP_MAP_UNARY: ggml_op = 64;
pub const ggml_op_GGML_OP_MAP_BINARY: ggml_op = 65;
pub const ggml_op_GGML_OP_MAP_CUSTOM1_F32: ggml_op = 66;
pub const ggml_op_GGML_OP_MAP_CUSTOM2_F32: ggml_op = 67;
pub const ggml_op_GGML_OP_MAP_CUSTOM3_F32: ggml_op = 68;
pub const ggml_op_GGML_OP_MAP_CUSTOM1: ggml_op = 69;
pub const ggml_op_GGML_OP_MAP_CUSTOM2: ggml_op = 70;
pub const ggml_op_GGML_OP_MAP_CUSTOM3: ggml_op = 71;
pub const ggml_op_GGML_OP_CROSS_ENTROPY_LOSS: ggml_op = 72;
pub const ggml_op_GGML_OP_CROSS_ENTROPY_LOSS_BACK: ggml_op = 73;
pub const ggml_op_GGML_OP_COUNT: ggml_op = 74;
pub type ggml_op = ::std::os::raw::c_uint;
pub const ggml_unary_op_GGML_UNARY_OP_ABS: ggml_unary_op = 0;
pub const ggml_unary_op_GGML_UNARY_OP_SGN: ggml_unary_op = 1;
@ -1614,15 +1614,11 @@ pub struct ggml_tensor {
pub flags: i32,
pub grad: *mut ggml_tensor,
pub src: [*mut ggml_tensor; 10usize],
pub perf_runs: ::std::os::raw::c_int,
pub perf_cycles: i64,
pub perf_time_us: i64,
pub view_src: *mut ggml_tensor,
pub view_offs: usize,
pub data: *mut ::std::os::raw::c_void,
pub name: [::std::os::raw::c_char; 64usize],
pub extra: *mut ::std::os::raw::c_void,
pub padding: [::std::os::raw::c_char; 8usize],
}
#[test]
fn bindgen_test_layout_ggml_tensor() {
@ -1630,7 +1626,7 @@ fn bindgen_test_layout_ggml_tensor() {
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<ggml_tensor>(),
368usize,
336usize,
concat!("Size of: ", stringify!(ggml_tensor))
);
assert_eq!(
@ -1738,39 +1734,9 @@ fn bindgen_test_layout_ggml_tensor() {
stringify!(src)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).perf_runs) as usize - ptr as usize },
240usize,
concat!(
"Offset of field: ",
stringify!(ggml_tensor),
"::",
stringify!(perf_runs)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).perf_cycles) as usize - ptr as usize },
248usize,
concat!(
"Offset of field: ",
stringify!(ggml_tensor),
"::",
stringify!(perf_cycles)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).perf_time_us) as usize - ptr as usize },
256usize,
concat!(
"Offset of field: ",
stringify!(ggml_tensor),
"::",
stringify!(perf_time_us)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).view_src) as usize - ptr as usize },
264usize,
240usize,
concat!(
"Offset of field: ",
stringify!(ggml_tensor),
@ -1780,7 +1746,7 @@ fn bindgen_test_layout_ggml_tensor() {
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).view_offs) as usize - ptr as usize },
272usize,
248usize,
concat!(
"Offset of field: ",
stringify!(ggml_tensor),
@ -1790,7 +1756,7 @@ fn bindgen_test_layout_ggml_tensor() {
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize },
280usize,
256usize,
concat!(
"Offset of field: ",
stringify!(ggml_tensor),
@ -1800,7 +1766,7 @@ fn bindgen_test_layout_ggml_tensor() {
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize },
288usize,
264usize,
concat!(
"Offset of field: ",
stringify!(ggml_tensor),
@ -1810,7 +1776,7 @@ fn bindgen_test_layout_ggml_tensor() {
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).extra) as usize - ptr as usize },
352usize,
328usize,
concat!(
"Offset of field: ",
stringify!(ggml_tensor),
@ -1818,18 +1784,8 @@ fn bindgen_test_layout_ggml_tensor() {
stringify!(extra)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).padding) as usize - ptr as usize },
360usize,
concat!(
"Offset of field: ",
stringify!(ggml_tensor),
"::",
stringify!(padding)
)
);
}
pub const GGML_TENSOR_SIZE: usize = 368;
pub const GGML_TENSOR_SIZE: usize = 336;
pub type ggml_abort_callback =
::std::option::Option<unsafe extern "C" fn(data: *mut ::std::os::raw::c_void) -> bool>;
#[repr(C)]
@ -1962,9 +1918,6 @@ pub struct ggml_cgraph {
pub leafs: *mut *mut ggml_tensor,
pub visited_hash_table: ggml_hash_set,
pub order: ggml_cgraph_eval_order,
pub perf_runs: ::std::os::raw::c_int,
pub perf_cycles: i64,
pub perf_time_us: i64,
}
#[test]
fn bindgen_test_layout_ggml_cgraph() {
@ -1972,7 +1925,7 @@ fn bindgen_test_layout_ggml_cgraph() {
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<ggml_cgraph>(),
80usize,
64usize,
concat!("Size of: ", stringify!(ggml_cgraph))
);
assert_eq!(
@ -2060,36 +2013,6 @@ fn bindgen_test_layout_ggml_cgraph() {
stringify!(order)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).perf_runs) as usize - ptr as usize },
60usize,
concat!(
"Offset of field: ",
stringify!(ggml_cgraph),
"::",
stringify!(perf_runs)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).perf_cycles) as usize - ptr as usize },
64usize,
concat!(
"Offset of field: ",
stringify!(ggml_cgraph),
"::",
stringify!(perf_cycles)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).perf_time_us) as usize - ptr as usize },
72usize,
concat!(
"Offset of field: ",
stringify!(ggml_cgraph),
"::",
stringify!(perf_time_us)
)
);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
@ -2195,84 +2118,6 @@ fn bindgen_test_layout_ggml_init_params() {
)
);
}
pub const ggml_task_type_GGML_TASK_TYPE_INIT: ggml_task_type = 0;
pub const ggml_task_type_GGML_TASK_TYPE_COMPUTE: ggml_task_type = 1;
pub const ggml_task_type_GGML_TASK_TYPE_FINALIZE: ggml_task_type = 2;
pub type ggml_task_type = ::std::os::raw::c_uint;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ggml_compute_params {
pub type_: ggml_task_type,
pub ith: ::std::os::raw::c_int,
pub nth: ::std::os::raw::c_int,
pub wsize: usize,
pub wdata: *mut ::std::os::raw::c_void,
}
#[test]
fn bindgen_test_layout_ggml_compute_params() {
const UNINIT: ::std::mem::MaybeUninit<ggml_compute_params> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<ggml_compute_params>(),
32usize,
concat!("Size of: ", stringify!(ggml_compute_params))
);
assert_eq!(
::std::mem::align_of::<ggml_compute_params>(),
8usize,
concat!("Alignment of ", stringify!(ggml_compute_params))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).type_) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(ggml_compute_params),
"::",
stringify!(type_)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).ith) as usize - ptr as usize },
4usize,
concat!(
"Offset of field: ",
stringify!(ggml_compute_params),
"::",
stringify!(ith)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).nth) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(ggml_compute_params),
"::",
stringify!(nth)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).wsize) as usize - ptr as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(ggml_compute_params),
"::",
stringify!(wsize)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).wdata) as usize - ptr as usize },
24usize,
concat!(
"Offset of field: ",
stringify!(ggml_compute_params),
"::",
stringify!(wdata)
)
);
}
pub const ggml_numa_strategy_GGML_NUMA_STRATEGY_DISABLED: ggml_numa_strategy = 0;
pub const ggml_numa_strategy_GGML_NUMA_STRATEGY_DISTRIBUTE: ggml_numa_strategy = 1;
pub const ggml_numa_strategy_GGML_NUMA_STRATEGY_ISOLATE: ggml_numa_strategy = 2;
@ -2372,9 +2217,6 @@ extern "C" {
extern "C" {
pub fn ggml_is_transposed(tensor: *const ggml_tensor) -> bool;
}
extern "C" {
pub fn ggml_is_contiguous(tensor: *const ggml_tensor) -> bool;
}
extern "C" {
pub fn ggml_is_permuted(tensor: *const ggml_tensor) -> bool;
}
@ -2396,6 +2238,18 @@ extern "C" {
extern "C" {
pub fn ggml_n_dims(tensor: *const ggml_tensor) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn ggml_is_contiguous(tensor: *const ggml_tensor) -> bool;
}
extern "C" {
pub fn ggml_is_contiguous_0(tensor: *const ggml_tensor) -> bool;
}
extern "C" {
pub fn ggml_is_contiguous_1(tensor: *const ggml_tensor) -> bool;
}
extern "C" {
pub fn ggml_is_contiguous_2(tensor: *const ggml_tensor) -> bool;
}
extern "C" {
pub fn ggml_are_same_shape(t0: *const ggml_tensor, t1: *const ggml_tensor) -> bool;
}
@ -2757,6 +2611,7 @@ extern "C" {
ctx: *mut ggml_context,
a: *mut ggml_tensor,
b: *mut ggml_tensor,
dim: ::std::os::raw::c_int,
) -> *mut ggml_tensor;
}
extern "C" {
@ -3208,7 +3063,6 @@ extern "C" {
b: *mut ggml_tensor,
n_dims: ::std::os::raw::c_int,
mode: ::std::os::raw::c_int,
n_ctx: ::std::os::raw::c_int,
) -> *mut ggml_tensor;
}
extern "C" {
@ -3218,7 +3072,40 @@ extern "C" {
b: *mut ggml_tensor,
n_dims: ::std::os::raw::c_int,
mode: ::std::os::raw::c_int,
n_ctx: ::std::os::raw::c_int,
) -> *mut ggml_tensor;
}
extern "C" {
pub fn ggml_rope_ext(
ctx: *mut ggml_context,
a: *mut ggml_tensor,
b: *mut ggml_tensor,
c: *mut ggml_tensor,
n_dims: ::std::os::raw::c_int,
mode: ::std::os::raw::c_int,
n_ctx_orig: ::std::os::raw::c_int,
freq_base: f32,
freq_scale: f32,
ext_factor: f32,
attn_factor: f32,
beta_fast: f32,
beta_slow: f32,
) -> *mut ggml_tensor;
}
extern "C" {
pub fn ggml_rope_ext_inplace(
ctx: *mut ggml_context,
a: *mut ggml_tensor,
b: *mut ggml_tensor,
c: *mut ggml_tensor,
n_dims: ::std::os::raw::c_int,
mode: ::std::os::raw::c_int,
n_ctx_orig: ::std::os::raw::c_int,
freq_base: f32,
freq_scale: f32,
ext_factor: f32,
attn_factor: f32,
beta_fast: f32,
beta_slow: f32,
) -> *mut ggml_tensor;
}
extern "C" {
@ -3228,8 +3115,7 @@ extern "C" {
b: *mut ggml_tensor,
n_dims: ::std::os::raw::c_int,
mode: ::std::os::raw::c_int,
n_ctx: ::std::os::raw::c_int,
n_orig_ctx: ::std::os::raw::c_int,
n_ctx_orig: ::std::os::raw::c_int,
freq_base: f32,
freq_scale: f32,
ext_factor: f32,
@ -3245,8 +3131,7 @@ extern "C" {
b: *mut ggml_tensor,
n_dims: ::std::os::raw::c_int,
mode: ::std::os::raw::c_int,
n_ctx: ::std::os::raw::c_int,
n_orig_ctx: ::std::os::raw::c_int,
n_ctx_orig: ::std::os::raw::c_int,
freq_base: f32,
freq_scale: f32,
ext_factor: f32,
@ -3258,40 +3143,28 @@ extern "C" {
extern "C" {
pub fn ggml_rope_yarn_corr_dims(
n_dims: ::std::os::raw::c_int,
n_orig_ctx: ::std::os::raw::c_int,
n_ctx_orig: ::std::os::raw::c_int,
freq_base: f32,
beta_fast: f32,
beta_slow: f32,
dims: *mut f32,
);
}
extern "C" {
pub fn ggml_rope_xpos_inplace(
ctx: *mut ggml_context,
a: *mut ggml_tensor,
b: *mut ggml_tensor,
n_dims: ::std::os::raw::c_int,
base: f32,
down: bool,
) -> *mut ggml_tensor;
}
extern "C" {
pub fn ggml_rope_back(
ctx: *mut ggml_context,
a: *mut ggml_tensor,
b: *mut ggml_tensor,
c: *mut ggml_tensor,
n_dims: ::std::os::raw::c_int,
mode: ::std::os::raw::c_int,
n_ctx: ::std::os::raw::c_int,
n_orig_ctx: ::std::os::raw::c_int,
n_ctx_orig: ::std::os::raw::c_int,
freq_base: f32,
freq_scale: f32,
ext_factor: f32,
attn_factor: f32,
beta_fast: f32,
beta_slow: f32,
xpos_base: f32,
xpos_down: bool,
) -> *mut ggml_tensor;
}
extern "C" {
@ -3428,6 +3301,16 @@ extern "C" {
scale_factor: ::std::os::raw::c_int,
) -> *mut ggml_tensor;
}
extern "C" {
pub fn ggml_upscale_ext(
ctx: *mut ggml_context,
a: *mut ggml_tensor,
ne0: ::std::os::raw::c_int,
ne1: ::std::os::raw::c_int,
ne2: ::std::os::raw::c_int,
ne3: ::std::os::raw::c_int,
) -> *mut ggml_tensor;
}
extern "C" {
pub fn ggml_pad(
ctx: *mut ggml_context,
@ -3471,15 +3354,6 @@ extern "C" {
k: ::std::os::raw::c_int,
) -> *mut ggml_tensor;
}
extern "C" {
pub fn ggml_flash_attn(
ctx: *mut ggml_context,
q: *mut ggml_tensor,
k: *mut ggml_tensor,
v: *mut ggml_tensor,
masked: bool,
) -> *mut ggml_tensor;
}
extern "C" {
pub fn ggml_flash_attn_ext(
ctx: *mut ggml_context,
@ -3504,16 +3378,6 @@ extern "C" {
masked: bool,
) -> *mut ggml_tensor;
}
extern "C" {
pub fn ggml_flash_ff(
ctx: *mut ggml_context,
a: *mut ggml_tensor,
b0: *mut ggml_tensor,
b1: *mut ggml_tensor,
c0: *mut ggml_tensor,
c1: *mut ggml_tensor,
) -> *mut ggml_tensor;
}
extern "C" {
pub fn ggml_ssm_conv(
ctx: *mut ggml_context,
@ -5115,12 +4979,18 @@ extern "C" {
extern "C" {
pub fn ggml_cpu_has_avx512_vnni() -> ::std::os::raw::c_int;
}
extern "C" {
pub fn ggml_cpu_has_avx512_bf16() -> ::std::os::raw::c_int;
}
extern "C" {
pub fn ggml_cpu_has_fma() -> ::std::os::raw::c_int;
}
extern "C" {
pub fn ggml_cpu_has_neon() -> ::std::os::raw::c_int;
}
extern "C" {
pub fn ggml_cpu_has_sve() -> ::std::os::raw::c_int;
}
extern "C" {
pub fn ggml_cpu_has_arm_fma() -> ::std::os::raw::c_int;
}
@ -5142,9 +5012,6 @@ extern "C" {
extern "C" {
pub fn ggml_cpu_has_cuda() -> ::std::os::raw::c_int;
}
extern "C" {
pub fn ggml_cpu_has_clblast() -> ::std::os::raw::c_int;
}
extern "C" {
pub fn ggml_cpu_has_vulkan() -> ::std::os::raw::c_int;
}
@ -5163,6 +5030,9 @@ extern "C" {
extern "C" {
pub fn ggml_cpu_has_sycl() -> ::std::os::raw::c_int;
}
extern "C" {
pub fn ggml_cpu_has_rpc() -> ::std::os::raw::c_int;
}
extern "C" {
pub fn ggml_cpu_has_vsx() -> ::std::os::raw::c_int;
}
@ -5897,23 +5767,6 @@ extern "C" {
n_threads: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn whisper_pcm_to_mel_phase_vocoder(
ctx: *mut whisper_context,
samples: *const f32,
n_samples: ::std::os::raw::c_int,
n_threads: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn whisper_pcm_to_mel_phase_vocoder_with_state(
ctx: *mut whisper_context,
state: *mut whisper_state,
samples: *const f32,
n_samples: ::std::os::raw::c_int,
n_threads: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn whisper_set_mel(
ctx: *mut whisper_context,
@ -6177,7 +6030,6 @@ pub struct whisper_full_params {
pub max_len: ::std::os::raw::c_int,
pub split_on_word: bool,
pub max_tokens: ::std::os::raw::c_int,
pub speed_up: bool,
pub debug_mode: bool,
pub audio_ctx: ::std::os::raw::c_int,
pub tdrz_enable: bool,
@ -6496,19 +6348,9 @@ fn bindgen_test_layout_whisper_full_params() {
stringify!(max_tokens)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).speed_up) as usize - ptr as usize },
52usize,
concat!(
"Offset of field: ",
stringify!(whisper_full_params),
"::",
stringify!(speed_up)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).debug_mode) as usize - ptr as usize },
53usize,
52usize,
concat!(
"Offset of field: ",
stringify!(whisper_full_params),