JuliaSIMD / JuliaSIMD/LoopVectorization.jl

vmap gives incorrect results for iszero

Aperta
#149 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Julia
Stelle
789
Fork
73
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

If I run vmap with certain functions i get wrong results in some cases. I noticed this first for an integer array with iszero:
```
a = rand(Int8,200,20)
@test map(iszero,a) == vmap(iszero,a) #fails

```
Repeated evaluations of `vmap(iszero,a)` give different answers each time.
The same happens for some other functions I tested such as:

```
a = rand(200,20) #also for floats
vmap( ==(2.0), a)
vmap( >(0.5), a)
```
As a pattern these all return boolean arrays, functions that return floats seem to be unaffected.

vmapreduce is unaffected:
```
a = rand( Int8,200,20)
@test vmapreduce(iszero,+,a) == mapreduce(iszero,+,a) #passes
@test sum(map(iszero,a)) == sum(vmap(iszero,a)) #fails
```
The inplace version seems affected as well:
```
a = rand( Int8,200,20)
out = rand( Bool,200,20)
vmap!(iszero,out,a)
@test out == map(iszero,a) #fails
```
Interestingly this seems to consistently return the same (wrong) result instead of the always changing values of the out of place version. Here again this seems to only affect functions that return bools.

This is just from some playing around not something I actually need but unless I'm violating some assumptions LoopVectorization makes this seems like a bug.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.