diff --git a/crates/openvino/src/blob.rs b/crates/openvino/src/blob.rs index 32a8410..0a7ced0 100644 --- a/crates/openvino/src/blob.rs +++ b/crates/openvino/src/blob.rs @@ -50,6 +50,12 @@ impl Blob { } /// Return the tensor description of this [`Blob`]. + /// + /// # Panics + /// + /// May panic in the improbable case where some future version of the OpenVINO library returns a + /// dimensions array with a size different than the one auto-generated in the bindings; see + /// `struct dimensions` in `openvino-sys/src/generated/types.rs`. pub fn tensor_desc(&self) -> Result { let blob = self.instance as *const ie_blob_t; @@ -58,11 +64,9 @@ impl Blob { let mut dimensions = MaybeUninit::uninit(); try_unsafe!(ie_blob_get_dims(blob, dimensions.as_mut_ptr()))?; - // Safety: this assertion is trying to avoid the improbable case where some future version - // of the OpenVINO library returns a dimensions array with size different than the one - // auto-generated in the bindings; see `struct dimensions` in - // `openvino-sys/src/generated/types.rs`. It is not clear to me whether this will return the - // statically-expected size or the dynamic size -- this is not effective in the former case. + // Safety: See `Panics` section in function documentation; itt is not clear to me whether + // this will return the statically-expected size or the dynamic size -- this is not + // effective in the former case. assert_eq!(unsafe { dimensions.assume_init() }.dims.len(), 8); let mut precision = MaybeUninit::uninit(); diff --git a/crates/openvino/src/tensor_desc.rs b/crates/openvino/src/tensor_desc.rs index 6e3179c..9d396cf 100644 --- a/crates/openvino/src/tensor_desc.rs +++ b/crates/openvino/src/tensor_desc.rs @@ -51,6 +51,6 @@ impl TensorDesc { /// Get the number of elements described by this [`TensorDesc`]. pub fn len(&self) -> usize { - self.dims().iter().fold(1, |a, &b| a * b as usize) + self.dims().iter().product() } }