Skip to content

Commit 1f7e979

Browse files
committed
unify logger name
1 parent 9c974de commit 1f7e979

37 files changed

+246
-255
lines changed

tests/backend_test_base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def setUp(self):
3131
utils.INTERNAL_NAME = 1
3232
np.random.seed(1) # Make it reproducible.
3333

34-
self.log = logging.getLogger("tf2onnx.unitest." + str(type(self)))
34+
self.logger = logging.getLogger(self.__class__.__name__)
3535
if not self.config.is_debug_mode:
3636
# suppress log info of tensorflow so that result of test can be seen much easier
3737
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
@@ -121,15 +121,15 @@ def run_test_case(self, feed_dict, input_names_with_port, output_names_with_port
121121
os.makedirs(self.test_data_directory)
122122
model_path = os.path.join(self.test_data_directory, self._testMethodName + "_original.pb")
123123
utils.save_protobuf(model_path, sess.graph_def)
124-
self.log.debug("created file %s", model_path)
124+
self.logger.debug("created file %s", model_path)
125125

126126
graph_def = tf_optimize(input_names_with_port, output_names_with_port,
127127
sess.graph_def, constant_fold)
128128

129129
if self.config.is_debug_mode:
130130
model_path = os.path.join(self.test_data_directory, self._testMethodName + "_after_tf_optimize.pb")
131131
utils.save_protobuf(model_path, graph_def)
132-
self.log.debug("created file %s", model_path)
132+
self.logger.debug("created file %s", model_path)
133133

134134
tf.reset_default_graph()
135135
tf.import_graph_def(graph_def, name='')
@@ -158,5 +158,5 @@ def save_onnx_model(self, model_proto, feed_dict, postfix=""):
158158
model_proto, include_test_data=self.config.is_debug_mode,
159159
as_text=self.config.is_debug_mode)
160160

161-
self.log.debug("create model file: %s", target_path)
161+
self.logger.debug("create model file: %s", target_path)
162162
return target_path

tests/run_pretrained_models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
# pylint: disable=broad-except,logging-not-lazy,unused-argument,unnecessary-lambda
3535

3636
logging.basicConfig(level=logging.INFO, format=constants.LOG_FORMAT)
37-
log = logging.getLogger("tf2onnx")
37+
logger = logging.getLogger("run_pretrained")
3838

