Table of Contents

Class DirectILKernelGenerator

Namespace
NumSharp.Backends.Kernels
Assembly
NumSharp.dll

Binary operations (same-type) - contiguous kernels and generic helpers.

public static class DirectILKernelGenerator
Inheritance
DirectILKernelGenerator
Inherited Members

Fields

VectorBits

Detected vector width at startup: 512, 256, 128, or 0 (no SIMD).

public static readonly int VectorBits

Field Value

int

VectorBytes

Number of bytes per vector register.

public static readonly int VectorBytes

Field Value

int

Properties

Enabled

Whether IL generation is enabled. Can be disabled for debugging.

public static bool Enabled { get; set; }

Property Value

bool

Name

Provider name for diagnostics.

public static string Name { get; }

Property Value

string

Methods

Clip(NPTypeCode, ClipMode, ClipBoundsKind, void*, void*, long, void*, void*)

Run a clip operation. Picks (and on first call, IL-generates) the appropriate DynamicMethod for the (dtype, mode, kind) tuple and invokes it with the supplied pointers.

public static void Clip(NPTypeCode dtype, DirectILKernelGenerator.ClipMode mode, DirectILKernelGenerator.ClipBoundsKind kind, void* src, void* dst, long size, void* lo, void* hi)

Parameters

dtype NPTypeCode
mode DirectILKernelGenerator.ClipMode
kind DirectILKernelGenerator.ClipBoundsKind
src void*
dst void*
size long
lo void*
hi void*

GetAdjacentDiffKernel(NPTypeCode)

Get or generate the adjacent-difference (subtract) stencil kernel for dt. Returns null for Boolean (np.diff differences booleans with not_equal, not subtract) and whenever IL generation is disabled or the emitter rejects the dtype — the caller then falls back to the generic view-subtract path.

public static DirectILKernelGenerator.AdjacentDiffKernel GetAdjacentDiffKernel(NPTypeCode dt)

Parameters

dt NPTypeCode

Returns

DirectILKernelGenerator.AdjacentDiffKernel

GetArgwhereCountKernel(Type)

IL-emitted count of non-zero elements. Returns null only when Enabled is false — every supported dtype has a kernel (SIMD where Vector{T} exists, scalar IL via op_Inequality otherwise).

public static ArgwhereCountKernel GetArgwhereCountKernel(Type elementType)

Parameters

elementType Type

Returns

ArgwhereCountKernel

GetArgwhereExpandKernel()

IL-emitted coord expand (singleton — same kernel handles any ndim).

public static ArgwhereExpandKernel GetArgwhereExpandKernel()

Returns

ArgwhereExpandKernel

GetArgwhereFlatKernel(Type)

IL-emitted bit-scan that writes flat indices of non-zero elements into a pre-sized buffer.

public static ArgwhereFlatKernel GetArgwhereFlatKernel(Type elementType)

Parameters

elementType Type

Returns

ArgwhereFlatKernel

GetBinaryScalarDelegate(BinaryScalarKernelKey)

Get or generate an IL-based binary scalar delegate. Returns a Func<TLhs, TRhs, TResult> delegate.

public static Delegate GetBinaryScalarDelegate(BinaryScalarKernelKey key)

Parameters

key BinaryScalarKernelKey

Returns

Delegate

GetChooseFlatKernel(int, int)

IL-emitted flat choose kernel, cached per (element width, mode). Returns null only when Enabled is false.

public static ChooseFlatKernel GetChooseFlatKernel(int elemBytes, int mode)

Parameters

elemBytes int
mode int

Returns

ChooseFlatKernel

GetChooseStridedKernel(int, int)

IL-emitted strided choose kernel, cached per (element width, mode). Returns null only when Enabled is false.

public static ChooseStridedKernel GetChooseStridedKernel(int elemBytes, int mode)

Parameters

elemBytes int
mode int

Returns

ChooseStridedKernel

GetComparisonKernel(ComparisonKernelKey)

Get or generate a comparison kernel for the specified key.

public static ComparisonKernel GetComparisonKernel(ComparisonKernelKey key)

