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 indexer to attach specific manager #1688

Merged
merged 4 commits into from
Jun 3, 2022

Conversation

patins1
Copy link
Contributor

@patins1 patins1 commented Jun 1, 2022

This feature allows to pass an NDManager to NDArray indexation operation so that the result is attached to the passed NDManager instead of to the original NDManager of the NDArray.
Thus, ArrayDataset.get() does not need to attach the result of the indexation a second time, thus batch creation is speeded up.

In my performance tests, I got following improvement:

Before:
It took 6872ms totally
It took 6876ms totally
It took 6825ms totally
It took 6923ms totally

After:
It took 6734ms totally
It took 6709ms totally
It took 6728ms totally
It took 6703ms totally

So the training time is reduced by 2.2% !

Also, this pull request fixes a bug that temporary resources are returned to the wrong manager.

@patins1 patins1 requested review from zachgk and frankfliu as code owners June 1, 2022 12:21
Copy link
Contributor

@zachgk zachgk left a comment

Choose a reason for hiding this comment

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

This is a good change @patins1!

import org.testng.Assert;
import org.testng.annotations.Test;

public class ManagerAttachmentTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of creating these tests for both MXNet engine and PyTorch engine, can you move it into the integration module? That is where we put the tests representing behavior shared for the entire engine spec. Engines that don't fully implement the spec can return an UnsupportedOperationException and it will not be considered failing the test

* @param index the section of this {@code NDArray} to return
* @return the partial {@code NDArray}
*/
default NDArray get(NDIndex index, NDManager manager) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor thing, but I feel like it would be more consistent to put manager as the first argument

frankfliu added 2 commits June 2, 2022 11:19
1. moved MXNet and PyTorch unit test into integration test module
2. Fix TensorFlow tempAttach issue

Change-Id: I213b34caf51679a5ae7d955414c4bc5c4db91c1a
Change-Id: Iaca16533bfdb7611a4d68d574b5a7fa884280bc0
@patins1
Copy link
Contributor Author

patins1 commented Jun 3, 2022

Rectifications look great @zachgk @frankfliu

@zachgk zachgk merged commit f867faa into deepjavalibrary:master Jun 3, 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.

3 participants