Skip to main content

build_tensor_value

Function build_tensor_value 

Source
pub fn build_tensor_value(
    cx: &mut Cx,
    shape: Vec<usize>,
    dtype_hint: Option<Symbol>,
    data: Vec<Value>,
) -> Result<Value>
Expand description

Builds a tensor Value of the given shape from row-major data cells.

The cell count must equal the product of shape (one for an empty, scalar shape). Every cell must be a scalar number value (not a nested tensor). When dtype_hint is Some, all cells must promote to that domain; otherwise the element domain is chosen as the cheapest join of the cell domains. Returns an error on a cell-count mismatch, a non-scalar cell, or an impossible dtype.