Skip to content

Commit

Permalink
Working Small conversion of arith to qcggi
Browse files Browse the repository at this point in the history
  • Loading branch information
WoutLegiest committed Jan 15, 2025
1 parent 80140b0 commit 1e77b0c
Show file tree
Hide file tree
Showing 16 changed files with 566 additions and 595 deletions.
415 changes: 415 additions & 0 deletions lib/Dialect/Arith/Conversions/ArithToCGGIQuart/ArithToCGGIQuart.cpp

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions lib/Dialect/Arith/Conversions/ArithToCGGIQuart/ArithToCGGIQuart.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef LIB_DIALECT_ARITH_CONVERSIONS_ARITHTOCGGIQUART_ARITHTOCGGIQUART_H_
#define LIB_DIALECT_ARITH_CONVERSIONS_ARITHTOCGGIQUART_ARITHTOCGGIQUART_H_

#include "mlir/include/mlir/Pass/Pass.h" // from @llvm-project

namespace mlir::heir::arith {

#define GEN_PASS_DECL
#include "lib/Dialect/Arith/Conversions/ArithToCGGIQuart/ArithToCGGIQuart.h.inc"

#define GEN_PASS_REGISTRATION
#include "lib/Dialect/Arith/Conversions/ArithToCGGIQuart/ArithToCGGIQuart.h.inc"

} // namespace mlir::heir::arith

#endif // LIB_DIALECT_ARITH_CONVERSIONS_ARITHTOCGGIQUART_ARITHTOCGGIQUART_H_
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
#ifndef LIB_DIALECT_ARITH_TRANSFORMS_PASSES_TD_
#define LIB_DIALECT_ARITH_TRANSFORMS_PASSES_TD_
#ifndef LIB_DIALECT_ARITH_CONVERSIONS_ARITHTOCGGIQUART_TD_
#define LIB_DIALECT_ARITH_CONVERSIONS_ARITHTOCGGIQUART_TD_

include "mlir/Pass/PassBase.td"

def QuarterWideInt : Pass<"arith-quarter-wide-int"> {

let summary = "Convert high precision arithmetic operations to a sequence of lower precision operations";
let description = [{
def ArithToCGGIQuart : Pass<"arith-to-cggi-quart"> {
let summary = "Lower `arith` to `cggi` dialect and divide each operation into smaller parts.";
let description = [{
This pass converts high precision arithmetic operations, i.e. operations on 32 bit integer,
into a sequence of lower precision operations, i.e 8b operations.
Currently, the pass splits the 32b integer into four 8b integers, using the tensor dialect.
These smaller integers are stored in an 16b integer, so that we don't lose the carry information.
This pass converts the `arith` dialect to the `cggi` dialect.

Based on the `arith-emulate-wide-int` pass from the MLIR arith dialect.

General assumption: the first element in the tensor is also the LSB element.
}];
let dependentDialects = [
"mlir::arith::ArithDialect",
"mlir::memref::MemRefDialect",
"mlir::tensor::TensorDialect",
"mlir::heir::cggi::CGGIDialect",
];
}

#endif // LIB_DIALECT_ARITH_TRANSFORMS_PASSES_TD_
#endif // LIB_DIALECT_ARITH_CONVERSIONS_ARITHTOCGGIQUART_ARITHTOCGGIQUART_TD_
46 changes: 46 additions & 0 deletions lib/Dialect/Arith/Conversions/ArithToCGGIQuart/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
load("@llvm-project//mlir:tblgen.bzl", "gentbl_cc_library")

package(
default_applicable_licenses = ["@heir//:license"],
default_visibility = ["//visibility:public"],
)

cc_library(
name = "ArithToCGGIQuart",
srcs = ["ArithToCGGIQuart.cpp"],
hdrs = ["ArithToCGGIQuart.h"],
deps = [
":pass_inc_gen",
"@heir//lib/Dialect/CGGI/IR:Dialect",
"@heir//lib/Utils:ConversionUtils",
"@llvm-project//mlir:ArithDialect",
"@llvm-project//mlir:IR",
"@llvm-project//mlir:MemRefDialect",
"@llvm-project//mlir:Pass",
"@llvm-project//mlir:TensorDialect",
"@llvm-project//mlir:Transforms",
],
)

gentbl_cc_library(
name = "pass_inc_gen",
tbl_outs = [
(
[
"-gen-pass-decls",
"-name=ArithToCGGIQuart",
],
"ArithToCGGIQuart.h.inc",
),
(
["-gen-pass-doc"],
"ArithToCGGIQuart.md",
),
],
tblgen = "@llvm-project//mlir:mlir-tblgen",
td_file = "ArithToCGGIQuart.td",
deps = [
"@llvm-project//mlir:OpBaseTdFiles",
"@llvm-project//mlir:PassBaseTdFiles",
],
)
41 changes: 0 additions & 41 deletions lib/Dialect/Arith/Transforms/BUILD

This file was deleted.

17 changes: 0 additions & 17 deletions lib/Dialect/Arith/Transforms/Passes.h

This file was deleted.

Loading

0 comments on commit 1e77b0c

Please sign in to comment.