Skip to content

Commit

Permalink
Added Sobel without pad
Browse files Browse the repository at this point in the history
  • Loading branch information
Branimir Pervan authored and Branimir Pervan committed Oct 24, 2023
1 parent e2a899e commit 5cd93e9
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/main/scala/apps/tester.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package apps
import elevate.core._
import rise.GAP8.DSL.gap8Run
import rise.GAP8.primitives.{copyToL1, copyToL2, gap8hwConv3x3}
import rise.core.DSL.HighLevelConstructs.zipND
import rise.core.DSL.HighLevelConstructs.{slide2D, zipND}
import rise.core.DSL.Type._
import rise.core.DSL._
import rise.core._
Expand Down Expand Up @@ -44,9 +44,35 @@ object tester {
| return res;
| }
|""".stripMargin,
i16 ->: i16
u32 ->: u32
)

val h: Nat = 240
val w: Nat = 320


//(h`.`w`.`u8) ->: (3`.`3`.`int) ->: (3`.`3`.`int) ->: (h`.`w`.`u8
val sobelWithoutPad: ToBeTyped[Rise] =
fun(
ArrayType(h, ArrayType(w, u8)) ->:
ArrayType(3, ArrayType(3, u8)) ->:
ArrayType(3, ArrayType(3, u8)) ->:
ArrayType(h - 2, ArrayType(w - 2, u8))
)((pic, hf, vf) =>
gap8Run(8)(
pic |>
slide2D(sz = 3, st = 1) |>
mapSeq(mapSeq(fun(submat =>
zip(submat |> join)(hf |> join) |> map(fun(x => (cast(fst(x)) :: u32) * cast(snd(x)) :: u32)) |> reduceSeq(add)(cast(l(0)) :: u32) |> letf(h =>
zip(submat |> join)(vf |> join) |> map(fun(x => (cast(fst(x)) :: u32) * cast(snd(x)) :: u32)) |> reduceSeq(add)(cast(l(0)) :: u32) |> letf(v =>
cast(gapSqrt(h * h + v * v)) :: u8
)
)
))))
)

println(translateToString(util.gen.gap8.hosted("SobelWOutPad").fromExpr(sobelWithoutPad)))

//2D Zip
//Merge mapPar
//1D slide
Expand Down

0 comments on commit 5cd93e9

Please sign in to comment.