o
    wi
                     @   s^   d dl Zd dlZd dlmZ G dd deZejdd Zdd Zd	d
 Z	dd Z
dd ZdS )    N)ITritonDeployablec                   @   s4   e Zd Zdd Zdd Zdd Zdejfdd	Zd
S )MockTritonDeployablec                 C   s   d| _ d| _d S )N   
   r      )input_shapeoutput_shapeself r   `/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/tests/deploy/test_triton_deployable.py__init__   s   
zMockTritonDeployable.__init__c                 C      d| j tjdiS )Ninputshapedtype)r	   npfloat32r   r   r   r   get_triton_input      z%MockTritonDeployable.get_triton_inputc                 C   r   )Noutputr   )r
   r   r   r   r   r   r   get_triton_output   r   z&MockTritonDeployable.get_triton_outputinputsc                 K   s"   |d }dt | jt | iS )Nr   r   )r   onesr
   mean)r   r   
input_datar   r   r   triton_infer_fn    s   z$MockTritonDeployable.triton_infer_fnN)	__name__
__module____qualname__r   r   r   r   ndarrayr   r   r   r   r   r      s
    r   c                   C   s   t  S )N)r   r   r   r   r   mock_deployable%   s   r$   c                 C   B   |   }d|v s
J |d d dksJ |d d tjksJ dS )zCTest that get_triton_input returns the correct input specification.r   r   r   r   N)r   r   r   )r$   
input_specr   r   r   test_get_triton_input*      r'   c                 C   r%   )zETest that get_triton_output returns the correct output specification.r   r   r   r   N)r   r   r   )r$   output_specr   r   r   test_get_triton_output3   r(   r*   c                 C   sb   t jddt j}t |}| j|d}d|v sJ |d jdks%J t |d |s/J dS )z5Test that triton_infer_fn processes inputs correctly.r   r   )r   r   r   N)	r   randomrandastyper   r   r   r   allclose)r$   
test_input
input_meanresultr   r   r   test_triton_infer_fn<   s   
r2   c                   C   s6   t t t  W d   dS 1 sw   Y  dS )z<Test that ITritonDeployable cannot be instantiated directly.N)pytestraises	TypeErrorr   r   r   r   r   !test_abstract_class_instantiationK   s   "r6   )numpyr   r3   nemo.deploy.triton_deployabler   r   fixturer$   r'   r*   r2   r6   r   r   r   r   <module>   s   
		