diku-dk / linalg

Linear algebra package for Futhark
ISC License
17 stars 4 forks source link

Broken call to "flatten_to" in linalg.fut #6

Closed Woogachaka closed 1 year ago

Woogachaka commented 1 year ago

when trying to compile using linalg

Error at lib/github.com/diku-dk/linalg/linalg.fut:221:13-22: Unknown name "flatten_to" If you find this error message confusing, uninformative, or wrong, please open an issue: https://github.com/diku-dk/futhark/issues

athas commented 1 year ago

That's because you're using an unreleased version of the compiler. We're removing flatten_to. We haven't made a new release of linalg because it might break compatibility with the latest release. It may be possible to create a forwards- and backwards-compatible version of this is a problem for you.

Woogachaka commented 1 year ago

thank you for the swift response! That said, I'd be happy with just a patched solution in my case for now (with the plan to appropriately swap over once all the appropriate supports are in place). Is there a definition of flatten_to you could direct me to for now? I admit I don't fully understand the difference between flatten_to and flatten

athas commented 1 year ago

Yes, I wrote a small library of the functions that we are removing:

-- Redefinitions of prelude functions that changed their type, or were
-- removed, since Futhark 0.24.3.  Does not redefine functions that
-- were previously existential and were simply made more precise
-- (concat, flatten).

def split [n] 't (i: i64) (xs: [n]t): ([i]t, []t) =
  (xs[0:i], xs[i:])

def concat_to [n] [m] 't (k: i64) (xs: [n]t) (ys: [m]t): *[k]t =
  resize k (concat xs ys)

def flatten_to [n][m] 't (l: i64) (xs: [n][m]t): [l]t =
  resize l (flatten xs)

def unflatten [p] 't (n: i64) (m: i64) (xs: [p]t): [n][m]t =
  unflatten (resize (n*m) xs)

def unflatten_3d [p] 't (n: i64) (m: i64) (l: i64) (xs: [p]t): [n][m][l]t =
  unflatten n m (unflatten (n*m) l xs)

def unflatten_4d [p] 't (n: i64) (m: i64) (l: i64) (k: i64) (xs: [p]t): [n][m][l][k]t =
  unflatten n m (unflatten_3d (n*m) l k xs)

You'll have to patch your local copy of linalg, though. I'll see if I can just make it compatible.

Woogachaka commented 1 year ago

thanks! I'll try this patch out and let you know how it goes.

athas commented 1 year ago

Tagged a new version.