---
title: "ClikaRT::ops::bucketize"
sidebar_label: "bucketize"
description: "Bucket index of each input element against a sorted 1-D boundaries. With right == false (default) an element in [b[i-1], b[i]) maps to bucket i; right == true uses (b[i-1], b[i]]."
---

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

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

## bucketize() {#bucketize}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`bucketize`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `boundaries`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`bool` `out_int32` `=` `false`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`bool` `right` `=` `false`<br />
)

</div>

Bucket index of each `input` element against a sorted 1-D `boundaries`.

With `right == false` (default) an element in `[b[i-1], b[i])` maps to bucket `i`; `right == true` uses `(b[i-1], b[i]]`. Output shape mirrors `input`.

**Parameters**

- `input`: the values to bucket.
- `boundaries`: 1-D ascending bucket edges.
- `out_int32`: emit `Int32` indices instead of `Int64`; default false.
- `right`: flip the half-open side; default false.

**Returns:** integer bucket indices, shaped like `input`.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when `boundaries` is not 1-D.

<div class="api-declared">

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

</div>
