Skip to content

Bug in dense_dims for reshaped views #157

Open

Description

@ranocha

Reported in #156 (comment):

julia> using ArrayInterface

julia> u_base = randn(10, 10); u_view = view(u_base, 3, :); u_reshaped_view = reshape(u_view, 1, size(u_base, 2));

julia> ArrayInterface.dense_dims(u_reshaped_view)

As confirmed by @chriselrod in #156 (comment), this is a bug:

The correct answer for u_reshaped_view would be (False(),False()).

Activity

  1. Tokazama commented on Jun 10, 2022

    @Tokazama
    Member

    resolved with #161

  2. ranocha commented on Jun 10, 2022

    @ranocha
    ContributorAuthor

    I fixed it only for the case of reshaped versions of abstract vectors. It still fails for reshaped views of higher-dimensional arrays, e.g.,

    (@v1.7) pkg> activate --temp
      Activating new project at `/tmp/jl_4vH1Gz`
    
    (jl_4vH1Gz) pkg> add ArrayInterface
        Updating registry at `~/.julia/registries/General.toml`
       Resolving package versions...
        Updating `/tmp/jl_4vH1Gz/Project.toml`
      [4fba245c] + ArrayInterface v6.0.14
    
    julia> using ArrayInterface
    
    julia> u_base = randn(10, 10, 10); u_view = view(u_base, 3, :, :); u_reshaped_view = reshape(u_view, 1, size(u_base, 2) * size(u_base, 3));
    
    julia> ArrayInterface.dense_dims(u_reshaped_view)
    
    julia> ArrayInterface.dense_dims(u_reshaped_view) |> isnothing
    true

    Thus, this issue is not resolved in general.

  3. Tokazama commented on Jun 10, 2022

    @Tokazama
    Member

    I guess in that example we could know that no dimensions are dense because u_view doesn't have any dense dimensions, but I'm not sure we can do any better at identifying instances where they are dense.

  4. Tokazama commented on Jun 11, 2022

    @Tokazama
    Member

    #307 tests all the examples in this issue. I'm assuming there are still times when we don't detect dense dimensions just because we can't know in some situations without knowing the size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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