{"id":15934911,"url":"https://github.com/pinto0309/sor4onnx","last_synced_at":"2025-06-20T15:34:40.118Z","repository":{"id":60034658,"uuid":"488656161","full_name":"PINTO0309/sor4onnx","owner":"PINTO0309","description":"Simple OP Renamer for ONNX.","archived":false,"fork":false,"pushed_at":"2024-05-28T23:38:21.000Z","size":645,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-29T08:21:23.271Z","etag":null,"topics":["cli","model-converter","models","onnx","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PINTO0309.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-04T16:06:12.000Z","updated_at":"2024-05-28T23:37:20.000Z","dependencies_parsed_at":"2024-05-29T02:26:11.747Z","dependency_job_id":"55a05a80-18fd-4e62-afb1-3cf9127a84d2","html_url":"https://github.com/PINTO0309/sor4onnx","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PINTO0309%2Fsor4onnx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PINTO0309%2Fsor4onnx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PINTO0309%2Fsor4onnx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PINTO0309%2Fsor4onnx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PINTO0309","download_url":"https://codeload.github.com/PINTO0309/sor4onnx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245355605,"owners_count":20601760,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","model-converter","models","onnx","python"],"created_at":"2024-10-07T03:21:38.894Z","updated_at":"2025-03-24T21:32:36.587Z","avatar_url":"https://github.com/PINTO0309.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sor4onnx\n**S**imple **O**P **R**enamer for **ONNX**.\n\nhttps://github.com/PINTO0309/simple-onnx-processing-tools\n\n[![Downloads](https://static.pepy.tech/personalized-badge/sor4onnx?period=total\u0026units=none\u0026left_color=grey\u0026right_color=brightgreen\u0026left_text=Downloads)](https://pepy.tech/project/sor4onnx) ![GitHub](https://img.shields.io/github/license/PINTO0309/sor4onnx?color=2BAF2B) [![PyPI](https://img.shields.io/pypi/v/sor4onnx?color=2BAF2B)](https://pypi.org/project/sor4onnx/) [![CodeQL](https://github.com/PINTO0309/sor4onnx/workflows/CodeQL/badge.svg)](https://github.com/PINTO0309/sor4onnx/actions?query=workflow%3ACodeQL)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/33194443/170158065-9a81787b-86ad-4971-857d-5f4185dfcf0b.png\" /\u003e\n\u003c/p\u003e\n\n# Key concept\n\n\n- [x] Performs a partial match search on the specified string and replaces all input and output names with the specified string.\n\n## 1. Setup\n### 1-1. HostPC\n```bash\n### option\n$ echo export PATH=\"~/.local/bin:$PATH\" \u003e\u003e ~/.bashrc \\\n\u0026\u0026 source ~/.bashrc\n\n### run\n$ pip install -U onnx \\\n\u0026\u0026 python3 -m pip install -U onnx_graphsurgeon --index-url https://pypi.ngc.nvidia.com \\\n\u0026\u0026 pip install -U sor4onnx\n```\n### 1-2. Docker\nhttps://github.com/PINTO0309/simple-onnx-processing-tools#docker\n\n## 2. CLI Usage\n```\n$ sor4onnx -h\n\nusage:\n  sor4onnx [-h]\n  -if INPUT_ONNX_FILE_PATH\n  -on OLD_NEW OLD_NEW\n  -of OUTPUT_ONNX_FILE_PATH\n  [-m {full,inputs,outputs}]\n  [-sm {exact_match,partial_match,prefix_match,suffix_match}]\n  [-n]\n\noptional arguments:\n  -h, --help\n      show this help message and exit.\n\n  -if INPUT_ONNX_FILE_PATH, --input_onnx_file_path INPUT_ONNX_FILE_PATH\n      Input onnx file path.\n\n  -on OLD_NEW OLD_NEW, --old_new OLD_NEW OLD_NEW\n      All occurrences of substring old replaced by new.\n      e.g. --old_new \"onnx::\" \"\"\n\n  -of OUTPUT_ONNX_FILE_PATH, --output_onnx_file_path OUTPUT_ONNX_FILE_PATH\n      Output onnx file path.\n\n  -m {full,inputs,outputs}, --mode {full,inputs,outputs}\n      Specifies the type of node to be replaced.\n      full or inputs or outputs.\n      full: Rename all nodes.\n      inputs: Rename only the input node.\n      outputs: Rename only the output node.\n      Default: full\n\n  -sm {exact_match,partial_match,prefix_match,suffix_match}, --search_mode {exact_match,partial_match,prefix_match,suffix_match}\n      OP name search mode.\n      exact_match or partial_match or prefix_match or suffix_match.\n      exact_match: Exact match search for OP name.\n      partial_match: Partial match search for OP name.\n      prefix_match: Prefix match search for OP name.\n      suffix_match: Suffix match search for OP name.\n      Default: exact_match\n\n  -n, --non_verbose\n      Do not show all information logs. Only error logs are displayed.\n```\n\n## 3. In-script Usage\n```python\n\u003e\u003e\u003e from sor4onnx import rename\n\u003e\u003e\u003e help(rename)\n\nHelp on function rename in module sor4onnx.onnx_opname_renamer:\n\nrename(\n    old_new: List[str],\n    input_onnx_file_path: Union[str, NoneType] = '',\n    onnx_graph: Union[onnx.onnx_ml_pb2.ModelProto, NoneType] = None,\n    output_onnx_file_path: Union[str, NoneType] = '',\n    mode: Union[str, NoneType] = 'full',\n    search_mode: Union[str, NoneType] = 'exact_match',\n    non_verbose: Union[bool, NoneType] = False\n) -\u003e onnx.onnx_ml_pb2.ModelProto\n\n    Parameters\n    ----------\n    old_new: List[str]\n        All occurrences of substring old replaced by new.\n        e.g.\n        old_new = [\"onnx::\", \"\"]\n\n    input_onnx_file_path: Optional[str]\n        Input onnx file path.\n        Either input_onnx_file_path or onnx_graph must be specified.\n        Default: ''\n\n    onnx_graph: Optional[onnx.ModelProto]\n        onnx.ModelProto.\n        Either input_onnx_file_path or onnx_graph must be specified.\n        onnx_graph If specified, ignore input_onnx_file_path and process onnx_graph.\n\n    output_onnx_file_path: Optional[str]\n        Output onnx file path. If not specified, no ONNX file is output.\n        Default: ''\n\n    mode: Optional[str]\n        Specifies the type of node to be replaced.\n        full or inputs or outputs.\n        full: Rename all nodes.\n        inputs: Rename only the input node.\n        outputs: Rename only the output node.\n        Default: full\n\n    search_mode: Optional[str]\n        OP name search mode.\n        exact_match or partial_match or prefix_match or suffix_match.\n        exact_match: Exact match search for OP name.\n        partial_match: Partial match search for OP name.\n        prefix_match: Prefix match search for OP name.\n        suffix_match: Suffix match search for OP name.\n        Default: exact_match\n\n    non_verbose: Optional[bool]\n        Do not show all information logs. Only error logs are displayed.\n        Default: False\n\n    Returns\n    -------\n    renamed_graph: onnx.ModelProto\n        Renamed onnx ModelProto.\n```\n\n## 4. CLI Execution\n```bash\n$ sor4onnx \\\n--input_onnx_file_path fusionnet_180x320.onnx \\\n--old_new \"onnx::\" \"\" \\\n--mode full \\\n--search_mode prefix_match \\\n--output_onnx_file_path fusionnet_180x320_renamed.onnx\n```\n\n## 5. In-script Execution\n```python\nfrom sor4onnx import rename\n\nonnx_graph = rename(\n  old_new=[\"onnx::\", \"\"],\n  input_onnx_file_path=\"fusionnet_180x320.onnx\",\n  output_onnx_file_path=\"fusionnet_180x320_renamed.onnx\",\n  mode=\"full\",\n  search_mode=\"prefix_match\",\n)\n\n# or\n\nonnx_graph = rename(\n  old_new=[\"onnx::\", \"\"],\n  onnx_graph=graph,\n  mode=\"full\",\n  search_mode=\"prefix_match\",\n)\n```\n\n## 6. Sample\n### Before\n![image](https://user-images.githubusercontent.com/33194443/166736425-54b19eab-b025-441c-a1ce-79c075a9b26f.png)\n\n### After\n![image](https://user-images.githubusercontent.com/33194443/166736670-a784850b-bec3-4d74-95a4-dd67738ac481.png)\n\n## 7. Reference\n1. https://github.com/onnx/onnx/blob/main/docs/Operators.md\n2. https://docs.nvidia.com/deeplearning/tensorrt/onnx-graphsurgeon/docs/index.html\n3. https://github.com/NVIDIA/TensorRT/tree/main/tools/onnx-graphsurgeon\n4. https://github.com/PINTO0309/simple-onnx-processing-tools\n5. https://github.com/PINTO0309/PINTO_model_zoo\n\n## 8. Issues\nhttps://github.com/PINTO0309/simple-onnx-processing-tools/issues\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinto0309%2Fsor4onnx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpinto0309%2Fsor4onnx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinto0309%2Fsor4onnx/lists"}