Autodoc¶
Generated from the header Doxygen comments (doxygen + moxygen). For a curated view see the Reference and Cheat sheet.
Classes¶
| Name | Description |
|---|---|
anyrank |
A rank-erased tensor for the host/ndarray dispatch boundary. |
anyrank_front |
A range of fixed-rank-Sr sub-views over an anyrank's batch axes. |
anyshape |
The shape spelling for the rank-erased anyrank boundary: exactly one etc marks the dynamic-rank region, the dims AFTER it are the static Tail (anchored at ndim), the dims BEFORE it are the static Head (anchored at 0). |
axis |
Compile-time axis selector — a value tag carrying a list of axes, the sibling of shape<...> for axis arguments. |
candidates_t |
One parameter's candidate list for dispatch_values — the runtime value paired with the compile-time values it is allowed to be. |
compute_type |
The type math should ACCUMULATE / compute in for element type T. |
compute_type< bfloat16 > |
|
compute_type< half > |
|
copy_meta_t |
Tag for as_anyrank(..., copy_meta): COPY shape/stride into an inline, device-passable store instead of wrapping the caller's arrays. |
cpp_alloc |
Host allocator using C++ new[] / delete[]. |
cuda_gpu_alloc |
Device (GPU) memory (cudaMalloc). |
cuda_mapped_alloc |
Page-locked + device-mapped (zero-copy) host memory (cudaHostAlloc). |
cuda_pinned_alloc |
Page-locked ("pinned") host memory (cudaMallocHost). |
dtype |
Compile-time element-type tag — a value carrier for T, the sibling of axis<...> for the dtype argument. |
into_t |
|
keep_strides |
Sentinel Layout selector for recast<NewShape, [keep_strides](#keep_strides)>() (the default): PRESERVE the source strides (fold where the source layout makes them derivable, keep runtime otherwise). |
keepdims_t |
numpy/pytorch keepdims=True tag for axis reductions — pass as any trailing keyword (composes with dtype<...>/axis<...>/into(dest) in any order) to keep the reduced axes as size-1 instead of removing them, so the result broadcasts back against the input: sum<0>(a, keepdims), sum(a, axis<0,2>{}, keepdims). |
none_t |
Open-ended slice sentinel — teeny's None (python a[:n] / a[m:]). |
owning_storage |
Generic owning storage (move-only, no ref-counting), parameterised by an allocator policy. |
peel_range |
A range of sub-views obtained by peeling Axes.... |
ptr_storage |
|
storage_policy |
|
gpu, N > |
|
gpu_view, N > |
|
heap, N > |
|
mapped, N > |
|
mapped_view, N > |
|
pinned, N > |
|
pinned_view, N > |
|
stack, N > |
|
view, N > |
|
storage_size |
Storage element count for a stack tensor (0 for view/owning). |
storage_size< Mapping, true > |
|
strides |
An mdspan layout policy with per-dimension static or dynamic strides — the stride analogue of extents/shape. |
tensor |
One N-dimensional tensor, parameterised by ownership. |
Enumerations¶
| Name | Description |
|---|---|
ellipsis_t |
The ellipsis marker (numpy ...) for the unspecified middle axes. |
storage |
Ownership / memory-space of a tensor's storage. |
ellipsis_t¶
The ellipsis marker (numpy ...) for the unspecified middle axes.
Its own type (an empty enum) keeps it distinct from any real extent value, and being an enum it is a valid non-type template argument for anyshape<...>.
It has two roles that never overlap, so one marker serves both:
-
when indexing,
t(1, ellipsis, 2)stands for as manyallas fill the rank; -
in an
anyshape<...>boundary tag it marks the rank-erased region — there it is conventionally spelledetc("and so on"), an alias ofellipsis. Soellipsis/ellipsis_tis the primary name andetc/etc_tthe alias:t(1, etc, 2)==t(1, ellipsis, 2)andanyshape<ellipsis, 3>==anyshape<etc, 3>. (The_is_ellipsisindexing trait lives in[indexing.h](#indexingh).)
storage¶
Ownership / memory-space of a tensor's storage.
view / stack need no allocator. The owning modes differ only in where the memory lives and how it is (de)allocated:
-
heap: ordinary C++new[]/delete[](host memory). -
gpu:cudaMalloc(device memory; not host-dereferenceable). -
pinned:cudaMallocHost(page-locked host memory — pytorch's "pinned"). -
mapped:cudaHostAlloc(page-locked + device-mapped / zero-copy). Thegpu/pinned/mappedstorage is defined in the opt-in[teeny/cuda.h](#cudah)(which needs the CUDA runtime); using them without it is a compile error.
| Value | Description |
|---|---|
view |
|
stack |
|
heap |
|
gpu |
|
pinned |
|
mapped |
|
gpu_view |
|
pinned_view |
|
mapped_view |
Typedefs¶
| Return | Name | Description |
|---|---|---|
layout_right |
ccontiguous |
Names for the two contiguous layouts: ccontiguous is C-contiguous (row-major, layout_right), fcontiguous is Fortran-contiguous (column-major, layout_left). |
layout_left |
fcontiguous |
|
ccontiguous |
corder |
Legacy aliases (corder/forder); prefer ccontiguous/fcontiguous. |
fcontiguous |
forder |
|
layout_stride |
dynamic_strides |
dynamic_strides — the all-runtime strided layout (layout_stride, a full runtime stride array). |
integral_constant< int, V > |
Int |
|
integral_constant< long, V > |
Long |
|
integral_constant< size_t, V > |
Size |
|
integral_constant< unsigned, V > |
UInt |
|
integral_constant< ptrdiff_t, V > |
Diff |
|
integral_constant< bool, V > |
Bool |
|
integral_constant< int8_t, V > |
Int8 |
|
integral_constant< int16_t, V > |
Int16 |
|
integral_constant< int32_t, V > |
Int32 |
|
integral_constant< int64_t, V > |
Int64 |
|
integral_constant< uint8_t, V > |
UInt8 |
|
integral_constant< uint16_t, V > |
UInt16 |
|
integral_constant< uint32_t, V > |
UInt32 |
|
integral_constant< uint64_t, V > |
UInt64 |
|
Int8< V > |
I1 |
|
Int16< V > |
I2 |
|
Int32< V > |
I4 |
|
Int64< V > |
I8 |
|
UInt8< V > |
U1 |
|
UInt16< V > |
U2 |
|
UInt32< V > |
U4 |
|
UInt64< V > |
U8 |
|
int8_t |
i1 |
|
int16_t |
i2 |
|
int32_t |
i4 |
|
int64_t |
i8 |
|
uint8_t |
u1 |
|
uint16_t |
u2 |
|
uint32_t |
u4 |
|
uint64_t |
u8 |
|
float |
f4 |
|
double |
f8 |
|
extents< int64_t, _dyn_extent(E)... > |
shape |
User-friendly shape type: shape<2,3,4> == extents<int64_t, 2,3,4>. |
extents< Idx, _dyn_extent(E)... > |
shape_as |
shape<...> with an explicit index type: shape_as<int32_t, -1,3,3>. |
shape_as< int32_t, E... > |
shape32 |
|
dextents< int64_t, N > |
rank |
Fully-dynamic shape of a given rank: rank<3> == shape<-1,-1,-1> == extents<int64_t, dynamic_extent, dynamic_extent, dynamic_extent>. |
ellipsis_t |
etc_t |
etc — the anyshape<...> spelling of ellipsis (same marker, same value). |
_kw::resolve_t< _dtype_arg, Expl, void, _is_dtype, Dflt, Tags... > |
dtype_arg_t |
|
tensor< T, Shape, Layout, storage::gpu > |
gpu |
Owning tensor in device (GPU) memory (move-only). |
tensor< T, Shape, Layout, storage::pinned > |
pinned |
Owning tensor in page-locked ("pinned") host memory (move-only). |
tensor< T, Shape, Layout, storage::mapped > |
mapped |
Owning tensor in mapped (zero-copy) host memory (move-only). |
tensor< T, dextents< offset_t, R >, layout_stride, O > |
dyn_tensor |
A fixed-rank, fully-dynamic, arbitrarily-strided tensor view. |
__half |
half |
IEEE binary16 — the native CUDA __half under nvcc. |
__nv_bfloat16 |
bfloat16 |
bfloat16 — the native CUDA __nv_bfloat16 under nvcc. |
typename compute_type< T >::type |
compute_type_t |
|
half |
f2 |
|
bfloat16 |
bf16 |
|
strides< S... > |
layout_static_stride |
Back-compat alias: the original all-static-stride layout name. |
_kw::resolve_t< _kw::keep_tag, Expl, void, _is_layout_tag, Dflt, Tags... > |
layout_arg_t |
layout_arg_t |
typename _promote< A, B, true >::type |
promote_t |
|
conditional_t<(is_floating_point< T >::value||!is_same< compute_type_t< T >, T >::value), conditional_t<(sizeof(T) >=sizeof(double)), T, double >, conditional_t<(sizeof(T) >=8), T, conditional_t< is_signed< T >::value, int64_t, uint64_t > > > |
reduce_type_t |
Default accumulator type for a reduction over element type T. |
integral_constant< storage, O > |
storage_c |
Value-tag carrier for an ownership mode, for the factories' value-tag backend form, e.g. |
tensor< T, Shape, Layout, storage::view > |
view |
A non-owning view type. |
tensor< T, Shape, Layout, storage::stack > |
local |
Stack-owned tensor (fully static shape). |
tensor< T, Shape, Layout, storage::heap > |
owned |
Heap-owned tensor (host only, move-only). |
ccontiguous¶
Names for the two contiguous layouts: ccontiguous is C-contiguous (row-major, layout_right), fcontiguous is Fortran-contiguous (column-major, layout_left).
Use wherever a Layout is expected — this is teeny's default and preferred spelling.
fcontiguous¶
corder¶
Legacy aliases (corder/forder); prefer ccontiguous/fcontiguous.
forder¶
dynamic_strides¶
dynamic_strides — the all-runtime strided layout (layout_stride, a full runtime stride array).
Prefer teeny's strides<S...> (folds known strides to immediates, and is what slicing produces); dynamic_strides is strides<> with every stride runtime.
Int¶
Long¶
Size¶
UInt¶
Diff¶
Bool¶
Int8¶
Int16¶
Int32¶
Int64¶
UInt8¶
UInt16¶
UInt32¶
UInt64¶
I1¶
I2¶
I4¶
I8¶
U1¶
U2¶
U4¶
U8¶
i1¶
i2¶
i4¶
i8¶
u1¶
u2¶
u4¶
u8¶
f4¶
f8¶
shape¶
User-friendly shape type: shape<2,3,4> == extents<int64_t, 2,3,4>.
The fixed-size int64_t index type matches DLPack's shape exactly, so it drops straight onto ndarray bindings. A dynamic dimension can be spelled either dynamic_extent or, numpy-style, -1 — so shape<-1,2,3> == shape<dynamic_extent,2,3> == extents<int64_t, dynamic_extent, 2, 3>. Use it in place of extents<...>: local<double, shape<3,3>>, owned<float, shape<-1,4>>.
shape_as¶
shape<...> with an explicit index type: shape_as<int32_t, -1,3,3>.
shape<> is the int64 default (DLPack's index type); shape32<...> narrows the offset math to int32 for the kernel-boundary view (see reindex). The -1 == dynamic rule is the same.
shape32¶
rank¶
Fully-dynamic shape of a given rank: rank<3> == shape<-1,-1,-1> == extents<int64_t, dynamic_extent, dynamic_extent, dynamic_extent>.
Handy for a rank-N view whose sizes are all runtime: view<float, rank<3>>. rank<0> is the rank-0 (scalar) shape.
etc_t¶
etc — the anyshape<...> spelling of ellipsis (same marker, same value).
dtype_arg_t¶
gpu¶
Owning tensor in device (GPU) memory (move-only).
gpu<T,E>(extents).
pinned¶
Owning tensor in page-locked ("pinned") host memory (move-only).
pinned<T,E>(extents) — pytorch's pin_memory.
mapped¶
Owning tensor in mapped (zero-copy) host memory (move-only).
mapped<T,E>(extents).
dyn_tensor¶
A fixed-rank, fully-dynamic, arbitrarily-strided tensor view.
O is the memory space of the view — [storage::view](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a1bda80f2be4d3658e0baa43fbe7ae8c1) (host) by default, [storage::gpu_view](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a716b431c57855c3a30f4c286ad4f0299) when the pointer lives in device memory (see anyrank's Space).
half¶
IEEE binary16 — the native CUDA __half under nvcc.
bfloat16¶
bfloat16 — the native CUDA __nv_bfloat16 under nvcc.
compute_type_t¶
f2¶
bf16¶
layout_static_stride¶
Back-compat alias: the original all-static-stride layout name.
layout_arg_t¶
layout_arg_t
That precedence rule (and its wording) lives ONCE, in _kw::resolve (kwargs.h) – shared with dtype_arg_t/storage_arg. Unlike dtype_arg_t, no unwrapping is needed here: the tag itself IS the layout type, so the answer is the tag that was found (keep_tag, which also supplies Dflt when there was none).
promote_t¶
reduce_type_t¶
using reduce_type_t = conditional_t<(is_floating_point< T >::value||!is_same< compute_type_t< T >, T >::value), conditional_t<(sizeof(T) >=sizeof(double)), T, double >, conditional_t<(sizeof(T) >=8), T, conditional_t< is_signed< T >::value, int64_t, uint64_t > > >
Default accumulator type for a reduction over element type T.
double for floating-point types narrower than double (float, half, bfloat16) — enough headroom that summing many low-precision values doesn't lose catastrophically; a floating type already at least as wide as double (double itself, or long double) keeps itself — long double is double-sized on some ABIs (e.g. MSVC, arm64 macOS), where widening it would be a no-op precision-wise but a needless type change. Integer types narrower than 8 bytes accumulate in 64-bit (int64_t if signed, uint64_t if unsigned — bool counts as unsigned) so that summing / multiplying many small integers can't overflow mid-accumulation (signed overflow is UB); integers already ≥8 bytes keep their own type. The RESULT is still cast back to the element type T (accumulate wide, cast down); a caller who wants the untruncated wide value uses the explicit accumulator (sum<int64_t>(a)). Half types are spotted via [compute_type](#compute_type) (the only T whose compute type differs from itself). Override per call, e.g. sum<float>(a).
storage_c¶
Value-tag carrier for an ownership mode, for the factories' value-tag backend form, e.g.
empty<T>(shape, storage_c<[storage::gpu](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a0aa0be2a866411d9ff03515227454947)>{}).
view¶
A non-owning view type.
Construct as view<T,E>(ptr, extents).
local¶
Stack-owned tensor (fully static shape).
Use local<T,E>{}.
owned¶
Heap-owned tensor (host only, move-only).
Use owned<T,E>(extents).
Functions¶
| Return | Name | Description |
|---|---|---|
auto |
make_gpu |
|
auto |
make_pinned |
|
auto |
make_mapped |
|
auto |
to |
Move x to memory space Space ([storage::gpu](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a0aa0be2a866411d9ff03515227454947)/pinned/mapped/heap), optionally converting the element type to ET — the memory-backend half of pytorch's .to. |
auto |
to |
Rvalue overload of to<Space>: a temporary source cannot be borrowed (the no-copy branch would dangle — and for a device temporary would point at freed device memory). |
DLManagedTensor * |
to_dlpack |
Export a view (view / gpu_view / pinned_view / mapped_view) to a DLManagedTensor (borrows the data — the caller must keep the underlying memory alive; only the metadata is owned by the capsule). |
DLManagedTensor * |
to_dlpack |
Export an owning tensor, TRANSFERRING ownership of the buffer into the capsule (the tensor is moved-from; the capsule's deleter frees the buffer). |
DLTensor |
to_dltensor |
Export to a bare DLTensor (unmanaged — no capsule, no deleter, no allocation). |
auto |
from_dlpack |
Import a DLManagedTensor of known element type T as an anyrank (runtime rank). |
auto |
from_dlpack |
Import a bare DLTensor (unmanaged — no deleter). |
auto |
from_dlpack |
Import a versioned managed tensor (DLPack 1.0+, what a modern __dlpack__(max_version=…) emits). |
auto |
from_dlpack |
Import with a STATIC TRAILING shape baked into the carrier's type — from_dlpack<float, anyshape<etc,-1,-1,3>>(m) for a (*batch, *spatial, C) tensor with a static channel count. |
auto |
from_dlpack |
|
auto |
from_dlpack |
|
auto |
from_dlpack |
Import as a fixed-rank view (requires the payload's ndim == R). |
auto |
from_dlpack |
|
auto |
from_dlpack |
|
bool |
dispatch_dlpack |
Import + dispatch: read the dtype/rank from the DLManagedTensor and call f with a fixed-rank typed view (one instantiation per (dtype, rank)). |
bool |
dispatch_dlpack_dtype |
Import + dtype-only dispatch that PRESERVES the rank: read the dtype from the capsule and call f with the typed anyrank (rank still dynamic), instead of collapsing to a fixed rank like dispatch_dlpack. |
auto |
reindex |
Free forms of reindex/index_fits for anyrank — the whole-carrier twins of tensor's free forms (tensor.h): deduce the carrier, so a type-dependent receiver (e.g. |
bool |
index_fits |
|
anyrank< T, offset_t, _meta_view< offset_t >, Space > |
as_anyrank |
Build an anyrank that wraps the caller's shape/stride arrays with no copy (the default) — e.g. |
anyrank< T, offset_t, _meta_store< offset_t, MaxRank >, Space > |
as_anyrank |
as_anyrank(data, shape, stride, ndim, copy_meta) — COPY shape/stride into an inline store, so the carrier is trivially copyable and can be passed into a CUDA kernel by value (peel on device). |
auto |
as_anyrank |
as_anyrank(..., anyshape<etc,c,c>{}[, layout]) — carry a STATIC TRAILING shape (and, with a layout tag, static trailing STRIDES) in the carrier's type, so fixed/peel_front hand out cells with those inner extents/strides already folded (no per-call recast). |
auto |
as_anyrank |
as_anyrank(..., copy_meta, anyshape<etc,c,c>{}[, layout]) — the static-tail carrier over an INLINE (device-passable) meta store. |
void |
dispatch_index |
Narrow a view's — or a whole anyrank carrier's — OFFSET INDEX WIDTH to Idx2 (default int32_t) when the narrowing is lossless, then call f — else call f with the argument as-is. |
void |
dispatch_layout |
Runtime-classify a DYNAMIC-strided view's contiguity and hand f a view whose LAYOUT is baked into the type — ccontiguous (C-order) or fcontiguous (F-order) when the runtime strides match, else the original dynamic_strides. |
bool |
dispatch_rank |
Call f with a fixed-rank view of t chosen by its runtime ndim. |
bool |
dispatch_value |
Turn a runtime value into a compile-time one from a candidate list. |
constexpr candidates_t< Vs... > |
candidates constexpr noexcept |
candidates<1,2,3>(d) — one dispatch_values parameter: the compile-time candidates as template arguments, the runtime value as the argument. |
bool |
dispatch_values |
The product form of dispatch_value: turn SEVERAL runtime values into compile-time ones in one call, one candidate list per parameter. |
auto |
slice |
A python-like slice [start : stop : step) for operator() / slice_along. |
auto |
slice |
|
auto |
slice |
|
auto |
peel_at |
The i-th sub-view obtained by peeling Axes... (0 <= i < product of the peeled extents). |
auto |
peel_at |
|
auto |
peel_at |
|
auto |
peel_at |
|
auto |
peel_at |
|
auto |
peel |
Build a range of sub-views by peeling Axes... of t. |
auto |
peel |
|
auto |
peel |
|
auto |
peel |
|
peel_range< MD, storage::view, Axes... > |
peel_of |
Build a range of sub-views over a raw mdspan. |
auto |
peel_front |
Peel the FIRST N axes -> a range of sub-views over the rest — the runtime-batch-rank half of (*batch, *spatial, C). |
auto |
peel_front |
|
auto |
peel_front_at |
The i-th sub-view obtained by peeling the first N axes (grid-stride style). |
auto |
peel_front_at |
|
tensor< T, E, L, O >::index_type |
size_front |
The number of sub-views peel_front<N>(t) would yield — the product of the peeled leading extents — computed directly, without materialising the range. |
auto |
peel_zip |
Zip-peel 2 tensors' Axes... in lock-step -> a range of tuple<ViewA,ViewB> (numpy-style broadcast: shapes may differ as long as they're broadcast-compatible; Axes... name axes in the BROADCAST rank's numbering — the larger of the two operands' own ranks — negatives wrap against it). |
auto |
peel_zip |
|
auto |
peel_zip |
|
auto |
peel_zip |
|
auto |
peel_zip |
Zip-peel 3 tensors' Axes... in lock-step -> a range of tuple<ViewA,ViewB,ViewC> (same broadcast/axis-numbering rule as the 2-tensor form). |
auto |
peel_zip |
|
auto |
peel_zip |
|
auto |
peel_zip |
|
void |
scan_ |
In-place sequential fold ("scan") along axis Axis, batched over every other axis: carry = init, then for each element along Axis (in increasing order) carry = f(carry, x), x = carry– the new carry doubles as the new element. |
void |
scan_ |
|
void |
scan_ |
Value form + trailing keyword bag: scan_(t, init, f, axis<Axis>{}) == scan_<Axis>(t, init, f). |
void |
scan_ |
|
auto |
scan |
Out-of-place twin of scan_: a fresh dense copy of t, scanned. |
auto & |
scan |
into(dest) form: write the scanned result into a preallocated dest (a shape matching t's EXACTLY, checked – a static_assert when both are static, _TNY_CHECK otherwise; unlike copy_'s own numpy-style broadcast, dest must match rather than merely receive a broadcast copy, since scan_ then walks dest's own axis numbering) – one copy, no fresh allocation beyond that; device-safe. |
decltype(auto) |
scan |
Value form + trailing keyword bag: scan(t, init, f, axis<Axis>{}) == scan<Axis>(t, init, f), and scan(t, init, f, axis<Axis>{}, into(dest)) == scan<Axis>(t, init, f, into(dest)). |
auto |
operator+ |
|
auto |
operator* |
|
auto |
operator- |
|
auto |
operator/ |
|
auto |
operator- |
|
auto |
operator~ |
|
auto |
sum |
Sum of all elements (empty -> 0). |
auto |
prod |
Product of all elements (empty -> 1). |
auto |
max |
Maximum element. |
auto |
min |
Minimum element. |
reduce_to< _reduce_result_t< Acc, _mean_result_t< T > > > |
||
_acc_t< Acc, T > auto |
dot |
Inner product over matching extents. |
auto |
sqnorm |
Squared Euclidean norm — the sum of squares Σ aᵢ², over ALL axes. |
auto |
norm |
Euclidean (L2) norm √Σ aᵢ², over ALL axes. |
reduce_to< _reduce_result_t< Acc, _mean_result_t< T > > > |
||
conditional_t< is_void< Acc >::value, _norm_root_t< T >, Acc > auto |
sqdist |
Squared Euclidean distance Σ(aᵢ-bᵢ)² between two same-shape tensors — mathematically sqnorm(a-b), computed as one fused pass with no a-b intermediate (mirrors dot's convenience-wrapper status over a manual sum(a*b)). |
auto |
dist |
Euclidean distance √Σ(aᵢ-bᵢ)² — mathematically norm(a-b), one fused pass (see sqdist's doc comment for the accuracy note). |
auto |
normalize |
Out-of-place unit vector a / norm(a) -> a NEW dense tensor (static shape -> stack, dynamic -> heap). |
auto & |
normalize |
normalize(a, into(y)) — the unit vector into a caller buffer y. |
auto |
normalize |
normalize<Axes...>(a) — unit vectors along the named axes: each element divided by the L2 norm over those axes (keepdim broadcast). |
auto |
normalize |
|
auto & |
normalize |
normalize<Axes...>(a, into(y)) — the axis-scoped unit vectors into a caller buffer y, whose shape must match a's EXACTLY (only the DIVISOR is reduced, so the result keeps the source's full shape). |
auto & |
normalize |
|
auto |
cross |
3D cross product a × b -> a NEW stack 3-vector of promote(Ta,Tb). |
auto & |
cross |
cross(a, b, into(y)) — the cross product into a caller buffer y (rank-1, length 3); y may alias a or b. |
bool |
allclose |
True if every element satisfies \|a-b\| <= atol + rtol*\|b\| (numpy allclose; broadcasts, computes in the compute type of the promoted element type). |
decltype(auto) |
allclose |
Generic trailing keyword bag for allclose — dot/sqdist/dist's binary (no axis concept) shape, with numpy's OPTIONAL rtol/atol positionals kept ahead of the bag: allclose(a, b, dtype<double>{}), allclose(a, b, into(cell)), allclose(a, b, rtol, into(cell)), allclose(a, b, rtol, atol, dtype<double>{}, into(cell)). |
decltype(auto) |
allclose |
allclose(a, b, tags...) — the keyword bag with both tolerances defaulted. |
decltype(auto) |
allclose |
allclose(a, b, rtol, tags...) — the keyword bag with atol defaulted. |
auto |
minimum |
|
auto |
maximum |
|
auto |
minimum |
|
auto |
maximum |
|
auto & |
minimum |
|
auto & |
maximum |
|
auto & |
minimum |
|
auto & |
maximum |
|
auto |
clamp |
clamp(a, lo, hi) -> a new tensor with each element clamped; clamp(a, lo, hi, into(y)) writes into y. |
auto & |
clamp |
|
auto |
mean |
Arithmetic mean of all elements. |
constexpr bool |
storage_is_owning constexpr noexcept |
Whether the mode owns (and therefore allocates) its storage. |
constexpr bool |
storage_is_view constexpr noexcept |
Whether the mode is a non-owning view (view/gpu_view/pinned_view/ mapped_view) — the pointer-wrapping modes (vs stack's inline array). |
constexpr bool |
storage_is_device constexpr noexcept |
Whether the storage lives in device (GPU) memory (owning or view). |
constexpr bool |
storage_is_host_accessible constexpr noexcept |
Whether the storage is dereferenceable from the host. |
constexpr storage |
storage_view_of constexpr noexcept |
The non-owning VIEW kind that preserves a source's memory space: a device source (gpu/gpu_view) -> gpu_view, a pinned/mapped source -> pinned_view/mapped_view, anything else -> view. |
constexpr storage |
storage_arg constexpr |
storage_arg |
constexpr storage |
storage_resolve constexpr noexcept |
Resolve a factory's ownership: an explicitly named mode passes through, storage_deduce becomes stack for a static shape / heap for a dynamic one. |
tensor< typename MD::element_type, typename MD::extents_type, typename MD::layout_type, OW > |
as_tensor |
Wrap any cuda::std::mdspan (e.g. |
void |
fetch_add noexcept |
Accumulate v into *p, atomic on both host and device (#257). |
into_t< tensor< T, E, L, O > > |
into noexcept |
into(y) — the output-destination tag: pass it as the last argument to an out-of-place math producer (a.add(b, into(y)), cross(a,b,into(y)), exp(a, into(y)), …) to write the result into y (one fused pass, no allocation) and get y& back, instead of a freshly allocated result. |
into_t< tensor< T, E, L, O > > |
into noexcept |
into(y) over a TEMPORARY view — the destination may be written straight out of a view-producing op, with no named intermediate: cross(a, b, into(N(i, all))), sum(a, into(cells.at(i, j))), x.add(y, into(z.permute<1,0>())). |
auto |
reindex |
Free forms of reindex/index_fits — deduce the tensor, so a type-dependent receiver avoids .template: reindex<int32_t>(t), index_fits<int32_t>(t). |
auto |
reindex |
|
bool |
index_fits |
|
auto |
wrap |
Wrap p as a non-owning view with a contiguous layout (default C-order). |
auto |
wrap |
Value-tag layout form: wrap(p, e, fcontiguous{}) == wrap<fcontiguous>(p, e) — deduces the layout from a bare ccontiguous{}/fcontiguous{} argument instead of an explicit <Layout> template argument, so a type-dependent receiver needs no .template. |
auto |
wrap |
wrap(mdspan) — a spelling of as_tensor(mdspan) under the one factory name users already reach for. |
auto |
wrap |
Wrap p as a non-owning view with explicit runtime strides (a layout_stride view). |
auto |
wrap |
Wrap p as a non-owning view with per-dimension compile-time strides (may be negative): pass a strides<S...>{} as the third argument. |
auto |
wrap |
Wrap p with a mix of static and runtime strides — the exact analogue of shape<-1,2,3,-1>{d0,d1} for strides. |
auto |
make_view |
make_view<L>(ptr, extents) — a non-owning view (alias of wrap). |
auto |
make_view |
Value-tag layout form, mirroring wrap's (#374): make_view(p, e, fcontiguous{}) == make_view<fcontiguous>(p, e), deduced from a bare ccontiguous{}/fcontiguous{} argument so a type-dependent receiver needs no .template. |
auto |
empty |
empty<T>(extents) — a new UNINITIALISED tensor. |
auto |
empty |
BACKEND-LED entry point — the one spelling the T-led entry point above cannot cover: a LEADING explicit template argument that names the BACKEND rather than the element type (empty<[storage::pinned](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a8a4f12ef77f9e30413cabd15cf16c913)>(e, dtype<double>{}, fcontiguous{})), because a value can never bind the class T of the entry point above. |
auto |
make_local |
make_local<T>(extents) — a stack-owned tensor (static shape). |
auto |
make_heap |
make_heap<T>(extents) — a heap-owned tensor (host, move-only). |
auto |
full |
full(extents, v) — a new tensor filled with v. |
auto |
full |
BACKEND-LED entry point — a LEADING explicit template argument that names the BACKEND rather than the element type: full<[storage::pinned](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a8a4f12ef77f9e30413cabd15cf16c913)>(e, v, dtype<double>{}, fcontiguous{}). |
auto |
zeros |
zeros<T>(extents) / ones<T>(extents) — a new tensor of 0s / 1s. |
auto |
zeros |
BACKEND-LED entry point — see [empty()](#empty)'s twin above (#373). |
auto |
ones |
|
auto |
ones |
BACKEND-LED entry point — see [empty()](#empty)'s twin above (#373). |
auto |
arange |
arange<T>(n) — a 1-D tensor [0, 1, ..., n-1] (heap, host). |
auto |
arange |
BACKEND-LED entry point — see [empty()](#empty)'s twin above (#373). |
auto |
arange |
Static arange<T, N>() — a stack [0..N-1] (host+device, folds). |
auto |
arange |
arange<T>(Int<N>()) — the static form spelled with a static integer. |
make_gpu¶
template<class T = void, class Layout = void, class Shape, class... Tags> auto make_gpu(Shape e, Tags... tags)
make_pinned¶
template<class T = void, class Layout = void, class Shape, class... Tags> auto make_pinned(Shape e, Tags... tags)
make_mapped¶
template<class T = void, class Layout = void, class Shape, class... Tags> auto make_mapped(Shape e, Tags... tags)
to¶
template<storage Space, class ET = void, bool Force = false, class T, class Shape, class Layout, storage O> auto to(const tensor< T, Shape, Layout, O > & x)
Move x to memory space Space ([storage::gpu](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a0aa0be2a866411d9ff03515227454947)/pinned/mapped/heap), optionally converting the element type to ET — the memory-backend half of pytorch's .to.
ET defaults to the source type.
auto d = to<storage::gpu>(h); // upload host -> device
auto e = to<storage::gpu, half>(h); // convert to half AND upload
auto c = to<storage::heap>(d); // download device -> host
Force false and no dtype change, a source already in a compatible space borrows instead of copying — the exact same space (heap->heap, gpu->gpu), OR a device source moving to a device space (a gpu OR a gpu_view slice -> gpu). So the common "send data that's
already on the device to the device" returns a gpu_view, NOT a host round-trip. Pass Force = true for a fresh owning copy:
auto v = to<storage::gpu>(g); // g is gpu (or a gpu_view slice) -> a view, no copy
auto k = to<storage::gpu, void, true>(g); // forced: a fresh gpu copy
cudaMemcpy — no host hop; a strided device source falls back to the host densify (a device gather kernel is the #50 follow-up). A device -> host copy downloads via cudaMemcpy (any layout C/F/strided preserved, densified on the host). A host -> device copy reads the source directly (gathering only the viewed extent) and uploads. Space == stack needs a static shape.
:::note
The no-copy branch returns a borrow of x (a gpu_view for a device source, else a host view), so it must outlive the result — same lifetime rule as [view()](#view)/permute()/slicing. On a temporary the rvalue overload below instead moves a same-space dense owning source (steals its buffer) or forces a copy, so nothing dangles. NB a contiguous device download copies exactly numel; a strided device download still copies its full span (over-copies — #50).
:::
to¶
template<storage Space, class ET = void, bool Force = false, class T, class Shape, class Layout, storage O> auto to(tensor< T, Shape, Layout, O > && x)
Rvalue overload of to<Space>: a temporary source cannot be borrowed (the no-copy branch would dangle — and for a device temporary would point at freed device memory).
A same-space, same-dtype, dense OWNING temporary is moved (its buffer stolen — no copy, no round-trip); otherwise this forces a fresh owning copy (which, for a device->device contiguous source, is the device-to-device path above, not a host round-trip).
to_dlpack¶
template<class T, class Shape, class Layout, storage O, enable_if_t< storage_is_view(O), int > = 0> DLManagedTensor * to_dlpack(const tensor< T, Shape, Layout, O > & t, DLDevice dev = { _dl::device_of< O >(), 0 })
Export a view (view / gpu_view / pinned_view / mapped_view) to a DLManagedTensor (borrows the data — the caller must keep the underlying memory alive; only the metadata is owned by the capsule).
The device defaults to the tensor's memory space (kDLCPU for a host view, kDLCUDA for a gpu_view, kDLCUDAHost for a pinned_view/ mapped_view; pass dev to override). The consumer owns the returned pointer and MUST call m->deleter(m) exactly once.
to_dlpack¶
template<class T, class Shape, class Layout, storage O, enable_if_t< storage_is_owning(O), int > = 0> DLManagedTensor * to_dlpack(tensor< T, Shape, Layout, O > && t)
Export an owning tensor, TRANSFERRING ownership of the buffer into the capsule (the tensor is moved-from; the capsule's deleter frees the buffer).
Device is taken from the tensor's memory space.
to_dltensor¶
template<class T, class Shape, class Layout, storage O> DLTensor to_dltensor(const tensor< T, Shape, Layout, O > & t, int64_t * shape_out, int64_t * strides_out, DLDevice dev = { _dl::device_of< O >(), 0 })
Export to a bare DLTensor (unmanaged — no capsule, no deleter, no allocation).
Borrows both the data AND the shape/stride arrays: the caller supplies shape_out/strides_out (each ≥ t.rank()``int64_ts), which this fills, and the returned DLTensor points at them + t.data(). The caller must keep the tensor's memory and those two buffers alive for as long as the DLTensor is used. Use for a consumer that takes a plain DLTensor rather than a managed capsule. Device defaults to the tensor's memory space (override with dev). Works for any storage (a pure borrow).
from_dlpack¶
Import a DLManagedTensor of known element type T as an anyrank (runtime rank).
The shape/stride METADATA is copied into the carrier (so it is self-contained), while the DATA is BORROWED — the caller keeps m alive while the view is used, then calls m->deleter(m). A null strides (DLPack's C-contiguous shorthand) is expanded to row-major. byte_offset is folded into the data pointer.
Space is the memory space to tag the carrier with (default [storage::view](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a1bda80f2be4d3658e0baa43fbe7ae8c1) = host); every view peeled off it inherits it. It is checked against m->dl_tensor.device: importing a kDLCUDA capsule as the default host Space trips _TNY_CHECK — spell from_dlpack<T, [storage::gpu_view](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a716b431c57855c3a30f4c286ad4f0299)>(m) so fixed()/peel_front yield device-tagged views (no host deref of a device pointer). (Closes the #38 hole where the device field was ignored and a device capsule silently became a host view.)
from_dlpack¶
Import a bare DLTensor (unmanaged — no deleter).
Borrows the data, copies the metadata; the CALLER owns the whole lifetime (there is nothing to free). Use when a producer hands you a plain DLTensor* rather than a capsule. Same Space/device check as the managed overload.
from_dlpack¶
template<class T, storage Space = storage::view> auto from_dlpack(const DLManagedTensorVersioned * m)
Import a versioned managed tensor (DLPack 1.0+, what a modern __dlpack__(max_version=…) emits).
Reads its dl_tensor payload; as with the classic capsule the caller keeps m alive and calls m->deleter(m).
from_dlpack¶
template<class T, class S, storage Space = storage::view, class Layout = keep_strides, enable_if_t< _is_anyshape< S >::value, int > = 0> auto from_dlpack(const DLManagedTensor * m, Layout = {})
Import with a STATIC TRAILING shape baked into the carrier's type — from_dlpack<float, anyshape<etc,-1,-1,3>>(m) for a (*batch, *spatial, C) tensor with a static channel count.
The payload's trailing dims are debug-checked against the tag once, here at the import boundary (next to the producer), then folded into every fixed/peel_front cell — no per-call recast. etc = the erased batch (see anyshape); the Space device check is the same as the tag-less overloads. Accepts all three carriers.
Pass a layout tag by value to also fold the trailing STRIDES: from_dlpack<float, anyshape<etc,-1,-1,3>>(m, ccontiguous{}) bakes a C-contiguous inner block (checked vs the payload's strides here — the "input
is contiguous" precondition, asserted at the boundary once instead of a per-call recast/dispatch_layout). Default [keep_strides](#keep_strides) keeps them runtime.
from_dlpack¶
template<class T, class S, storage Space = storage::view, class Layout = keep_strides, enable_if_t< _is_anyshape< S >::value, int > = 0> auto from_dlpack(const DLTensor * dt, Layout = {})
from_dlpack¶
template<class T, class S, storage Space = storage::view, class Layout = keep_strides, enable_if_t< _is_anyshape< S >::value, int > = 0> auto from_dlpack(const DLManagedTensorVersioned * m, Layout = {})
from_dlpack¶
template<class T, size_t R, storage Space = storage::view> auto from_dlpack(const DLManagedTensor * m)
Import as a fixed-rank view (requires the payload's ndim == R).
Returns a layout_stride tensor view borrowing the data. Space (default host [storage::view](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a1bda80f2be4d3658e0baa43fbe7ae8c1)) tags the view and is checked against the device, as in the anyrank overloads — from_dlpack<T, R, [storage::gpu_view](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a716b431c57855c3a30f4c286ad4f0299)>(m) for a device tensor. Accepts all three carriers (managed / bare / versioned).
from_dlpack¶
from_dlpack¶
template<class T, size_t R, storage Space = storage::view> auto from_dlpack(const DLManagedTensorVersioned * m)
dispatch_dlpack¶
template<storage Space = storage::view, class Carrier, class F> bool dispatch_dlpack(const Carrier * m, F && f)
Import + dispatch: read the dtype/rank from the DLManagedTensor and call f with a fixed-rank typed view (one instantiation per (dtype, rank)).
Returns false if the dtype/rank is outside the supported set. Data borrowed; caller owns m. Space (default host [storage::view](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a1bda80f2be4d3658e0baa43fbe7ae8c1)) tags the views and is checked against the capsule's device — dispatch a device capsule with dispatch_dlpack<[storage::gpu_view](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a716b431c57855c3a30f4c286ad4f0299)>(m, f).
dispatch_dlpack_dtype¶
template<storage Space = storage::view, class Carrier, class F> bool dispatch_dlpack_dtype(const Carrier * m, F && f)
Import + dtype-only dispatch that PRESERVES the rank: read the dtype from the capsule and call f with the typed anyrank (rank still dynamic), instead of collapsing to a fixed rank like dispatch_dlpack.
The caller then peels its own axes — the (*batch, *spatial, C) batch idiom for (auto cell : at.peel_front<-Sr>()) …, which instantiates the kernel once per Sr, not once per total rank. Returns false for an unsupported dtype. Data borrowed; caller owns m. Space tags the carrier and is checked against the capsule's device (see from_dlpack).
reindex¶
template<class Idx2, class T, class offset_t, class Meta, storage Space, class Tail, class TailS, class Head, class HeadS> auto reindex(const anyrank< T, offset_t, Meta, Space, Tail, TailS, Head, HeadS > & a)
Free forms of reindex/index_fits for anyrank — the whole-carrier twins of tensor's free forms (tensor.h): deduce the carrier, so a type-dependent receiver (e.g.
inside a generic dispatch_dlpack_dtype- style functor) can write reindex<Idx2>(at) / index_fits<Idx2>(at) without the .template disambiguator. (Idx2 is a TYPE, so there is no value form.) [anyrank::reindex](#reindex-3) is const-only (unlike tensor's mutable/const pair), so only one overload is needed here. No MaxRank parameter: it would sit 10th in the deduced list, so a caller could not practically override it without spelling out every preceding deduced parameter by hand; this free form always takes the member's own default (the carrier's max_rank) — call the member directly (at.reindex<Idx2, 8>()) when a custom capacity is needed.
index_fits¶
template<class Idx2, class T, class offset_t, class Meta, storage Space, class Tail, class TailS, class Head, class HeadS> bool index_fits(const anyrank< T, offset_t, Meta, Space, Tail, TailS, Head, HeadS > & a)
as_anyrank¶
template<storage Space = storage::view, class T, class offset_t> anyrank< T, offset_t, _meta_view< offset_t >, Space > as_anyrank(T * data, offset_t * shape, offset_t * stride, int ndim)
Build an anyrank that wraps the caller's shape/stride arrays with no copy (the default) — e.g.
straight off a DLPack tensor. The arrays must outlive the carrier. HOST only: the pointers are not valid inside a device kernel, so peel/dispatch on the host and pass the resulting fixed-rank views to the device. To instead copy into an inline, device-passable store, pass the copy_meta tag (overload below). DLPack strides are in ELEMENTS; numpy __array_interface__ in BYTES (divide by the itemsize first).
Space is the memory space of data (default [storage::view](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a1bda80f2be4d3658e0baa43fbe7ae8c1) = host); pass as_anyrank<[storage::gpu_view](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a716b431c57855c3a30f4c286ad4f0299)>(...) for a device pointer so the views peeled off it are gpu_view-tagged. (The shape/stride metadata arrays are host either way — Space labels the DATA, not the metadata store.)
as_anyrank¶
template<size_t MaxRank = TNY_MAX_RANK, storage Space = storage::view, class T, class offset_t> anyrank< T, offset_t, _meta_store< offset_t, MaxRank >, Space > as_anyrank(T * data, const offset_t * shape, const offset_t * stride, int ndim, copy_meta_t)
as_anyrank(data, shape, stride, ndim, copy_meta) — COPY shape/stride into an inline store, so the carrier is trivially copyable and can be passed into a CUDA kernel by value (peel on device).
MaxRank sets the inline capacity (default TNY_MAX_RANK); pass it as as_anyrank<64>(..., copy_meta). Accepts const arrays (it copies).
as_anyrank¶
template<storage Space = storage::view, class T, class offset_t, class S, class Layout = keep_strides, enable_if_t< _is_anyshape< S >::value, int > = 0> auto as_anyrank(T * data, offset_t * shape, offset_t * stride, int ndim, S, Layout = {})
as_anyrank(..., anyshape<etc,c,c>{}[, layout]) — carry a STATIC TRAILING shape (and, with a layout tag, static trailing STRIDES) in the carrier's type, so fixed/peel_front hand out cells with those inner extents/strides already folded (no per-call recast).
The runtime shape/strides' trailing dims are debug-checked against the tag once, here, then trusted. etc = the erased batch; the dims after it are the static tail (see anyshape). The optional layout tag chooses the trailing strides (like recast's 2nd arg): [keep_strides](#keep_strides) (default — strides stay runtime), ccontiguous/fcontiguous (fold the contiguous inner block — the "input is contiguous" precondition, checked here), or strides<S...> (impose them). Wraps the caller's arrays (no copy).
as_anyrank¶
template<size_t MaxRank = TNY_MAX_RANK, storage Space = storage::view, class T, class offset_t, class S, class Layout = keep_strides, enable_if_t< _is_anyshape< S >::value, int > = 0> auto as_anyrank(T * data, const offset_t * shape, const offset_t * stride, int ndim, copy_meta_t, S, Layout = {})
as_anyrank(..., copy_meta, anyshape<etc,c,c>{}[, layout]) — the static-tail carrier over an INLINE (device-passable) meta store.
dispatch_index¶
Narrow a view's — or a whole anyrank carrier's — OFFSET INDEX WIDTH to Idx2 (default int32_t) when the narrowing is lossless, then call f — else call f with the argument as-is.
The kernel-boundary primitive behind the int32 fast path (#115): it instantiates f for BOTH widths and picks at run time via index_fits/reindex, so a genuinely dynamic view runs its offset math in 32-bit (half the by-value footprint, fewer device registers) exactly when that is lossless. _TNY_HOST; preserves the view's mutability. Use it standalone on a known-rank view (or a peel_front batch cell), or via dispatch_rank<narrow_index> to fuse it with the rank dispatch.
anyrank carries the same index_fits/reindex pair (#467), so the very same call narrows the CARRIER before the rank is fixed — the GPU spelling, since narrowing has to happen host-side, before the launch, while the batch idiom keeps ndim runtime. dispatch_index(at, f) is then just the two arms written out:
Idx2 NEED NOT fit the argument's STATIC extents (#491): if one of them is too large to be represented in Idx2, index_fits<Idx2>() would answer false at run time anyway, so the narrow arm is dead — it is dropped at COMPILE time (the if constexpr below) and only the wide arm is instantiated. So a generic caller may hand dispatch_index<Idx2> a shape it knows nothing about and still get the "let run time decide" behaviour it asked for. A direct v.reindex<Idx2>() on such a shape stays a compile error — there the narrowing is the whole request, not one of two arms.
dispatch_layout¶
template<class T, class E, storage O, class F> void dispatch_layout(tensor< T, E, dynamic_strides, O > v, F && f)
Runtime-classify a DYNAMIC-strided view's contiguity and hand f a view whose LAYOUT is baked into the type — ccontiguous (C-order) or fcontiguous (F-order) when the runtime strides match, else the original dynamic_strides.
The layout counterpart of dispatch_index. An anyrank boundary erases the producer's contiguity into layout_stride, so a later recast<shape<…>> can only KEEP runtime strides. dispatch_layout cheaply checks (is_dense<ccontiguous>() / <fcontiguous>() — a stride compare, no data touched) and, in the contiguous arms, hands f a view whose strides are EXTENT-DERIVED — so recast<shape<-1,c,c>>() then folds the inner strides to immediates SAFELY (no "I promise it's contiguous" — the runtime check already proved it). f is instantiated up to 3× (only the matching arm runs), so make it generic over the view type.
OPT-IN per call site (like dispatch_index): do NOT wrap from_dlpack in it by default — it triples instantiations and composes multiplicatively with the rank/width dispatchers. Reach for it when the inner block's folded strides actually matter (a small static-C kernel; see the efficient-kernels guide).
for (auto cell : at.peel_front<-Sr>())
dispatch_layout(cell, [&](auto v){ kernel<Sr>(v.recast(shape<-1,c,c>{})); });
dispatch_rank¶
template<bool Narrow = false, class T, class offset_t, class Meta, storage Space, class Tail, class TailS, class Head, class HeadS, class F> bool dispatch_rank(const anyrank< T, offset_t, Meta, Space, Tail, TailS, Head, HeadS > & t, F && f)
Call f with a fixed-rank view of t chosen by its runtime ndim.
f is a generic callable instantiated once per possible rank; the kernel it launches is fully static. Returns false if ndim exceeds max_rank. Prefer peel_front<-Sr> when only the trailing dims need to be static — one instantiation instead of one per total rank.
narrow_index flag: each fixed cell is then also dispatch_index-narrowed (rank OUTER, width INNER — only the leaf doubles). Narrow = false (the default) is exactly the plain rank dispatch — no extra instantiation.
dispatch_value¶
Turn a runtime value into a compile-time one from a candidate list.
dispatch_value<1,2,3>(D, f) calls f(Int<k>{}) for the matching candidate k == D (so f receives a static integral_constant it can use as a template argument), and returns whether any matched.
candidates¶
constexpr noexcept
candidates<1,2,3>(d) — one dispatch_values parameter: the compile-time candidates as template arguments, the runtime value as the argument.
v may be any integer or enum type — a bound/order enum dispatches without a hand-written static_cast at the call site (the candidates are plain ints, and so is the integral_constant``f receives, exactly as with dispatch_value).
dispatch_values¶
The product form of dispatch_value: turn SEVERAL runtime values into compile-time ones in one call, one candidate list per parameter.
f is called with one integral_constant per list, in list order, when every value matched one of its own candidates; the return value says whether it ran. Pure sugar over the nesting — same per-parameter match test, same instantiation count (once per combination of candidates), and the same failure contract per parameter: a value outside its list simply doesn't fire (no assert, no abort), so f is not called and the call returns false.
dispatch_values([&](auto D, auto O, auto B){ kernel<D.value, O.value, B.value>(v); },
candidates<1,2,3>(spatial_ndim), // spatial rank
candidates<0,1,2,3>(order), // interpolation order
candidates<0,1,2,3,4,5,6,7>(bnd)); // boundary condition (an enum)
dispatch_value pyramid. The candidate lists sit next to each other, so the instantiation budget (3 × 4 × 8 here) is visible in one place. f comes FIRST because the candidate lists are variadic — the one place teeny puts the callable ahead of its arguments.
slice¶
A python-like slice [start : stop : step) for operator() / slice_along.
none marks an open end; negative bounds wrap (count from the back); step defaults to 1 and may exceed 1.
slice(1, 4) = [1,4); slice(none, 4) = [0,4); slice(2, none) = [2,end); slice(0, none, 2) = every other element; slice(none, none) keeps the whole axis (== all, which is preferable when you want the axis kept — it folds and preserves static extents). A ranged axis is resolved at run time (its extent becomes dynamic); axes kept with all stay static.
slice¶
slice¶
peel_at¶
The i-th sub-view obtained by peeling Axes... (0 <= i < product of the peeled extents).
Peeled axes vary in row-major order (the last listed axis fastest). Returns a [tny::tensor](#tensor) view. A raw mdspan carries no memory space, so this tags the result as a host view; the [tny::tensor](#tensor) overloads below preserve the source's space.
peel_at¶
template<long... Axes, class T, class E, class L, storage O> auto peel_at(tensor< T, E, L, O > & t, typename tensor< T, E, L, O >::index_type i)
peel_at¶
template<long... Axes, class T, class E, class L, storage O> auto peel_at(const tensor< T, E, L, O > & t, typename tensor< T, E, L, O >::index_type i)
peel_at¶
template<long... Axes, class T, class E, class L, storage O> auto peel_at(tensor< T, E, L, O > & t, typename tensor< T, E, L, O >::index_type i, axis< Axes... >)
peel_at¶
template<long... Axes, class T, class E, class L, storage O> auto peel_at(const tensor< T, E, L, O > & t, typename tensor< T, E, L, O >::index_type i, axis< Axes... >)
peel¶
Build a range of sub-views by peeling Axes... of t.
Non-const t yields mutable peel; const t yields read-only peel.
peel¶
template<long... Axes, class T, class E, class L, storage O> auto peel(const tensor< T, E, L, O > & t)
peel¶
template<long... Axes, class T, class E, class L, storage O> auto peel(tensor< T, E, L, O > & t, axis< Axes... >)
peel¶
template<long... Axes, class T, class E, class L, storage O> auto peel(const tensor< T, E, L, O > & t, axis< Axes... >)
peel_of¶
Build a range of sub-views over a raw mdspan.
peel_front¶
Peel the FIRST N axes -> a range of sub-views over the rest — the runtime-batch-rank half of (*batch, *spatial, C).
N is signed: peel_front<3> peels 3 leading dims; peel_front<-1> keeps the last axis (peels all but it), so negative = "keep the last |N|".
peel_front¶
template<long N, class T, class E, class L, storage O> auto peel_front(const tensor< T, E, L, O > & t)
peel_front_at¶
template<long N, class T, class E, class L, storage O> auto peel_front_at(tensor< T, E, L, O > & t, typename tensor< T, E, L, O >::index_type i)
The i-th sub-view obtained by peeling the first N axes (grid-stride style).
peel_front_at¶
template<long N, class T, class E, class L, storage O> auto peel_front_at(const tensor< T, E, L, O > & t, typename tensor< T, E, L, O >::index_type i)
size_front¶
template<long N, class T, class E, class L, storage O> tensor< T, E, L, O >::index_type size_front(const tensor< T, E, L, O > & t)
The number of sub-views peel_front<N>(t) would yield — the product of the peeled leading extents — computed directly, without materialising the range.
Same signed N as peel_front: size_front<3>(t) multiplies the first 3 extents; size_front<-2>(t) the all-but-last-two (the flattened batch count of a (*batch, C, C) tensor).
peel_zip¶
template<long... Axes, class Ta, class Ea, class La, storage Oa, class Tb, class Eb, class Lb, storage Ob> auto peel_zip(tensor< Ta, Ea, La, Oa > & a, tensor< Tb, Eb, Lb, Ob > & b)
Zip-peel 2 tensors' Axes... in lock-step -> a range of tuple<ViewA,ViewB> (numpy-style broadcast: shapes may differ as long as they're broadcast-compatible; Axes... name axes in the BROADCAST rank's numbering — the larger of the two operands' own ranks — negatives wrap against it).
A distinct name from peel (see the design note above peel_zip_range), not an overload.
The operands need not share an INDEX TYPE: the cells carry one wide enough — and, where the operands disagree on signedness, signed enough — to address every operand exactly, so a reversed view (flip, or a negative slice step) zipped against an unsigned-indexed tensor steps backwards instead of wrapping to a huge positive offset (#362).
peel_zip¶
template<long... Axes, class Ta, class Ea, class La, storage Oa, class Tb, class Eb, class Lb, storage Ob> auto peel_zip(const tensor< Ta, Ea, La, Oa > & a, const tensor< Tb, Eb, Lb, Ob > & b)
peel_zip¶
template<long... Axes, class Ta, class Ea, class La, storage Oa, class Tb, class Eb, class Lb, storage Ob> auto peel_zip(tensor< Ta, Ea, La, Oa > & a, tensor< Tb, Eb, Lb, Ob > & b, axis< Axes... >)
peel_zip¶
template<long... Axes, class Ta, class Ea, class La, storage Oa, class Tb, class Eb, class Lb, storage Ob> auto peel_zip(const tensor< Ta, Ea, La, Oa > & a, const tensor< Tb, Eb, Lb, Ob > & b, axis< Axes... >)
peel_zip¶
template<long... Axes, class Ta, class Ea, class La, storage Oa, class Tb, class Eb, class Lb, storage Ob, class Tc, class Ec, class Lc, storage Oc> auto peel_zip(tensor< Ta, Ea, La, Oa > & a, tensor< Tb, Eb, Lb, Ob > & b, tensor< Tc, Ec, Lc, Oc > & c)
Zip-peel 3 tensors' Axes... in lock-step -> a range of tuple<ViewA,ViewB,ViewC> (same broadcast/axis-numbering rule as the 2-tensor form).
The "triangle's three vertex tensors" idiom.
peel_zip¶
template<long... Axes, class Ta, class Ea, class La, storage Oa, class Tb, class Eb, class Lb, storage Ob, class Tc, class Ec, class Lc, storage Oc> auto peel_zip(const tensor< Ta, Ea, La, Oa > & a, const tensor< Tb, Eb, Lb, Ob > & b, const tensor< Tc, Ec, Lc, Oc > & c)
peel_zip¶
template<long... Axes, class Ta, class Ea, class La, storage Oa, class Tb, class Eb, class Lb, storage Ob, class Tc, class Ec, class Lc, storage Oc> auto peel_zip(tensor< Ta, Ea, La, Oa > & a, tensor< Tb, Eb, Lb, Ob > & b, tensor< Tc, Ec, Lc, Oc > & c, axis< Axes... >)
peel_zip¶
template<long... Axes, class Ta, class Ea, class La, storage Oa, class Tb, class Eb, class Lb, storage Ob, class Tc, class Ec, class Lc, storage Oc> auto peel_zip(const tensor< Ta, Ea, La, Oa > & a, const tensor< Tb, Eb, Lb, Ob > & b, const tensor< Tc, Ec, Lc, Oc > & c, axis< Axes... >)
scan_¶
template<long Axis, class T, class E, class L, storage O, class Carry, class F> void scan_(tensor< T, E, L, O > & t, Carry init, F f)
In-place sequential fold ("scan") along axis Axis, batched over every other axis: carry = init, then for each element along Axis (in increasing order) carry = f(carry, x), x = carry– the new carry doubles as the new element.
f is a device-safe functor (lambda-free engines, like map_/zip_with_): Carry operator()(Carry carry, T x) const. A reverse sweep composes with the existing negative-stride view, no separate "direction" flag: scan_<Axis>(t.flip<Axis>(), init, f) (an rvalue view binds fine –scan_ has both lvalue and rvalue overloads, unlike peel this doesn't need a named temporary first). The two calls TOGETHER –scan_(t, init, f, ax); scan_(t.flip(ax), init, f, ax);– are the blessed "forward + backward sweep" idiom for a two-pass line recurrence (an L1 min-plus distance transform; the causal + anticausal passes of an IIR spline prefilter). There is deliberately no scan2_: the pair already reuses everything a fused engine would (docs/structure.md has the worked example; #464). scan_<Axis>(t, init, f) == scan_(t, init, f, axis<Axis>{})– the axis keyword is TRAILING, like index_select's and the reductions' (#348). It used to LEAD (scan_(t, axis<Axis>{}, init, f)); that spelling was REMOVED outright, with no deprecated alias.
scan_¶
template<long Axis, class T, class E, class L, storage O, class Carry, class F> void scan_(tensor< T, E, L, O > && t, Carry init, F f)
scan_¶
template<class T, class E, class L, storage O, class Carry, class F, class Tag0, class... Tags> void scan_(tensor< T, E, L, O > & t, Carry init, F f, Tag0, Tags...)
Value form + trailing keyword bag: scan_(t, init, f, axis<Axis>{}) == scan_<Axis>(t, init, f).
The keyword is TRAILING, matching index_select(idx, axis<A>{}) and the reduction family (#348) – and it rides the generic _kw bag ([kwargs.h](#kwargsh)), so axis<A>{} is validated by name and a future keyword drops in without touching this signature. scan_ recognises exactly one keyword (axis); its out-of-place twin scan below adds into(dest), and those two compose in either order. Both an lvalue and an rvalue overload, so scan_(t.flip<A>(), init, f, axis<A>{}) needs no named temporary.
scan_¶
template<class T, class E, class L, storage O, class Carry, class F, class Tag0, class... Tags> void scan_(tensor< T, E, L, O > && t, Carry init, F f, Tag0 tag0, Tags... tags)
scan¶
template<long Axis, class T, class E, class L, storage O, class Carry, class F, enable_if_t< tensor< T, E, L, O >::is_static, int > = 0> auto scan(const tensor< T, E, L, O > & t, Carry init, F f)
Out-of-place twin of scan_: a fresh dense copy of t, scanned.
Static shape -> stack (host+device); dynamic -> heap (host only, like clone(), which this is built on).
scan¶
template<long Axis, class T, class E, class L, storage O, class Carry, class F, class D> auto & scan(const tensor< T, E, L, O > & t, Carry init, F f, into_t< D > out)
into(dest) form: write the scanned result into a preallocated dest (a shape matching t's EXACTLY, checked – a static_assert when both are static, _TNY_CHECK otherwise; unlike copy_'s own numpy-style broadcast, dest must match rather than merely receive a broadcast copy, since scan_ then walks dest's own axis numbering) – one copy, no fresh allocation beyond that; device-safe.
copy_ casts INTO dest's element type FIRST, so if dest's dtype differs from t's the whole recurrence then runs in dest's own precision. scan is the ONE producer in the library that does this – every other into(dest) (the elementwise/unary/scalar/axpy family, index_select, the reductions) computes in the SOURCE's precision and casts only the final result (#379 made that true of the elementwise family, which used to take its compute type from dest too – silently, and wrongly). Here it is deliberate: scan_'s carry is sequential and stateful, so the precision the recurrence runs in IS the precision of every intermediate carry, and there is no single "final result" to cast (see docs/api-ux-review.md's F4-e). Returns dest&.
scan¶
template<class T, class E, class L, storage O, class Carry, class F, class Tag0, class... Tags, enable_if_t< tensor< T, E, L, O >::is_static||_kw::has< _is_into_tag, Tag0, Tags... >(), int > = 0> decltype(auto) scan(const tensor< T, E, L, O > & t, Carry init, F f, Tag0 tag0, Tags... tags)
Value form + trailing keyword bag: scan(t, init, f, axis<Axis>{}) == scan<Axis>(t, init, f), and scan(t, init, f, axis<Axis>{}, into(dest)) == scan<Axis>(t, init, f, into(dest)).
Both keywords ride the generic _kw bag ([kwargs.h](#kwargsh)), so they compose in ANY subset and ANY order — scan(t, init, f, into(dest), axis<0>{}) is the same call — exactly like the reduction family's dtype/axis/keepdims/into bag (#348).
SPLIT IN TWO on the allocation key, like the <Axis> overloads it forwards to (#375): a call that allocates its result (dynamic shape, no into) yields a heap tensor via clone() and is _TNY_HOST; a static shape (stack result) or ANY into(dest) call (no allocation at all) stays _TNY_API — else nvcc's device pass would see a _TNY_API forwarder call a __host__ allocator.
operator+¶
template<class S, class T, class E, class L, storage O, enable_if_t< is_arithmetic< S >::value, int > = 0> auto operator+(S s, const tensor< T, E, L, O > & a)
operator*¶
template<class S, class T, class E, class L, storage O, enable_if_t< is_arithmetic< S >::value, int > = 0> auto operator*(S s, const tensor< T, E, L, O > & a)
operator-¶
template<class S, class T, class E, class L, storage O, enable_if_t< is_arithmetic< S >::value, int > = 0> auto operator-(S s, const tensor< T, E, L, O > & a)
operator/¶
template<class S, class T, class E, class L, storage O, enable_if_t< is_arithmetic< S >::value, int > = 0> auto operator/(S s, const tensor< T, E, L, O > & a)
operator-¶
operator~¶
template<class T, class E, class L, storage O, enable_if_t< is_integral< T >::value, int > = 0> auto operator~(const tensor< T, E, L, O > & a)
sum¶
template<class Acc = void, class T, class E, class L, storage O> auto sum(const tensor< T, E, L, O > & a)
Sum of all elements (empty -> 0).
Accumulates in the reduce type (double for small floats), result cast to T; sum<Acc>(a) returns Acc.
prod¶
template<class Acc = void, class T, class E, class L, storage O> auto prod(const tensor< T, E, L, O > & a)
Product of all elements (empty -> 1).
Accumulates in the reduce type, result cast to T; prod<Acc>(a) returns Acc.
max¶
template<class Acc = void, class T, class E, class L, storage O> auto max(const tensor< T, E, L, O > & a)
Maximum element.
Requires a non-empty tensor. Result type T (max<Acc>(a) returns Acc).
min¶
template<class Acc = void, class T, class E, class L, storage O> auto min(const tensor< T, E, L, O > & a)
Minimum element.
Requires a non-empty tensor. Result type T (min<Acc>(a) returns Acc).
reduce_to< _reduce_result_t< Acc, _mean_result_t< T > > >¶
dot¶
template<class Acc = void, class Ta, class Ea, class La, storage Oa, class Tb, class Eb, class Lb, storage Ob> _acc_t< Acc, T > auto dot(const tensor< Ta, Ea, La, Oa > & a, const tensor< Tb, Eb, Lb, Ob > & b)
Inner product over matching extents.
Accumulates in the reduce type of the promoted element type (double for small floats), result cast to promote(Ta,Tb); dot<Acc>(a, b) returns Acc.
sqnorm¶
template<class Acc = void, class T, class E, class L, storage O> auto sqnorm(const tensor< T, E, L, O > & a)
Squared Euclidean norm — the sum of squares Σ aᵢ², over ALL axes.
Just dot(a, a): accumulates in the reduce type, result cast to the element type (sqnorm<Acc>(a) accumulates AND returns Acc). The value-tag/axis/keepdims/into composition (sqnorm(a, dtype<Acc>{}), sqnorm(a, axis<0>{}), ...) is handled generically by _TNY_RED_TAGGED (invoked further below, right after sqnorm's own axis core — see _TNY_RED_AXIS_CORE(sqnorm, ...) above).
norm¶
template<class Acc = void, class T, class E, class L, storage O> auto norm(const tensor< T, E, L, O > & a)
Euclidean (L2) norm √Σ aᵢ², over ALL axes.
Accumulates the squares in the reduce type and takes the root there, then casts to the result type: a floating element type keeps its type, an INTEGER one yields double (numpy/mean rule). norm<Acc>(a) makes Acc accumulator AND result.
reduce_to< _reduce_result_t< Acc, _mean_result_t< T > > >¶
reduce_to< _reduce_result_t< Acc, _mean_result_t< T > > >(_red_sqrt(axreduce<>(a, R(0), _md::r_addsq{})))
sqdist¶
template<class Acc = void, class Ta, class Ea, class La, storage Oa, class Tb, class Eb, class Lb, storage Ob> conditional_t< is_void< Acc >::value, _norm_root_t< T >, Acc > auto sqdist(const tensor< Ta, Ea, La, Oa > & a, const tensor< Tb, Eb, Lb, Ob > & b)
Squared Euclidean distance Σ(aᵢ-bᵢ)² between two same-shape tensors — mathematically sqnorm(a-b), computed as one fused pass with no a-b intermediate (mirrors dot's convenience-wrapper status over a manual sum(a*b)).
Each difference is formed and squared directly in the accumulator type, so the result can be MORE accurate than the un-fused sqnorm(a-b) spelling for a narrow element type (a-b there rounds to the operands' own type before sqnorm widens it) — not necessarily bit-identical, only for double operands are the two guaranteed equal. Binary only (no axis-list form, like dot); sqdist<Acc>(a,b) makes Acc accumulator AND result.
dist¶
template<class Acc = void, class Ta, class Ea, class La, storage Oa, class Tb, class Eb, class Lb, storage Ob> auto dist(const tensor< Ta, Ea, La, Oa > & a, const tensor< Tb, Eb, Lb, Ob > & b)
Euclidean distance √Σ(aᵢ-bᵢ)² — mathematically norm(a-b), one fused pass (see sqdist's doc comment for the accuracy note).
Floating result (integer operands -> double, the norm/mean rule); dist<Acc>(a,b) makes Acc accumulator AND result.
normalize¶
Out-of-place unit vector a / norm(a) -> a NEW dense tensor (static shape -> stack, dynamic -> heap).
The result element type is floating (integer input -> double, like norm). A zero vector yields NaNs (no epsilon — exact math; add one at the call site if you need it).
normalize¶
template<class T, class E, class L, storage O, class D> auto & normalize(const tensor< T, E, L, O > & a, into_t< D > out)
normalize(a, into(y)) — the unit vector into a caller buffer y.
normalize¶
template<long... Axes, class T, class E, class L, storage O, enable_if_t<(sizeof...(Axes) > 0) &&_md::_nrm_out_api< E, Axes... >::value, int > = 0> auto normalize(const tensor< T, E, L, O > & a)
normalize<Axes...>(a) — unit vectors along the named axes: each element divided by the L2 norm over those axes (keepdim broadcast).
Floating result (integer -> double). Axes distinct, in any order (numpy-normalised). Static shape -> a stack result (host+device); dynamic -> heap (host only).
normalize¶
template<long... Axes, class T, class E, class L, storage O, enable_if_t<(sizeof...(Axes) > 0) &&_md::_nrm_out_api< E, Axes... >::value, int > = 0> auto normalize(const tensor< T, E, L, O > & a, axis< Axes... >)
normalize¶
template<long... Axes, class T, class E, class L, storage O, class D, enable_if_t<(sizeof...(Axes) > 0) &&_md::_nrm_kept_api< E, Axes... >::value, int > = 0> auto & normalize(const tensor< T, E, L, O > & a, into_t< D > out)
normalize<Axes...>(a, into(y)) — the axis-scoped unit vectors into a caller buffer y, whose shape must match a's EXACTLY (only the DIVISOR is reduced, so the result keeps the source's full shape).
A statically wrong y is a COMPILE error when both shapes are static, a _TNY_CHECK otherwise — the same guarantee as the whole-tensor normalize(a, into(y)) (#434). Same one-line forward to .div(..., out) as that form; the reduced norm itself is still materialised (it is a tensor, not a scalar) — which is the ONLY allocation here, hence the weaker _nrm_kept_* key: normalize<0>(a, into(y)) on a shape<-1,3> source reduces to a shape<3> stack norm and stays device-callable. Axes distinct, in any order — same rule as the allocating form (_keepdims asserts distinctness and sorts).
normalize¶
template<long... Axes, class T, class E, class L, storage O, class D, enable_if_t<(sizeof...(Axes) > 0) &&_md::_nrm_kept_api< E, Axes... >::value, int > = 0> auto & normalize(const tensor< T, E, L, O > & a, axis< Axes... >, into_t< D > out)
cross¶
template<class Ta, class Ea, class La, storage Oa, class Tb, class Eb, class Lb, storage Ob> auto cross(const tensor< Ta, Ea, La, Oa > & a, const tensor< Tb, Eb, Lb, Ob > & b)
3D cross product a × b -> a NEW stack 3-vector of promote(Ta,Tb).
Both operands are rank-1, length 3. In place: the member a.cross_(b) (a becomes a × b). Into a preallocated slot: cross(a, b, into(y)).
cross¶
template<class Ta, class Ea, class La, storage Oa, class Tb, class Eb, class Lb, storage Ob, class D> auto & cross(const tensor< Ta, Ea, La, Oa > & a, const tensor< Tb, Eb, Lb, Ob > & b, into_t< D > out)
cross(a, b, into(y)) — the cross product into a caller buffer y (rank-1, length 3); y may alias a or b.
This is ff's "crossto". y may be a SLICE of a bigger output, written with no named intermediate: cross(a, b, into(N(i, all))) fills row i of a matrix of 3-vectors ([into()](#into) binds such a temporary view — tensor.h).
allclose¶
template<class Acc = void, class Ta, class Ea, class La, storage Oa, class Tb, class Eb, class Lb, storage Ob> bool allclose(const tensor< Ta, Ea, La, Oa > & a, const tensor< Tb, Eb, Lb, Ob > & b, double rtol = _allclose_rtol(), double atol = _allclose_atol())
True if every element satisfies |a-b| <= atol + rtol*|b| (numpy allclose; broadcasts, computes in the compute type of the promoted element type).
allclose<Acc>(a, b) forces that comparison to be carried out in Acc instead (the dot/sqdist accumulator convention — the answer is a bool either way).
allclose¶
template<class Acc = void, class Ta, class Ea, class La, storage Oa, class Tb, class Eb, class Lb, storage Ob, class Tag0, class... Tags, enable_if_t< _kw::is_keyword< Tag0 >::value, int > = 0> decltype(auto) allclose(const tensor< Ta, Ea, La, Oa > & a, const tensor< Tb, Eb, Lb, Ob > & b, double rtol, double atol, Tag0 tag0, Tags... tags)
Generic trailing keyword bag for allclose — dot/sqdist/dist's binary (no axis concept) shape, with numpy's OPTIONAL rtol/atol positionals kept ahead of the bag: allclose(a, b, dtype<double>{}), allclose(a, b, into(cell)), allclose(a, b, rtol, into(cell)), allclose(a, b, rtol, atol, dtype<double>{}, into(cell)).
dtype<Acc>{} picks the comparison's compute type (== allclose<Acc>); into(dest) writes the answer into a RANK-0 destination (cast to its element type — a bool cell keeps it exactly) and returns dest&, allocating nothing.
Not an invocation of _TNY_RED_BINARY_TAGGED: that macro's wrappers forward (a, b) only, and allclose has the two tolerance positionals in between, which C++17 cannot default ahead of a trailing pack. Hence one bag overload per tolerance arity (0/1/2 given), the shorter two delegating. Tag0 is constrained to a keyword, so a tolerance can never be swallowed as a tag nor a tag be read as a tolerance, and the plain form above is never in competition.
allclose¶
template<class Acc = void, class Ta, class Ea, class La, storage Oa, class Tb, class Eb, class Lb, storage Ob, class Tag0, class... Tags, enable_if_t< _kw::is_keyword< Tag0 >::value, int > = 0> decltype(auto) allclose(const tensor< Ta, Ea, La, Oa > & a, const tensor< Tb, Eb, Lb, Ob > & b, Tag0 tag0, Tags... tags)
allclose(a, b, tags...) — the keyword bag with both tolerances defaulted.
allclose¶
template<class Acc = void, class Ta, class Ea, class La, storage Oa, class Tb, class Eb, class Lb, storage Ob, class Tag0, class... Tags, enable_if_t< _kw::is_keyword< Tag0 >::value, int > = 0> decltype(auto) allclose(const tensor< Ta, Ea, La, Oa > & a, const tensor< Tb, Eb, Lb, Ob > & b, double rtol, Tag0 tag0, Tags... tags)
allclose(a, b, rtol, tags...) — the keyword bag with atol defaulted.
minimum¶
template<class Ta, class Ea, class La, storage Oa, class Tb, class Eb, class Lb, storage Ob> auto minimum(const tensor< Ta, Ea, La, Oa > & a, const tensor< Tb, Eb, Lb, Ob > & b)
maximum¶
template<class Ta, class Ea, class La, storage Oa, class Tb, class Eb, class Lb, storage Ob> auto maximum(const tensor< Ta, Ea, La, Oa > & a, const tensor< Tb, Eb, Lb, Ob > & b)
minimum¶
template<class T, class E, class L, storage O, class S, enable_if_t< is_arithmetic< S >::value, int > = 0> auto minimum(const tensor< T, E, L, O > & a, S s)
maximum¶
template<class T, class E, class L, storage O, class S, enable_if_t< is_arithmetic< S >::value, int > = 0> auto maximum(const tensor< T, E, L, O > & a, S s)
minimum¶
template<class Ta, class Ea, class La, storage Oa, class Tb, class Eb, class Lb, storage Ob, class D> auto & minimum(const tensor< Ta, Ea, La, Oa > & a, const tensor< Tb, Eb, Lb, Ob > & b, into_t< D > out)
maximum¶
template<class Ta, class Ea, class La, storage Oa, class Tb, class Eb, class Lb, storage Ob, class D> auto & maximum(const tensor< Ta, Ea, La, Oa > & a, const tensor< Tb, Eb, Lb, Ob > & b, into_t< D > out)
minimum¶
template<class T, class E, class L, storage O, class S, class D, enable_if_t< is_arithmetic< S >::value, int > = 0> auto & minimum(const tensor< T, E, L, O > & a, S s, into_t< D > out)
maximum¶
template<class T, class E, class L, storage O, class S, class D, enable_if_t< is_arithmetic< S >::value, int > = 0> auto & maximum(const tensor< T, E, L, O > & a, S s, into_t< D > out)
clamp¶
template<class T, class E, class L, storage O> auto clamp(const tensor< T, E, L, O > & a, T lo, T hi)
clamp(a, lo, hi) -> a new tensor with each element clamped; clamp(a,
lo, hi, into(y)) writes into y.
clamp¶
template<class T, class E, class L, storage O, class D> auto & clamp(const tensor< T, E, L, O > & a, T lo, T hi, into_t< D > out)
mean¶
template<class Acc = void, class T, class E, class L, storage O> auto mean(const tensor< T, E, L, O > & a)
Arithmetic mean of all elements.
For a floating T, accumulates in the reduce type (double for small floats) and the result is cast to T. For an INTEGER T the result is double (numpy: integer mean is float64; the division runs in double, not truncating integer division). mean<Acc>(a) makes Acc both the accumulator and the result type.
storage_is_owning¶
constexpr noexcept
Whether the mode owns (and therefore allocates) its storage.
storage_is_view¶
constexpr noexcept
Whether the mode is a non-owning view (view/gpu_view/pinned_view/ mapped_view) — the pointer-wrapping modes (vs stack's inline array).
storage_is_device¶
constexpr noexcept
Whether the storage lives in device (GPU) memory (owning or view).
storage_is_host_accessible¶
constexpr noexcept
Whether the storage is dereferenceable from the host.
storage_view_of¶
constexpr noexcept
The non-owning VIEW kind that preserves a source's memory space: a device source (gpu/gpu_view) -> gpu_view, a pinned/mapped source -> pinned_view/mapped_view, anything else -> view.
Every view-producing op (slice / permute / peel / reshape / at) tags its result with this so a view never loses (or misreports) its space.
storage_arg¶
constexpr
storage_arg
That precedence rule (and its wording) lives ONCE, in _kw::resolve (kwargs.h) – shared with dtype_arg_t/layout_arg_t. The only storage-specific part is the currency: this keyword's explicit form and its answer are a storage VALUE, not a type, so both travel through resolve inside their own storage_c<O> carrier – which IS the value tag, hence keep_tag as the unwrap step – and are read back out with ::value here.
storage_resolve¶
constexpr noexcept
Resolve a factory's ownership: an explicitly named mode passes through, storage_deduce becomes stack for a static shape / heap for a dynamic one.
as_tensor¶
template<storage OW = storage::view, class MD> tensor< typename MD::element_type, typename MD::extents_type, typename MD::layout_type, OW > as_tensor(const MD & m)
Wrap any cuda::std::mdspan (e.g.
a submdspan result) as a non-owning [tny::tensor](#tensor) view, so the tensor API applies to it.
fetch_add¶
noexcept
Accumulate v into *p, atomic on both host and device (#257).
INTERNAL primitive behind the atomic accumulate ops — prefer a.atomic_add_(x) / t.at(i...).atomic_add_(v) in user code.
The scatter/"push" write: many threads may accumulate into overlapping outputs, which a plain += would race. Device -> atomicAdd (double needs sm_60+, __half sm_70+; not all integer widths have an overload — that surfaces as an nvcc error at instantiation). Host, arithmetic T EXCLUDING bool/long double -> cuda::std::atomic_ref<T> (libcu++'s C++17-usable backport of std::atomic_ref) so a push kernel parallelised with std::thread/OpenMP over overlapping outputs is genuinely race-free, matching the device semantics instead of merely documenting the caller must work around it.
The remaining element types keep the old plain *p += v (still not thread-safe there — same as before this fix, not a regression): bool (libcu++'s atomic_ref<bool> has no fetch_add) and long double (atomic_ref<long double> needs a 16-byte atomic RMW, which pulls in libatomic and fails to LINK on common toolchains that don't provide it — a working build must not start failing to link just because a caller touches atomic_add_ on a long double tensor). Non-arithmetic T (a portable software half/bfloat16 struct, OR the native __half/ __nv_bfloat16 CUDA types under __CUDACC__ on a host translation unit) has no atomic representation to route through atomic_ref either way.
into¶
noexcept
template<class T, class E, class L, storage O> into_t< tensor< T, E, L, O > > into(tensor< T, E, L, O > & d) noexcept
into(y) — the output-destination tag: pass it as the last argument to an out-of-place math producer (a.add(b, into(y)), cross(a,b,into(y)), exp(a, into(y)), …) to write the result into y (one fused pass, no allocation) and get y& back, instead of a freshly allocated result.
y's SHAPE follows the producer's own rule: a tensor-rhs (broadcasting) producer checks each OPERAND against the y you pass (equal extent or 1), so y may deliberately be LARGER or higher-rank than the operands' own broadcast result — a.add(b, into(y)) is "y = a + b" minus the allocation and the copy, and the operands stretch to fill y (#444) — while a unary or scalar-rhs producer requires y to match the source EXACTLY (it has nothing to stretch). Only the operands ever broadcast, never y: a y smaller in any axis is an error (compile-time when the extents are static, a debug-time check otherwise). y's dtype need not match: the arithmetic runs in the OPERANDS' own precision (a scalar rhs and the fused alpha included) and only the RESULT is cast to y, so a.op(b, into(y)) gives exactly the numbers y.copy_(a.op(b)) would (#379) — including for a half/bfloat16 operand, where into(y) rounds through the twin's own promote_t (a 16-bit float there) before casting to y, not straight from the float compute value. scan(t, init, f, into(y)) is the one deliberate exception — see its own doc-comment in iterate.h.
into¶
noexcept
template<class T, class E, class L, storage O> into_t< tensor< T, E, L, O > > into(tensor< T, E, L, O > && d) noexcept
into(y) over a TEMPORARY view — the destination may be written straight out of a view-producing op, with no named intermediate: cross(a, b, into(N(i, all))), sum(a, into(cells.at(i, j))), x.add(y, into(z.permute<1,0>())).
Every view-producing op (slicing, at, permute, unsqueeze, slice_along, peel_at, …) returns its view BY VALUE, so without this overload the most natural destination there is — a slot of a bigger output — had to be given a name first, which is exactly the boilerplate into(dest) exists to remove.
Restricted to the non-owning VIEW storages (view/gpu_view/ pinned_view/mapped_view): a temporary view aliases backing storage the caller owns elsewhere, so the write outlives the call, and the view itself lives to the end of the full expression that contains the producer. A temporary OWNING tensor (into(zeros<double>(shape<3>{})), into(local<double,shape<3>>{})) is rejected instead: its storage dies with the expression, so the result would be computed and thrown away.
The one sharp edge: use the call for its EFFECT, don't keep the dest& it returns — auto & r = cross(a, b, into(N(i, all))) dangles once the temporary view goes away (same rule as for (auto v : peel<0>(t)) and the other temporaries in the library).
reindex¶
Free forms of reindex/index_fits — deduce the tensor, so a type-dependent receiver avoids .template: reindex<int32_t>(t), index_fits<int32_t>(t).
(Idx2 is a TYPE, so there is no value form.)
reindex¶
template<class Idx2, class T, class E, class L, storage O> auto reindex(const tensor< T, E, L, O > & t)
index_fits¶
template<class Idx2, class T, class E, class L, storage O> bool index_fits(const tensor< T, E, L, O > & t)
wrap¶
template<class Layout = ccontiguous, storage Space = storage_deduce, class T, class Shape, class... Tags> auto wrap(T * p, Shape e, Tags...)
Wrap p as a non-owning view with a contiguous layout (default C-order).
This is the factory; the view<T,E> alias is the type it produces, and the member t.view() re-views an existing tensor.
MEMORY SPACE: p is a host pointer unless a trailing storage_c<Space>{} (or storage_v<Space>) tag names where it lives — pass the plain BACKEND the memory is in ([storage::gpu](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a0aa0be2a866411d9ff03515227454947) for a device pointer, [storage::pinned](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a8a4f12ef77f9e30413cabd15cf16c913)/[storage::mapped](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a55c0eb766bdf4045fa0997d162971e31) for page-locked host memory). Since wrap always yields a VIEW, the space folds to its view kind (gpu -> gpu_view, …) via storage_view_of — you never spell the _view kinds. Symmetric with as_anyrank<Space> / from_dlpack<T,Space>.
[storage::heap](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a4d4a9aa362b6ffe089fd2e992ccf4f5f)/[storage::stack](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508afac2a47adace059aff113283a03f6760) name no distinct memory space (they are ownership kinds, not backends), so passing one here just folds to a plain [storage::view](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a1bda80f2be4d3658e0baa43fbe7ae8c1), same as leaving the tag off — it does NOT make wrap return an owning tensor. For an owning heap/stack tensor, copy into one with empty<T, [storage::heap](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a4d4a9aa362b6ffe089fd2e992ccf4f5f)>(e)/make_heap<T>(e) instead.
The trailing argument is a keyword-tag bag (#277/#282), not a fixed storage_c<Space> parameter — today the only recognised keyword is storage_c/storage_v, but a future keyword (e.g. a stream tag) lands on all four wrap positional forms without touching any of them again.
wrap¶
template<class Layout, storage Space = storage_deduce, class T, class Shape, class... Tags, enable_if_t< is_same< Layout, ccontiguous >::value||is_same< Layout, fcontiguous >::value, int > = 0> auto wrap(T * p, Shape e, Layout, Tags...)
Value-tag layout form: wrap(p, e, fcontiguous{}) == wrap<fcontiguous>(p, e) — deduces the layout from a bare ccontiguous{}/fcontiguous{} argument instead of an explicit <Layout> template argument, so a type-dependent receiver needs no .template.
Composes with a trailing storage_c<Space>{} exactly like the template form. (strides<S...>{} keeps its own dedicated overload above — it carries the static strides themselves, not just a layout kind, so it is not a Layout here.) A SECOND layout tag after this one — wrap(p, e, fcontiguous{}, fcontiguous{}), agreeing or not — is a static_assert (#394): Layout is a single positional slot, not a composable keyword, so it can only be given once per call.
wrap¶
template<storage Space = storage_deduce, class MD, class... Tags, enable_if_t< _is_mdspan_like< MD >::value, int > = 0> auto wrap(const MD & md, Tags...)
wrap(mdspan) — a spelling of as_tensor(mdspan) under the one factory name users already reach for.
Wrap any cuda::std::mdspan/submdspan result as a non-owning view; the element type, extents and layout all come from the mdspan.
MEMORY SPACE: same contract as the pointer forms — the mdspan wraps a host pointer unless a trailing storage_c<Space>{} (or storage_v<Space>) tag names where it lives, and since wrap always yields a VIEW the plain backend folds to its view kind ([storage::gpu](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a0aa0be2a866411d9ff03515227454947) -> gpu_view, …) via storage_view_of, so you never spell the _view kinds: wrap(md, storage_v<[storage::gpu](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a0aa0be2a866411d9ff03515227454947)>) is a gpu_view. Takes the same trailing keyword-tag bag as the four positional forms (#282/#370).
NB the explicit template argument of THIS overload is the memory SPACE (an storage value: wrap<[storage::gpu](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a0aa0be2a866411d9ff03515227454947)>(md)), not a layout type as in wrap<fcontiguous>(p, e) — the layout is already carried by the mdspan, so there is nothing to name. Prefer the value-tag spelling above, which reads the same on every wrap form.
as_tensor stays public alongside this overload ON PURPOSE — two layers, not an accidental duplicate (#351): wrap is the caller-facing factory name for viewing existing memory whatever the carrier (pointer+shape, pointer+strides, an mdspan), with the family's keyword bag and backend->view-kind space folding; as_tensor is the mdspan-adaptation primitive underneath (no keyword bag, its <OW> is the already-folded view kind) — what teeny's own view-producing ops (permute/flip/squeeze/…) call with a pre-folded space, and the spelling the mdspan-interop docs teach.
wrap¶
template<storage Space = storage_deduce, class T, class Shape, class... Tags> auto wrap(T * p, Shape e, array< typename Shape::index_type, _shape_rank< Shape >()> st, Tags...)
Wrap p as a non-owning view with explicit runtime strides (a layout_stride view).
Pass one stride per dimension — an array or a braced list — in ELEMENTS; strides may be negative (a reversed view).
wrap(p, shape<2,3>{}, {3, 1}) is the row-major view; {1, 2} the column-major one. For strides known at compile time pass a strides<S...>{} instead (overload below) so they fold into the type. A trailing storage_c<Space>{} tags the memory space (default host; the plain backend folds to its view kind, e.g. [storage::gpu](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a0aa0be2a866411d9ff03515227454947) -> gpu_view).
wrap TRUSTS the strides you give it: a stride 0 (or a stride smaller than an inner extent) makes a SELF-OVERLAPPING view where several indices alias one element. Reading such a view is fine (that is how a broadcast works), but an in-place write into it (v.add_(b), v.iota_(...)) applies the update to the same element repeatedly — a host-debug check rejects an in-place write whose destination has an extent > 1 axis with stride 0. clone() to a dense tensor first if you need to write.
wrap¶
template<int64_t... Strides, storage Space = storage_deduce, class T, class Shape, class... Tags> auto wrap(T * p, Shape e, strides< Strides... >, Tags...)
Wrap p as a non-owning view with per-dimension compile-time strides (may be negative): pass a strides<S...>{} as the third argument.
wrap(p, shape<3,3>{}, strides<4,1>{}) folds the strides into the type (strides<S...> layout, EBO). Every stride must be a compile-time value — a strides<...> tag is a stateless layout, so it cannot carry runtime strides. For a mix of static and runtime strides, use the template form below; for all-runtime strides the {s...} overload above (a layout_stride view) is simplest.
wrap¶
template<int64_t S0, int64_t... Srest, storage Space = storage_deduce, class T, class Shape, class... Tags> auto wrap(T * p, Shape e, array< typename Shape::index_type, strides< S0, Srest... >::ndyn()> dyn, Tags...)
Wrap p with a mix of static and runtime strides — the exact analogue of shape<-1,2,3,-1>{d0,d1} for strides.
Give the per-dim pattern as template args (a compile-time stride, or dynamic_stride for a runtime one) and the runtime strides for the dynamic_stride slots as a braced list, in order:
wrap<dynamic_stride, 1>(ptr, shape<3,3>{}, {4}); // outer=4 (runtime), inner=1 (folds)
wrap<dynamic_stride, dynamic_stride>(ptr, sh, {4,1}); // both runtime (a strides<> layout)
storage_c<Space>{} tags the memory space (default host; the plain backend folds to its view kind, e.g. [storage::gpu](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a0aa0be2a866411d9ff03515227454947) -> gpu_view).
make_view¶
template<class Layout = ccontiguous, storage Space = storage_deduce, class T, class Shape, class... Tags> auto make_view(T * p, Shape e, Tags... tags)
make_view<L>(ptr, extents) — a non-owning view (alias of wrap).
The layout may be an explicit <L> template argument or, like wrap, a positional value tag (make_view(p, e, fcontiguous{})) — see the overload below. Takes the same optional trailing keyword-tag bag as wrap (#282) — today just storage_c<Space>{}/storage_v<Space>.
make_view¶
template<class Layout, storage Space = storage_deduce, class T, class Shape, class... Tags, enable_if_t< is_same< Layout, ccontiguous >::value||is_same< Layout, fcontiguous >::value, int > = 0> auto make_view(T * p, Shape e, Layout, Tags... tags)
Value-tag layout form, mirroring wrap's (#374): make_view(p, e, fcontiguous{}) == make_view<fcontiguous>(p, e), deduced from a bare ccontiguous{}/fcontiguous{} argument so a type-dependent receiver needs no .template.
Composes with a trailing storage_c<Space>{} exactly like the template form. Without this overload only ccontiguous{} would work — it would reach wrap's own positional layout overload by accident, because make_view's Layoutdefaults to ccontiguous — while fcontiguous{} fell through to the keyword bag and was rejected as an unrecognised trailing argument. A SECOND layout tag — make_view(p, e, fcontiguous{}, fcontiguous{}) — is a static_assert (#394), same as wrap's.
empty¶
template<class T = void, storage O = storage_deduce, class Layout = void, class Shape, class... Tags, enable_if_t< _fac_on_stack< O, Shape, Tags... >::value, int > = 0> auto empty(Shape = Shape{}, Tags...)
empty<T>(extents) — a new UNINITIALISED tensor.
The one factory the make_* family fuses into: ownership is deduced from the shape (fully static -> stack (host+device); any dynamic extent -> heap (host)) unless a backend is named — empty<T, [storage::gpu](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a0aa0be2a866411d9ff03515227454947)>(extents), or the value-tag spelling empty<T>(extents, storage_c<[storage::gpu](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a0aa0be2a866411d9ff03515227454947)>{}). gpu/pinned/mapped require <[teeny/cuda.h](#cudah)> (their storage lives there). T defaults to float. Split by the resolved ownership so the stack case stays _TNY_API (host+device) while the allocating cases are _TNY_HOST.
Element type, backend, and layout may each be given as a leading explicit template argument OR as a trailing value tag (dtype<T>{}/storage_c<O>{}/ a layout tag), in ANY order and ANY subset: empty<double>(e), empty(e, dtype<double>{}), empty(e, storage_c<[storage::gpu](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a0aa0be2a866411d9ff03515227454947)>{}, dtype<double>{}) all work. _TNY_KW_CHECK/dtype_arg_t/storage_arg/layout_arg_t ([kwargs.h](#kwargsh) and each tag's own header) validate and resolve the trailing bag; an unrecognised or duplicated keyword fails on one clean static_assert instead of an overload-resolution wall (#279/#280).
empty¶
template<storage O, class Layout = void, class Shape, class... Tags, enable_if_t< _fac_on_stack< O, Shape, Tags... >::value, int > = 0> auto empty(Shape e, Tags... tags)
BACKEND-LED entry point — the one spelling the T-led entry point above cannot cover: a LEADING explicit template argument that names the BACKEND rather than the element type (empty<[storage::pinned](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a8a4f12ef77f9e30413cabd15cf16c913)>(e, dtype<double>{}, fcontiguous{})), because a value can never bind the class T of the entry point above.
storage O has no default here, so this overload is viable only when the backend is actually named: with no explicit template argument O is neither deducible nor defaulted and the candidate simply drops out, leaving the T-led entry point alone. Past that leading argument it takes the very SAME keyword bag, so every keyword still composes in ANY subset and ANY order (#373) — a leading backend argument is no longer a "one dtype{} tag and nothing else" dead end. A storage_c<...>{} tag on top of the explicit backend is the one thing it rejects, on storage_arg's named "pick one" static_assert.
make_local¶
template<class T = void, class Layout = void, class Shape, class... Tags> auto make_local(Shape e = Shape{}, Tags... tags)
make_local<T>(extents) — a stack-owned tensor (static shape).
T defaults to float (numpy's default float dtype). Thin spelling of empty<T, [storage::stack](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508afac2a47adace059aff113283a03f6760)>. Takes the same trailing dtype/layout keyword-tag bag as empty (#282; no storage_c — the backend is fixed).
make_heap¶
template<class T = void, class Layout = void, class Shape, class... Tags> auto make_heap(Shape e, Tags... tags)
make_heap<T>(extents) — a heap-owned tensor (host, move-only).
T defaults to float. Thin spelling of empty<T, [storage::heap](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a4d4a9aa362b6ffe089fd2e992ccf4f5f)>. Takes the same trailing dtype/layout keyword-tag bag as empty (#282).
full¶
template<class T = void, storage O = storage_deduce, class Layout = void, class Shape, class V, class... Tags, enable_if_t< _fac_on_stack< O, Shape, Tags... >::value, int > = 0> auto full(Shape e, V v, Tags...)
full(extents, v) — a new tensor filled with v.
The element type defaults to the value's type (numpy/pytorch: full(s, 3) is int, full(s, 3.0) is float); pass full<T>(...) to override. Unlike the value-less zeros/ones (which default to float), there is a value here to infer from, so we do.
Ownership is deduced from the shape (static -> stack, dynamic -> heap) unless a backend is named — full<T, [storage::pinned](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a8a4f12ef77f9e30413cabd15cf16c913)>(s, v) or the value-tag full<T>(s, v, storage_c<[storage::pinned](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a8a4f12ef77f9e30413cabd15cf16c913)>{}). Because it fills host-side, only host-accessible backends (stack/heap/pinned/mapped) are allowed; a device (gpu) fill needs a kernel launch, so it is a static_assert steering you to to<[storage::gpu](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a0aa0be2a866411d9ff03515227454947)>(full<T>(s, v)). Split by resolved ownership for the _TNY_API/_TNY_HOST annotation.
Element type, backend, and layout may each be given as a leading explicit template argument OR as a trailing value tag, in ANY order and ANY subset, same as empty (#280/#281): full(e, v, fcontiguous{}), full(e, v, storage_c<[storage::heap](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a4d4a9aa362b6ffe089fd2e992ccf4f5f)>{}, dtype<double>{}).
full¶
template<storage O, class Layout = void, class Shape, class V, class... Tags, enable_if_t< _fac_on_stack< O, Shape, Tags... >::value, int > = 0> auto full(Shape e, V v, Tags... tags)
BACKEND-LED entry point — a LEADING explicit template argument that names the BACKEND rather than the element type: full<[storage::pinned](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a8a4f12ef77f9e30413cabd15cf16c913)>(e, v, dtype<double>{}, fcontiguous{}).
See [empty()](#empty)'s twin above for why storage O carries no default here and how the keyword bag composes (#373).
zeros¶
template<class T = void, storage O = storage_deduce, class Layout = void, class Shape, class... Tags, enable_if_t< _fac_on_stack< O, Shape, Tags... >::value, int > = 0> auto zeros(Shape e, Tags...)
zeros<T>(extents) / ones<T>(extents) — a new tensor of 0s / 1s.
T defaults to float. Same ownership deduction, backend selector, and _TNY_API/_TNY_HOST split as full; also composes dtype/storage_c/a layout tag in ANY order/subset, same as empty (#280/#281): zeros(e, dtype<double>{}), zeros(e, fcontiguous{}, storage_c<[storage::heap](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a4d4a9aa362b6ffe089fd2e992ccf4f5f)>{}). A device backend static_asserts — fill via to<[storage::gpu](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a0aa0be2a866411d9ff03515227454947)>(zeros<T>(shape)).
zeros¶
template<storage O, class Layout = void, class Shape, class... Tags, enable_if_t< _fac_on_stack< O, Shape, Tags... >::value, int > = 0> auto zeros(Shape e, Tags... tags)
BACKEND-LED entry point — see [empty()](#empty)'s twin above (#373).
ones¶
template<class T = void, storage O = storage_deduce, class Layout = void, class Shape, class... Tags, enable_if_t< _fac_on_stack< O, Shape, Tags... >::value, int > = 0> auto ones(Shape e, Tags...)
ones¶
template<storage O, class Layout = void, class Shape, class... Tags, enable_if_t< _fac_on_stack< O, Shape, Tags... >::value, int > = 0> auto ones(Shape e, Tags... tags)
BACKEND-LED entry point — see [empty()](#empty)'s twin above (#373).
arange¶
arange<T>(n) — a 1-D tensor [0, 1, ..., n-1] (heap, host).
T defaults to int64_t (an integer range, like numpy arange(n)). A host-accessible backend may be named — arange<T, [storage::pinned](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a8a4f12ef77f9e30413cabd15cf16c913)>(n) or arange<T>(n, storage_c<[storage::pinned](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a8a4f12ef77f9e30413cabd15cf16c913)>{}); a device backend static_asserts (use to<[storage::gpu](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a0aa0be2a866411d9ff03515227454947)>(arange<T>(n))). The static-N forms below stay stack. T/backend compose via the generic keyword mechanism too (#280/#281): arange(n, dtype<double>{}, storage_c<[storage::pinned](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a8a4f12ef77f9e30413cabd15cf16c913)>{}), either order. No layout keyword — a 1-D tensor has no C/F distinction.
arange¶
BACKEND-LED entry point — see [empty()](#empty)'s twin above (#373).
The analogous "leading explicit O" spelling: arange<[storage::pinned](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a8a4f12ef77f9e30413cabd15cf16c913)>(n, dtype<double>{}). A storage_c<...>{} tag on top of the explicit backend names the duplicate on storage_arg's "pick one" static_assert rather than falling off the overload set.
arange¶
Static arange<T, N>() — a stack [0..N-1] (host+device, folds).
arange¶
arange<T>(Int<N>()) — the static form spelled with a static integer.
Variables¶
| Return | Name | Description |
|---|---|---|
constexpr ellipsis_t |
ellipsis constexpr |
|
constexpr ellipsis_t |
etc constexpr |
|
constexpr full_extent_t |
all constexpr |
Keep-this-axis marker for slicing (an alias of full_extent). |
constexpr keepdims_t |
keepdims constexpr |
|
constexpr copy_meta_t |
copy_meta constexpr |
|
constexpr bool |
narrow_index constexpr |
The spelling for dispatch_rank's opt-in flag: dispatch_rank<narrow_index>(at, f). |
constexpr none_t |
none constexpr |
|
constexpr none_t |
newaxis constexpr |
|
constexpr int64_t |
dynamic_stride constexpr |
Per-dimension dynamic-stride sentinel. |
constexpr storage |
storage_deduce constexpr |
Factory sentinel meaning "deduce the ownership from the shape" — a fully static shape -> stack (host+device), any dynamic extent -> heap (host). |
constexpr storage_c< O > |
storage_v constexpr |
A ready-made storage_c<O> VALUE — the no-braces spelling of the value tag: wrap(p, e, storage_v<[storage::gpu](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a0aa0be2a866411d9ff03515227454947)>) instead of storage_c<[storage::gpu](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a0aa0be2a866411d9ff03515227454947)>{}. |
constexpr bool |
is_view_v constexpr |
Compile-time memory-space traits (SFINAE-friendly free forms of the tensor's is_view/is_device/… members): is_view_v<decltype(x)>. |
constexpr bool |
is_owning_v constexpr |
|
constexpr bool |
is_device_v constexpr |
|
constexpr bool |
is_host_accessible_v constexpr |
ellipsis¶
constexpr
etc¶
constexpr
all¶
constexpr
Keep-this-axis marker for slicing (an alias of full_extent).
keepdims¶
constexpr
copy_meta¶
constexpr
narrow_index¶
constexpr
The spelling for dispatch_rank's opt-in flag: dispatch_rank<narrow_index>(at, f).
none¶
constexpr
newaxis¶
constexpr
dynamic_stride¶
constexpr
Per-dimension dynamic-stride sentinel.
Strides are signed: a negative stride is a legitimate value (reversed / flipped views, and DLPack tensors carry them). So — unlike shape<...>, where -1 marks a dynamic extent — we cannot use -1 to mean "runtime" for a stride. Instead a reserved out-of-band value (INT64_MIN) marks a dynamic stride, leaving every ordinary stride (including negatives) expressible.
storage_deduce¶
constexpr
Factory sentinel meaning "deduce the ownership from the shape" — a fully static shape -> stack (host+device), any dynamic extent -> heap (host).
It is the default backend of empty (and the creation factories), out of the enum's normal range so it never names storage.
storage_v¶
constexpr
A ready-made storage_c<O> VALUE — the no-braces spelling of the value tag: wrap(p, e, storage_v<[storage::gpu](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a0aa0be2a866411d9ff03515227454947)>) instead of storage_c<[storage::gpu](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a0aa0be2a866411d9ff03515227454947)>{}.
is_view_v¶
constexpr
Compile-time memory-space traits (SFINAE-friendly free forms of the tensor's is_view/is_device/… members): is_view_v<decltype(x)>.
is_owning_v¶
constexpr
is_device_v¶
constexpr
is_host_accessible_v¶
constexpr
anyrank¶
template<class T, class offset_t = int64_t, class Meta = _meta_store<offset_t, TNY_MAX_RANK>, storage Space = storage::view, class Tail = shape<>, class TailS = _runtime_strides_t<Tail::rank()>, class Head = shape<>, class HeadS = _runtime_strides_t<Head::rank()>>
struct anyrank
Defined in include/teeny/dynamic.h:253
A rank-erased tensor for the host/ndarray dispatch boundary.
Holds a data pointer, a runtime ndim, and 1-D shape/stride tensors (Meta). as_anyrank(...)wraps the caller's arrays with no copy (a _meta_view store, HOST only) — the default; as_anyrank(..., copy_meta) COPIES them into an INLINE TNY_MAX_RANK store, so the carrier is trivially copyable and passes into a CUDA kernel by value (device_passable == true).
You do NOT compute on it — it is a doorway, not a room. Turn it into a statically-typed view at the boundary and compute on that:
-
fixed<R>()— force a known total rank R. -
dispatch_rank(...)— pick R from the runtimendim. -
peel_front<-Sr>()— the batch idiom: peel the runtime number of leading batch dims, keep the trailingSr"interesting" dims STATIC. One kernel per Sr. NB the template arg is NEGATIVE: pass-Sr(peel_front<-2>()keeps the last two dims), matching the tensor'speel_frontsign rule — a positive front-count would leave a runtime rank, which can't be a static view (asserted).
peel_front / peel_front_at / size_front each also take the keep-count as a static integer VALUE — at.peel_front(Int<-Sr>()), at.peel_front_at(lin, Int<-Sr>()), at.size_front(Int<-Sr>()) — identical to the <-Sr> template spelling but deduced, so a carrier whose type is a template parameter needs no .template disambiguator.
Before any of those, the carrier itself can be narrowed to 32-bit offsets: index_fits<Idx2>() asks whether the whole carrier survives the narrowing (every reachable offset AND every extent value), reindex<Idx2>() returns the same carrier with an Idx2 meta store — so a GPU boundary narrows ONCE, host-side, and every cell it later hands out is Idx2-indexed.
Deliberately no add_/mul_/etc.: a runtime-rank arithmetic path would loop over ndim (killing folding) or dispatch to every rank (the bloat peel_front<-Sr> avoids). Do host-side math on a fixed<R>()/peel_front<-Sr>() view instead.
List of all members¶
| Name | Kind | Owner |
|---|---|---|
data |
variable |
Declared here |
shape |
variable |
Declared here |
stride |
variable |
Declared here |
ndim |
variable |
Declared here |
size |
function |
Declared here |
step |
function |
Declared here |
fixed |
function |
Declared here |
peel_front_at |
function |
Declared here |
peel_front_at |
function |
Declared here |
peel_front_at |
function |
Declared here |
peel_front_at |
function |
Declared here |
peel_front_at |
function |
Declared here |
peel_front |
function |
Declared here |
peel_front |
function |
Declared here |
size_front |
function |
Declared here |
size_front |
function |
Declared here |
index_fits |
function |
Declared here |
reindex |
function |
Declared here |
tail_rank |
variable |
Declared here |
head_rank |
variable |
Declared here |
ends_rank |
variable |
Declared here |
space |
variable |
Declared here |
is_device |
variable |
Declared here |
view_space |
variable |
Declared here |
max_rank |
variable |
Declared here |
device_passable |
variable |
Declared here |
tail_type |
typedef |
Declared here |
tail_stride_type |
typedef |
Declared here |
head_type |
typedef |
Declared here |
head_stride_type |
typedef |
Declared here |
reindexed |
typedef |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
T * |
data |
|
Meta |
shape |
|
Meta |
stride |
|
int |
ndim |
data¶
Defined in include/teeny/dynamic.h:254
shape¶
Defined in include/teeny/dynamic.h:255
stride¶
Defined in include/teeny/dynamic.h:256
ndim¶
Defined in include/teeny/dynamic.h:257
Public Methods¶
| Return | Name | Description |
|---|---|---|
offset_t |
size const inline noexcept |
|
offset_t |
step const inline noexcept |
|
_ends_cell< T, offset_t, R, Head, HeadS, Tail, TailS, view_space > |
fixed const inline |
View this tensor as a fixed rank R (requires ndim == R). |
auto |
peel_front_at const inline |
The lin-th sub-view keeping the last \|N\| axes static (grid-stride style). |
auto |
peel_front_at const inline |
Value form: at.peel_front_at(lin, Int<-Sr>()) == at.peel_front_at<-Sr>(lin). |
auto |
peel_front_at const inline |
The lin-th cell peeled DIRECTLY to a target trailing shape — fuses peel_front_at<-NewE::rank()>(lin).recast<NewE, NewL>() into one call, so no separate recast in the caller. |
auto |
peel_front_at const inline |
Value-form twins (no .template on a dependent receiver): pass the target shape (and optional layout) as a tag — at.peel_front_at(i, shape<-1,c,c>{}) / at.peel_front_at(i, shape<-1,c,c>{}, ccontiguous{}). |
auto |
peel_front_at const inline |
|
anyrank_front< T, offset_t, Meta, Space, Tail, TailS, static_cast< size_t >(N< 0 ? -N :0)> |
peel_front const inline |
Peel the leading batch axes -> an iterable of fixed-rank-\|N\| sub-views (range-for, [size()](#size-1), operator[]). |
auto |
peel_front const inline |
Value form: at.peel_front(Int<-Sr>()) == at.peel_front<-Sr>() — the keep-count as a static integer, deduced, so a type-dependent receiver needs no .template. |
offset_t |
size_front const inline noexcept |
The number of cells peel_front<N>() would yield — the product of the peeled leading (batch) extents — computed directly, without building the range. |
offset_t |
size_front const inline noexcept |
Value form: at.size_front(Int<-Sr>()) == at.size_front<-Sr>() — the keep-count as a static integer, deduced, so a type-dependent receiver needs no .template. |
bool |
index_fits const inline noexcept |
Can this carrier be re-expressed with the index type Idx2 — i.e. |
reindexed< Idx2, MaxRank > |
reindex const inline |
Narrow the whole carrier's OFFSET INDEX WIDTH to Idx2 — same data pointer, same memory Space, same static Head/Tail geometry, with ndim and the runtime shape/strides copied into an inline Idx2 store. |
size¶
const inline noexcept
Defined in include/teeny/dynamic.h:309
step¶
const inline noexcept
Defined in include/teeny/dynamic.h:310
fixed¶
const inline
template<size_t R> inline _ends_cell< T, offset_t, R, Head, HeadS, Tail, TailS, view_space > fixed() const
Defined in include/teeny/dynamic.h:347
View this tensor as a fixed rank R (requires ndim == R).
BOTH the static Head (first head_rank dims) and Tail (last tail_rank) fold — the full-rank window has a compile-time left edge, so the Head anchors.
peel_front_at¶
const inline
Defined in include/teeny/dynamic.h:373
The lin-th sub-view keeping the last |N| axes static (grid-stride style).
N is negative — matching the tensor's peel_front, negative means "keep the last |N| dims". (A positive front-count would leave a runtime rank, which can't be a static view — hence the assert.) Follow with recast<shape<-1,...>>().
peel_front_at¶
const inline
template<class I, enable_if_t< _is_ic< I >::value, int > = 0> inline auto peel_front_at(offset_t lin, I) const
Defined in include/teeny/dynamic.h:385
Value form: at.peel_front_at(lin, Int<-Sr>()) == at.peel_front_at<-Sr>(lin).
The keep-count is the only compile-time selector here, so it takes the plain Int<k>() static integer (the single-selector spelling t.squeeze(Int<1>()) uses) — deduced, so a type-dependent receiver needs no .template. The lin argument stays an ordinary runtime index; a static integer in the SECOND position is always the selector, and a shape<...> tag there is the fused-recast twin below — never confusable.
peel_front_at¶
const inline
template<class NewE, class NewL = keep_strides, enable_if_t< _is_extents< NewE >::value, int > = 0> inline auto peel_front_at(offset_t lin) const
Defined in include/teeny/dynamic.h:402
The lin-th cell peeled DIRECTLY to a target trailing shape — fuses peel_front_at<-NewE::rank()>(lin).recast<NewE, NewL>() into one call, so no separate recast in the caller.
NewE's rank = the number of KEPT trailing dims (the batch is the leading ndim - rank dims, decoded into the pointer); a static extent in NewE folds, a -1 extent stays dynamic (read from the carrier). (*batch, *spatial, C) -> 2-D pull with C=3 is peel_front_at<shape<-1,-1,3>>(i). Removes the hand-kept Sr == recast-shape rank invariant. STRIDES: NewL defaults to [keep_strides](#keep_strides) so the cell keeps the carrier's RUNTIME strides (layout_stride) — an anyrank has no compile-time stride info to fold. To fold the inner strides, either pass a layout (peel_front_at<shape<-1,c,c>, ccontiguous> — a debug-checked "I promise it's contiguous") or use the runtime-proven dispatch_layout on the result. UB if a baked static extent doesn't match the carrier (debug-checked in recast, same contract).
peel_front_at¶
const inline
template<class NewE, enable_if_t< _is_extents< NewE >::value, int > = 0> inline auto peel_front_at(offset_t lin, NewE) const
Defined in include/teeny/dynamic.h:409
Value-form twins (no .template on a dependent receiver): pass the target shape (and optional layout) as a tag — at.peel_front_at(i, shape<-1,c,c>{}) / at.peel_front_at(i, shape<-1,c,c>{}, ccontiguous{}).
peel_front_at¶
const inline
template<class NewE, class NewL, enable_if_t< _is_extents< NewE >::value, int > = 0> inline auto peel_front_at(offset_t lin, NewE, NewL) const
Defined in include/teeny/dynamic.h:411
peel_front¶
const inline
template<long N> inline anyrank_front< T, offset_t, Meta, Space, Tail, TailS, static_cast< size_t >(N< 0 ? -N :0)> peel_front() const
Defined in include/teeny/dynamic.h:419
Peel the leading batch axes -> an iterable of fixed-rank-|N| sub-views (range-for, [size()](#size-1), operator[]).
The (*batch, *spatial, C) boundary with |N| = spatial + channels: one kernel instantiation for |N|, not one per total rank. N is negative (keep the last |N| dims), as on the tensor.
peel_front¶
const inline
Defined in include/teeny/dynamic.h:429
Value form: at.peel_front(Int<-Sr>()) == at.peel_front<-Sr>() — the keep-count as a static integer, deduced, so a type-dependent receiver needs no .template.
size_front¶
const inline noexcept
Defined in include/teeny/dynamic.h:437
The number of cells peel_front<N>() would yield — the product of the peeled leading (batch) extents — computed directly, without building the range.
N is NEGATIVE (keep the last |N| dims), the same sign as peel_front; size_front<-2>() is the flattened batch count of a (*batch, C, C) carrier.
size_front¶
const inline noexcept
template<class I, enable_if_t< _is_ic< I >::value, int > = 0> inline offset_t size_front(I) const noexcept
Defined in include/teeny/dynamic.h:447
Value form: at.size_front(Int<-Sr>()) == at.size_front<-Sr>() — the keep-count as a static integer, deduced, so a type-dependent receiver needs no .template.
index_fits¶
const inline noexcept
Defined in include/teeny/dynamic.h:495
Can this carrier be re-expressed with the index type Idx2 — i.e.
does every reachable element OFFSET fit Idx2, and is every axis's EXTENT VALUE representable in it? The whole-carrier twin of the view's index_fits<Idx2>(), and the precondition reindex<Idx2>() debug-checks. Both halves matter: narrowing rewrites the carrier's shape as well as its offsets, and a truncated extent silently becomes the wrong loop bound for every cell peeled off it (#489).
The offset half keeps the same SIGNED reach contract (teeny has negative-stride views): max = Σ_{s>0}(e−1)·s, min = Σ_{s<0}(e−1)·s; fits ⟺ min..max ⊆ Idx2. It accumulates in a wide type, with the accumulation itself overflow-checked (#471 — safe even against adversarial/corrupted shape/stride, e.g. off a raw DLPack import); a broadcast (stride-0) axis adds 0 there, and is then held to the extent-value half like any other axis.
Idx2 may be ANY integral type up to 64 bits, signed or unsigned (uint64_t/size_t included): the positive and negative reach accumulate in separate unsigned/signed 64-bit domains, so neither comparison can wrap (#484). The CARRIER's own offset_t may equally be unsigned 64-bit — as_anyrank(data, shape, stride, ndim) deduces it from the caller's arrays, so a C-interop boundary holding uint64_t/size_t metadata lands here with raw values above long long's range; each is measured in the type it is stored in rather than blind-cast down first (#486).
A STATIC extent (a Head/Tail geometry dim) that cannot be represented in Idx2 is a compile error from reindex<Idx2>() itself, so this runtime query is about the carrier's dynamic ones.
reindex¶
const inline
Defined in include/teeny/dynamic.h:524
Narrow the whole carrier's OFFSET INDEX WIDTH to Idx2 — same data pointer, same memory Space, same static Head/Tail geometry, with ndim and the runtime shape/strides copied into an inline Idx2 store.
Every cell peeled off the result is then Idx2-indexed for free, so a GPU boundary narrows once, on the host, and still launches the batch idiom (peel_front<-Sr>) — 32-bit offset math, fewer registers, and half the meta store to pass by value into a __global__.
The static extents/strides baked into the type are PURE TYPE INFO and are untouched (only their extents' index type follows Idx2). MaxRank sets the inline capacity (default: this carrier's own max_rank).
Debug-checks index_fits<Idx2>() — every offset AND every dynamic extent value — and is UB if the caller lies; the same contract as the view's reindex (a STATIC Head/Tail extent too large for Idx2 is a compile error instead, #489):
dispatch_index(at, f) does for you.
Public Static Attributes¶
| Return | Name | Description |
|---|---|---|
constexpr size_t |
tail_rank static constexpr |
|
constexpr size_t |
head_rank static constexpr |
|
constexpr size_t |
ends_rank static constexpr |
|
constexpr storage |
space static constexpr |
|
constexpr bool |
is_device static constexpr |
|
constexpr storage |
view_space static constexpr |
|
constexpr size_t |
max_rank static constexpr |
|
constexpr bool |
device_passable static constexpr |
tail_rank¶
static constexpr
Defined in include/teeny/dynamic.h:274
head_rank¶
static constexpr
Defined in include/teeny/dynamic.h:275
ends_rank¶
static constexpr
Defined in include/teeny/dynamic.h:276
space¶
static constexpr
Defined in include/teeny/dynamic.h:285
is_device¶
static constexpr
Defined in include/teeny/dynamic.h:286
view_space¶
static constexpr
Defined in include/teeny/dynamic.h:288
max_rank¶
static constexpr
constexpr size_t max_rank =
Meta::extents_type::static_extent(0) != dynamic_extent
? Meta::extents_type::static_extent(0) : size_t()
Defined in include/teeny/dynamic.h:292
device_passable¶
static constexpr
Defined in include/teeny/dynamic.h:306
Public Types¶
| Name | Description |
|---|---|
tail_type |
|
tail_stride_type |
|
head_type |
|
head_stride_type |
|
reindexed |
The carrier type reindex<Idx2>() produces: same T/Space and the same static Head/Tail geometry, with the offset width — and the meta store — narrowed to Idx2. |
tail_type¶
Defined in include/teeny/dynamic.h:270
tail_stride_type¶
Defined in include/teeny/dynamic.h:271
head_type¶
Defined in include/teeny/dynamic.h:272
head_stride_type¶
Defined in include/teeny/dynamic.h:273
reindexed¶
using reindexed = anyrank< T, Idx2, _meta_store< Idx2, MaxRank >, Space, _reindex_extents_t< Idx2, Tail >, TailS, _reindex_extents_t< Idx2, Head >, HeadS >
Defined in include/teeny/dynamic.h:462
The carrier type reindex<Idx2>() produces: same T/Space and the same static Head/Tail geometry, with the offset width — and the meta store — narrowed to Idx2.
Always an INLINE (copy_meta) store: narrowing has to copy, there is nothing to narrow a wrapped array into.
anyrank_front¶
template<class T, class offset_t, class Meta, storage Space, class Tail, class TailS, size_t Sr>
struct anyrank_front
Defined in include/teeny/dynamic.h:568
A range of fixed-rank-Sr sub-views over an anyrank's batch axes.
Inherits the carrier's Space, so each cell is a host or gpu_view view accordingly.
List of all members¶
| Name | Kind | Owner |
|---|---|---|
src |
variable |
Declared here |
size |
function |
Declared here |
operator[] |
function |
Declared here |
begin |
function |
Declared here |
end |
function |
Declared here |
subrange |
function |
Declared here |
enumerate |
function |
Declared here |
MaxNb |
variable |
Declared here |
Cell |
typedef |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
anyrank< T, offset_t, Meta, Space, Tail, TailS > |
src |
src¶
Defined in include/teeny/dynamic.h:569
Public Methods¶
| Return | Name | Description |
|---|---|---|
offset_t |
size const inline noexcept |
|
auto |
operator[] const inline |
|
iterator |
begin const inline |
|
iterator |
end const inline |
|
subrange_t |
subrange const inline |
|
enum_range |
enumerate const inline |
size¶
const inline noexcept
Defined in include/teeny/dynamic.h:573
operator[]¶
const inline
Defined in include/teeny/dynamic.h:575
begin¶
const inline
Defined in include/teeny/dynamic.h:623
end¶
const inline
Defined in include/teeny/dynamic.h:624
subrange¶
const inline
Defined in include/teeny/dynamic.h:634
enumerate¶
const inline
Defined in include/teeny/dynamic.h:676
Public Static Attributes¶
| Return | Name | Description |
|---|---|---|
constexpr size_t |
MaxNb static constexpr |
MaxNb¶
static constexpr
Defined in include/teeny/dynamic.h:571
Public Types¶
| Name | Description |
|---|---|
Cell |
Cell¶
Defined in include/teeny/dynamic.h:570
coord¶
Defined in include/teeny/dynamic.h:648
List of all members¶
| Name | Kind | Owner |
|---|---|---|
ctr |
variable |
Declared here |
nb |
variable |
Declared here |
lin |
variable |
Declared here |
operator[] |
function |
Declared here |
rank |
function |
Declared here |
linear |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
const offset_t * |
ctr |
|
int |
nb |
|
offset_t |
lin |
ctr¶
Defined in include/teeny/dynamic.h:649
nb¶
Defined in include/teeny/dynamic.h:649
lin¶
Defined in include/teeny/dynamic.h:649
Public Methods¶
| Return | Name | Description |
|---|---|---|
offset_t |
operator[] const inline noexcept |
|
int |
rank const inline noexcept |
|
offset_t |
linear const inline noexcept |
operator[]¶
const inline noexcept
Defined in include/teeny/dynamic.h:650
rank¶
const inline noexcept
Defined in include/teeny/dynamic.h:651
linear¶
const inline noexcept
Defined in include/teeny/dynamic.h:652
enum_iterator¶
Defined in include/teeny/dynamic.h:655
List of all members¶
| Name | Kind | Owner |
|---|---|---|
it |
variable |
Declared here |
operator* |
function |
Declared here |
operator++ |
function |
Declared here |
operator!= |
function |
Declared here |
operator== |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
iterator |
it |
it¶
Defined in include/teeny/dynamic.h:656
Public Methods¶
| Return | Name | Description |
|---|---|---|
item |
operator* const inline |
|
enum_iterator & |
operator++ inline |
|
bool |
operator!= const inline |
|
bool |
operator== const inline |
operator*¶
const inline
Defined in include/teeny/dynamic.h:657
operator++¶
inline
Defined in include/teeny/dynamic.h:658
operator!=¶
const inline
Defined in include/teeny/dynamic.h:659
operator==¶
const inline
Defined in include/teeny/dynamic.h:660
enum_range¶
Defined in include/teeny/dynamic.h:662
List of all members¶
| Name | Kind | Owner |
|---|---|---|
r |
variable |
Declared here |
begin |
function |
Declared here |
end |
function |
Declared here |
subrange |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
anyrank_front |
r |
r¶
Defined in include/teeny/dynamic.h:663
Public Methods¶
| Return | Name | Description |
|---|---|---|
enum_iterator |
begin const inline |
|
enum_iterator |
end const inline |
|
enum_subrange |
subrange const inline |
begin¶
const inline
Defined in include/teeny/dynamic.h:664
end¶
const inline
Defined in include/teeny/dynamic.h:665
subrange¶
const inline
Defined in include/teeny/dynamic.h:671
enum_subrange¶
Defined in include/teeny/dynamic.h:666
List of all members¶
| Name | Kind | Owner |
|---|---|---|
b |
variable |
Declared here |
e |
variable |
Declared here |
begin |
function |
Declared here |
end |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
enum_iterator |
b |
|
enum_iterator |
e |
b¶
Defined in include/teeny/dynamic.h:667
e¶
Defined in include/teeny/dynamic.h:667
Public Methods¶
| Return | Name | Description |
|---|---|---|
enum_iterator |
begin const inline |
|
enum_iterator |
end const inline |
begin¶
const inline
Defined in include/teeny/dynamic.h:668
end¶
const inline
Defined in include/teeny/dynamic.h:669
item¶
Defined in include/teeny/dynamic.h:654
List of all members¶
| Name | Kind | Owner |
|---|---|---|
index |
variable |
Declared here |
cell |
variable |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
coord |
index |
|
Cell |
cell |
index¶
Defined in include/teeny/dynamic.h:654
cell¶
Defined in include/teeny/dynamic.h:654
iterator¶
Defined in include/teeny/dynamic.h:582
List of all members¶
| Name | Kind | Owner |
|---|---|---|
tmpl |
variable |
Declared here |
base |
variable |
Declared here |
ctr |
variable |
Declared here |
ext |
variable |
Declared here |
str |
variable |
Declared here |
nb |
variable |
Declared here |
off |
variable |
Declared here |
lin |
variable |
Declared here |
operator* |
function |
Declared here |
operator++ |
function |
Declared here |
operator!= |
function |
Declared here |
operator== |
function |
Declared here |
index |
function |
Declared here |
nbatch |
function |
Declared here |
linear |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
Cell |
tmpl |
|
T * |
base |
|
offset_t |
ctr |
|
offset_t |
ext |
|
offset_t |
str |
|
int |
nb |
|
offset_t |
off |
|
offset_t |
lin |
tmpl¶
Defined in include/teeny/dynamic.h:583
base¶
Defined in include/teeny/dynamic.h:584
ctr¶
Defined in include/teeny/dynamic.h:585
ext¶
Defined in include/teeny/dynamic.h:586
str¶
Defined in include/teeny/dynamic.h:587
nb¶
Defined in include/teeny/dynamic.h:588
off¶
Defined in include/teeny/dynamic.h:589
lin¶
Defined in include/teeny/dynamic.h:589
Public Methods¶
| Return | Name | Description |
|---|---|---|
Cell |
operator* const inline |
|
iterator & |
operator++ inline |
|
bool |
operator!= const inline |
|
bool |
operator== const inline |
|
offset_t |
index const inline noexcept |
|
int |
nbatch const inline noexcept |
|
offset_t |
linear const inline noexcept |
operator*¶
const inline
Defined in include/teeny/dynamic.h:590
operator++¶
inline
Defined in include/teeny/dynamic.h:591
operator!=¶
const inline
Defined in include/teeny/dynamic.h:599
operator==¶
const inline
Defined in include/teeny/dynamic.h:600
index¶
const inline noexcept
Defined in include/teeny/dynamic.h:606
nbatch¶
const inline noexcept
Defined in include/teeny/dynamic.h:607
linear¶
const inline noexcept
Defined in include/teeny/dynamic.h:608
subrange_t¶
Defined in include/teeny/dynamic.h:629
A [lo, hi) slice of the batch cells for chunked/threaded sweeps: seed the incremental cursor once at lo, then O(1) per step.
Split [0, [size()](#size-2)) across threads/blocks; each sweeps its own chunk.
List of all members¶
| Name | Kind | Owner |
|---|---|---|
b |
variable |
Declared here |
e |
variable |
Declared here |
begin |
function |
Declared here |
end |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
iterator |
b |
|
iterator |
e |
b¶
Defined in include/teeny/dynamic.h:630
e¶
Defined in include/teeny/dynamic.h:630
Public Methods¶
| Return | Name | Description |
|---|---|---|
iterator |
begin const inline |
|
iterator |
end const inline |
begin¶
const inline
Defined in include/teeny/dynamic.h:631
end¶
const inline
Defined in include/teeny/dynamic.h:632
anyshape¶
Defined in include/teeny/alias.h:237
The shape spelling for the rank-erased anyrank boundary: exactly one etc marks the dynamic-rank region, the dims AFTER it are the static Tail (anchored at ndim), the dims BEFORE it are the static Head (anchored at 0).
Each non-etc slot is a per-dim static extent or -1 (dynamic), exactly like shape<...>. Hand it to as_anyrank(..., anyshape<etc,-1,-1,3>{}) or from_dlpack<T, anyshape<etc,-1,-1,3>>(m) so the peeled cells fold those inner dims — anyshape<etc,-1,-1,3> == (*batch, spatial, spatial, C=3).
A static leading Head (dims BEFORE etc) is allowed too: anyshape<A, B, etc, C, D> == (A, B, *middle, C, D) — e.g. anyshape<3, etc, 5> for (C_in=3, *spatial, C_out=5). The Head folds in fixed/dispatch_rank (full-rank materialisation); peel_front<-Sr> stays trailing-oriented (a leading Head is normally peeled into the batch).
Unlike a plain shape<...> (a concrete fixed-rank extents), an anyshape is a SPEC, not a tensor type — a runtime-rank object needs the data + runtime arrays, not just a type.
List of all members¶
| Name | Kind | Owner |
|---|---|---|
head |
typedef |
Declared here |
tail |
typedef |
Declared here |
Public Types¶
| Name | Description |
|---|---|
head |
|
tail |
head¶
Defined in include/teeny/alias.h:241
tail¶
Defined in include/teeny/alias.h:242
axis¶
Defined in include/teeny/alias.h:257
Compile-time axis selector — a value tag carrying a list of axes, the sibling of shape<...> for axis arguments.
It lets axis-taking ops be spelled by VALUE (deducing the axes from the argument type) instead of an explicit template list, so on a type-dependent receiver they need no .template: peel(t, axis<0,1>{}) == peel<0,1>(t), t.slice_along(axis<0,2>{}, i, slice(1,4)) == t.slice_along<0,2>(i, slice(1,4)).
Like numpy's axis: int | list[int], one variadic tag covers both a single axis (axis<0>{}) and a list (axis<0,2>{}); axes are signed (negatives count from the back, as everywhere in teeny). rank is the axis count.
List of all members¶
| Name | Kind | Owner |
|---|---|---|
rank |
variable |
Declared here |
Public Static Attributes¶
| Return | Name | Description |
|---|---|---|
constexpr size_t |
rank static constexpr |
rank¶
static constexpr
Defined in include/teeny/alias.h:257
candidates_t¶
Defined in include/teeny/dynamic.h:931
One parameter's candidate list for dispatch_values — the runtime value paired with the compile-time values it is allowed to be.
You never spell this type; candidates<Vs...>(v) builds it.
List of all members¶
| Name | Kind | Owner |
|---|---|---|
value |
variable |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
int |
value |
value¶
Defined in include/teeny/dynamic.h:931
compute_type¶
Defined in include/teeny/half.h:137
The type math should ACCUMULATE / compute in for element type T.
Half types compute in float (16-bit accumulation loses precision fast, the usual mixed-precision rule: accumulate wider than you store — and it lets the engines avoid depending on native half host operators). Everything else computes in itself.
List of all members¶
| Name | Kind | Owner |
|---|---|---|
type |
typedef |
Declared here |
Public Types¶
| Name | Description |
|---|---|
type |
type¶
Defined in include/teeny/half.h:137
compute_type< bfloat16 >¶
Defined in include/teeny/half.h:139
List of all members¶
| Name | Kind | Owner |
|---|---|---|
type |
typedef |
Declared here |
Public Types¶
| Name | Description |
|---|---|
type |
type¶
Defined in include/teeny/half.h:139
compute_type< half >¶
Defined in include/teeny/half.h:138
List of all members¶
| Name | Kind | Owner |
|---|---|---|
type |
typedef |
Declared here |
Public Types¶
| Name | Description |
|---|---|
type |
type¶
Defined in include/teeny/half.h:138
copy_meta_t¶
Defined in include/teeny/dynamic.h:208
Tag for as_anyrank(..., copy_meta): COPY shape/stride into an inline, device-passable store instead of wrapping the caller's arrays.
Named copy_meta, not copy: a bare copy variable in tny would, under using namespace tny, shadow an unqualified std::copy(...) call (finding a variable suppresses ADL) — a nasty surprise.
cpp_alloc¶
Defined in include/teeny/storage.h:112
Host allocator using C++ new[] / delete[].
List of all members¶
| Name | Kind | Owner |
|---|---|---|
allocate |
function |
Declared here |
allocate_uninit |
function |
Declared here |
deallocate |
function |
Declared here |
Public Static Methods¶
| Return | Name | Description |
|---|---|---|
T * |
allocate static inline |
|
T * |
allocate_uninit static inline |
|
void |
deallocate static inline |
allocate¶
static inline
Defined in include/teeny/storage.h:113
allocate_uninit¶
static inline
Defined in include/teeny/storage.h:114
deallocate¶
static inline
Defined in include/teeny/storage.h:115
cuda_gpu_alloc¶
Defined in include/teeny/cuda.h:30
Device (GPU) memory (cudaMalloc).
Not host-dereferenceable.
List of all members¶
| Name | Kind | Owner |
|---|---|---|
allocate |
function |
Declared here |
allocate_uninit |
function |
Declared here |
deallocate |
function |
Declared here |
Public Static Methods¶
| Return | Name | Description |
|---|---|---|
T * |
allocate static inline |
|
T * |
allocate_uninit static inline |
|
void |
deallocate static inline |
allocate¶
static inline
Defined in include/teeny/cuda.h:31
allocate_uninit¶
static inline
Defined in include/teeny/cuda.h:34
deallocate¶
static inline
Defined in include/teeny/cuda.h:35
cuda_mapped_alloc¶
Defined in include/teeny/cuda.h:48
Page-locked + device-mapped (zero-copy) host memory (cudaHostAlloc).
List of all members¶
| Name | Kind | Owner |
|---|---|---|
allocate |
function |
Declared here |
allocate_uninit |
function |
Declared here |
deallocate |
function |
Declared here |
Public Static Methods¶
| Return | Name | Description |
|---|---|---|
T * |
allocate static inline |
|
T * |
allocate_uninit static inline |
|
void |
deallocate static inline |
allocate¶
static inline
Defined in include/teeny/cuda.h:49
allocate_uninit¶
static inline
Defined in include/teeny/cuda.h:52
deallocate¶
static inline
Defined in include/teeny/cuda.h:53
cuda_pinned_alloc¶
Defined in include/teeny/cuda.h:39
Page-locked ("pinned") host memory (cudaMallocHost).
List of all members¶
| Name | Kind | Owner |
|---|---|---|
allocate |
function |
Declared here |
allocate_uninit |
function |
Declared here |
deallocate |
function |
Declared here |
Public Static Methods¶
| Return | Name | Description |
|---|---|---|
T * |
allocate static inline |
|
T * |
allocate_uninit static inline |
|
void |
deallocate static inline |
allocate¶
static inline
Defined in include/teeny/cuda.h:40
allocate_uninit¶
static inline
Defined in include/teeny/cuda.h:43
deallocate¶
static inline
Defined in include/teeny/cuda.h:44
dtype¶
Defined in include/teeny/alias.h:282
Compile-time element-type tag — a value carrier for T, the sibling of axis<...> for the dtype argument.
It lets a type-parameterised call be spelled by VALUE (deducing T from the argument) instead of an explicit <T> template argument, so on a type-dependent receiver it needs no .template: empty(shape<3,3>{}, dtype<double>{}) == empty<double>(shape<3,3>{}), a.to(dtype<float>{}) == a.to<float>(). Numpy's dtype= keyword is the namesake — including reuse as the reduction accumulator/result type: sum(a, dtype<double>{}) == sum<double>(a), matching np.sum(a, dtype=...).
into_t¶
Defined in include/teeny/tensor.h:32
List of all members¶
| Name | Kind | Owner |
|---|---|---|
dest |
variable |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
D & |
dest |
dest¶
Defined in include/teeny/tensor.h:32
keep_strides¶
Defined in include/teeny/layout.h:231
Sentinel Layout selector for recast<NewShape, [keep_strides](#keep_strides)>() (the default): PRESERVE the source strides (fold where the source layout makes them derivable, keep runtime otherwise).
Contrast an explicit layout — recast<NewShape, ccontiguous>() reinterprets AS that layout, deriving the strides from the extents (the "I promise this is C-contiguous" form). Not a real layout (it has no mapping) — only a recast tag.
keepdims_t¶
Defined in include/teeny/alias.h:311
numpy/pytorch keepdims=True tag for axis reductions — pass as any trailing keyword (composes with dtype<...>/axis<...>/into(dest) in any order) to keep the reduced axes as size-1 instead of removing them, so the result broadcasts back against the input: sum<0>(a, keepdims), sum(a, axis<0,2>{}, keepdims).
A distinct empty-tag type, like all/none, so it never collides with another argument.
none_t¶
Defined in include/teeny/indexing.h:117
Open-ended slice sentinel — teeny's None (python a[:n] / a[m:]).
slice(none, n) starts at 0, slice(m, none) runs to the end, and slice(none, none)folds to full_extent — so all == slice(none, none), keeping the axis and its static extent (all is built from it). Combined with runtime bounds it resolves at run time, so the one sentinel covers both.
A BARE noneargument to operator()/uget is a different thing: numpy newaxis (a[None]), which inserts a size-1 axis — see _is_newaxis below. newaxis is a named alias of none for that bare-argument spelling (numpy calls the same value None when it's a slice bound and np.newaxis when it's inserting an axis; teeny's none/newaxis mirror that with one type).
owning_storage¶
Defined in include/teeny/storage.h:129
Generic owning storage (move-only, no ref-counting), parameterised by an allocator policy.
Shared by all owning storage modes.
List of all members¶
| Name | Kind | Owner |
|---|---|---|
p |
variable |
Declared here |
owning_storage |
function |
Declared here |
owning_storage |
function |
Declared here |
owning_storage |
function |
Declared here |
owning_storage |
function |
Declared here |
owning_storage |
function |
Declared here |
data |
function |
Declared here |
data |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
T * |
p |
p¶
Defined in include/teeny/storage.h:130
Public Methods¶
| Return | Name | Description |
|---|---|---|
owning_storage |
Defaulted constructor. | |
owning_storage inline explicit |
||
owning_storage inline |
||
owning_storage |
Deleted constructor. | |
owning_storage inline noexcept |
||
T * |
data inline noexcept |
|
const T * |
data const inline noexcept |
owning_storage¶
Defined in include/teeny/storage.h:131
Defaulted constructor.
owning_storage¶
inline explicit
Defined in include/teeny/storage.h:132
owning_storage¶
inline
Defined in include/teeny/storage.h:133
owning_storage¶
Defined in include/teeny/storage.h:134
Deleted constructor.
owning_storage¶
inline noexcept
Defined in include/teeny/storage.h:136
data¶
inline noexcept
Defined in include/teeny/storage.h:142
data¶
const inline noexcept
Defined in include/teeny/storage.h:143
peel_range¶
Defined in include/teeny/iterate.h:154
A range of sub-views obtained by peeling Axes....
Supports [size()](#size-3), random-access operator[] (grid-stride loops), range-for (an INCREMENTAL cursor — #110 — that advances the pointer instead of re-decoding each step, and builds the loop-invariant sub-view mapping once), and subrange(lo,hi) for chunked/threaded sweeps.
List of all members¶
| Name | Kind | Owner |
|---|---|---|
src |
variable |
Declared here |
size |
function |
Declared here |
operator[] |
function |
Declared here |
begin |
function |
Declared here |
end |
function |
Declared here |
subrange |
function |
Declared here |
enumerate |
function |
Declared here |
Nd |
variable |
Declared here |
index_type |
typedef |
Declared here |
Cell |
typedef |
Declared here |
El |
typedef |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
MD |
src |
src¶
Defined in include/teeny/iterate.h:157
Public Methods¶
| Return | Name | Description |
|---|---|---|
index_type |
size const inline noexcept |
|
auto |
operator[] const inline |
|
iterator |
begin const inline |
|
iterator |
end const inline |
|
subrange_t |
subrange const inline |
|
enum_range |
enumerate const inline |
size¶
const inline noexcept
Defined in include/teeny/iterate.h:159
operator[]¶
const inline
Defined in include/teeny/iterate.h:167
begin¶
const inline
Defined in include/teeny/iterate.h:202
end¶
const inline
Defined in include/teeny/iterate.h:203
subrange¶
const inline
Defined in include/teeny/iterate.h:213
enumerate¶
const inline
Defined in include/teeny/iterate.h:248
Public Static Attributes¶
| Return | Name | Description |
|---|---|---|
constexpr size_t |
Nd static constexpr |
Nd¶
static constexpr
Defined in include/teeny/iterate.h:156
Public Types¶
| Name | Description |
|---|---|
index_type |
|
Cell |
|
El |
index_type¶
Defined in include/teeny/iterate.h:155
Cell¶
Defined in include/teeny/iterate.h:172
El¶
Defined in include/teeny/iterate.h:173
enum_iterator¶
Defined in include/teeny/iterate.h:227
List of all members¶
| Name | Kind | Owner |
|---|---|---|
it |
variable |
Declared here |
operator* |
function |
Declared here |
operator++ |
function |
Declared here |
operator!= |
function |
Declared here |
operator== |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
iterator |
it |
it¶
Defined in include/teeny/iterate.h:228
Public Methods¶
| Return | Name | Description |
|---|---|---|
item |
operator* const inline |
|
enum_iterator & |
operator++ inline |
|
bool |
operator!= const inline |
|
bool |
operator== const inline |
operator*¶
const inline
Defined in include/teeny/iterate.h:229
operator++¶
inline
Defined in include/teeny/iterate.h:230
operator!=¶
const inline
Defined in include/teeny/iterate.h:231
operator==¶
const inline
Defined in include/teeny/iterate.h:232
enum_range¶
Defined in include/teeny/iterate.h:234
List of all members¶
| Name | Kind | Owner |
|---|---|---|
r |
variable |
Declared here |
begin |
function |
Declared here |
end |
function |
Declared here |
subrange |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
peel_range |
r |
r¶
Defined in include/teeny/iterate.h:235
Public Methods¶
| Return | Name | Description |
|---|---|---|
enum_iterator |
begin const inline |
|
enum_iterator |
end const inline |
|
enum_subrange |
subrange const inline |
begin¶
const inline
Defined in include/teeny/iterate.h:236
end¶
const inline
Defined in include/teeny/iterate.h:237
subrange¶
const inline
Defined in include/teeny/iterate.h:243
enum_subrange¶
Defined in include/teeny/iterate.h:238
List of all members¶
| Name | Kind | Owner |
|---|---|---|
b |
variable |
Declared here |
e |
variable |
Declared here |
begin |
function |
Declared here |
end |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
enum_iterator |
b |
|
enum_iterator |
e |
b¶
Defined in include/teeny/iterate.h:239
e¶
Defined in include/teeny/iterate.h:239
Public Methods¶
| Return | Name | Description |
|---|---|---|
enum_iterator |
begin const inline |
|
enum_iterator |
end const inline |
begin¶
const inline
Defined in include/teeny/iterate.h:240
end¶
const inline
Defined in include/teeny/iterate.h:241
item¶
Defined in include/teeny/iterate.h:226
List of all members¶
| Name | Kind | Owner |
|---|---|---|
index |
variable |
Declared here |
cell |
variable |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
array< index_type, Nd ? Nd :1 > |
index |
|
Cell |
cell |
index¶
Defined in include/teeny/iterate.h:226
cell¶
Defined in include/teeny/iterate.h:226
iterator¶
Defined in include/teeny/iterate.h:174
List of all members¶
| Name | Kind | Owner |
|---|---|---|
tmpl |
variable |
Declared here |
base |
variable |
Declared here |
cur |
variable |
Declared here |
operator* |
function |
Declared here |
operator++ |
function |
Declared here |
operator!= |
function |
Declared here |
operator== |
function |
Declared here |
index |
function |
Declared here |
index |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
Cell |
tmpl |
|
El * |
base |
|
_md::peel_cursor< index_type, Nd > |
cur |
tmpl¶
Defined in include/teeny/iterate.h:175
base¶
Defined in include/teeny/iterate.h:176
cur¶
Defined in include/teeny/iterate.h:177
Public Methods¶
| Return | Name | Description |
|---|---|---|
Cell |
operator* const inline |
|
iterator & |
operator++ inline |
|
bool |
operator!= const inline |
|
bool |
operator== const inline |
|
index_type |
index const inline noexcept |
|
array< index_type, Nd ? Nd :1 > |
index const inline noexcept |
operator*¶
const inline
Defined in include/teeny/iterate.h:178
operator++¶
inline
Defined in include/teeny/iterate.h:179
operator!=¶
const inline
Defined in include/teeny/iterate.h:180
operator==¶
const inline
Defined in include/teeny/iterate.h:181
index¶
const inline noexcept
Defined in include/teeny/iterate.h:186
index¶
const inline noexcept
Defined in include/teeny/iterate.h:187
subrange_t¶
Defined in include/teeny/iterate.h:208
A [lo, hi) slice of the cells for chunked/threaded sweeps: seed the incremental cursor once at lo, then O(1) per step within the chunk.
(Split [0,[size()](#size-3)) across threads/blocks; each sweeps its chunk.)
List of all members¶
| Name | Kind | Owner |
|---|---|---|
b |
variable |
Declared here |
e |
variable |
Declared here |
begin |
function |
Declared here |
end |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
iterator |
b |
|
iterator |
e |
b¶
Defined in include/teeny/iterate.h:209
e¶
Defined in include/teeny/iterate.h:209
Public Methods¶
| Return | Name | Description |
|---|---|---|
iterator |
begin const inline |
|
iterator |
end const inline |
begin¶
const inline
Defined in include/teeny/iterate.h:210
end¶
const inline
Defined in include/teeny/iterate.h:211
ptr_storage¶
Defined in include/teeny/storage.h:159
Subclassed by:
gpu_view, N >,mapped_view, N >,pinned_view, N >,view, N >
List of all members¶
| Name | Kind | Owner |
|---|---|---|
p |
variable |
Declared here |
ptr_storage |
function |
Declared here |
ptr_storage |
function |
Declared here |
data |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
T * |
p |
p¶
Defined in include/teeny/storage.h:160
Public Methods¶
| Return | Name | Description |
|---|---|---|
ptr_storage |
Defaulted constructor. | |
constexpr |
ptr_storage inline constexpr noexcept |
|
constexpr T * |
data const inline constexpr noexcept |
ptr_storage¶
Defined in include/teeny/storage.h:161
Defaulted constructor.
ptr_storage¶
inline constexpr noexcept
Defined in include/teeny/storage.h:162
data¶
const inline constexpr noexcept
Defined in include/teeny/storage.h:163
storage_policy¶
Defined in include/teeny/storage.h:151
gpu, N >¶
Defined in include/teeny/cuda.h:61
Inherits:
owning_storage< T, cuda_gpu_alloc >
List of all members¶
| Name | Kind | Owner |
|---|---|---|
p |
variable |
Inherited from owning_storage |
owning_storage |
function |
Inherited from owning_storage |
owning_storage |
function |
Inherited from owning_storage |
owning_storage |
function |
Inherited from owning_storage |
owning_storage |
function |
Inherited from owning_storage |
owning_storage |
function |
Inherited from owning_storage |
data |
function |
Inherited from owning_storage |
data |
function |
Inherited from owning_storage |
Inherited from owning_storage¶
| Kind | Name | Description |
|---|---|---|
variable |
p |
|
function |
owning_storage |
Defaulted constructor. |
function |
owning_storage inline explicit |
|
function |
owning_storage inline |
|
function |
owning_storage |
Deleted constructor. |
function |
owning_storage inline noexcept |
|
function |
data inline noexcept |
|
function |
data const inline noexcept |
gpu_view, N >¶
Defined in include/teeny/storage.h:166
Inherits:
ptr_storage< T >
List of all members¶
| Name | Kind | Owner |
|---|---|---|
p |
variable |
Inherited from ptr_storage |
ptr_storage |
function |
Inherited from ptr_storage |
ptr_storage |
function |
Inherited from ptr_storage |
data |
function |
Inherited from ptr_storage |
Inherited from ptr_storage¶
| Kind | Name | Description |
|---|---|---|
variable |
p |
|
function |
ptr_storage |
Defaulted constructor. |
function |
ptr_storage inline constexpr noexcept |
|
function |
data const inline constexpr noexcept |
heap, N >¶
Defined in include/teeny/storage.h:186
Inherits:
owning_storage< T, cpp_alloc >
List of all members¶
| Name | Kind | Owner |
|---|---|---|
p |
variable |
Inherited from owning_storage |
owning_storage |
function |
Inherited from owning_storage |
owning_storage |
function |
Inherited from owning_storage |
owning_storage |
function |
Inherited from owning_storage |
owning_storage |
function |
Inherited from owning_storage |
owning_storage |
function |
Inherited from owning_storage |
data |
function |
Inherited from owning_storage |
data |
function |
Inherited from owning_storage |
Inherited from owning_storage¶
| Kind | Name | Description |
|---|---|---|
variable |
p |
|
function |
owning_storage |
Defaulted constructor. |
function |
owning_storage inline explicit |
|
function |
owning_storage inline |
|
function |
owning_storage |
Deleted constructor. |
function |
owning_storage inline noexcept |
|
function |
data inline noexcept |
|
function |
data const inline noexcept |
mapped, N >¶
Defined in include/teeny/cuda.h:69
Inherits:
owning_storage< T, cuda_mapped_alloc >
List of all members¶
| Name | Kind | Owner |
|---|---|---|
p |
variable |
Inherited from owning_storage |
owning_storage |
function |
Inherited from owning_storage |
owning_storage |
function |
Inherited from owning_storage |
owning_storage |
function |
Inherited from owning_storage |
owning_storage |
function |
Inherited from owning_storage |
owning_storage |
function |
Inherited from owning_storage |
data |
function |
Inherited from owning_storage |
data |
function |
Inherited from owning_storage |
Inherited from owning_storage¶
| Kind | Name | Description |
|---|---|---|
variable |
p |
|
function |
owning_storage |
Defaulted constructor. |
function |
owning_storage inline explicit |
|
function |
owning_storage inline |
|
function |
owning_storage |
Deleted constructor. |
function |
owning_storage inline noexcept |
|
function |
data inline noexcept |
|
function |
data const inline noexcept |
mapped_view, N >¶
Defined in include/teeny/storage.h:168
Inherits:
ptr_storage< T >
List of all members¶
| Name | Kind | Owner |
|---|---|---|
p |
variable |
Inherited from ptr_storage |
ptr_storage |
function |
Inherited from ptr_storage |
ptr_storage |
function |
Inherited from ptr_storage |
data |
function |
Inherited from ptr_storage |
Inherited from ptr_storage¶
| Kind | Name | Description |
|---|---|---|
variable |
p |
|
function |
ptr_storage |
Defaulted constructor. |
function |
ptr_storage inline constexpr noexcept |
|
function |
data const inline constexpr noexcept |
pinned, N >¶
Defined in include/teeny/cuda.h:65
Inherits:
owning_storage< T, cuda_pinned_alloc >
List of all members¶
| Name | Kind | Owner |
|---|---|---|
p |
variable |
Inherited from owning_storage |
owning_storage |
function |
Inherited from owning_storage |
owning_storage |
function |
Inherited from owning_storage |
owning_storage |
function |
Inherited from owning_storage |
owning_storage |
function |
Inherited from owning_storage |
owning_storage |
function |
Inherited from owning_storage |
data |
function |
Inherited from owning_storage |
data |
function |
Inherited from owning_storage |
Inherited from owning_storage¶
| Kind | Name | Description |
|---|---|---|
variable |
p |
|
function |
owning_storage |
Defaulted constructor. |
function |
owning_storage inline explicit |
|
function |
owning_storage inline |
|
function |
owning_storage |
Deleted constructor. |
function |
owning_storage inline noexcept |
|
function |
data inline noexcept |
|
function |
data const inline noexcept |
pinned_view, N >¶
Defined in include/teeny/storage.h:167
Inherits:
ptr_storage< T >
List of all members¶
| Name | Kind | Owner |
|---|---|---|
p |
variable |
Inherited from ptr_storage |
ptr_storage |
function |
Inherited from ptr_storage |
ptr_storage |
function |
Inherited from ptr_storage |
data |
function |
Inherited from ptr_storage |
Inherited from ptr_storage¶
| Kind | Name | Description |
|---|---|---|
variable |
p |
|
function |
ptr_storage |
Defaulted constructor. |
function |
ptr_storage inline constexpr noexcept |
|
function |
data const inline constexpr noexcept |
stack, N >¶
Defined in include/teeny/storage.h:172
List of all members¶
| Name | Kind | Owner |
|---|---|---|
a |
variable |
Declared here |
storage_policy |
function |
Declared here |
storage_policy |
function |
Declared here |
data |
function |
Declared here |
data |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
array< T, N > |
a |
a¶
Defined in include/teeny/storage.h:173
Public Methods¶
| Return | Name | Description |
|---|---|---|
constexpr |
storage_policy inline constexpr noexcept |
|
storage_policy inline noexcept |
||
constexpr T * |
data inline constexpr noexcept |
|
constexpr const T * |
data const inline constexpr noexcept |
storage_policy¶
inline constexpr noexcept
Defined in include/teeny/storage.h:178
storage_policy¶
inline noexcept
Defined in include/teeny/storage.h:179
data¶
inline constexpr noexcept
Defined in include/teeny/storage.h:180
data¶
const inline constexpr noexcept
Defined in include/teeny/storage.h:181
view, N >¶
Defined in include/teeny/storage.h:165
Inherits:
ptr_storage< T >
List of all members¶
| Name | Kind | Owner |
|---|---|---|
p |
variable |
Inherited from ptr_storage |
ptr_storage |
function |
Inherited from ptr_storage |
ptr_storage |
function |
Inherited from ptr_storage |
data |
function |
Inherited from ptr_storage |
Inherited from ptr_storage¶
| Kind | Name | Description |
|---|---|---|
variable |
p |
|
function |
ptr_storage |
Defaulted constructor. |
function |
ptr_storage inline constexpr noexcept |
|
function |
data const inline constexpr noexcept |
storage_size¶
Defined in include/teeny/storage.h:192
Storage element count for a stack tensor (0 for view/owning).
List of all members¶
| Name | Kind | Owner |
|---|---|---|
value |
variable |
Declared here |
Public Static Attributes¶
| Return | Name | Description |
|---|---|---|
constexpr size_t |
value static constexpr |
value¶
static constexpr
Defined in include/teeny/storage.h:192
storage_size< Mapping, true >¶
Defined in include/teeny/storage.h:194
List of all members¶
| Name | Kind | Owner |
|---|---|---|
value |
variable |
Declared here |
Public Static Attributes¶
| Return | Name | Description |
|---|---|---|
constexpr size_t |
value static constexpr |
value¶
static constexpr
Defined in include/teeny/storage.h:195
strides¶
Defined in include/teeny/layout.h:82
An mdspan layout policy with per-dimension static or dynamic strides — the stride analogue of extents/shape.
ccontiguous/fcontiguous (mdspan layout_right/layout_left) give contiguous (extent-derived) strides; layout_stride stores every stride at run time. strides<S...> bakes the KNOWN strides into the type (folding to immediates) — including negative strides — while any dimension marked dynamic_stride is supplied at run time:
tensor<float, shape<3,4>, strides<4,1>>(ptr); // static, folds
tensor<float, shape<3,4>, strides<-4,1>>(ptr); // reversed rows
tensor<float, shape<-1,4>, strides<dynamic_stride,1>>(ptr, {n}); // outer stride runtime
sizeof its data. Only the dynamic strides are stored.
Note: CCCL's submdspan is only defined for the standard layouts, so it does not apply here — but teeny's own slicing/slice_along/permute/flip/ peel build their views by hand (no submdspan), so they all work on a strides<...> source and in fact fold their output strides the same way. And required_span_size assumes non-negative strides — negative strides are for VIEWS into existing storage, not owning allocation.
Template Parameters¶
SOne stride per dimension: a compile-time value (may be negative), ordynamic_stridefor a runtime stride.
List of all members¶
| Name | Kind | Owner |
|---|---|---|
N |
variable |
Declared here |
static_stride |
function |
Declared here |
ndyn |
function |
Declared here |
all_static |
function |
Declared here |
slot |
function |
Declared here |
Public Static Attributes¶
| Return | Name | Description |
|---|---|---|
constexpr size_t |
N static constexpr |
N¶
static constexpr
Defined in include/teeny/layout.h:83
Public Static Methods¶
| Return | Name | Description |
|---|---|---|
constexpr int64_t |
static_stride static inline constexpr noexcept |
The compile-time stride of dimension r–dynamic_stride when that dimension's stride is only known at run time. |
constexpr size_t |
ndyn static inline constexpr noexcept |
How many dimensions carry a runtime stride (== the mapping's stored size). |
constexpr bool |
all_static static inline constexpr noexcept |
|
constexpr size_t |
slot static inline constexpr noexcept |
static_stride¶
static inline constexpr noexcept
Defined in include/teeny/layout.h:125
The compile-time stride of dimension r–dynamic_stride when that dimension's stride is only known at run time.
(0 for a rank-0 strides<>, whose r is never a valid dimension.)
ndyn¶
static inline constexpr noexcept
Defined in include/teeny/layout.h:130
How many dimensions carry a runtime stride (== the mapping's stored size).
all_static¶
static inline constexpr noexcept
Defined in include/teeny/layout.h:133
slot¶
static inline constexpr noexcept
Defined in include/teeny/layout.h:135
mapping¶
Defined in include/teeny/layout.h:145
Inherits:
ndyn()>,Shape
List of all members¶
| Name | Kind | Owner |
|---|---|---|
mapping |
function |
Declared here |
mapping |
function |
Declared here |
mapping |
function |
Declared here |
extents |
function |
Declared here |
stride |
function |
Declared here |
operator() |
function |
Declared here |
required_span_size |
function |
Declared here |
is_unique |
function |
Declared here |
is_exhaustive |
function |
Declared here |
is_strided |
function |
Declared here |
is_always_unique |
function |
Declared here |
is_always_exhaustive |
function |
Declared here |
is_always_strided |
function |
Declared here |
extents_type |
typedef |
Declared here |
index_type |
typedef |
Declared here |
rank_type |
typedef |
Declared here |
layout_type |
typedef |
Declared here |
Public Methods¶
| Return | Name | Description |
|---|---|---|
mapping |
Defaulted constructor. | |
constexpr |
mapping inline constexpr |
Fully-static strides: construct from extents only. |
constexpr |
mapping inline constexpr |
Mixed strides: extents + the runtime strides (dim order, dynamic ones only). |
constexpr const Shape & |
extents const inline constexpr noexcept |
|
constexpr index_type |
stride const inline constexpr noexcept |
|
constexpr index_type |
operator() const inline constexpr noexcept |
|
constexpr index_type |
required_span_size const inline constexpr noexcept |
|
constexpr bool |
is_unique const inline constexpr noexcept |
|
constexpr bool |
is_exhaustive const inline constexpr noexcept |
|
constexpr bool |
is_strided const inline constexpr noexcept |
mapping¶
Defined in include/teeny/layout.h:153
Defaulted constructor.
mapping¶
inline constexpr
template<size_t M = strides::ndyn(), enable_if_t< M==0, int > = 0> constexpr inline constexpr mapping(const Shape & e)
Defined in include/teeny/layout.h:157
Fully-static strides: construct from extents only.
mapping¶
inline constexpr
template<class OtherIdx> constexpr inline constexpr mapping(const Shape & e, const array< OtherIdx, strides::ndyn()> & dyn)
Defined in include/teeny/layout.h:174
Mixed strides: extents + the runtime strides (dim order, dynamic ones only).
Templated on the array's element type so a reindex (narrowing the offset index width) can pass its wider source strides — each is cast to index_type; symmetric with mdspan's layout_stride.
extents¶
const inline constexpr noexcept
Defined in include/teeny/layout.h:177
stride¶
const inline constexpr noexcept
Defined in include/teeny/layout.h:178
operator()¶
const inline constexpr noexcept
Defined in include/teeny/layout.h:183
required_span_size¶
const inline constexpr noexcept
Defined in include/teeny/layout.h:194
is_unique¶
const inline constexpr noexcept
Defined in include/teeny/layout.h:205
is_exhaustive¶
const inline constexpr noexcept
Defined in include/teeny/layout.h:206
is_strided¶
const inline constexpr noexcept
Defined in include/teeny/layout.h:207
Public Static Methods¶
| Return | Name | Description |
|---|---|---|
constexpr bool |
is_always_unique static inline constexpr noexcept |
|
constexpr bool |
is_always_exhaustive static inline constexpr noexcept |
|
constexpr bool |
is_always_strided static inline constexpr noexcept |
is_always_unique¶
static inline constexpr noexcept
Defined in include/teeny/layout.h:202
is_always_exhaustive¶
static inline constexpr noexcept
Defined in include/teeny/layout.h:203
is_always_strided¶
static inline constexpr noexcept
Defined in include/teeny/layout.h:204
Public Types¶
| Name | Description |
|---|---|
extents_type |
|
index_type |
|
rank_type |
|
layout_type |
extents_type¶
Defined in include/teeny/layout.h:146
index_type¶
Defined in include/teeny/layout.h:147
rank_type¶
Defined in include/teeny/layout.h:148
layout_type¶
Defined in include/teeny/layout.h:149
tensor¶
Defined in include/teeny/tensor.h:586
Inherits:
template mapping< Shape >
One N-dimensional tensor, parameterised by ownership.
The layout / extents / offset mapping is delegated to cuda::std::mdspan (the mapping lives in an empty base, so a fully-static tensor is exactly the size of its data). Ownership is a policy: [storage::view](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a1bda80f2be4d3658e0baa43fbe7ae8c1) (non-owning, trivially copyable, kernel-passable), [storage::stack](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508afac2a47adace059aff113283a03f6760) (inline storage, static shape), [storage::heap](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a4d4a9aa362b6ffe089fd2e992ccf4f5f) (host-only, move-only), the CUDA owners [storage::gpu](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a0aa0be2a866411d9ff03515227454947)/pinned/mapped (from [cuda.h](#cudah)), and the space-carrying views [storage::gpu_view](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a716b431c57855c3a30f4c286ad4f0299)/pinned_view/ mapped_view (a view of device / page-locked memory keeps its space). The tensor's copy/move semantics are induced by the storage member, not hand-written.
Template Parameters¶
-
TElement type. -
ShapeThe shape: anycuda::std::extents<Idx, E...>(static or dynamic per dim). Spell it with theshape<...>alias. -
Layoutmdspan layout policy (defaultccontiguous). -
OOwnership kind (default[storage::view](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a1bda80f2be4d3658e0baa43fbe7ae8c1)).
List of all members¶
| Name | Kind | Owner |
|---|---|---|
store_ |
variable |
Declared here |
tensor |
function |
Declared here |
tensor |
function |
Declared here |
tensor |
function |
Declared here |
tensor |
function |
Declared here |
tensor |
function |
Declared here |
tensor |
function |
Declared here |
tensor |
function |
Declared here |
tensor |
function |
Declared here |
tensor |
function |
Declared here |
tensor |
function |
Declared here |
mapping |
function |
Declared here |
extents |
function |
Declared here |
extent |
function |
Declared here |
extent |
function |
Declared here |
shape |
function |
Declared here |
shape |
function |
Declared here |
strides |
function |
Declared here |
stride |
function |
Declared here |
stride |
function |
Declared here |
numel |
function |
Declared here |
is_dense |
function |
Declared here |
is_dense |
function |
Declared here |
is_dense |
function |
Declared here |
is_contiguous |
function |
Declared here |
is_contiguous |
function |
Declared here |
data |
function |
Declared here |
data |
function |
Declared here |
mdspan |
function |
Declared here |
mdspan |
function |
Declared here |
view |
function |
Declared here |
view |
function |
Declared here |
operator() |
function |
Declared here |
operator() |
function |
Declared here |
at |
function |
Declared here |
at |
function |
Declared here |
operator() |
function |
Declared here |
operator() |
function |
Declared here |
uget |
function |
Declared here |
uget |
function |
Declared here |
uget |
function |
Declared here |
uget |
function |
Declared here |
uget |
function |
Declared here |
uget |
function |
Declared here |
uat |
function |
Declared here |
uat |
function |
Declared here |
operator() |
function |
Declared here |
operator() |
function |
Declared here |
operator() |
function |
Declared here |
operator() |
function |
Declared here |
at |
function |
Declared here |
at |
function |
Declared here |
uget |
function |
Declared here |
uget |
function |
Declared here |
uat |
function |
Declared here |
uat |
function |
Declared here |
operator T |
function |
Declared here |
item |
function |
Declared here |
slice_along |
function |
Declared here |
slice_along |
function |
Declared here |
slice_along |
function |
Declared here |
slice_along |
function |
Declared here |
subsample |
function |
Declared here |
subsample |
function |
Declared here |
subsample |
function |
Declared here |
subsample |
function |
Declared here |
unfold |
function |
Declared here |
unfold |
function |
Declared here |
unfold |
function |
Declared here |
unfold |
function |
Declared here |
index_select |
function |
Declared here |
index_select |
function |
Declared here |
index_select |
function |
Declared here |
index_select |
function |
Declared here |
permute |
function |
Declared here |
permute |
function |
Declared here |
flip |
function |
Declared here |
flip |
function |
Declared here |
flip |
function |
Declared here |
flip |
function |
Declared here |
clone |
function |
Declared here |
to |
function |
Declared here |
to |
function |
Declared here |
to |
function |
Declared here |
to |
function |
Declared here |
to |
function |
Declared here |
to |
function |
Declared here |
reshape |
function |
Declared here |
reshape |
function |
Declared here |
can_reshape_without_copy |
function |
Declared here |
recast |
function |
Declared here |
recast |
function |
Declared here |
index_fits |
function |
Declared here |
reindex |
function |
Declared here |
reindex |
function |
Declared here |
flatten |
function |
Declared here |
flatten |
function |
Declared here |
unsqueeze |
function |
Declared here |
unsqueeze |
function |
Declared here |
unsqueeze |
function |
Declared here |
unsqueeze |
function |
Declared here |
squeeze |
function |
Declared here |
squeeze |
function |
Declared here |
squeeze |
function |
Declared here |
squeeze |
function |
Declared here |
flip |
function |
Declared here |
flip |
function |
Declared here |
squeeze |
function |
Declared here |
squeeze |
function |
Declared here |
unsqueeze |
function |
Declared here |
unsqueeze |
function |
Declared here |
permute |
function |
Declared here |
permute |
function |
Declared here |
squeeze |
function |
Declared here |
squeeze |
function |
Declared here |
unsqueeze |
function |
Declared here |
unsqueeze |
function |
Declared here |
flip |
function |
Declared here |
flip |
function |
Declared here |
permute |
function |
Declared here |
permute |
function |
Declared here |
reshape |
function |
Declared here |
reshape |
function |
Declared here |
recast |
function |
Declared here |
recast |
function |
Declared here |
recast |
function |
Declared here |
recast |
function |
Declared here |
add_ |
function |
Declared here |
sub_ |
function |
Declared here |
mul_ |
function |
Declared here |
div_ |
function |
Declared here |
add_ |
function |
Declared here |
sub_ |
function |
Declared here |
mul_ |
function |
Declared here |
div_ |
function |
Declared here |
minimum_ |
function |
Declared here |
maximum_ |
function |
Declared here |
minimum_ |
function |
Declared here |
maximum_ |
function |
Declared here |
add_ |
function |
Declared here |
sub_ |
function |
Declared here |
atomic_add_ |
function |
Declared here |
atomic_sub_ |
function |
Declared here |
atomic_add_ |
function |
Declared here |
atomic_sub_ |
function |
Declared here |
operator+= |
function |
Declared here |
operator-= |
function |
Declared here |
operator*= |
function |
Declared here |
operator/= |
function |
Declared here |
copy_ |
function |
Declared here |
fill_ |
function |
Declared here |
zero_ |
function |
Declared here |
iota_ |
function |
Declared here |
add |
function |
Declared here |
sub |
function |
Declared here |
mul |
function |
Declared here |
div |
function |
Declared here |
pow |
function |
Declared here |
add |
function |
Declared here |
sub |
function |
Declared here |
mul |
function |
Declared here |
div |
function |
Declared here |
pow |
function |
Declared here |
add |
function |
Declared here |
sub |
function |
Declared here |
add |
function |
Declared here |
sub |
function |
Declared here |
maximum |
function |
Declared here |
minimum |
function |
Declared here |
maximum |
function |
Declared here |
clamp |
function |
Declared here |
clamp |
function |
Declared here |
normalize |
function |
Declared here |
normalize |
function |
Declared here |
normalize |
function |
Declared here |
normalize |
function |
Declared here |
normalize |
function |
Declared here |
normalize |
function |
Declared here |
normalize |
function |
Declared here |
normalize |
function |
Declared here |
normalize |
function |
Declared here |
normalize |
function |
Declared here |
cross |
function |
Declared here |
cross |
function |
Declared here |
map_ |
function |
Declared here |
zip_with_ |
function |
Declared here |
map |
function |
Declared here |
map |
function |
Declared here |
all |
function |
Declared here |
any |
function |
Declared here |
dot |
function |
Declared here |
dot |
function |
Declared here |
sqdist |
function |
Declared here |
sqdist |
function |
Declared here |
dist |
function |
Declared here |
dist |
function |
Declared here |
allclose |
function |
Declared here |
allclose |
function |
Declared here |
allclose |
function |
Declared here |
allclose |
function |
Declared here |
neg_ |
function |
Declared here |
abs_ |
function |
Declared here |
exp_ |
function |
Declared here |
log_ |
function |
Declared here |
sin_ |
function |
Declared here |
cos_ |
function |
Declared here |
sqrt_ |
function |
Declared here |
tanh_ |
function |
Declared here |
floor_ |
function |
Declared here |
ceil_ |
function |
Declared here |
round_ |
function |
Declared here |
trunc_ |
function |
Declared here |
sign_ |
function |
Declared here |
pow_ |
function |
Declared here |
clamp_ |
function |
Declared here |
normalize_ |
function |
Declared here |
normalize_ |
function |
Declared here |
cross_ |
function |
Declared here |
operator++ |
function |
Declared here |
operator-- |
function |
Declared here |
operator++ |
function |
Declared here |
operator-- |
function |
Declared here |
add_ |
function |
Declared here |
sub_ |
function |
Declared here |
mul_ |
function |
Declared here |
div_ |
function |
Declared here |
add_ |
function |
Declared here |
sub_ |
function |
Declared here |
minimum_ |
function |
Declared here |
maximum_ |
function |
Declared here |
add_ |
function |
Declared here |
sub_ |
function |
Declared here |
atomic_add_ |
function |
Declared here |
atomic_sub_ |
function |
Declared here |
copy_ |
function |
Declared here |
map_ |
function |
Declared here |
zip_with_ |
function |
Declared here |
cross_ |
function |
Declared here |
normalize_ |
function |
Declared here |
minimum |
function |
Declared here |
ownership |
variable |
Declared here |
is_static |
variable |
Declared here |
is_view |
variable |
Declared here |
is_owning |
variable |
Declared here |
is_device |
variable |
Declared here |
is_host_accessible |
variable |
Declared here |
buffer_size |
variable |
Declared here |
is_strides_layout |
variable |
Declared here |
is_contiguous_layout |
variable |
Declared here |
rank |
function |
Declared here |
element_type |
typedef |
Declared here |
extents_type |
typedef |
Declared here |
shape_type |
typedef |
Declared here |
layout_type |
typedef |
Declared here |
index_type |
typedef |
Declared here |
mapping_type |
typedef |
Declared here |
view_type |
typedef |
Declared here |
const_view_type |
typedef |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
storage_policy< T, O, buffer_size > |
store_ |
store_¶
Defined in include/teeny/tensor.h:606
Public Methods¶
| Return | Name | Description |
|---|---|---|
tensor |
Defaulted constructor. | |
tensor |
Defaulted constructor. | |
tensor |
Defaulted constructor. | |
tensor inline |
View constructor: wrap p with the given mapping. |
|
tensor inline explicit |
View constructor from a pointer alone — for a fully-static geometry (static extents AND a fully determined layout: contiguous, or an all-static strides<...>). |
|
tensor inline |
View constructor from a pointer + extents (contiguous / static-stride layouts). | |
tensor inline explicit |
Owning constructor: allocate storage for m (heap/device/host/pinned). |
|
tensor inline explicit |
Owning constructor from extents (contiguous / static-stride layouts). | |
tensor inline explicit |
UNINITIALISED constructors (numpy np.empty) used by [empty()](#empty): the buffer is left indeterminate — fill before reading. |
|
tensor inline |
||
constexpr const mapping_type & |
mapping const inline constexpr noexcept |
|
constexpr const Shape & |
extents const inline constexpr noexcept |
|
constexpr auto |
extent const inline constexpr noexcept |
Extent of an axis given by a STATIC index (extent(Int<0>())): a compile-time integral_constant when that extent is static, else a runtime index_type. |
constexpr index_type |
extent const inline constexpr noexcept |
Extent of an axis given by a RUNTIME index (extent(0)). |
constexpr auto |
shape const inline constexpr noexcept |
[shape()](#shape) — the extents as an array-like accessor: [shape()](#shape)[Int<k>()] folds to a compile-time value where static, [shape()](#shape)[i] (runtime) is a value, and it converts to the raw extents() for interop. |
constexpr auto |
shape const inline constexpr noexcept |
|
constexpr auto |
strides const inline constexpr noexcept |
strides() — the strides as an array-like accessor (twin of [shape()](#shape)): strides()[Int<k>()] folds where the layout makes the stride derivable, strides()[i] (runtime) is a value. |
constexpr auto |
stride const inline constexpr noexcept |
Stride of an axis given by a STATIC index (stride(Int<0>())): a compile-time integral_constant when known statically (static- stride layout; a contiguous layout over static extents; or the always-unit stride of a contiguous layout even for dynamic shapes). |
constexpr index_type |
stride const inline constexpr noexcept |
Stride of an axis given by a RUNTIME index (stride(0)). |
constexpr auto |
numel const inline constexpr noexcept |
Number of elements. |
constexpr bool |
is_dense const inline constexpr noexcept |
Whether the elements occupy a dense block of memory, in some axis order — true for a C- or F-contiguous tensor, and also for a permuted one (a permuted C-contiguous view still packs the same memory densely). |
bool |
is_dense const inline noexcept |
Exact denseness in layout L (e.g. |
bool |
is_dense const inline noexcept |
|
bool |
is_contiguous const inline noexcept |
Whether the elements are contiguous in a specific order — C-order by default (numpy/pytorch's is_contiguous), or F-order via is_contiguous<fcontiguous>(). |
bool |
is_contiguous const inline noexcept |
|
T * |
data inline noexcept |
|
const T * |
data const inline noexcept |
|
view_type |
mdspan inline noexcept |
The raw cuda::std::mdspan over this tensor's storage. |
const_view_type |
mdspan const inline noexcept |
|
auto |
view inline noexcept |
A non-owning teeny view of this tensor's storage — a view (or gpu_view, for a device tensor) that aliases the same memory (no copy), keeping the source layout. |
auto |
view const inline noexcept |
|
T & |
operator() inline noexcept |
Element access when every argument is an integer (negatives wrap). |
const T & |
operator() const inline noexcept |
|
auto |
at inline noexcept |
at(i...) — a single element as a rank-0 VIEW (all-integer args; negatives wrap). |
auto |
at const inline noexcept |
|
auto |
operator() inline noexcept |
Sub-view when any argument is a slice (all, slice(a,b[,step])) or a bare none (numpy newaxis). |
auto |
operator() const inline noexcept |
|
T & |
uget inline noexcept |
|
const T & |
uget const inline noexcept |
|
auto |
uget inline noexcept |
|
auto |
uget const inline noexcept |
|
decltype(auto) |
uget inline noexcept |
|
decltype(auto) |
uget const inline noexcept |
|
auto |
uat inline noexcept |
Unchecked at: a single element as a rank-0 VIEW, no negative wrap. |
auto |
uat const inline noexcept |
|
decltype(auto) |
operator() inline noexcept |
Ellipsis form: exactly one ellipsis in the args expands to rank - (#other args) copies of all, then the call re-runs — so t(1, ellipsis, 2) on rank 5 is t(1, all, all, all, 2). |
decltype(auto) |
operator() const inline noexcept |
|
decltype(auto) |
operator() inline noexcept |
Tuple-unpack form — t(m) where m is a single tuple-like index pack (a cuda::std::array or cuda::std::tuple) holding the WHOLE index list: exactly numpy's x[(a, b, c)] == x[a, b, c]. |
decltype(auto) |
operator() const inline noexcept |
|
decltype(auto) |
at inline noexcept |
Tuple-unpack at: t.at(m) == t.at(m[0], m[1], ...) — the element as a rank-0 VIEW. |
decltype(auto) |
at const inline noexcept |
|
decltype(auto) |
uget inline noexcept |
Tuple-unpack uget / uat: the unchecked twins (no negative-index wrap), same unpack, same result types as the checked forms. |
decltype(auto) |
uget const inline noexcept |
|
decltype(auto) |
uat inline noexcept |
|
decltype(auto) |
uat const inline noexcept |
|
operator T const inline noexcept |
||
T |
item const inline noexcept |
The single element of a rank-0 tensor (explicit reader). |
auto |
slice_along inline noexcept |
Index/slice one or more named axes; other axes are kept. |
auto |
slice_along const inline noexcept |
|
auto |
slice_along inline noexcept |
Value form: t.slice_along(axis<0,2>{}, i, slice(1,4)) == t.slice_along<0,2>(i, slice(1,4)). |
auto |
slice_along const inline noexcept |
|
auto |
subsample inline noexcept |
Subsample a coloured/strided sub-lattice: bind named axes to a slice(start,none,k) each, sharing one STEP k across all of them but taking a separate START per axis — sugar for slice_along (#258), for the "every k-th voxel, offset per axis" pattern coloured Gauss-Seidel relaxation needs (loc[d] % k == digit_d(n)). |
auto |
subsample const inline noexcept |
|
auto |
subsample inline noexcept |
Value form: t.subsample(axis<0,1>{}, k, s0, s1) == t.subsample<0,1>(k, s0, s1) — leading axis<...> selector, same placement as slice_along's own value form (a second variadic pack, the starts, needs the disambiguating tag up front rather than trailing). |
auto |
subsample const inline noexcept |
|
auto |
unfold inline noexcept |
Sliding/strided window along axis Axis (pytorch Tensor.unfold): appends a NEW trailing axis of width size, stepped by step along Axis -> a rank-(N+1) view. |
auto |
unfold const inline noexcept |
|
auto |
unfold inline noexcept |
Value form: t.unfold(Int<0>(), K, s) == t.unfold<0>(K, s) — a single-axis selector (like flip/squeeze/unsqueeze's own Int<k>() twin), so no .template is needed on a dependent receiver. |
auto |
unfold const inline noexcept |
|
auto |
index_select const inline |
|
decltype(auto) |
index_select const inline |
Value form + trailing keyword bag: t.index_select(idx, axis<Axis>{}) == t.index_select<Axis>(idx), and t.index_select(idx, axis<Axis>{}, into(dest)) == t.index_select<Axis>(idx, into(dest)). |
decltype(auto) |
index_select const inline |
|
auto & |
index_select const inline |
into(dest) form: writes the gather straight into dest — one pass, no allocation, _TNY_API (device-safe). |
auto |
permute inline noexcept |
Reorder the axes (a permutation of 0..N-1; negatives wrap) -> a rank-N view. |
auto |
permute const inline noexcept |
|
auto |
flip inline noexcept |
Reverse axis Ax (negatives wrap) -> a view (numpy flip). |
auto |
flip const inline noexcept |
|
auto |
flip inline noexcept |
Reverse SEVERAL axes at once (numpy flip(a, axis=(...))) -> a rank-N view. |
auto |
flip const inline noexcept |
|
auto |
clone const inline |
|
auto |
to const inline & |
pytorch-like .to<T2>(): convert the element type to T2. |
auto |
to const inline & |
|
auto |
to const inline && |
|
auto |
to const inline && |
|
auto |
to const inline & |
|
auto |
to const inline && |
|
auto |
reshape inline noexcept |
View this tensor as a new shape — numpy semantics: a VIEW whenever the layout can be regrouped without a copy (not only when C-contiguous; a strided/permuted source often still views — split a contiguous axis, merge a contiguous run). |
auto |
reshape const inline noexcept |
|
bool |
can_reshape_without_copy const inline noexcept |
Whether reshape<NewExt...>() can produce a VIEW (no copy) of this tensor's actual layout — numpy's rule: not just C-contiguity, but any stride-compatible regrouping (splitting an axis, merging a contiguous run). |
auto |
recast inline |
Reinterpret with a MORE-STATIC extents type of the same rank — recover statically-known inner dims at the dynamic (ndarray) boundary: a runtime (n,3,3) view -> .recast<shape<-1,3,3>>() so the 3s (extents) fold. |
auto |
recast const inline |
|
bool |
index_fits const inline noexcept |
Can this view be re-expressed with the index type Idx2 — i.e. |
auto |
reindex inline |
No-copy, layout-preserving retype of the offset index width to Idx2: same pointer, same layout KIND, the extents' index_type and any dynamic strides narrowed to Idx2 (a strides<...> literal pack is unchanged). |
auto |
reindex const inline |
|
auto |
flatten inline noexcept |
View as 1-D (ravel) — a VIEW whenever the layout is mergeable into a single contiguous run without a copy (numpy semantics; [clone()](#clone) first otherwise). |
auto |
flatten const inline noexcept |
|
auto |
unsqueeze inline noexcept |
Insert a size-1 axis at position Ax (numpy newaxis/unsqueeze) -> a rank-(N+1) view. |
auto |
unsqueeze const inline noexcept |
|
auto |
unsqueeze inline noexcept |
Insert size-1 axes at SEVERAL positions at once (numpy expand_dims(a, axis=(...))) -> a rank-(N+k) view. |
auto |
unsqueeze const inline noexcept |
|
auto |
squeeze inline noexcept |
Drop a size-1 axis Ax (negatives wrap) -> a rank-(N-1) view. |
auto |
squeeze const inline noexcept |
|
auto |
squeeze inline noexcept |
Drop SEVERAL size-1 axes at once (numpy squeeze(axis=(...))) -> a rank-(N-k) view. |
auto |
squeeze const inline noexcept |
|
auto |
flip inline noexcept |
|
auto |
flip const inline noexcept |
|
auto |
squeeze inline noexcept |
|
auto |
squeeze const inline noexcept |
|
auto |
unsqueeze inline noexcept |
|
auto |
unsqueeze const inline noexcept |
|
auto |
permute inline noexcept |
|
auto |
permute const inline noexcept |
|
auto |
squeeze inline noexcept |
Value form: t.squeeze(axis<0,2>{}) == t.squeeze<0,2>(), likewise unsqueeze/flip/permute. |
auto |
squeeze const inline noexcept |
|
auto |
unsqueeze inline noexcept |
|
auto |
unsqueeze const inline noexcept |
|
auto |
flip inline noexcept |
|
auto |
flip const inline noexcept |
|
auto |
permute inline noexcept |
|
auto |
permute const inline noexcept |
|
auto |
reshape inline noexcept |
|
auto |
reshape const inline noexcept |
|
auto |
recast inline |
|
auto |
recast const inline |
|
auto |
recast inline |
|
auto |
recast const inline |
|
tensor & |
add_ |
|
tensor & |
sub_ |
|
tensor & |
mul_ |
|
tensor & |
div_ |
|
tensor & |
add_ |
|
tensor & |
sub_ |
|
tensor & |
mul_ |
|
tensor & |
div_ |
|
tensor & |
minimum_ |
|
tensor & |
maximum_ |
|
tensor & |
minimum_ |
|
tensor & |
maximum_ |
|
tensor & |
add_ |
|
tensor & |
sub_ |
|
tensor & |
atomic_add_ |
|
tensor & |
atomic_sub_ |
|
tensor & |
atomic_add_ |
|
tensor & |
atomic_sub_ |
|
tensor & |
operator+= inline |
|
tensor & |
operator-= inline |
|
tensor & |
operator*= inline |
|
tensor & |
operator/= inline |
|
tensor & |
copy_ |
|
tensor & |
fill_ |
|
tensor & |
zero_ |
|
tensor & |
iota_ |
|
auto |
add const |
|
auto |
sub const |
|
auto |
mul const |
|
auto |
div const |
|
auto |
pow const |
|
auto & |
add const |
|
auto & |
sub const |
|
auto & |
mul const |
|
auto & |
div const |
|
auto & |
pow const |
|
auto |
add const |
|
auto |
sub const |
|
auto & |
add const |
|
auto & |
sub const |
|
auto |
maximum const |
|
auto & |
minimum const |
|
auto & |
maximum const |
|
auto |
clamp const |
|
auto & |
clamp const |
|
auto |
normalize const |
|
auto & |
normalize const |
|
auto |
normalize const |
|
auto |
normalize const |
|
auto |
normalize const |
|
auto |
normalize const |
|
auto & |
normalize const |
|
auto & |
normalize const |
|
auto & |
normalize const |
|
auto & |
normalize const |
|
auto |
cross const |
|
auto & |
cross const |
|
tensor & |
map_ |
|
tensor & |
zip_with_ |
|
auto |
map const |
|
auto & |
map const |
|
bool |
all const |
|
bool |
any const |
|
class Eb class Lb storage Ob auto |
dot const |
|
decltype(auto) |
dot const |
|
auto |
sqdist const |
|
decltype(auto) |
sqdist const |
|
auto |
dist const |
|
decltype(auto) |
dist const |
|
bool |
allclose const |
|
decltype(auto) |
allclose const |
|
decltype(auto) |
allclose const |
|
decltype(auto) |
allclose const |
|
tensor & |
neg_ |
|
tensor & |
abs_ |
|
tensor & |
exp_ |
|
tensor & |
log_ |
|
tensor & |
sin_ |
|
tensor & |
cos_ |
|
tensor & |
sqrt_ |
|
tensor & |
tanh_ |
|
tensor & |
floor_ |
|
tensor & |
ceil_ |
|
tensor & |
round_ |
|
tensor & |
trunc_ |
|
tensor & |
sign_ |
|
tensor & |
pow_ |
|
tensor & |
clamp_ |
|
tensor & |
normalize_ |
|
tensor & |
normalize_ |
|
tensor & |
cross_ |
|
tensor & |
operator++ inline |
|
tensor & |
operator-- inline |
|
tensor< T, Shape, ccontiguous, storage::stack > |
operator++ inline |
|
tensor< T, Shape, ccontiguous, storage::stack > |
operator-- inline |
|
tensor< T, E, L, O > & |
add_ |
|
tensor< T, E, L, O > & |
sub_ |
|
tensor< T, E, L, O > & |
mul_ |
|
tensor< T, E, L, O > & |
div_ |
|
tensor< T, E, L, O > & |
add_ |
|
tensor< T, E, L, O > & |
sub_ |
|
tensor< T, E, L, O > & |
minimum_ |
|
tensor< T, E, L, O > & |
maximum_ |
|
tensor< T, E, L, O > & |
add_ |
|
tensor< T, E, L, O > & |
sub_ |
|
tensor< T, E, L, O > & |
atomic_add_ |
|
tensor< T, E, L, O > & |
atomic_sub_ |
|
tensor< T, E, L, O > & |
copy_ |
|
tensor< T, E, L, O > & |
map_ |
|
tensor< T, E, L, O > & |
zip_with_ |
|
tensor< T, E, L, O > & |
cross_ |
|
tensor< T, E, L, O > & |
normalize_ |
|
u_abs u_log u_cos u_tanh u_ceil u_trunc auto |
minimum const |
tensor¶
Defined in include/teeny/tensor.h:609
Defaulted constructor.
tensor¶
Defined in include/teeny/tensor.h:615
Defaulted constructor.
tensor¶
Defined in include/teeny/tensor.h:616
Defaulted constructor.
tensor¶
inline
template<storage OO = O, enable_if_t< storage_is_view(OO), int > = 0> inline tensor(T * p, mapping_type m)
Defined in include/teeny/tensor.h:620
View constructor: wrap p with the given mapping.
tensor¶
inline explicit
template<storage OO = O, enable_if_t< storage_is_view(OO) &&is_static &&(_contiguous_layout< Layout >::value||_strides_all_static< Layout >::value), int > = 0> inline explicit tensor(T * p)
Defined in include/teeny/tensor.h:627
View constructor from a pointer alone — for a fully-static geometry (static extents AND a fully determined layout: contiguous, or an all-static strides<...>).
e.g. tensor<float, shape<3,4>, strides<4,1>>(ptr).
tensor¶
inline
template<storage OO = O, enable_if_t< storage_is_view(OO) &&is_constructible< mapping_type, Shape >::value, int > = 0> inline tensor(T * p, Shape e)
Defined in include/teeny/tensor.h:631
View constructor from a pointer + extents (contiguous / static-stride layouts).
tensor¶
inline explicit
template<storage OO = O, enable_if_t< storage_is_owning(OO), int > = 0> inline explicit tensor(mapping_type m)
Defined in include/teeny/tensor.h:643
Owning constructor: allocate storage for m (heap/device/host/pinned).
tensor¶
inline explicit
template<storage OO = O, enable_if_t< storage_is_owning(OO) &&is_constructible< mapping_type, Shape >::value, int > = 0> inline explicit tensor(Shape e)
Defined in include/teeny/tensor.h:648
Owning constructor from extents (contiguous / static-stride layouts).
tensor¶
inline explicit
template<storage OO = O, enable_if_t< OO==storage::stack, int > = 0> inline explicit tensor(_uninit_t)
Defined in include/teeny/tensor.h:655
UNINITIALISED constructors (numpy np.empty) used by [empty()](#empty): the buffer is left indeterminate — fill before reading.
local<...>{} and zeros(...) keep their zero-fill; this is the opt-out.
tensor¶
inline
template<storage OO = O, enable_if_t< storage_is_owning(OO) &&is_constructible< mapping_type, Shape >::value, int > = 0> inline tensor(Shape e, _uninit_t)
Defined in include/teeny/tensor.h:657
mapping¶
const inline constexpr noexcept
Defined in include/teeny/tensor.h:661
extents¶
const inline constexpr noexcept
Defined in include/teeny/tensor.h:662
extent¶
const inline constexpr noexcept
template<class Idx, enable_if_t< _is_ic< Idx >::value, int > = 0> constexpr inline constexpr auto extent(Idx) const noexcept
Defined in include/teeny/tensor.h:670
Extent of an axis given by a STATIC index (extent(Int<0>())): a compile-time integral_constant when that extent is static, else a runtime index_type.
extent¶
const inline constexpr noexcept
template<class Idx, enable_if_t<!_is_ic< Idx >::value, int > = 0> constexpr inline constexpr index_type extent(Idx d) const noexcept
Defined in include/teeny/tensor.h:674
Extent of an axis given by a RUNTIME index (extent(0)).
shape¶
const inline constexpr noexcept
Defined in include/teeny/tensor.h:681
[shape()](#shape) — the extents as an array-like accessor: [shape()](#shape)[Int<k>()] folds to a compile-time value where static, [shape()](#shape)[i] (runtime) is a value, and it converts to the raw extents() for interop.
[shape(d)](#shape) is the per-axis shorthand (== extent(d)).
shape¶
const inline constexpr noexcept
Defined in include/teeny/tensor.h:682
strides¶
const inline constexpr noexcept
Defined in include/teeny/tensor.h:686
strides() — the strides as an array-like accessor (twin of [shape()](#shape)): strides()[Int<k>()] folds where the layout makes the stride derivable, strides()[i] (runtime) is a value.
strides(d) == stride(d).
stride¶
const inline constexpr noexcept
template<class Idx, enable_if_t< _is_ic< Idx >::value, int > = 0> constexpr inline constexpr auto stride(Idx) const noexcept
Defined in include/teeny/tensor.h:693
Stride of an axis given by a STATIC index (stride(Int<0>())): a compile-time integral_constant when known statically (static- stride layout; a contiguous layout over static extents; or the always-unit stride of a contiguous layout even for dynamic shapes).
stride¶
const inline constexpr noexcept
template<class Idx, enable_if_t<!_is_ic< Idx >::value, int > = 0> constexpr inline constexpr index_type stride(Idx d) const noexcept
Defined in include/teeny/tensor.h:697
Stride of an axis given by a RUNTIME index (stride(0)).
numel¶
const inline constexpr noexcept
Defined in include/teeny/tensor.h:715
Number of elements.
A fully static shape folds to an integral_constant (so it propagates into later compile-time arithmetic, like extent(Int<k>())); any dynamic dim -> a runtime index_type.
is_dense¶
const inline constexpr noexcept
Defined in include/teeny/tensor.h:736
Whether the elements occupy a dense block of memory, in some axis order — true for a C- or F-contiguous tensor, and also for a permuted one (a permuted C-contiguous view still packs the same memory densely).
Formally: the strides are a permutation of a dense nested packing (1, e0, e0·e1, ...). Size-1 axes are ignored (their stride is unconstrained); an empty tensor is trivially dense. Negative strides (flips) are not dense in this sense -> false.
Pass a layout for an exact check: is_dense<ccontiguous>() / is_dense<fcontiguous>() test C-/F-contiguity specifically (or any layout whose mapping is derivable from the extents). For the C-order question specifically, [is_contiguous()](#is_contiguous) (below) reads clearer.
is_dense¶
const inline noexcept
Defined in include/teeny/tensor.h:763
Exact denseness in layout L (e.g.
ccontiguous/fcontiguous): the actual strides equal what L produces for these extents. Two spellings — t.is_dense<ccontiguous>() (type form) and t.is_dense(ccontiguous()) (value form, layout deduced from the argument).
is_dense¶
const inline noexcept
Defined in include/teeny/tensor.h:774
is_contiguous¶
const inline noexcept
Defined in include/teeny/tensor.h:782
Whether the elements are contiguous in a specific order — C-order by default (numpy/pytorch's is_contiguous), or F-order via is_contiguous<fcontiguous>().
A thin alias of is_dense<Layout>(); this (not [is_dense()](#is_dense)) is what reshape/flatten need. Value form: is_contiguous(ccontiguous{}).
is_contiguous¶
const inline noexcept
Defined in include/teeny/tensor.h:784
data¶
inline noexcept
Defined in include/teeny/tensor.h:787
data¶
const inline noexcept
Defined in include/teeny/tensor.h:788
mdspan¶
inline noexcept
Defined in include/teeny/tensor.h:790
The raw cuda::std::mdspan over this tensor's storage.
mdspan¶
const inline noexcept
Defined in include/teeny/tensor.h:791
view¶
inline noexcept
Defined in include/teeny/tensor.h:798
A non-owning teeny view of this tensor's storage — a view (or gpu_view, for a device tensor) that aliases the same memory (no copy), keeping the source layout.
On an already-non-owning tensor it re-wraps the same pointer (an equivalent view). For the raw mdspan, use [mdspan()](#mdspan).
view¶
const inline noexcept
Defined in include/teeny/tensor.h:799
operator()¶
inline noexcept
template<class... Args, enable_if_t< _all_index< Args... >::value, int > = 0> inline T & operator()(Args... a) noexcept
Defined in include/teeny/tensor.h:1028
Element access when every argument is an integer (negatives wrap).
operator()¶
const inline noexcept
template<class... Args, enable_if_t< _all_index< Args... >::value, int > = 0> inline const T & operator()(Args... a) const noexcept
Defined in include/teeny/tensor.h:1031
at¶
inline noexcept
template<class... Args, enable_if_t< _all_index< Args... >::value, int > = 0> inline auto at(Args... a) noexcept
Defined in include/teeny/tensor.h:1041
at(i...) — a single element as a rank-0 VIEW (all-integer args; negatives wrap).
Unlike operator(), which returns a plain T&, this is a view, so the whole tensor API applies to one element: x.at(i,j) = 3 writes it, float v = x.at(i,j) reads it (rank-0 tensors convert to/from T), and x.at(i,j).atomic_add_(v) is an atomic scatter.
at¶
const inline noexcept
template<class... Args, enable_if_t< _all_index< Args... >::value, int > = 0> inline auto at(Args... a) const noexcept
Defined in include/teeny/tensor.h:1046
operator()¶
inline noexcept
template<class... Args, enable_if_t<!_all_index< Args... >::value &&!_has_ellipsis< Args... >::value &&!_is_pack_call< Args... >::value, int > = 0> inline auto operator()(Args... a) noexcept
Defined in include/teeny/tensor.h:1064
Sub-view when any argument is a slice (all, slice(a,b[,step])) or a bare none (numpy newaxis).
Integer args drop their axis, all keeps it, a range keeps a strided window, and a bare none inserts a size-1 axis (static extent 1, stride 0) at its position — all via the one gather (folds static strides into strides<...>; works on any source layout). t(none,all,all) == unsqueeze<0>().
That vocabulary is CLOSED: an argument type the gather does not recognise is a compile error naming the mistake (a std::array/ std::tuple where the index pack wants cuda::std's, say), never a silently kept full axis (#448).
operator()¶
const inline noexcept
template<class... Args, enable_if_t<!_all_index< Args... >::value &&!_has_ellipsis< Args... >::value &&!_is_pack_call< Args... >::value, int > = 0> inline auto operator()(Args... a) const noexcept
Defined in include/teeny/tensor.h:1068
uget¶
inline noexcept
template<class... Args, enable_if_t< _all_index< Args... >::value, int > = 0> inline T & uget(Args... a) noexcept
Defined in include/teeny/tensor.h:1093
uget¶
const inline noexcept
template<class... Args, enable_if_t< _all_index< Args... >::value, int > = 0> inline const T & uget(Args... a) const noexcept
Defined in include/teeny/tensor.h:1096
uget¶
inline noexcept
template<class... Args, enable_if_t<!_all_index< Args... >::value &&!_has_ellipsis< Args... >::value &&!_is_pack_call< Args... >::value, int > = 0> inline auto uget(Args... a) noexcept
Defined in include/teeny/tensor.h:1102
uget¶
const inline noexcept
template<class... Args, enable_if_t<!_all_index< Args... >::value &&!_has_ellipsis< Args... >::value &&!_is_pack_call< Args... >::value, int > = 0> inline auto uget(Args... a) const noexcept
Defined in include/teeny/tensor.h:1106
uget¶
inline noexcept
template<class... Args, enable_if_t< _has_ellipsis< Args... >::value, int > = 0> inline decltype(auto) uget(Args... a) noexcept
Defined in include/teeny/tensor.h:1111
uget¶
const inline noexcept
template<class... Args, enable_if_t< _has_ellipsis< Args... >::value, int > = 0> inline decltype(auto) uget(Args... a) const noexcept
Defined in include/teeny/tensor.h:1114
uat¶
inline noexcept
template<class... Args, enable_if_t< _all_index< Args... >::value, int > = 0> inline auto uat(Args... a) noexcept
Defined in include/teeny/tensor.h:1119
Unchecked at: a single element as a rank-0 VIEW, no negative wrap.
uat¶
const inline noexcept
template<class... Args, enable_if_t< _all_index< Args... >::value, int > = 0> inline auto uat(Args... a) const noexcept
Defined in include/teeny/tensor.h:1124
operator()¶
inline noexcept
template<class... Args, enable_if_t< _has_ellipsis< Args... >::value, int > = 0> inline decltype(auto) operator()(Args... a) noexcept
Defined in include/teeny/tensor.h:1134
Ellipsis form: exactly one ellipsis in the args expands to rank - (#other args) copies of all, then the call re-runs — so t(1, ellipsis, 2) on rank 5 is t(1, all, all, all, 2).
What remains decides the result (all integers -> element, else view).
operator()¶
const inline noexcept
template<class... Args, enable_if_t< _has_ellipsis< Args... >::value, int > = 0> inline decltype(auto) operator()(Args... a) const noexcept
Defined in include/teeny/tensor.h:1137
operator()¶
inline noexcept
template<class P, enable_if_t< _is_index_pack< P >::value, int > = 0> inline decltype(auto) operator()(const P & p) noexcept
Defined in include/teeny/tensor.h:1157
Tuple-unpack form — t(m) where m is a single tuple-like index pack (a cuda::std::array or cuda::std::tuple) holding the WHOLE index list: exactly numpy's x[(a, b, c)] == x[a, b, c].
The pack is unpacked and re-dispatched through the ordinary variadic call, so everything that call does still applies: its elements may be integers/Int<>, all, slice(...), a bare none (newaxis) or one ellipsis, and the result is an element (T&) or a view exactly as if they had been written out. Arity and validity are diagnosed by that call's own static_asserts.
This is pure packing sugar and is single-argument only — the pack IS the index list, and is never mixed with other positional arguments. It closes the loop with a peel range's enumerate() / it.index(), whose multi-index is a cuda::std::array: for (auto [m, cell] : peel(t, axis<0,1>{}).enumerate()) out(m) = f(cell);. Also available on at/uget/uat (and, on C++23, t[m]).
operator()¶
const inline noexcept
template<class P, enable_if_t< _is_index_pack< P >::value, int > = 0> inline decltype(auto) operator()(const P & p) const noexcept
Defined in include/teeny/tensor.h:1159
at¶
inline noexcept
template<class P, enable_if_t< _is_index_pack< P >::value, int > = 0> inline decltype(auto) at(const P & p) noexcept
Defined in include/teeny/tensor.h:1164
Tuple-unpack at: t.at(m) == t.at(m[0], m[1], ...) — the element as a rank-0 VIEW.
All-integer packs only (as with variadic at).
at¶
const inline noexcept
template<class P, enable_if_t< _is_index_pack< P >::value, int > = 0> inline decltype(auto) at(const P & p) const noexcept
Defined in include/teeny/tensor.h:1166
uget¶
inline noexcept
template<class P, enable_if_t< _is_index_pack< P >::value, int > = 0> inline decltype(auto) uget(const P & p) noexcept
Defined in include/teeny/tensor.h:1171
Tuple-unpack uget / uat: the unchecked twins (no negative-index wrap), same unpack, same result types as the checked forms.
uget¶
const inline noexcept
template<class P, enable_if_t< _is_index_pack< P >::value, int > = 0> inline decltype(auto) uget(const P & p) const noexcept
Defined in include/teeny/tensor.h:1173
uat¶
inline noexcept
template<class P, enable_if_t< _is_index_pack< P >::value, int > = 0> inline decltype(auto) uat(const P & p) noexcept
Defined in include/teeny/tensor.h:1175
uat¶
const inline noexcept
template<class P, enable_if_t< _is_index_pack< P >::value, int > = 0> inline decltype(auto) uat(const P & p) const noexcept
Defined in include/teeny/tensor.h:1177
operator T¶
const inline noexcept
Defined in include/teeny/tensor.h:1196
item¶
const inline noexcept
Defined in include/teeny/tensor.h:1201
The single element of a rank-0 tensor (explicit reader).
slice_along¶
inline noexcept
Defined in include/teeny/tensor.h:1255
Index/slice one or more named axes; other axes are kept.
slice_along<Axes...>(args...) applies args[k] to axis Axes[k] (each an integer – negatives wrap – or a slice all/rng) and keeps every other axis, returning a view. e.g. t.slice_along<1>(2) drops axis 1 at index 2; t.slice_along<0,2>(i, rng(1,4)) binds axes 0 and 2 at once.
NB this is NOT numpy's take_along_axis / pytorch's take_along_dim (a data-dependent gather driven by an index TENSOR – that is teeny's index_select). slice_along binds compile-time-named axes to a scalar index or a slice, so it is always an affine view: pytorch's select/narrow generalised to several axes at once (#423).
slice_along¶
const inline noexcept
Defined in include/teeny/tensor.h:1262
slice_along¶
inline noexcept
template<long... Axes, class... Args> inline auto slice_along(axis< Axes... >, Args... args) noexcept
Defined in include/teeny/tensor.h:1273
Value form: t.slice_along(axis<0,2>{}, i, slice(1,4)) == t.slice_along<0,2>(i, slice(1,4)).
The leading axis<...> selector is a single distinct-typed argument, so it needs no .template on a dependent receiver AND disambiguates cleanly from the template form.
slice_along¶
const inline noexcept
template<long... Axes, class... Args> inline auto slice_along(axis< Axes... >, Args... args) const noexcept
Defined in include/teeny/tensor.h:1275
subsample¶
inline noexcept
template<long... Axes, class K, class... Starts> inline auto subsample(K k, Starts... starts) noexcept
Defined in include/teeny/tensor.h:1292
Subsample a coloured/strided sub-lattice: bind named axes to a slice(start,none,k) each, sharing one STEP k across all of them but taking a separate START per axis — sugar for slice_along (#258), for the "every k-th voxel, offset per
axis" pattern coloured Gauss-Seidel relaxation needs (loc[d] % k == digit_d(n)).
Pure sugar, no new addressing power: t.subsample<0,1>(k, s0, s1) == t.slice_along<0,1>(slice(s0,none,k), slice(s1,none,k)). k and each start accept a runtime value OR a compile-time one (Int<k>()) — folds through [slice()](#slice-2)'s own static-range machinery, so a fully-static (start,k) pair keeps a folded static output extent/stride, same as a hand-written [slice()](#slice-2).
subsample¶
const inline noexcept
template<long... Axes, class K, class... Starts> inline auto subsample(K k, Starts... starts) const noexcept
Defined in include/teeny/tensor.h:1297
subsample¶
inline noexcept
template<long... Axes, class K, class... Starts> inline auto subsample(axis< Axes... >, K k, Starts... starts) noexcept
Defined in include/teeny/tensor.h:1307
Value form: t.subsample(axis<0,1>{}, k, s0, s1) == t.subsample<0,1>(k, s0, s1) — leading axis<...> selector, same placement as slice_along's own value form (a second variadic pack, the starts, needs the disambiguating tag up front rather than trailing).
subsample¶
const inline noexcept
template<long... Axes, class K, class... Starts> inline auto subsample(axis< Axes... >, K k, Starts... starts) const noexcept
Defined in include/teeny/tensor.h:1309
unfold¶
inline noexcept
template<long Axis, class Sz, class St = integral_constant<long,1>> inline auto unfold(Sz size, St step = St{}) noexcept
Defined in include/teeny/tensor.h:1337
Sliding/strided window along axis Axis (pytorch Tensor.unfold): appends a NEW trailing axis of width size, stepped by step along Axis -> a rank-(N+1) view.
Axis's own extent shrinks to the window COUNT ([shape(Axis)](#shape) - size) / step + 1, e.g. t.unfold<0>(K, s) == pytorch's t.unfold(0, K, s). size/step accept a runtime value OR a compile-time one (Int<k>()), folding the output extent/stride to static where derivable (like [slice()](#slice-2)). size must be in [1, [shape(Axis)](#shape)] and step >= 1 — a static_assert when both are known at compile time, a debug-time check otherwise. ND windows compose by chaining: t.unfold<0>(K0,s0).unfold<1>(K1,s1) appends TWO window axes at the end (nitorch's nd-unfold pattern) — no separate nd-unfold primitive is needed.
unfold¶
const inline noexcept
template<long Axis, class Sz, class St = integral_constant<long,1>> inline auto unfold(Sz size, St step = St{}) const noexcept
Defined in include/teeny/tensor.h:1349
unfold¶
inline noexcept
template<class I, class Sz, class St = integral_constant<long,1>, enable_if_t< _is_ic< I >::value, int > = 0> inline auto unfold(I, Sz size, St step = St{}) noexcept
Defined in include/teeny/tensor.h:1365
Value form: t.unfold(Int<0>(), K, s) == t.unfold<0>(K, s) — a single-axis selector (like flip/squeeze/unsqueeze's own Int<k>() twin), so no .template is needed on a dependent receiver.
unfold¶
const inline noexcept
template<class I, class Sz, class St = integral_constant<long,1>, enable_if_t< _is_ic< I >::value, int > = 0> inline auto unfold(I, Sz size, St step = St{}) const noexcept
Defined in include/teeny/tensor.h:1367
index_select¶
const inline
template<long Axis, class Ti, class Ei, class Li, storage Oi, enable_if_t< _md::index_select_extents< Shape, _norm_axis(Axis, rank()), _shape_static_extent< Ei >(0)>::rank_dynamic() !=0, int > = 0> inline auto index_select(const tensor< Ti, Ei, Li, Oi > & idx, const tensor< Ti, Ei, Li, Oi > & idx) const
Defined in include/teeny/tensor.h:1420
index_select¶
const inline
template<class Ti, class Ei, class Li, storage Oi, class Tag0, class... Tags, class AxisTag = _kw::find_t<_is_axis_tag, _kw::unset, Tag0, Tags...>, enable_if_t< _md::_idxsel_api< Shape, Ei, AxisTag, Tag0, Tags... >::value, int > = 0> inline decltype(auto) index_select(const tensor< Ti, Ei, Li, Oi > & idx, Tag0 tag0, Tags... tags) const
Defined in include/teeny/tensor.h:1460
Value form + trailing keyword bag: t.index_select(idx, axis<Axis>{}) == t.index_select<Axis>(idx), and t.index_select(idx, axis<Axis>{}, into(dest)) == t.index_select<Axis>(idx, into(dest)).
Deduces Axis from the tag, so no .template disambiguator is needed on a type-dependent receiver (the primary reason this form exists — the mesh-distance kernels this feature targets call it from templates).
Both keywords ride the generic _kw bag ([kwargs.h](#kwargsh)) rather than one hand-written overload per arrangement (#451), so they compose in ANY subset and ANY order — t.index_select(idx, into(dest), axis<0>{}) is the same call — exactly like scan's pair and the reduction family's dtype/axis/keepdims/into bag. An unrecognised or duplicated keyword is one named static_assert (_TNY_KW_CHECK), not a wall of overload-resolution noise.
SPLIT IN TWO on the same key as the <Axis> overloads it forwards to (#375): a call that allocates its result (dynamic result shape, no into) is heap-owned and _TNY_HOST; a static result (stack-owned) or ANY into(dest) call (no allocation at all) stays _TNY_API — else nvcc's device pass would see a _TNY_API forwarder call a __host__ allocator.
index_select¶
const inline
template<class Ti, class Ei, class Li, storage Oi, class Tag0, class... Tags, class AxisTag = _kw::find_t<_is_axis_tag, _kw::unset, Tag0, Tags...>, enable_if_t< _md::_idxsel_host< Shape, Ei, AxisTag, Tag0, Tags... >::value, int > = 0> inline decltype(auto) index_select(const tensor< Ti, Ei, Li, Oi > & idx, Tag0, Tags...) const
Defined in include/teeny/tensor.h:1472
index_select¶
const inline
template<long Axis, class Ti, class Ei, class Li, storage Oi, class D> inline auto & index_select(const tensor< Ti, Ei, Li, Oi > & idx, into_t< D > out) const
Defined in include/teeny/tensor.h:1488
into(dest) form: writes the gather straight into dest — one pass, no allocation, _TNY_API (device-safe).
Returns dest&. dest's extents must match (axis Axis == idx.numel(), checked; every other axis == this tensor's own, checked by the underlying copy_). dest must not ALIAS this tensor's storage — an aliased in-place gather is unsupported (each j overwrites a slot of dest that a LATER j may still need to read from *this) and silently reorders instead of erroring.
permute¶
inline noexcept
Defined in include/teeny/tensor.h:1512
Reorder the axes (a permutation of 0..N-1; negatives wrap) -> a rank-N view.
permute¶
const inline noexcept
Defined in include/teeny/tensor.h:1515
flip¶
inline noexcept
Defined in include/teeny/tensor.h:1525
Reverse axis Ax (negatives wrap) -> a view (numpy flip).
Uses a negative stride, so the index type must be signed (shape<...> is).
An EMPTY tensor ([numel()](#numel) == 0) flips to a view over the same base pointer: there is no last element to move the origin to, so [data()](#data-6) is left exactly where it was.
flip¶
const inline noexcept
Defined in include/teeny/tensor.h:1528
flip¶
inline noexcept
Defined in include/teeny/tensor.h:1545
Reverse SEVERAL axes at once (numpy flip(a, axis=(...))) -> a rank-N view.
The axes are relative to the source rank (negatives count from the back) and must be distinct, in ANY order — flipping axes commutes, so t.flip<0,2>(), t.flip<2,0>() and t.flip<0>().flip<2>() are the same view (same type, same elements). Each named axis gets its stride negated and the base pointer moved to its last element, all in ONE view — no chain of intermediates. Arity picks this overload; one axis (or none) still means flip<Ax>() above.
As for the single-axis form, an EMPTY tensor keeps its base pointer ([data()](#data-6) unchanged) — even when only one axis is empty and the others are flipped.
flip¶
const inline noexcept
Defined in include/teeny/tensor.h:1555
clone¶
const inline
Defined in include/teeny/tensor.h:1576
to¶
const inline &
template<class T2 = element_type, bool Force = false, enable_if_t<!Force &&is_same< T2, element_type >::value, int > = 0> inline auto to() const &
Defined in include/teeny/tensor.h:1613
pytorch-like .to<T2>(): convert the element type to T2.
No copy when it already matches — if T2 is the current element type and Force is false, this returns a (read-only) view of *this, no allocation, keeping the source layout. So x.to<>() is a zero-cost borrow, not a clone. Because it borrows, the result must not outlive the storage it points at — the same lifetime rule as [view()](#view-1)/[permute()](#permute)/slicing. Pass Force = true to always materialise a fresh owning copy even when the dtype already matches (x.to<float, true>() force-clones a float tensor); x.clone() is the unconditional-copy spelling.
On a temporary the borrow is only taken when it cannot dangle: a non-owning view rvalue (view/gpu_view — e.g. a slice or .to<>() result) points at storage owned elsewhere, so borrowing from it is safe and stays zero-cost. An owning rvalue (stack/heap/gpu/pinned/ mapped) would carry its storage off, so its matching-dtype case forces a fresh owning copy instead of a dangling borrow (mirroring the free to<Space>(tensor&&)).
When a conversion IS needed (T2 differs, or Force), the result is a dense, row-major OWNING copy cast elementwise (via copy_): static shape -> stack (host+device), dynamic -> heap (host only). The copy runs on the HOST, so it cannot dereference DEVICE memory: the dynamic-shape (_TNY_HOST) copying overload static_asserts that the source is host-accessible. To also move across memory spaces (host <-> CUDA) — or to convert a gpu/gpu_view tensor at all — use the to<[storage::gpu](#namespacetny_1a269cef88b5ff5cb896f1766df7f21508a0aa0be2a866411d9ff03515227454947), T2, Force>(x) free functions from <[teeny/cuda.h](#cudah)>, which copy device-aware.
to¶
const inline &
template<class T2 = element_type, bool Force = false, bool S = is_static, enable_if_t<(Force||!is_same< T2, element_type >::value) &&!S, int > = 0> inline auto to() const &
Defined in include/teeny/tensor.h:1621
to¶
const inline &&
template<class T2 = element_type, bool Force = false, enable_if_t< storage_is_view(O) &&!Force &&is_same< T2, element_type >::value, int > = 0> inline auto to() const &&
Defined in include/teeny/tensor.h:1640
to¶
const inline &&
template<class T2 = element_type, bool Force = false, bool S = is_static, enable_if_t<!(storage_is_view(O) &&!Force &&is_same< T2, element_type >::value) &&!S, int > = 0> inline auto to() const &&
Defined in include/teeny/tensor.h:1648
to¶
const inline &
template<bool Force = false, class T2, bool S = is_static, enable_if_t<!(S||(!Force &&is_same< T2, element_type >::value)), int > = 0> inline auto to(dtype< T2 >, dtype< T2 >) const &
Defined in include/teeny/tensor.h:1669
to¶
const inline &&
template<bool Force = false, class T2, bool S = is_static, enable_if_t<!(S||(storage_is_view(O) &&!Force &&is_same< T2, element_type >::value)), int > = 0> inline auto to(dtype< T2 >, dtype< T2 >) const &&
Defined in include/teeny/tensor.h:1675
reshape¶
inline noexcept
Defined in include/teeny/tensor.h:1775
View this tensor as a new shape — numpy semantics: a VIEW whenever the layout can be regrouped without a copy (not only when C-contiguous; a strided/permuted source often still views — split a contiguous axis, merge a contiguous run).
The output is a folded strides<...> view (compile-time strides when the source is fully static). One extent may be -1 (numpy-style), inferred from the total size: t.reshape<6,-1>(). A non-viewable reshape is a compile error (static source) or a debug check (dynamic) — [clone()](#clone) first, or query can_reshape_without_copy.
reshape¶
const inline noexcept
Defined in include/teeny/tensor.h:1776
can_reshape_without_copy¶
const inline noexcept
Defined in include/teeny/tensor.h:1785
Whether reshape<NewExt...>() can produce a VIEW (no copy) of this tensor's actual layout — numpy's rule: not just C-contiguity, but any stride-compatible regrouping (splitting an axis, merging a contiguous run).
One -1 may be inferred. false -> the reshape needs a [clone()](#clone). (The result type of a viewable reshape is a folded strides<...> view.)
recast¶
inline
Defined in include/teeny/tensor.h:1857
Reinterpret with a MORE-STATIC extents type of the same rank — recover statically-known inner dims at the dynamic (ndarray) boundary: a runtime (n,3,3) view -> .recast<shape<-1,3,3>>() so the 3s (extents) fold.
NewLayout chooses the STRIDES (default [keep_strides](#keep_strides)):
-
[keep_strides](#keep_strides)(default) — PRESERVE the source strides; works on ANY layout (no copy, no contiguity requirement), a strided/transposed source keeps its strides, adynamic_stridessource keeps them at run time. Never mis-addresses. -
ccontiguous/fcontiguous— reinterpret AS that order, deriving the strides from the extents (folds the inner unit stride). The "I promise this is contiguous" form — UB if it isn't. -
strides<S...>— impose those (static) strides; adynamic_strideslot comes from the source.
Each static dim of NewShape is validated against the actual extent. Functional form: [recast(shape_value, layout_value)](#recast-4) (both may mix static/dynamic; the runtime values only deduce the types).
recast¶
const inline
Defined in include/teeny/tensor.h:1859
index_fits¶
const inline noexcept
Defined in include/teeny/tensor.h:1889
Can this view be re-expressed with the index type Idx2 — i.e.
does every element OFFSET fit Idx2, and is every axis's EXTENT VALUE representable in it? The precondition reindex<Idx2>() debug-checks, and the whole of it: narrowing rewrites the extents as well as the offsets, and a truncated extent is a wrong loop bound everywhere downstream (#489).
The offset half computes the SIGNED reach directly (teeny has negative-stride views, so required_span_size's non-negative assumption doesn't apply): max = Σ_{s>0}(e−1)·s, min = Σ_{s<0}(e−1)·s; fits ⟺ min..max ⊆ Idx2. It accumulates in a wide type, with the accumulation itself overflow-checked (#471 — safe even against adversarial/corrupted extents+strides, e.g. off a raw DLPack import); a broadcast (stride-0) axis adds 0 there, and is then held to the extent-value half like any other axis.
Idx2 may be ANY integral type up to 64 bits, signed or unsigned (uint64_t/size_t included): the positive and negative reach accumulate in separate unsigned/signed 64-bit domains, so neither comparison can wrap (#484). The VIEW's own index type may equally be unsigned 64-bit (shape_as<uint64_t, ...>): each raw extent/stride is measured in the type it is stored in, never blind-cast down to a signed one first (#486).
A STATIC extent that cannot be represented in Idx2 is a compile error from reindex<Idx2>() itself, so this runtime query is about the dynamic ones.
reindex¶
inline
Defined in include/teeny/tensor.h:1908
No-copy, layout-preserving retype of the offset index width to Idx2: same pointer, same layout KIND, the extents' index_type and any dynamic strides narrowed to Idx2 (a strides<...> literal pack is unchanged).
Narrowing the boundary view to shape32 halves the by-value footprint and runs offset math in 32-bit (big device win). Orthogonal to recast (which staticizes the extent VALUES) — they compose. Debug-checks index_fits<Idx2>() — every offset AND every dynamic extent value — and is UB if the caller lies (same contract as u*). A STATIC extent too large for Idx2 is a compile error instead (#489).
reindex¶
const inline
Defined in include/teeny/tensor.h:1913
flatten¶
inline noexcept
Defined in include/teeny/tensor.h:1922
View as 1-D (ravel) — a VIEW whenever the layout is mergeable into a single contiguous run without a copy (numpy semantics; [clone()](#clone) first otherwise).
Just reshape<-1>() (one inferred dim), spelled out for discoverability.
flatten¶
const inline noexcept
Defined in include/teeny/tensor.h:1923
unsqueeze¶
inline noexcept
Defined in include/teeny/tensor.h:1929
Insert a size-1 axis at position Ax (numpy newaxis/unsqueeze) -> a rank-(N+1) view.
Negative Ax counts from the back, so .unsqueeze<-1>() appends a trailing axis: (H,W) -> (H,W,1).
unsqueeze¶
const inline noexcept
Defined in include/teeny/tensor.h:1932
unsqueeze¶
inline noexcept
Defined in include/teeny/tensor.h:1943
Insert size-1 axes at SEVERAL positions at once (numpy expand_dims(a, axis=(...))) -> a rank-(N+k) view.
The positions are relative to the final rank N + k (negatives count from the back of it), and must be distinct (in ANY order — sorted internally, #275) — e.g. (H,W).unsqueeze<1,3>() -> (H,1,W,1), (H,W).unsqueeze<0,-1>() -> (1,H,W,1). Arity picks this overload; one axis still means unsqueeze<Ax>() above.
unsqueeze¶
const inline noexcept
Defined in include/teeny/tensor.h:1953
squeeze¶
inline noexcept
Defined in include/teeny/tensor.h:1985
Drop a size-1 axis Ax (negatives wrap) -> a rank-(N-1) view.
[squeeze()](#squeeze) (no axis) drops EVERY statically-size-1 axis.
squeeze¶
const inline noexcept
Defined in include/teeny/tensor.h:1994
squeeze¶
inline noexcept
Defined in include/teeny/tensor.h:2012
Drop SEVERAL size-1 axes at once (numpy squeeze(axis=(...))) -> a rank-(N-k) view.
The positions are relative to the source rank (negatives count from the back) and must be distinct (in ANY order — sorted internally, #275); every named axis must have extent 1 (static_assert where the extent is static, _TNY_CHECK where it is dynamic). e.g. a (1,H,1,W) view .squeeze<0,2>() -> (H,W). Arity picks this overload; one axis (or none) still means squeeze<Ax>() above.
squeeze¶
const inline noexcept
Defined in include/teeny/tensor.h:2023
flip¶
inline noexcept
Defined in include/teeny/tensor.h:2038
flip¶
const inline noexcept
Defined in include/teeny/tensor.h:2039
squeeze¶
inline noexcept
Defined in include/teeny/tensor.h:2040
squeeze¶
const inline noexcept
Defined in include/teeny/tensor.h:2041
unsqueeze¶
inline noexcept
Defined in include/teeny/tensor.h:2042
unsqueeze¶
const inline noexcept
template<class I, enable_if_t< _is_ic< I >::value, int > = 0> inline auto unsqueeze(I) const noexcept
Defined in include/teeny/tensor.h:2043
permute¶
inline noexcept
template<class... I, enable_if_t<(sizeof...(I) > 0) &&_all_ic< I... >::value, int > = 0> inline auto permute(I...) noexcept
Defined in include/teeny/tensor.h:2044
permute¶
const inline noexcept
template<class... I, enable_if_t<(sizeof...(I) > 0) &&_all_ic< I... >::value, int > = 0> inline auto permute(I...) const noexcept
Defined in include/teeny/tensor.h:2045
squeeze¶
inline noexcept
Defined in include/teeny/tensor.h:2069
Value form: t.squeeze(axis<0,2>{}) == t.squeeze<0,2>(), likewise unsqueeze/flip/permute.
squeeze/unsqueeze/flip/permute are axis-LIST ops (like peel/slice_along/the reductions), so — unlike the single-axis Int<k>() form above — they take the axis<...> tag: a single distinct-typed argument, so no .template is needed on a dependent receiver.
An EMPTY list — axis<>{} — names no axis, so it is a no-op: the same shape and strides back, as a view (numpy's own rule for an empty axis tuple, np.squeeze(a, axis=()) / np.expand_dims(a, axis=()); same identity _keepdims<>/slice_along(axis<>{})/peel(t, axis<>{}) already have). It is NOT the same as the no-argument [squeeze()](#squeeze) (drop EVERY statically-size-1 axis) or [unsqueeze()](#unsqueeze) (insert at axis 0) — those keep their meanings; only the axis-LIST spelling reads an empty list as "no axes named" (#369). Generic code that computes an axis list therefore stays correct when the list comes out empty.
permute is the exception, and needs nothing added: it takes a FULL permutation, so its own sizeof...(Perm) == [rank()](#rank-3) check already accepts axis<>{} for a rank-0 tensor only (a no-op there — the one permutation of no axes) and rejects it at compile time for any other rank, rather than silently doing something else.
squeeze¶
const inline noexcept
Defined in include/teeny/tensor.h:2071
unsqueeze¶
inline noexcept
Defined in include/teeny/tensor.h:2073
unsqueeze¶
const inline noexcept
Defined in include/teeny/tensor.h:2075
flip¶
inline noexcept
Defined in include/teeny/tensor.h:2077
flip¶
const inline noexcept
Defined in include/teeny/tensor.h:2079
permute¶
inline noexcept
Defined in include/teeny/tensor.h:2081
permute¶
const inline noexcept
Defined in include/teeny/tensor.h:2082
reshape¶
inline noexcept
template<class... I, enable_if_t<(sizeof...(I) > 0) &&_all_ic< I... >::value, int > = 0> inline auto reshape(I...) noexcept
Defined in include/teeny/tensor.h:2083
reshape¶
const inline noexcept
template<class... I, enable_if_t<(sizeof...(I) > 0) &&_all_ic< I... >::value, int > = 0> inline auto reshape(I...) const noexcept
Defined in include/teeny/tensor.h:2084
recast¶
inline
Defined in include/teeny/tensor.h:2085
recast¶
const inline
Defined in include/teeny/tensor.h:2086
recast¶
inline
Defined in include/teeny/tensor.h:2091
recast¶
const inline
Defined in include/teeny/tensor.h:2092
add_¶
template<bool Atomic = false, class B, enable_if_t<!is_arithmetic< B >::value, int > = 0> tensor & add_(const B & b)
Defined in include/teeny/tensor.h:2099
sub_¶
template<bool Atomic = false, class B, enable_if_t<!is_arithmetic< B >::value, int > = 0> tensor & sub_(const B & b)
Defined in include/teeny/tensor.h:2100
mul_¶
Defined in include/teeny/tensor.h:2101
div_¶
Defined in include/teeny/tensor.h:2102
add_¶
Defined in include/teeny/tensor.h:2103
sub_¶
Defined in include/teeny/tensor.h:2104
mul_¶
Defined in include/teeny/tensor.h:2105
div_¶
Defined in include/teeny/tensor.h:2106
minimum_¶
Defined in include/teeny/tensor.h:2112
maximum_¶
Defined in include/teeny/tensor.h:2113
minimum_¶
Defined in include/teeny/tensor.h:2114
maximum_¶
Defined in include/teeny/tensor.h:2115
add_¶
template<class B, enable_if_t<!is_arithmetic< B >::value, int > = 0> tensor & add_(const B & b, T alpha)
Defined in include/teeny/tensor.h:2120
sub_¶
template<class B, enable_if_t<!is_arithmetic< B >::value, int > = 0> tensor & sub_(const B & b, T alpha)
Defined in include/teeny/tensor.h:2121
atomic_add_¶
template<class B, enable_if_t<!is_arithmetic< B >::value, int > = 0> tensor & atomic_add_(const B & b)
Defined in include/teeny/tensor.h:2130
atomic_sub_¶
template<class B, enable_if_t<!is_arithmetic< B >::value, int > = 0> tensor & atomic_sub_(const B & b)
Defined in include/teeny/tensor.h:2131
atomic_add_¶
Defined in include/teeny/tensor.h:2132
atomic_sub_¶
Defined in include/teeny/tensor.h:2133
operator+=¶
inline
Defined in include/teeny/tensor.h:2137
operator-=¶
inline
Defined in include/teeny/tensor.h:2138
operator*=¶
inline
Defined in include/teeny/tensor.h:2139
operator/=¶
inline
Defined in include/teeny/tensor.h:2140
copy_¶
Defined in include/teeny/tensor.h:2143
fill_¶
Defined in include/teeny/tensor.h:2144
zero_¶
Defined in include/teeny/tensor.h:2145
iota_¶
Defined in include/teeny/tensor.h:2146
add¶
const
Defined in include/teeny/tensor.h:2149
sub¶
const
Defined in include/teeny/tensor.h:2150
mul¶
const
Defined in include/teeny/tensor.h:2151
div¶
const
Defined in include/teeny/tensor.h:2152
pow¶
const
Defined in include/teeny/tensor.h:2153
add¶
const
Defined in include/teeny/tensor.h:2155
sub¶
const
Defined in include/teeny/tensor.h:2156
mul¶
const
Defined in include/teeny/tensor.h:2157
div¶
const
Defined in include/teeny/tensor.h:2158
pow¶
const
Defined in include/teeny/tensor.h:2159
add¶
const
template<class B, enable_if_t<!is_arithmetic< B >::value, int > = 0> auto add(const B & b, T alpha) const
Defined in include/teeny/tensor.h:2163
sub¶
const
template<class B, enable_if_t<!is_arithmetic< B >::value, int > = 0> auto sub(const B & b, T alpha) const
Defined in include/teeny/tensor.h:2164
add¶
const
template<class B, class D, enable_if_t<!is_arithmetic< B >::value, int > = 0> auto & add(const B & b, T alpha, into_t< D > out) const
Defined in include/teeny/tensor.h:2165
sub¶
const
template<class B, class D, enable_if_t<!is_arithmetic< B >::value, int > = 0> auto & sub(const B & b, T alpha, into_t< D > out) const
Defined in include/teeny/tensor.h:2166
maximum¶
const
Defined in include/teeny/tensor.h:2183
minimum¶
const
Defined in include/teeny/tensor.h:2184
maximum¶
const
Defined in include/teeny/tensor.h:2185
clamp¶
const
Defined in include/teeny/tensor.h:2186
clamp¶
const
Defined in include/teeny/tensor.h:2187
normalize¶
const
Defined in include/teeny/tensor.h:2188
normalize¶
const
Defined in include/teeny/tensor.h:2189
normalize¶
const
template<long... Axes, enable_if_t<(sizeof...(Axes) > 0) &&_md::_nrm_out_api< Shape, Axes... >::value, int > = 0> auto normalize() const
Defined in include/teeny/tensor.h:2197
normalize¶
const
template<long... Axes, enable_if_t<(sizeof...(Axes) > 0) &&_md::_nrm_out_host< Shape, Axes... >::value, int > = 0> auto normalize() const
Defined in include/teeny/tensor.h:2199
normalize¶
const
template<long... Axes, enable_if_t<(sizeof...(Axes) > 0) &&_md::_nrm_out_api< Shape, Axes... >::value, int > = 0> auto normalize(axis< Axes... >) const
Defined in include/teeny/tensor.h:2201
normalize¶
const
template<long... Axes, enable_if_t<(sizeof...(Axes) > 0) &&_md::_nrm_out_host< Shape, Axes... >::value, int > = 0> auto normalize(axis< Axes... >) const
Defined in include/teeny/tensor.h:2203
normalize¶
const
template<long... Axes, class D, enable_if_t<(sizeof...(Axes) > 0) &&_md::_nrm_kept_api< Shape, Axes... >::value, int > = 0> auto & normalize(into_t< D > out) const
Defined in include/teeny/tensor.h:2205
normalize¶
const
template<long... Axes, class D, enable_if_t<(sizeof...(Axes) > 0) &&_md::_nrm_kept_host< Shape, Axes... >::value, int > = 0> auto & normalize(into_t< D > out) const
Defined in include/teeny/tensor.h:2207
normalize¶
const
template<long... Axes, class D, enable_if_t<(sizeof...(Axes) > 0) &&_md::_nrm_kept_api< Shape, Axes... >::value, int > = 0> auto & normalize(axis< Axes... >, into_t< D > out) const
Defined in include/teeny/tensor.h:2209
normalize¶
const
template<long... Axes, class D, enable_if_t<(sizeof...(Axes) > 0) &&_md::_nrm_kept_host< Shape, Axes... >::value, int > = 0> auto & normalize(axis< Axes... >, into_t< D > out) const
Defined in include/teeny/tensor.h:2211
cross¶
const
template<class Tb, class Eb, class Lb, storage Ob> auto cross(const tensor< Tb, Eb, Lb, Ob > & b) const
Defined in include/teeny/tensor.h:2212
cross¶
const
template<class Tb, class Eb, class Lb, storage Ob, class D> auto & cross(const tensor< Tb, Eb, Lb, Ob > & b, into_t< D > out) const
Defined in include/teeny/tensor.h:2213
map_¶
Defined in include/teeny/tensor.h:2219
zip_with_¶
Defined in include/teeny/tensor.h:2220
map¶
const
Defined in include/teeny/tensor.h:2221
map¶
const
Defined in include/teeny/tensor.h:2222
all¶
const
Defined in include/teeny/tensor.h:2226
any¶
const
Defined in include/teeny/tensor.h:2227
dot¶
const
Defined in include/teeny/tensor.h:2274
dot¶
const
template<class Acc = void, class Tb, class Eb, class Lb, storage Ob, class Tag0, class... Tags> decltype(auto) dot(const tensor< Tb, Eb, Lb, Ob > & b, Tag0 tag0, Tags... tags) const
Defined in include/teeny/tensor.h:2276
sqdist¶
const
template<class Acc = void, class Tb, class Eb, class Lb, storage Ob> auto sqdist(const tensor< Tb, Eb, Lb, Ob > & b) const
Defined in include/teeny/tensor.h:2279
sqdist¶
const
template<class Acc = void, class Tb, class Eb, class Lb, storage Ob, class Tag0, class... Tags> decltype(auto) sqdist(const tensor< Tb, Eb, Lb, Ob > & b, Tag0 tag0, Tags... tags) const
Defined in include/teeny/tensor.h:2281
dist¶
const
template<class Acc = void, class Tb, class Eb, class Lb, storage Ob> auto dist(const tensor< Tb, Eb, Lb, Ob > & b) const
Defined in include/teeny/tensor.h:2283
dist¶
const
template<class Acc = void, class Tb, class Eb, class Lb, storage Ob, class Tag0, class... Tags> decltype(auto) dist(const tensor< Tb, Eb, Lb, Ob > & b, Tag0 tag0, Tags... tags) const
Defined in include/teeny/tensor.h:2285
allclose¶
const
template<class Acc = void, class Tb, class Eb, class Lb, storage Ob> bool allclose(const tensor< Tb, Eb, Lb, Ob > & b, double rtol = _allclose_rtol(), double atol = _allclose_atol()) const
Defined in include/teeny/tensor.h:2293
allclose¶
const
template<class Acc = void, class Tb, class Eb, class Lb, storage Ob, class Tag0, class... Tags, enable_if_t< _kw::is_keyword< Tag0 >::value, int > = 0> decltype(auto) allclose(const tensor< Tb, Eb, Lb, Ob > & b, Tag0 tag0, Tags... tags) const
Defined in include/teeny/tensor.h:2297
allclose¶
const
template<class Acc = void, class Tb, class Eb, class Lb, storage Ob, class Tag0, class... Tags, enable_if_t< _kw::is_keyword< Tag0 >::value, int > = 0> decltype(auto) allclose(const tensor< Tb, Eb, Lb, Ob > & b, double rtol, Tag0 tag0, Tags... tags) const
Defined in include/teeny/tensor.h:2300
allclose¶
const
template<class Acc = void, class Tb, class Eb, class Lb, storage Ob, class Tag0, class... Tags, enable_if_t< _kw::is_keyword< Tag0 >::value, int > = 0> decltype(auto) allclose(const tensor< Tb, Eb, Lb, Ob > & b, double rtol, double atol, Tag0 tag0, Tags... tags) const
Defined in include/teeny/tensor.h:2304
neg_¶
Defined in include/teeny/tensor.h:2308
abs_¶
Defined in include/teeny/tensor.h:2309
exp_¶
Defined in include/teeny/tensor.h:2310
log_¶
Defined in include/teeny/tensor.h:2311
sin_¶
Defined in include/teeny/tensor.h:2312
cos_¶
Defined in include/teeny/tensor.h:2313
sqrt_¶
Defined in include/teeny/tensor.h:2314
tanh_¶
Defined in include/teeny/tensor.h:2315
floor_¶
Defined in include/teeny/tensor.h:2316
ceil_¶
Defined in include/teeny/tensor.h:2317
round_¶
Defined in include/teeny/tensor.h:2318
trunc_¶
Defined in include/teeny/tensor.h:2319
sign_¶
Defined in include/teeny/tensor.h:2320
pow_¶
Defined in include/teeny/tensor.h:2321
clamp_¶
Defined in include/teeny/tensor.h:2322
normalize_¶
Defined in include/teeny/tensor.h:2323
normalize_¶
template<long... Axes, enable_if_t< _md::_nrm_kept_host< Shape, Axes... >::value, int > = 0> tensor & normalize_()
Defined in include/teeny/tensor.h:2329
cross_¶
template<class Tb, class Eb, class Lb, storage Ob> tensor & cross_(const tensor< Tb, Eb, Lb, Ob > & b)
Defined in include/teeny/tensor.h:2331
operator++¶
inline
Defined in include/teeny/tensor.h:2337
operator--¶
inline
Defined in include/teeny/tensor.h:2338
operator++¶
inline
template<bool S = is_static, enable_if_t< S, int > = 0> inline tensor< T, Shape, ccontiguous, storage::stack > operator++(int)
Defined in include/teeny/tensor.h:2340
operator--¶
inline
template<bool S = is_static, enable_if_t< S, int > = 0> inline tensor< T, Shape, ccontiguous, storage::stack > operator--(int)
Defined in include/teeny/tensor.h:2342
add_¶
template<bool Atomic, class B, enable_if_t<!is_arithmetic< B >::value, int >> tensor< T, E, L, O > & add_(const B & b)
Defined in include/teeny/math.h:1342
sub_¶
template<bool Atomic, class B, enable_if_t<!is_arithmetic< B >::value, int >> tensor< T, E, L, O > & sub_(const B & b)
Defined in include/teeny/math.h:1348
mul_¶
template<class B, enable_if_t<!is_arithmetic< B >::value, int >> tensor< T, E, L, O > & mul_(const B & b)
Defined in include/teeny/math.h:1354
div_¶
template<class B, enable_if_t<!is_arithmetic< B >::value, int >> tensor< T, E, L, O > & div_(const B & b)
Defined in include/teeny/math.h:1356
add_¶
Defined in include/teeny/math.h:1358
sub_¶
Defined in include/teeny/math.h:1364
minimum_¶
template<class B, enable_if_t<!is_arithmetic< B >::value, int >> tensor< T, E, L, O > & minimum_(const B & b)
Defined in include/teeny/math.h:1373
maximum_¶
template<class B, enable_if_t<!is_arithmetic< B >::value, int >> tensor< T, E, L, O > & maximum_(const B & b)
Defined in include/teeny/math.h:1375
add_¶
template<class B, enable_if_t<!is_arithmetic< B >::value, int >> tensor< T, E, L, O > & add_(const B & b, T alpha)
Defined in include/teeny/math.h:1380
sub_¶
template<class B, enable_if_t<!is_arithmetic< B >::value, int >> tensor< T, E, L, O > & sub_(const B & b, T alpha)
Defined in include/teeny/math.h:1382
atomic_add_¶
template<class B, enable_if_t<!is_arithmetic< B >::value, int >> tensor< T, E, L, O > & atomic_add_(const B & b)
Defined in include/teeny/math.h:1386
atomic_sub_¶
template<class B, enable_if_t<!is_arithmetic< B >::value, int >> tensor< T, E, L, O > & atomic_sub_(const B & b)
Defined in include/teeny/math.h:1388
copy_¶
Defined in include/teeny/math.h:1392
map_¶
Defined in include/teeny/math.h:1542
zip_with_¶
Defined in include/teeny/math.h:1544
cross_¶
template<class Tb, class Eb, class Lb, storage Ob> tensor< T, E, L, O > & cross_(const tensor< Tb, Eb, Lb, Ob > & b)
Defined in include/teeny/math.h:2376
normalize_¶
template<long... Axes, enable_if_t< _md::_nrm_kept_api< E, Axes... >::value, int >> tensor< T, E, L, O > & normalize_()
Defined in include/teeny/math.h:2399
minimum¶
const
Defined in include/teeny/math.h:2634
Public Static Attributes¶
| Return | Name | Description |
|---|---|---|
constexpr storage |
ownership static constexpr |
|
constexpr bool |
is_static static constexpr |
|
constexpr bool |
is_view static constexpr |
|
constexpr bool |
is_owning static constexpr |
|
constexpr bool |
is_device static constexpr |
|
constexpr bool |
is_host_accessible static constexpr |
|
constexpr size_t |
buffer_size static constexpr |
|
constexpr bool |
is_strides_layout static constexpr |
|
constexpr bool |
is_contiguous_layout static constexpr |
ownership¶
static constexpr
Defined in include/teeny/tensor.h:596
is_static¶
static constexpr
Defined in include/teeny/tensor.h:597
is_view¶
static constexpr
Defined in include/teeny/tensor.h:599
is_owning¶
static constexpr
Defined in include/teeny/tensor.h:600
is_device¶
static constexpr
Defined in include/teeny/tensor.h:601
is_host_accessible¶
static constexpr
Defined in include/teeny/tensor.h:602
buffer_size¶
static constexpr
Defined in include/teeny/tensor.h:603
is_strides_layout¶
static constexpr
Defined in include/teeny/tensor.h:663
is_contiguous_layout¶
static constexpr
Defined in include/teeny/tensor.h:664
Public Static Methods¶
| Return | Name | Description |
|---|---|---|
constexpr size_t |
rank static inline constexpr noexcept |
rank¶
static inline constexpr noexcept
Defined in include/teeny/tensor.h:660
Public Types¶
| Name | Description |
|---|---|
element_type |
|
extents_type |
|
shape_type |
|
layout_type |
|
index_type |
|
mapping_type |
|
view_type |
|
const_view_type |
element_type¶
Defined in include/teeny/tensor.h:587
extents_type¶
Defined in include/teeny/tensor.h:588
shape_type¶
Defined in include/teeny/tensor.h:589
layout_type¶
Defined in include/teeny/tensor.h:590
index_type¶
Defined in include/teeny/tensor.h:591
mapping_type¶
Defined in include/teeny/tensor.h:592
view_type¶
Defined in include/teeny/tensor.h:593
const_view_type¶
Defined in include/teeny/tensor.h:594
mapping¶
Defined in include/teeny/layout.h:145
Inherits:
ndyn()>,Shape
List of all members¶
| Name | Kind | Owner |
|---|---|---|
mapping |
function |
Declared here |
mapping |
function |
Declared here |
mapping |
function |
Declared here |
extents |
function |
Declared here |
stride |
function |
Declared here |
operator() |
function |
Declared here |
required_span_size |
function |
Declared here |
is_unique |
function |
Declared here |
is_exhaustive |
function |
Declared here |
is_strided |
function |
Declared here |
is_always_unique |
function |
Declared here |
is_always_exhaustive |
function |
Declared here |
is_always_strided |
function |
Declared here |
extents_type |
typedef |
Declared here |
index_type |
typedef |
Declared here |
rank_type |
typedef |
Declared here |
layout_type |
typedef |
Declared here |
Public Methods¶
| Return | Name | Description |
|---|---|---|
mapping |
Defaulted constructor. | |
constexpr |
mapping inline constexpr |
Fully-static strides: construct from extents only. |
constexpr |
mapping inline constexpr |
Mixed strides: extents + the runtime strides (dim order, dynamic ones only). |
constexpr const Shape & |
extents const inline constexpr noexcept |
|
constexpr index_type |
stride const inline constexpr noexcept |
|
constexpr index_type |
operator() const inline constexpr noexcept |
|
constexpr index_type |
required_span_size const inline constexpr noexcept |
|
constexpr bool |
is_unique const inline constexpr noexcept |
|
constexpr bool |
is_exhaustive const inline constexpr noexcept |
|
constexpr bool |
is_strided const inline constexpr noexcept |
mapping¶
Defined in include/teeny/layout.h:153
Defaulted constructor.
mapping¶
inline constexpr
template<size_t M = strides::ndyn(), enable_if_t< M==0, int > = 0> constexpr inline constexpr mapping(const Shape & e)
Defined in include/teeny/layout.h:157
Fully-static strides: construct from extents only.
mapping¶
inline constexpr
template<class OtherIdx> constexpr inline constexpr mapping(const Shape & e, const array< OtherIdx, strides::ndyn()> & dyn)
Defined in include/teeny/layout.h:174
Mixed strides: extents + the runtime strides (dim order, dynamic ones only).
Templated on the array's element type so a reindex (narrowing the offset index width) can pass its wider source strides — each is cast to index_type; symmetric with mdspan's layout_stride.
extents¶
const inline constexpr noexcept
Defined in include/teeny/layout.h:177
stride¶
const inline constexpr noexcept
Defined in include/teeny/layout.h:178
operator()¶
const inline constexpr noexcept
Defined in include/teeny/layout.h:183
required_span_size¶
const inline constexpr noexcept
Defined in include/teeny/layout.h:194
is_unique¶
const inline constexpr noexcept
Defined in include/teeny/layout.h:205
is_exhaustive¶
const inline constexpr noexcept
Defined in include/teeny/layout.h:206
is_strided¶
const inline constexpr noexcept
Defined in include/teeny/layout.h:207
Public Static Methods¶
| Return | Name | Description |
|---|---|---|
constexpr bool |
is_always_unique static inline constexpr noexcept |
|
constexpr bool |
is_always_exhaustive static inline constexpr noexcept |
|
constexpr bool |
is_always_strided static inline constexpr noexcept |
is_always_unique¶
static inline constexpr noexcept
Defined in include/teeny/layout.h:202
is_always_exhaustive¶
static inline constexpr noexcept
Defined in include/teeny/layout.h:203
is_always_strided¶
static inline constexpr noexcept
Defined in include/teeny/layout.h:204
Public Types¶
| Name | Description |
|---|---|
extents_type |
|
index_type |
|
rank_type |
|
layout_type |
extents_type¶
Defined in include/teeny/layout.h:146
index_type¶
Defined in include/teeny/layout.h:147
rank_type¶
Defined in include/teeny/layout.h:148
layout_type¶
Defined in include/teeny/layout.h:149
item¶
Defined in include/teeny/iterate.h:226
List of all members¶
| Name | Kind | Owner |
|---|---|---|
index |
variable |
Declared here |
cell |
variable |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
array< index_type, Nd ? Nd :1 > |
index |
|
Cell |
cell |
index¶
Defined in include/teeny/iterate.h:226
cell¶
Defined in include/teeny/iterate.h:226
item¶
Defined in include/teeny/dynamic.h:654
List of all members¶
| Name | Kind | Owner |
|---|---|---|
index |
variable |
Declared here |
cell |
variable |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
coord |
index |
|
Cell |
cell |
index¶
Defined in include/teeny/dynamic.h:654
cell¶
Defined in include/teeny/dynamic.h:654
coord¶
Defined in include/teeny/dynamic.h:648
List of all members¶
| Name | Kind | Owner |
|---|---|---|
ctr |
variable |
Declared here |
nb |
variable |
Declared here |
lin |
variable |
Declared here |
operator[] |
function |
Declared here |
rank |
function |
Declared here |
linear |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
const offset_t * |
ctr |
|
int |
nb |
|
offset_t |
lin |
ctr¶
Defined in include/teeny/dynamic.h:649
nb¶
Defined in include/teeny/dynamic.h:649
lin¶
Defined in include/teeny/dynamic.h:649
Public Methods¶
| Return | Name | Description |
|---|---|---|
offset_t |
operator[] const inline noexcept |
|
int |
rank const inline noexcept |
|
offset_t |
linear const inline noexcept |
operator[]¶
const inline noexcept
Defined in include/teeny/dynamic.h:650
rank¶
const inline noexcept
Defined in include/teeny/dynamic.h:651
linear¶
const inline noexcept
Defined in include/teeny/dynamic.h:652
iterator¶
Defined in include/teeny/iterate.h:174
List of all members¶
| Name | Kind | Owner |
|---|---|---|
tmpl |
variable |
Declared here |
base |
variable |
Declared here |
cur |
variable |
Declared here |
operator* |
function |
Declared here |
operator++ |
function |
Declared here |
operator!= |
function |
Declared here |
operator== |
function |
Declared here |
index |
function |
Declared here |
index |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
Cell |
tmpl |
|
El * |
base |
|
_md::peel_cursor< index_type, Nd > |
cur |
tmpl¶
Defined in include/teeny/iterate.h:175
base¶
Defined in include/teeny/iterate.h:176
cur¶
Defined in include/teeny/iterate.h:177
Public Methods¶
| Return | Name | Description |
|---|---|---|
Cell |
operator* const inline |
|
iterator & |
operator++ inline |
|
bool |
operator!= const inline |
|
bool |
operator== const inline |
|
index_type |
index const inline noexcept |
|
array< index_type, Nd ? Nd :1 > |
index const inline noexcept |
operator*¶
const inline
Defined in include/teeny/iterate.h:178
operator++¶
inline
Defined in include/teeny/iterate.h:179
operator!=¶
const inline
Defined in include/teeny/iterate.h:180
operator==¶
const inline
Defined in include/teeny/iterate.h:181
index¶
const inline noexcept
Defined in include/teeny/iterate.h:186
index¶
const inline noexcept
Defined in include/teeny/iterate.h:187
enum_range¶
Defined in include/teeny/iterate.h:234
List of all members¶
| Name | Kind | Owner |
|---|---|---|
r |
variable |
Declared here |
begin |
function |
Declared here |
end |
function |
Declared here |
subrange |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
peel_range |
r |
r¶
Defined in include/teeny/iterate.h:235
Public Methods¶
| Return | Name | Description |
|---|---|---|
enum_iterator |
begin const inline |
|
enum_iterator |
end const inline |
|
enum_subrange |
subrange const inline |
begin¶
const inline
Defined in include/teeny/iterate.h:236
end¶
const inline
Defined in include/teeny/iterate.h:237
subrange¶
const inline
Defined in include/teeny/iterate.h:243
enum_subrange¶
Defined in include/teeny/iterate.h:238
List of all members¶
| Name | Kind | Owner |
|---|---|---|
b |
variable |
Declared here |
e |
variable |
Declared here |
begin |
function |
Declared here |
end |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
enum_iterator |
b |
|
enum_iterator |
e |
b¶
Defined in include/teeny/iterate.h:239
e¶
Defined in include/teeny/iterate.h:239
Public Methods¶
| Return | Name | Description |
|---|---|---|
enum_iterator |
begin const inline |
|
enum_iterator |
end const inline |
begin¶
const inline
Defined in include/teeny/iterate.h:240
end¶
const inline
Defined in include/teeny/iterate.h:241
iterator¶
Defined in include/teeny/dynamic.h:582
List of all members¶
| Name | Kind | Owner |
|---|---|---|
tmpl |
variable |
Declared here |
base |
variable |
Declared here |
ctr |
variable |
Declared here |
ext |
variable |
Declared here |
str |
variable |
Declared here |
nb |
variable |
Declared here |
off |
variable |
Declared here |
lin |
variable |
Declared here |
operator* |
function |
Declared here |
operator++ |
function |
Declared here |
operator!= |
function |
Declared here |
operator== |
function |
Declared here |
index |
function |
Declared here |
nbatch |
function |
Declared here |
linear |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
Cell |
tmpl |
|
T * |
base |
|
offset_t |
ctr |
|
offset_t |
ext |
|
offset_t |
str |
|
int |
nb |
|
offset_t |
off |
|
offset_t |
lin |
tmpl¶
Defined in include/teeny/dynamic.h:583
base¶
Defined in include/teeny/dynamic.h:584
ctr¶
Defined in include/teeny/dynamic.h:585
ext¶
Defined in include/teeny/dynamic.h:586
str¶
Defined in include/teeny/dynamic.h:587
nb¶
Defined in include/teeny/dynamic.h:588
off¶
Defined in include/teeny/dynamic.h:589
lin¶
Defined in include/teeny/dynamic.h:589
Public Methods¶
| Return | Name | Description |
|---|---|---|
Cell |
operator* const inline |
|
iterator & |
operator++ inline |
|
bool |
operator!= const inline |
|
bool |
operator== const inline |
|
offset_t |
index const inline noexcept |
|
int |
nbatch const inline noexcept |
|
offset_t |
linear const inline noexcept |
operator*¶
const inline
Defined in include/teeny/dynamic.h:590
operator++¶
inline
Defined in include/teeny/dynamic.h:591
operator!=¶
const inline
Defined in include/teeny/dynamic.h:599
operator==¶
const inline
Defined in include/teeny/dynamic.h:600
index¶
const inline noexcept
Defined in include/teeny/dynamic.h:606
nbatch¶
const inline noexcept
Defined in include/teeny/dynamic.h:607
linear¶
const inline noexcept
Defined in include/teeny/dynamic.h:608
subrange_t¶
Defined in include/teeny/iterate.h:208
A [lo, hi) slice of the cells for chunked/threaded sweeps: seed the incremental cursor once at lo, then O(1) per step within the chunk.
(Split [0,[size()](#size-3)) across threads/blocks; each sweeps its chunk.)
List of all members¶
| Name | Kind | Owner |
|---|---|---|
b |
variable |
Declared here |
e |
variable |
Declared here |
begin |
function |
Declared here |
end |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
iterator |
b |
|
iterator |
e |
b¶
Defined in include/teeny/iterate.h:209
e¶
Defined in include/teeny/iterate.h:209
Public Methods¶
| Return | Name | Description |
|---|---|---|
iterator |
begin const inline |
|
iterator |
end const inline |
begin¶
const inline
Defined in include/teeny/iterate.h:210
end¶
const inline
Defined in include/teeny/iterate.h:211
enum_iterator¶
Defined in include/teeny/iterate.h:227
List of all members¶
| Name | Kind | Owner |
|---|---|---|
it |
variable |
Declared here |
operator* |
function |
Declared here |
operator++ |
function |
Declared here |
operator!= |
function |
Declared here |
operator== |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
iterator |
it |
it¶
Defined in include/teeny/iterate.h:228
Public Methods¶
| Return | Name | Description |
|---|---|---|
item |
operator* const inline |
|
enum_iterator & |
operator++ inline |
|
bool |
operator!= const inline |
|
bool |
operator== const inline |
operator*¶
const inline
Defined in include/teeny/iterate.h:229
operator++¶
inline
Defined in include/teeny/iterate.h:230
operator!=¶
const inline
Defined in include/teeny/iterate.h:231
operator==¶
const inline
Defined in include/teeny/iterate.h:232
enum_range¶
Defined in include/teeny/dynamic.h:662
List of all members¶
| Name | Kind | Owner |
|---|---|---|
r |
variable |
Declared here |
begin |
function |
Declared here |
end |
function |
Declared here |
subrange |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
anyrank_front |
r |
r¶
Defined in include/teeny/dynamic.h:663
Public Methods¶
| Return | Name | Description |
|---|---|---|
enum_iterator |
begin const inline |
|
enum_iterator |
end const inline |
|
enum_subrange |
subrange const inline |
begin¶
const inline
Defined in include/teeny/dynamic.h:664
end¶
const inline
Defined in include/teeny/dynamic.h:665
subrange¶
const inline
Defined in include/teeny/dynamic.h:671
enum_subrange¶
Defined in include/teeny/dynamic.h:666
List of all members¶
| Name | Kind | Owner |
|---|---|---|
b |
variable |
Declared here |
e |
variable |
Declared here |
begin |
function |
Declared here |
end |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
enum_iterator |
b |
|
enum_iterator |
e |
b¶
Defined in include/teeny/dynamic.h:667
e¶
Defined in include/teeny/dynamic.h:667
Public Methods¶
| Return | Name | Description |
|---|---|---|
enum_iterator |
begin const inline |
|
enum_iterator |
end const inline |
begin¶
const inline
Defined in include/teeny/dynamic.h:668
end¶
const inline
Defined in include/teeny/dynamic.h:669
subrange_t¶
Defined in include/teeny/dynamic.h:629
A [lo, hi) slice of the batch cells for chunked/threaded sweeps: seed the incremental cursor once at lo, then O(1) per step.
Split [0, [size()](#size-2)) across threads/blocks; each sweeps its own chunk.
List of all members¶
| Name | Kind | Owner |
|---|---|---|
b |
variable |
Declared here |
e |
variable |
Declared here |
begin |
function |
Declared here |
end |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
iterator |
b |
|
iterator |
e |
b¶
Defined in include/teeny/dynamic.h:630
e¶
Defined in include/teeny/dynamic.h:630
Public Methods¶
| Return | Name | Description |
|---|---|---|
iterator |
begin const inline |
|
iterator |
end const inline |
begin¶
const inline
Defined in include/teeny/dynamic.h:631
end¶
const inline
Defined in include/teeny/dynamic.h:632
enum_iterator¶
Defined in include/teeny/dynamic.h:655
List of all members¶
| Name | Kind | Owner |
|---|---|---|
it |
variable |
Declared here |
operator* |
function |
Declared here |
operator++ |
function |
Declared here |
operator!= |
function |
Declared here |
operator== |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
iterator |
it |
it¶
Defined in include/teeny/dynamic.h:656
Public Methods¶
| Return | Name | Description |
|---|---|---|
item |
operator* const inline |
|
enum_iterator & |
operator++ inline |
|
bool |
operator!= const inline |
|
bool |
operator== const inline |
operator*¶
const inline
Defined in include/teeny/dynamic.h:657
operator++¶
inline
Defined in include/teeny/dynamic.h:658
operator!=¶
const inline
Defined in include/teeny/dynamic.h:659
operator==¶
const inline
Defined in include/teeny/dynamic.h:660
enum_subrange¶
Defined in include/teeny/iterate.h:238
List of all members¶
| Name | Kind | Owner |
|---|---|---|
b |
variable |
Declared here |
e |
variable |
Declared here |
begin |
function |
Declared here |
end |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
enum_iterator |
b |
|
enum_iterator |
e |
b¶
Defined in include/teeny/iterate.h:239
e¶
Defined in include/teeny/iterate.h:239
Public Methods¶
| Return | Name | Description |
|---|---|---|
enum_iterator |
begin const inline |
|
enum_iterator |
end const inline |
begin¶
const inline
Defined in include/teeny/iterate.h:240
end¶
const inline
Defined in include/teeny/iterate.h:241
enum_subrange¶
Defined in include/teeny/dynamic.h:666
List of all members¶
| Name | Kind | Owner |
|---|---|---|
b |
variable |
Declared here |
e |
variable |
Declared here |
begin |
function |
Declared here |
end |
function |
Declared here |
Public Attributes¶
| Return | Name | Description |
|---|---|---|
enum_iterator |
b |
|
enum_iterator |
e |
b¶
Defined in include/teeny/dynamic.h:667
e¶
Defined in include/teeny/dynamic.h:667
Public Methods¶
| Return | Name | Description |
|---|---|---|
enum_iterator |
begin const inline |
|
enum_iterator |
end const inline |
begin¶
const inline
Defined in include/teeny/dynamic.h:668
end¶
const inline
Defined in include/teeny/dynamic.h:669
Generated by Moxygen