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
Java bindings #2100
base: master
Are you sure you want to change the base?
Java bindings #2100
Conversation
Thanks for opening your first pull request in this repository! Someone will review it when they have a chance. In the mean time, please be sure that you've handled the following things, to make the review process quicker and easier:
Thank you again for your contributions! 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Vasniktel, this is a truly impressive effort. Adding a binding for another language is a lot of work. I'm really excited to add these. I think that the review process will take a lot of time, though; since we're basically adding an entire new interface to mlpack, lots of testing and review have to happen in order to make it all fit. I have to apologize that I've been slow about this initial review---the PR itself is pretty intimidating. :)
My review here is pretty initial---it's likely as we dig deeper, we'll find more things to change or fix or what.
So far, I've checked out the bindings and built them locally and run the tests, which all pass fine. From my end I need to do the following before I think everything is ready for release:
- high-level structural review of the code (it would probably be good to take a second pass though)
- fine-grained review of all the code
- test build documentation for the website and deploy
- try to do some data science with mlpack from Java
- understand how the Java bindings would fit in with Scala and how we can cover that also
- figure out what packaging the Java bindings look like (plus Scala too?)
- make sure tests run on different OSes (Linux/OS X/Windows)
Many of the comments I make during this process might be outside the scope of this PR, so we can always open issues for them that can be handled later. I'm sure we won't get everything perfect right after the first merge, but I think we can get most of the way there. :)
@@ -14,6 +14,7 @@ | |||
|
|||
#include <mlpack/prereqs.hpp> | |||
#include <mlpack/core/math/lin_alg.hpp> | |||
#include <mlpack/core/math/ccov.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we removed this some time ago, my guess is this is just a merge artifact. But we shouldn't re-add ccov.hpp
because it doesn't exist anymore. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partly fixed in 6574dc8. I was unable to get it compiled without adding these and some other includes. Particularly, it says that mlpack::math::ColumnCovariance
is not defined (not sure what the problem is)
#elif(BINDING_TYPE == BINDING_TYPE_JAVA) // This is a Java binding. | ||
|
||
// TODO: not sure where we use this | ||
#define BINDING_MATRIX_TRANSPOSED true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only used for the NMF binding, because it makes a difference which matrix is W and which is H when the binding operates on transposed or non-transposed data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the insight :) I'm not sure though what value I should set it to for Java
@@ -15,6 +15,8 @@ | |||
#define MLPACK_METHODS_LOGISTIC_REGRESSION_LOGISTIC_REGRESSION_FUNCTION_HPP | |||
|
|||
#include <mlpack/prereqs.hpp> | |||
#include <mlpack/core/math/make_alias.hpp> | |||
#include <mlpack/core/math/shuffle_data.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also not sure that this change is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partly fixed in 6574dc8.
Hello @Vasniktel do you think you could update the linux build steps: https://github.com/mlpack/mlpack/blob/master/.ci/linux-steps.yaml to enable the java bindings? |
Time for a small status report ;) I've been working out the way bindings are being generated. We are compiling bindings for every method separately right now (every *.so file is being compiled separately by cmake script after the appropriate JNI wrapper file was generated by JavaCPP library). The whole process looks like this:
Disadvantages of this approach are:
An alternative approach could be to make JavaCPP do all the hard work. In that way, the process reduces to the following:
The only downside is that we have to pass all compiler flags to JavaCPP maven plugin to make sure bindings are compiled correctly. I'm working on this new process right now. Meanwhile, I've noticed that usage of move assignment operator for |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions! 👍 |
Hey, @rcurtin. It would be good to keep this issue open ;) |
@Vasniktel agreed, I'm sorry I haven't managed to review this. Things have been crazy. :( |
That's ok ;). I don't have much time to work on this myself. |
@Vasniktel if you want I can help you in this, or else if you don't enough time I can open a new PR for completing this. :) |
@Yashwants19 Thanks. It would be great if you could take this over. I don't think I will be able to finish this any time soon :( Sorry for the long delay. |
Is this coming any time soon? |
I'd like to keep this one open---it is really nice code, it just needs to be reviewed and merged. I hope to have the time sometime... |
Implementation of automatic bindings generator for Java.
We are using Nd4j on the Java side to work with matrices.
Types are being mapped as follows:
arma::Mat<T>
is mapped toINDArray
class of Nd4j library.std::vector<T>
is mapped toList<T>
int
->Integer
double
->Double
std::string
->String
If you want to try it yourself:
mkdir build && cd build
cmake -D BUILD_JAVA_BINDINGS=1 ..
make java
cd src/mlpack/bindings/java/maven/target
There must be a *.jar file in the directory. You can use it to run generated bindings. Don't forget to put it and its dependencies (https://mvnrepository.com/artifact/org.nd4j/nd4j-api/1.0.0-beta5) in your classpath.
TODO:
.jar
file with native libraries