Skip to content

Commit 03aece2

Browse files
committed
fix: label count params should be c_int in the pub extern "C" fn init_unified_classifier_c
Signed-off-by: carlory <[email protected]>
1 parent 54ce859 commit 03aece2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

candle-binding/src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This file is a binding for the candle-core and candle-transformers libraries.
22
// It is based on https://github.com/huggingface/candle/tree/main/candle-examples/examples/bert
33
use std::collections::HashMap;
4-
use std::ffi::{c_char, CStr, CString};
4+
use std::ffi::{c_char, c_int, CStr, CString};
55
use std::path::Path;
66
use std::sync::Arc;
77
use std::sync::Mutex;
@@ -1887,11 +1887,11 @@ pub extern "C" fn init_unified_classifier_c(
18871887
pii_head_path: *const c_char,
18881888
security_head_path: *const c_char,
18891889
intent_labels: *const *const c_char,
1890-
intent_labels_count: usize,
1890+
intent_labels_count: c_int,
18911891
pii_labels: *const *const c_char,
1892-
pii_labels_count: usize,
1892+
pii_labels_count: c_int,
18931893
security_labels: *const *const c_char,
1894-
security_labels_count: usize,
1894+
security_labels_count: c_int,
18951895
use_cpu: bool,
18961896
) -> bool {
18971897
let modernbert_path = unsafe {
@@ -1924,21 +1924,21 @@ pub extern "C" fn init_unified_classifier_c(
19241924

19251925
// Convert C string arrays to Rust Vec<String>
19261926
let intent_labels_vec = unsafe {
1927-
std::slice::from_raw_parts(intent_labels, intent_labels_count)
1927+
std::slice::from_raw_parts(intent_labels, intent_labels_count as usize)
19281928
.iter()
19291929
.map(|&ptr| CStr::from_ptr(ptr).to_str().unwrap_or("").to_string())
19301930
.collect::<Vec<String>>()
19311931
};
19321932

19331933
let pii_labels_vec = unsafe {
1934-
std::slice::from_raw_parts(pii_labels, pii_labels_count)
1934+
std::slice::from_raw_parts(pii_labels, pii_labels_count as usize)
19351935
.iter()
19361936
.map(|&ptr| CStr::from_ptr(ptr).to_str().unwrap_or("").to_string())
19371937
.collect::<Vec<String>>()
19381938
};
19391939

19401940
let security_labels_vec = unsafe {
1941-
std::slice::from_raw_parts(security_labels, security_labels_count)
1941+
std::slice::from_raw_parts(security_labels, security_labels_count as usize)
19421942
.iter()
19431943
.map(|&ptr| CStr::from_ptr(ptr).to_str().unwrap_or("").to_string())
19441944
.collect::<Vec<String>>()

0 commit comments

Comments
 (0)