PyTorch AdaptiveAvgPool2dImpl constructor
haifengl opened this issue · 2 comments
AdaptiveAvgPool2dImpl constructor takes a parameter output_size
. It is the target output size of the image of the form H x W.
Can be a tuple (H, W) or a single H for a square image H x H. But currently the constructor takes only LongOptional as input. This will cause the second parameter be undefined number during runtime and cause errors.
LongOptional
is a subclass of Pointer
. Like any Pointer
, it can point to a single item or an array.
In the case of AdaptiveAvgPool2dImpl
you must supply an array of 2 LongOptional
.
The problem here is that, for LongOptional
, the usual array constructor that takes the array length as argument is shadowed by the constructor that takes the optional long.
You should be able to use a vector instead:
AdaptiveAvgPool2dImpl aap = new AdaptiveAvgPool2dImpl(new LongOptionalVector(new LongOptional(10), new LongOptional(12)).front());
Can you give it a try ?
It seems work. I will further check if the computation result is correct. Thanks! I would suggest changing the API to LongPointer
instead of LongOptional
. In fact, Conv2dImpl's kernel
parameter is similar and it takes LongPointer
. It is clear and less misleading.