GenericTensor icon indicating copy to clipboard operation
GenericTensor copied to clipboard

`Iterate` to return state machine object

Open WhiteBlackGoose opened this issue 3 years ago • 1 comments

It currently returns IEnumerable, which has a virtual call. We can make it much faster by writing a value type state machine (foreach does not force IEnumerable).

WhiteBlackGoose avatar Jun 04 '22 14:06 WhiteBlackGoose

For internal API there should be an indexing state machine which would work like this:

Span<int> id = stackalloc[shape.Length];
var indexMachine = new IndexIterator(id);
while (indexMachine.Move())
{
    myTensor[id] = myTensor[id];
}

WhiteBlackGoose avatar Jun 04 '22 14:06 WhiteBlackGoose