in optimum/utils/input_generators.py [0:0]
def generate(self, input_name: str, framework: str = "pt", int_dtype: str = "int64", float_dtype: str = "fp32"):
decoder_hidden_size = self.normalized_config.DECODER_NORMALIZED_CONFIG_CLASS.hidden_size
decoder_num_attention_heads = self.normalized_config.DECODER_NORMALIZED_CONFIG_CLASS.num_attention_heads
decoder_shape = (
self.batch_size,
decoder_num_attention_heads,
self.sequence_length,
decoder_hidden_size // decoder_num_attention_heads,
)
if not self.use_cross_attention:
return [
(
self.random_float_tensor(decoder_shape, framework=framework, dtype=float_dtype),
self.random_float_tensor(decoder_shape, framework=framework, dtype=float_dtype),
)
for _ in range(self.num_layers)
]
else:
encoder_hidden_size = decoder_hidden_size
encoder_num_attention_heads = decoder_num_attention_heads
encoder_shape = (
self.batch_size,
encoder_num_attention_heads,
self.encoder_sequence_length,
encoder_hidden_size // encoder_num_attention_heads,
)
return [
(
self.random_float_tensor(decoder_shape, framework=framework, dtype=float_dtype),
self.random_float_tensor(decoder_shape, framework=framework, dtype=float_dtype),
self.random_float_tensor(encoder_shape, framework=framework, dtype=float_dtype),
self.random_float_tensor(encoder_shape, framework=framework, dtype=float_dtype),
)
for _ in range(self.num_layers)
]