Skip to main content

checked_shape_product

Function checked_shape_product 

Source
pub fn checked_shape_product(
    op: &'static str,
    role: &'static str,
    shape: &[usize],
) -> Result<usize>
Expand description

Compute a shape product with overflow reported as a typed tensor error.

§Examples

use tenferro_tensor::validate::checked_shape_product;

assert_eq!(checked_shape_product("zeros", "shape", &[2, 3])?, 6);

§Errors

Returns crate::Error::Validation containing tenferro_tensor_core::ValidationError::InvalidArgument when the product of shape exceeds usize::MAX; role identifies the shape-like argument in the diagnostic.