Skip to content

Broadcasting on nested ReshapedArrays and Adjoints falls back to DefaultArrayStyle #244

@tanhevg

Description

@tanhevg

MWE:

using CuArrays

x = cu(rand(5))
xx = reshape(x', 5)
typeof(xx) # ok: Base.ReshapedArray{Float32,1,LinearAlgebra.Adjoint{Float32,CuArray{Float32,1,Nothing}},Tuple{}}
typeof(-xx) # WTF: Array{Float32,1}

This is because the code that defines broadcast styles in GPUArrays.broadcast.jl only defines them for adapted types for the nested level of 1.

I guess one possible workaround would be

broadcastable(x::Base.ReshapedArray) = broadcastable(x.parent)
# etc etc for LinearAlgebra.Adjoint and others

I am not sure, however, if this would break other things, and whether it should sit within JuliaGPU or in Base

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions