Skip to content

Add model input size to nvinfer engine name #1022

@bwsw

Description

@bwsw

When you experiment with different input sizes you want keep engines for them instead of being replaced with the engines generated when the model is built with a new input size.

@staticmethod
def parse_model_engine_file(model_engine_file: str) -> Optional[Dict]:
"""Try to parse ``model-engine-file`` according to default Deepstream
engine naming scheme."""
result = re.match(
r'(?P<model_file>.*)'
r'_b(?P<batch_size>\d+)'
r'_gpu(?P<gpu_id>\d+)'
r'_(?P<precision>fp32|fp16|int8)\.engine',
model_engine_file,
)
if not result:
return None
return {
'model_file': result['model_file'],
'batch_size': int(result['batch_size']),
'gpu_id': int(result['gpu_id']),
'precision': ModelPrecision[result['precision'].upper()],
}
@staticmethod
def generate_model_engine_file(
model_file: Optional[str],
batch_size: int,
device_id: str,
precision: ModelPrecision,
) -> str:
"""Generate ``model-engine-file`` according to default Deepstream
engine naming scheme."""
prefix = model_file if model_file else 'model'
return f'{prefix}_b{batch_size}_{device_id}_{precision.name.lower()}.engine'

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions