Skip to content

Commit e2476a2

Browse files
committed
clean comment-outs
1 parent d4a7cdb commit e2476a2

File tree

3 files changed

+13
-39
lines changed

3 files changed

+13
-39
lines changed

src/compiler/lowering/EwOpsLowering.cpp

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,12 @@ template <class UnaryOp, unaryFuncType unaryFunc> struct UnaryOpLowering : publi
8888
ssize_t numCols = sparseMatType.getNumCols();
8989

9090
if (numRows < 0 || numCols < 0) {
91-
std::cout<<"here 5"<<std::endl;
9291
throw ErrorHandler::compilerError(
9392
loc, "EwOpsLowering (BinaryOp)",
9493
"ewOps codegen currently only works with matrix dimensions that are known at compile time");
9594
}
9695

9796
MemRefType sparseValuesMemRefType =
98-
//MemRefType::get({ShapedType::kDynamic}, matrixElementType);
9997
MemRefType::get({ShapedType::kDynamic}, matrixElementType);
10098

10199
Value argValuesMemref = rewriter.create<daphne::ConvertCSRMatrixToValuesMemRef>(
@@ -116,8 +114,6 @@ template <class UnaryOp, unaryFuncType unaryFunc> struct UnaryOpLowering : publi
116114
OpBuilderNested.create<linalg::YieldOp>(locNested, resValue);
117115
});
118116

119-
120-
//rewriter.replaceOp(op, resMemref);
121117
MemRefType sparseColIdxsMemRefType = MemRefType::get({ShapedType::kDynamic}, rewriter.getIndexType());
122118
MemRefType sparseRowOffsetsMemRefType = MemRefType::get({numRows + 1}, rewriter.getIndexType());
123119

@@ -129,12 +125,11 @@ template <class UnaryOp, unaryFuncType unaryFunc> struct UnaryOpLowering : publi
129125
Value maxNumRowsValue = rewriter.create<arith::ConstantIndexOp>(loc, numRows);
130126
Value numColsValue = rewriter.create<arith::ConstantIndexOp>(loc, numCols);
131127
Value maxNumNonZerosValue = rewriter.create<arith::ConstantIndexOp>(loc, numCols * numRows);
132-
//auto resCSRMatrix = convertMemRefToCSRMatrix(loc, rewriter, resMemref, op.getType());
133128

134129
auto resCSRMatrix = convertMemRefToCSRMatrix(loc, rewriter,
135130
resMemref, argColIdxsMemref, argRowOffsetsMemref,
136-
maxNumRowsValue, numColsValue, maxNumNonZerosValue, op.getType());
137-
//maxNumRowsValue, numColsValue, maxNumNonZerosValue, adaptor.getArg().getType());
131+
//maxNumRowsValue, numColsValue, maxNumNonZerosValue, op.getType());
132+
maxNumRowsValue, numColsValue, maxNumNonZerosValue, adaptor.getArg().getType());
138133

139134
rewriter.replaceOp(op, resCSRMatrix);
140135

@@ -160,7 +155,6 @@ template <class UnaryOp, unaryFuncType unaryFunc> struct UnaryOpLowering : publi
160155
ssize_t numCols = matrixType.getNumCols();
161156

162157
if (numRows < 0 || numCols < 0) {
163-
std::cout<<"here 6"<<std::endl;
164158
throw ErrorHandler::compilerError(
165159
loc, "EwOpsLowering (BinaryOp)",
166160
"ewOps codegen currently only works with matrix dimensions that are known at compile time");
@@ -230,7 +224,6 @@ class BinaryOpLowering final : public mlir::OpConversionPattern<BinaryOp> {
230224
if (lhsRows != 1 && rhsRows == 1) {
231225
// rhs is a row vector, broadcast along columns
232226
if (lhsCols != rhsCols) {
233-
std::cout<<"here 7"<<std::endl;
234227
throw ErrorHandler::compilerError(
235228
loc, "EwOpsLowering (BinaryOp)",
236229
"could not broadcast rhs along columns. Rhs must "
@@ -244,7 +237,6 @@ class BinaryOpLowering final : public mlir::OpConversionPattern<BinaryOp> {
244237
} else if (lhsCols != 1 && rhsCols == 1) {
245238
// rhs is a column vector, broadcast along rows
246239
if (lhsRows != rhsRows) {
247-
std::cout<<"here 8"<<std::endl;
248240
throw ErrorHandler::compilerError(
249241
loc, "EwOpsLowering (BinaryOp)",
250242
"could not broadcast rhs along rows. Rhs must "
@@ -258,7 +250,6 @@ class BinaryOpLowering final : public mlir::OpConversionPattern<BinaryOp> {
258250
} else {
259251
// rhs is not broadcasted, return identity mapping
260252
if (lhsRows != rhsRows || lhsCols != rhsCols) {
261-
std::cout<<"here 9"<<std::endl;
262253
throw ErrorHandler::compilerError(
263254
loc, "EwOpsLowering (BinaryOp)",
264255
"lhs and rhs must have equal dimensions or allow for broadcasting but operands have dimensions (" +
@@ -388,9 +379,7 @@ class BinaryOpLowering final : public mlir::OpConversionPattern<BinaryOp> {
388379
auto resSparseMemRef = rewriter.create<memref::AllocOp>(loc, sparseLhsValuesMemRefType, ValueRange{one});
389380

390381
rewriter.create<scf::ForOp>(
391-
// loc, rowPtr, nextRowPtr, rewriter.create<arith::ConstantIndexOp>(loc, 1),
392382
loc, zero, numSparseLhsRowsValue, one, ValueRange{},
393-
// [&](OpBuilder &OpBuilderNested, Location locNested, Value loopIdx)
394383
[&](OpBuilder &OpBuilderNested, Location locNested, Value loopIdx, ValueRange loopInvariants)
395384
{
396385
auto rowPtr = loopIdx;
@@ -402,12 +391,9 @@ class BinaryOpLowering final : public mlir::OpConversionPattern<BinaryOp> {
402391
locNested, sparseLhsRowOffsetsMemRef, ValueRange{nextRowPtr});
403392

404393
OpBuilderNested.create<scf::ForOp>(
405-
// locNested, colIdxLowerIncl, colIdxUpperExcl, one, ValueRange{rowPtr},
406394
locNested, colIdxLowerIncl, colIdxUpperExcl, one, ValueRange{},
407-
// [&](OpBuilder &OpBuilderTwiceNested, Location locTwiceNested, Value loopIdxNested, ValueRange loopInvariantsNested)
408395
[&](OpBuilder &OpBuilderTwiceNested, Location locTwiceNested, Value loopIdxNested, ValueRange loopInvariants)
409396
{
410-
// auto rowIdx = loopInvariantsNested[0];
411397
auto rowIdx = rowPtr;
412398
auto colIdx = OpBuilderTwiceNested.create<memref::LoadOp>(
413399
locTwiceNested, sparseLhsColIdxsMemRef, ValueRange{loopIdxNested});
@@ -420,48 +406,37 @@ class BinaryOpLowering final : public mlir::OpConversionPattern<BinaryOp> {
420406

421407
Value resValue = binaryFunc(
422408
OpBuilderTwiceNested, locTwiceNested, this->typeConverter, sparseLhsValue, denseRhsValue);
423-
424-
//Value store;
425409

426410
if (llvm::isa<daphne::EwAddOp>(op))
427411
{
428-
// auto store = OpBuilderTwiceNested.create<memref::StoreOp>(
429412
OpBuilderTwiceNested.create<memref::StoreOp>(
430413
locTwiceNested, resValue, resDenseMemRef, ValueRange{rowIdx, colIdx});
431414
}
432415
else if (llvm::isa<daphne::EwMulOp>(op))
433416
{
434-
// auto store = OpBuilderTwiceNested.create<memref::StoreOp>(
435417
OpBuilderTwiceNested.create<memref::StoreOp>(
436418
locTwiceNested, resValue, resSparseMemRef, ValueRange{loopIdxNested});
437419
}
438420
else
439421
{
440-
std::cout<<"here 10"<<std::endl;
441422
throw ErrorHandler::compilerError(loc, "EwOpsLowering (BinaryOp)", "Unsupported ewOps codegen");
442423
}
443424
OpBuilderTwiceNested.create<scf::YieldOp>(locTwiceNested, resValue);
444-
// OpBuilderTwiceNested.create<scf::YieldOp>(locTwiceNested);
445425
}
446426
);
447-
448-
// OpBuilderNested.create<scf::YieldOp>(locNested, resValue);
449-
// auto resValue = colLoop.getResult(0);
450427
OpBuilderNested.create<scf::YieldOp>(locNested);
451428
}
452429
);
453430

454431
if (llvm::isa<daphne::EwAddOp>(op))
455432
{
456433
Value resDenseMatrix = convertMemRefToDenseMatrix(loc, rewriter, resDenseMemRef, op.getType());
457-
std::cout<<"here 1"<<std::endl;
458434
rewriter.replaceOp(op, resDenseMatrix);
459435

460436
return mlir::success();
461437
}
462438
else if (llvm::isa<daphne::EwMulOp>(op))
463439
{
464-
llvm::errs()<<resSparseMemRef[0]<< "\n";
465440
Value maxNumRowsValue = rewriter.create<arith::ConstantIndexOp>(loc, sparseLhsRows);
466441
Value numColsValue = rewriter.create<arith::ConstantIndexOp>(loc, sparseLhsCols);
467442
Value maxNumNonZerosValue = rewriter.create<arith::ConstantIndexOp>(loc, sparseLhsCols * sparseLhsRows);
@@ -473,16 +448,11 @@ class BinaryOpLowering final : public mlir::OpConversionPattern<BinaryOp> {
473448
if (!resCSRMatrix) {
474449
llvm::errs() << "Error: resCSRMatrix is null!\n";
475450
}
476-
std::cout<<"here 2"<<std::endl;
477-
op.dump();
478451
rewriter.replaceOp(op, resCSRMatrix);
479-
std::cout<<"here 3"<<std::endl;
480-
op.dump();
481452
return mlir::success();
482453
}
483454
else
484455
{
485-
std::cout<<"here 11"<<std::endl;
486456
throw ErrorHandler::compilerError(loc, "EwOpsLowering (BinaryOp)", "Unsupported ewOps codegen");
487457
}
488458
}
@@ -567,14 +537,11 @@ class BinaryOpLowering final : public mlir::OpConversionPattern<BinaryOp> {
567537

568538

569539
auto lhsEndFirst = OpBuilderNested.create<arith::CmpIOp>(
570-
// locNested, arith::CmpIPredicate::ult, lhsColIdxLowerIncl, lhsColIdxUpperExcl);
571540
locNested, arith::CmpIPredicate::ult, lhsColUpper, rhsColUpper);
572541

573542
auto lhsAllZero = OpBuilderNested.create<arith::CmpIOp>(
574-
// locNested, arith::CmpIPredicate::eq, lhsColUpper, rhsColUpper);
575543
locNested, arith::CmpIPredicate::eq, lhsColIdxLowerIncl, lhsColIdxUpperExcl);
576544
auto rhsAllZero = OpBuilderNested.create<arith::CmpIOp>(
577-
// locNested, arith::CmpIPredicate::eq, lhsColUpper, rhsColUpper);
578545
locNested, arith::CmpIPredicate::eq, rhsColIdxLowerIncl, rhsColIdxUpperExcl);
579546

580547
auto operation = OpBuilderNested.create<scf::IfOp>(
@@ -881,7 +848,6 @@ class BinaryOpLowering final : public mlir::OpConversionPattern<BinaryOp> {
881848
ssize_t rhsCols = rhsMatrixType.getNumCols();
882849

883850
if (lhsRows < 0 || lhsCols < 0 || rhsRows < 0 || rhsCols < 0) {
884-
std::cout<<"here 4"<<std::endl;
885851
throw ErrorHandler::compilerError(
886852
loc, "EwOpsLowering (BinaryOp)",
887853
"ewOps codegen currently only works with matrix dimensions that are known at compile time");

src/compiler/lowering/MatMulOpLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ class MatMulLowering : public OpConversionPattern<daphne::MatMulOp> {
614614
OpBuilderNested.create<scf::YieldOp>(locNested, ValueRange{});
615615
}
616616
);
617-
// Value resDenseMatrix = convertMemRefToDenseMatrix(loc, rewriter, resMemRef, op.getType());
617+
618618
Value resDenseMatrix = convertMemRefToDenseMatrix(loc, rewriter, resMemRef, rhs.getType());
619619
rewriter.replaceOp(op, resDenseMatrix);
620620
return mlir::success();

src/runtime/local/kernels/EwUnaryMat.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,18 @@ template <typename VT> struct EwUnaryMat<CSRMatrix<VT>, CSRMatrix<VT>> {
110110
res = DataObjectFactory::create<CSRMatrix<VT>>(numRows, numCols, maxNumNonZeros, false);
111111

112112
const VT *valuesArg = arg->getValues();
113+
const size_t *colIdxsArg = arg->getColIdxs();
114+
const size_t *rowOffsetsArg = arg->getRowOffsets();
115+
113116
VT *valuesRes = res->getValues();
117+
size_t *colIdxsRes = res->getColIdxs();
118+
size_t *rowOffsetsRes = res->getRowOffsets();
119+
120+
for (size_t i = 0; i < numNonZeros; i++)
121+
colIdxsRes[i] = colIdxsArg[i];
114122

115-
res->getColIdxsSharedPtr() = arg->getColIdxsSharedPtr();
116-
res->getRowOffsetsSharedPtr() = arg->getRowOffsetsSharedPtr();
123+
for (size_t i = 0; i < numRows + 1; i++)
124+
rowOffsetsRes[i] = rowOffsetsArg[i];
117125

118126
EwUnaryScaFuncPtr<VT, VT> func = getEwUnaryScaFuncPtr<VT, VT>(opCode);
119127

0 commit comments

Comments
 (0)