Skip to content
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

Native functions v2 #233

Merged
merged 34 commits into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
09b425f
Initial native function use
rnett Mar 5, 2021
278d7cc
Allow body constants
rnett Mar 5, 2021
c2b0b60
Fix body forbids
rnett Mar 5, 2021
dec04e6
Use default eager session for tensor calls
rnett Mar 5, 2021
047243b
Use default eager for single tensor call too
rnett Mar 5, 2021
696ef67
Get functions from graph
rnett Mar 5, 2021
71b8fab
Start of saver support
rnett Mar 5, 2021
3697122
Update loading, detect statefulness, use PartitionedCall
rnett Mar 6, 2021
abf0ed1
Start of dependencies
rnett Mar 6, 2021
ba65103
Support dependencies
rnett Mar 6, 2021
bafcec2
Remove unwrapping
rnett Mar 6, 2021
bb641e3
Proper attribute setters
rnett Mar 7, 2021
9e686c4
Add ignored gradient test
rnett Mar 7, 2021
b4bf605
Rebase fix
rnett Mar 9, 2021
b7ab76c
Op generation for functions
rnett Mar 13, 2021
6d8308e
Rebase fix
rnett Mar 17, 2021
eaeaf6e
SavedFunction for running functions from SavedModelBundles
rnett Apr 11, 2021
f32fbf2
Review fixes
rnett Apr 17, 2021
f892c54
Generation and better javadoc
rnett Apr 17, 2021
f485ccf
Rework pointer scopes
rnett Apr 19, 2021
5977c40
SessionFunction instead of SavedModelBundle specific class
rnett May 15, 2021
12af327
Add CallableFunction javadoc
rnett May 15, 2021
1b4bf59
Remove obsolete test
rnett May 15, 2021
54e8855
Rebase fix
rnett May 15, 2021
117b391
Formatting fixes and nits
rnett May 21, 2021
3df55b9
Add session function test, Signature.builder with name
rnett May 21, 2021
99a3403
Remove extra synchronization
rnett May 21, 2021
cecf71d
Formatting
rnett May 28, 2021
61e5ffd
New names
rnett May 30, 2021
1258276
Note on SavedModel functions
rnett May 30, 2021
b1b378e
Fix tests
rnett May 30, 2021
cba0fea
Rename name method
rnett May 30, 2021
e67ae1e
Re-add tests w/ SessionFunction
rnett May 30, 2021
c09385d
Helper methods for saving
rnett May 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import java.nio.charset.Charset;
import java.util.List;
import java.util.Map;
import org.tensorflow.ConcreteFunction;
import org.tensorflow.DeviceSpec;
import org.tensorflow.EagerSession;
import org.tensorflow.ExecutionEnvironment;
Expand Down Expand Up @@ -87,6 +89,7 @@
import org.tensorflow.op.core.ExtractVolumePatches;
import org.tensorflow.op.core.Fill;
import org.tensorflow.op.core.Fingerprint;
import org.tensorflow.op.core.Function;
import org.tensorflow.op.core.Gather;
import org.tensorflow.op.core.GatherNd;
import org.tensorflow.op.core.GetSessionHandle;
Expand Down Expand Up @@ -1116,6 +1119,31 @@ public Bucketize bucketize(Operand<? extends TNumber> input, List<Float> boundar
return Bucketize.create(scope, input, boundaries);
}

/**
* Calls the function in an execution environment, adding its graph as a function if it isn't
* already present. Only works for functions with a single input and output.
*
* @param argument the argument to the call
* @return the output of the function
* @see ConcreteFunction#call(Ops, Operand)
*/
public Operand<?> call(ConcreteFunction function, Operand<?> argument) {
return Function.call(scope, function, argument);
}

/**
* Calls the function in an execution environment, adding its graph as a function if it isn't
* already present. The inputs and outputs are keyed by the names set in the {@code Signature}.
*
* @param arguments the arguments to the call
* @return the outputs of the function
* @see ConcreteFunction#call(Ops, Map)
*/
public Map<String, Operand<?>> call(ConcreteFunction function,
Map<String, Operand<?>> arguments) {
return Function.call(scope, function, arguments);
}

/**
* Clips tensor values to a specified min and max.
* Given a tensor {@code t}, this operation returns a tensor of the same type and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// Once created and added to graphs, functions can be invoked by creating an
// operation whose operation type matches the function name.
@Opaque @Properties(inherit = org.tensorflow.internal.c_api.presets.tensorflow.class)
public class TF_Function extends Pointer {
public class TF_Function extends org.tensorflow.internal.c_api.AbstractTF_Function {
/** Empty constructor. Calls {@code super((Pointer)null)}. */
public TF_Function() { super((Pointer)null); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
Expand Down
Loading