Class NDScope

java.lang.Object
ai.djl.ndarray.NDScope
All Implemented Interfaces:
AutoCloseable

public class NDScope extends Object implements AutoCloseable
A class that tracks NDResource objects created in the try-with-resource block and close them automatically when out of the block scope.

This class has been derived from org.bytedeco.javacpp.PointerScope by Samuel Audet

  • Constructor Details

    • NDScope

      public NDScope()
      Constructs a new NDScope instance.
  • Method Details

    • register

      public static void register(NDArray array)
      Registers NDArray object to this scope.
      Parameters:
      array - the NDArray object
    • unregister

      public static void unregister(NDArray array)
      Unregisters NDArray object from this scope.
      Parameters:
      array - the NDArray object
    • unregister

      public static void unregister(NDArray... arrays)
      Unregisters NDArray object from this scope.
      Parameters:
      arrays - the array of NDArray object
    • unregister

      public static void unregister(NDList ndlist)
      Unregisters NDArray object from this scope.
      Parameters:
      ndlist - the NDList object
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • suppressNotUsedWarning

      public void suppressNotUsedWarning()
      A method that does nothing.

      You may use it if you do not have a better way to suppress the warning of a created but not explicitly used scope.