o
    Xi                     @  sF   d Z ddlmZ ddlZddlmZ ddlmZ G dd dejZ	dS )z0Class for storing metadata about the IR objects.    )annotationsN)Mapping)Anyc                      sL   e Zd ZdZdd fddZdddZdddZdddZdddZ  Z	S )MetadataStorea2  Class for storing metadata about the IR objects.

    Metadata is stored as key-value pairs. The keys are strings and the values
    can be any Python object.

    The metadata store also supports marking keys as invalid. This is useful
    when a pass wants to mark a key that needs to be recomputed.
    NdataMapping[str, Any] | NonereturnNonec                  s   t  | t | _d S N)super__init__set_invalid_keys)selfr   	__class__ E/home/ubuntu/.local/lib/python3.10/site-packages/onnx_ir/_metadata.pyr      s   zMetadataStore.__init__keystritemr   c                 C  s   || j |< | j| d S r
   )r   r   discard)r   r   r   r   r   r   __setitem__   s   
zMetadataStore.__setitem__c                 C  s   | j | d S r
   )r   addr   r   r   r   r   
invalidate   s   zMetadataStore.invalidateboolc                 C  s
   || j vS )aV  Returns whether the value is valid.

        Note that default values (None) are not necessarily invalid. For example,
        a shape that is unknown (None) may be still valid if shape inference has
        determined that the shape is unknown.

        Whether a value is valid is solely determined by the user that sets the value.
        )r   r   r   r   r   is_valid!   s   
	zMetadataStore.is_validc                 C  s   | j j d| jd| jdS )N(z, invalid_keys=))r   __name__r   r   )r   r   r   r   __repr__,   s   zMetadataStore.__repr__r
   )r   r   r   r	   )r   r   r   r   r   r	   )r   r   r   r	   )r   r   r   r   )r   r   )
r    
__module____qualname____doc__r   r   r   r   r!   __classcell__r   r   r   r   r      s    	


r   )
r$   
__future__r   collectionscollections.abcr   typingr   UserDictr   r   r   r   r   <module>   s   