mirror of https://github.com/llvm/torch-mlir
d49eabb3fc
# Description Implementation of the op for `torch.aten.unfold`: [TorchToLinalg Op Support #347](https://github.com/nod-ai/SHARK-ModelDev/issues/849) Documentation of op can be found here: [PyTorch Docs](https://pytorch.org/docs/stable/generated/torch.Tensor.unfold.html) For this op, we apply a sliding window of some `size` along a single `dimension`, with `step` in between iterations. `Declaration: aten::unfold(Tensor(a) self, int dimension, int size, int step) -> Tensor(a)` The resulting `unfolded` tensor modifies the shape of `dimension` to be equal to the number of blocks that the sliding windows extracts/inserts, with an additional dimension of `size` appended (the number of cols of the output tensor directly translates from the size of the sliding window). So if we had a tensor of rank 3 (A x B x C), with dimension = 1, size = 2 and step = 2: (A x B x C) |=> (A x (B - size) // step + 1 x C x size) After extracting the window from the input tensor, we insert the (1 x size) slice into the output tensor. We can make this simpler by mapping the output indices from the input indices, like they do in the official implementation: [PyTorch Code](https://github.com/pytorch/pytorch/blob/main/torch/_inductor/lowering.py#L1694) |
||
---|---|---|
.. | ||
CMakeLists.txt | ||
DataMovement.cpp | ||
IndirectDataMovement.cpp | ||
Linear.cpp | ||
Pooling.cpp | ||
PopulatePatterns.h | ||
Random.cpp | ||
Reduction.cpp | ||
TensorConstructors.cpp | ||
TensorScalarInterop.cpp | ||
TorchToLinalg.cpp | ||
Uncategorized.cpp | ||
Utils.cpp |