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

allow empty batch data #1569

Merged
merged 2 commits into from
Apr 14, 2022
Merged

allow empty batch data #1569

merged 2 commits into from
Apr 14, 2022

Conversation

patins1
Copy link
Contributor

@patins1 patins1 commented Apr 13, 2022

Description

This fix handles the edge case of flattening a batch of zero size. It is a good quality metric for a software function to be able to handle zero data input even if the calling function could detect this case and create a fake expected output (that was my work-around before).

Before this fix, this exception would have been thrown:

Caused by: ai.djl.engine.EngineException: cannot reshape tensor of 0 elements into shape [0, -1] because the unspecified dimension size -1 can be any value and is ambiguous
at ai.djl.pytorch.jni.PyTorchLibrary.torchReshape(Native Method)

@zachgk
Copy link
Contributor

zachgk commented Apr 13, 2022

The change looks good @patins1, but it seems like you are failing the formatter check. Can you run ./gradlew formatJava (see docs)?

Change-Id: I2d1e2894d37fb4f6a09ad3c70344bd1e822da65c
@codecov-commenter
Copy link

Codecov Report

Merging #1569 (a652145) into master (bb5073f) will decrease coverage by 1.25%.
The diff coverage is 52.95%.

@@             Coverage Diff              @@
##             master    #1569      +/-   ##
============================================
- Coverage     72.08%   70.83%   -1.26%     
- Complexity     5126     5394     +268     
============================================
  Files           473      503      +30     
  Lines         21970    23579    +1609     
  Branches       2351     2561     +210     
============================================
+ Hits          15838    16703     +865     
- Misses         4925     5597     +672     
- Partials       1207     1279      +72     
Impacted Files Coverage Δ
api/src/main/java/ai/djl/modality/cv/Image.java 69.23% <ø> (-4.11%) ⬇️
...i/djl/modality/cv/translator/BigGANTranslator.java 21.42% <ø> (-5.24%) ⬇️
...odality/cv/translator/BigGANTranslatorFactory.java 33.33% <0.00%> (+8.33%) ⬆️
...nslator/InstanceSegmentationTranslatorFactory.java 14.28% <0.00%> (-3.90%) ⬇️
.../modality/cv/translator/YoloTranslatorFactory.java 8.33% <0.00%> (-1.67%) ⬇️
...i/djl/modality/cv/translator/YoloV5Translator.java 5.69% <0.00%> (ø)
...odality/cv/translator/YoloV5TranslatorFactory.java 8.33% <0.00%> (-1.67%) ⬇️
...pi/src/main/java/ai/djl/ndarray/BytesSupplier.java 54.54% <0.00%> (-12.13%) ⬇️
...ain/java/ai/djl/ndarray/index/dim/NDIndexPick.java 100.00% <ø> (ø)
api/src/main/java/ai/djl/nn/Blocks.java 75.00% <0.00%> (-25.00%) ⬇️
... and 230 more

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 ad72072...a652145. Read the comment docs.

@frankfliu frankfliu merged commit ef7d6ca into deepjavalibrary:master Apr 14, 2022
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.

4 participants