JuliaDiff / JuliaDiff/ChainRulesCore.jl
Projections do not play well with GPUCompiler
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 267
- Forks
- 66
- PR merge metrics
- No merged PRs in 30d
Description
Here's an example that does not play well with GPUCompiler: https://gist.github.com/pabloferz/1390d85383e3243015be7ad5b162bcc4
A possible, but probably incomplete fix discussed with @mcabbott, is having the following specializations:
function ProjectTo(x::AbstractArray{T}) where {T <: AbstractFloat}
return ProjectTo{AbstractArray}(; element=ProjectTo(zero(T)), axes=axes(x))
end
ProjectTo(x::AbstractArray{T}) where {T <: Bool} = ProjectTo{NoTangent}()
function (project::ProjectTo{AbstractArray})(dx::AbstractArray{S}) where {S <: Number}
T = ChainRulesCore.project_type(project.element)
return S <: T ? dx : map(project.element, dx)
end
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the GPUCompiler case from the linked gist, then inspect the existing ProjectTo behavior for AbstractArray values in ChainRulesCore. Compare the result with the proposed AbstractFloat, Bool, and Number specializations, and confirm the GPUCompiler example works without breaking projection behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100