1

I'm trying to broadcast a simple conditional function on an AFArray type.

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

Here's the 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

How can I handle this without copying the array from the GPU back to the host?

Le Minaw
  • 835
  • 7
  • 17

0 Answers0