Package ai.djl.ndarray
Interface NDResource
- All Superinterfaces:
AutoCloseable
- All Known Subinterfaces:
LazyNDArray
,NDArray
,SparseNDArray
- All Known Implementing Classes:
NDArrayAdapter
,NDList
An object which is managed by an
NDManager
and tracks the manager it is attached to.-
Method Summary
Modifier and TypeMethodDescriptionvoid
Attaches thisNDResource
to the specifiedNDManager
.void
close()
void
detach()
Detaches theNDResource
from currentNDManager
's lifecycle.Returns theNDManager
that manages this.default void
returnResource
(NDManager manager) Attaches thisNDResource
to the specifiedNDManager
from which it was previously detached and temp-attached to the current manager of this resource.void
tempAttach
(NDManager manager) Temporarily attaches thisNDResource
to the specifiedNDManager
.
-
Method Details
-
getManager
NDManager getManager()Returns theNDManager
that manages this.- Returns:
- the
NDManager
that manages this.
-
getResourceNDArrays
-
attach
Attaches thisNDResource
to the specifiedNDManager
.Attached resource will be closed when the
NDManager
is closed.- Parameters:
manager
- theNDManager
to be attached to
-
returnResource
Attaches thisNDResource
to the specifiedNDManager
from which it was previously detached and temp-attached to the current manager of this resource. This is functionally equivalent to the attach method, however the cap-state disregarded when adding the resource back to the original manager.- Parameters:
manager
- theNDManager
to be attached to
-
tempAttach
Temporarily attaches thisNDResource
to the specifiedNDManager
.Attached resource will be returned to the original manager when the
NDManager
is closed.- Parameters:
manager
- theNDManager
to be attached to
-
detach
void detach()Detaches theNDResource
from currentNDManager
's lifecycle.This becomes un-managed and it is the user's responsibility to close this. Failure to close the resource might cause your machine to run out of native memory.
- See Also:
-
close
void close()- Specified by:
close
in interfaceAutoCloseable
-