Skip Navigation

AUTOMAP: How to do NumPy-style broadcasting in Futhark (but better)

futhark-lang.org

AUTOMAP: How to do NumPy-style broadcasting in Futhark (but better)

NumPy-style broadcasting = being able to write code like

 futhark
    
[[1, 2, 3],
 [4, 5, 6],  + [10, 11, 12]
 [7, 8, 9]]

  

and have it evaluate the same as

 futhark
    
              [[1, 2, 3],
map (map (+))  [4, 5, 6],  (rep 3 [10, 11, 12])
               [7, 8, 9]]

  

(which evaluates to [[11, 13, 15], [14, 16, 18], [18, 19, 21]]).

numpy docs. Numpy and most other languages do this at runtime, which is typically easier. But Futhark is statically-typed, so the type of the result must be known at compile time, and this means the broadcasting must also be done at compile time.

Hacker News @lemmy.smeargle.fans

NumPy-style broadcasting in Futhark

0 comments

No comments