Parameters

key ComparisonKernelKey

Returns

ComparisonKernel

GetComparisonScalarDelegate(ComparisonScalarKernelKey)

Get or generate a comparison scalar delegate. Returns a Func<TLhs, TRhs, bool> delegate.

public static Delegate GetComparisonScalarDelegate(ComparisonScalarKernelKey key)

Parameters

key ComparisonScalarKernelKey

Returns

Delegate

GetCopyKernel(CopyKernelKey)

public static CopyKernel GetCopyKernel(CopyKernelKey key)

Parameters

key CopyKernelKey

Returns

CopyKernel

GetCumulativeKernel(CumulativeKernelKey)

Get or generate a cumulative (scan) kernel. Returns a delegate that computes running accumulation over all elements.

public static CumulativeKernel GetCumulativeKernel(CumulativeKernelKey key)

Parameters

key CumulativeKernelKey

Returns

CumulativeKernel

GetDiagWriteKernel(int)

IL-emitted diagonal-write kernel for a given copy-width (copyKind — the CopyKindFor(long) of the dtype itemsize; always 1/2/4/8/16 for real dtypes, so the store is a typed MOV rather than a per-element cpblk). Returns null when Enabled is false or emission fails, so callers can fall back to the SetData path.

public static DiagWriteKernel GetDiagWriteKernel(int copyKind)

Parameters

copyKind int

Returns

DiagWriteKernel

GetFilterAxisKernel(long)

IL-emitted kernel cached by innerSize. Pass the actual innerSize you'll use at call time; the function buckets {1,2,4,8,16} into typed-copy variants and anything else into the bulk-cpblk variant. Returns null only when Enabled is false.

public static FilterAxisKernel GetFilterAxisKernel(long innerSize)

Parameters

innerSize long

Returns

FilterAxisKernel

GetGemvKernel(NPTypeCode)

Get the matrix·vector (gemv) kernel for dt, or null when out of scope (only Single / Double — the dtypes NumPy routes through cblas gemv), IL/SIMD unavailable, or Vector256 not hardware accelerated. A null return routes the caller back to the general GEMM.

public static DirectILKernelGenerator.GemvKernel GetGemvKernel(NPTypeCode dt)

Parameters

dt NPTypeCode

Returns

DirectILKernelGenerator.GemvKernel

GetGramKernel(NPTypeCode)

Get the symmetric-Gram kernel for dt, or null when the dtype is outside scope (only Single / Double are served — cov's real result dtypes), IL/SIMD is unavailable, or Vector256 is not hardware accelerated. A null return routes the caller back to np.dot.

public static DirectILKernelGenerator.GramKernel GetGramKernel(NPTypeCode dt)

Parameters

dt NPTypeCode

Returns

DirectILKernelGenerator.GramKernel

GetIndicesKernel()

IL-emitted indices fill kernel (singleton — same kernel handles any ndim). Returns null only when Enabled is false.

public static IndicesKernel GetIndicesKernel()

Returns

IndicesKernel

GetMixedTypeKernel(MixedTypeKernelKey)

Get or generate a mixed-type kernel for the specified key.

public static MixedTypeKernel GetMixedTypeKernel(MixedTypeKernelKey key)

Parameters

key MixedTypeKernelKey

Returns

MixedTypeKernel

GetNonZeroPerDimKernel()

IL-emitted per-dim coord expander (singleton — same kernel handles any ndim). Returns null only when Enabled is false.

public static NonZeroPerDimKernel GetNonZeroPerDimKernel()

Returns

NonZeroPerDimKernel

GetPlaceKernel(int)

IL-emitted place kernel, generated once per copy-width (copyKind — the CopyKindFor(long) of the dtype itemsize; always 1/2/4/8/16 for real dtypes, so the masked write is a typed MOV rather than a per-element cpblk). Returns null only when Enabled is false.

public static PlaceKernel GetPlaceKernel(int copyKind)

Parameters

copyKind int

Returns

PlaceKernel

GetPredicateContiguousKernel(UnaryOp, NPTypeCode)

Dedicated SIMD contiguous kernel for the float-classification predicates (IsNan / IsInf / IsFinite) over Single / Double input — the port of NumPy's vectorized loops_unary_fp_le.dispatch.c.src loops (npyv_pack_isnan/isinf/isfinite).

The general unary route cannot vectorize these: its SIMD gate (CanUseUnarySimd(UnaryKernelKey)) requires input dtype == output dtype and a predicate is inherently float→bool, so IsNan/IsInf/IsFinite fell to a per-element scalar walk (measured 40.6 µs vs NumPy's 4.1 µs on 100K float32 isnan). Lane logic per vector, all in the float domain so no reinterpret casts are needed: isnan: NOT Equals(v, v) — NaN is the only self-unequal value isinf: Equals(Abs(v), +inf) — Abs(NaN) is NaN, NaN == inf is false isfinite: LessThan(Abs(v), +inf) — NaN < inf is false, inf < inf is false then the comparison kernels' mask→bool store (ExtractMostSignificantBits + BMI2 PDEP → one sized store per vector, per-lane fallback without BMI2).

Returns null when the (op, dtype) pair is outside this kernel's scope — integer/Half/Complex inputs keep the existing scalar routes (NumPy's own HALF/CFLOAT predicate loops are scalar too), and callers fall back to GetUnaryKernel(UnaryKernelKey).

public static UnaryKernel? GetPredicateContiguousKernel(UnaryOp op, NPTypeCode inputType)

Parameters

op UnaryOp
inputType NPTypeCode

Returns

UnaryKernel

GetPredicateStridedKernel(UnaryOp, NPTypeCode)

Fused strided kernel for IsNan/IsInf/IsFinite over a 1-D strided (stepped / reversed / offset) Single/Double source writing a fresh contiguous bool result — NumPy's simd_unary_KIND_TYPE_NCONTIG_CONTIG shape: each vector is assembled from lanes strided scalar loads (CreateElements(int, Type), the npyv_loadn equivalent NumPy prefers over hardware gather for these cheap lane ops), the predicate mask applied, and the bools stored via the PDEP pack. Replaces the scalar gather-to-tile route, which paid ~1 ns/element on the gather alone (70 µs vs NumPy's 4.9 µs on a 50K stride-2 isnan). Same (op, dtype) gates as GetPredicateContiguousKernel(UnaryOp, NPTypeCode).

public static StridedUnaryKernel? GetPredicateStridedKernel(UnaryOp op, NPTypeCode inputType)

Parameters

op UnaryOp
inputType NPTypeCode

Returns

StridedUnaryKernel

GetPutFlatKernel(int, bool)

The flat scatter kernel for one element width and index width; null under the same conditions as GetTakeFlatKernel(int, bool, bool).

public static PutFlatKernel GetPutFlatKernel(int copyKind, bool idx32)

Parameters

copyKind int
idx32 bool

Returns

PutFlatKernel

GetPutKernel(int)

IL-emitted put kernel, generated once per copy-width (copyKind — the CopyKindFor(long) of the dtype itemsize; always 1/2/4/8/16 for real dtypes, so the scatter copy is a typed MOV rather than a per-element cpblk). Handles any mode. Returns null only when Enabled is false.

public static PutKernel GetPutKernel(int copyKind)

Parameters

copyKind int

Returns

PutKernel

GetPutKernel(int, bool)

As GetPutKernel(int), with the index width selectable: idx32 generates a kernel that reads the indices argument as int32 values (the delegate still types the pointer long* — the caller reinterprets its int*), so an int32 index array is scattered in place instead of widened to an int64 copy first.

public static PutKernel GetPutKernel(int copyKind, bool idx32)

Parameters

copyKind int
idx32 bool

Returns

PutKernel

GetRavelMultiIndexKernel()

IL-emitted multi→flat folder (singleton — same kernel handles any ndim, both orders, and arbitrary per-axis mode tuples). Returns null only when Enabled is false.

public static RavelMultiIndexKernel GetRavelMultiIndexKernel()

Returns

RavelMultiIndexKernel

GetRepeatBroadcastKernel(int)

Returns the cached IL-emitted broadcast-repeat kernel for the given slab size. First call for a size triggers IL generation, later calls hit a dictionary lookup.

public static DirectILKernelGenerator.RepeatBroadcastKernel GetRepeatBroadcastKernel(int chunkBytes)

Parameters

chunkBytes int

Returns

DirectILKernelGenerator.RepeatBroadcastKernel

GetRepeatPerJKernel(int)

Returns the cached IL-emitted per-j repeat kernel for the given slab size.

public static DirectILKernelGenerator.RepeatPerJKernel GetRepeatPerJKernel(int chunkBytes)

Parameters

chunkBytes int

Returns

DirectILKernelGenerator.RepeatPerJKernel

GetSearchSortedKernel(NPTypeCode, bool, bool, bool)

Get or generate a searchsorted kernel.

public static DirectILKernelGenerator.SearchSortedKernel GetSearchSortedKernel(NPTypeCode type, bool leftSide, bool hasSorter, bool contiguousA)

Parameters

type NPTypeCode

Element dtype of a (and contiguous v, after caller normalizes).

leftSide bool

true = side='left', false = side='right'.

hasSorter bool

true = sorter param non-null (kernel emits sort_idx indirection).

contiguousA bool

true = a is contiguous (arrStrideBytes == elemSize). Lets JIT use scaled-index addressing instead of imul, which closes the gap to NumPy on the random-key hot path. When false, arrStrideBytes is honored as a runtime parameter.

Returns

DirectILKernelGenerator.SearchSortedKernel

GetSelectKernel(NPTypeCode, int, bool)

Get or generate a fused select kernel for (dtype, n conditions, defScalar). Returns null if IL generation is disabled or the dtype is not SIMD-eligible for this kernel (the caller then uses the composition).

public static SelectFusedKernel GetSelectKernel(NPTypeCode dtype, int n, bool defScalar)

Parameters

dtype NPTypeCode
n int
defScalar bool

Returns

SelectFusedKernel

GetShiftArrayKernel<T>(bool)

Get or generate a shift kernel for element-wise shift amounts.

public static DirectILKernelGenerator.ShiftArrayKernel<T>? GetShiftArrayKernel<T>(bool isLeftShift) where T : unmanaged

Parameters

isLeftShift bool

True for left shift, false for right shift

Returns

DirectILKernelGenerator.ShiftArrayKernel<T>

Kernel delegate or null if not supported

Type Parameters

T

Integer element type

GetShiftScalarKernel<T>(bool)

Get or generate a SIMD-optimized shift kernel for uniform shift amount.

public static DirectILKernelGenerator.ShiftScalarKernel<T>? GetShiftScalarKernel<T>(bool isLeftShift) where T : unmanaged

Parameters

isLeftShift bool

True for left shift, false for right shift

Returns

DirectILKernelGenerator.ShiftScalarKernel<T>

Kernel delegate or null if not supported

Type Parameters

T

Integer element type

GetStridedUnaryKernel(UnaryKernelKey)

Get or generate a fused strided-SIMD unary kernel for the given key. Gating (same-width SIMD-capable op, supported dtype) is the caller's responsibility.

public static StridedUnaryKernel GetStridedUnaryKernel(UnaryKernelKey key)

Parameters

key UnaryKernelKey

Returns

StridedUnaryKernel

GetTakeAlongAxisKernel(int)

IL-emitted take_along_axis gather kernel, cached per element width (elemBytes ∈ {1,2,4,8,16}). Returns null only when Enabled is false.

public static TakeAlongAxisKernel GetTakeAlongAxisKernel(int elemBytes)

Parameters

elemBytes int

Returns

TakeAlongAxisKernel

GetTakeFlatKernel(int, bool, bool)

The flat gather kernel for one element width (copyKind ∈ {1,2,4,8,16}; the CopyKindFor(long) of the per-index slab) and index width. null when runtime IL generation is unavailable or the slab is not a single primitive width (copyKind 0 — the general TakeKernel serves those with cpblk).

public static TakeFlatKernel GetTakeFlatKernel(int copyKind, bool idx32, bool prefetch)

Parameters

copyKind int
idx32 bool
prefetch bool

Returns

TakeFlatKernel

GetTakeKernel(int, bool)

IL-emitted take kernel, generated once per (copy-width, prefetch) pair. copyKind is the CopyKindFor(long) of the per-index slab size (1/2/4/8/16 for a typed MOV copy, 0 for a runtime-sized cpblk); prefetch emits the software-prefetch inner body (a large-source win, a small-source pessimization — the caller gates it on the gathered region exceeding cache). One kernel handles any ndim, both axis=None and axis=k. Returns null only when Enabled is false.

public static TakeKernel GetTakeKernel(int copyKind, bool prefetch)

Parameters

copyKind int
prefetch bool

Returns

TakeKernel

GetTakeKernel(int, bool, bool)

As GetTakeKernel(int, bool), with the index width selectable: idx32 generates a kernel that reads the indices argument as int32 values (the pointer is still typed long* by the delegate — the caller reinterprets its int*), so an int32 index array is gathered in place instead of being widened to a temporary int64 copy first.

public static TakeKernel GetTakeKernel(int copyKind, bool prefetch, bool idx32)

Parameters

copyKind int
prefetch bool
idx32 bool

Returns

TakeKernel

GetTraceAccumTypeCode(NPTypeCode)

Maps src NPTypeCode → (result NPTypeCode, supported). Convenience for callers that already have the type-code.

public static (NPTypeCode, bool) GetTraceAccumTypeCode(NPTypeCode src)

Parameters

src NPTypeCode

Returns

(NPTypeCode, bool)

GetTraceKernel(Type)

IL-emitted singleton per srcType. Returns null when the dtype has no kernel (no triples are unsupported in the current implementation; the field exists for graceful future expansion).

public static TraceKernel GetTraceKernel(Type srcType)

Parameters

srcType Type

Returns

TraceKernel

GetTypedElementReductionKernel<TResult>(ElementReductionKernelKey)

Get or generate a typed element-wise reduction kernel. Returns a delegate that reduces all elements to a single value of type TResult.

public static TypedElementReductionKernel<TResult> GetTypedElementReductionKernel<TResult>(ElementReductionKernelKey key) where TResult : unmanaged

Parameters

key ElementReductionKernelKey

Returns

TypedElementReductionKernel<TResult>

Type Parameters

TResult

GetUnaryKernel(UnaryKernelKey)

Get or generate a unary kernel for the specified key.

public static UnaryKernel GetUnaryKernel(UnaryKernelKey key)

Parameters

key UnaryKernelKey

Returns

UnaryKernel

GetUnaryScalarDelegate(UnaryScalarKernelKey)

Get or generate an IL-based unary scalar delegate. Returns a Func<TInput, TOutput> delegate.

public static Delegate GetUnaryScalarDelegate(UnaryScalarKernelKey key)

Parameters

key UnaryScalarKernelKey

Returns

Delegate

GetUnravelIndexKernel()

IL-emitted unravel kernel (singleton — same kernel handles any ndim and both C / F order via the runtime idxStart / idxStep args). Returns null only when Enabled is false.

public static UnravelIndexKernel GetUnravelIndexKernel()

Returns

UnravelIndexKernel

GetWeightedSumIterKernel(WeightedSumKernelKey)

Returns the cached IL-emitted weighted-sum kernel for the given dtype, or null if the dtype isn't supported (Bool/Char/Half/Complex/Decimal). The kernel signature matches NDInnerLoopFunc; pass it to NDIter.ForEach over the 4-operand [a, w, num_out, scl_out] iterator.

public static NDInnerLoopFunc? GetWeightedSumIterKernel(DirectILKernelGenerator.WeightedSumKernelKey key)

Parameters

key DirectILKernelGenerator.WeightedSumKernelKey

Returns

NDInnerLoopFunc

GetWhereKernel<T>()

Get or generate an IL-based where kernel for the specified type. Returns null if IL generation is disabled or fails.

