Views with repeating indices lead to different results than Base.Array
- Dominant language
- Julia
- Stars
- 1.4k
- Forks
- 281
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 30
Description
**Describe the bug**
Views don't play well with assignments, leading to silent errors.
**To Reproduce**
The Minimal Working Example (MWE) for this bug:
```julia
using Revise, CuArrays, Flux
function cusubmwe(N)
v = ones(Float32, N)
vgpu = v|> gpu
indices = (i->(i-1)%N + 1).(1:N^2)
subv = view(v, indices)
subvgpu = view(vgpu, indices)
subv .+= 1
subvgpu .+= 1
@info "indices: $indices"
@info "cpu: $(v)"
@info "gpu: $(vgpu)"
end
```
Output:
```
[ Info: indices: [1, 2, 3, 1, 2, 3, 1, 2, 3]
[ Info: cpu: Float32[4.0, 4.0, 4.0]
[ Info: gpu: Float32[2.0, 2.0, 2.0]
```
**Expected behavior**
The cpu version provides a baseline.
**Build log**
```
Building WebIO ──→ `C:\Users\Clinton\.julia\packages\WebIO\2mZPb\deps\build.log`
Building NNlib ──→ `C:\Users\Clinton\.julia\packages\NNlib\FAI3o\deps\build.log`
Building Libtask → `C:\Users\Clinton\.julia\packages\Libtask\GQPaW\deps\build.log`
Building CMake ──→ `C:\Users\Clinton\.julia\packages\CMake\ULbyn\deps\build.log`
Building NLopt ──→ `C:\Users\Clinton\.julia\packages\NLopt\eqN9a\deps\build.log`
```
**Environment details (please complete this section)**
Details on Julia:
```
Commit b8e9a9ecc6 (2020-03-21 16:36 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-8.0.1 (ORCJIT, skylake)
Environment:
JULIA_EDITOR = "C:\Users\Clinton\AppData\Local\atom\app-1.45.0\atom.exe" -a
JULIA_NUM_THREADS = 6
```
Julia packages:
CuArrays v2.0.1 #master (https://github.com/JuliaGPU/CuArrays.jl.git)
GPUArrays v3.1.0 #master (https://github.com/JuliaGPU/GPUArrays.jl.git)
CUDAnative v3.0.4
Flux v0.10.4 #master (https://github.com/FluxML/Flux.jl.git)
CUDA: toolkit and driver version
10.2 / 441.66
**Additional context**
This came up in the context of https://github.com/FluxML/Zygote.jl/issues/600, but I am basing the mwe on an example from Michael Abbott from Slack (https://julialang.slack.com/archives/C6G240ENA/p1587070650391500).
I think this is the reason I was having difficulties with Zygote AD on views of CuArrays as mentioned in that issue, though I don't know for sure.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.