o
    e/  ã                   @   s*   d dl mZ ddlmZ G dd„ dƒZdS )é    )Úservice_pb2é   )Úraise_errorc                   @   s<   e Zd ZdZddd„Zdd„ Zddd„Zd	d
„ Zdd„ ZdS )ÚInferRequestedOutputa”  An object of InferRequestedOutput class is used to describe a
    requested output tensor for an inference request.

    Parameters
    ----------
    name : str
        The name of output tensor to associate with this object
    class_count : int
        The number of classifications to be requested. The default
        value is 0 which means the classification results are not
        requested.
    r   c                 C   s4   t  ¡  ¡ | _|| j_|dkr|| jjd _d S d S )Nr   Úclassification)r   ZModelInferRequestZInferRequestedOutputTensorÚ_outputÚnameÚ
parametersÚint64_param)Úselfr   Zclass_count© r   úSD:\Projects\ConvertPro\env\Lib\site-packages\tritonclient/grpc/_requested_output.pyÚ__init__/   s
   ÿzInferRequestedOutput.__init__c                 C   s   | j jS )zˆGet the name of output associated with this object.

        Returns
        -------
        str
            The name of output
        )r   r   ©r   r   r   r   r   5   s   zInferRequestedOutput.namec                 C   sN   d| j jv r
tdƒ || j jd _|| j jd _|dkr%|| j jd _dS dS )aT  Marks the output to return the inference result in
        specified shared memory region.

        Parameters
        ----------
        region_name : str
            The name of the shared memory region to hold tensor data.
        byte_size : int
            The size of the shared memory region to hold tensor data.
        offset : int
            The offset, in bytes, into the region where the data for
            the tensor starts. The default value is 0.

        Raises
        ------
        InferenceServerException
            If failed to set shared memory for the tensor.
        r   z3shared memory can't be set on classification outputÚshared_memory_regionÚshared_memory_byte_sizer   Úshared_memory_offsetN)r   r	   r   Zstring_paramr
   )r   Zregion_nameZ	byte_sizeÚoffsetr   r   r   Úset_shared_memory?   s   ÿz&InferRequestedOutput.set_shared_memoryc                 C   s4   | j j dd¡ | j j dd¡ | j j dd¡ dS )zåClears the shared memory option set by the last call to
        InferRequestedOutput.set_shared_memory(). After call to this
        function requested output will no longer be returned in a
        shared memory region.
        r   Nr   r   )r   r	   Úpopr   r   r   r   Úunset_shared_memoryZ   s   z(InferRequestedOutput.unset_shared_memoryc                 C   s   | j S )zÅRetrieve the underlying InferRequestedOutputTensor message.
        Returns
        -------
        protobuf message
            The underlying InferRequestedOutputTensor protobuf message.
        )r   r   r   r   r   Ú_get_tensore   s   z InferRequestedOutput._get_tensorN)r   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r   r   !   s    


r   N)Ztritonclient.grpcr   Ú_utilsr   r   r   r   r   r   Ú<module>   s   