public static WhereKernel<T>? GetWhereKernel<T>() where T : unmanaged

Returns

WhereKernel<T>

Type Parameters

T

GetWhereScalarXKernel<T>()

public static WhereScalarXKernel<T> GetWhereScalarXKernel<T>() where T : unmanaged

Returns

WhereScalarXKernel<T>

Type Parameters

T

GetWhereScalarXYKernel<T>()

public static WhereScalarXYKernel<T> GetWhereScalarXYKernel<T>() where T : unmanaged

Returns

WhereScalarXYKernel<T>

Type Parameters

T

GetWhereScalarYKernel<T>()

public static WhereScalarYKernel<T> GetWhereScalarYKernel<T>() where T : unmanaged

Returns

WhereScalarYKernel<T>

Type Parameters

T

ModfHelper(double*, double*, long)

SIMD-optimized Modf operation for contiguous double arrays. Computes fractional and integral parts in-place. Handles special values (NaN, Inf) according to C standard modf.

public static void ModfHelper(double* data, double* integral, long size)

Parameters

data double*

Input array (will contain fractional parts after)

integral double*

Output array for integral parts

size long

Number of elements

ModfHelper(float*, float*, long)

SIMD-optimized Modf operation for contiguous float arrays. Computes fractional and integral parts in-place. Handles special values (NaN, Inf) according to C standard modf.

public static void ModfHelper(float* data, float* integral, long size)

Parameters

data float*

Input array (will contain fractional parts after)

integral float*

Output array for integral parts

size long

Number of elements

NanToNum(NPTypeCode, void*, void*, long, void*, void*, void*)

Run a nan_to_num pass. Picks (and on first call IL-generates) the kernel for dtype (Half/Single/Double) and invokes it.

public static void NanToNum(NPTypeCode dtype, void* src, void* dst, long size, void* nan, void* posinf, void* neginf)

Parameters

dtype NPTypeCode
src void*
dst void*
size long
nan void*
posinf void*
neginf void*

Quantile(NPTypeCode, NPTypeCode, QuantileMethod, void*, void*, long, int, int*, int, double*, int, void*, long, bool, int*)

Run the cached quantile kernel for the given dtype triple. First call for a tuple emits and caches the DynamicMethod; later calls jump straight into the specialized native code.

public static void Quantile(NPTypeCode srcType, NPTypeCode outType, QuantileMethod method, void* srcBase, void* scratchBase, long outer, int n, int* kSorted, int nKs, double* q, int nQs, void* dstBase, long dstOuterStride, bool ignoreNaN = false, int* rowKScratch = null)

Parameters

srcType NPTypeCode
outType NPTypeCode
method QuantileMethod
srcBase void*
scratchBase void*
outer long
n int
kSorted int*
nKs int
q double*
nQs int
dstBase void*
dstOuterStride long
ignoreNaN bool
rowKScratch int*

SelectKernelSupportsDtype(NPTypeCode)

True when the fused select kernel supports dtype — the 1/2/4/8-byte numeric dtypes. Everything else stays on the copyto composition.

public static bool SelectKernelSupportsDtype(NPTypeCode dtype)

Parameters

dtype NPTypeCode

Returns

bool

TryGetAxisReductionKernel(AxisReductionKernelKey)

Try to get an axis reduction kernel. Supports all reduction operations and all types including type promotion. Uses SIMD for capable types, scalar loop for others.

public static AxisReductionKernel? TryGetAxisReductionKernel(AxisReductionKernelKey key)

Parameters

key AxisReductionKernelKey

Returns

AxisReductionKernel

TryGetBooleanAxisReductionKernel(AxisReductionKernelKey)

Try to get a boolean axis reduction kernel (All / Any). Returns null for non-SIMD-capable dtypes (Half, Complex, Decimal, Char) so the caller can fall back to the NDAxisIter scalar path.

public static AxisReductionKernel? TryGetBooleanAxisReductionKernel(AxisReductionKernelKey key)

Parameters

key AxisReductionKernelKey

Returns

AxisReductionKernel

TryGetCastKernel(NPTypeCode, NPTypeCode)

