Modifier and Type | Field and Description |
---|---|
protected java.util.concurrent.atomic.AtomicBoolean |
closed |
protected Device |
device |
protected java.lang.String |
name |
protected NDManager |
parent |
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.AutoCloseable> |
resources |
protected java.lang.String |
uid |
Modifier | Constructor and Description |
---|---|
protected |
BaseNDManager(NDManager parent,
Device device) |
Modifier and Type | Method and Description |
---|---|
NDArray |
arange(float start,
float stop,
float step,
DataType dataType)
Returns evenly spaced values within a given interval.
|
void |
attach(java.lang.String resourceId,
java.lang.AutoCloseable resource)
|
void |
close() |
NDArray |
create(Shape shape,
DataType dataType)
|
NDArray |
create(java.lang.String data)
Creates and initializes a scalar
NDArray . |
NDArray |
createCoo(java.nio.Buffer data,
long[][] indices,
Shape shape)
Creates a Coordinate Format (COO) Matrix.
|
NDArray |
createCSR(java.nio.Buffer data,
long[] indptr,
long[] indices,
Shape shape)
Creates a Compressed Sparse Row Storage (CSR) Format Matrix.
|
NDArray |
createRowSparse(java.nio.Buffer data,
Shape dataShape,
long[] indices,
Shape shape)
Stores the matrix in row sparse format.
|
void |
debugDump(int level)
Prints information about this
NDManager and all sub-managers to the console. |
void |
detach(java.lang.String resourceId)
Detaches a
NDArray from this NDManager 's lifecycle. |
NDArray |
eye(int rows,
int cols,
int k,
DataType dataType)
Returns a 2-D array with ones on the diagonal and zeros elsewhere.
|
NDArray |
full(Shape shape,
float value,
DataType dataType)
Return a new
NDArray of given shape, filled with value. |
Device |
getDevice()
Returns the default
Device of this NDManager . |
java.lang.String |
getName()
Gets the name of the NDManager.
|
NDManager |
getParentManager()
Returns the parent
NDManager . |
void |
invoke(java.lang.String operation,
NDArray[] src,
NDArray[] dest,
ai.djl.util.PairList<java.lang.String,?> params)
An engine specific generic invocation to native operation.
|
NDList |
invoke(java.lang.String operation,
NDList src,
ai.djl.util.PairList<java.lang.String,?> params)
An engine specific generic invocation to native operation.
|
boolean |
isOpen()
Check if the manager is still valid.
|
NDArray |
linspace(float start,
float stop,
int num,
boolean endpoint)
Returns evenly spaced numbers over a specified interval.
|
NDList |
load(java.nio.file.Path path)
Loads the NDArrays saved to a file.
|
NDManager |
newSubManager()
Creates a child
NDManager . |
NDArray |
ones(Shape shape,
DataType dataType)
|
NDArray |
randomInteger(long low,
long high,
Shape shape,
DataType dataType)
Returns random integer values from low (inclusive) to high (exclusive).
|
NDArray |
randomMultinomial(int n,
NDArray pValues)
Draw samples from a multinomial distribution.
|
NDArray |
randomMultinomial(int n,
NDArray pValues,
Shape shape)
Draw samples from a multinomial distribution.
|
NDArray |
randomNormal(float loc,
float scale,
Shape shape,
DataType dataType)
Draws random samples from a normal (Gaussian) distribution.
|
NDArray |
randomUniform(float low,
float high,
Shape shape,
DataType dataType)
Draws samples from a uniform distribution.
|
void |
setName(java.lang.String name)
Sets the name for the NDManager.
|
java.lang.String |
toString() |
NDArray |
zeros(Shape shape,
DataType dataType)
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
allocateDirect, arange, arange, arange, arange, arange, arange, arange, arange, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, createCSR, createRowSparse, decode, decode, eye, eye, eye, eye, full, full, full, getEngine, linspace, linspace, linspace, linspace, load, newBaseManager, newBaseManager, newBaseManager, newSubManager, ones, ones, randomNormal, randomNormal, randomNormal, randomUniform, randomUniform, zeros, zeros
protected NDManager parent
protected java.lang.String uid
protected java.lang.String name
protected Device device
protected java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.AutoCloseable> resources
protected java.util.concurrent.atomic.AtomicBoolean closed
public NDArray create(java.lang.String data)
NDArray
. NDArray of String DataType only supports
scalar.public NDArray createCSR(java.nio.Buffer data, long[] indptr, long[] indices, Shape shape)
createCSR
in interface NDManager
data
- the data to set for the CSR Matrixindptr
- the indptr array is what will help identify the rows where the data appearsindices
- the indices array stores the column index for each non-zero element in datashape
- the Shape
of the NDArray
NDArray
public NDArray createRowSparse(java.nio.Buffer data, Shape dataShape, long[] indices, Shape shape)
public NDArray createCoo(java.nio.Buffer data, long[][] indices, Shape shape)
public NDList load(java.nio.file.Path path)
public void setName(java.lang.String name)
public java.lang.String getName()
public NDArray full(Shape shape, float value, DataType dataType)
NDArray
of given shape, filled with value.public NDArray arange(float start, float stop, float step, DataType dataType)
Values are generated within the half-open interval [start, stop) (in other words, the
interval including start but excluding stop). For integer arguments, the function is
equivalent to the Python built-in range function, but returns an instance of NDArray
rather than a list.
public NDArray eye(int rows, int cols, int k, DataType dataType)
eye
in interface NDManager
rows
- the number of rows int the outputcols
- the number of columns in the outputk
- the index of the diagonal: a positive value refers to an upper diagonal, and a
negative value to a lower diagonaldataType
- the DataType
of the NDArray
NDArray
where all elements are equal to zero, except for the k-th diagonal,
whose values are equal to onepublic NDArray linspace(float start, float stop, int num, boolean endpoint)
Returns num evenly spaced samples, calculated over the interval [start, stop].The endpoint of the interval can optionally be excluded.
public NDArray randomInteger(long low, long high, Shape shape, DataType dataType)
randomInteger
in interface NDManager
low
- Lowest (signed) longs to be drawn from the distributionhigh
- one above the largest (signed) long to be drawn from the distributionshape
- the Shape
of the NDArray
dataType
- the DataType
of the NDArray
NDArray
public NDArray randomUniform(float low, float high, Shape shape, DataType dataType)
Samples are uniformly distributed over the half-open interval [low, high) (includes low, but excludes high). In other words, any value within the given interval is equally likely to be drawn by uniform.
randomUniform
in interface NDManager
low
- the lower boundary of the output interval. All values generated will be greater
than or equal to low.high
- the upper boundary of the output interval. All values generated will be less than
high.shape
- the Shape
of the NDArray
dataType
- the DataType
of the NDArray
NDArray
public NDArray randomNormal(float loc, float scale, Shape shape, DataType dataType)
public NDArray randomMultinomial(int n, NDArray pValues)
The multinomial distribution is a multivariate generalization of the binomial distribution. Take an experiment with one of p possible outcomes. An example of such an experiment is throwing a dice, where the outcome can be 1 through 6. Each sample drawn from the distribution represents n such experiments. Its values, X_i = [X_0, X_1, ..., X_p], represent the number of times the outcome was i.
randomMultinomial
in interface NDManager
n
- the number of experimentspValues
- the probabilities of each of the p different outcomes. These should sum to 1
The last element is always assumed to account for the remaining probability, as long as
pValues.sum().getFloat() <= 1)NDArray
public NDArray randomMultinomial(int n, NDArray pValues, Shape shape)
The multinomial distribution is a multivariate generalization of the binomial distribution. Take an experiment with one of p possible outcomes. An example of such an experiment is throwing a dice, where the outcome can be 1 through 6. Each sample drawn from the distribution represents n such experiments. Its values, X_i = [X_0, X_1, ..., X_p], represent the number of times the outcome was i.
randomMultinomial
in interface NDManager
n
- the number of experimentspValues
- the probabilities of each of the p different outcomes. These should sum to 1
The last element is always assumed to account for the remaining probability, as long as
pValues.sum().getFloat() <= 1)shape
- the output Shape
NDArray
public boolean isOpen()
public NDManager getParentManager()
NDManager
.getParentManager
in interface NDManager
NDManager
public NDManager newSubManager()
NDManager
.
Child NDManager
will inherit default Device
from this NDManager
.
newSubManager
in interface NDManager
NDManager
public java.lang.String toString()
toString
in class java.lang.Object
public void attach(java.lang.String resourceId, java.lang.AutoCloseable resource)
NDArray
or NDManager
to this NDManager
.
Attached resource will be closed when this NDManager
is closed.
public void detach(java.lang.String resourceId)
public void invoke(java.lang.String operation, NDArray[] src, NDArray[] dest, ai.djl.util.PairList<java.lang.String,?> params)
You should avoid using this function if possible. Since this function is engine specific, using this API may cause a portability issue. Native operation may not be compatible between each version.
public NDList invoke(java.lang.String operation, NDList src, ai.djl.util.PairList<java.lang.String,?> params)
You should avoid using this function if possible. Since this function is engine specific, using this API may cause a portability issue. Native operation may not compatible between each version.
public void close()