[Feature Request]: Allocation-free ToArray(Array destination) method
Background and Feature Description
When evaluating sequential data, often we split large sequences into batches to be processed by a model. Combining batches back into a sequence requires multiple results.ToArray
API Definition and Usage
Add an extension method overload to the ToArray() method that allows passing in an existing Array to copy the data to
public static void ToArray<float>(this NDArray array, Array destination, long destinationIndex, long destinationLength)
Alternatives
No response
Risks
No response
How large the destination will be?
NDArray has a data property, maybe you can utilize the IntPtr type.
destination will be whatever size you want it to be, you initialise it externally then pass it to the function to get filled. The idea is the API is very similar to Array.Copy().
Do you know if using the IntPtr respects any slicing operations? For example at the moment, I read data from a slice of the last dimension:
var slice = result[Slice.ParseSlices(":, :, 0")]
will Marshal.Copy(slice.data, ...) respect that?