-
Notifications
You must be signed in to change notification settings - Fork 688
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
[pytorch] Add NDList to IValue unit test #1762
Conversation
public void testMapOfTensor() { | ||
try (NDManager manager = NDManager.newBaseManager()) { | ||
NDArray array1 = manager.zeros(new Shape(1)); | ||
array1.setName("input1.key1"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: add some comments to explain why use input1
as prefix? Like group all keys with same prefix into one Map?
Codecov Report
@@ Coverage Diff @@
## master #1762 +/- ##
============================================
- Coverage 72.08% 70.62% -1.46%
- Complexity 5126 5567 +441
============================================
Files 473 527 +54
Lines 21970 24702 +2732
Branches 2351 2680 +329
============================================
+ Hits 15838 17447 +1609
- Misses 4925 5927 +1002
- Partials 1207 1328 +121
Continue to review full report at Codecov.
|
The testing code can be used as example as well Change-Id: I693624fd111afb0a5547d619a03d2cb15831af1b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for adding these tests, good examples to follow for new DJL users like me. Appreciate it!
NDArray array5 = manager.ones(new Shape(1)); | ||
array5.setName("input2.key3"); | ||
NDList input = new NDList(array1, array2, array3, array4, array5); | ||
// the NDList is mapped to (input1: Dict(str, Tensor), input2: Dict(str, Tensor)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any way to generate something like
(input1: Dict(str, list(Tensor)), input2: Dict(str, list(Tensor)))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- We don't support this currently, it's possible to add nested IValue support.
- But you have to use IValue directly, and use PyTorch specific API, which doesn't work with Translator pattern. something like: https://github.com/deepjavalibrary/djl/blob/master/engines/pytorch/pytorch-engine/src/test/java/ai/djl/pytorch/integration/IValueTest.java#L184-L191
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a PR for your issue: #1765
The testing code can be used as example as well
Change-Id: I693624fd111afb0a5547d619a03d2cb15831af1b
Description
Brief description of what this PR is about