Table of Contents

Class StrideDetector

Namespace
NumSharp.Backends.Kernels
Assembly
NumSharp.dll

Stride-based pattern detection for selecting optimal SIMD execution paths. All methods are aggressively inlined for minimal dispatch overhead.

public static class StrideDetector
Inheritance
StrideDetector
Inherited Members

Methods

CanSimdChunk<T>(int*, int*, int*, int)

Check if inner dimension is suitable for SIMD chunking. Returns true if both operands have inner stride of 1 (contiguous) or 0 (broadcast).

public static bool CanSimdChunk<T>(int* lhsStrides, int* rhsStrides, int* shape, int ndim) where T : unmanaged

Parameters

lhsStrides int*
rhsStrides int*
shape int*
ndim int

Returns

bool

Type Parameters

T

Classify<T>(int*, int*, int*, int)

Classify the binary operation into an execution path based on stride analysis. Classification priority:

  1. SimdFull - both fully contiguous (fastest)
  2. SimdScalarRight/Left - one operand is scalar
  3. SimdChunk - inner dimension is contiguous/broadcast
  4. General - fallback for arbitrary strides
public static ExecutionPath Classify<T>(int* lhsStrides, int* rhsStrides, int* shape, int ndim) where T : unmanaged

Parameters

lhsStrides int*
rhsStrides int*
shape int*
ndim int

Returns

ExecutionPath

Type Parameters

T

IsContiguous(int*, int*, int)

Check if array is fully contiguous (C-order). An array is contiguous if strides match expected C-order values: strides[n-1] = 1, strides[i] = strides[i+1] * shape[i+1]

public static bool IsContiguous(int* strides, int* shape, int ndim)

Parameters

strides int*
shape int*
ndim int

Returns

bool

IsScalar(int*, int)

Check if array is a scalar (all strides are zero). A scalar is broadcast to any shape - each element accesses the same value.

public static bool IsScalar(int* strides, int ndim)

Parameters

strides int*
ndim int

Returns

bool