Class Function

java.lang.Object
org.apache.tvm.TVMValue
org.apache.tvm.Function

public class Function extends TVMValue
TVM Packed Function.
  • Field Details

    • isResident

      public final boolean isResident
  • Method Details

    • getFunction

      public static Function getFunction(String name)
      Get registered function.
      Parameters:
      name - full function name.
      Returns:
      TVM function.
    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • asFunction

      public Function asFunction()
      Easy for user to get the instance from returned TVMValue.
      Overrides:
      asFunction in class TVMValue
      Returns:
      this
    • release

      public void release()
      Release the Function.

      We highly recommend you to do this manually since the GC strategy is lazy.

      Overrides:
      release in class TVMValue
    • invoke

      public TVMValue invoke()
      Invoke the function.
      Returns:
      the result.
    • pushArg

      public Function pushArg(int arg)
      Push argument to the function.
      Parameters:
      arg - int argument.
      Returns:
      this
    • pushArg

      public Function pushArg(long arg)
      Push argument to the function.
      Parameters:
      arg - long argument.
      Returns:
      this
    • pushArg

      public Function pushArg(float arg)
      Push argument to the function.
      Parameters:
      arg - float argument.
      Returns:
      this
    • pushArg

      public Function pushArg(double arg)
      Push argument to the function.
      Parameters:
      arg - double argument.
      Returns:
      this
    • pushArg

      public Function pushArg(String arg)
      Push argument to the function.
      Parameters:
      arg - String argument.
      Returns:
      this
    • pushArg

      public Function pushArg(NDArrayBase arg)
      Push argument to the function.
      Parameters:
      arg - NDArray.
      Returns:
      this
    • pushArg

      public Function pushArg(Module arg)
      Push argument to the function.
      Parameters:
      arg - Module.
      Returns:
      this
    • pushArg

      public Function pushArg(Function arg)
      Push argument to the function.
      Parameters:
      arg - Function.
      Returns:
      this
    • pushArg

      public Function pushArg(byte[] arg)
      Push argument to the function.
      Parameters:
      arg - bytes.
      Returns:
      this
    • pushArg

      public Function pushArg(Device arg)
      Push argument to the function.
      Parameters:
      arg - Device.
      Returns:
      this
    • call

      public TVMValue call(Object... args)
      Invoke function with arguments.
      Parameters:
      args - Can be Integer, Long, Float, Double, String, NDArray.
      Returns:
      the result.
    • register

      public static void register(String name, Function.Callback function, boolean override)
      Register user-defined global function.
      Parameters:
      name - The function name.
      function - The function to be registered.
      override - Whether override existing entry.
    • register

      public static void register(String name, Function.Callback function)
      Register user-defined global function, do not override existing entry.
      Parameters:
      name - The function name.
      function - The function to be registered.
    • convertFunc

      public static Function convertFunc(Function.Callback function)
      Convert a Java function to TVM function.
      Parameters:
      function - Java function.
      Returns:
      TVM function.