Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyTorch AdaptiveAvgPool2dImpl constructor #1492

Closed
haifengl opened this issue Apr 13, 2024 · 2 comments
Closed

PyTorch AdaptiveAvgPool2dImpl constructor #1492

haifengl opened this issue Apr 13, 2024 · 2 comments
Assignees
Labels

Comments

@haifengl
Copy link

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.

@haifengl haifengl changed the title AdaptiveAvgPool2dImpl constructor PyTorch AdaptiveAvgPool2dImpl constructor Apr 13, 2024
@HGuillemet
Copy link
Collaborator

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 ?

@haifengl
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants