Comments (3)
Your operator is not associative. It will function in the sequential backend because the neutral element is never given as the first argument to the operator, but has to be compatible with this.
ne `op` a == a
a`op` ne == a
(a `op` b) `op` c == a `op` (b `op` c)
To correct your code you can write
def minmax [n] (pts: [n]f32) : (f32, f32) =
let decorated_pts = (map (\(num) -> (num, num)) pts)
let (min, max) = reduce (\(amin, amax) (bmin, bmax) -> (f32.min amin bmin, f32.max amax bmax))
(f32.highest, f32.lowest) decorated_pts
in (min, max)
from futhark.
FluxusMagna is correct. There is a bit more information here: https://futhark-lang.org/examples/scan-reduce.html
And here: https://futhark-lang.org/examples/no-neutral-element.html
It is deceptively easy to think of reduce
as foldl
, but that is not what it is.
from futhark.
Thanks, I'll digest it :)
from futhark.
Related Issues (20)
- Internal compiler error: lmadcopyCPU: 0 HOT 1
- Platform inconsistency in power calculation HOT 6
- This should not type check
- Size-type error after pass `simplify` HOT 1
- Futhark does not run with GHC 9.8 HOT 2
- Internal compiler error: unknown variable HOT 1
- ispc backend failing on large ranges HOT 9
- Document `FUTHARK_COMPILER_DEBUGGING=2`.
- Limit context memory use HOT 4
- Internal compiler error
- Internal compiler error (unhandled IO exception).
- Dead repl link on front page HOT 1
- Justification for Alias Tracking HOT 1
- Module ascription does not type check
- Is it possible to add a compiled version of the windows version available for download? HOT 4
- Documentation improvement for Prelude math functions HOT 3
- Type suffixes should be ignored when unifying expressions
- Spurious variance in tensor contraction expression going into loop tiling HOT 10
- OpenCL and Macbook M1 pro - Program that uses builint hist fails to run HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from futhark.