Custom C++ Extension Error

I updated PyTorch to 0.4 and started rewriting my old C extensions. However, my code gave an error, when I tried to copy data from one tensor to another. In my old implementation, I also had a similar line but I have never seen that error.

tensor.copy_(other_tensor) gives the following error:

RuntimeError: VariableType::ID() not implemented

What does this error mean? How can I fix this? Thanks in advance.

Hi,

It’s very hard for me to help you with this error without any context code at all :slight_smile:

What I believe might be the issue is that tensor in your case is a Tensor, while other_tensor is a Variable. For example, this code will fail with precisely this message:

auto x = at::ones(at::CPU(at::kFloat), {2, 2});
auto y = at::randn(torch::CPU(at::kFloat), {2, 2});
x.copy_(y);

where the first tensor is created with at::CPU type, which creates a tensor, while the second is created with torch::CPU type, which creates a variable. Could this be the error you ran into? In that case, please change the first to torch::CPU.

If not, please elaborate on your code so that I have a chance to better understand it.

1 Like

It works now! Thank you very much!

Aren’t tensor and variable now merged? Why do we still need to declare them differently?