overlap#

Create an overlapping view an of input operator giving a higher-rank view of the input

For example, the following 1D tensor [1 2 3 4 5] could be cloned into a 2d tensor with a window size of 2 and overlap of 1, resulting in:

[1 2
 2 3
 3 4
 4 5]

Currently this only works on 1D tensors going to 2D, but may be expanded for higher dimensions in the future. Note that if the window size does not divide evenly into the existing column dimension, the view may chop off the end of the data to make the tensor rectangular.

Note

Only 1D input operators are accepted at this time

template<typename OpType, int N>
__MATX_INLINE__ auto matx::overlap(const OpType &op, const index_t (&windows)[N], const index_t (&strides)[N])#
template<typename OpType, int N>
__MATX_INLINE__ auto matx::overlap(const OpType &op, const std::array<index_t, N> &windows, const std::array<index_t, N> &strides)#

Create an overlapping tensor view.

Creates an overlapping tensor view where an existing tensor can be repeated into a higher rank with overlapping elements. For example, the following 1D tensor [1 2 3 4 5] could be cloned into a 2d tensor with a window size of 2 and overlap of 1, resulting in:

 [1 2
  2 3
  3 4
  4 5]
Currently this only works on 1D tensors going to 2D, but may be expanded for higher dimensions in the future. Note that if the window size does not divide evenly into the existing column dimension, the view may chop off the end of the data to make the tensor rectangular.

Template Parameters:
  • OpType – Type of operator input

  • N – Rank of overlapped window

Parameters:
  • op – input operator

  • windows – Window size (columns in output)

  • strides – Strides between data elements

Returns:

Overlapping view of data

Examples#

auto aop = linspace<0>(a.Shape(), (TestType)0, (TestType)9);
tensor_t<TestType, 2> b4out{{4, 3}};

// Input is {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
// Output is: {{0, 1, 2}, {2, 3, 4}, {4, 5, 6}, {6, 7, 8}}
(b4out = overlap(aop, {3}, {2})).run(exec);