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

restrict: better offset support #9

Merged
merged 2 commits into from
Jun 2, 2021
Merged

restrict: better offset support #9

merged 2 commits into from
Jun 2, 2021

Conversation

johnnychen94
Copy link
Member

@johnnychen94 johnnychen94 commented Jun 2, 2021

Two things are included in this PR:

  1. relax require_one_based_indexing constrain via eagerly collect; this helps handle edge cases such as SubArray with offsets and others.
  2. OffsetArray performance was not good because there was unnecessary offset computation in the internal for loop. By eagerly convert it to the non-offsetted array before passing to restrict, the overhead is removed.
using ImageBase, TestImages, OffsetArrays

img = testimage("camera");
imgo = OffsetArray(img, -1, -1);

@btime restrict($img);
# 90.136 μs (10 allocations: 772.31 KiB)

@btime restrict($imgo);
# master: 211.889 μs (14 allocations: 772.53 KiB)
# PR: 89.594 μs (10 allocations: 772.31 KiB)

@codecov
Copy link

codecov bot commented Jun 2, 2021

Codecov Report

Merging #9 (69d90bc) into master (1eb0a79) will decrease coverage by 0.85%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #9      +/-   ##
==========================================
- Coverage   92.85%   92.00%   -0.86%     
==========================================
  Files           3        3              
  Lines         126      125       -1     
==========================================
- Hits          117      115       -2     
- Misses          9       10       +1     
Impacted Files Coverage Δ
src/restrict.jl 96.63% <100.00%> (-0.03%) ⬇️
src/compat.jl 0.00% <0.00%> (-100.00%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1eb0a79...69d90bc. Read the comment docs.

@johnnychen94 johnnychen94 changed the title better offset support restrict: better offset support Jun 2, 2021
@johnnychen94 johnnychen94 merged commit 046f4e4 into master Jun 2, 2021
@johnnychen94 johnnychen94 deleted the jc/offset branch June 2, 2021 11:47
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.

1 participant