3939
TEMP_DIR = os.path.join(utils.get_temp_directory(), "run_pretrained")
4040
PERFITER = 1000
@@ -255,7 +255,7 @@ def run_test(self, name, backend="caffe2", debug=False, onnx_file=None, opset=No
255255
dtype = tf.as_dtype(t.dtype).name
256256
v = inputs[k]
257257
if dtype != v.dtype:
258-
log.warning("input dtype doesn't match tensorflow's")
258+
logger.warning("input dtype doesn't match tensorflow's")
259259
inputs[k] = np.array(v, dtype=dtype)
260260
if self.force_input_shape:
261261
for k, v in inputs.items():

tests/test_backend.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def test_maxpool(self):
188188
mp = tf.nn.max_pool(x, ksize, strides, padding=padding)
189189
_ = tf.identity(mp, name=_TFOUTPUT)
190190

191-
self.log.debug(str(p))
191+
self.logger.debug(str(p))
192192
self._run_test_case([_OUTPUT], {_INPUT: x_val})
193193

194194
@unittest.skipIf(get_test_config().is_onnxruntime_backend and get_test_config().backend_version == "0.2.1",
@@ -207,7 +207,7 @@ def test_avgpool(self):
207207
mp = tf.nn.avg_pool(x, ksize, strides, padding=padding)
208208
_ = tf.identity(mp, name=_TFOUTPUT)
209209

210-
self.log.debug(str(p))
210+
self.logger.debug(str(p))
211211
self._run_test_case([_OUTPUT], {_INPUT: x_val}, rtol=1e-06)
212212

213213
def _conv_test(self, x_val, w, strides=None, padding="VALID", dilations=None, rtol=1e-07):
@@ -1125,7 +1125,7 @@ def test_pad_const_default_val(self):
11251125
paddings = tf.constant(pad)
11261126
op = tf.pad(x, paddings, mode)
11271127
_ = tf.identity(op, name=_TFOUTPUT)
1128-
self.log.debug(str(p))
1128+
self.logger.debug(str(p))
11291129
self._run_test_case([_OUTPUT], {_INPUT: x_val})
11301130

11311131
@skip_caffe2_backend()

tf2onnx/graph.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from tf2onnx.schemas import get_schema
2525

2626

27-
log = logging.getLogger("graph")
27+
logger = logging.getLogger(__name__)
2828

2929

3030
# todo(pengwa): remove protected-access later
@@ -90,8 +90,8 @@ def attr_onnx(self):
9090
"""Return onnx valid attributes"""
9191
schema = get_schema(self.type, self.graph.opset, self.domain)
9292
if schema is None and not (self.is_const() or self.is_graph_input()):
93-
log.debug("Node %s uses non-stardard onnx op <%s, %s>, skip attribute check",
94-
self.name, self.domain, self.type)
93+
logger.debug("Node %s uses non-stardard onnx op <%s, %s>, skip attribute check",
94+
self.name, self.domain, self.type)
9595
onnx_attrs = {}
9696
for a in self._attr.values():
9797
if schema is None or schema.has_attribute(a.name):

tf2onnx/loader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from tf2onnx import utils
1717

1818

19-
log = logging.getLogger("loader")
19+
logger = logging.getLogger(__name__)
2020

2121
# pylint: disable=unused-argument
2222

@@ -48,7 +48,7 @@ def remove_redundant_inputs(frozen_graph, input_names):
4848
frozen_inputs.append(inp)
4949
deleted_inputs = list(set(input_names) - set(frozen_inputs))
5050
if deleted_inputs:
51-
log.warning("inputs [%s] is not in frozen graph, delete them", ",".join(deleted_inputs))
51+
logger.warning("inputs [%s] is not in frozen graph, delete them", ",".join(deleted_inputs))
5252
return frozen_inputs
5353

5454

tf2onnx/onnx_opset/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Licensed under the MIT license.
33

44
"""
5-
tf2onnx.tf2onnx.onnx_opset.math
5+
common
66
"""
77

88
from __future__ import division
@@ -14,7 +14,7 @@
1414
from tf2onnx import constants
1515

1616

17-
log = logging.getLogger("onnx_opset.common")
17+
logger = logging.getLogger(__name__)
1818

1919
# pylint: disable=unused-argument,missing-docstring
2020

tf2onnx/onnx_opset/controlflow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Licensed under the MIT license.
33

44
"""
5-
tf2onnx.tf2onnx.onnx_opset.controlflow
5+
controlflow
66
"""
77

88
from __future__ import division
@@ -21,7 +21,7 @@
2121
from tf2onnx.utils import make_sure
2222

2323

24-
log = logging.getLogger("onnx_opset.controlflow")
24+
logger = logging.getLogger(__name__)
2525

2626
# pylint: disable=unused-argument,missing-docstring
2727

tf2onnx/onnx_opset/generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Licensed under the MIT license.
33

44
"""
5-
tf2onnx.tf2onnx.onnx_opset.generator
5+
generator
66
"""
77

88
from __future__ import division
@@ -17,7 +17,7 @@
1717
from tf2onnx.handler import tf_op
1818

1919

20-
log = logging.getLogger("onnx_opset.generator")
20+
logger = logging.getLogger(__name__)
2121

2222
# pylint: disable=unused-argument,missing-docstring
2323

tf2onnx/onnx_opset/logical.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Licensed under the MIT license.
33

44
"""
5-
tf2onnx.tf2onnx.onnx_opset.logical
5+
logical
66
"""
77

88
from __future__ import division
@@ -17,7 +17,7 @@
1717
from tf2onnx.onnx_opset import common
1818

1919

20-
log = logging.getLogger("onnx_opset.logical")
20+
logger = logging.getLogger(__name__)
2121

2222
# pylint: disable=unused-argument,missing-docstring
2323

tf2onnx/onnx_opset/math.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Licensed under the MIT license.
33

44
"""
5-
tf2onnx.tf2onnx.onnx_opset.math
5+
math
66
"""
77

88
from __future__ import division
@@ -18,7 +18,7 @@
1818
from tf2onnx.onnx_opset import common
1919

2020

21-
log = logging.getLogger("onnx_opset.math")
21+
logger = logging.getLogger(__name__)
2222

2323
# pylint: disable=unused-argument,missing-docstring
2424

0 commit comments

Comments
 (0)