fix: empty dim len can be 1 (#949)

This commit is contained in:
dante
2025-02-28 23:56:19 -05:00
committed by GitHub
parent bc26691bd5
commit fcbb27677f
3 changed files with 4 additions and 1 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -1342,9 +1342,11 @@ impl<F: PrimeField + TensorType + PartialOrd + std::hash::Hash> ValTensor<F> {
/// Gets the total number of elements in the tensor
pub fn len(&self) -> usize {
match self {
ValTensor::Value { dims, .. } => {
ValTensor::Value { dims, inner, .. } => {
if !dims.is_empty() && (dims != &[0]) {
dims.iter().product::<usize>()
} else if dims.is_empty() {
inner.inner.len()
} else {
0
}