From c7ee7fb0cc0c7894672a03a015bb8b84d044ddec Mon Sep 17 00:00:00 2001 From: yxy Date: Thu, 26 Oct 2023 22:44:44 +0800 Subject: [PATCH] add tile-conv-relu --- examples/GemminiDialect/makefile | 9 +++++ examples/GemminiDialect/tile-conv-relu.mlir | 39 +++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 examples/GemminiDialect/tile-conv-relu.mlir diff --git a/examples/GemminiDialect/makefile b/examples/GemminiDialect/makefile index 88abb0647d..3b11f8fd12 100644 --- a/examples/GemminiDialect/makefile +++ b/examples/GemminiDialect/makefile @@ -121,6 +121,15 @@ tile-conv-run: @riscv64-unknown-linux-gnu-gcc log.o -O2 -static -o a.out @spike --extension=gemmini pk a.out +tile-conv-relu-run: + @${BUDDY_OPT} ./tile-conv-relu.mlir -lower-gemmini | \ + ${BUDDY_TRANSLATE} --buddy-to-llvmir | \ + ${BUDDY_LLC} -filetype=obj -mtriple=riscv64 \ + -mattr=+buddyext,+D -float-abi=hard \ + -o log.o + @riscv64-unknown-linux-gnu-gcc log.o -O2 -static -o a.out + @spike --extension=gemmini pk a.out + tile-rect-conv-run: @${BUDDY_OPT} ./tile-rect-conv.mlir -lower-gemmini | \ ${BUDDY_TRANSLATE} --buddy-to-llvmir | \ diff --git a/examples/GemminiDialect/tile-conv-relu.mlir b/examples/GemminiDialect/tile-conv-relu.mlir new file mode 100644 index 0000000000..21fd10113d --- /dev/null +++ b/examples/GemminiDialect/tile-conv-relu.mlir @@ -0,0 +1,39 @@ +// RUN: buddy-opt %s \ +// RUN: --lower-gemmini | \ +// RUN: FileCheck %s + +// batchSize = 1 inputDim = 5 inChannels = 1 +memref.global "private" @input : memref<1x5x5x1xi8> = dense<[[[[1], [0], [-1], [0], [1]], + [[1], [0], [-1], [0], [1]], + [[1], [0], [-1], [0], [1]], + [[1], [0], [-1], [0], [1]], + [[1], [0], [-1], [0], [1]]]]> + +// outChannels = 2 kernelDim = 3 inChannels = 1 +memref.global "private" @weight : memref<9x2xi8> = dense<[[-1, 2], [-1, 2], [-1, 2], + [-1, 2], [-1, 2], [-1, 2], + [-1, 2], [-1, 2], [-1, 2]]> + +// outChannels = 2 +memref.global "private" @bias : memref<2xi32> = dense<[1,1]> + +func.func @main() -> i64 { + %0 = arith.constant 0 : i64 + %3 = arith.constant 3 : i64 + %input = memref.get_global @input : memref<1x5x5x1xi8> + %weight = memref.get_global @weight : memref<9x2xi8> + %bias = memref.get_global @bias : memref<2xi32> + %output = memref.alloc() : memref<9x2xi8> + // CHECK: "gemmini.intr.loop_conv_ws_config1" + // CHECK: "gemmini.intr.loop_conv_ws_config2" + // CHECK: "gemmini.intr.loop_conv_ws_config3" + // CHECK: "gemmini.intr.loop_conv_ws_config4" + // CHECK: "gemmini.intr.loop_conv_ws_config5" + // CHECK: "gemmini.intr.loop_conv_ws_config6" + // CHECK: "gemmini.intr.loop_conv_ws" + // CHECK: "gemmini.intr.flush" + gemmini.tile_conv %input %weight %bias %output %3 %3 %3 {stride = 1, act = 1}: + memref<1x5x5x1xi8> memref<9x2xi8> memref<2xi32> memref<9x2xi8> i64 i64 i64 + gemmini.print %output : memref<9x2xi8> + return %0 : i64 +}