Comments (2)
Another example of similar behaviour, except now there is no dead code, but there is a more complicated scalar expression to reason about.
let a = use (fromList (Z :. (1 :: Int)) [(1::Float,2::Float)])
b = map fst a
in generate (I1 (let I1 n1 = shape b ; I1 n2 = shape a in min n1 n2))
(\(I1 i) -> b ! I1 i)
This show
s as:
let
a0 = use (Vector (Z :. 1) [(((), 1.0), 2.0)])
a1 = map (\(T2 x0 _) -> x0) a0
in
generate (min (let T1 x0 = shape a1 in x0) (let T1 x0 = shape a0 in x0)) (\(T1 x0) -> a1 ! x0)
whereas an optimal fusion result would have been map fst (use (Vector ...))
.
Notable is that if fst
is replaced by (*2)
(and the type of a
with Vector Float
), then the map
does fuse. Is this an instance of the thing I ran into earlier, where nodes like map fst
in the fused AST are not actually compiled as manifest arrays but rather reduce to manipulation of SoA-form arrays?
from accelerate.
Two more programs that produce (somewhat) unexpected results:
zipWith (+)
(zipWith (\x y -> x * 2 * y) a a)
(map (\x -> x * x) a)
which show
s as:
\a0 ->
transform
(let T1 x0 = shape a0 ; T1 x1 = shape a0 ; T1 x2 = shape a0 in (min (min x1 x0) x2))
(\(T1 x0) -> x0)
(\x0 -> 2.0 * x0 * x0 + x0 * x0)
a0
which could have been \a -> map (\x -> 2 * x * x + x * x) a
.
Program 2:
zipWith (+) a (map (\x -> x) a)
which show
s as:
\a0 ->
let a1 = map (\x0 -> x0) a0
in
generate
(let T1 x0 = shape a1 ; T1 x1 = shape a0 in (min x1 x0))
(\(T1 x0) -> a0 ! x0 + a1 ! x0)
which could have been \a -> map (\x -> x * x) a
, or indeed \a -> generate (shape a) (\(T1 x) -> a ! x + a ! x)
.
I'm just collecting these for future reference at this point.
from accelerate.
Related Issues (20)
- [BUG] Build fails HOT 6
- [BUG] Imperfect dead code elimination
- [BUG] Unexpectedly long phases when training a neural network HOT 1
- Support CUDA 11 HOT 1
- [BUG] CUDA-10 library doesn't support the Turing-based RTX 2060? HOT 8
- `inconsistent valuation @ shared 'Acc'` when trying to lift non-`Acc` function to `Acc` HOT 6
- `Foreign` instance for reference interpreter
- Is there a way to force accelerate operations to be sequentially evaluated? HOT 10
- [BUG] doc bugs
- Could not enable debugging options HOT 5
- Support GHCJS compilation HOT 7
- [BUG] Function hashes have incorrect length causing internal errors HOT 2
- [BUG] undefined symbol: _ZTIN4llvm10CallbackVHE HOT 4
- [BUG] Value 'sm_30' is not defined for option 'gpu-name' HOT 4
- [BUG] typo in Semigroup instance of Exp (Maybe a) HOT 1
- How to realise convolution? HOT 13
- [Tracking Issue] Implementing (Segmented) Single-Pass Look-Back Scans
- [BUG] Internal error in package accelerate and LLVM.PTX backend: CUDA Exception - misaligned address HOT 1
- [BUG] Runtime error with llvm-ptx backend: double free or corruption (!prev)
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 accelerate.