|
1 | 1 | // This file is a binding for the candle-core and candle-transformers libraries. |
2 | 2 | // It is based on https://github.com/huggingface/candle/tree/main/candle-examples/examples/bert |
3 | 3 | use std::collections::HashMap; |
4 | | -use std::ffi::{c_char, CStr, CString}; |
| 4 | +use std::ffi::{c_char, c_int, CStr, CString}; |
5 | 5 | use std::path::Path; |
6 | 6 | use std::sync::Arc; |
7 | 7 | use std::sync::Mutex; |
@@ -1887,11 +1887,11 @@ pub extern "C" fn init_unified_classifier_c( |
1887 | 1887 | pii_head_path: *const c_char, |
1888 | 1888 | security_head_path: *const c_char, |
1889 | 1889 | intent_labels: *const *const c_char, |
1890 | | - intent_labels_count: usize, |
| 1890 | + intent_labels_count: c_int, |
1891 | 1891 | pii_labels: *const *const c_char, |
1892 | | - pii_labels_count: usize, |
| 1892 | + pii_labels_count: c_int, |
1893 | 1893 | security_labels: *const *const c_char, |
1894 | | - security_labels_count: usize, |
| 1894 | + security_labels_count: c_int, |
1895 | 1895 | use_cpu: bool, |
1896 | 1896 | ) -> bool { |
1897 | 1897 | let modernbert_path = unsafe { |
@@ -1924,21 +1924,21 @@ pub extern "C" fn init_unified_classifier_c( |
1924 | 1924 |
|
1925 | 1925 | // Convert C string arrays to Rust Vec<String> |
1926 | 1926 | 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) |
1928 | 1928 | .iter() |
1929 | 1929 | .map(|&ptr| CStr::from_ptr(ptr).to_str().unwrap_or("").to_string()) |
1930 | 1930 | .collect::<Vec<String>>() |
1931 | 1931 | }; |
1932 | 1932 |
|
1933 | 1933 | 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) |
1935 | 1935 | .iter() |
1936 | 1936 | .map(|&ptr| CStr::from_ptr(ptr).to_str().unwrap_or("").to_string()) |
1937 | 1937 | .collect::<Vec<String>>() |
1938 | 1938 | }; |
1939 | 1939 |
|
1940 | 1940 | 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) |
1942 | 1942 | .iter() |
1943 | 1943 | .map(|&ptr| CStr::from_ptr(ptr).to_str().unwrap_or("").to_string()) |
1944 | 1944 | .collect::<Vec<String>>() |
|
0 commit comments