---
title: "sum"
sidebar_label: "sum"
description: "Kotlin binding reference: sum."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

//[clika-runtime](../../../index.md)/[io.clika.runtime](../index.md)/[Ops](index.md)/[sum](sum.md)

# sum

[common]\
fun [sum](sum.md)(input: [Tensor](../Tensor/index.md), dims: [LongArray](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html) = longArrayOf(), keepdim: [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) = false, dtype: [DType](../DType/index.md) = DType.UNDEFINED): [Tensor](../Tensor/index.md)

`sum(input: Tensor, dims: LongArray = longArrayOf(), keepdim: Boolean = false, dtype: DType = DType.UNDEFINED)`: the `sum` operator. Sums `input` over `dims`. Empty `dims` reduces EVERY dimension (a 0-D result unless `keepdim`). Integer inputs accumulate and return at their own dtype unless `dtype` widens them explicitly.