TypeTensor - v0.1.0
    Preparing search index...

    Type Alias SumOp<Input, Axes, KeepDims, OutputDType>

    SumOp: ValidateReduction<Input["__shape"], Axes> extends true
        ? StorageTransformation<
            "sum",
            TensorStorage<
                OutputDType,
                ComputeReductionShape<Input["__shape"], Axes, KeepDims>,
                ComputeStrides<ComputeReductionShape<Input["__shape"], Axes, KeepDims>>,
                ReductionOpLayout<Input["__layout"]>,
            >,
            readonly [Input],
        > & { __keepDims: KeepDims; __sumAxes: Axes }
        : never

    Sum reduction operation Computes the sum of tensor elements along specified axes

    Type Parameters

    • Input extends AnyTensorStorage

      Input tensor storage type

    • Axes extends readonly number[] | undefined

      Axes to reduce along (undefined means reduce all)

    • KeepDims extends boolean = false

      Whether to keep reduced dimensions as size 1

    • OutputDType extends AnyDType = Input["__dtype"]
    // Sum along axis 1, remove dimension
    type Input = TensorStorage<Float32, [2, 3, 4], [12, 4, 1], DefaultLayoutFlags>;
    type Result = SumOp<Input, [1], false>; // Shape: [2, 4]
    // Sum all elements to scalar
    type Scalar = SumOp<Input, undefined, false>; // Shape: []