Skip to content

Commit

Permalink
Workaround subarray test failure due to associativity. (#29386)
Browse files Browse the repository at this point in the history
| subarray: Test Failed at /usr/share/julia/test/subarray.jl:611
|  Expression: #= /usr/share/julia/test/subarray.jl:611 =# @inferred(sum(Base.unaliascopy(V))) == sum(V) == sum(A[2:5, :, 2:5, 1:2:5])
|   Evaluated: 121.8579669083425 == 121.8579669083425 == 121.85796690834263

A = rand(5,5,5,5)
V = view(A, 2:5, :, 2:5, 1:2:5)
@code_typed sum(V)  # calls mapfoldl
@code_typed sum(A[2:5, :, 2:5, 1:2:5])  # calls mapreduce

mapreduce doesn't guarantee the associativity, which is likely
the cause of this precision issue in random sum.

(cherry picked from commit 518f548)
  • Loading branch information
cdluminate authored and KristofferC committed Oct 19, 2018
1 parent d2238ec commit fff684c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test/subarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ V = view(A, 1:1 ,:, 1:3, :)
A = rand(5,5,5,5)
V = view(A, 2:5, :, 2:5, 1:2:5)
@test @inferred(Base.unaliascopy(V)) == V == A[2:5, :, 2:5, 1:2:5]
@test @inferred(sum(Base.unaliascopy(V))) == sum(V) == sum(A[2:5, :, 2:5, 1:2:5])
@test @inferred(sum(Base.unaliascopy(V))) sum(V) sum(A[2:5, :, 2:5, 1:2:5])

# issue #27632
function _test_27632(A)
Expand Down

0 comments on commit fff684c

Please sign in to comment.