Skip to content
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

Why does broadcasting cause @report_call errors while map does not? #669

Open
ehehela opened this issue Oct 18, 2024 · 2 comments
Open

Why does broadcasting cause @report_call errors while map does not? #669

ehehela opened this issue Oct 18, 2024 · 2 comments

Comments

@ehehela
Copy link

ehehela commented Oct 18, 2024

When I was broadcasting a function over vector of data of custom type, @report_call prompts an error stating that no matching method was found. The code is shown below. My question is, why does this error occur? However, when I use map function instead of broadcasting, there is no such error. Could this be a false positive?

MWE, Julia version: 1.11.1
using JET, BenchmarkTools

struct Point{dim,T}
    coord::NTuple{dim,T}
end
getcoordinate(n) = n.coord

pts = Point.(rand(NTuple{2,Float64}, 10))

fun(p) = getcoordinate.(p)
coords = fun(pts)
@report_opt fun(pts)    # No errors detected
@report_call fun(pts)   # ═════ 2 possible errors found ═════
@btime fun($pts)    # 17.417 ns (2 allocation: 224 bytes)

fun2(p) = map(getcoordinate, p)
coords = fun2(pts)
@report_opt fun2(pts)    # No errors detected
@report_call fun2(pts)   # No errors detected
@btime fun2($pts)   # 18.437 ns (2 allocation: 224 bytes)
@ehehela ehehela changed the title Why does broadcasting a function cause @report_call errors while map does not? Why does broadcasting cause @report_call errors while map does not? Oct 18, 2024
@aviatesk
Copy link
Owner

map and broadcast return exactly the same result in this case, but their implementations are different, so it’s not surprising that JET gives different analysis results. However, this report from @report_call seems to be a false positive, so I’ll fix it.

@ehehela
Copy link
Author

ehehela commented Oct 19, 2024

Thanks for your selfless contributions and tireless work. This issue can be closed if nothing else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants