Skip to content

Commit cb7fa2a

Browse files
authored
Expose more TensorDesc features (#54)
1 parent e403601 commit cb7fa2a

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

crates/openvino/src/tensor_desc.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,25 @@ impl TensorDesc {
3232
}
3333
}
3434

35+
/// Layout of the tensor.
36+
pub fn layout(&self) -> Layout {
37+
self.instance.layout
38+
}
39+
40+
/// Dimensions of the tensor.
41+
///
42+
/// Length of the slice is equal to the tensor rank.
43+
pub fn dims(&self) -> &[usize] {
44+
&self.instance.dims.dims[..self.instance.dims.ranks]
45+
}
46+
47+
/// Precision of the tensor.
48+
pub fn precision(&self) -> Precision {
49+
self.instance.precision
50+
}
51+
3552
/// Get the number of elements described by this [`TensorDesc`].
3653
pub fn len(&self) -> usize {
37-
self.instance.dims.dims[..self.instance.dims.ranks as usize]
38-
.iter()
39-
.fold(1, |a, &b| a * b as usize)
54+
self.dims().iter().fold(1, |a, &b| a * b as usize)
4055
}
4156
}

0 commit comments

Comments
 (0)