Skip to content

Broadcasting on ArrayPartitions is not applied recursively #418

Description

@efaulhaber
julia> x = CUDA.zeros(10_000_000);

julia> y = ArrayPartition(x);

julia> y .= 0
ERROR: Scalar indexing is disallowed.
Invocation of setindex! resulted in scalar indexing of a GPU array.
This is typically caused by calling an iterating implementation of a method.
Such implementations *do not* execute on the GPU, but very slowly on the CPU,
and therefore should be avoided.

This should recursively apply a broadcast to the elements of the partition, which should then correctly dispatch to the GPU code. This doesn't work, so some CPU code is called instead.

Edit: It looks like a simple

function Base.fill!(m::ArrayPartition, x)
    for i in eachindex(m.x)
        fill!(m.x[i], x)
    end

    return m
end

might do the trick.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions