Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 10 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/openvino-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ include = [
]

[build-dependencies]
bindgen = "0.55.1"
cmake = "0.1.44"
bindgen = "0.58.1"
cmake = "0.1.45"

[features]
default = ["cpu"]
Expand Down
5 changes: 5 additions & 0 deletions crates/openvino-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,18 @@ fn main() {
file("upstream/inference-engine/ie_bridges/c/include/c_api/ie_c_api.h");
let bindings = bindgen::Builder::default()
.header(openvino_c_api_header.to_string_lossy())
.allowlist_function("ie_.*")
.blocklist_type("__uint8_t")
.blocklist_type("__int64_t")
.size_t_is_usize(true)
// While understanding the warnings in https://docs.rs/bindgen/0.36.0/bindgen/struct.Builder.html#method.rustified_enum
// that these enums could result in unspecified behavior if constructed from an invalid
// value, the expectation here is that OpenVINO only returns valid layout and precision
// values. This assumption is reasonable because otherwise OpenVINO itself would be broken.
.rustified_enum("layout_e")
.rustified_enum("precision_e")
.rustified_enum("resize_alg_e")
.rustified_enum("colorformat_e")
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.generate()
.expect("generate C API bindings");
Expand Down
5 changes: 2 additions & 3 deletions crates/openvino/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ impl Core {
weights_content: &[u8],
) -> Result<CNNNetwork> {
let mut instance = std::ptr::null_mut();
let weights_desc =
TensorDesc::new(Layout::ANY, &[weights_content.len() as u64], Precision::U8);
let weights_desc = TensorDesc::new(Layout::ANY, &[weights_content.len()], Precision::U8);
let weights_blob = Blob::new(weights_desc, weights_content)?;
try_unsafe!(ie_core_read_network_from_memory(
self.instance,
model_content as *const _ as *const u8,
model_content.len() as u64,
model_content.len(),
weights_blob.instance,
&mut instance as *mut *mut _,
))?;
Expand Down
4 changes: 2 additions & 2 deletions crates/openvino/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl CNNNetwork {
let mut cname = std::ptr::null_mut();
try_unsafe!(ie_network_get_input_name(
self.instance,
index as u64,
index,
&mut cname as *mut *mut _
))?;
let name = unsafe { CStr::from_ptr(cname) }
Expand All @@ -40,7 +40,7 @@ impl CNNNetwork {
let mut cname = std::ptr::null_mut();
try_unsafe!(ie_network_get_output_name(
self.instance,
index as u64,
index,
&mut cname as *mut *mut _
))?;
let name = unsafe { CStr::from_ptr(cname) }
Expand Down
2 changes: 1 addition & 1 deletion crates/openvino/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ drop_using_function!(InferRequest, ie_infer_request_free);
impl InferRequest {
/// Set the batch size of the inference requests.
pub fn set_batch_size(&mut self, size: usize) -> Result<()> {
try_unsafe!(ie_infer_request_set_batch(self.instance, size as u64))
try_unsafe!(ie_infer_request_set_batch(self.instance, size))
}

/// Assign a [Blob] to the input (i.e. `name`) on the network.
Expand Down
4 changes: 2 additions & 2 deletions crates/openvino/src/tensor_desc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct TensorDesc {

impl TensorDesc {
/// Construct a new [TensorDesc] from its C API components.
pub fn new(layout: Layout, dimensions: &[u64], precision: Precision) -> Self {
pub fn new(layout: Layout, dimensions: &[usize], precision: Precision) -> Self {
// Setup dimensions.
assert!(dimensions.len() < 8);
let mut dims = [0; 8];
Expand All @@ -19,7 +19,7 @@ impl TensorDesc {
instance: tensor_desc_t {
layout,
dims: dimensions_t {
ranks: dimensions.len() as u64,
ranks: dimensions.len(),
dims,
},
precision,
Expand Down