JuliaSIMD / JuliaSIMD/LoopVectorization.jl

vmap gives incorrect results for iszero

Offen
#149 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Julia
Sterne
789
Forks
73
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.