{"record":{"id":"b13794d834952854","repo":"PaddlePaddle/PaddleOCR","slug":"input-name-repr-name-not-found-in-dynamic-shap","errorCode":null,"errorMessage":"Input name {repr(name)} not found in `dynamic_shapes`","messagePattern":"Input name (.+?) not found in `dynamic_shapes`","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/infer/utility.py","lineNumber":479,"sourceCode":"        config = inference.Config(str(model_file), str(params_file))\n        config.enable_use_gpu(100, device_id)\n        # NOTE: Disable oneDNN to circumvent a bug in Paddle Inference\n        config.disable_mkldnn()\n        config.disable_glog_info()\n        return inference.create_predictor(config)\n\n    dynamic_shape_input_data = dynamic_shape_input_data or {}\n\n    predictor = _get_predictor(pp_model_file, pp_params_file)\n    input_names = predictor.get_input_names()\n    for name in dynamic_shapes:\n        if name not in input_names:\n            raise ValueError(\n                f\"Invalid input name {repr(name)} found in `dynamic_shapes`\"\n            )\n    for name in input_names:\n        if name not in dynamic_shapes:\n            raise ValueError(f\"Input name {repr(name)} not found in `dynamic_shapes`\")\n    for name in dynamic_shape_input_data:\n        if name not in input_names:\n            raise ValueError(\n                f\"Invalid input name {repr(name)} found in `dynamic_shape_input_data`\"\n            )\n\n    trt_inputs = []\n    for name, candidate_shapes in dynamic_shapes.items():\n        # XXX: Currently we have no way to get the data type of the tensor\n        # without creating an input handle.\n        handle = predictor.get_input_handle(name)\n        dtype = _pd_dtype_to_np_dtype(handle.type())\n        min_shape, opt_shape, max_shape = candidate_shapes\n        if name in dynamic_shape_input_data:\n            min_arr = np.array(dynamic_shape_input_data[name][0], dtype=dtype).reshape(\n                min_shape\n            )\n            opt_arr = np.array(dynamic_shape_input_data[name][1], dtype=dtype).reshape(","sourceCodeStart":461,"sourceCodeEnd":497,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/tools/infer/utility.py#L461-L497","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before — model inputs are ['images'] but yml has:\ntrt_dynamic_shapes: {x: [...]}  # -> Input name 'images' not found in `dynamic_shapes`\n\n# after\ntrt_dynamic_shapes:\n  images: [[1,3,48,320],[1,3,48,640],[1,3,48,1280]]","handlingStrategy":"validation","validationCode":"input_names = set(predictor.get_input_names())\nmissing = input_names - set(dynamic_shapes)\nassert not missing, f'dynamic_shapes missing inputs: {missing} — every model input needs [min, opt, max]'","typeGuard":null,"tryCatchPattern":"try:\n    _convert_trt(dynamic_shapes, model_file, params_file, ...)\nexcept ValueError as e:\n    if 'not found in `dynamic_shapes`' in str(e):\n        raise SystemExit('add min/opt/max shapes for every input reported by get_input_names()')\n    raise","preventionTips":["After any model re-export, re-derive TRT shape configs programmatically","Log predictor.get_input_names() at startup to make mismatches diagnosable"],"tags":["tensorrt","dynamic-shapes","input-names","config-mismatch"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}