I work on PyTorch1.0.
I build c++ extensions based on the code of Aten.
The input argument of the original c++ function should be IntList
type.
When I call this function in Python, I pass a Python list to this function.
However, it raises an “Incompatible argument” error.
How to match IntList
type in Python?
I recommend you to use std::vector<std::int64_t>
instead of IntList because pybind support STL (and conversion with python list), and IntList (ArrayRefstd::int64_t) can be converted from std::vector.
see https://pybind11.readthedocs.io/en/stable/advanced/cast/stl.html
1 Like
Thanks.
Can you provide a simple example code which converts std::vector<int64_t>
into IntList
?
std::vector<int64_t>
implicitly converts to IntList
. And IntList
has a vec()
method which returns a vector.