ClikaRT::ops::expand
function
expand()
Tensor expand(
Tensor x,
ClikaRT::Span<const ScalarOrTensor> shape,
bool bidirectional = false
)
Broadcast x to a larger shape WITHOUT copying.
Size-1 dims stretch to their target; leading target dims with no input counterpart broadcast; -1 keeps the input's extent at that position. Extents are literals or 0-D integer Tensors (trace symbolically). With bidirectional = true the aligned dims broadcast BOTH ways (the ONNX Expand rule): a target extent of 1 against a non-1 input dim keeps the input dim (the pairwise max) instead of raising. The default is the strict directed form (broadcast_to).
Returns a VIEW: every stretched position aliases ONE stored element; treat the result as read-only (or contiguous it to materialize).
Throws
ClikaRT::Error: (INVALID_ARGUMENT) when a non-1 input dim mismatches its target (code_name()carries the reason).
Returns: a view of x with the requested shape.
auto row = ClikaRT::ops::unsqueeze(bias, 0); // [1, d]
auto b = ClikaRT::ops::expand(row, {batch, -1}); // [batch, d], no copy
Declared in ClikaRT/compute/ops.h, line 3160