-
Notifications
You must be signed in to change notification settings - Fork 73
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
document package maturity #149
Comments
Well the project hasn't reached a stable 1.0 release so the API may change. However, it continues to be updated for fixes and features so will continue to work into the future. |
@TotallyGamerJet purego is cool stuff! Great work you've done so far. Do you think this can ever make it into golang.org/x/sys ? |
That's really up to the Go team. golang#18296 kind of brings up the idea but no one is currently pushing for it. |
Purego is amazing. It let me create Golightly, a purego wrapper of LightGBM, a very nice ML library. Golightly has basic ML functionality working, including training models and applying them. I'm running into problems with passing more complicated data back and forth (e.g., a 2-dimensional array of float32 or an array of strings). The current documentation for RegisterFunc covers relationships between simple types. Would it be in the scope of the purego project to document more complicated data structure? Or, does the CGO ecosystem provide documentation already that can be applied in a purego context (and perhaps linked from here)? |
So the more complex types are made up of the simpler ones. An array of strings would be **byte. You can get this type by using a []*byte which you'd then pass to the function using unsafe.SliceData(slice) As for the two dimensional float array I believe it would just be a single slice with the size of width and height make([]float32, width*height). Unless the function requires the memory be in C in which case you'd use malloc. |
@TotallyGamerJet, thank you. I was able to create an array of floats using your advice pretty easily, but had a much harder time to figure out what you meant about the array of strings. Through trial and error, I came up with this working solution:
In retrospect, it is exactly what you said, but it didn't click at first. Hopefully, this concrete example code will help out someone else. |
I'm glad you figured it out. Just one note. You want to make sure that myStrings doesn't get garbage collected before the string pointers are no longer needed. You can do that by placing a runtime.KeepAlive(myStrings) call after the last call to the C function. |
This project seems very cool!
However it's hard to assess the relative maturity of this package; which features it has or doesn't have, what are the largest caveats or roadblocks that one might encounter.
It would be super great to have some high-level documentation about what consumers of this package can expect so that people can assess how suitable/viable this package is.
Thanks! :)
The text was updated successfully, but these errors were encountered: