o
    ۾i                     @   sZ   d Z ddlmZmZ G dd dedZG dd deZG dd	 d	eZG d
d deZdS )z/
Defines CPU Options for use in the CPU target
    )ABCMetaabstractmethodc                   @   s0   e Zd ZdZedefddZdefddZdS )AbstractOptionValuez2Abstract base class for custom option values.
    returnc                 C   s   dS )z*Returns an encoding of the values
        N selfr   r   J/home/ubuntu/.local/lib/python3.10/site-packages/numba/core/cpu_options.pyencode
   s   zAbstractOptionValue.encodec                 C   s   | j j d|   dS )N())	__class____name__r
   r   r   r   r	   __repr__   s   zAbstractOptionValue.__repr__N)r   
__module____qualname____doc__r   strr
   r   r   r   r   r	   r      s
    r   )	metaclassc                   @   s:   e Zd ZdZdd Zdd ZeZdefddZd	d
 Z	dS )FastMathOptionsz9
    Options for controlling fast math optimization.
    c                 C   s   h d}t |tr|j | _d S |du rdh| _d S |du r%t | _d S t |tr;|| }|r6td| || _d S t |tr\t| | }|rPtd| dd | D | _d S d}t|)	N>   afnnszarcpfastninfnnanreassoccontractTr   FzUnrecognized fastmath flags: %sc                 S   s   h | ]\}}|r|qS r   r   ).0venabler   r   r	   	<setcomp>0       z+FastMathOptions.__init__.<locals>.<setcomp>z<Expected fastmath option(s) to be either a bool, dict or set)	
isinstancer   flagscopyset
ValueErrordictkeysitems)r   valuevalid_flagsinvalidmsgr   r   r	   __init__   s&   



zFastMathOptions.__init__c                 C   
   t | jS N)boolr$   r   r   r   r	   __bool__5      
zFastMathOptions.__bool__r   c                 C   r0   r1   )r   r$   r   r   r   r	   r
   :   r4   zFastMathOptions.encodec                 C       t |t | u r| j|jkS tS r1   )typer$   NotImplementedr   otherr   r   r	   __eq__=      zFastMathOptions.__eq__N)
r   r   r   r   r/   r3   __nonzero__r   r
   r:   r   r   r   r	   r      s    r   c                   @   s:   e Zd ZdZdZdd Zdd Zdd Zd	efd
dZ	dS )ParallelOptionsz7
    Options for controlling auto parallelization.
    )	enabledcomprehension	reductioninplace_binopsetitemnumpystencilfusionprangec                 C   sB  t |tr"|| _|| _|| _|| _|| _|| _|| _|| _	|| _
d S t |trpd| _|dd| _|dd| _|dd| _|dd| _|dd| _|dd| _|dd| _	|d	d| _
|rnd
|  }t|d S t |tr|j| _|j| _|j| _|j| _|j| _|j| _|j| _|j	| _	|j
| _
d S d}t|)NTr?   r@   rA   rB   rC   rD   rE   rF   z!Unrecognized parallel options: %sz4Expect parallel option to be either a bool or a dict)r#   r2   r>   r?   r@   rA   rB   rC   rD   rE   rF   r(   popr)   	NameErrorr=   r'   )r   r+   r.   r   r   r	   r/   J   sH   



zParallelOptions.__init__c                    s    fdd j D S )z"Get values as dictionary.
        c                    s   i | ]}|t  |qS r   )getattr)r   kr   r   r	   
<dictcomp>s   r"   z/ParallelOptions._get_values.<locals>.<dictcomp>)	__slots__r   r   r   r	   _get_valuesp   s   zParallelOptions._get_valuesc                 C   s$   t |t | u r|  | kS tS r1   )r6   rM   r7   r8   r   r   r	   r:   u   s   zParallelOptions.__eq__r   c                 C   s   d dd |   D S )Nz, c                 s   s"    | ]\}}| d | V  qdS )=Nr   )r   rJ   r   r   r   r	   	<genexpr>{   s     z)ParallelOptions.encode.<locals>.<genexpr>)joinrM   r*   r   r   r   r	   r
   z   s   zParallelOptions.encodeN)
r   r   r   r   rL   r/   rM   r:   r   r
   r   r   r   r	   r=   C   s    &r=   c                   @   s^   e Zd ZdZdd Zedd Zedd Zedd	 Zed
d Z	dd Z
defddZdS )InlineOptionsz*
    Options for controlling inlining
    c                 C   sD   d}t |tr|dv rd}nt|d}|r|| _d S d| }t|)NF)alwaysneverT__call__z~kwarg 'inline' must be one of the strings 'always' or 'never', or it can be a callable that returns True/False. Found value %s)r#   r   hasattr_inliner'   )r   r+   okr.   r   r   r	   r/      s   


zInlineOptions.__init__c                 C   
   | j dkS )z&
        True if never inline
        rS   rV   r   r   r   r	   is_never_inline      
zInlineOptions.is_never_inlinec                 C   rX   )z'
        True if always inline
        rR   rY   r   r   r   r	   is_always_inline   r[   zInlineOptions.is_always_inlinec                 C   s   | j p| j S )z2
        True if a cost model is provided
        )r\   rZ   r   r   r   r	   has_cost_model   s   zInlineOptions.has_cost_modelc                 C   s   | j S )z
        The raw value
        rY   r   r   r   r	   r+      s   zInlineOptions.valuec                 C   r5   r1   )r6   r+   r7   r8   r   r   r	   r:      r;   zInlineOptions.__eq__r   c                 C   r0   r1   )reprrV   r   r   r   r	   r
      r4   zInlineOptions.encodeN)r   r   r   r   r/   propertyrZ   r\   r]   r+   r:   r   r
   r   r   r   r	   rQ   ~   s    



rQ   N)r   abcr   r   r   r   r=   rQ   r   r   r   r	   <module>   s    /;