heat icon indicating copy to clipboard operation
heat copied to clipboard

Features/1400 implement unfold operation similar to torch tensor unfold

Open FOsterfeld opened this issue 10 months ago • 30 comments

Due Diligence

  • General:
  • Implementation:
    • [x] unit tests: all split configurations tested
    • [x] unit tests: multiple dtypes tested
    • [x] documentation updated where needed

Description

Add the function unfold to the available manipulations. unfold(a, dimension, size, step) for a DNDarray a behaves like torch.Tensor.unfold.

Example:

>>> x = ht.arange(1., 8)
>>> x
DNDarray([1., 2., 3., 4., 5., 6., 7.], dtype=ht.float32, device=cpu:0, split=e)
>>> ht.unfold(x, 0, 2, 1)
DNDarray([[1., 2.],
          [2., 3.],
          [3., 4.],
          [4., 5.],
          [5., 6.],
          [6., 7.]], dtype=ht.float32, device=cpu:0, split=None)
>>> ht.unfold(x, 0, 2, 2)
DNDarray([[1., 2.],
          [3., 4.],
          [5., 6.]], dtype=ht.float32, device=cpu:0, split=None)

Issue/s resolved: #1400

Changes proposed:

Type of change

  • New feature (non-breaking change which adds functionality)

Memory requirements

Performance

Does this change modify the behaviour of other functions? If so, which?

no

FOsterfeld avatar Apr 02 '24 14:04 FOsterfeld