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

[fix] DynamicBuffer position error when expand for the firtst time #2007

Merged
merged 2 commits into from Sep 11, 2022

Conversation

Carkham
Copy link
Contributor

@Carkham Carkham commented Sep 11, 2022

Description

When the DynamicBuffer exapnd for the first time, its FloatBuffer.position would incorrectly increase by 1 resulting in an error in the location of subsequent data.

details
This can reproduce the error

DynamicBuffer bb = new DynamicBuffer();
for (int i = 0; i < 129; i++) {
    bb.put((float) i);
}
FloatBuffer buf = bb.getBuffer();
float value = buf.get(128); // This value should be 128f but got 0f.

This problem arises because DynamicBuffer expands when it is about to be full but not yet full, and adds the content before the expansion to the expanded Buffer, but because it is not yet full, the last position before the expansion of the element is not filled, and it is also added to the new Buffer, resulting in the position error of subsequent elements

@codecov-commenter
Copy link

codecov-commenter commented Sep 11, 2022

Codecov Report

Merging #2007 (b8183ea) into master (bb5073f) will decrease coverage by 2.14%.
The diff coverage is 68.30%.

@@             Coverage Diff              @@
##             master    #2007      +/-   ##
============================================
- Coverage     72.08%   69.94%   -2.15%     
- Complexity     5126     5945     +819     
============================================
  Files           473      587     +114     
  Lines         21970    26312    +4342     
  Branches       2351     2855     +504     
============================================
+ Hits          15838    18404    +2566     
- Misses         4925     6528    +1603     
- Partials       1207     1380     +173     
Impacted Files Coverage Δ
api/src/main/java/ai/djl/modality/cv/Image.java 69.23% <ø> (-4.11%) ⬇️
...rc/main/java/ai/djl/modality/cv/MultiBoxPrior.java 76.00% <ø> (ø)
...rc/main/java/ai/djl/modality/cv/output/Joints.java 71.42% <ø> (ø)
.../main/java/ai/djl/modality/cv/output/Landmark.java 100.00% <ø> (ø)
...main/java/ai/djl/modality/cv/output/Rectangle.java 72.41% <0.00%> (ø)
...i/djl/modality/cv/translator/BigGANTranslator.java 21.42% <0.00%> (-5.24%) ⬇️
...odality/cv/translator/BigGANTranslatorFactory.java 33.33% <0.00%> (+8.33%) ⬆️
.../cv/translator/InstanceSegmentationTranslator.java 0.00% <0.00%> (-86.59%) ⬇️
...nslator/InstanceSegmentationTranslatorFactory.java 7.14% <0.00%> (-11.04%) ⬇️
.../cv/translator/SemanticSegmentationTranslator.java 0.00% <0.00%> (ø)
... and 501 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@frankfliu frankfliu merged commit a82b338 into deepjavalibrary:master Sep 11, 2022
@Carkham Carkham deleted the bugfix-dynamicBuffer branch September 12, 2022 14:19
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.

None yet

3 participants