CLArrays.jl
CLArrays.jl copied to clipboard
"AssertionError: Found non concrete return type"
Originally posted as issue https://github.com/FluxML/Flux.jl/issues/325, but reposted here because it seems to be more of a CLArrays/Transpiler error than a Flux error.
This issue seems to be similar to issue https://github.com/JuliaGPU/CLArrays.jl/issues/5 in this repo.
Here's the code snippet that I am trying to run (based on the Flux linear regression example here):
import CLArrays
W = rand(CLArrays.CLArray{Float32}, 2, 5)
b = rand(CLArrays.CLArray{Float32}, 2)
predict(x) = W*x .+ b
loss(x, y) = sum((predict(x) .- y).^2)
x, y = rand(CLArrays.CLArray{Float32}, 5), rand(CLArrays.CLArray{Float32}, 2) # Dummy data
loss(x, y)
import Flux
W = Flux.Tracker.param(W)
b = Flux.Tracker.param(b)
l = loss(x, y)
Flux.back!(l)
Here is the output I get. Every line before Flux.back!(l) runs fine. Flux.back!(l) is the first line to give an error.
julia> import CLArrays
julia> W = rand(CLArrays.CLArray{Float32}, 2, 5)
GPU: 2×5 Array{Float32,2}:
0.267291 0.880699 0.750357 0.631781 0.306915
0.0219415 0.640799 0.565351 0.29246 0.555488
julia> b = rand(CLArrays.CLArray{Float32}, 2)
GPU: 2-element Array{Float32,1}:
0.227399
0.708808
julia> predict(x) = W*x .+ b
predict (generic function with 1 method)
julia> loss(x, y) = sum((predict(x) .- y).^2)
loss (generic function with 1 method)
julia> x, y = rand(CLArrays.CLArray{Float32}, 5), rand(CLArrays.CLArray{Float32}, 2) # Dummy data
(GPU: Float32[0.119538, 0.55785, 0.0553175, 0.0510188, 0.15501], GPU: Float32[0.825204, 0.021798])
julia> loss(x, y)
1.3931789f0
julia> import Flux
julia> W = Flux.Tracker.param(W)
Tracked 2×5 CLArrays.CLArray{Float32,2}:
0.267291 0.880699 0.750357 0.631781 0.306915
0.0219415 0.640799 0.565351 0.29246 0.555488
julia> b = Flux.Tracker.param(b)
Tracked 2-element CLArrays.CLArray{Float32,1}:
0.227399
0.708808
julia> l = loss(x, y)
1.393179f0 (tracked)
julia> Flux.back!(l)
___________________________________________________________________
Error in Expr rewrite! AssertionError("Found non concrete return type: Tuple{CLArrays.DeviceArray{Float32,2,Transpiler.CLIntrinsics.GlobalPointer{Float32}},CLArrays.DeviceArray{Float32,1,Transpiler.CLIntrinsics.GlobalPointer{Float32}},Any}")
Expression resulting in the error:
(Core.tuple)((CLArrays.reconstruct)((CLArrays.getindex)(x::Tuple{CLArrays.DeviceArray{Float32,2,CLArrays.HostPtr{Float32}},CLArrays.DeviceArray{Float32,1,CLArrays.HostPtr{Float32}},RowVector{Float32,CLArrays.CLArray{Float32,1}}}, 1)::CLArrays.DeviceArray{Float32,2,CLArrays.HostPtr{Float32}}, (CLArrays.getindex)(ptrs::Tuple{Transpiler.CLIntrinsics.GlobalPointer{Float32},Transpiler.CLIntrinsics.GlobalPointer{Float32},Transpiler.CLIntrinsics.GlobalPointer{Float32}}, 1)::Transpiler.CLIntrinsics.GlobalPointer{Float32})::CLArrays.DeviceArray{Float32,2,Transpiler.CLIntrinsics.GlobalPointer{Float32}}, (CLArrays.reconstruct)((CLArrays.getindex)(x::Tuple{CLArrays.DeviceArray{Float32,2,CLArrays.HostPtr{Float32}},CLArrays.DeviceArray{Float32,1,CLArrays.HostPtr{Float32}},RowVector{Float32,CLArrays.CLArray{Float32,1}}}, 2)::CLArrays.DeviceArray{Float32,1,CLArrays.HostPtr{Float32}}, (CLArrays.getindex)(ptrs::Tuple{Transpiler.CLIntrinsics.GlobalPointer{Float32},Transpiler.CLIntrinsics.GlobalPointer{Float32},Transpiler.CLIntrinsics.GlobalPointer{Float32}}, 2)::Transpiler.CLIntrinsics.GlobalPointer{Float32})::CLArrays.DeviceArray{Float32,1,Transpiler.CLIntrinsics.GlobalPointer{Float32}}, (CLArrays.reconstruct)((CLArrays.getindex)(x::Tuple{CLArrays.DeviceArray{Float32,2,CLArrays.HostPtr{Float32}},CLArrays.DeviceArray{Float32,1,CLArrays.HostPtr{Float32}},RowVector{Float32,CLArrays.CLArray{Float32,1}}}, 3)::RowVector{Float32,CLArrays.CLArray{Float32,1}}, (CLArrays.getindex)(ptrs::Tuple{Transpiler.CLIntrinsics.GlobalPointer{Float32},Transpiler.CLIntrinsics.GlobalPointer{Float32},Transpiler.CLIntrinsics.GlobalPointer{Float32}}, 3)::Transpiler.CLIntrinsics.GlobalPointer{Float32})::Any)::Tuple{CLArrays.DeviceArray{Float32,2,Transpiler.CLIntrinsics.GlobalPointer{Float32}},CLArrays.DeviceArray{Float32,1,Transpiler.CLIntrinsics.GlobalPointer{Float32}},Any}
happening in function tree:
Sugar stack trace:
[1] CLArrays.reconstruct(Tuple{CLArrays.DeviceArray{Float32,2,CLArrays.HostPtr{Float32}},CLArrays.DeviceArray{Float32,1,CLArrays.HostPtr{Float32}},RowVector{Float32,CLArrays.CLArray{Float32,1}}}, Transpiler.CLIntrinsics.GlobalPointer{Float32}, Transpiler.CLIntrinsics.GlobalPointer{Float32}, Transpiler.CLIntrinsics.GlobalPointer{Float32})
[2] GPUArrays.broadcast_kernel!(CLArrays.KernelState, Flux.Tracker.##41#42, CLArrays.DeviceArray{Float32,2,Transpiler.CLIntrinsics.GlobalPointer{Float32}}, Tuple{UInt32,UInt32}, Tuple{GPUArrays.BInfo{Array,2},GPUArrays.BInfo{Array,1},GPUArrays.BInfo{Array,2}}, Tuple{CLArrays.DeviceArray{Float32,2,Transpiler.CLIntrinsics.GlobalPointer{Float32}},CLArrays.DeviceArray{Float32,1,Transpiler.CLIntrinsics.GlobalPointer{Float32}},RowVector{Float32,CLArrays.CLArray{Float32,1}}})
Code of the context this error occured in:
begin
return (Core.tuple)((CLArrays.reconstruct)((CLArrays.getindex)(x::Tuple{CLArrays.DeviceArray{Float32,2,CLArrays.HostPtr{Float32}},CLArrays.DeviceArray{Float32,1,CLArrays.HostPtr{Float32}},RowVector{Float32,CLArrays.CLArray{Float32,1}}}, 1)::CLArrays.DeviceArray{Float32,2,CLArrays.HostPtr{Float32}}, (CLArrays.getindex)(ptrs::Tuple{Transpiler.CLIntrinsics.GlobalPointer{Float32},Transpiler.CLIntrinsics.GlobalPointer{Float32},Transpiler.CLIntrinsics.GlobalPointer{Float32}}, 1)::Transpiler.CLIntrinsics.GlobalPointer{Float32})::CLArrays.DeviceArray{Float32,2,Transpiler.CLIntrinsics.GlobalPointer{Float32}}, (CLArrays.reconstruct)((CLArrays.getindex)(x::Tuple{CLArrays.DeviceArray{Float32,2,CLArrays.HostPtr{Float32}},CLArrays.DeviceArray{Float32,1,CLArrays.HostPtr{Float32}},RowVector{Float32,CLArrays.CLArray{Float32,1}}}, 2)::CLArrays.DeviceArray{Float32,1,CLArrays.HostPtr{Float32}}, (CLArrays.getindex)(ptrs::Tuple{Transpiler.CLIntrinsics.GlobalPointer{Float32},Transpiler.CLIntrinsics.GlobalPointer{Float32},Transpiler.CLIntrinsics.GlobalPointer{Float32}}, 2)::Transpiler.CLIntrinsics.GlobalPointer{Float32})::CLArrays.DeviceArray{Float32,1,Transpiler.CLIntrinsics.GlobalPointer{Float32}}, (CLArrays.reconstruct)((CLArrays.getindex)(x::Tuple{CLArrays.DeviceArray{Float32,2,CLArrays.HostPtr{Float32}},CLArrays.DeviceArray{Float32,1,CLArrays.HostPtr{Float32}},RowVector{Float32,CLArrays.CLArray{Float32,1}}}, 3)::RowVector{Float32,CLArrays.CLArray{Float32,1}}, (CLArrays.getindex)(ptrs::Tuple{Transpiler.CLIntrinsics.GlobalPointer{Float32},Transpiler.CLIntrinsics.GlobalPointer{Float32},Transpiler.CLIntrinsics.GlobalPointer{Float32}}, 3)::Transpiler.CLIntrinsics.GlobalPointer{Float32})::Any)::Tuple{CLArrays.DeviceArray{Float32,2,Transpiler.CLIntrinsics.GlobalPointer{Float32}},CLArrays.DeviceArray{Float32,1,Transpiler.CLIntrinsics.GlobalPointer{Float32}},Any}
end::Any
ERROR: AssertionError: Found non concrete return type: Tuple{CLArrays.DeviceArray{Float32,2,Transpiler.CLIntrinsics.GlobalPointer{Float32}},CLArrays.DeviceArray{Float32,1,Transpiler.CLIntrinsics.GlobalPointer{Float32}},Any}
Stacktrace:
[1] (::Sugar.##70#78{Sugar.LazyMethod{:CL}})(::Expr) at /Users/dilum/.julia/v0.6/Sugar/src/methods.jl:562
[2] replace_or_drop(::Sugar.##70#78{Sugar.LazyMethod{:CL}}, ::Sugar.##19#20, ::Expr, ::Array{Any,1}) at /Users/dilum/.julia/v0.6/Sugar/src/ast_tools.jl:32
[3] replace_or_drop(::Function, ::Function, ::Array{Any,1}, ::Array{Any,1}) at /Users/dilum/.julia/v0.6/Sugar/src/ast_tools.jl:25
[4] replace_or_drop(::Sugar.##70#78{Sugar.LazyMethod{:CL}}, ::Sugar.##19#20, ::Expr, ::Array{Any,1}) at /Users/dilum/.julia/v0.6/Sugar/src/ast_tools.jl:44
[5] replace_or_drop(::Function, ::Function, ::Array{Any,1}, ::Array{Any,1}) at /Users/dilum/.julia/v0.6/Sugar/src/ast_tools.jl:25
[6] replace_or_drop(::Sugar.##70#78{Sugar.LazyMethod{:CL}}, ::Sugar.##19#20, ::Expr, ::Array{Any,1}) at /Users/dilum/.julia/v0.6/Sugar/src/ast_tools.jl:44
[7] replace_expr(::Function, ::Expr) at /Users/dilum/.julia/v0.6/Sugar/src/ast_tools.jl:21
[8] rewrite_ast(::Sugar.LazyMethod{:CL}, ::Expr) at /Users/dilum/.julia/v0.6/Sugar/src/methods.jl:475
[9] getast!(::Sugar.LazyMethod{:CL}) at /Users/dilum/.julia/v0.6/Sugar/src/methods.jl:278
[10] dependencies!(::Sugar.LazyMethod{:CL}, ::Bool) at /Users/dilum/.julia/v0.6/Sugar/src/methods.jl:664
[11] dependencies!(::Sugar.LazyMethod{:CL}) at /Users/dilum/.julia/v0.6/Sugar/src/methods.jl:655
[12] print_dependencies(::Transpiler.CLIO{Base.AbstractIOBuffer{Array{UInt8,1}}}, ::Sugar.LazyMethod{:CL}, ::Set{Any}) at /Users/dilum/.julia/v0.6/Sugar/src/methods.jl:873
[13] assemble_kernel(::Sugar.LazyMethod{:CL}) at /Users/dilum/.julia/v0.6/CLArrays/src/compilation.jl:217
[14] (::CLArrays.##19#21{GPUArrays.#broadcast_kernel!,Tuple{CLArrays.KernelState,Flux.Tracker.##41#42,CLArrays.CLArray{Float32,2},Tuple{UInt32,UInt32},Tuple{GPUArrays.BInfo{Array,2},GPUArrays.BInfo{Array,1},GPUArrays.BInfo{Array,2}},Tuple{CLArrays.CLArray{Float32,2},CLArrays.CLArray{Float32,1},RowVector{Float32,CLArrays.CLArray{Float32,1}}}},GPUArrays.#broadcast_kernel!,OpenCL.cl.Context})() at /Users/dilum/.julia/v0.6/CLArrays/src/compilation.jl:251
[15] get!(::CLArrays.##19#21{GPUArrays.#broadcast_kernel!,Tuple{CLArrays.KernelState,Flux.Tracker.##41#42,CLArrays.CLArray{Float32,2},Tuple{UInt32,UInt32},Tuple{GPUArrays.BInfo{Array,2},GPUArrays.BInfo{Array,1},GPUArrays.BInfo{Array,2}},Tuple{CLArrays.CLArray{Float32,2},CLArrays.CLArray{Float32,1},RowVector{Float32,CLArrays.CLArray{Float32,1}}}},GPUArrays.#broadcast_kernel!,OpenCL.cl.Context}, ::Dict{Any,Any}, ::Tuple{Ptr{Void},GPUArrays.#broadcast_kernel!,NTuple{6,DataType}}) at ./dict.jl:449
[16] CLArrays.CLFunction(::GPUArrays.#broadcast_kernel!, ::Tuple{CLArrays.KernelState,Flux.Tracker.##41#42,CLArrays.CLArray{Float32,2},Tuple{UInt32,UInt32},Tuple{GPUArrays.BInfo{Array,2},GPUArrays.BInfo{Array,1},GPUArrays.BInfo{Array,2}},Tuple{CLArrays.CLArray{Float32,2},CLArrays.CLArray{Float32,1},RowVector{Float32,CLArrays.CLArray{Float32,1}}}}, ::OpenCL.cl.Context) at /Users/dilum/.julia/v0.6/CLArrays/src/compilation.jl:249
[17] _gpu_call(::Function, ::CLArrays.CLArray{Float32,2}, ::Tuple{Flux.Tracker.##41#42,CLArrays.CLArray{Float32,2},Tuple{UInt32,UInt32},Tuple{GPUArrays.BInfo{Array,2},GPUArrays.BInfo{Array,1},GPUArrays.BInfo{Array,2}},Tuple{CLArrays.CLArray{Float32,2},CLArrays.CLArray{Float32,1},RowVector{Float32,CLArrays.CLArray{Float32,1}}}}, ::Tuple{Tuple{Int64},Tuple{Int64}}) at /Users/dilum/.julia/v0.6/CLArrays/src/compilation.jl:15
[18] gpu_call(::Function, ::CLArrays.CLArray{Float32,2}, ::Tuple{Flux.Tracker.##41#42,CLArrays.CLArray{Float32,2},Tuple{UInt32,UInt32},Tuple{GPUArrays.BInfo{Array,2},GPUArrays.BInfo{Array,1},GPUArrays.BInfo{Array,2}},Tuple{CLArrays.CLArray{Float32,2},CLArrays.CLArray{Float32,1},RowVector{Float32,CLArrays.CLArray{Float32,1}}}}, ::Int64) at /Users/dilum/.julia/v0.6/GPUArrays/src/abstract_gpu_interface.jl:151
[19] _broadcast!(::Function, ::CLArrays.CLArray{Float32,2}, ::Tuple{Tuple{Bool,Bool},Tuple{Bool},Tuple{Bool,Bool}}, ::Tuple{Tuple{Int64,Int64},Tuple{Int64},Tuple{Int64,Int64}}, ::CLArrays.CLArray{Float32,2}, ::Tuple{CLArrays.CLArray{Float32,1},RowVector{Float32,CLArrays.CLArray{Float32,1}}}, ::Type{Val{2}}, ::CartesianRange{CartesianIndex{2}}) at /Users/dilum/.julia/v0.6/GPUArrays/src/broadcast.jl:89
[20] broadcast_c! at ./broadcast.jl:213 [inlined]
[21] broadcast! at ./broadcast.jl:206 [inlined]
[22] back(::Base.#*, ::CLArrays.CLArray{Float32,1}, ::TrackedArray{…,CLArrays.CLArray{Float32,2}}, ::CLArrays.CLArray{Float32,1}) at /Users/dilum/.julia/v0.6/Flux/src/tracker/array.jl:316
[23] back_(::Flux.Tracker.Call{Base.#*,Tuple{TrackedArray{…,CLArrays.CLArray{Float32,2}},CLArrays.CLArray{Float32,1}}}, ::CLArrays.CLArray{Float32,1}, ::CLArrays.CLArray{Float32,1}) at /Users/dilum/.julia/v0.6/Flux/src/tracker/back.jl:25
[24] back(::Flux.Tracker.Tracked{CLArrays.CLArray{Float32,1}}, ::CLArrays.CLArray{Float32,1}) at /Users/dilum/.julia/v0.6/Flux/src/tracker/back.jl:38
[25] macro expansion at /Users/dilum/.julia/v0.6/Flux/src/tracker/back.jl:49 [inlined]
[26] (::Flux.Tracker.##69#71)(::TrackedArray{…,CLArrays.CLArray{Float32,1}}, ::CLArrays.CLArray{Float32,1}) at /Users/dilum/.julia/v0.6/Flux/src/tracker/array.jl:405
[27] foreach(::Function, ::Tuple{TrackedArray{…,CLArrays.CLArray{Float32,1}},TrackedArray{…,CLArrays.CLArray{Float32,1}}}, ::Tuple{CLArrays.CLArray{Float32,1},CLArrays.CLArray{Float32,1}}, ::Vararg{Tuple{CLArrays.CLArray{Float32,1},CLArrays.CLArray{Float32,1}},N} where N) at ./abstractarray.jl:1734
[28] back_(::Flux.Tracker.Call{Flux.Tracker.Broadcasted{Base.#+,CLArrays.CLArray{ForwardDiff.Dual{Void,Float32,2},1}},Tuple{TrackedArray{…,CLArrays.CLArray{Float32,1}},TrackedArray{…,CLArrays.CLArray{Float32,1}}}}, ::CLArrays.CLArray{Float32,1}, ::CLArrays.CLArray{Float32,1}) at /Users/dilum/.julia/v0.6/Flux/src/tracker/back.jl:25
[29] back(::Flux.Tracker.Tracked{CLArrays.CLArray{Float32,1}}, ::CLArrays.CLArray{Float32,1}) at /Users/dilum/.julia/v0.6/Flux/src/tracker/back.jl:38
[30] macro expansion at /Users/dilum/.julia/v0.6/Flux/src/tracker/back.jl:49 [inlined]
[31] (::Flux.Tracker.##69#71)(::TrackedArray{…,CLArrays.CLArray{Float32,1}}, ::CLArrays.CLArray{Float32,1}) at /Users/dilum/.julia/v0.6/Flux/src/tracker/array.jl:405
[32] foreach(::Function, ::Tuple{TrackedArray{…,CLArrays.CLArray{Float32,1}},CLArrays.CLArray{Float32,1}}, ::Tuple{CLArrays.CLArray{Float32,1},CLArrays.CLArray{Float32,1}}, ::Vararg{Tuple{CLArrays.CLArray{Float32,1},CLArrays.CLArray{Float32,1}},N} where N) at ./abstractarray.jl:1734
[33] back_(::Flux.Tracker.Call{Flux.Tracker.Broadcasted{##1#2,CLArrays.CLArray{ForwardDiff.Dual{Void,Float32,2},1}},Tuple{TrackedArray{…,CLArrays.CLArray{Float32,1}},CLArrays.CLArray{Float32,1}}}, ::CLArrays.CLArray{Float32,1}, ::CLArrays.CLArray{Float32,1}) at /Users/dilum/.julia/v0.6/Flux/src/tracker/back.jl:25
[34] back(::Flux.Tracker.Tracked{CLArrays.CLArray{Float32,1}}, ::CLArrays.CLArray{Float32,1}) at /Users/dilum/.julia/v0.6/Flux/src/tracker/back.jl:38
[35] back(::Base.#sum, ::Float32, ::TrackedArray{…,CLArrays.CLArray{Float32,1}}) at /Users/dilum/.julia/v0.6/Flux/src/tracker/array.jl:210
[36] back_(::Flux.Tracker.Call{Base.#sum,Tuple{TrackedArray{…,CLArrays.CLArray{Float32,1}}}}, ::Float32, ::Float32) at /Users/dilum/.julia/v0.6/Flux/src/tracker/back.jl:25
[37] back(::Flux.Tracker.Tracked{Float32}, ::Int64) at /Users/dilum/.julia/v0.6/Flux/src/tracker/back.jl:36
[38] back!(::Flux.Tracker.TrackedReal{Float32}) at /Users/dilum/.julia/v0.6/Flux/src/tracker/scalar.jl:14
Additional info:
The output of versioninfo() is:
Julia Version 0.6.4
Commit 9d11f62bcb (2018-07-09 19:09 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell MAX_THREADS=16)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
The output of Pkg.status() is:
2 required packages:
- CLArrays 0.1.3
- Flux 0.5.3
39 additional packages:
- AbstractTrees 0.1.0
- Adapt 0.2.0
- BinDeps 0.8.8
- BinaryProvider 0.3.3
- CLBLAS 1.2.0
- CLFFT 0.5.2
- ColorTypes 0.6.7
- Colors 0.8.2
- CommonSubexpressions 0.1.0
- Compat 0.70.0
- DataFlow 0.3.1
- DataStructures 0.8.4
- DiffResults 0.0.3
- DiffRules 0.0.6
- FixedPointNumbers 0.4.6
- ForwardDiff 0.7.5
- GPUArrays 0.2.4
- GZip 0.4.0
- Homebrew 0.6.3
- JSON 0.17.2
- Juno 0.4.1
- Lazy 0.12.1
- MacroTools 0.4.2
- Matcha 0.1.1
- Media 0.3.0
- NNlib 0.3.1
- NaNMath 0.3.1
- Nullables 0.0.6
- OpenCL 0.7.0
- Primes 0.3.0
- Reexport 0.1.0
- Requires 0.4.4
- SHA 0.5.7
- SpecialFunctions 0.6.0
- StaticArrays 0.7.2
- Sugar 0.4.5
- Transpiler 0.4.8
- URIParser 0.3.1
- ZipFile 0.6.0
That looks a bit like a problem with RowVector... When I search for RowVector in CLArrays, I realize, that there doesn't seem to be the right converts defined for it... I'll take a look at it!
Great, thank you Simon!
On Tue, Jul 17, 2018 at 09:57 Simon [email protected] wrote:
That looks a bit like a problem with RowVector... When I search for RowVector in CLArrays, I realize, that there doesn't seem to be the right converts defined for it... I'll take a look at it!
— You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/JuliaGPU/CLArrays.jl/issues/35#issuecomment-405591113, or mute the thread https://github.com/notifications/unsubscribe-auth/AFXArXOlxD95WbAubkNZx5N4QvTQFa55ks5uHe0tgaJpZM4VR5Ak .
--
Dilum Aluthge
[email protected] [email protected]
https://www.aluthge.com https://www.aluthge.com
@SimonDanisch Any luck?