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 {
5050 }
5151
5252 /// 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`.
5359 pub fn tensor_desc ( & self ) -> Result < TensorDesc > {
5460 let blob = self . instance as * const ie_blob_t ;
5561
@@ -58,11 +64,9 @@ impl Blob {
5864
5965 let mut dimensions = MaybeUninit :: uninit ( ) ;
6066 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.
6670 assert_eq ! ( unsafe { dimensions. assume_init( ) } . dims. len( ) , 8 ) ;
6771
6872 let mut precision = MaybeUninit :: uninit ( ) ;
Original file line number Diff line number Diff line change @@ -51,6 +51,6 @@ impl TensorDesc {
5151
5252 /// Get the number of elements described by this [`TensorDesc`].
5353 pub fn len ( & self ) -> usize {
54- self . dims ( ) . iter ( ) . fold ( 1 , |a , & b| a * b as usize )
54+ self . dims ( ) . iter ( ) . product ( )
5555 }
5656}
You can’t perform that action at this time.
0 commit comments