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

Allow conv2d and pool2d to use dynamic dimensions for width and height. #620

Merged
merged 3 commits into from
Mar 26, 2023

Conversation

nkoppel
Copy link
Contributor

@nkoppel nkoppel commented Mar 26, 2023

Adds the convolve_dim method to ConvAlgebra and uses it to implement ConvAlgebra for usize. Conv2d and Pool2d still require nightly, as making them work on stable would require making Const<N>::Convolved be usize, which I don't think is a desirable outcome of changing toolchains.

type Convolved = usize;

fn convolve_dim(&self) -> Self::Convolved {
(self.size() + 2 * P - K) / S + 1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(self.size() + 2 * P - K) / S + 1
(self.size() + 2 * P).checked_sub(K).unwrap() / S + 1

I think we'll need to add some sort of check/assertion for when this conv operation is valid. The const generic version does this implicitly with the where bound

@coreylowman
Copy link
Owner

I like how this ends up removing more code than it adds😀

@coreylowman
Copy link
Owner

Nice change 🚀

@coreylowman coreylowman merged commit 9eeb400 into coreylowman:main Mar 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants