-
Notifications
You must be signed in to change notification settings - Fork 214
Functional API: Execution environment agnostic function #205
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
Comments
More thoughts about
|
Note to myself: see how cross-graph references work wrt including graphs as functions, see #207. |
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cc @karllessard
This is somewhat of a sub-task of #181. The biggest pain I've ran into when using ConcreteFunction is that it only has tensor
call
methods, when it's mostly going to be used withOperand
. This is a fairly simple issue on the surface. But, there's no way to executeConcreteFunction
in graph mode, i.e. if they are nested. The function used to generate the graph-mode outputs (which are wrapped in Signature) isn't saved. Now, it's easy enough to do this Java-side, in a sub class so thatConcreteFunction
still supports loading. However, there's other issues such as supporting inputs with different shapes and dtypes that made me realize that what I'm trying to do here is closer to Python'sFunction
and we may want to handle it with a new abstraction. There's alsoTF_Function
andTF_GraphCopyFunction
andTFE_ContextAddFunction
which seems like it would allow attaching aConcreteFunction
to a graph without having to re-execute the builder in a new graph.So I'd propose two things:
ConcreteFunction
s using the nativeTF_Function
APIs (the fact that the eager one doesn't mention gradients makes me a little worried, but I would think we can handle that manually later if necessary).Function
class that acts liketf.function
, in that it createsConcreteFunction
s as necessary for the argument shapes and dtypes. Additionally, since this will save the graph-creator lambda, we can have adebug
flag that re-runs the lambda.We also need to do something with variable handling, although that will probably need to wait on #179. Python seems to use an implicit variable-creation context to create them at the call-site and only allows it on the first call. I'd be fine with throwing errors and forcing the user to extract them, I think. I need to look into the details a bit more before I propose anything for this though. Variable scopes might be worth doing anyways for freezing, although hopefully explicit as part of
Ops
/Scope
.We'll need to pay attention to Graph states, like random seeds, too.
The text was updated successfully, but these errors were encountered: