
    j                    Z    d dl mZ d dlmZ d dlZd dlmZ ddlmZ  G d de          Z	dS )	    )annotations)PathN)check_requirements   )BaseBackendc                  "    e Zd ZdZddZdd
ZdS )AxeleraBackendzAxelera AI inference backend for Axelera Metis AI accelerators.

    Loads compiled Axelera models (.axm files) and runs inference using the Axelera AI runtime SDK.
    weight
str | PathreturnNonec                   	 ddl m} n!# t          $ r t          dd           Y nw xY wddl m} t	          |          }t          |                    d          d          }|t          d|           |                    t          |                    
                                | _        |j        d	z  }|                                r0dd
lm} |                     |                    |                     dS dS )zLoad an Axelera model from a directory containing a .axm file.

        Args:
            weight (str | Path): Path to the Axelera model directory containing the .axm binary.
        r   )opzaxelera-rt==1.6.0zV--extra-index-url https://software.axelera.ai/artifactory/api/pypi/axelera-pypi/simple)cmdsz*.axmNzNo .axm file found in: zmetadata.yaml)YAML)axelera.runtimer   ImportErrorr   r   nextrglobFileNotFoundErrorloadstr	optimizedmodelparentexistsultralytics.utilsr   apply_metadata)selfr
   r   wfoundmetadata_filer   s          b/var/www/html/Carbon-Document/venv/lib/python3.11/site-packages/ultralytics/nn/backends/axelera.py
load_modelzAxeleraBackend.load_model   s=   	******* 	 	 	#m     	 	'&&&&&LLQWWW%%t,,=#$Aa$A$ABBBWWSZZ((2244
 6!! 	:......		- 8 899999	: 	:s   	 ''imtorch.Tensorlistc                P    |                      |                                          S )zRun inference on the Axelera hardware accelerator.

        Args:
            im (torch.Tensor): Input image tensor in BCHW format, normalized to [0, 1].

        Returns:
            (list): Model predictions as a list of output arrays.
        )r   cpu)r   r%   s     r#   forwardzAxeleraBackend.forward2   s     zz"&&((###    N)r
   r   r   r   )r%   r&   r   r'   )__name__
__module____qualname____doc__r$   r*    r+   r#   r	   r	      sF         
: : : :<	$ 	$ 	$ 	$ 	$ 	$r+   r	   )

__future__r   pathlibr   torchultralytics.utils.checksr   baser   r	   r0   r+   r#   <module>r6      s    # " " " " "        7 7 7 7 7 7      -$ -$ -$ -$ -$[ -$ -$ -$ -$ -$r+   