Skip to content

Commit

Permalink
add close method to all nd manager (#3225)
Browse files Browse the repository at this point in the history
* add close method to all nd manager
  • Loading branch information
lanking520 committed May 31, 2024
1 parent e939474 commit 8955f6f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
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

0 comments on commit 8955f6f

Please sign in to comment.