fix: allow dimensions to be zero

Torch allows this, ONNX Runtime doesn't complain
This commit is contained in:
Carson M.
2026-03-11 14:17:04 -05:00
parent 26f656b9a5
commit e336d6bf05

View File

@@ -328,12 +328,13 @@ macro_rules! impl_to_shape {
.iter()
.enumerate()
.map(|(i, c)| {
if *c >= 1 {
#[allow(unused_comparisons)]
if *c >= 0 {
Ok(*c as i64)
} else {
Err(Error::new_with_code(
ErrorCode::InvalidArgument,
format!("Invalid dimension #{}; all dimensions must be >= 1 when creating a tensor from raw data", i + 1)
format!("Invalid dimension #{}; all dimensions must be >= 0 when creating a tensor from raw data", i + 1)
))
}
})