File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,12 @@ impl Blob {
50
50
}
51
51
52
52
/// Return the tensor description of this [`Blob`].
53
+ ///
54
+ /// # Panics
55
+ ///
56
+ /// May panic in the improbable case where some future version of the OpenVINO library returns a
57
+ /// dimensions array with a size different than the one auto-generated in the bindings; see
58
+ /// `struct dimensions` in `openvino-sys/src/generated/types.rs`.
53
59
pub fn tensor_desc ( & self ) -> Result < TensorDesc > {
54
60
let blob = self . instance as * const ie_blob_t ;
55
61
@@ -58,11 +64,9 @@ impl Blob {
58
64
59
65
let mut dimensions = MaybeUninit :: uninit ( ) ;
60
66
try_unsafe ! ( ie_blob_get_dims( blob, dimensions. as_mut_ptr( ) ) ) ?;
61
- // Safety: this assertion is trying to avoid the improbable case where some future version
62
- // of the OpenVINO library returns a dimensions array with size different than the one
63
- // auto-generated in the bindings; see `struct dimensions` in
64
- // `openvino-sys/src/generated/types.rs`. It is not clear to me whether this will return the
65
- // statically-expected size or the dynamic size -- this is not effective in the former case.
67
+ // Safety: See `Panics` section in function documentation; itt is not clear to me whether
68
+ // this will return the statically-expected size or the dynamic size -- this is not
69
+ // effective in the former case.
66
70
assert_eq ! ( unsafe { dimensions. assume_init( ) } . dims. len( ) , 8 ) ;
67
71
68
72
let mut precision = MaybeUninit :: uninit ( ) ;
Original file line number Diff line number Diff line change @@ -51,6 +51,6 @@ impl TensorDesc {
51
51
52
52
/// Get the number of elements described by this [`TensorDesc`].
53
53
pub fn len ( & self ) -> usize {
54
- self . dims ( ) . iter ( ) . fold ( 1 , |a , & b| a * b as usize )
54
+ self . dims ( ) . iter ( ) . product ( )
55
55
}
56
56
}
You can’t perform that action at this time.
0 commit comments