{"record":{"id":"afd6fb9ce975d4f5","repo":"PaddlePaddle/PaddleOCR","slug":"invalid-input-name-repr-name-found-in-dynamic","errorCode":null,"errorMessage":"Invalid input name {repr(name)} found in `dynamic_shapes`","messagePattern":"Invalid input name (.+?) found in `dynamic_shapes`","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/infer/utility.py","lineNumber":474,"sourceCode":"            ), f\"The `{type(trt_config)}` don't have the attribute `{attr_name}`!\"\n            setattr(trt_config, attr_name, trt_cfg_setting[attr_name])\n\n    def _get_predictor(model_file, params_file):\n        # HACK\n        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","sourceCodeStart":456,"sourceCodeEnd":492,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/tools/infer/utility.py#L456-L492","documentation":"During _convert_trt (building TensorRT engines from the Paddle model), the code cross-checks the keys of the dynamic_shapes dict against predictor.get_input_names(). This ValueError fires when dynamic_shapes contains an input name the model does not have — a stale or hand-edited shape spec left over from a different model. The check runs before any engine building, so no work is wasted.","triggerScenarios":"Passing dynamic_shapes={'x': ...} to a model whose input is named 'images' (or vice versa); reusing an inference.yml from one architecture with another model.","commonSituations":"Copying TRT config between det and rec models whose input tensor names differ; older/newer exports renaming inputs; hand-written shape dictionaries using guessed names.","solutions":["Inspect actual input names: print(predictor.get_input_names()) or use paddle_infer to list them","Fix the dynamic_shapes keys (usually in inference.yml Hpi.backend_configs.paddle_infer.trt_dynamic_shapes) to exactly match the model inputs","Re-download the matching model package so yml and model agree"],"exampleFix":"# inference.yml — before\ntrt_dynamic_shapes:\n  x: [[1,3,48,320],[1,3,48,640],[1,3,48,1280]]  # model input is 'images'\n\n# after\ntrt_dynamic_shapes:\n  images: [[1,3,48,320],[1,3,48,640],[1,3,48,1280]]","handlingStrategy":"validation","validationCode":"predictor = build_raw_predictor(model)  # or read yml + model once\ninput_names = set(predictor.get_input_names())\nassert set(dynamic_shapes) <= input_names, f'dynamic_shapes keys not in {input_names}'","typeGuard":null,"tryCatchPattern":"try:\n    _convert_trt(dynamic_shapes, model_file, params_file, ...)\nexcept ValueError as e:\n    if 'Invalid input name' in str(e):\n        raise SystemExit('dynamic_shapes keys must equal predictor.get_input_names()')\n    raise","preventionTips":["Generate TRT shape configs from the live model's get_input_names() rather than hand-copying them","Never reuse an inference.yml across different architectures"],"tags":["tensorrt","input-names","dynamic-shapes","config-mismatch"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}