-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
复现代码
import tempfile
import oneflow as flow
from oneflow_onnx.oneflow2onnx.util import convert_to_onnx_and_check
from flowvision.models.face_recognition import iresnet50
model = iresnet50().to("cuda")
class ModelGraph(flow.nn.Graph):
def __init__(self, model):
super().__init__()
self.config.allow_fuse_add_to_output(True)
self.backbone = model
def build(self, x):
x = x.to("cuda")
out = self.backbone(x)
return out
model.eval()
model_graph = ModelGraph(model)
model_graph._compile(flow.randn(1, 3, 112, 112))
with tempfile.TemporaryDirectory() as tmpdirname:
flow.save(model.state_dict(), tmpdirname)
convert_to_onnx_and_check(
model_graph, flow_weight_dir=tmpdirname, onnx_model_path="./", print_outlier=True)报错
File ~/miniconda/lib/python3.9/site-packages/oneflow_onnx/oneflow2onnx/util.py:102, in compare_result(a, b, rtol, atol, print_outlier)
100 if np.abs(a[i] - b[i]) > atol + rtol * np.abs(b[i]):
101 print("a[{}]={}, b[{}]={}".format(i, a[i], i, b[i]))
--> 102 assert np.allclose(a, b, rtol=rtol, atol=atol)
AssertionError:
但是 self.config.allow_fuse_add_to_output(True) 这一行注释掉就可以成功转换。
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels