Skip to content

Commit

Permalink
materialize!(::KnetArray, ...) returns KnetArray.
Browse files Browse the repository at this point in the history
  • Loading branch information
denizyuret committed Jul 23, 2021
1 parent 1394098 commit e9bec84
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/knetarrays/getindex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,28 @@ function materialize!(A::SubArray{T,N,<:KnetArray}, B) where {T,N}
_A = view(CuArray(A.parent), A.indices...)
_B = (B isa KnetArray || B isa AbstractArray ? CuArray(B) : B)
materialize!(_A, _B)
return A
end

# For contiguous I, dotview(A, I...) gives a shared-memory KnetArray rather than a view
function materialize!(A::KnetArray, B) where {T,N}
_A = CuArray(A)
_B = (B isa KnetArray || B isa AbstractArray ? CuArray(B) : B)
materialize!(_A, _B)
return A
end

# Ambiguity fixes:
function materialize!(A::SubArray{T,N,<:KnetArray}, B::Broadcasted{S}) where {T,N,S}
_A = view(CuArray(A.parent), A.indices...)
materialize!(_A, B)
return A
end

function materialize!(A::KnetArray{T,N}, B::Broadcasted{S}) where {T,N,S}
_A = CuArray(A)
materialize!(_A, B)
return A
end


Expand Down

0 comments on commit e9bec84

Please sign in to comment.