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

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

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

# countNonzero

[common]\
fun [countNonzero](countNonzero.md)(input: [Tensor](../Tensor/index.md), dims: [LongArray](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html) = longArrayOf()): [Tensor](../Tensor/index.md)

`countNonzero(input: Tensor, dims: LongArray = longArrayOf())`: the `count_nonzero` operator. Number of nonzero elements over `dims`. Empty `dims` counts across the whole tensor. Output dtype is always `Int64`. An element is nonzero exactly when its Bool cast is true: +0 and -0 are zero; a subnormal, an infinity and a NaN are nonzero.