Eypros
Eypros

Reputation: 5723

Equivalent of _new_empty_tensor from torchvision in pure torch function

I am trying to use a vision transformer repository (https://github.com/wangjian123799/L-DETR) which uses a version of torch and torchvision. Anyway, because exact versions are not given and torch is super fast at deprecating versions I guess I am in the unpleasant situation to try to find what combination of those two packages would work for me.

The error message is this one:

cannot import name '_new_empty_tensor' from 'torchvision.ops'

The simpler question would be which is the last version of torchvision that includes _new_empty_tensor?

But I would be happy with a workaround. For example inspecting the code I found the usage for the later to be:

_new_empty_tensor(input, output_shape)

which to me it just creates an empty tensor with the given dimensions. Correct me if I am wrong here. So, could I just use torch instead and create a torch Tensor instead? Would there be any issue? And as a side question why torchvision even introduced such functions? Isn't it supposed to just provide some additional functionality for images? Am I missing something here?

Upvotes: 0

Views: 50

Answers (1)

jodag
jodag

Reputation: 22284

The last version of torchvision that includes ops._new_empty_tensor is 0.8.2, which is compatible with PyTorch 1.7.1. That said, the requirements.txt in the repo you linked includes:

torch>=1.5.0
torchvision>=0.6.0

From this, I would guess that PyTorch 1.5.0 and torchvision 0.6.0 are what the devs actually used when they trained that model.

Upvotes: 1

Related Questions