Skip to content

Commit

Permalink
tool: Opset coverage notebook (#2831)
Browse files Browse the repository at this point in the history
Signed-off-by: Naren Dasan <naren@narendasan.com>
Signed-off-by: Naren Dasan <narens@nvidia.com>
  • Loading branch information
narendasan authored and laikhtewari committed May 24, 2024
1 parent 6f1b76d commit 4a7fcf7
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,8 @@ bazel-tensorrt
bazel-project
build/
wheelhouse/
*_status.json
tests/py/dynamo/models/*.ts
tests/py/dynamo/models/*.ep
*.deb
*.tar.xz
9 changes: 9 additions & 0 deletions py/torch_tensorrt/dynamo/tools/opset_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,15 @@ def opset_coverage(
)


def get_coverage_status(opset: List[Tuple[str, str]], name: str) -> OpsetCoverage:
coverage = opset_coverage(opset)
return coverage


ATEN_COVERAGE = get_coverage_status(ATEN_OPS, "ATen")
PRIMS_COVERAGE = get_coverage_status(PRIM_OPS, "prim")
PY_OVERLOAD_COVERAGE = get_coverage_status(OVERLOADED_PY_OPS, "py_overload")

if __name__ == "__main__":

def find_coverage_status(opset: List[Tuple[str, str]], name: str) -> None:
Expand Down
92 changes: 92 additions & 0 deletions tools/opset_coverage.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import torch_tensorrt\n",
"from torch_tensorrt.dynamo.tools.opset_coverage import ATEN_COVERAGE, PRIMS_COVERAGE, PY_OVERLOAD_COVERAGE, SupportStatus, OpsetCoverage"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"unsupported_ops = {}\n",
"backwards_ops = {}\n",
"\n",
"for target, info in ATEN_COVERAGE.support_status.items():\n",
" if info[\"status\"] == \"FALLBACK\":\n",
" if \"backward\" not in target:\n",
" unsupported_ops.update({target : info[\"schema\"]})\n",
" else:\n",
" backwards_ops.update({target : info[\"schema\"]})\n",
"\n",
"print(\"Unsupported Ops:\")\n",
"for _, schema in unsupported_ops.items():\n",
" print(schema)\n",
"\n",
"print(\"\\nBackwards Ops:\")\n",
"for _, schema in backwards_ops.items():\n",
" print(schema)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"unsupported_ops = {}\n",
"backwards_ops = {}\n",
"\n",
"for target, info in PRIMS_COVERAGE.support_status.items():\n",
" if info[\"status\"] == \"FALLBACK\":\n",
" if \"backward\" not in target:\n",
" unsupported_ops.update({target : info[\"schema\"]})\n",
" else:\n",
" backwards_ops.update({target : info[\"schema\"]})\n",
"\n",
"print(\"Unsupported Ops:\")\n",
"for _, schema in unsupported_ops.items():\n",
" print(schema)\n",
"\n",
"print(\"\\nBackwards Ops:\")\n",
"for _, schema in backwards_ops.items():\n",
" print(schema)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "torch230cu121py311",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 4a7fcf7

Please sign in to comment.