Class MxNDManager

java.lang.Object
ai.djl.ndarray.BaseNDManager
ai.djl.mxnet.engine.MxNDManager
All Implemented Interfaces:
ai.djl.ndarray.NDManager, AutoCloseable

public class MxNDManager extends ai.djl.ndarray.BaseNDManager
MxNDManager is the MXNet implementation of NDManager.
  • Nested Class Summary

    Nested classes/interfaces inherited from class ai.djl.ndarray.BaseNDManager

    ai.djl.ndarray.BaseNDManager.TempResource

    Nested classes/interfaces inherited from interface ai.djl.ndarray.NDManager

    ai.djl.ndarray.NDManager.SystemNDManager
  • Field Summary

    Fields inherited from class ai.djl.ndarray.BaseNDManager

    alternativeManager, capped, closed, device, name, parent, resources, tempResources, uid
  • Method Summary

    Modifier and Type
    Method
    Description
    allocateDirect(int capacity)
    ai.djl.ndarray.NDArray
    arange(float start, float stop, float step, ai.djl.ndarray.types.DataType dataType)
    create(ai.djl.ndarray.types.Shape shape, ai.djl.ndarray.types.DataType dataType)
    create(com.sun.jna.Pointer handle)
    Creates an MxNDArray with the given Native Memory Pointer and attaches to this manager.
    create(com.sun.jna.Pointer handle, ai.djl.ndarray.types.SparseFormat fmt)
    Creates a sparse MxNDArray with the given Native Memory Pointer and attaches to this manager.
    createCSR(Buffer data, long[] indptr, long[] indices, ai.djl.ndarray.types.Shape shape)
    createRowSparse(Buffer data, ai.djl.ndarray.types.Shape dataShape, long[] indices, ai.djl.ndarray.types.Shape shape)
    ai.djl.ndarray.NDArray
    eye(int rows, int cols, int k, ai.djl.ndarray.types.DataType dataType)
    from(ai.djl.ndarray.NDArray array)
    ai.djl.ndarray.NDArray
    full(ai.djl.ndarray.types.Shape shape, float value, ai.djl.ndarray.types.DataType dataType)
    final ai.djl.engine.Engine
    void
    invoke(String operation, ai.djl.ndarray.NDArray[] src, ai.djl.ndarray.NDArray[] dest, ai.djl.util.PairList<String,?> params)
    ai.djl.ndarray.NDArray
    invoke(String operation, ai.djl.ndarray.NDArray[] src, ai.djl.util.PairList<String,?> params)
    An engine specific generic invocation to native operator.
    ai.djl.ndarray.NDArray
    invoke(String operation, ai.djl.ndarray.NDArray src, ai.djl.util.PairList<String,?> params)
    An engine specific generic invocation to native operator.
    void
    invoke(String operation, ai.djl.ndarray.NDList src, ai.djl.ndarray.NDList dest, ai.djl.util.PairList<String,?> params)
    An engine specific generic invocation to native operator.
    ai.djl.ndarray.NDList
    invoke(String operation, ai.djl.ndarray.NDList src, ai.djl.util.PairList<String,?> params)
    ai.djl.ndarray.NDArray
    invoke(String operation, ai.djl.util.PairList<String,?> params)
    An engine specific generic invocation to native operator.
    ai.djl.ndarray.NDArray
    linspace(float start, float stop, int num, boolean endpoint)
    ai.djl.ndarray.NDList
    load(Path path)
    newSubManager(ai.djl.Device dev)
    ai.djl.ndarray.NDArray
    ones(ai.djl.ndarray.types.Shape shape, ai.djl.ndarray.types.DataType dataType)
    ai.djl.ndarray.NDArray
    randomInteger(long low, long high, ai.djl.ndarray.types.Shape shape, ai.djl.ndarray.types.DataType dataType)
    ai.djl.ndarray.NDArray
    randomMultinomial(int n, ai.djl.ndarray.NDArray pValues)
    ai.djl.ndarray.NDArray
    randomMultinomial(int n, ai.djl.ndarray.NDArray pValues, ai.djl.ndarray.types.Shape shape)
    ai.djl.ndarray.NDArray
    randomNormal(float loc, float scale, ai.djl.ndarray.types.Shape shape, ai.djl.ndarray.types.DataType dataType)
    ai.djl.ndarray.NDArray
    ai.djl.ndarray.NDArray
    randomUniform(float low, float high, ai.djl.ndarray.types.Shape shape, ai.djl.ndarray.types.DataType dataType)
    ai.djl.ndarray.NDArray
    sampleGamma(ai.djl.ndarray.NDArray alpha, ai.djl.ndarray.NDArray beta)
    ai.djl.ndarray.NDArray
    sampleGamma(ai.djl.ndarray.NDArray alpha, ai.djl.ndarray.NDArray beta, ai.djl.ndarray.types.Shape shape)
    ai.djl.ndarray.NDArray
    sampleNormal(ai.djl.ndarray.NDArray mu, ai.djl.ndarray.NDArray sigma)
    ai.djl.ndarray.NDArray
    sampleNormal(ai.djl.ndarray.NDArray mu, ai.djl.ndarray.NDArray sigma, ai.djl.ndarray.types.Shape shape)
    ai.djl.ndarray.NDArray
    samplePoisson(ai.djl.ndarray.NDArray lam)
    ai.djl.ndarray.NDArray
    samplePoisson(ai.djl.ndarray.NDArray lam, ai.djl.ndarray.types.Shape shape)
    ai.djl.ndarray.NDArray
    zeros(ai.djl.ndarray.types.Shape shape, ai.djl.ndarray.types.DataType dataType)

    Methods inherited from class ai.djl.ndarray.BaseNDManager

    attachInternal, attachUncappedInternal, cap, close, copyBuffer, create, createCoo, debugDump, defaultDevice, detachInternal, getDevice, getManagedArrays, getName, getParentManager, isOpen, newSubManager, setName, tempAttachInternal, toString, truncatedNormal, validateBuffer

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface ai.djl.ndarray.NDManager

    arange, arange, arange, arange, arange, arange, arange, arange, attachAll, 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, create, create, create, create, createCSR, createCSR, createRowSparse, decode, decode, eye, eye, eye, eye, full, full, full, hanningWindow, linspace, linspace, linspace, linspace, load, ones, ones, randomNormal, randomNormal, randomNormal, randomUniform, randomUniform, ret, tempAttachAll, truncatedNormal, truncatedNormal, truncatedNormal, zeros, zeros
  • Method Details

    • allocateDirect

      public ByteBuffer allocateDirect(int capacity)
    • from

      public MxNDArray from(ai.djl.ndarray.NDArray array)
    • create

      public MxNDArray create(com.sun.jna.Pointer handle)
      Creates an MxNDArray with the given Native Memory Pointer and attaches to this manager.
      Parameters:
      handle - the array's native memory pointer
      Returns:
      the created array
    • create

      public MxNDArray create(com.sun.jna.Pointer handle, ai.djl.ndarray.types.SparseFormat fmt)
      Creates a sparse MxNDArray with the given Native Memory Pointer and attaches to this manager.
      Parameters:
      handle - the array's native memory pointer
      fmt - the sparse format to use
      Returns:
      the created array
    • create

      public MxNDArray create(ai.djl.ndarray.types.Shape shape, ai.djl.ndarray.types.DataType dataType)
      Specified by:
      create in interface ai.djl.ndarray.NDManager
      Overrides:
      create in class ai.djl.ndarray.BaseNDManager
    • createCSR

      public MxNDArray createCSR(Buffer data, long[] indptr, long[] indices, ai.djl.ndarray.types.Shape shape)
      Specified by:
      createCSR in interface ai.djl.ndarray.NDManager
      Overrides:
      createCSR in class ai.djl.ndarray.BaseNDManager
    • createRowSparse

      public MxNDArray createRowSparse(Buffer data, ai.djl.ndarray.types.Shape dataShape, long[] indices, ai.djl.ndarray.types.Shape shape)
      Specified by:
      createRowSparse in interface ai.djl.ndarray.NDManager
      Overrides:
      createRowSparse in class ai.djl.ndarray.BaseNDManager
    • load

      public ai.djl.ndarray.NDList load(Path path)
      Specified by:
      load in interface ai.djl.ndarray.NDManager
      Overrides:
      load in class ai.djl.ndarray.BaseNDManager
    • zeros

      public ai.djl.ndarray.NDArray zeros(ai.djl.ndarray.types.Shape shape, ai.djl.ndarray.types.DataType dataType)
    • ones

      public ai.djl.ndarray.NDArray ones(ai.djl.ndarray.types.Shape shape, ai.djl.ndarray.types.DataType dataType)
    • full

      public ai.djl.ndarray.NDArray full(ai.djl.ndarray.types.Shape shape, float value, ai.djl.ndarray.types.DataType dataType)
      Specified by:
      full in interface ai.djl.ndarray.NDManager
      Overrides:
      full in class ai.djl.ndarray.BaseNDManager
    • arange

      public ai.djl.ndarray.NDArray arange(float start, float stop, float step, ai.djl.ndarray.types.DataType dataType)
      Specified by:
      arange in interface ai.djl.ndarray.NDManager
      Overrides:
      arange in class ai.djl.ndarray.BaseNDManager
    • eye

      public ai.djl.ndarray.NDArray eye(int rows, int cols, int k, ai.djl.ndarray.types.DataType dataType)
      Specified by:
      eye in interface ai.djl.ndarray.NDManager
      Overrides:
      eye in class ai.djl.ndarray.BaseNDManager
    • linspace

      public ai.djl.ndarray.NDArray linspace(float start, float stop, int num, boolean endpoint)
      Specified by:
      linspace in interface ai.djl.ndarray.NDManager
      Overrides:
      linspace in class ai.djl.ndarray.BaseNDManager
    • randomInteger

      public ai.djl.ndarray.NDArray randomInteger(long low, long high, ai.djl.ndarray.types.Shape shape, ai.djl.ndarray.types.DataType dataType)
      Specified by:
      randomInteger in interface ai.djl.ndarray.NDManager
      Overrides:
      randomInteger in class ai.djl.ndarray.BaseNDManager
    • randomPermutation

      public ai.djl.ndarray.NDArray randomPermutation(long n)
      Specified by:
      randomPermutation in interface ai.djl.ndarray.NDManager
      Overrides:
      randomPermutation in class ai.djl.ndarray.BaseNDManager
    • randomUniform

      public ai.djl.ndarray.NDArray randomUniform(float low, float high, ai.djl.ndarray.types.Shape shape, ai.djl.ndarray.types.DataType dataType)
      Specified by:
      randomUniform in interface ai.djl.ndarray.NDManager
      Overrides:
      randomUniform in class ai.djl.ndarray.BaseNDManager
    • randomNormal

      public ai.djl.ndarray.NDArray randomNormal(float loc, float scale, ai.djl.ndarray.types.Shape shape, ai.djl.ndarray.types.DataType dataType)
      Specified by:
      randomNormal in interface ai.djl.ndarray.NDManager
      Overrides:
      randomNormal in class ai.djl.ndarray.BaseNDManager
    • randomMultinomial

      public ai.djl.ndarray.NDArray randomMultinomial(int n, ai.djl.ndarray.NDArray pValues, ai.djl.ndarray.types.Shape shape)
      Specified by:
      randomMultinomial in interface ai.djl.ndarray.NDManager
      Overrides:
      randomMultinomial in class ai.djl.ndarray.BaseNDManager
    • randomMultinomial

      public ai.djl.ndarray.NDArray randomMultinomial(int n, ai.djl.ndarray.NDArray pValues)
      Specified by:
      randomMultinomial in interface ai.djl.ndarray.NDManager
      Overrides:
      randomMultinomial in class ai.djl.ndarray.BaseNDManager
    • sampleNormal

      public ai.djl.ndarray.NDArray sampleNormal(ai.djl.ndarray.NDArray mu, ai.djl.ndarray.NDArray sigma)
      Specified by:
      sampleNormal in interface ai.djl.ndarray.NDManager
      Overrides:
      sampleNormal in class ai.djl.ndarray.BaseNDManager
    • sampleNormal

      public ai.djl.ndarray.NDArray sampleNormal(ai.djl.ndarray.NDArray mu, ai.djl.ndarray.NDArray sigma, ai.djl.ndarray.types.Shape shape)
      Specified by:
      sampleNormal in interface ai.djl.ndarray.NDManager
      Overrides:
      sampleNormal in class ai.djl.ndarray.BaseNDManager
    • samplePoisson

      public ai.djl.ndarray.NDArray samplePoisson(ai.djl.ndarray.NDArray lam)
      Specified by:
      samplePoisson in interface ai.djl.ndarray.NDManager
      Overrides:
      samplePoisson in class ai.djl.ndarray.BaseNDManager
    • samplePoisson

      public ai.djl.ndarray.NDArray samplePoisson(ai.djl.ndarray.NDArray lam, ai.djl.ndarray.types.Shape shape)
      Specified by:
      samplePoisson in interface ai.djl.ndarray.NDManager
      Overrides:
      samplePoisson in class ai.djl.ndarray.BaseNDManager
    • sampleGamma

      public ai.djl.ndarray.NDArray sampleGamma(ai.djl.ndarray.NDArray alpha, ai.djl.ndarray.NDArray beta)
      Specified by:
      sampleGamma in interface ai.djl.ndarray.NDManager
      Overrides:
      sampleGamma in class ai.djl.ndarray.BaseNDManager
    • sampleGamma

      public ai.djl.ndarray.NDArray sampleGamma(ai.djl.ndarray.NDArray alpha, ai.djl.ndarray.NDArray beta, ai.djl.ndarray.types.Shape shape)
      Specified by:
      sampleGamma in interface ai.djl.ndarray.NDManager
      Overrides:
      sampleGamma in class ai.djl.ndarray.BaseNDManager
    • newSubManager

      public MxNDManager newSubManager(ai.djl.Device dev)
    • invoke

      public void invoke(String operation, ai.djl.ndarray.NDArray[] src, ai.djl.ndarray.NDArray[] dest, ai.djl.util.PairList<String,?> params)
      Specified by:
      invoke in interface ai.djl.ndarray.NDManager
      Overrides:
      invoke in class ai.djl.ndarray.BaseNDManager
    • invoke

      public ai.djl.ndarray.NDList invoke(String operation, ai.djl.ndarray.NDList src, ai.djl.util.PairList<String,?> params)
      Specified by:
      invoke in interface ai.djl.ndarray.NDManager
      Overrides:
      invoke in class ai.djl.ndarray.BaseNDManager
    • invoke

      public void invoke(String operation, ai.djl.ndarray.NDList src, ai.djl.ndarray.NDList dest, ai.djl.util.PairList<String,?> params)
      An engine specific generic invocation to native operator.

      You should avoid using this function if possible. Since this function is engine specific, using this API may cause portability issues. A native operation may not be compatible between each version.

      Parameters:
      operation - the native operation to perform
      src - the NDList of source NDArray
      dest - the NDList to save output to
      params - the parameters to be passed to the native operator
      Throws:
      IllegalArgumentException - if operation is not supported by Engine
      ai.djl.engine.EngineException - if operation failed in native engine
    • invoke

      public ai.djl.ndarray.NDArray invoke(String operation, ai.djl.ndarray.NDArray[] src, ai.djl.util.PairList<String,?> params)
      An engine specific generic invocation to native operator.

      You should avoid using this function if possible. Since this function is engine specific, using this API may cause portability issues. A native operation may not be compatible between each version.

      Parameters:
      operation - the native operation to perform
      src - the array of source NDArray
      params - the parameters to be passed to the native operator
      Returns:
      the output array of NDArray
      Throws:
      IllegalArgumentException - if operation is not supported by Engine
      ai.djl.engine.EngineException - if operation failed in native engine
    • invoke

      public ai.djl.ndarray.NDArray invoke(String operation, ai.djl.ndarray.NDArray src, ai.djl.util.PairList<String,?> params)
      An engine specific generic invocation to native operator.

      You should avoid using this function if possible. Since this function is engine specific, using this API may cause portability issues. A native operation may not be compatible between each version.

      Parameters:
      operation - the native operation to perform
      src - the source NDArray
      params - the parameters to be passed to the native operator
      Returns:
      the output array of NDArray
      Throws:
      IllegalArgumentException - if operation is not supported by Engine
      ai.djl.engine.EngineException - if operation failed in native engine
    • invoke

      public ai.djl.ndarray.NDArray invoke(String operation, ai.djl.util.PairList<String,?> params)
      An engine specific generic invocation to native operator.

      You should avoid using this function if possible. Since this function is engine specific, using this API may cause portability issues. A native operation may not be compatible between each version.

      Parameters:
      operation - the native operation to perform
      params - the parameters to be passed to the native operator
      Returns:
      the output array of NDArray
      Throws:
      IllegalArgumentException - if operation is not supported by Engine
      ai.djl.engine.EngineException - if operation failed in native engine
    • getEngine

      public final ai.djl.engine.Engine getEngine()