Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uniqueness error after fusion #1358

Closed
athas opened this issue May 25, 2021 · 1 comment
Closed

Uniqueness error after fusion #1358

athas opened this issue May 25, 2021 · 1 comment
Assignees

Comments

@athas
Copy link
Member

athas commented May 25, 2021

let iota_2d (n: i64) : [n][n](i64, i64) =
  tabulate_2d n n (\i j -> (i, j))

let first_anti_diag [n] 't (i: i64) (xs: [n][n]t) =
  if i >= 0 then
   xs
    |> flatten
    |> (.[i:n * i + 1:n - 1])
  else []

let process_block [b]
                  (prev_anti_diag: [][b][b]i32)
                  (block: [b][b]i32)
                  (i: i64) : *[b][b]i32 =
  let inds = tabulate b (\tx -> (tx, tx))
  let vals = tabulate b (\tx -> prev_anti_diag[i, tx - 1, b - 1])
  in scatter_2d (copy block) inds vals

let main [b][num_blocks] (i: i64) (matb: *[num_blocks][num_blocks][b][b]i32) =
  #[unsafe]
  let ip1 = i + 1
  let res = map2 (process_block (first_anti_diag (i - 1) matb))
                 (first_anti_diag i matb :> [ip1][b][b]i32)
                 (iota ip1)
  in scatter_2d matb (iota_2d num_blocks |> first_anti_diag i :> [ip1](i64, i64)) res

My guess is that we're not being careful about the aliases of that if expression.

@athas athas self-assigned this May 25, 2021
@athas
Copy link
Member Author

athas commented May 25, 2021

Much simpler:

let main [n] (xs: *[n]i32) =
  let vals = map (+2) (reverse xs)
  in scatter xs (iota n) vals

How did we not notice this before?

@athas athas closed this as completed in b3e875b May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant