Skip to content
Merged
Prev Previous commit
Next Next commit
disable check_model on Windows
  • Loading branch information
xadupre committed Nov 12, 2023
commit b3dd245d817998c425a8525fc3ce1390d4292002
5 changes: 4 additions & 1 deletion onnx_array_api/light_api/model.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from typing import Any, Dict, List, Optional, Union
from enum import IntEnum
import numpy as np
Expand Down Expand Up @@ -396,5 +397,7 @@ def to_onnx(self) -> GRAPH_PROTO:
# If no opsets, it a subgraph, not a model.
return graph
model = make_model(graph, opset_imports=opsets)
check_model(model)
if sys.platform != "win32":
# check_model fails sometimes on Windows
check_model(model)
return model
20 changes: 11 additions & 9 deletions onnx_array_api/npx/npx_graph_builder.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from inspect import Parameter, signature
from typing import Any, Callable, Dict, List, Optional, Tuple, Union

import numpy as np
from onnx import (
IR_VERSION,
Expand Down Expand Up @@ -476,14 +476,16 @@ def _make_onnx(self):
functions=list(f[0] for f in self.functions_.values()),
ir_version=self.ir_version,
)
try:
check_model(model)
except ValidationError as e:
if "Field 'shape' of 'type' is required but missing" in str(e):
# checker does like undefined shape
pass
else:
raise RuntimeError(f"Model is not valid\n{model}") from e
if sys.platform != "win32":
# check_model fails sometimes on Windows
try:
check_model(model)
except ValidationError as e:
if "Field 'shape' of 'type' is required but missing" in str(e):
# checker does like undefined shape
pass
else:
raise RuntimeError(f"Model is not valid\n{model}") from e
has_undefined = 0 in set(
o.type.tensor_type.elem_type for o in model.graph.output
)
Expand Down