Closed Munksgaard closed 2 years ago
This code, which relies on the fft library, produces an ICE when compiled with the C backend:
import "lib/github.com/diku-dk/fft/stockham-radix-2" module fft32 = mk_fft f32 let center_fft [n] 't (img: [n][n]t): [n][n]t = map (rotate 1) img let blur_fft [n] (kernel: [n][n]f32) (inp: [n][n]bool): [n][n]f32 = let kernel' = kernel |> fft32.fft2_re let inp' = map (map f32.bool) inp |> fft32.fft2_re in map2 (map2 (\x y -> x)) kernel' inp' |> center_fft |> fft32.ifft2 |> map (map (\(x, y) -> x + y)) let main [n] (img: [n][n]bool): [n][n]f32 = let blur = blur_fft (replicate n (replicate n 0)) in blur img
The error:
$ futhark-master c bluenoise-only.fut Warning at bluenoise-only.fut:13:21-21: Unused variable "y" . Internal compiler error. Please report this at https://github.com/diku-dk/futhark/issues. Type error after pass 'simplify': In function main When checking function body In expression of statement {defunc_3_map_res_13954 : ({}, [n_13735][n_13735]f32 @ mem_14569 -> {base: [n_13735, n_13735]; contiguous: true; LMADs: [{offset: 0i64; strides: [n_13735, 1i64]; rotates: [0i64, 0i64]; shape: [n_13735, n_13735]; permutation: [0, 1]; monotonicity: [Inc, Inc]}]}), defunc_3_map_res_13955 : ({}, [n_13735][n_13735]f32 @ mem_14572 -> {base: [n_13735, n_13735]; contiguous: true; LMADs: [{offset: 0i64; strides: [n_13735, 1i64]; rotates: [0i64, 0i64]; shape: [n_13735, n_13735]; permutation: [0, 1]; monotonicity: [Inc, Inc]}]})} Inside the loop body When matching {x_13956 : ({as_transformed_13921}, [n_13735]f32 @ mem_14451 -> {base: [n_13735, n_13735]; contiguous: true; LMADs: [{offset: mul_nw64 (i_14276) (n_13735); strides: [1i64]; rotates: [0i64]; shape: [n_13735]; permutation: [0]; monotonicity: [Inc]}, {offset: 0i64; strides: [n_13735, 1i64]; rotates: [1i64, 0i64]; shape: [n_13735, n_13735]; permutation: [1, 0]; monotonicity: [Inc, Inc]}]})} with as_transformed_13921[i_14276, 0i64 :+ n_13735 * 1i64] Type error: Expression type: {[n_13735]f32 @ (mem_14451 -> {base: [n_13735, n_13735]; contiguous: false; LMADs: [{offset: i_14276; strides: [n_13735]; rotates: [1i64]; shape: [n_13735]; permutation: [0]; monotonicity: [Inc]}]})} cannot match pattern type: {[n_13735]f32 @ (mem_14451 -> {base: [n_13735, n_13735]; contiguous: true; LMADs: [{offset: mul_nw64 (i_14276) (n_13735); strides: [1i64]; rotates: [0i64]; shape: [n_13735]; permutation: [0]; monotonicity: [Inc]}, {offset: 0i64; strides: [n_13735, 1i64]; rotates: [1i64, 0i64]; shape: [n_13735, n_13735]; permutation: [1, 0]; monotonicity: [Inc, Inc]}]})} with context elements: []
The solution is to perform LMAD-merging (like we do in ad-hoc ways in the various constructor functions) after simplifying the components of an index function.
This code, which relies on the fft library, produces an ICE when compiled with the C backend:
The error: