我正在尝试广播一种AFArray
类型的简单条件函数。
using ArrayFire
f = x -> x > .5 ? "foo" : "bar"
a = rand(Float32, 10, 10)
b = rand(AFArray{Float32}, 10, 10)
display( f.(a) ) # This one works...
display( f.(b) ) # ...this one does not
这是stacktrace:
ERROR: LoadError: TypeError: non-boolean (ArrayFire.AFArray{Bool,2}) used in boolean context
Stacktrace:
[1] (::##1#2)(::ArrayFire.AFArray{Float32,2}) at D:\LeMinaw\Dev\MandelFrac\test.jl:3
[2] broadcast_c(::Function, ::Type{ArrayFire.AFArray}, ::ArrayFire.AFArray{Float32,2}) at C:\Users\LeMinaw\.julia\v0.6\ArrayFire\src\array.jl:317
[3] broadcast(::Function, ::ArrayFire.AFArray{Float32,2}) at .\broadcast.jl:455
[4] include_from_node1(::String) at .\loading.jl:576
[5] include(::String) at .\sysimg.jl:14
while loading D:\LeMinaw\Dev\MandelFrac\test.jl, in expression starting on line 9
如何在不将阵列从GPU复制回主机的情况下处理此问题?