Skip to content

Commit 3b30722

Browse files
committed
Remove unnecessary casting from usize to u64
With the bindgen change to use `size_t_is_usize`, the high-level API no longer has to cast `usize` to `u64` before calling into the openvino-sys crate.
1 parent a09ea39 commit 3b30722

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

crates/openvino/src/core.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,12 @@ impl Core {
5656
weights_content: &[u8],
5757
) -> Result<CNNNetwork> {
5858
let mut instance = std::ptr::null_mut();
59-
let weights_desc =
60-
TensorDesc::new(Layout::ANY, &[weights_content.len() as u64], Precision::U8);
59+
let weights_desc = TensorDesc::new(Layout::ANY, &[weights_content.len()], Precision::U8);
6160
let weights_blob = Blob::new(weights_desc, weights_content)?;
6261
try_unsafe!(ie_core_read_network_from_memory(
6362
self.instance,
6463
model_content as *const _ as *const u8,
65-
model_content.len() as u64,
64+
model_content.len(),
6665
weights_blob.instance,
6766
&mut instance as *mut *mut _,
6867
))?;

crates/openvino/src/network.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl CNNNetwork {
2424
let mut cname = std::ptr::null_mut();
2525
try_unsafe!(ie_network_get_input_name(
2626
self.instance,
27-
index as u64,
27+
index,
2828
&mut cname as *mut *mut _
2929
))?;
3030
let name = unsafe { CStr::from_ptr(cname) }
@@ -40,7 +40,7 @@ impl CNNNetwork {
4040
let mut cname = std::ptr::null_mut();
4141
try_unsafe!(ie_network_get_output_name(
4242
self.instance,
43-
index as u64,
43+
index,
4444
&mut cname as *mut *mut _
4545
))?;
4646
let name = unsafe { CStr::from_ptr(cname) }

crates/openvino/src/request.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ drop_using_function!(InferRequest, ie_infer_request_free);
1414
impl InferRequest {
1515
/// Set the batch size of the inference requests.
1616
pub fn set_batch_size(&mut self, size: usize) -> Result<()> {
17-
try_unsafe!(ie_infer_request_set_batch(self.instance, size as u64))
17+
try_unsafe!(ie_infer_request_set_batch(self.instance, size))
1818
}
1919

2020
/// Assign a [Blob] to the input (i.e. `name`) on the network.

crates/openvino/src/tensor_desc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub struct TensorDesc {
88

99
impl TensorDesc {
1010
/// Construct a new [TensorDesc] from its C API components.
11-
pub fn new(layout: Layout, dimensions: &[u64], precision: Precision) -> Self {
11+
pub fn new(layout: Layout, dimensions: &[usize], precision: Precision) -> Self {
1212
// Setup dimensions.
1313
assert!(dimensions.len() < 8);
1414
let mut dims = [0; 8];
@@ -19,7 +19,7 @@ impl TensorDesc {
1919
instance: tensor_desc_t {
2020
layout,
2121
dims: dimensions_t {
22-
ranks: dimensions.len() as u64,
22+
ranks: dimensions.len(),
2323
dims,
2424
},
2525
precision,

0 commit comments

Comments
 (0)