arrayfire / arrayfire

ArrayFire: a general purpose GPU library.
https://arrayfire.com
BSD 3-Clause "New" or "Revised" License
4.56k stars 534 forks source link

JIT improvements #1401

Open pavanky opened 8 years ago

pavanky commented 8 years ago

place holder issue to track JIT improvements.

Convert to JIT:

New functions:

Behavior changes:

CPU Specific changes:

CUDA changes

pavanky commented 8 years ago

@arrayfire/core-devel any other suggestions we can think of ?

ghost commented 7 years ago

Is replace in JIT? Can you add batch mode to it (and select) too?

pavanky commented 7 years ago

@gaika Not sure if replace can be JIT'd but select can definitely be including batch mode.

Although both of them support "batch" mode right now also.

ghost commented 7 years ago

Not sure how batch is supported, because when I pass arrays with different dimensions I get:

ERROR: ArrayFire Error (203) : Invalid input size
In function af_err af_select(void**, af_array, af_array, af_array)
In file src/api/c/select.cpp:54
Invalid dimension for argument 1
Expected: cdims[i] == std::min(adims[i], bdims[i])
pavanky commented 7 years ago

@gaika can you tell me what the dimensions are for a, b, and c?

ghost commented 7 years ago

For example:

julia> select(a, b, c)
ERROR: ArrayFire Error (203) : Invalid input size
In function af_err af_select(void**, af_array, af_array, af_array)
In file src/api/c/select.cpp:46
Invalid dimension for argument 1
Expected: cinfo.ndims() == std::min(ainfo.ndims(), binfo.ndims())

Stacktrace:
 [1] _error(::UInt32) at /home/joe/.julia/v0.6/ArrayFire/src/util.jl:44
 [2] select(::ArrayFire.AFArray{Bool,2}, ::ArrayFire.AFArray{Int64,1}, ::ArrayFire.AFArray{Int64,2}) at /home/joe/.julia/v0.6/ArrayFir
e/src/wrap.jl:1068                                                                                                                   

julia> a
ArrayFire.AFArray{Bool,2}
1×3 Array{Bool,2}:
 true  false  true

julia> b
ArrayFire.AFArray{Int64,1}
1-element Array{Int64,1}:
 0

julia> c
ArrayFire.AFArray{Int64,2}
2×3 Array{Int64,2}:
 4  5  6
 7  8  9
pavanky commented 7 years ago

@gaika Please don't use a 1x1 array, they are highly inefficient compared to af::constant(val, dims);

On the note of batching, I see that the conditional arrays need to match one of the input dimensions for now. This can be fixed.