Skip to content

Broadcast does not work with wrappers (Adjoint, Transpose, SubArray) #147

@maleadt

Description

@maleadt
julia> cu([1]) .= 1
1-element CuArray{Float32,1}:
 1.0

julia> transpose(cu([1])) .= 1
ERROR: scalar setindex! is disabled

@MikeInnes @vchuravy You guys have been dabbling with broadcast recently, any idea?

I also want to get this working for subarrays, which require the following additional changes:

## Adapt.jl
+adapt(T, x::SubArray) = SubArray(adapt(T, parent(x), parentindices(x)))
## CuArrays.jl
+cudaconvert(x::SubArray{<:Any,<:Any,<:CuArray}) = SubArray(cudaconvert(parent(x), parentindices(x)))

+Base.cconvert(::Type{Ptr{T}}, V::SubArray{T,N,P,<:Tuple{Vararg{Base.RangeIndex}}}) where 
+             {T,N,P<:CuArray} =
+    Mem.view(buffer(V.parent), (Base.first_index(V) - 1) * sizeof(T))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions