Skip to content

Conversation

@IanButterworth
Copy link
Collaborator

@IanButterworth IanButterworth commented Apr 20, 2025

This fixes --track-allocations=user

        0             @timeit to "processing outputs" @views for out in yolo.out
        0                 outnr += 1
     1600                 w, h, a, bo, ba = out[:size]
      480                 weights = reshape(yolo.W[out[:idx]], w, h, a, bo, ba)
        0                 sxy = out[:scale_x_y]
        -                 # adjust the predicted box coordinates into pixel values
        0                 if yolo.cfg[:output][outnr][:new_coords] == 1
        0                     if haskey(yolo.cfg[:output][outnr], :max_delta)
        0                         delta = Float32(yolo.cfg[:output][outnr][:max_delta])
        0                         clamp!(weights[:, :, 1:2, :, :], -delta, delta)
        -                     end
        0                     weights[:, :, 1:2, :, :] = (weights[:, :, 1:2, :, :] .* sxy .- (sxy - 1)/2 .+ out[:offset]) .* out[:scale]
        0                     weights[:, :, 3:4, :, :] = (weights[:, :, 3:4, :, :] .* sxy).^2 .* out[:anchor]
        -                 else
        -                     # Classic behavior
     6560                     weights[:, :, 1:2, :, :] = (σ.(weights[:, :, 1:2, :, :]) .* sxy .- (sxy - 1)/2 .+ out[:offset]) .* out[:scale]
     3040                     weights[:, :, 3:4, :, :] = exp.(weights[:, :, 3:4, :, :]) .* out[:anchor]

Before

    42768             @timeit to "processing outputs" @views for out in yolo.out
        -                 outnr += 1
        -                 w, h, a, bo, ba = out[:size]
        -                 weights = reshape(yolo.W[out[:idx]], w, h, a, bo, ba)
        -                 sxy = out[:scale_x_y]
        -                 # adjust the predicted box coordinates into pixel values
        -                 if yolo.cfg[:output][outnr][:new_coords] == 1
        -                     if haskey(yolo.cfg[:output][outnr], :max_delta)
        -                         delta = Float32(yolo.cfg[:output][outnr][:max_delta])
        -                         clamp!(weights[:, :, 1:2, :, :], -delta, delta)
        -                     end
        -                     weights[:, :, 1:2, :, :] = (weights[:, :, 1:2, :, :] .* sxy .- (sxy - 1)/2 .+ out[:offset]) .* out[:scale]
        -                     weights[:, :, 3:4, :, :] = (weights[:, :, 3:4, :, :] .* sxy).^2 .* out[:anchor]
        -                 else

@IanButterworth IanButterworth force-pushed the ib/toplevel_tryfinally branch 2 times, most recently from bf8025c to 1e95edd Compare April 20, 2025 12:13
@IanButterworth IanButterworth changed the title Try lifting tryfinally to macros to fix user code locations Lift tryfinally to macros to fix user code locations Apr 20, 2025
@IanButterworth IanButterworth marked this pull request as ready for review April 20, 2025 12:13
@IanButterworth IanButterworth force-pushed the ib/toplevel_tryfinally branch from 1e95edd to 720f439 Compare April 20, 2025 12:14
@IanButterworth
Copy link
Collaborator Author

IanButterworth commented Apr 20, 2025

Needs more work for @timeit on function defs, which I've left as-is for now. That needs more thought.

@IanButterworth IanButterworth force-pushed the ib/toplevel_tryfinally branch from 720f439 to 278e796 Compare April 20, 2025 21:17
@codecov-commenter
Copy link

codecov-commenter commented Apr 20, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 88.88889% with 4 lines in your changes missing coverage. Please review.

Project coverage is 94.57%. Comparing base (ada4b6c) to head (278e796).
Report is 15 commits behind head on master.

Files with missing lines Patch % Lines
src/TimerOutput.jl 88.88% 4 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #196      +/-   ##
==========================================
+ Coverage   84.82%   94.57%   +9.74%     
==========================================
  Files           5        6       +1     
  Lines         323      479     +156     
==========================================
+ Hits          274      453     +179     
+ Misses         49       26      -23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@IanButterworth
Copy link
Collaborator Author

@ericphanson do you know whether this ontop of #194 is a full fix, or should we try to take this approach for function defs too?

@ericphanson
Copy link
Contributor

I'm not sure, I don't fully understand either fix aha. I think #194 is basically removing the wrong line nums and pushing in the source one. For this one, what does tryfinally have to do with it?

@IanButterworth
Copy link
Collaborator Author

The issue this fixes is that doing the Expr(:tryfinally deep in the functions called by the macros was overwriting the source info for the user code. Doing the Expr(:tryfinally at the top level macro avoids that issue.

@KristofferC any opinion here? I'm proposing merging this and then rebasing #194 and merging if green, given that PR has tests.

@IanButterworth IanButterworth merged commit 768db6c into KristofferC:master May 3, 2025
9 checks passed
@IanButterworth IanButterworth deleted the ib/toplevel_tryfinally branch May 3, 2025 09:32
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 this pull request may close these issues.

3 participants