Module Nx_array.Move
Movements.
Movements.
A movement maps the indices of a result to the indices of its argument: the result's element at an index is the argument's element at the mapped index. Movements are plain data, so code that records or lowers them shares one vocabulary, and equal movements, by structural equality, have equal maps. Their arrays are immutable, so a movement once built never changes.
The type for the elements start + j·step, j < count, of an axis.
The type for windows along axis: window w's element j is the axis's element w·step + j·dilation, j < size.
type t = - #
| Reshape of int iarray(*
*)Reshape s'has shapes'and the argument's elements in the same C order of indices: elementkin C order is the argument's elementkin C order. - #
| Broadcast of int iarray(*
*)Broadcast s'has shapes', which has at least the argument's rank. Aligned from the right, each extent of the argument is1ors''s; a new axis or an extent-1 one repeats the argument's elements along it. - #
| Permute of int iarray(*
*)Permute phas, as its axisi, the argument's axisp.(i), or a new axis of one element wherep.(i) < 0. Each axis of the argument thatpdoes not list has one element. The map is a bijection of elements, so it is a view: a permutation of the axes, and a squeeze or an unsqueeze that states which axes go and come. - #
| Slice of range iarray(*
*)Slice rskeeps the elementsrs.(i)of each axisi. A negative step reverses the axis. - #
| Window of window iarray(*
*)Window wshas, for each window ofws, on strictly increasing axes, its axis replaced by the number of windows,(d - 1 - dilation·(size - 1)) / step + 1of an axis of extentd, or0wheredilation·(size - 1) + 1exceedsd, and a trailing axis of extentsizeappended, in axis order. The result's element at(…, w, …, j)is the argument's element at(…, w·step + j·dilation, …).
The type for movements.
shape m s is the shape of the result of m on an argument of shape s.
Raises Invalid_argument if an extent of s is negative, if s or the result has extents other than 0 whose product exceeds Nx_array.Layout.max_numel, if the result has more than Nx_array.Layout.max_rank axes, or unless:
Reshape s':s''s extents are non-negative, their products's.Broadcast s':s''s extents are non-negative; it has at leasts's rank, and each extent ofsaligned from the right is1ors''s.Permute p:p's entries>= 0are distinct axes ofs, every axis ofsit does not list has extent1, and it has at mostNx_array.Layout.max_rankentries.Slice rs:rshas a range per axis, each withstep <> 0andcount >= 0; ifcount > 0,startandstart + (count - 1)·steplie in[0, d)for an axis of extentd.Window ws: each window's axis is an axis ofs, after the previous window's;size,stepanddilationare at least1.