-
Notifications
You must be signed in to change notification settings - Fork 14
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
Port existing functionality for creating a graph from c_api.h to a NIF. #40
Comments
I believe we can't build graphs because there is no tensorflow C API for it? Or am I mistaking it by something else? 🤔 |
Uhh let me double check myself I just spent some time poking around it for a bit and I thought I saw the necessary functions. |
So, TF_GraphCopyFunction allows us to add arbitrary functions to a graph and those functions appear to be a set of operations. And https://github.com/tensorflow/tensorflow/blob/r1.10/tensorflow/python/framework/ops.py, lines 1537-1581 would suggest we may have the necessary functionality to create arbitrary ops for the graph from the c-api. Line 1576 TF_FinishOperation actually adds it. |
Awesome, thanks! :) |
Hello @GrandathePanda and @josevalim The problem is users still can't do ML or DL because there is no gradient computation support for training on custom created graphs in the Tensorflow C API. Again look under Current Status here: https://www.tensorflow.org/extend/language_bindings If there are any relevant use cases for having simple custom graphs and ops then porting such functionality from the C API makes sense, otherwise I have a feeling this might complicate Tensorflex unnecessarily, without adding any value to it. What do you think? |
My impression was TF_CAPI_EXPORT void TF_AddGradients allows gradient computation and allows us to begin to build towards constructing actual ml/dl models It just doesn't seem to be documented on that status page. |
There is also in the current c-api.h in tensorflow's repo TF_CAPI_EXPORT void TF_AddGradientsWithPrefix The caveat for both of them seems to be that they dont currently have support for all gradient types but a subset at the moment |
Yes, while they have been added in some fashion, using them is not straightforward and requires linking some gradient C++ API functionality for successful compilation (which is not how compilation is referenced on the C API installation page). I did not find any documentation on doing that and only some arbitrary mentions on some issues on the tensorflow repo. Since they don't seem to work right out of the box, I think that's why they have not updated the status page. However, if you can get gradients to work then I think custom graphs would make a lot of sense! :) Would you be interested in taking a look at this? Even running gradient computation ops on a simple ML graph constructed in C via the C API would be a successful start to this. I am not sure if incorporating them will be as easy as you say, though. |
Certainly I would love to take a look! |
Awesome! :) I will try again sometime next week to see if I can get them to work as well, but my previous attempt had not worked. |
As a quick update, it was a busy work week last week but I'm close to having creating a new graph and adding basic operations to it finished. I will then attempt the gradients portion and If all goes well will put up a PR hopefully by end of week. |
Awesome, sounds great! I haven't been getting much time lately too but I'll let you know if I come up with something as well. |
I have a question: adding those APIs mean we no longer need to build the models in Python or is this API just a small subset of what is necessary to build a model? |
Hello @josevalim, if all this works as intended, then we might get some basic models to train completely in Elixir. I couldn't find support for all gradient types in the actual C API, so not all types of models (RNNs etc. maybe) might be directly trainable. Basically we might be able to do some things that initially we would do in Python, but not all. |
That's very nice to hear then. To me one of the biggest concerns with Tensorflow in Elixir is that you still have to write the models in Python, so you still need to learn Python and the main reason for using the Elixir bindings is because you want to integrate with a live Elixir system. But by being able to create some graphs in Elixir, it means we can have tutorials that are fully handled by Elixir. 👍 |
I completely agree. Integrating these APIs might not be a straightforward process but it will be very good to have independent Elixir training-to-inference support in Elixir itself so it is well worth it. I have got caught up with packing and last minute things lately but I will try this out once I'm a little settled. :) |
I have not forgotten this, and speaking to the lack of straightforwardness, I ran into an issue with operation definitions. I have a stack overflow question that has been open for a bit and no one has answered so I figured I would link to it here and see if you @anshuman23 might be able to shed some light, |
Sorry for the late reply @GrandathePanda. I'll take a look at this in the next few days and let you know! |
Sounds good! |
So the description of the library is for utilizing models in elixir, not certain if you also want to head in the direction of being able to construct graphs as well. If so I'd like to try and add some functionality regarding building arbitrary operation graphs, nothing super fancy just construct and execute some operations with run_session afterward. Then if that goes well I could build up from there.
The text was updated successfully, but these errors were encountered: