Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions include/Standalone/LinneaDialect.td
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def Linnea_Dialect : Dialect {
let extraClassDeclaration = [{
//Type parseType(DialectAsmParser& parser) const override;
//void printType(Type type, DialectAsmPrinter& printer) const override;
Attribute parseAttribute(DialectAsmParser &parser, Type type) const override;
void printAttribute(Attribute attr, DialectAsmPrinter &printer) const override;
//Attribute parseAttribute(DialectAsmParser &parser, Type type) const override;
//void printAttribute(Attribute attr, DialectAsmPrinter &printer) const override;
}];
}

Expand Down
64 changes: 58 additions & 6 deletions include/Standalone/LinneaPasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,66 @@
#ifndef LINNEA_PASSES_H
#define LINNEA_PASSES_H

#include "mlir/Dialect/Bufferization/IR/Bufferization.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Dialect/SCF/SCF.h"
#include "mlir/Dialect/Vector/IR/VectorOps.h"
#include "mlir/Pass/Pass.h"

namespace mlir {
class ModuleOp;
} // namespace mlir

namespace mlir {
namespace func {
class FuncOp;
} // namespace func
} // namespace mlir

namespace mlir {
namespace vector {
class VectorDialect;
} // namespace vector
} // namespace mlir

namespace mlir {
namespace linalg {
class LinalgDialect;
} // namespace linalg
} // namespace mlir

namespace mlir {
namespace scf {
class SCFDialect;
} // namespace scf
} // namespace mlir

namespace mlir {
namespace memref {
class MemRefDialect;
} // namespace memref
} // namespace mlir

namespace mlir {
namespace arith {
class ArithmeticDialect;
} // namespace arith
} // namespace mlir

namespace mlir {
namespace bufferization {
class BufferizationDialect;
} // namespace bufferization
} // namespace mlir

namespace mlir {
namespace tensor {
class TensorDialect;
} // namespace tensor
} // namespace mlir

namespace mlir {
namespace LLVM {
class LLVMDialect;
} // namespace LLVM
} // namespace mlir

namespace mlir {
namespace linnea {
std::unique_ptr<OperationPass<func::FuncOp>> createConvertLinneaToLinalgPass();
Expand Down
4 changes: 4 additions & 0 deletions lib/Standalone/LinneaCompilerPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@
#include "mlir/Conversion/ReconcileUnrealizedCasts/ReconcileUnrealizedCasts.h"
#include "mlir/Conversion/SCFToControlFlow/SCFToControlFlow.h"
#include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h"
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
#include "mlir/Dialect/Arithmetic/Transforms/Passes.h"
#include "mlir/Dialect/Bufferization/IR/Bufferization.h"
#include "mlir/Dialect/Bufferization/Transforms/Passes.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/Func/Transforms/Passes.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/Linalg/Passes.h"
#include "mlir/Dialect/Linalg/Transforms/BufferizableOpInterfaceImpl.h"
#include "mlir/Dialect/Tensor/Transforms/Passes.h"
Expand Down
6 changes: 6 additions & 0 deletions lib/Standalone/LinneaConvertToLinalg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@
#include "Standalone/LinneaOps.h"
#include "Standalone/LinneaPasses.h"
#include "Standalone/LinneaUtils.h"
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
#include "mlir/Dialect/Bufferization/IR/Bufferization.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/Func/Transforms/FuncConversions.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Vector/IR/VectorOps.h"
#include "mlir/Transforms/DialectConversion.h"

#include "mlir/Pass/Pass.h"
Expand Down
1 change: 1 addition & 0 deletions lib/Standalone/LinneaConvertToLoops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Standalone/LinneaPasses.h"
#include "Standalone/LinneaUtils.h"
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
#include "mlir/Dialect/Bufferization/IR/Bufferization.h"
#include "mlir/Dialect/Linalg/Passes.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Pass/PassManager.h"
Expand Down
2 changes: 1 addition & 1 deletion test/Integration/linnea-lower-add-op.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// RUN: FileCheck %s
//
module {
func @entry() {
func.func @entry() {

%c5 = arith.constant 5 : index
%fc = arith.constant 5.0 : f32
Expand Down
2 changes: 1 addition & 1 deletion test/Integration/linnea-lower-add-op2.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// RUN: FileCheck %s
//
module {
func @entry() {
func.func @entry() {

%c5 = arith.constant 5 : index
%fc = arith.constant 5.0 : f32
Expand Down
2 changes: 1 addition & 1 deletion test/Integration/linnea-lower-chain.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// RUN: rm -rf %testdir/chain

module {
func @entry() {
func.func @entry() {

// A1.
%fA1 = arith.constant 1 : i32
Expand Down
2 changes: 1 addition & 1 deletion test/Integration/linnea-lower-mul-op.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

module {
func @entry() {
func.func @entry() {

%c5 = arith.constant 5 : index

Expand Down
2 changes: 1 addition & 1 deletion test/Integration/linnea-lower-mul-op2.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

module {
func @entry() {
func.func @entry() {

%c5 = arith.constant 5 : index
%fc = arith.constant 5.0 : f32
Expand Down
2 changes: 1 addition & 1 deletion test/Integration/linnea-lower-mul-op3.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

module {
func @entry() {
func.func @entry() {

%c5 = arith.constant 5 : index
%fc = arith.constant 5.0 : f32
Expand Down
4 changes: 2 additions & 2 deletions test/Standalone/canonicalize.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// CHECK-LABEL: @bar
// CHECK-SAME: %[[arg0:[a-zA-Z0-9]+]]: !linnea.matrix<#linnea.property<["square"]>, [32, 32], f32>
func @bar(%arg0 : !linnea.matrix<#linnea.property<["square"]>, [32,32], f32>) -> !linnea.term {
func.func @bar(%arg0 : !linnea.matrix<#linnea.property<["square"]>, [32,32], f32>) -> !linnea.term {

%0 = linnea.equation {
%1 = linnea.inverse.high %arg0 : !linnea.matrix<#linnea.property<["square"]>, [32,32], f32>
Expand All @@ -19,7 +19,7 @@ func @bar(%arg0 : !linnea.matrix<#linnea.property<["square"]>, [32,32], f32>) ->

// CHECK-LABEL: @bar
// CHECK-SAME: %[[arg0:[a-zA-Z0-9]+]]: !linnea.matrix<#linnea.property<["general"]>, [32, 32], f32>
func @bar(%arg0: !linnea.matrix<#linnea.property<["general"]>, [32, 32], f32>,
func.func @bar(%arg0: !linnea.matrix<#linnea.property<["general"]>, [32, 32], f32>,
%arg1: !linnea.identity<[32, 32], f32>) -> !linnea.term {

%0 = linnea.equation {
Expand Down
2 changes: 1 addition & 1 deletion test/Standalone/conversion.mlir
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: standalone-opt %s --properties-propagation --linnea-func-type-conversion --convert-linnea-to-linalg | FileCheck %s

// CHECK-LABEL: func @bar(
func @bar(%arg0: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>,
func.func @bar(%arg0: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>,
%arg1: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) {
%0 = linnea.equation {
// CHECK: %{{.*}} = linalg.generic
Expand Down
2 changes: 1 addition & 1 deletion test/Standalone/invalid.mlir
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: standalone-opt --verify-diagnostics %s

func @some_func() {
func.func @some_func() {
// expected-error @below {{Unexpected empty region}}
linnea.equation {

Expand Down
14 changes: 7 additions & 7 deletions test/Standalone/ops.mlir
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: standalone-opt --split-input-file %s | standalone-opt | FileCheck %s

// CHECK-LABEL: func @bar(
func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) {
func.func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) {
// CHECK: %{{.*}} = linnea.mul.low %{{.*}}
%0 = linnea.mul.low %arg0, %arg1 { semirings = "min-plus" }: !linnea.term, !linnea.matrix<#linnea.property<["general"]>,[32,32], f32> -> !linnea.term
return
Expand All @@ -10,7 +10,7 @@ func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"
// -----

// CHECK-LABEL: func @bar(
func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) {
func.func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) {
%0 = linnea.equation {
// CHECK: %{{.*}} = linnea.mul.high %{{.*}}
%1 = linnea.mul.high %arg0, %arg1 : !linnea.term, !linnea.matrix<#linnea.property<["general"]>,[32,32], f32> -> !linnea.term
Expand All @@ -22,7 +22,7 @@ func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"
// -----

// CHECK-LABEL: func @bar(
func @bar(%arg0: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) {
func.func @bar(%arg0: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) {
// CHECK: %{{.*}} = linnea.equation
%0 = linnea.equation {
// CHECK: %[[T:.*]] = linnea.transpose %{{.*}}
Expand All @@ -36,7 +36,7 @@ func @bar(%arg0: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) {
// -----

// CHECK-LABEL: func @bar(
func @bar(%arg0: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>, %arg1: f32) {
func.func @bar(%arg0: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>, %arg1: f32) {
// CHECK: %{{.*}} = linnea.fill
linnea.fill(%arg1, %arg0) : f32, !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>
return
Expand All @@ -45,7 +45,7 @@ func @bar(%arg0: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>, %ar
// -----

// CHECK-LABEL: func @bar(
func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) {
func.func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) {
%0 = linnea.equation {
// CHECK: %{{.*}} = linnea.mul.high
%1 = linnea.mul.high %arg0, %arg1 { semirings = "min-plus" } : !linnea.term, !linnea.matrix<#linnea.property<["general"]>,[32,32], f32> -> !linnea.term
Expand All @@ -57,7 +57,7 @@ func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"
// -----

// CHECK-LABEL: func @bar(
func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) {
func.func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) {
// CHECK: %{{.*}} = linnea.mul.low %{{.*}}
%0 = linnea.mul.low %arg0, %arg1 { semirings = "min-plus" } : !linnea.term, !linnea.matrix<#linnea.property<["general"]>,[32,32], f32> -> !linnea.term
return
Expand All @@ -66,7 +66,7 @@ func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"
// -----

// CHECK-LABEL: func @bar(
func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) {
func.func @bar(%arg0: !linnea.term, %arg1: !linnea.matrix<#linnea.property<["general"]>,[32,32], f32>) {
%0 = linnea.equation {
// CHECK: %{{.*}} = linnea.mul.high %{{.*}}
%1 = linnea.mul.high %arg0, %arg1 { semirings = "min-plus" } : !linnea.term, !linnea.matrix<#linnea.property<["general"]>,[32,32], f32> -> !linnea.term
Expand Down
4 changes: 2 additions & 2 deletions test/Standalone/properties-propagation.mlir
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: standalone-opt %s --split-input-file --properties-propagation | FileCheck %s
module {
// CHECK: entry
func @entry() {
func.func @entry() {

%c5 = arith.constant 5 : index
%fc = arith.constant 5.0 : f32
Expand Down Expand Up @@ -46,7 +46,7 @@ module {

module {
// CHECK: entry
func @entry() {
func.func @entry() {

%c5 = arith.constant 5 : index
%fc = arith.constant 5.0 : f32
Expand Down