Skip to content

Commit

Permalink
Expose more TensorDesc features
Browse files Browse the repository at this point in the history
  • Loading branch information
chemicstry committed Nov 24, 2022
1 parent dc2812e commit e4dd767
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions crates/openvino/src/tensor_desc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,25 @@ impl TensorDesc {
}
}

/// Layout of the tensor.
pub fn layout(&self) -> Layout {
self.instance.layout
}

/// Dimensions of the tensor.
///
/// Length of the slice is equal to the tensor rank.
pub fn dims(&self) -> &[usize] {
&self.instance.dims.dims[..self.instance.dims.ranks]
}

/// Precision of the tensor.
pub fn precision(&self) -> Precision {
self.instance.precision
}

/// Get the number of elements described by this [`TensorDesc`].
pub fn len(&self) -> usize {
self.instance.dims.dims[..self.instance.dims.ranks as usize]
.iter()
.fold(1, |a, &b| a * b as usize)
self.dims().iter().fold(1, |a, &b| a * b as usize)
}
}

0 comments on commit e4dd767

Please sign in to comment.