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

Add callback #292

Merged
merged 5 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
@@ -0,0 +1,16 @@
# From https://www.tensorflow.org/versions/r2.9/api_docs/python/tf/distribute/Strategy#example_usage_2.

import tensorflow as tf

strategy = tf.distribute.MirroredStrategy(["GPU:0", "GPU:1"])
tensor_input = tf.constant(3.0)


@tf.function
def replica_fn(input):
return input * 2.0


# Indirect call to replica_fun().
result = strategy.run(replica_fn, (tensor_input,))
print(result)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tensorflow==2.9.3
Original file line number Diff line number Diff line change
Expand Up @@ -4395,6 +4395,33 @@ public void testHasLikelyTensorParameter147() throws Exception {
testHasLikelyTensorParameterHelper(false, false);
}

/**
* Test for https://github.com/ponder-lab/Hybridize-Functions-Refactoring/issues/280.
*/
@Test
public void testHasLikelyTensorParameter148() throws Exception {
khatchad marked this conversation as resolved.
Show resolved Hide resolved
Set<Function> functions = this.getFunctions();
assertNotNull(functions);
assertEquals(1, functions.size());
Function function = functions.iterator().next();
assertNotNull(function);
assertEquals(true, function.getIsHybrid());

argumentsType params = function.getParameters();

// two params.
exprType[] actualParams = params.args;
assertEquals(1, actualParams.length);

exprType actualParameter = actualParams[0];
assertNotNull(actualParameter);

String paramName = NodeUtils.getRepresentationString(actualParameter);
assertEquals("input", paramName);
khatchad marked this conversation as resolved.
Show resolved Hide resolved

assertTrue("Expecting function with likely tensor parameter.", function.getLikelyHasTensorParameter());
}

// TODO: Test arbitrary expression.
// TODO: Test cast/assert statements?
// TODO: https://www.tensorflow.org/guide/function#pass_tensors_instead_of_python_literals. How do we deal with union types? Do we want
Expand Down