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] Graph environment decoupling in preparation of eager execution #24858
[Java] Graph environment decoupling in preparation of eager execution #24858
Conversation
0c3ab56
to
1cb8055
Compare
FYI, just applied a small change to this PR |
Nagging Reviewer @asimshankar: You have been added as a reviewer to this pull request. Please add your review or reassign. It has been 44 days with no activity and the |
I think this should be assigned to @sjamesr instead. |
1cb8055
to
76be6ee
Compare
Thanks for approving the PR, @sjamesr Since it was created a while ago, I had to rebase the code on current branch to get it compile, you might need to reapprove. Also, I took that opportunity to rename |
Friendly reminder @sjamesr to please re-approve this PR, Since it is a XL pull request, I'm just afraid that I'll need to rebase it more than once if we wait too long between approvals. Thanks! |
PiperOrigin-RevId: 239692145
This PR is the first of a series of pull requests that enables eager execution in the TensorFlow Java client. It might look ambitious at first but is pretty basic when understanding what is coming next.
This PR decouples the actual implementation for building operations, which is tightly bound to graph execution, from its public interface. Doing this in a single PR helps to get a better picture of the targeted architecture and discuss about it if needed.
So in brief:
Operation
concrete class became aGraphOperation
that implements theOperation
interface by extending from theAbstractOperation
abstract classOperationBuilder
concrete class became aGraphOperationBuilder
that implements theOperationBuilder
interfaceGraph
implements theExecutionEnvironment
interface to be used by theOps
classesOnce we are happy with this solution, we can start adding
Operation
,OperationBuilder
andExecutionEnvironment
implementations for eager execution, which are pretty straightforward according to my previous POC.I tried to preserve backward compatibility as much as possible. I ended up with the following exceptions:
Constructor in
Output
is now package-private and accepts onlyAbstractOperation
instances** Note: I could have play around to keep it public but for me, it sounds wrong to instantiate an
Output
directly instead of calling the available type-safeOperation.output
methodScope.graph()
has been changed toScope.env()
to return an instance ofExecutionEnvironment
instead instead of aGraph
** Note: This can only impacts clients already using the
Ops
API and even there, unless they did something tricky, theOps
classes will take care of the change flawlessly.See diagram below for an overview of the targeted architecture: