Comments (3)
xref #92
I generally suspect the @code_typed
is more reliable, but I'm not sure even that's always true.
from cthulhu.jl.
Thanks. I have another (unrelated?) question:
After running
julia> @noinline function f(x...)
return x
end;
julia> g(x) = f(x, 1);
julia> g(1)
(1, 1)
I get
julia> methods(f).ms[1].specializations
svec(MethodInstance for f(::Int64, ::Int64), #undef, #undef, #undef, #undef, #undef, #undef, MethodInstance for f(::Int64, ::Vararg{Int64}))
Why is the specialization f(::Int64, ::Int64)
created?
from cthulhu.jl.
Great question, I've been (and sometimes still am) confused about the same thing. The short answer is that specialization of inference is distinct from specialization of codegen.
julia> @noinline function f(x...)
return x
end;
julia> g(x) = f(x, 1);
julia> g(1)
(1, 1)
julia> using MethodAnalysis
julia> mis = methodinstances(f)
2-element Vector{Core.MethodInstance}:
MethodInstance for f(::Int64, ::Int64)
MethodInstance for f(::Int64, ::Vararg{Int64, N} where N)
julia> mis[1].cache.specptr
Ptr{Nothing} @0x0000000000000000
julia> mis[2].cache.specptr
Ptr{Nothing} @0x00007f007fe42e10
It's the second one which actually runs. But it's been decided (and I generally agree) that it's useful for callers who know more about their argument types to be able to infer the return type. It also can help link, e.g., the callee of a do
block to the method in which it's defined (why that might be important: https://julialang.org/blog/2021/01/precompile_tutorial/). You can generally use Base.inferencebarrier(arg)
in the caller when you want to prevent even inference-specialization of the callee.
from cthulhu.jl.
Related Issues (20)
- internal assertion error examining BigInt() constructor
- `ERROR: MethodError: no method matching display(::Dict{String, Vector{TypedSyntax.InlayHint}})` and `julia.usePlotPane` HOT 1
- Incorrectly positioned type assertion
- Internal `AssertionError: label > 0` when descending a method call HOT 14
- Precompilation fails on 32-bit Julia 1.9
- `UndefVarError: T not defined` when using `@descend` HOT 2
- Different type annotations when function is defined once on Julia nightly HOT 2
- Inlay hint display for juxtaposition and infix operators HOT 4
- Display certain unions with `Base.warn_color()` to match `code_warntype` HOT 1
- Allow user to overload printing behavior HOT 2
- Show Inlay Hints in VSCode for all open files
- Add CI for Arm Macs
- Precompilation error on julia master due to `IOError: stream is closed` HOT 4
- Duplicate Inlay Hints when Language server is providing type hints HOT 2
- expected Core.Compiler.InferenceState, got a value of type Nothing HOT 2
- Program Slice View
- `type CodeInfo has no field rettype` on Julia's master branch HOT 1
- Imperfect type inference on Julia nightly that doesn't agree with `@code_warntype` HOT 1
- Inlay hints placed in wrong locations HOT 2
- AssertionError from Core.Compiler HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cthulhu.jl.