Class GraphModule

java.lang.Object
org.apache.tvm.contrib.GraphModule

public class GraphModule extends Object
Wrapper runtime module. This is a thin wrapper of the underlying TVM module. you can also directly call set_input, run, and get_output of underlying module functions.
  • Constructor Details

    • GraphModule

      public GraphModule(Module module, Device dev)
  • Method Details

    • release

      public void release()
      Release the GraphModule.

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

    • setInput

      public GraphModule setInput(String key, NDArray value)
      Set inputs to the module.
      Parameters:
      key - The input key.
      value - The input value
      Returns:
      self.
    • setInput

      public GraphModule setInput(int key, NDArray value)
      Set inputs to the module.
      Parameters:
      key - The input key.
      value - The input value.
      Returns:
      self.
    • run

      public GraphModule run()
      Run forward execution of the graph.
      Returns:
      self.
    • getInput

      public NDArray getInput(int index, NDArray out)
      Get index-th input to out.
      Parameters:
      index - The input index.
      out - The output array container.
      Returns:
      out.
    • getOutput

      public NDArray getOutput(int index, NDArray out)
      Get index-th output to out.
      Parameters:
      index - The output index.
      out - The output array container.
      Returns:
      out.
    • debugGetOutput

      public NDArray debugGetOutput(String node, NDArray out)
      Run graph up to node and get the output to out.
      Parameters:
      node - The node name.
      out - The output array container.
      Returns:
      out.
    • debugGetOutput

      public NDArray debugGetOutput(int node, NDArray out)
      Run graph up to node and get the output to out.
      Parameters:
      node - The node index.
      out - The output array container.
      Returns:
      out.
    • loadParams

      public GraphModule loadParams(byte[] params)
      Load parameters from serialized byte array of parameter dict.
      Parameters:
      params - The serialized parameter.
      Returns:
      self.
    • getFunction

      public Function getFunction(String key)
      Get internal module function.
      Parameters:
      key - The key to the module.
      Returns:
      The function.
      Throws:
      IllegalArgumentException - if function does not exist.