Revision 65b9be408674bd6b08ea302571b1ac0f52b7a9f7 authored by Shuhei Kadowaki on 25 April 2022, 02:50:53 UTC, committed by GitHub on 25 April 2022, 02:50:53 UTC
Make `cat` inferrable even if its arguments are not fully constant: ```julia julia> r = rand(Float32, 56, 56, 64, 1); julia> f(r) = cat(r, r, dims=(3,)) f (generic function with 1 method) julia> @inferred f(r); julia> last(@code_typed f(r)) Array{Float32, 4} ``` After descending into its call graph, I found that constant propagation is prohibited at `cat_t(::Type{T}, X...; dims)` due to the method instance heuristic, i.e. its body is considered to be too complex for successful inlining although it's explicitly annotated as `@inline`. But for this case, the constant propagation is greatly helpful both for abstract interpretation and optimization since it can improve the return type inference. Since it is not an easy task to improve the method instance heuristic, which is our primary logic for constant propagation, this commit does a quick fix by helping inference with the `@constprop` annotation. There is another issue that currently there is no good way to properly apply `@constprop`/`@inline` effects to a keyword function (as a note, this is a general issue of macro annotations on a method definition). So this commit also changes some internal helper functions of `cat` so that now they are not keyword ones: the changes are also necessary for the `@inline` annotation on `cat_t` to be effective to trick the method instance heuristic.
1 parent 45abec4
File | Mode | Size |
---|---|---|
.devcontainer | ||
.github | ||
base | ||
cli | ||
contrib | ||
deps | ||
doc | ||
etc | ||
src | ||
stdlib | ||
test | ||
.buildkite-external-version | -rw-r--r-- | 5 bytes |
.clang-format | -rw-r--r-- | 3.3 KB |
.codecov.yml | -rw-r--r-- | 52 bytes |
.gitattributes | -rw-r--r-- | 65 bytes |
.gitignore | -rw-r--r-- | 493 bytes |
.mailmap | -rw-r--r-- | 12.1 KB |
CITATION.bib | -rw-r--r-- | 513 bytes |
CITATION.cff | -rw-r--r-- | 940 bytes |
CONTRIBUTING.md | -rw-r--r-- | 22.5 KB |
HISTORY.md | -rw-r--r-- | 349.5 KB |
LICENSE.md | -rw-r--r-- | 1.3 KB |
Make.inc | -rw-r--r-- | 49.8 KB |
Makefile | -rw-r--r-- | 26.4 KB |
NEWS.md | -rw-r--r-- | 3.2 KB |
README.md | -rw-r--r-- | 7.3 KB |
THIRDPARTY.md | -rw-r--r-- | 3.7 KB |
VERSION | -rw-r--r-- | 10 bytes |
julia.spdx.json | -rw-r--r-- | 35.8 KB |
sysimage.mk | -rw-r--r-- | 4.1 KB |
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...