o
    eo  ã                   @   s   d dl mZ G dd„ dƒZdS )é    )Ú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.
    binary_data : bool
        Indicates whether to return result data for the output in
        binary format or explicit tensor within JSON. The default
        value is True, which means the data will be delivered as
        binary data in the HTTP body after JSON object. This field
        will be unset if shared memory is set for the output.
    class_count : int
        The number of classifications to be requested. The default
        value is 0 which means the classification results are not
        requested.
    Tr   c                 C   s2   || _ i | _|dkr|| jd< || _|| jd< d S )Nr   ÚclassificationÚbinary_data)Ú_nameÚ_parametersÚ_binary)ÚselfÚnamer   Zclass_count© r   úSD:\Projects\ConvertPro\env\Lib\site-packages\tritonclient/http/_requested_output.pyÚ__init__3   s   
zInferRequestedOutput.__init__c                 C   s   | j S )zˆGet the name of output associated with this object.

        Returns
        -------
        str
            The name of output
        )r   ©r	   r   r   r   r
   ;   s   zInferRequestedOutput.namec                 C   sP   d| j v r	tdƒ | jrd| j d< || j d< || j d< |dkr&|| j d< d	S d	S )
aÚ  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.

        r   z3shared memory can't be set on classification outputFr   Úshared_memory_regionÚshared_memory_byte_sizer   Úshared_memory_offsetN)r   r   r   )r	   Zregion_nameZ	byte_sizeÚoffsetr   r   r   Úset_shared_memoryE   s   



ÿz&InferRequestedOutput.set_shared_memoryc                 C   s:   | j | jd< | j dd¡ | j dd¡ | 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   r   Nr   r   )r   r   Úpopr   r   r   r   Úunset_shared_memory^   s   z(InferRequestedOutput.unset_shared_memoryc                 C   s   d| j i}| jr| j|d< |S )zŽRetrieve the underlying input as json dict.

        Returns
        -------
        dict
            The underlying tensor as a dict
        r
   Ú
parameters)r   r   )r	   Ztensorr   r   r   Ú_get_tensorj   s   

z InferRequestedOutput._get_tensorN)Tr   )r   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r
   r   r   r   r   r   r   r   r      s    


r   N)Ztritonclient.utilsr   r   r   r   r   r   Ú<module>   s   