From 9c298ea29332b2ada258f08d6169ee3054175daa Mon Sep 17 00:00:00 2001 From: BBuf <1182563586@qq.com> Date: Wed, 23 Jun 2021 09:20:55 +0800 Subject: [PATCH] unset useless code --- oneflow_onnx/oneflow2onnx/handlers/array.py | 1 - oneflow_onnx/oneflow2onnx/util.py | 11 +++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/oneflow_onnx/oneflow2onnx/handlers/array.py b/oneflow_onnx/oneflow2onnx/handlers/array.py index 1a44d51..5d92e9d 100644 --- a/oneflow_onnx/oneflow2onnx/handlers/array.py +++ b/oneflow_onnx/oneflow2onnx/handlers/array.py @@ -28,7 +28,6 @@ import numpy as np from onnx import numpy_helper from onnx import onnx_pb from onnx.onnx_pb import TensorProto -import onnx import oneflow import oneflow_onnx diff --git a/oneflow_onnx/oneflow2onnx/util.py b/oneflow_onnx/oneflow2onnx/util.py index 950f41b..8eab17f 100644 --- a/oneflow_onnx/oneflow2onnx/util.py +++ b/oneflow_onnx/oneflow2onnx/util.py @@ -34,10 +34,9 @@ def run_onnx(onnx_model_path, ort_optimize=True): assert len(sess.get_inputs()) <= 1 ipt_dict = OrderedDict() for ipt in sess.get_inputs(): - # ipt_data = np.random.uniform(low=-10, high=10, size=ipt.shape).astype( - # np.float32 - # ) - ipt_data = (np.random.randint(0, 255, size=ipt.shape).astype(np.float32) - 128.0 ) / 128.0 + ipt_data = np.random.uniform(low=-10, high=10, size=ipt.shape).astype( + np.float32 + ) ipt_dict[ipt.name] = ipt_data onnx_res = sess.run([], ipt_dict)[0] @@ -93,8 +92,8 @@ def compare_result(a, b, print_outlier=False): a = a.flatten() b = b.flatten() for i in range(len(a)): - # if np.abs(a[i] - b[i]) > atol + rtol * np.abs(b[i]): - print("a[{}]={}, b[{}]={}".format(i, a[i], i, b[i])) + if np.abs(a[i] - b[i]) > atol + rtol * np.abs(b[i]): + print("a[{}]={}, b[{}]={}".format(i, a[i], i, b[i])) assert np.allclose(a, b, rtol=rtol, atol=atol) -- GitLab