New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
type-instability with repeat and cat? #30686
Comments
It's weird! # code1
function add_gpu_test()
xs = Vector{AbstractArray{Float32, 4}}([rand(Float32, 2,3,3,1) for _ in 1:3])
@code_warntype cat(xs...; dims=Val(3))
end
add_gpu_test() #code2
function add_gpu_test()
xs = Vector{AbstractArray{Float32, 4}}([rand(Float32, 2,3,3,1) for _ in 1:3])
cat(xs...; dims=Val(3))
end
@code_warntype add_gpu_test() code1 is type-stable while code2 is not. Why? |
@kellertuer , @KristofferC |
Same reason you don't do it I guess? People have other things to do that take priority. |
I don't have the skills to do that yet. |
Today, I solve it partly by using |
I think I rephrased my problem back then, though I did not write that in the thread linked in the original post here.
I think Kristopher is right: Probably there is not much demand for this to be addressed and I for myself do this only as a small part of my job, so mainly in my free time and I am not clever enough to fix this myself, I can not contribute to a solution here but
faith in what? That this specific small thing will be fixed by someone? If someone comes along needing this and being able to fix this case, sure it will be fixed, but again, open source means (a) a lot pof people putting in their free time and (b) anyone who sees how to fix it can fix it (and thats for example not me). |
it's "Both the runtime efficiency issue and the memory efficiency issue will be solved sooner or later, right?" |
I want to use
repeat
(orcat
) for my own type or to be precise for a field of my own type, in this application to take the array that is stored in my own type, create as many copies as there are dimensions and create a newA1
with this array internally. However, whenever trying to use that, I get type instabilities. So I also tried a second version, since I first only need a specific repeat, that employscat
, but I run into the same problem, that used within a function, it seems not to be stable.Note that copying both following
runExamples()
to REPL or running the body in REPL does not yield a type-instability (a prior version of this was posted here)where the
@code_warntypes
yield for the first examplewhile for the second (the repeat) one correctly gets
Body::A1{A2,3}
and similarly for the approach withcat
. Bot do yield a 3D array withinA1
where the third dimension has 2 (ndims(a)
) entries, but even with a lot of reading and research the function does not get type stable.So why can't
repeat
orcat
infer the proper type of its result?The text was updated successfully, but these errors were encountered: