PaddlePaddle/PaddleOCR · error · ValueError
Invalid input name {repr(name)} found in `dynamic_shape_inpu
Error message
Invalid input name {repr(name)} found in `dynamic_shape_input_data` What it means
During TRT engine building, dynamic_shape_input_data optionally provides real calibration/shape data per input. Its keys are validated against predictor.get_input_names(); a key that matches no model input raises this ValueError. It fires after the dynamic_shapes checks, and guards against feeding sample data to a nonexistent tensor, which would silently be ignored or crash the engine build.
Source
Thrown at tools/infer/utility.py:482
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(
opt_shape
)
max_arr = np.array(dynamic_shape_input_data[name][2], dtype=dtype).reshape(View on GitHub (pinned to 2661c7c0ef)
Solutions
- Make the keys of trt_dynamic_shapes_input_data (or the function argument) exactly match predictor.get_input_names()
- Remove stale input-data entries entirely if calibration data is not required
- Regenerate the config from the model's own inference.yml
Example fix
# before
trt_dynamic_shapes_input_data: {x: [[[...]]]} # input actually 'images'
# after
trt_dynamic_shapes_input_data:
images: [[[1,3,48,640]]] Defensive patterns
Strategy: validation
Validate before calling
input_names = set(predictor.get_input_names())
assert set(dynamic_shape_input_data) <= input_names, \
f'dynamic_shape_input_data keys must be actual inputs, got extra: {set(dynamic_shape_input_data) - input_names}' Try / catch
try:
_convert_trt(dynamic_shapes, model_file, params_file, dynamic_shape_input_data=..., ...)
except ValueError as e:
if 'dynamic_shape_input_data' in str(e):
dynamic_shape_input_data = {k: v for k, v in dynamic_shape_input_data.items() if k in input_names}
_convert_trt(..., dynamic_shape_input_data=dynamic_shape_input_data, ...)
raise Prevention
- Keep input-data configs in the same file as dynamic_shapes so they are updated together
- Prefer omitting calibration data over guessing tensor names
When it happens
Trigger: Passing dynamic_shape_input_data={'x': [...]} when the model input is named differently ('images', 'input'); reusing the input-data section of an inference.yml with another model.
Common situations: Same root cause as the dynamic_shapes mismatches: yml copied between det/rec/e2e models whose tensor names differ, or renamed inputs across export versions.
Related errors
- Invalid input name {repr(name)} found in `dynamic_shapes`
- Input name {repr(name)} not found in `dynamic_shapes`
- 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/51d7ff19204e791e.
Report an issue: GitHub.