Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Some reshapes of subarrays are strided, but `StrideIndex` fails.

未关闭
#10 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
julia
领域
performance

调研方向

复现两个 Julia 示例,然后检查 src/array_index.jl 第 197-203 行附近的代码,其中 StrideIndex 会失败。跟踪 dense_dims(view(A,ix,:,:)) 以及折叠维度的处理;当两个 StrideIndex 调用都能正常工作,并且 dense_dims 如描述的那样报告 (static(false), static(false)) 时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

julia> ix = 2;

julia> A = rand(7, 5, 6);

julia> src = view(view(A,ix, :, :),:);

julia> ArrayInterface.StrideIndex(src)
ERROR: TypeError: in typeassert, expected Tuple{Int64}, got a value of type Nothing
Stacktrace:
 [1] (ArrayInterface.StrideIndex{1, nothing, nothing})(s::Tuple{StaticInt{1}}, o::Tuple{StaticInt{1}})
   @ ArrayInterface ~/.julia/dev/ArrayInterface/src/array_index.jl:197
 [2] (ArrayInterface.StrideIndex{1, nothing, nothing})(a::SubArray{Float64, 1, Base.ReshapedArray{Float64, 1, SubArray{Float64, 2, Array{Float64, 3}, Tuple{Int64, Base.Slice{Base.OneTo{Int64}}, Base.Slice{Base.OneTo{Int64}}}, true}, Tuple{}}, Tuple{Base.Slice{Base.OneTo{Int64}}}, true})
   @ ArrayInterface ~/.julia/dev/ArrayInterface/src/array_index.jl:200
 [3] ArrayInterface.StrideIndex(a::SubArray{Float64, 1, Base.ReshapedArray{Float64, 1, SubArray{Float64, 2, Array{Float64, 3}, Tuple{Int64, Base.Slice{Base.OneTo{Int64}}, Base.Slice{Base.OneTo{Int64}}}, true}, Tuple{}}, Tuple{Base.Slice{Base.OneTo{Int64}}}, true})
   @ ArrayInterface ~/.julia/dev/ArrayInterface/src/array_index.jl:203
 [4] top-level scope
   @ REPL[25]:1

julia> ArrayInterface.StrideIndex(vec(view(A,ix,:,:)))
ERROR: TypeError: in typeassert, expected Tuple{Int64}, got a value of type Nothing
Stacktrace:
 [1] (ArrayInterface.StrideIndex{1, nothing, nothing})(s::Tuple{StaticInt{1}}, o::Tuple{StaticInt{1}})
   @ ArrayInterface ~/.julia/dev/ArrayInterface/src/array_index.jl:197
 [2] (ArrayInterface.StrideIndex{1, nothing, nothing})(a::Base.ReshapedArray{Float64, 1, SubArray{Float64, 2, Array{Float64, 3}, Tuple{Int64, Base.Slice{Base.OneTo{Int64}}, Base.Slice{Base.OneTo{Int64}}}, true}, Tuple{}})
   @ ArrayInterface ~/.julia/dev/ArrayInterface/src/array_index.jl:200
 [3] ArrayInterface.StrideIndex(a::Base.ReshapedArray{Float64, 1, SubArray{Float64, 2, Array{Float64, 3}, Tuple{Int64, Base.Slice{Base.OneTo{Int64}}, Base.Slice{Base.OneTo{Int64}}}, true}, Tuple{}})
   @ ArrayInterface ~/.julia/dev/ArrayInterface/src/array_index.jl:203
 [4] top-level scope
   @ REPL[26]:1

Basically, if collapsed dims are dense with respect to one another, collapsing them presevers strided-ness.

We should also redefine dense dims as necessary to be a statement only about that dim.

julia> ArrayInterface.dense_dims(view(A,ix,:,:))
(static(false), static(false))

So that the first dim is not dense, but the second one still is w/ respect to the first.

主要语言
Julia
星标
14
派生
8
PR 合并指标
30 天内没有已合并 PR

环境准备

我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

JuliaArrays/StaticArrayInterface.jl 的其他 Issue

查看 JuliaArrays/StaticArrayInterface.jl 的全部 Issue

相似的 Issue

更多 Julia Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。