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 the usage of the repeat function for embedding #2590

Merged
merged 14 commits into from
May 22, 2023
Merged

Fix the usage of the repeat function for embedding #2590

merged 14 commits into from
May 22, 2023

Conversation

takanori-ugai
Copy link
Contributor

Description

embeddedTokens = embedding.embed(manager, { 1, 2 }) ;

gets the following error.

Exception in thread "main" java.lang.IllegalArgumentException: The desired shape has too many dimensions
at ai.djl.pytorch.engine.PtNDArray.repeatsToMatchShape(PtNDArray.java:1330)
at ai.djl.pytorch.engine.PtNDArray.repeat(PtNDArray.java:1323)
at ai.djl.pytorch.engine.PtNDArray.repeat(PtNDArray.java:39)
at ai.djl.nn.core.ConstantEmbedding.embed(ConstantEmbedding.java:108)

To fix this error, simplify to repeat the length of the input and reshape.

@takanori-ugai takanori-ugai requested review from zachgk, frankfliu and a team as code owners May 9, 2023 01:51
@zachgk
Copy link
Contributor

zachgk commented May 11, 2023

Can you add this as a test as well to show what is being fixed and ensure it doesn't break again? You can add it to BlockCoreTest

@codecov-commenter
Copy link

codecov-commenter commented May 12, 2023

Codecov Report

Patch coverage: 71.75% and project coverage change: +1.60 🎉

Comparison is base (bb5073f) 72.08% compared to head (cd9fdae) 73.69%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2590      +/-   ##
============================================
+ Coverage     72.08%   73.69%   +1.60%     
- Complexity     5126     6952    +1826     
============================================
  Files           473      684     +211     
  Lines         21970    30333    +8363     
  Branches       2351     3138     +787     
============================================
+ Hits          15838    22354    +6516     
- Misses         4925     6453    +1528     
- Partials       1207     1526     +319     
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% <ø> (ø)
.../main/java/ai/djl/modality/cv/output/Landmark.java 100.00% <ø> (ø)
...djl/modality/cv/transform/RandomFlipLeftRight.java 25.00% <0.00%> (-25.00%) ⬇️
...djl/modality/cv/transform/RandomFlipTopBottom.java 25.00% <0.00%> (-25.00%) ⬇️
...i/djl/modality/cv/translator/BigGANTranslator.java 21.42% <0.00%> (-5.24%) ⬇️
.../modality/cv/translator/ImageFeatureExtractor.java 0.00% <0.00%> (ø)
.../ai/djl/modality/cv/translator/YoloTranslator.java 27.77% <0.00%> (+18.95%) ⬆️
...ain/java/ai/djl/modality/cv/util/NDImageUtils.java 67.10% <0.00%> (+7.89%) ⬆️
api/src/main/java/ai/djl/modality/nlp/Decoder.java 63.63% <ø> (ø)
... and 227 more

... and 354 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@zachgk zachgk merged commit 1225ec6 into deepjavalibrary:master May 22, 2023
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