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

add close method to all nd manager #3225

Merged
merged 2 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ public NDList load(Path path) {
return new NDList(new LgbmDataset(this, null, path));
}

/** {@inheritDoc} */
@Override
public void close() {
super.close();
if (alternativeManager != null) {
alternativeManager.close();
alternativeManager = null;
}
}

/** The SystemManager is the root {@link LgbmNDManager} of which all others are children. */
private static final class SystemManager extends LgbmNDManager implements SystemNDManager {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,16 @@ public NDArray createCSR(Buffer buffer, long[] indptr, long[] indices, Shape sha
return new XgbNDArray(this, alternativeManager, handle, shape, SparseFormat.CSR);
}

/** {@inheritDoc} */
@Override
public void close() {
super.close();
if (alternativeManager != null) {
alternativeManager.close();
alternativeManager = null;
}
}

/** The SystemManager is the root {@link XgbNDManager} of which all others are children. */
private static final class SystemManager extends XgbNDManager implements SystemNDManager {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ public NDArray ones(Shape shape, DataType dataType) {
return create(bb, shape, dataType);
}

/** {@inheritDoc} */
@Override
public void close() {
super.close();
if (alternativeManager != null) {
alternativeManager.close();
alternativeManager = null;
}
}

/** The SystemManager is the root {@link TrtNDManager} of which all others are children. */
private static final class SystemManager extends TrtNDManager implements SystemNDManager {

Expand Down
Loading