public class CloseValidationMemoryMgr extends AbstractMemoryMgr implements SessionMemMgr
SessionMemMgr
that wraps an existing memory manager, to ensure that:assertAllReleasedExcept(Collection)
with the output arraysNOTE: This is intended for debugging and testing only
Constructor and Description |
---|
CloseValidationMemoryMgr(SameDiff sd,
SessionMemMgr underlying) |
Modifier and Type | Method and Description |
---|---|
INDArray |
allocate(boolean detached,
DataType dataType,
long... shape)
Allocate an array with the specified datatype and shape.
NOTE: This array should be assumed to be uninitialized - i.e., contains random values. |
INDArray |
allocate(boolean detached,
LongShapeDescriptor descriptor)
As per
SessionMemMgr.allocate(boolean, DataType, long...) but from a LongShapeDescriptor instead |
void |
assertAllReleasedExcept(@NonNull Collection<INDArray> except)
Check that all arrays have been released (after an inference call) except for the specified arrays.
|
void |
close()
Close the session memory manager and clean up any memory / resources, if any
|
protected Set<INDArray> |
identitySetAllConstPhVar() |
void |
release(INDArray array)
Release the array.
|
dup, ulike
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
dup, ulike
public CloseValidationMemoryMgr(SameDiff sd, SessionMemMgr underlying)
public INDArray allocate(boolean detached, DataType dataType, long... shape)
SessionMemMgr
allocate
in interface SessionMemMgr
detached
- If true: the array is safe to return outside of the SameDiff session run (for example, the array
is one that may be returned to the user)dataType
- Datatype of the returned arrayshape
- Array shapepublic INDArray allocate(boolean detached, LongShapeDescriptor descriptor)
SessionMemMgr
SessionMemMgr.allocate(boolean, DataType, long...)
but from a LongShapeDescriptor insteadallocate
in interface SessionMemMgr
public void release(INDArray array)
SessionMemMgr
release
in interface SessionMemMgr
array
- The array that can be releasedpublic void close()
SessionMemMgr
close
in interface Closeable
close
in interface AutoCloseable
close
in interface SessionMemMgr
public void assertAllReleasedExcept(@NonNull @NonNull Collection<INDArray> except)
except
- Arrays that should not have been closed (usually network outputs)Copyright © 2020. All rights reserved.