-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Making introspection macros work for broadcasting syntax (.
)
#28615
Comments
.
operator..
operator.
Ref: #25474. |
A workaround is to wrap in another function:
|
Yeah, that works for some macros like julia> foo() = abs.([1,2,3])
foo (generic function with 2 methods)
julia> @which foo()
foo() in Main at REPL[76]:1 |
For broadcasting it is not completely clear what function should be shown due to e.g. fusing. In |
I was encountering this error when I tried to dig into and understand the broadcasting mechanism, so in that case, showing the initial |
.
operator..
)
I know this is an old thread, but the introspection you're after is julia> Meta.@lower abs.([1,2,3])
:($(Expr(:thunk, CodeInfo(
1 ─ %1 = (Base.getproperty)(Base.Broadcast, :materialize) │
│ %2 = (Base.getproperty)(Base.Broadcast, :broadcasted) │
│ %3 = (Base.vect)(1, 2, 3) │
│ %4 = (%2)(abs, %3) │
│ %5 = (%1)(%4) │
└── return %5 │
)))) That'll give you the breadcrumbs you wanted. Note that it's a complicated expansion — there are two function calls there (well three including I'm not sure we can really do much here. Perhaps the |
I get the same error for I have to wrap the broadcast calls inside a function. Calling the broadcast directly results in an error. x=rand(10)
sinm(x) = sin.(x)
@code_llvm sinm(x)
@code_llvm sin.(x) Error: julia> @code_llvm sin.(x)
ERROR: no unique matching method found for the specified argument types
Stacktrace:
[1] error(::String) at .\error.jl:33
[2] which(::Any, ::Any) at .\reflection.jl:1148
[3] _dump_function(::Any, ::Any, ::Bool, ::Bool, ::Bool, ::Bool, ::Symbol, ::Bool, ::Symbol, ::Base.CodegenParams) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\InteractiveUtils\src\codeview.jl:77
[4] _dump_function at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\InteractiveUtils\src\codeview.jl:71 [inlined]
[5] code_llvm at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\InteractiveUtils\src\codeview.jl:132 [inlined]
[6] #code_llvm#28 at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\InteractiveUtils\src\codeview.jl:134 [inlined]
[7] code_llvm(::Any, ::Any; raw::Bool, dump_module::Bool, optimize::Bool, debuginfo::Symbol) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\InteractiveUtils\src\codeview.jl:136
[8] code_llvm(::Any, ::Any) at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\InteractiveUtils\src\codeview.jl:136
[9] top-level scope at none:0 |
In the code above I'd expect
@which
to returnbroadcast
and@code_lowered
to return whatever code that broadcast gets lowered to.If the loop fusion magic behind the scenes turns out to be complicated to work with these macros, clearer error messages (or, in the case of @code_lowered, an error message), would be great as well.
The text was updated successfully, but these errors were encountered: