Skip to content

Commit 4045b0b

Browse files
committed
make Ternary.java be able to process STMP sparse inputs
1 parent 3f484b3 commit 4045b0b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/main/java/org/apache/sysds/hops/codegen/cplan/CNodeTernary.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,13 @@ public String codegen(boolean sparse, GeneratorAPI api) {
8282
String varj = _inputs.get(j-1).getVarname();
8383
//replace sparse and dense inputs
8484
tmp = tmp.replace("%IN"+j+"v%",
85-
varj+(varj.startsWith("a")?"vals":"") );
85+
varj+(varj.startsWith("a")?"vals" : varj.startsWith("STMP") ? ".values()" :"") );
8686
tmp = tmp.replace("%IN"+j+"i%",
87-
varj+(varj.startsWith("a")?"ix":"") );
87+
varj+(varj.startsWith("a")?"ix": varj.startsWith("STMP") ? ".indexes()" :"") );
8888
tmp = tmp.replace("%IN"+j+"%", varj );
89+
tmp = tmp.replace("%POS%", varj.startsWith("a") ? varj+"i" : varj.startsWith("STMP") ? "0" : "");
90+
tmp = tmp.replace("%LEN%",
91+
varj.startsWith("a") ? "alen" : varj.startsWith("STMP") ? varj+".size()" : "");
8992
}
9093
sb.append(tmp);
9194

src/main/java/org/apache/sysds/hops/codegen/cplan/java/Ternary.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public String getTemplate(CNodeTernary.TernaryType type, boolean sparse) {
5151

5252
case LOOKUP_RC1:
5353
return sparse ?
54-
" double %TMP% = getValue(%IN1v%, %IN1i%, ai, alen, %IN3%-1);\n" :
54+
" double %TMP% = getValue(%IN1v%, %IN1i%, %POS%, %LEN%, %IN3%-1);\n" :
5555
" double %TMP% = getValue(%IN1%, %IN2%, rix, %IN3%-1);\n";
5656

5757
case LOOKUP_RVECT1:

0 commit comments

Comments
 (0)