Class CachedOp

java.lang.Object
ai.djl.util.NativeResource<com.sun.jna.Pointer>
ai.djl.mxnet.engine.CachedOp
All Implemented Interfaces:
AutoCloseable

public class CachedOp extends ai.djl.util.NativeResource<com.sun.jna.Pointer>
The CachedOp is an internal helper that provides the core functionality to execute a MxSymbolBlock.

We don't recommended users interact with this class directly. Users should use Predictor instead. CachedOp is an operator that simplifies calling and analyzing the input shape. It requires minimum input to do inference because most of the information can be obtained from the model itself.

  • Field Summary

    Fields inherited from class ai.djl.util.NativeResource

    handle
  • Constructor Summary

    Constructors
    Constructor
    Description
    CachedOp(com.sun.jna.Pointer handle, MxNDManager manager, List<ai.djl.nn.Parameter> parameters, List<Integer> paramIndices, ai.djl.util.PairList<String,Integer> dataIndices)
    Creates an instance of CachedOp.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    ai.djl.ndarray.NDList
    forward(ai.djl.training.ParameterStore parameterStore, ai.djl.ndarray.NDList data, boolean training)
    Assigns inputs to the empty locations of the input NDArray.

    Methods inherited from class ai.djl.util.NativeResource

    getHandle, getUid, isReleased, onClose

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CachedOp

      public CachedOp(com.sun.jna.Pointer handle, MxNDManager manager, List<ai.djl.nn.Parameter> parameters, List<Integer> paramIndices, ai.djl.util.PairList<String,Integer> dataIndices)
      Creates an instance of CachedOp.

      It can be created by using JnaUtils.createCachedOp(MxSymbolBlock, MxNDManager, boolean)

      Parameters:
      handle - the C handle of the CachedOp
      manager - the manager used to create the NDArray
      parameters - the parameter values
      paramIndices - the parameters required by the model and their corresponding location
      dataIndices - the input data names required by the model and their corresponding location
  • Method Details

    • forward

      public ai.djl.ndarray.NDList forward(ai.djl.training.ParameterStore parameterStore, ai.djl.ndarray.NDList data, boolean training)
      Assigns inputs to the empty locations of the input NDArray.
      Parameters:
      parameterStore - the parameterStore
      data - the input in NDList format
      training - true for a training forward pass
      Returns:
      an NDList
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Overrides:
      close in class ai.djl.util.NativeResource<com.sun.jna.Pointer>