expand
torch_to_nnef.op.aten.expand
expand
Translate operator aten::expand
to NNEF.
Illustration of expand:. torch.arange(9).reshape(3, 3).expand(2, 3, 3)
Out[4]:
tensor([[[0, 1, 2],
[3, 4, 5],
[6, 7, 8]],
[[0, 1, 2],
[3, 4, 5],
[6, 7, 8]]])
which can be re-expressed as
torch.arange(9).reshape(3, 3).repeat(2).reshape(2, 3, 3)
this allows us to express it as a NNEF tile followed by a reshape.
repeat
Map PyTorch: 'aten:repeat' to NNEF.
repeat_interleave
This is same as np.repeat.
Equivalent with repeat
te = y new = te.unsqueeze(dim+1) new_repeats = [1] * (len(te.shape) + 1) new_repeats[ dim + 1 ] = n_repeat shapes = list(te.shape) shapes[dim] *= n_repeat new.repeat(new_repeats).reshape(shapes)