---
title: "ClikaRT::ops::masked_select"
sidebar_label: "masked_select"
description: "The elements of input where mask is true, as a 1-D tensor. The output LENGTH is data-dependent (the number of true entries); under tracing it carries a data-dependent extent."
---

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

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

## masked\_select() {#masked_select}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`masked_select`**([`Tensor`](../Tensor.md) `input`, [`Tensor`](../Tensor.md) `mask`)

</div>

The elements of `input` where `mask` is true, as a 1-D tensor.

The output LENGTH is data-dependent (the number of true entries); under tracing it carries a data-dependent extent. `mask` is Bool and broadcasts to `input`'s shape.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when `mask` is not Bool or does not broadcast to `input` (`code_name()` carries the reason).

**Returns:** a new 1-D tensor of the selected elements, dtype of `input`.

<div class="api-declared">

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

</div>
