Libtorch C++ - no matching member function for call to 'size' for InterpolateFuncOptions

778 views Asked by At

Using Libtorch 1.6.0 in C++, I get the following error:

error: no matching member function for call to 'size'

My line is the following:

image = F::interpolate(image, F::InterpolateFuncOptions().size({target_height, target_width}).mode(torch::kNearest));

But in the documentation it seems correct... Any idea?

Thanks in advance

1

There are 1 answers

0
Szymon Maszke On BEST ANSWER

You should wrap it with std::vector like this:

image = F::interpolate(image, 
        F::InterpolateFuncOptions()
        .size(std::vector<>{target_height, target_width})
        .mode(torch::kNearest));

Reason for this is size has no overloaded call for std::initializer_list that you were trying to use (see size docs here).