Skip to content
fn

histc_op

→TensorImplPtr
int histc_op(const int & a, int bins, double lo, double hi)

Python wrappers

Public Python APIs implemented by this engine symbol.

Histogram counts over [lo,hi)[\mathrm{lo}, \mathrm{hi}) with bins uniform buckets.

Composite — counts-only wrapper around histogram_op. When lo == hi the range is auto-derived from the input via min_op and max_op, with the degenerate min == max case bumped by +1+1 so the bins remain well-defined (matches reference framework behaviour). Not differentiable — integer-valued output.

Math

Let w=(hi−lo)/binsw = (\mathrm{hi} - \mathrm{lo}) / \mathrm{bins}. Then for each bin index k∈[0,bins)k \in [0, \mathrm{bins}),

yk=# ⁣{ i:lo+kw≤ai<lo+(k+1)w } y_k = \#\!\left\{\, i : \mathrm{lo} + k w \le a_i < \mathrm{lo} + (k+1) w \,\right\}

See Also

histogram_op — full version that also returns bin edges.

Parameters

aTensorImplPtr
Input tensor of arbitrary shape.
binsint64
Number of histogram bins. Must be positive.
lodouble
Inclusive lower edge. If lo == hi, auto-range from min(a) to max(a).
hidouble
Exclusive upper edge.

Returns

TensorImplPtr

1-D tensor of length bins holding integer counts.

Raises

Failure
If a is null.

Notes

Values outside [lo, hi) are dropped silently by the underlying histogram_op — no overflow / underflow bins are returned.