Open Bastacyclop opened 3 years ago
I believe that using temporary values for index computations would avoid at least part of the exponential blowup. Additionally a lot of the branching could be eliminated at the imperative DPIA level, but this requires some work and would benefit from https://github.com/rise-lang/shine/issues/22.
If we change the program to clamp before generate, code generation is fast and the code size is reasonable (1300 characters):
map(padClamp2D(0, 1))(input) |> fun(clamped =>
generate(fun(i =>
select(i < alpha)(
zipND(2)(clamped `@` i, clamped `@` alpha) |>
map(map(fun(p => fst(p) * snd(p))))
)(clamped `@` alpha)
)) |>
map(dropLast(1)) >>
map(map(dropLast(1))) >>
normalize(h)(w) >> mapSeq(mapSeq(mapSeq(id)))
)
The code size blowup might be related to how padClamp
is implemented.
The example expression shown in https://github.com/rise-lang/shine/pull/83 takes around 4mn to compile and generates huge code (about 60 million characters) with too many ifs.