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 NN test. #318

Merged
merged 6 commits into from
Jan 22, 2024
Merged
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
Prev Previous commit
Next Next commit
Add test.
khatchad committed Jan 22, 2024
commit 646e9fd491d839fec980c7c5d6c8abeb7ecfb2f8
Original file line number Diff line number Diff line change
@@ -6201,26 +6201,39 @@ public void testTensorFlowKerasCustomLayer() throws Exception {
assertTrue(function.getLikelyHasTensorParameter());
}

private static void testFunctionHelper(Function function, Boolean expectedHybrid, Boolean expectedTensorParameter,
Boolean expectedPrimitiveParameter, Boolean expectedPythonSideEffects, Boolean expectedRecursive,
Refactoring expectedRefactoring, PreconditionSuccess expectedPassingPrecondition, Set<Transformation> expectedTransformations,
int expectedStatusSeverity) {
assertEquals(expectedHybrid, function.getIsHybrid());
assertEquals(expectedTensorParameter, function.getLikelyHasTensorParameter());
assertEquals(expectedPrimitiveParameter, function.getLikelyHasPrimitiveParameters());
assertEquals(expectedPythonSideEffects, function.getHasPythonSideEffects());
assertEquals(expectedRecursive, function.getIsRecursive());
assertEquals(expectedRefactoring, function.getRefactoring());
assertEquals(expectedPassingPrecondition, function.getPassingPrecondition());
assertEquals(expectedTransformations, function.getTransformations());
assertEquals(expectedStatusSeverity, function.getStatus().getSeverity());
}

@Test
public void testNeuralNetwork() throws Exception {
Set<Function> functions = getFunctions();

for (Function function : functions) {
switch (function.getIdentifier()) {
case "run_optimization":
System.out.println(function.getIdentifier());
break;
case "NeuralNet.__init__":
System.out.println(function.getIdentifier());
break;
case "accuracy":
System.out.println(function.getIdentifier());
break;
case "cross_entropy_loss":
System.out.println(function.getIdentifier());
testFunctionHelper(function, false, true, false, false, false, CONVERT_EAGER_FUNCTION_TO_HYBRID, P1,
singleton(CONVERT_TO_HYBRID), RefactoringStatus.OK);
break;
case "NeuralNet.call":
System.out.println(function.getIdentifier());
testFunctionHelper(function, false, true, true, false, false, CONVERT_EAGER_FUNCTION_TO_HYBRID, P1,
singleton(CONVERT_TO_HYBRID), RefactoringStatus.OK);
break;
case "NeuralNet.__init__":
assertFalse(function.getStatus().isOK());
break;
default:
throw new IllegalStateException("Unexpecting: " + function.getIdentifier() + ".");