---
title: "ClikaRT::ops::take"
sidebar_label: "take"
description: "Read elements of self at FLAT (row-major linearized) positions. self is treated as flattened 1-D: out[..] = self.flat[index[..]]. The output takes index's shape and self's dtype."
---

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

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

## take() {#take}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`take`**([`Tensor`](../Tensor.md) `self`, [`Tensor`](../Tensor.md) `index`)

</div>

Read elements of `self` at FLAT (row-major linearized) positions.

`self` is treated as flattened 1-D: `out[..] = self.flat[`[`index`](./index-fn.md#index)`[..]]`. The output takes [`index`](./index-fn.md#index)'s shape and `self`'s dtype. Index dtype law as [`gather`](./gather.md#gather).

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when an index is out of range or its dtype is wrong (`code_name()` carries the reason).

**Returns:** a new tensor shaped like [`index`](./index-fn.md#index), dtype of `self`.

<div class="api-declared">

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

</div>
