Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
cda1512
basic test setup
j143 Aug 15, 2025
9754f87
set transpose ooc operator
j143 Aug 15, 2025
fad987b
use swapindex for transpose operation
j143 Aug 15, 2025
7d02d26
setup TeeOp
j143 Aug 15, 2025
95e7a61
add Hop and rewrite class
j143 Aug 15, 2025
fde2ede
register the rewrite as static
j143 Aug 16, 2025
00657b5
add transpose operation test
j143 Aug 16, 2025
11add0b
add transpose operation test
j143 Aug 16, 2025
0e6feff
trigger the rewrite for the tee
j143 Aug 16, 2025
646b390
add rewrite and add missing methods in TeeOp
j143 Aug 16, 2025
2fcf260
add size information for output
j143 Aug 16, 2025
a5b165b
take a defensive copy of consumers before rewrite
j143 Aug 16, 2025
30ee4b9
add Tee LOP and use it in TeeOp
j143 Aug 17, 2025
acd097d
add license header
j143 Aug 17, 2025
5f38a90
tee reaches the teeinstruction
j143 Aug 17, 2025
0c0f4f5
plan triggered tee rewrite works, as a start
j143 Aug 17, 2025
051658a
add tee rewrite
j143 Aug 17, 2025
ba89bc6
add tee rewrite
j143 Aug 17, 2025
eb71889
add documentation for applyTeeRewrite method
j143 Aug 17, 2025
f25a90b
tee provide two outputs
j143 Aug 17, 2025
5f3fa08
correct program plan
j143 Aug 23, 2025
b124aad
lets use a 2 pass, post order traversal
j143 Aug 25, 2025
ab19f38
for now use a placeholder to cleanly copy
j143 Aug 26, 2025
f09bccc
create ec variable in the Tee instruction
j143 Aug 26, 2025
62c345a
add tee op in the Opcodes, Opcode type is Tee
j143 Aug 27, 2025
098566b
format the files for 2 spaces
j143 Aug 27, 2025
640e531
comment failed transpose 1000x500 test, put rewriteinject after readw…
j143 Aug 27, 2025
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
2 changes: 1 addition & 1 deletion src/main/java/org/apache/sysds/common/InstructionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,5 @@ public enum InstructionType {
PMM,
MatrixReshape,
Write,
Init,
Init, Tee,
}
1 change: 1 addition & 0 deletions src/main/java/org/apache/sysds/common/Opcodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ public enum Opcodes {
READ("read", InstructionType.Variable),
WRITE("write", InstructionType.Variable, InstructionType.Write),
CREATEVAR("createvar", InstructionType.Variable),
TEE("tee", InstructionType.Tee),

//Reorg instruction opcodes
TRANSPOSE("r'", InstructionType.Reorg),
Expand Down
170 changes: 170 additions & 0 deletions src/main/java/org/apache/sysds/hops/TeeOp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.sysds.hops;

import org.apache.sysds.common.Types.ExecType;
import org.apache.sysds.lops.Lop;
import org.apache.sysds.lops.Tee;
import org.apache.sysds.runtime.meta.DataCharacteristics;

import java.util.ArrayList;


public class TeeOp extends Hop {

private final ArrayList<Hop> _outputs = new ArrayList<>();

private TeeOp() {
// default constructor
}

/**
* Takes in a single Hop input and gives two outputs
*
* @param input
*/
public TeeOp(Hop input) {
super(input.getName(), input.getDataType(), input._valueType);

// add single input for this hop
getInput().add(0, input);
input.getParent().add(this);

// output variables list to feed tee output into
// for (Hop out: outputs) {
// _outputs.add(out);
// }

// This characteristics are same as the input
refreshSizeInformation();
}

@Override
public boolean allowsAllExecTypes() {
return false;
}

/**
* Computes the output matrix characteristics (rows, cols, nnz) based on worst-case output
* and/or input estimates. Should return null if dimensions are unknown.
*
* @param memo memory table
* @return output characteristics
*/
@Override
protected DataCharacteristics inferOutputCharacteristics(MemoTable memo) {
return null;
}

@Override
public Lop constructLops() {
// return already created Lops
if (getLops() != null) {
return getLops();
}

Tee teeLop = new Tee(getInput().get(0).constructLops(),
getDataType(), getValueType());
setOutputDimensions(teeLop);
setLineNumbers(teeLop);
setLops(teeLop);

return getLops();
}

@Override
protected ExecType optFindExecType(boolean transitive) {
return ExecType.OOC;
}

@Override
public String getOpString() {
return "tee";
}

/**
* In memory-based optimizer mode (see OptimizerUtils.isMemoryBasedOptLevel()),
* the exectype is determined by checking this method as well as memory budget of this Hop.
* Please see findExecTypeByMemEstimate for more detail.
* <p>
* This method is necessary because not all operator are supported efficiently
* on GPU (for example: operations on frames and scalar as well as operations such as table).
*
* @return true if the Hop is eligible for GPU Exectype.
*/
@Override
public boolean isGPUEnabled() {
return false;
}

/**
* Computes the hop-specific output memory estimate in bytes. Should be 0 if not
* applicable.
*
* @param dim1 dimension 1
* @param dim2 dimension 2
* @param nnz number of non-zeros
* @return memory estimate
*/
@Override
protected double computeOutputMemEstimate(long dim1, long dim2, long nnz) {
return 0;
}

/**
* Computes the hop-specific intermediate memory estimate in bytes. Should be 0 if not
* applicable.
*
* @param dim1 dimension 1
* @param dim2 dimension 2
* @param nnz number of non-zeros
* @return memory estimate
*/
@Override
protected double computeIntermediateMemEstimate(long dim1, long dim2, long nnz) {
return 0;
}

/**
* Update the output size information for this hop.
*/
@Override
public void refreshSizeInformation() {
Hop input1 = getInput().get(0);
setDim1(input1.getDim1());
setDim2(input1.getDim2());
setNnz(input1.getNnz());
setBlocksize(input1.getBlocksize());
}

@Override
public Object clone() throws CloneNotSupportedException {
return null;
}

@Override
public boolean compare(Hop that) {
return false;
}

public Hop getOutput(int index) {
return _outputs.get(index);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public ProgramRewriter(boolean staticRewrites, boolean dynamicRewrites)
//add static HOP DAG rewrite rules
_dagRuleSet.add( new RewriteRemoveReadAfterWrite() ); //dependency: before blocksize
_dagRuleSet.add( new RewriteBlockSizeAndReblock() );
_dagRuleSet.add( new RewriteInjectOOCTee() );
if( OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION )
_dagRuleSet.add( new RewriteRemoveUnnecessaryCasts() );
if( OptimizerUtils.ALLOW_COMMON_SUBEXPRESSION_ELIMINATION )
Expand Down
Loading
Loading