PaddlePaddle/PaddleOCR · error · ValueError
Input name {repr(name)} not found in `dynamic_shapes`
Error message
Input name {repr(name)} not found in `dynamic_shapes` What it means
The inverse of the extra-key check: during TRT conversion, every actual model input must have an entry in dynamic_shapes, because TensorRT needs min/opt/max ranges for each input to build the engine. This ValueError fires when a model input has no corresponding key — e.g. a shape spec written for an older export with fewer/differently named inputs.
Source
Thrown at tools/infer/utility.py:479
config = inference.Config(str(model_file), str(params_file))
config.enable_use_gpu(100, device_id)
# NOTE: Disable oneDNN to circumvent a bug in Paddle Inference
config.disable_mkldnn()
config.disable_glog_info()
return inference.create_predictor(config)
dynamic_shape_input_data = dynamic_shape_input_data or {}
predictor = _get_predictor(pp_model_file, pp_params_file)
input_names = predictor.get_input_names()
for name in dynamic_shapes:
if name not in input_names:
raise ValueError(
f"Invalid input name {repr(name)} found in `dynamic_shapes`"
)
for name in input_names:
if name not in dynamic_shapes:
raise ValueError(f"Input name {repr(name)} not found in `dynamic_shapes`")
for name in dynamic_shape_input_data:
if name not in input_names:
raise ValueError(
f"Invalid input name {repr(name)} found in `dynamic_shape_input_data`"
)
trt_inputs = []
for name, candidate_shapes in dynamic_shapes.items():
# XXX: Currently we have no way to get the data type of the tensor
# without creating an input handle.
handle = predictor.get_input_handle(name)
dtype = _pd_dtype_to_np_dtype(handle.type())
min_shape, opt_shape, max_shape = candidate_shapes
if name in dynamic_shape_input_data:
min_arr = np.array(dynamic_shape_input_data[name][0], dtype=dtype).reshape(
min_shape
)
opt_arr = np.array(dynamic_shape_input_data[name][1], dtype=dtype).reshape(View on GitHub (pinned to 2661c7c0ef)
Solutions
- List the model's input names and ensure dynamic_shapes has a min/opt/max triple for each one
- Update inference.yml trt_dynamic_shapes to cover all inputs with correct names
- Re-download the model package that matches the inference code version
Example fix
# before — model inputs are ['images'] but yml has:
trt_dynamic_shapes: {x: [...]} # -> Input name 'images' not found in `dynamic_shapes`
# after
trt_dynamic_shapes:
images: [[1,3,48,320],[1,3,48,640],[1,3,48,1280]] Defensive patterns
Strategy: validation
Validate before calling
input_names = set(predictor.get_input_names())
missing = input_names - set(dynamic_shapes)
assert not missing, f'dynamic_shapes missing inputs: {missing} — every model input needs [min, opt, max]' Try / catch
try:
_convert_trt(dynamic_shapes, model_file, params_file, ...)
except ValueError as e:
if 'not found in `dynamic_shapes`' in str(e):
raise SystemExit('add min/opt/max shapes for every input reported by get_input_names()')
raise Prevention
- After any model re-export, re-derive TRT shape configs programmatically
- Log predictor.get_input_names() at startup to make mismatches diagnosable
When it happens
Trigger: dynamic_shapes covering only 'x' while get_input_names() returns ['x', 'conv_weight'] or ['images']; partial hand-editing of the shape config; models with multiple inputs (rare for OCR) configured for one.
Common situations: Model re-exported with an extra input; yml from a single-input model reused with a multi-input one; typos in one of several input names so only some resolve.
Related errors
- Invalid input name {repr(name)} found in `dynamic_shapes`
- Invalid input name {repr(name)} found in `dynamic_shape_inpu
- Configuration Error: 'trt_dynamic_shapes' must be defined in
- Unsupported data type: {pd_dtype}
AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14).
Data as JSON: /api/errors/b13794d834952854.
Report an issue: GitHub.