It is very common to have to generate dummy inputs to perform a task (tracing, exporting a model to some backend, testing model outputs, etc). The goal of DummyInputGenerator classes is to make this generation easy and re-usable.
Generates dummy inputs for the supported input names, in the requested framework.
( inputs dim: int )
Concatenates inputs together.
( shape: typing.List[int] value: typing.Union[int, float] = 1 dtype: typing.Optional[typing.Any] = None framework: str = 'pt' )
Generates a constant tensor.
( input_name: str framework: str = 'pt' int_dtype: str = 'int64' float_dtype: str = 'fp32' )
Generates the dummy input matching input_name
for the requested framework.
( input_ dim: int desired_length: typing.Optional[int] = None padding_length: typing.Optional[int] = None value: typing.Union[int, float] = 1 dtype: typing.Optional[typing.Any] = None )
Parameters
int
) —
The dimension along which to pad. Optional[int]
, defaults to None
) —
The desired length along the dimension after padding. Optional[int]
, defaults to None
) —
The length to pad along the dimension. Union[int, float]
, defaults to 1) —
The value to use for padding. Optional[Any]
, defaults to None
) —
The dtype of the padding. Pads an input either to the desired length, or by a padding length.
( shape: typing.List[int] min_value: float = 0 max_value: float = 1 framework: str = 'pt' dtype: str = 'fp32' )
Parameters
List[int]
) —
The shape of the random tensor. float
, defaults to 0) —
The minimum value allowed. float
, defaults to 1) —
The maximum value allowed. str
, defaults to "pt"
) —
The requested framework. str
, defaults to "fp32"
) —
The dtype of the generated float tensor. Could be “fp32”, “fp16”, “bf16”. Generates a tensor of random floats in the [min_value, max_value) range.
( shape: typing.List[int] max_value: int min_value: int = 0 framework: str = 'pt' dtype: str = 'int64' )
Parameters
List[int]
) —
The shape of the random tensor. int
) —
The maximum value allowed. int
, defaults to 0) —
The minimum value allowed. str
, defaults to "pt"
) —
The requested framework. str
, defaults to "int64"
) —
The dtype of the generated integer tensor. Could be “int64”, “int32”, “int8”. Generates a tensor of random integers in the [min_value, max_value) range.
( shape: typing.List[int] padding_side: str = 'right' framework: str = 'pt' dtype: str = 'int64' )
Parameters
List[int]
) —
The shape of the random tensor. str
, defaults to “right”) —
The side on which the padding is applied. str
, defaults to "pt"
) —
The requested framework. str
, defaults to "int64"
) —
The dtype of the generated integer tensor. Could be “int64”, “int32”, “int8”. Generates a mask tensor either right or left padded.
( input_name: str ) → bool
Checks whether the DummyInputGenerator
supports the generation of the requested input.
( task: str normalized_config: NormalizedTextConfig batch_size: int = 2 sequence_length: int = 16 num_choices: int = 4 random_batch_size_range: typing.Union[typing.Tuple[int, int], NoneType] = None random_sequence_length_range: typing.Union[typing.Tuple[int, int], NoneType] = None random_num_choices_range: typing.Union[typing.Tuple[int, int], NoneType] = None padding_side: str = 'right' **kwargs )
Generates dummy encoder text inputs.
( task: str normalized_config: NormalizedTextConfig batch_size: int = 2 sequence_length: int = 16 num_choices: int = 4 random_batch_size_range: typing.Union[typing.Tuple[int, int], NoneType] = None random_sequence_length_range: typing.Union[typing.Tuple[int, int], NoneType] = None random_num_choices_range: typing.Union[typing.Tuple[int, int], NoneType] = None padding_side: str = 'right' **kwargs )
Generates dummy decoder text inputs.
( task: str normalized_config: NormalizedTextConfig batch_size: int = 2 sequence_length: int = 16 random_batch_size_range: typing.Union[typing.Tuple[int, int], NoneType] = None random_sequence_length_range: typing.Union[typing.Tuple[int, int], NoneType] = None **kwargs )
Generates dummy past_key_values inputs.
( task: str normalized_config: typing.Union[optimum.utils.normalized_config.NormalizedSeq2SeqConfig, optimum.utils.normalized_config.NormalizedEncoderDecoderConfig] batch_size: int = 2 sequence_length: int = 16 encoder_sequence_length: typing.Optional[int] = None random_batch_size_range: typing.Union[typing.Tuple[int, int], NoneType] = None random_sequence_length_range: typing.Union[typing.Tuple[int, int], NoneType] = None **kwargs )
Generates dummy past_key_values inputs for seq2seq architectures.
( task: str normalized_config: NormalizedConfig batch_size: int = 2 sequence_length: int = 16 random_batch_size_range: typing.Union[typing.Tuple[int, int], NoneType] = None random_sequence_length_range: typing.Union[typing.Tuple[int, int], NoneType] = None **kwargs )
Generates dummy bbox inputs.
( task: str normalized_config: NormalizedVisionConfig batch_size: int = 2 num_channels: int = 3 width: int = 64 height: int = 64 **kwargs )
Generates dummy vision inputs.
( task: str normalized_config: NormalizedConfig batch_size: int = 2 feature_size: int = 80 nb_max_frames: int = 3000 audio_sequence_length: int = 16000 **kwargs )