/usr/local/lib/python3.6/site-packages/transformers/onnx/__pycache__
NameSizeModeActions
config.cpython-36.pyc208370644editdlrm
convert.cpython-36.pyc128450644editdlrm
features.cpython-36.pyc102140644editdlrm
utils.cpython-36.pyc15240644editdlrm
__init__.cpython-36.pyc8760644editdlrm
__main__.cpython-36.pyc27020644editdlrm
Edit: /usr/local/lib/python3.6/site-packages/transformers/onnx/__pycache__/features.cpython-36.pyc (10214B)
3 Eg>@s8ddlmZmZddlmZmZmZmZmZm Z ddl m Z m Z m Z mZmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd l m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+ddl,m-Z-ddl.m/Z/ddl0m1Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7ddl8m9Z9ddl:m;Z;ddlm?Z?e=j@eAZBerddlCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLerddlCmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTe re reBjUd d!d"eVee?eeVee ge?ffd#d$d%ZWGd&d'd'ZXd!S)()partialreduce)CallableDictOptionalTupleTypeUnion)PretrainedConfigPreTrainedModelTFPreTrainedModelis_tf_availableis_torch_available)AlbertOnnxConfig)BartOnnxConfig)BeitOnnxConfig)BertOnnxConfig)BlenderbotOnnxConfig)BlenderbotSmallOnnxConfig)CamembertOnnxConfig)DistilBertOnnxConfig)ElectraOnnxConfig)FlaubertOnnxConfig)GPT2OnnxConfig)GPTNeoOnnxConfig)GPTJOnnxConfig)IBertOnnxConfig)LayoutLMOnnxConfig)M2M100OnnxConfig)MarianOnnxConfig)MBartOnnxConfig)RobertaOnnxConfig) T5OnnxConfig) ViTOnnxConfig)XLMRobertaOnnxConfig)logging) OnnxConfig) AutoModelAutoModelForCausalLMAutoModelForImageClassificationAutoModelForMaskedLMAutoModelForMultipleChoiceAutoModelForQuestionAnsweringAutoModelForSeq2SeqLM"AutoModelForSequenceClassificationAutoModelForTokenClassification) TFAutoModelTFAutoModelForCausalLMTFAutoModelForMaskedLMTFAutoModelForMultipleChoiceTFAutoModelForQuestionAnsweringTFAutoModelForSeq2SeqLM$TFAutoModelForSequenceClassification!TFAutoModelForTokenClassificationzThe ONNX export features are only supported for PyTorch or TensorFlow. You will not be able to export models without one of these libraries installed.N)onnx_config_cls)supported_featuresr:returncGs`|dkrtdi}xF|D]>}d|krF|jdd}t|j|d||<qt|j|d||<qW|S)a_ Generate the mapping between supported the features and their corresponding OnnxConfig for a given model. Args: *supported_features: The names of the supported features. onnx_config_cls: The OnnxConfig class corresponding to the model. Returns: The dictionary mapping a feature to an OnnxConfig constructor. Nz#A OnnxConfig class must be providedz -with-past)task) ValueErrorreplacerZ with_pastZfrom_model_config)r:r;mappingfeaturer>rCD/usr/local/lib/python3.6/site-packages/transformers/onnx/features.pysupported_features_mapping>s   rEc@seZdZiZiZer.eeee e e e e ed ZerJeeeeeeeedZedddddededd d d d d dded edd d d d d dded eddd dddededddddededdd dddededddddededdd ddde dedd d d d d e!dedd d d e"deddd ddde#dedd d d e$deddd ddde%dedd d d dde&dedd d d dde'dedd d d de(dedddde)deddd ddde*dedde+dedde,dedd d d d d e-dedd d d d d e.ddZ/e0e1dddde/j2DZ3e4d(e5e6e5e7e5e8e9ge:ffdddZ;e4e5e5dddZdd d!Z?e4d*e5e5e5e5e@eAeBfd"d#d$ZCe4d+e@eAeBfe5eDe5e8fd%d&d'ZEdS),FeaturesManager) defaultz masked-lmz causal-lmz seq2seq-lmzsequence-classificationztoken-classificationzmultiple-choicezquestion-answeringzimage-classification)rGz masked-lmz causal-lmz seq2seq-lmzsequence-classificationztoken-classificationzmultiple-choicezquestion-answeringrGz masked-lmzsequence-classificationztoken-classificationzquestion-answering)r:zdefault-with-pastz causal-lmzcausal-lm-with-pastz seq2seq-lmzseq2seq-lm-with-pastzimage-classification)ZalbertZbartZmbartZbertZibertZ camembertZ distilbertZflaubertZmarianzm2m-100ZrobertaZt5z xlm-robertaZgpt2zgpt-jzgpt-neoZlayoutlmZelectraZvitZbeitZ blenderbotzblenderbot-smallcCs||BS)NrC)s1s2rCrCrD'szFeaturesManager.ccs|]}|jVqdS)N)keys).0vrCrCrD 'szFeaturesManager.N) model_type model_namer<cCsX|j}|tjkrN|r&|d|dn|}t|dttjjd|dtj|S)a Tries to retrieve the feature -> OnnxConfig constructor map from the model type. Args: model_type (`str`): The model type to retrieve the supported features for. model_name (`str`, *optional*): The name attribute of the model object, only used for the exception message. Returns: The dictionary mapping each feature to a corresponding OnnxConfig constructor. z ()z is not supported yet. Only z' are supported. If you want to support z) please propose a PR or open up an issue.)lowerrF_SUPPORTED_MODEL_TYPEKeyErrorlistrK)rOrPZmodel_type_and_model_namerCrCrD%get_supported_features_for_model_type)s  "z5FeaturesManager.get_supported_features_for_model_type)rBr<cCs |jddS)Nz -with-pastr=)r@)rBrCrCrDfeature_to_taskCszFeaturesManager.feature_to_task) frameworkcCsP|dkrtd|dn2|dkr4t r4tdn|dkrLt rLtddS) z Validates if the framework requested for the export is both correct and available, otherwise throws an exception. pttfzAOnly two frameworks are supported for ONNX export: pt or tf, but z was provided.zOCannot export model to ONNX using PyTorch because no PyTorch package was found.zUCannot export model to ONNX using TensorFlow because no TensorFlow package was found.N)rYrZ)r?r RuntimeErrorr)rXrCrCrD_validate_framework_choiceGs z*FeaturesManager._validate_framework_choicerY)rBrXr<cCsXtj|}tj||dkr$tj}ntj}||krPtd|dttjj||S)ad Attempts to retrieve an AutoModel class from a feature name. Args: feature (`str`): The feature required. framework (`str`, *optional*, defaults to `"pt"`): The framework to use for the export. Returns: The AutoModel class corresponding to the feature. rYzUnknown task: z. Possible values are )rFrWr\_TASKS_TO_AUTOMODELS_TASKS_TO_TF_AUTOMODELSrTrUvalues)rBrXr>Ztask_to_automodelrCrCrDget_model_class_for_featureVs  z+FeaturesManager.get_model_class_for_feature)rBmodelrX cache_dirr<c Csbtj||}y|j||d}Wn>tk r\|dkrH|j|d|d}n|j|d|d}YnX|S)a Attempts to retrieve a model from a model's name and the feature to be enabled. Args: feature (`str`): The feature required. model (`str`): The name of the model to export. framework (`str`, *optional*, defaults to `"pt"`): The framework to use for the export. Returns: The instance of the model. )rbrYT)Zfrom_tfrb)Zfrom_ptrb)rFr`Zfrom_pretrainedOSError)rBrarXrbZ model_classrCrCrDget_model_from_featureqs z&FeaturesManager.get_model_from_feature)rarBr<cCsd|jjjdd}t|dd}tj||d}||krNt|jjd|d||jjtj||fS)aR Check whether or not the model has the requested features. Args: model: The model to export. feature: The name of the feature to check if it is available. Returns: (str) The type of the model (OnnxConfig) The OnnxConfig instance holding the model export properties. _-namer=)rPz doesn't support feature z. Supported values are: )configrOr@getattrrFrVr?rS)rarBrOrPZmodel_featuresrCrCrDcheck_supported_model_or_raises z.FeaturesManager.check_supported_model_or_raise)N)rY)rYN)rG)F__name__ __module__ __qualname__r]r^rr)r,r*r/r0r1r-r.r+rr2r4r3r7r8r9r5r6rErrr!rrrrrr rr"r#r%rrrrrr$rrrrSsortedrr_ZAVAILABLE_FEATURES staticmethodstrrrrr r(rVrWr\rr`r r r rdrrjrCrCrCrDrFYsr     " rF)Y functoolsrrtypingrrrrrr r=r r r rrZ models.albertrZ models.bartrZ models.beitrZ models.bertrZmodels.blenderbotrZmodels.blenderbot_smallrZmodels.camembertrZmodels.distilbertrZmodels.electrarZmodels.flaubertrZ models.gpt2rZmodels.gpt_neorZ models.gptjrZ models.ibertrZmodels.layoutlmrZmodels.m2m_100rZ models.marianr Z models.mbartr!Zmodels.robertar"Z models.t5r#Z models.vitr$Zmodels.xlm_robertar%utilsr&rhr( get_loggerrkloggerZtransformers.models.autor)r*r+r,r-r.r/r0r1r2r3r4r5r6r7r8r9warningrprErFrCrCrCrDsJ                          , (