TypeTensor - v0.1.0
    Preparing search index...

    Type Alias ReshapeOp<Input, NewShape>

    ReshapeOp: CanReshapeStorage<Input> extends false
        ? never & {
            __error: "Cannot reshape non-contiguous tensor. Call contiguous() first.";
            __hint: "Non-contiguous tensors must be made contiguous before reshaping.";
        }
        : CanReshape<Input["__shape"], NewShape> extends true
            ? StorageTransformation<
                "reshape",
                TensorStorage<
                    Input["__dtype"],
                    NewShape,
                    ComputeReshapeStrides<Input, NewShape>,
                    ViewLayout<Input["__layout"]>,
                >,
                readonly [Input],
            >
            : never & {
                __cause: "Total number of elements must be the same";
                __error: `Cannot reshape tensor of shape [${ShapeToString<
                    Input["__shape"],
                >}] to shape [${ShapeToString<NewShape>}]`;
                __from_size: Product<Input["__shape"]>;
                __to_size: Product<NewShape>;
            }

    Reshape operation with compile-time shape validation

    Creates a new view of the tensor with a different shape. The total number of elements must remain the same.

    Requirements:

    • Input tensor must be contiguous (C or F order)
    • Total number of elements must remain the same
    • Result is a view of the original data

    Type Parameters

    type A = TensorStorage<Float32, [2, 3, 4]>; // 24 elements
    type B = ReshapeOp<A, [6, 4]>; // Valid: 24 elements
    type C = ReshapeOp<A, [5, 5]>; // Error: incompatible shapes