---
title: "ClikaRT::ops::full"
sidebar_label: "full"
description: "A new tensor of the given shape with every element set to fill_value. Each shape extent is an int literal or a 0-D integer Tensor (traces symbolically)."
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--function">function</span>

## full() {#full}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`full`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const` [`ScalarOrTensor`](../ScalarOrTensor.md)`>` `shape`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ScalarOrTensor`](../ScalarOrTensor.md) `fill_value`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`DataType`](../../index.md#DataType) `dtype`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`StreamOrDevice`](../StreamOrDevice.md) `device` `=` `{}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`StreamOrDevice`](../StreamOrDevice.md) `pinned_for` `=` `{}`<br />
)

</div>

A new tensor of the given shape with every element set to `fill_value`.

Each [`shape`](./shape.md#shape) extent is an int literal or a 0-D integer [Tensor](../Tensor.md) (traces symbolically). `fill_value` is a scalar literal or a tensor: a bool keeps Bool kind, an integer keeps its integer-ness across the boundary and stays exact past 2^53, and a tensor fills every element from its values (a 0-D tensor, or one broadcastable to [`shape`](./shape.md#shape)), the same write as [`fill_`](./fill_.md#fill_) on an [`empty`](./empty.md#empty) tensor in one kernel. [`Tensor::full`](../Tensor.md#full) is the literal-only form.

**Parameters**

- `shape`: extents, one per dim.
- `fill_value`: the value, cast to [`dtype`](../dtype/index.md).
- `dtype`: element type.
- `device`: stream or device. Default: the default device.
- `pinned_for`: peer-pinned host allocation (see [`empty`](./empty.md#empty)). Default: absent.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when `fill_value` is absent, a tensor it carries does not broadcast to [`shape`](./shape.md#shape), or an extent is negative (`code_name()` carries the reason).

**Returns:** a new filled tensor.

```cpp
auto neg_inf = ClikaRT::ops::full({b, s}, -1e9, ClikaRT::DataType::Float32);
```

<div class="api-declared">

Declared in `ClikaRT/compute/ops.h`, line 2400

</div>
