onnx_diagnostic.torch_export_patches.onnx_export_serialization¶
- onnx_diagnostic.torch_export_patches.onnx_export_serialization.flatten_base_model_output(bo: BaseModelOutput) Tuple[List[Any], Any][source][source]¶
Serializes a
transformers.modeling_outputs.BaseModelOutputwith python objects.
- onnx_diagnostic.torch_export_patches.onnx_export_serialization.flatten_dynamic_cache(dynamic_cache: DynamicCache) Tuple[List[Any], Any][source][source]¶
Serializes a
transformers.cache_utils.DynamicCachewith python objects.
- onnx_diagnostic.torch_export_patches.onnx_export_serialization.flatten_encoder_decoder_cache(ec_cache: EncoderDecoderCache) Tuple[List[Any], Any][source][source]¶
Serializes a
transformers.cache_utils.EncoderDecoderCachewith python objects.
- onnx_diagnostic.torch_export_patches.onnx_export_serialization.flatten_mamba_cache(mamba_cache: MambaCache) Tuple[List[Any], Any][source][source]¶
Serializes a
transformers.cache_utils.MambaCachewith python objects.
- onnx_diagnostic.torch_export_patches.onnx_export_serialization.flatten_sliding_window_cache(cache: SlidingWindowCache) Tuple[List[Any], Any][source][source]¶
Serializes a
transformers.cache_utils.SlidingWindowCachewith python objects.
- onnx_diagnostic.torch_export_patches.onnx_export_serialization.flatten_with_keys_base_model_output(bo: BaseModelOutput) Tuple[List[Tuple[KeyEntry, Any]], Any][source][source]¶
Serializes a
transformers.modeling_outputs.BaseModelOutputwith python objects.
- onnx_diagnostic.torch_export_patches.onnx_export_serialization.flatten_with_keys_dynamic_cache(dynamic_cache: DynamicCache) Tuple[List[Tuple[KeyEntry, Any]], Any][source][source]¶
Serializes a
transformers.cache_utils.DynamicCachewith python objects.
- onnx_diagnostic.torch_export_patches.onnx_export_serialization.flatten_with_keys_encoder_decoder_cache(ec_cache: EncoderDecoderCache) Tuple[List[Tuple[KeyEntry, Any]], Any][source][source]¶
Serializes a
transformers.cache_utils.EncoderDecoderCachewith python objects.
- onnx_diagnostic.torch_export_patches.onnx_export_serialization.flatten_with_keys_mamba_cache(cache: MambaCache) Tuple[List[Tuple[KeyEntry, Any]], Any][source][source]¶
Serializes a
transformers.cache_utils.MambaCachewith python objects.
- onnx_diagnostic.torch_export_patches.onnx_export_serialization.flatten_with_keys_sliding_window_cache(cache: SlidingWindowCache) Tuple[List[Tuple[KeyEntry, Any]], Any][source][source]¶
Serializes a
transformers.cache_utils.SlidingWindowCachewith python objects.
- onnx_diagnostic.torch_export_patches.onnx_export_serialization.register_cache_serialization(verbose: int = 0) Dict[str, bool][source][source]¶
Registers many classes with
register_class_serialization(). Returns information needed to undo the registration.
- onnx_diagnostic.torch_export_patches.onnx_export_serialization.register_class_serialization(cls, f_flatten: Callable, f_unflatten: Callable, f_flatten_with_keys: Callable, f_check: Callable | None = None, verbose: int = 0) bool[source][source]¶
Registers a class. It can be undone with
unregister().- Parameters:
cls – class to register
f_flatten – see
torch.utils._pytree.register_pytree_nodef_unflatten – see
torch.utils._pytree.register_pytree_nodef_flatten_with_keys – see
torch.utils._pytree.register_pytree_nodef_check – called to check the registration was successful
verbose – verbosity
- Returns:
registered or not
- onnx_diagnostic.torch_export_patches.onnx_export_serialization.serialization_functions(verbose: int = 0) Dict[str, Callable | int][source][source]¶
Returns the list of serialization functions.
- onnx_diagnostic.torch_export_patches.onnx_export_serialization.unflatten_base_model_output(values: List[Any], context: Any, output_type=None) BaseModelOutput[source][source]¶
Restores a
transformers.modeling_outputs.BaseModelOutputfrom python objects.
- onnx_diagnostic.torch_export_patches.onnx_export_serialization.unflatten_dynamic_cache(values: List[Any], context: Any, output_type=None) DynamicCache[source][source]¶
Restores a
transformers.cache_utils.DynamicCachefrom python objects.
- onnx_diagnostic.torch_export_patches.onnx_export_serialization.unflatten_encoder_decoder_cache(values: List[Any], context: Any, output_type=None) EncoderDecoderCache[source][source]¶
Restores a
transformers.cache_utils.EncoderDecoderCachefrom python objects.
- onnx_diagnostic.torch_export_patches.onnx_export_serialization.unflatten_mamba_cache(values: List[Any], context: Any, output_type=None) MambaCache[source][source]¶
Restores a
transformers.cache_utils.MambaCachefrom python objects.
- onnx_diagnostic.torch_export_patches.onnx_export_serialization.unflatten_sliding_window_cache(values: List[Any], context: Any, output_type=None) SlidingWindowCache[source][source]¶
Restores a
transformers.cache_utils.SlidingWindowCachefrom python objects.