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

Fix/style fixes #719

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,433 changes: 1,279 additions & 1,154 deletions onnx2tf/onnx2tf.py

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions onnx2tf/ops/Add.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import sys
import random
random.seed(0)
import numpy as np
np.random.seed(0)
import itertools
import collections
import tensorflow as tf
import onnx_graphsurgeon as gs
from onnx2tf.utils.common_functions import (
Expand All @@ -22,13 +19,9 @@
shape_unmatched_special_avoidance_workaround,
merge_two_consecutive_identical_ops_into_one,
deterring_shape_corruption_due_to_broadcast,
acquisition_of_validation_data,
onnx_tf_tensor_validation,
obtaining_an_inverted_pattern_for_brute_force_validation,
correction_process_for_accuracy_errors,
nhwc_determination_of_output_value_of_binary_input_op,
)
from typing import Any, Dict


@print_node_info
Expand Down
1 change: 0 additions & 1 deletion onnx2tf/ops/Concat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import sys
import copy
import random
random.seed(0)
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion onnx2tf/ops/DepthToSpace.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
dummy_tf_inference,
onnx_tf_tensor_validation,
)
from typing import List, Dict, Any
from typing import Any, Dict


@print_node_info
Expand Down
1 change: 0 additions & 1 deletion onnx2tf/ops/GridSample.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import sys
import copy
import random
random.seed(0)
import numpy as np
Expand Down
1 change: 0 additions & 1 deletion onnx2tf/ops/Pad.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
import copy
import random
random.seed(0)
Expand Down
3 changes: 0 additions & 3 deletions onnx2tf/ops/ScaleAndTranslate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
make_tf_node_info,
pre_process_transpose,
post_process_transpose,
make_tf_partial_model_inputs,
dummy_tf_inference,
transpose_with_flexing_deterrence,
)
from typing import Any, Dict, List
from onnx2tf.utils.logging import *
from onnx2tf.utils.enums import (
NUMPY_DTYPES_TO_TF_DTYPES,
Expand Down
2 changes: 0 additions & 2 deletions onnx2tf/utils/common_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
import io
import sys
import copy
import json
import psutil
import random
random.seed(0)
import requests
import flatbuffers
import itertools
import collections
import traceback
import subprocess
import numpy as np
np.random.seed(0)
Expand Down
14 changes: 13 additions & 1 deletion onnx2tf/utils/logging.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import traceback
from enum import Enum
from typing import Union

__all__ = ["Color", "LOG_LEVELS", "debug", "info", "warn", "error", "set_log_level", "get_log_level"]
__all__ = ["Color", "LOG_LEVELS", "debug", "info", "warn", "error", "set_log_level", "get_log_level", "error_tb", "warn_tb"]

class Color(Enum):
BLACK = '\033[30m'
Expand Down Expand Up @@ -56,9 +57,11 @@ def get_log_level():
def debug(*args):
if log_level <= LOG_LEVELS['debug']:
print(*args)

def info(*args):
if log_level <= LOG_LEVELS['info']:
print(*args)

def warn(*args, prefix=True):
if log_level <= LOG_LEVELS['warn']:
if prefix and any(args):
Expand All @@ -68,6 +71,7 @@ def warn(*args, prefix=True):
)
else:
print(*args)

def error(*args, prefix=True):
if log_level <= LOG_LEVELS['error']:
if prefix and any(args):
Expand All @@ -77,3 +81,11 @@ def error(*args, prefix=True):
)
else:
print(*args)

def warn_tb(*args, **kwargs):
warn(traceback.format_exc(), prefix=False)
warn(*args, **kwargs)

def error_tb(*args, **kwargs):
error(*args, **kwargs)
error(traceback.format_exc(), prefix=False)
1 change: 0 additions & 1 deletion test_cind/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
class Model(nn.Module):
def __init__(self):
super(Model, self).__init__()
pass

def forward(self, x_1, x_2):
x_1[x_1==1] = 0
Expand Down
Loading