Passing tuple/int to custom conv forward

I’m trying to use the C++ Extension tutorial to write a custom convolution function for use in python.

torch::Tensor conv2d_forward(
    const torch::Tensor input,
    const torch::Tensor weight,
    const torch::Tensor bias,
    torch::ExpandingArray<2> stride,
    torch::ExpandingArray<2> padding,
    torch::ExpandingArray<2> dilation,
    int64_t groups
    return F::conv2d(input,weight,F::Conv2dFuncOptions().bias(bias).stride(stride).padding(padding).dilation(dilation).groups(groups));

I was hoping that I could then call this function using pybind like this:

torchexplain_cpp.conv2d_forward(input, weight, bias, (1,1),(1,1),(1,1),1)

But I get an incompatible arguments error regarding the tuples.
How would I appropriately pass python tuples OR ints to the function?
Thank you

Could you try to use c10::ArrayRef<long int> as the type for stride, padding, and dilation and rerun the script?

Thank you for your reply, that works now. I’m still new to C++ and I realise now that ExpandingArray is a template. Is it possible to use it for parameter types? or would I have to either:
Convert the ints to tuples in python
Write separate functions in C++ for int options vs. tuple options?

If you would like to pass integers directly, you could use the int64_t type in C++, as you’ve already done with the groups parameter.
Could you explain the use case a bit, if I misunderstood it?

Of course sorry. To clarify I was hoping that by specifying the optional parameters as ExpandingArray, then the function would accept either tuples, or integers that would then be expanded to tuples. So I could either pass (1,1) or simply 1 for my stride and see the same behaviour.
Again I’m still learning c++ and it seems now incorrect.
Thank you again for your help!

Ah OK, thanks for the explanation.
I’m not sure what the proper way would be, but I’ve seen the usage of c10::ArrayRef<long int> in C++ and passing a tuple with different number of elements on the Python side via:

(1, 2)
(1, 2, 3)