Procs
proc export_tensor[T](t: Tensor[T]): tuple[shape: seq[int], strides: seq[int], data: seq[T]] {.noSideEffect.}
-
Export the tensor as a tuple containing
- shape
- strides
- data
If the tensor was not contiguous (a slice for example), it is reshaped. Data is exported in C order (last index changes the fastest, column in 2D case)
Source Edit proc toRawSeq[T](t: Tensor[T]): seq[T] {.noSideEffect, ...deprecated: "This proc cannot be reimplemented in a backward compatible way.".}
-
Convert a tensor to the raw sequence of data. Important: Up to v0.6.0, Arraymancer always took full ownership of the data it operated on. In particular, even after slicing, it kept tracked of the full memory allocated initially.
This proc used to return the raw in-memory representation of the data without reshaping due to views/slices and offsets This is not true anymore.
It instead returns the canonical row-major serialization of the data.
It is recommended that you implement your own serialization using Arraymancer's unsafe_raw_buf + shape + strides + offset or that you raise your use-case in the issue tracker https://github.com/mratsim/Arraymancer/issues so that more suitable primitives can be crafted
Source Edit