Enum NDIterFlags
Iterator-level flags. Conceptually matches NumPy's NPY_ITFLAG_* constants.
NOTE: Bit positions differ from NumPy's implementation:
- NumPy uses bits 0-7 for IDENTPERM, NEGPERM, HASINDEX, etc.
- NumSharp reserves bits 0-7 for legacy compatibility flags (SourceBroadcast, SourceContiguous, DestinationContiguous)
- NumPy-equivalent flags are shifted to bits 8-15
This layout maintains backward compatibility with existing NumSharp code while adding NumPy parity flags. The semantic meaning of each flag matches NumPy, only the bit positions differ.
[Flags]
public enum NDIterFlags : uint
Fields
None = 0SourceBroadcast = 1Source operand has broadcast dimensions (stride=0).
SourceContiguous = 2Source operand is contiguous after coalescing.
DestinationContiguous = 4Destination operand is contiguous after coalescing.
IDENTPERM = 256The axis permutation is identity.
NEGPERM = 512The permutation has negative entries (flipped axes).
HASINDEX = 1024Iterator is tracking a flat index.
HASMULTIINDEX = 2048Iterator is tracking a multi-index.
FORCEDORDER = 4096Iteration order was forced on construction.
EXLOOP = 8192Inner loop is handled outside the iterator.
RANGE = 16384Iterator is ranged (subset iteration).
BUFFER = 32768Iterator uses buffering.
GROWINNER = 65536Grow the buffered inner loop when possible.
ONEITERATION = 131072Single iteration, can specialize iternext.
DELAYBUF = 262144Delay buffer allocation until first Reset.
REDUCE = 524288Iteration includes reduction operands.
REUSE_REDUCE_LOOPS = 1048576Reduce loops don't need recalculation.
BUFREDUCE = 2097152The buffered iteration runs NumPy's reduce DOUBLE LOOP:
npyiter_find_buffering_setupchose the outer reduce dimension as the core / outer split, so each buffer fill is walked as up to ReduceOuterSize inner loops of CoreSize elements, the pointers stepping by ReduceOuterStrides between them (npyiter_buffered_reduce_iternext).This is what NumPy's
NPY_ITFLAG_REDUCEmeans AFTER the buffering setup, which clears that flag when the chosen split does not use the reduce loop. NumSharp keeps REDUCE as the construction's answer ("an operand is reduced") because IsReduction, the parallel-safety decision and IsFirstVisit(int) read it, and records the setup's answer here. Set only together with BUFFER.CONTIGUOUS = 8All operands are contiguous (SIMD eligible).
GATHER_ELIGIBLE = 16Can use AVX2 gather for strided access.
PARALLEL_SAFE = 64The iteration range can be split across parallel workers without write hazards. Set at construction when there is no REDUCE operand (cross-iteration accumulation on a shared slot) and either no WRITE operands at all, or exactly one WRITE operand whose potential overlap with the inputs was resolved by COPY_IF_OVERLAP processing (forced copy + write-back on Dispose). Consumed by the parallel ForEach work (roadmap Wave 6.2).