Get or generate a contig cast kernel for the given pair. Returns null for unsupported pairs (Boolean/Char/Half/Complex/Decimal involved).

public static DirectILKernelGenerator.CastKernel TryGetCastKernel(NPTypeCode srcType, NPTypeCode dstType)

Parameters

srcType NPTypeCode
dstType NPTypeCode

Returns

DirectILKernelGenerator.CastKernel

TryGetCopyKernel(CopyKernelKey)

public static CopyKernel? TryGetCopyKernel(CopyKernelKey key)

Parameters

key CopyKernelKey

Returns

CopyKernel

TryGetCumulativeAxisKernel(CumulativeAxisKernelKey)

Try to get or generate a cumulative axis kernel.

public static CumulativeAxisKernel? TryGetCumulativeAxisKernel(CumulativeAxisKernelKey key)

Parameters

key CumulativeAxisKernelKey

Returns

CumulativeAxisKernel

TryGetCumulativeKernel(CumulativeKernelKey)

Try to get or generate a cumulative kernel.

public static CumulativeKernel? TryGetCumulativeKernel(CumulativeKernelKey key)

Parameters

key CumulativeKernelKey

Returns

CumulativeKernel

TryGetInnerCastKernel(NPTypeCode, NPTypeCode)

Get or emit the scalar inner-loop cast kernel for the pair. Non-null for every dtype pair (all 225 Converts.To{Dst}({Src}) methods exist); returns null only if IL generation is disabled or a method unexpectedly fails to resolve.

public static DirectILKernelGenerator.InnerCastLoop TryGetInnerCastKernel(NPTypeCode srcType, NPTypeCode dstType)

Parameters

srcType NPTypeCode
dstType NPTypeCode

Returns

DirectILKernelGenerator.InnerCastLoop

TryGetMaskedCastKernel(NPTypeCode, NPTypeCode)

Get or generate a masked-cast kernel for the given (src, dst) pair. Returns null for unsupported pairs (Boolean/Char/Half/Complex/Decimal involved).

public static DirectILKernelGenerator.MaskedCastKernel TryGetMaskedCastKernel(NPTypeCode srcType, NPTypeCode dstType)

Parameters

srcType NPTypeCode
dstType NPTypeCode

Returns

DirectILKernelGenerator.MaskedCastKernel

TryGetNanAxisReductionKernel(AxisReductionKernelKey)

Try to get a NaN-aware axis reduction kernel. SIMD kernels exist only for float/double; Half and Complex route to scalar fallback paths (Default.Reduction.Nan.cs ExecuteNanAxisReductionScalar / np.nanmean.cs / np.nanvar.cs / np.nanstd.cs) which handle them directly.

public static AxisReductionKernel? TryGetNanAxisReductionKernel(AxisReductionKernelKey key)

Parameters

key AxisReductionKernelKey

Returns

AxisReductionKernel

TryGetStridedCastKernel(NPTypeCode, NPTypeCode)

Get or generate a strided/broadcast cast kernel for the given pair. Returns null for unsupported pairs.

public static DirectILKernelGenerator.StridedCastKernel TryGetStridedCastKernel(NPTypeCode srcType, NPTypeCode dstType)

Parameters

srcType NPTypeCode
dstType NPTypeCode

Returns

DirectILKernelGenerator.StridedCastKernel

TryGetTypedElementReductionKernel<TResult>(ElementReductionKernelKey)

Try to get or generate an element reduction kernel.

public static TypedElementReductionKernel<TResult>? TryGetTypedElementReductionKernel<TResult>(ElementReductionKernelKey key) where TResult : unmanaged

Parameters

key ElementReductionKernelKey

Returns

TypedElementReductionKernel<TResult>

Type Parameters

TResult

WhereExecute<T>(bool*, T*, T*, T*, long)

Execute where operation using IL-generated kernel or fallback to static helper.

public static void WhereExecute<T>(bool* cond, T* x, T* y, T* result, long count) where T : unmanaged

Parameters

cond bool*
x T*
y T*
result T*
count long

Type Parameters

T