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

Refactor BlockFactory interface #1045

Merged
merged 1 commit into from
Jun 23, 2021

Conversation

frankfliu
Copy link
Contributor

Change-Id: I7e9aa60f541c00852c548332338ee0fc914ee92f

Description

Brief description of what this PR is about

  • If this change is a backward incompatible change, why must this change be made?
  • Interesting edge cases to note here

Change-Id: I7e9aa60f541c00852c548332338ee0fc914ee92f
@codecov-commenter
Copy link

codecov-commenter commented Jun 22, 2021

Codecov Report

Merging #1045 (bb3a0e6) into master (5f85fcc) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1045      +/-   ##
============================================
- Coverage     70.36%   70.35%   -0.01%     
+ Complexity     5168     5166       -2     
============================================
  Files           508      509       +1     
  Lines         23084    23080       -4     
  Branches       2429     2428       -1     
============================================
- Hits          16242    16237       -5     
  Misses         5536     5536              
- Partials       1306     1307       +1     
Impacted Files Coverage Δ
api/src/main/java/ai/djl/BaseModel.java 72.91% <ø> (-0.74%) ⬇️
...tclassification/TextClassificationModelLoader.java 100.00% <ø> (ø)
...ine/src/main/java/ai/djl/mxnet/engine/MxModel.java 61.11% <ø> (-1.06%) ⬇️
...o/nlp/embedding/GloveWordEmbeddingModelLoader.java 50.00% <ø> (-20.00%) ⬇️
...e/src/main/java/ai/djl/pytorch/engine/PtModel.java 50.00% <ø> (-1.39%) ⬇️
...in/java/ai/djl/repository/zoo/BaseModelLoader.java 75.00% <100.00%> (+2.02%) ⬆️
.../nlp/embedding/GloveWordEmbeddingBlockFactory.java 100.00% <100.00%> (ø)
api/src/main/java/ai/djl/repository/Artifact.java 91.37% <0.00%> (-1.73%) ⬇️
...pi/src/main/java/ai/djl/util/ClassLoaderUtils.java 52.94% <0.00%> (+1.47%) ⬆️

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 5f85fcc...bb3a0e6. Read the comment docs.

*/
Block newBlock(NDManager manager);
Block newBlock(Model model, Path modelPath, Map<String, ?> arguments) throws IOException;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this right? I thought the plan was to use BlockFactory to deprecate the Map<String, ?> arguments and replace it with serializing the BlockFactory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The purpose of BlockFactory is to create the Block then you can load the parameters into the Block.
The problem is the BlockFactory may need extra information:

  1. Some files in the model directory
  2. some model specific arguments. If we hard-code those arguments, which will make the BlockFactory implementation not re-useable.

@frankfliu frankfliu merged commit d4e93e6 into deepjavalibrary:master Jun 23, 2021
@frankfliu frankfliu deleted the blockfactory branch June 23, 2021 21:51
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