-
Notifications
You must be signed in to change notification settings - Fork 32
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
Replace usage of typeof
(inferred) by Core.Typeof
(runtime)
#627
Changes from all commits
2ff254c
1473848
cd1f85e
28b8eae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -363,7 +363,8 @@ Determine the default `eltype` of the values returned by `vi[spl]`. | |
This method is considered legacy, and is likely to be deprecated in the future. | ||
""" | ||
function Base.eltype(vi::AbstractVarInfo, spl::Union{AbstractSampler,SampleFromPrior}) | ||
T = Base.promote_op(getindex, typeof(vi), typeof(spl)) | ||
# TODO(torfjelde): Is there _any_ scenario where this isn't just `typeof(getlogp(vi))`? | ||
T = Base.promote_op(getindex, Core.Typeof(vi), Core.Typeof(spl)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not clear to me why this would be helpful or needed here - |
||
if T === Union{} | ||
# In this case `getindex(vi, spl)` errors | ||
# Let us throw a more descriptive error message | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -737,7 +737,7 @@ For a `context` that is _not_ a `SamplingContext`, we fall back to | |
`matchingvalue(SampleFromPrior(), vi, value)`. | ||
""" | ||
function matchingvalue(sampler, vi, value) | ||
T = typeof(value) | ||
T = Core.Typeof(value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, I don't see why this would be beneficial in this place? Maybe the problem is rather that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed it might be the case that If I've understood @wsmoses correctly, Enzyme should be using the runtime value rather than the inferred value, and so this is the discrepancy between how we do it in DPPL: we use inferred instead of runtime. However, this didn't seem to help 😕 |
||
if hasmissing(T) | ||
_value = convert(get_matching_type(sampler, vi, T), value) | ||
if _value === value | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,7 +217,7 @@ function SimpleVarInfo(θ::Union{<:NamedTuple,<:AbstractDict}) | |
SimpleVarInfo{SIMPLEVARINFO_DEFAULT_ELTYPE}(θ) | ||
else | ||
# Infer from `values`. | ||
SimpleVarInfo{float_type_with_fallback(infer_nested_eltype(typeof(θ)))}(θ) | ||
SimpleVarInfo{float_type_with_fallback(infer_nested_eltype(Core.Typeof(θ)))}(θ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here? |
||
end | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
promote_op
was introduced when fixing TuringLang/Turing.jl#2151. Ifgetindex
errors it will returnUnion{}
, which - probably - is not equal totypeof(getlogp(vi))
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah true 👍