-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat/native Implemnt Sigmoid, ReLU, and tanh for Native back ends #7
Conversation
First, big thanks, for the PR and the issues. I think it is best to create separate issues/PRs for them, as they need to be fixed at Collenchyma. Review, with three points that need to be resolved before we can merge that PR.
|
There were the following issues with your Pull Request
Guidelines are available at https://github.com/autumnai/collenchyma-nn/blob/master/CONTRIBUTING.md#git-commit-guidelines This message was auto-generated by https://gitcop.com |
@MichaelHirn I updated the non plain functions to perform the sync. Regarding the |
Regarding the issues raised:
The |
Awesome ✨ Thanks for squashing the commits, adding the synchronization and referencing the issues, that improves the code and future works a lot 👍 I made a PR to your The bench PR should help to refactor the native activation functions. My gut tells me, that we can significantly increase the performance if we rewrite it, so that we can drop the For later comparsion, these are the current benches on my machine with the
|
feat/bench: add bench and perf utilities
Looks very nice 👍
I think we are still quite far away from that. The speediest solution will most likely involve things like SIMD optimizations which due to the current lack of support in Rust can only be achieved by using external libraries like BLAS or similar. But I think these optimizations are something for the future since that would introduce a dependency on the collenchyma-blas plugin and I'd rather keep that simple for the time being. The solution as it is already provides great value. One thing we should think about are traits for only a subset of the plugins features, e.g. |
Yes, definitely a good point. A Plugin could have multiple plugin traits instead of one. Exposing all of the traits at the root level of the crate, would then yield the same result as we currently have at the application side with Regarding my previous comment, I feel I was quite ambiguous with |
FWIW, When I'm next on a suitable machine I'll try profiling with the bench to see where time goes. Also, I think it's worth making a bench on the underlying sigmoid functions. But I think that requires that they're public. Maybe wrapping them in publicly exposed functions marked #[bench](so they don't exist in release versions) could dance around that. |
I profiled this and found most of the time is spend in |
@higgs: I think the PR is mergable as it is. I think the refactoring of the traits is something that needs a bit more discussion. |
@MichaelHirn I ran bench just like you and my numbers were in line with yours except I ran them on a 2012 mac book air so it took a good deal more nanoseconds/iteration than your box. I also began looking at comparing against the cuda version but my desktop has a GeForce 460 which is too old for cuNN (which requires the CUDA API version 3). So the comparison was a non starter and underlined the importance of implementing the native backend. :) |
@ehiggs Thank you so much for that PR. I merge it now into master. For publishing this to cargo, we should make the refactor with the traits to avoid |
feat/native Implemnt Sigmoid, ReLU, and tanh for Native back ends
This implements Sigmoid, ReLU, and tanh activation functions for the native backend. This includes the grad functions too.
Notes:
write_to_memory
should be moved to a single common function somewhere (co
?). Currently it is copy pasted in the tests (twice in each) and in the native back ends.if let
s). Perhaps this could be abstracted into an iterator or a deeper function that does all the unwrapping we want. I think this is a side issue from the implementations as they stand now. A side effect of the nested if lets is that I had to make up stupid variable names which don't add anything to the readability.write_to_memory
doesn't work nicely in the face of different features being enabled. If only one feature is enabled, Rust doesn't like that we use an if let because there's only one possible backend. If we use multiple backends then it doesn't like it when we /dont/ use an if let since we aren't sure about the results of the backend resolution.I don't know if you want to merge this and pull the issues into issues; or if you want these to be fixed in the PR, so I'll leave it up to you.
If you want to make some changes, please fork my branch and pass a PR back to me.
Thanks!
r? @MichaelHirn