Class InferRequest


  • public class InferRequest
    extends Wrapper
    This is a class of infer request that can be run in asynchronous or synchronous manners.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected InferRequest​(long addr)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void delete​(long nativeObj)  
      Tensor get_output_tensor()
      Gets an output tensor for inference.
      Tensor get_tensor​(java.lang.String tensorName)
      Gets an input/output tensor for inference by tensor name.
      void infer()
      Infers specified input(s) in synchronous mode.
      void release()
      Detele the native object to release resources.
      void set_input_tensor​(Tensor tensor)
      Sets an input tensor to infer models with single input.
      void set_output_tensor​(Tensor tensor)
      Sets an output tensor to infer models with single output.
      void start_async()
      Starts inference of specified input(s) in asynchronous mode.
      void wait_async()
      Waits for the result to become available.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • InferRequest

        protected InferRequest​(long addr)
    • Method Detail

      • infer

        public void infer()
        Infers specified input(s) in synchronous mode.

        It blocks all methods of InferRequest while request is ongoing (running or waiting in a queue). Calling any method leads to throwning the ov::Busy exception.

      • set_input_tensor

        public void set_input_tensor​(Tensor tensor)
        Sets an input tensor to infer models with single input.

        If model has several inputs, an exception is thrown.

        Parameters:
        tensor - Reference to the input tensor.
      • get_output_tensor

        public Tensor get_output_tensor()
        Gets an output tensor for inference.
        Returns:
        Output tensor for the model. If model has several outputs, an exception is thrown.
      • start_async

        public void start_async()
        Starts inference of specified input(s) in asynchronous mode.

        It returns immediately. Inference starts also immediately. Calling any method while the request in a running state leads to throwning the ov::Busy exception.

      • wait_async

        public void wait_async()
        Waits for the result to become available. Blocks until the result becomes available.
      • set_output_tensor

        public void set_output_tensor​(Tensor tensor)
        Sets an output tensor to infer models with single output.

        If model has several outputs, an exception is thrown.

        Parameters:
        tensor - Reference to the output tensor.
      • get_tensor

        public Tensor get_tensor​(java.lang.String tensorName)
        Gets an input/output tensor for inference by tensor name.
        Parameters:
        tensorName - Name of a tensor to get.
        Returns:
        The tensor with name "tensorName". If the tensor is not found, an exception is thrown.
      • release

        public void release()
        Detele the native object to release resources.

        This mehtod is protected from double deallocation

      • delete

        protected void delete​(long nativeObj)
        Overrides:
        delete in class Wrapper