Skip to content

Commit a2d4e4e

Browse files
committed
docu
1 parent a41b3d1 commit a2d4e4e

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

_doc/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ See :func:`onnx_diagnostic.helpers.string_type`.
117117
onnx_dtype_name
118118
+++++++++++++++
119119

120-
See :func:`onnx_diagnostic.helpers.onnx_dtype_name`.
120+
See :func:`onnx_diagnostic.helpers.onnx_helper.onnx_dtype_name`.
121121

122122
.. code-block:: python
123123
124124
import onnx
125-
from onnx_diagnostic.helpers import onnx_dtype_name
125+
from onnx_diagnostic.helpers.onnx_helper import onnx_dtype_name
126126
127127
itype = onnx.TensorProto.BFLOAT16
128128
print(onnx_dtype_name(itype))

onnx_diagnostic/helpers/onnx_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ def tensor_statistics(tensor: Union[np.ndarray, TensorProto]) -> Dict[str, Union
834834
835835
import pprint
836836
import numpy as np
837-
from onnx_diagnostic.helper.onnx_helper import tensor_statistics
837+
from onnx_diagnostic.helpers.onnx_helper import tensor_statistics
838838
839839
t = np.random.rand(40, 50).astype(np.float16)
840840
pprint.pprint(tensor_statistics(t))

onnx_diagnostic/helpers/torch_helper.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ def onnx_dtype_to_torch_dtype(itype: int) -> "torch.dtype": # noqa: F821
102102
:param to: onnx dtype
103103
:return: torch dtype
104104
"""
105-
import torch
106-
107105
if itype == onnx.TensorProto.FLOAT:
108106
return torch.float32
109107
if itype == onnx.TensorProto.FLOAT16:
@@ -314,6 +312,9 @@ def steal_forward(
314312
315313
import torch
316314
from onnx_diagnostic.helpers.torch_helper import steal_forward
315+
from onnx_diagnostic.helpers.mini_onnx_builder import (
316+
create_input_tensors_from_onnx_model,
317+
)
317318
318319
class SubModel(torch.nn.Module):
319320
def forward(self, x):
@@ -363,7 +364,11 @@ def forward(self, x, y):
363364
for idx, m in model.named_modules():
364365
level = str(idx).split(".")
365366
ll = len(level)
366-
_, start_line = inspect.getsourcelines(m.forward)
367+
try:
368+
_, start_line = inspect.getsourcelines(m.forward)
369+
except OSError:
370+
# The code is not available.
371+
start_line = 0
367372
name = f"{idx}-{m.__class__.__name__}-{start_line}"
368373
models.append((f"{' ' * ll}{name}", m))
369374
model = models

onnx_diagnostic/torch_models/test_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ def call_torch_export_export(
780780

781781
disc = max_diff(data["expected"], expected)
782782
for k, v in disc.items():
783-
summary[f"disc_exported_{k}"] = v
783+
summary[f"disc_exported_{k}"] = str(v)
784784
if verbose:
785785
print("[validate_model] done (exported run)")
786786
print(f"[validate_model] exported discrepancies={string_diff(disc)}")

0 commit comments

Comments
 (0)