Is torch.tile deprecated & no longer supported?

Hi, I’m currently attempting to re-implement a Tensorflow project using PyTorch. For reference, I’m currently utilizing the following virtual environment setup for the project:

  • OS: Pop_OS 18.04 (Ubuntu 18.04 derivative)
  • Python version: 3.6.9
  • PyTorch version: 1.7.1+cu10
  • CUDA version : 11.1

Unfortunately, I’ve encountered a problem in re-implementing one of the code lines, which called for use of tf.tile(link to Tensorflow’s documentation on tf.tile) in the original Tensorflow project.

I’ve noted that in one page of PyTorch’s official documentation, that a similar torch.tile functionality seem to be available, hence I decided to try and utilize this. However, whenever I call this method, I always encounter the following error instead:

>>> import torch
>>> test_tensor = torch.tensor([1,2,3,4])
>>> test_tensor.tile((2,))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Tensor' object has no attribute 'tile'

Please do note that the same error still occurs even if I call the tile as a function applied on the created Tensor object, as seen below:

>>> import torch
>>> test_tensor = torch.tensor([1,2,3,4])
>>> torch.tile(test_tensor, (2,2))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'torch' has no attribute 'tile'

Looking at similar posts of unable to call some specific PyTorch methods, I thought that perhaps there was a problem with the PyTorch implementation with my machine specifically which caused this issue. Hence, I then tried to call the same function in a different machine which this time has the following Virtual Environment config:

  • OS: Pop_OS 20.04 (Ubuntu 20.04 derivative)
  • Python version: 3.8.5
  • PyTorch version: 1.6.0
  • CUDA version:

Unfortunately, I was still met with the exact same error as the original machine, which made me think that tile has been deprecated as per title. May I confirm with anyone whether this is true, and if yes: why the PyTorch’s documentation has not yet been updated with this deprecation?

In the meantime I understand that the tile function could be effectively replaced in functionality by the similar Tensor.repeat method, so I’ll be using that for now. However, I’d just like to have a confirmation/clarification on the errors/behaviors that I’ve encountered on torch.tile .

Thank you for any replies or confirmation in advance!

Hello Nicholas!

I think you have it backwards. Rather than being deprecated, it
appears that tile() is a new function.

I see tile() absent from the 1.7.0 documentation, but present in the
master (unstable) documentation you linked to.

Here is tile() in a somewhat old nightly build:

>>> import torch
>>> torch.__version__
>>> torch.tile
<built-in method tile of type object at 0x7f6626fc1360>

If tile() is useful to you, you could consider running a nightly build
(at a little bit of risk). Or stick with repeat() for the time being, it that
works for you.


K. Frank


Ah apologies I didn’t realize that the version I linked was that of an unreleased build myself! Thank you very much for the clarification and apologies on my part for not noticing! In that case I’ll be sticking with repeat for now then and avoid installing the nightly for now since my project requires stable functionality as much as possible.

Quite excited to try out the tile & other new functions that will be released in the future versions of torch though, and will definitely try them later for myself!

I’m getting

AttributeError: module 'torch' has no attribute 'tile'

I’m on version 1.7.0, it seems it is missing from docs as @KFrank pointed out. I’m still confused was it deprecated?

No, as @KFrank explained, this is a new function, which is not available in 1.7.0, but in the current master branch and nightly binaries.

1 Like