Skip to content

SP-2017: Performance optimizations#7

Open
phanicode wants to merge 1 commit intomainfrom
SP-2017-photo-opt
Open

SP-2017: Performance optimizations#7
phanicode wants to merge 1 commit intomainfrom
SP-2017-photo-opt

Conversation

@phanicode
Copy link

@phanicode phanicode commented Mar 3, 2026

Description of changes

Patch.mul seems to allocate np.zeros, this does not need to happen for our purposes , and the scale can be refactored and multiplied downstream.

@phanicode phanicode force-pushed the SP-2017-photo-opt branch from 670cb2f to c53fedd Compare March 3, 2026 19:54
@gtorrini gtorrini self-requested a review March 6, 2026 17:11
deriv, deriv_scale, img = item
else:
deriv, img = item
deriv_scale = 1.0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add an inline comment here reminding that deriv_scale is unity so the vals calculation just multiplies by a constant

patch_h, patch_w = patch_data.shape

# 1. Equivalent to get_overlapping_region for Y
y_start = max(0, -y0)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a docstring clarifying what the input parameters represent. I understand it is trying to find the overlap between mod_img and patch_data, but it's unclear which is the "reference" vs "desired" size.

assert(np.all(np.isfinite(um.patch)))
# print 'Adding umod', um, 'with counts', counts, 'to mod', mod.shape
(um * counts).addTo(mod)
# (um * counts).addTo(mod)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can either remove this (since it's commented out), or keep it in as reference for which original function we have substituted/replaced. Which do you think makes more sense?

Copy link

@gtorrini gtorrini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments/requests for clarification. Please ping me when it is ready again, and I will approve once I have successfully visualized/understood what's going on in the fast add improvement. Thank you for the work!

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