forked from apache/systemds
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
.../java/org/apache/sysds/test/component/codegen/rewrite/functions/SubtreeGeneratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.apache.sysds.test.component.codegen.rewrite.functions; | ||
|
||
import org.apache.sysds.hops.rewriter.RewriterStatement; | ||
import org.apache.sysds.hops.rewriter.RewriterUtils; | ||
import org.apache.sysds.hops.rewriter.RuleContext; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import java.util.List; | ||
import java.util.function.Function; | ||
|
||
public class SubtreeGeneratorTest { | ||
|
||
private static RuleContext ctx; | ||
private static Function<RewriterStatement, RewriterStatement> canonicalConverter; | ||
|
||
@BeforeClass | ||
public static void setup() { | ||
ctx = RewriterUtils.buildDefaultContext(); | ||
canonicalConverter = RewriterUtils.buildCanonicalFormConverter(ctx, true); | ||
} | ||
|
||
@Test | ||
public void test1() { | ||
RewriterStatement stmt = RewriterUtils.parse("+(1, a)", ctx, "LITERAL_INT:1", "FLOAT:a"); | ||
List<RewriterStatement> subtrees = RewriterUtils.generateSubtrees(stmt, ctx, 100); | ||
|
||
for (RewriterStatement sub : subtrees) { | ||
System.out.println("=========="); | ||
System.out.println(sub.toParsableString(ctx, true)); | ||
} | ||
|
||
assert subtrees.size() == 2; | ||
} | ||
|
||
@Test | ||
public void test2() { | ||
RewriterStatement stmt = RewriterUtils.parse("+(+(1, b), a)", ctx, "LITERAL_INT:1", "FLOAT:a,b"); | ||
List<RewriterStatement> subtrees = RewriterUtils.generateSubtrees(stmt, ctx, 100); | ||
|
||
for (RewriterStatement sub : subtrees) { | ||
System.out.println("=========="); | ||
System.out.println(sub.toParsableString(ctx, true)); | ||
} | ||
|
||
assert subtrees.size() == 3; | ||
} | ||
} |