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

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

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

# TensorSpec

[common]\
class [TensorSpec](index.md)(val name: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), val dtype: [DType](../DType/index.md) = DType.FLOAT32, val dims: [LongArray](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html) = LongArray(0), val optional: [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) = false, val dimNames: [List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)&lt;[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)&gt; = emptyList())

A named, typed tensor slot of a model's contract. A [dims](dims.md) entry equal to [DYNAMIC_DIM](Companion/DYNAMIC_DIM.md) resolves at run time and an empty [dims](dims.md) leaves the shape unconstrained; [dimNames](dimNames.md) is empty or [dims](dims.md)-long with &quot;&quot; for an unnamed dim, and the same name on two slots declares one size; [optional](optional.md) marks an input the model runs without.

## Constructors

| | |
|---|---|
| [TensorSpec](TensorSpec.md) | [common]<br>constructor(name: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), dtype: [DType](../DType/index.md) = DType.FLOAT32, dims: [LongArray](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html) = LongArray(0), optional: [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) = false, dimNames: [List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)&lt;[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)&gt; = emptyList()) |

## Types

| Name | Summary |
|---|---|
| [Companion](Companion/index.md) | [common]<br>object [Companion](Companion/index.md) |

## Properties

| Name | Summary |
|---|---|
| [dimNames](dimNames.md) | [common]<br>val [dimNames](dimNames.md): [List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)&lt;[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)&gt; |
| [dims](dims.md) | [common]<br>val [dims](dims.md): [LongArray](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html) |
| [dtype](dtype.md) | [common]<br>val [dtype](dtype.md): [DType](../DType/index.md) |
| [name](name.md) | [common]<br>val [name](name.md): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) |
| [optional](optional.md) | [common]<br>val [optional](optional.md): [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) = false |

## Functions

| Name | Summary |
|---|---|
| [dimIsDynamic](dimIsDynamic.md) | [common]<br>fun [dimIsDynamic](dimIsDynamic.md)(i: [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)): [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)<br>True when dim [i](dimIsDynamic.md) is dynamic. |
| [dimName](dimName.md) | [common]<br>fun [dimName](dimName.md)(i: [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)<br>The dim's declared name, or &quot;&quot; (unnamed or out of range). |
| [mergeFrom](mergeFrom.md) | [common]<br>fun [mergeFrom](mergeFrom.md)(other: [TensorSpec](index.md)): [TensorSpec](index.md)<br>This spec widened by another observation of the same slot: a dim dynamic on either side stays dynamic, differing extents become dynamic, a rank clash makes every dim dynamic at the larger rank; a dim name is kept where the two agree or one is unnamed; the name and [optional](optional.md) are this spec's (the name adopted from [other](mergeFrom.md) when empty). Fails when the dtypes differ. |
| [toString](toString.md) | [common]<br>open override fun [toString](toString.md)(): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) |