Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ONNX] Introduce Input/Ouptut adapter; Switch to 'DynamoExporter' #98421

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b331513
[ONNX] Introduce Input/Ouptut formatter; Switch to 'DynamoExporter'
BowenBao Apr 5, 2023
76916fc
documentations and small tweaks on "[ONNX] Introduce Input/Ouptut for…
BowenBao Apr 5, 2023
9ea006c
a few more comments and proofreading on "[ONNX] Introduce Input/Ouptu…
BowenBao Apr 6, 2023
341b184
fix public interface CI; More docstrings on "[ONNX] Introduce Input/O…
BowenBao Apr 6, 2023
8f118af
remove debug code change on "[ONNX] Introduce Input/Ouptut formatter;…
BowenBao Apr 6, 2023
ef5242a
update doc on "[ONNX] Introduce Input/Ouptut formatter; Switch to 'Dy…
BowenBao Apr 6, 2023
5f4c2a4
Update on "[ONNX] Introduce Input/Ouptut formatter; Switch to 'Dynamo…
BowenBao Apr 6, 2023
4d7df4a
Update on "[ONNX] Introduce Input/Ouptut formatter; Switch to 'Dynamo…
BowenBao Apr 6, 2023
0ae4cb2
Resolve huge conflict after rebase on "[ONNX] Introduce Input/Ouptut …
BowenBao Apr 10, 2023
1584922
adjust public api on "[ONNX] Introduce Input/Ouptut formatter; Switch…
BowenBao Apr 11, 2023
82f1349
Update on "[ONNX] Introduce Input/Ouptut formatter; Switch to 'Dynamo…
BowenBao Apr 11, 2023
a7846c0
fix CI docs and onnx test on "[ONNX] Introduce Input/Ouptut formatter…
BowenBao Apr 12, 2023
008947a
Update on "[ONNX] Introduce Input/Ouptut formatter; Switch to 'Dynamo…
BowenBao Apr 12, 2023
d4dc318
Address feedbacks with small fixes on "[ONNX] Introduce Input/Ouptut …
BowenBao Apr 14, 2023
e5ae056
Rename from format to adapt on "[ONNX] Introduce Input/Ouptut formatt…
BowenBao Apr 14, 2023
500a752
Update test skips; add a few missed 'adapt' renaming on "[ONNX] Intro…
BowenBao Apr 14, 2023
73fd8dc
rebase + final feedbacks on "[ONNX] Introduce Input/Ouptut adapter; S…
BowenBao Apr 14, 2023
daf60af
Update on "[ONNX] Introduce Input/Ouptut adapter; Switch to 'DynamoEx…
BowenBao Apr 14, 2023
73a01d0
Update on "[ONNX] Introduce Input/Ouptut adapter; Switch to 'DynamoEx…
BowenBao Apr 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/onnx.rst
Original file line number Diff line number Diff line change
Expand Up @@ -736,4 +736,4 @@ Preview: torch.onnx TorchDynamo Exporter

torch.onnx.ExportOptions
torch.onnx.ExportOutput
torch.onnx.ExportOutputSerializer
torch.onnx.ExportOutputSerializer
5 changes: 4 additions & 1 deletion test/onnx/dynamo/test_exporter_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import torch
from beartype import roar
from torch.onnx import dynamo_export, ExportOptions, ExportOutput
from torch.onnx._internal import exporter
from torch.onnx._internal.exporter import (
_DEFAULT_OPSET_VERSION,
ExportOutputSerializer,
Expand Down Expand Up @@ -135,7 +136,9 @@ def serialize(
def test_raise_on_invalid_save_argument_type(self):
with self.assertRaises(roar.BeartypeException):
ExportOutput(torch.nn.Linear(2, 3)) # type: ignore[arg-type]
export_output = ExportOutput(onnx.ModelProto())
export_output = ExportOutput(
onnx.ModelProto(), exporter.InputFormatter(), exporter.OutputFormatter()
)
with self.assertRaises(roar.BeartypeException):
export_output.save(None) # type: ignore[arg-type]
export_output.model_proto
Expand Down
36 changes: 34 additions & 2 deletions test/onnx/pytorch_test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import random
import sys
import unittest
from typing import Optional
from typing import Mapping, Optional, Type

import numpy as np
import packaging.version

import torch
from torch.autograd import function
from torch.onnx._internal import diagnostics
from torch.onnx._internal import diagnostics, exporter
from torch.testing._internal import common_utils

pytorch_test_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
Expand Down Expand Up @@ -206,6 +206,38 @@ def wrapper(self, *args, **kwargs):
return skip_dec


def skip_fx_exporters(
exporter_cls_and_reason: Mapping[Optional[Type[exporter.Exporter]], str]
):
"""Skip exporting test for selected FX exporters.

Args:
exporter_cls_and_reason: Mapping from FX exporter class to skip the test to the
reason for skipping.

Returns:
A decorator for skipping exporting test for FX exporters.
"""

def skip_dec(func):
@functools.wraps(func)
def wrapper(self, *args, **kwargs):
for exporter_cls, reason in exporter_cls_and_reason.items():
if exporter_cls == self.exporter_cls:
exporter_name = (
exporter_cls.__name__
if exporter_cls is not None
else "dynamo_export"
)
raise unittest.SkipTest(
f"Skip verify test for '{exporter_name}'. {reason}"
)

return wrapper

return skip_dec


# skips tests for opset_versions listed in unsupported_opset_versions.
# if the caffe2 test cannot be run for a specific version, add this wrapper
# (for example, an op was modified but the change is not supported in caffe2)
Expand Down