Skip to content

Commit ae490fd

Browse files
committed
Revert "lint only python_black (#2698)"
This reverts commit 087be5c.
1 parent 087be5c commit ae490fd

File tree

712 files changed

+57869
-81343
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

712 files changed

+57869
-81343
lines changed

Diff for: benchmarks/common/base_benchmark_util.py

+158-339
Large diffs are not rendered by default.

Diff for: benchmarks/common/base_model_init.py

+84-204
Large diffs are not rendered by default.

Diff for: benchmarks/common/platform_util.py

+34-62
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
ONLINE_CPUS_LIST = "On-line CPU(s) list:"
3838

3939

40-
class CPUInfo:
40+
class CPUInfo():
4141
"""CPU information class."""
4242

4343
def __init__(self):
@@ -56,9 +56,7 @@ def _get_core_membind_info():
5656
:rtype: List[List[str, Any]]
5757
"""
5858
args = ["lscpu", "--parse=CPU,Core,Socket,Node"]
59-
process_lscpu = subprocess.check_output(args, universal_newlines=True).split(
60-
"\n"
61-
)
59+
process_lscpu = subprocess.check_output(args, universal_newlines=True).split("\n")
6260

6361
# Get information about core, node, socket and cpu. On a machine with no NUMA nodes, the last column is empty
6462
# so regex also check for empty string on the last column
@@ -102,15 +100,13 @@ def _sort_membind_info(membind_bind_info):
102100

103101
# Add core info
104102
if cpu_id == core_id:
105-
core_info.update(
106-
{
107-
core_id: {
108-
"cpu_id": cpu_id,
109-
"node_id": node_id,
110-
"socket_id": socket_id,
111-
},
112-
}
113-
)
103+
core_info.update({
104+
core_id: {
105+
"cpu_id": cpu_id,
106+
"node_id": node_id,
107+
"socket_id": socket_id,
108+
},
109+
})
114110
else:
115111
# Add information about Hyper Threading
116112
core_info[core_id]["ht_cpu_id"] = cpu_id
@@ -186,10 +182,10 @@ def binding_information(self):
186182

187183

188184
class PlatformUtil:
189-
"""
185+
'''
190186
This module implements a platform utility that exposes functions that
191187
detects platform information.
192-
"""
188+
'''
193189

194190
def __init__(self, args):
195191
self.args = args
@@ -260,14 +256,13 @@ def _get_cpuset(self):
260256
def linux_init(self):
261257
lscpu_cmd = "lscpu"
262258
try:
263-
lscpu_output = subprocess.check_output(
264-
[lscpu_cmd], stderr=subprocess.STDOUT
265-
)
259+
lscpu_output = subprocess.check_output([lscpu_cmd],
260+
stderr=subprocess.STDOUT)
266261
# handle python2 vs 3 (bytes vs str type)
267262
if isinstance(lscpu_output, bytes):
268-
lscpu_output = lscpu_output.decode("utf-8")
263+
lscpu_output = lscpu_output.decode('utf-8')
269264

270-
cpu_info = lscpu_output.split("\n")
265+
cpu_info = lscpu_output.split('\n')
271266

272267
except Exception as e:
273268
print("Problem getting CPU info: {}".format(e))
@@ -301,9 +296,7 @@ def linux_init(self):
301296
for node in range(0, self.num_numa_nodes):
302297
if line.find(NUMA_NODE_CPU_RANGE_STR_.format(str(node))) == 0:
303298
range_for_node = line.split(":")[1].strip()
304-
range_list_for_node = self._get_list_from_string_ranges(
305-
range_for_node
306-
)
299+
range_list_for_node = self._get_list_from_string_ranges(range_for_node)
307300
core_list_per_node[node] = range_list_for_node
308301

309302
# Try to get the cpuset.cpus info, since lscpu does not know if the cpuset is limited
@@ -317,11 +310,7 @@ def linux_init(self):
317310
# machine, so let's avoid unnecessary complexity and don't bother with the cpuset_cpu list.
318311
# The cpuset_cpus list will also get populated if the num_cores arg is being specified,
319312
# since this list will be used to create the numactl args in base_model_init.py
320-
if (
321-
(online_cpus_list != "" and online_cpus_list != cpuset)
322-
or online_cpus_list == ""
323-
or num_cores_arg != -1
324-
):
313+
if (online_cpus_list != "" and online_cpus_list != cpuset) or online_cpus_list == "" or num_cores_arg != -1:
325314
self.cpuset_cpus = self._get_list_from_string_ranges(cpuset)
326315

327316
# Uses numactl get the core number for each numa node and adds the cores for each
@@ -334,55 +323,38 @@ def linux_init(self):
334323
else:
335324
cores_per_node = self.num_cores_per_socket
336325
if hasattr(self.args, "numa_cores_per_instance"):
337-
if (
338-
self.num_numa_nodes > 0
339-
and self.args.numa_cores_per_instance is not None
340-
):
326+
if self.num_numa_nodes > 0 and self.args.numa_cores_per_instance is not None:
341327
try:
342328
# Get the list of cores
343-
cpu_array_command = (
344-
"numactl -H | grep 'node [0-9]* cpus:' |"
329+
cpu_array_command = \
330+
"numactl -H | grep 'node [0-9]* cpus:' |" \
345331
"sed 's/.*node [0-9]* cpus: *//' | head -{0} |cut -f1-{1} -d' '".format(
346-
self.num_numa_nodes, int(cores_per_node)
347-
)
348-
)
332+
self.num_numa_nodes, int(cores_per_node))
349333
cpu_array = subprocess.Popen(
350-
cpu_array_command,
351-
shell=True,
352-
stdout=subprocess.PIPE,
353-
stderr=subprocess.PIPE,
354-
).stdout.readlines()
334+
cpu_array_command, shell=True, stdout=subprocess.PIPE,
335+
stderr=subprocess.PIPE).stdout.readlines()
355336

356337
for node_cpus in cpu_array:
357338
node_cpus = str(node_cpus).lstrip("b'").replace("\\n'", " ")
358-
self.cpu_core_list.append(
359-
[x for x in node_cpus.split(" ") if x != ""]
360-
)
339+
self.cpu_core_list.append([x for x in node_cpus.split(" ") if x != ''])
361340

362341
# If we have the cpuset list, cross check that list with our core list and
363342
# remove cores that are not part of the cpuset list
364343
if self.cpuset_cpus is not None:
365344
for socket, core_list in enumerate(self.cpu_core_list):
366-
self.cpu_core_list[socket] = [
367-
x for x in core_list if int(x) in self.cpuset_cpus
368-
]
345+
self.cpu_core_list[socket] = [x for x in core_list if int(x) in self.cpuset_cpus]
369346

370347
if hasattr(self.args, "verbose") and self.args.verbose:
371348
print("Core list: {}".format(self.cpu_core_list), flush=True)
372349

373350
except Exception as e:
374-
print(
375-
"Warning: An error occured when getting the list of cores using '{}':\n {}".format(
376-
cpu_array_command, e
377-
)
378-
)
351+
print("Warning: An error occured when getting the list of cores using '{}':\n {}".
352+
format(cpu_array_command, e))
379353

380354
if self.cpuset_cpus is not None:
381355
# Reformat the cpuset_cpus list so that it's split up by node
382356
for node in core_list_per_node.keys():
383-
core_list_per_node[node] = [
384-
x for x in core_list_per_node[node] if x in self.cpuset_cpus
385-
]
357+
core_list_per_node[node] = [x for x in core_list_per_node[node] if x in self.cpuset_cpus]
386358
self.cpuset_cpus = core_list_per_node
387359

388360
# Remove cores that aren't part of the cpu_core_list
@@ -410,9 +382,9 @@ def windows_init(self):
410382

411383
# handle python2 vs 3 (bytes vs str type)
412384
if isinstance(wmic_output, bytes):
413-
wmic_output = wmic_output.decode("utf-8")
385+
wmic_output = wmic_output.decode('utf-8')
414386

415-
cpu_info = wmic_output.split("\r\r\n")
387+
cpu_info = wmic_output.split('\r\r\n')
416388

417389
except Exception as e:
418390
print("Problem getting CPU info: {}".format(e))
@@ -430,12 +402,12 @@ def windows_init(self):
430402
elif line.find(THREAD_COUNT_STR_) == 0:
431403
num_threads = int(line.split("=")[1].strip())
432404

433-
self.num_cpu_sockets = len(
434-
re.findall(r"\b%s\b" % re.escape(NUM_SOCKETS_STR_), wmic_output)
435-
)
405+
self.num_cpu_sockets = len(re.findall(
406+
r'\b%s\b' % re.escape(NUM_SOCKETS_STR_), wmic_output))
436407

437408
if self.num_cpu_sockets > 0 and num_threads:
438-
self.num_threads_per_core = int(num_threads / self.num_cpu_sockets)
409+
self.num_threads_per_core =\
410+
int(num_threads / self.num_cpu_sockets)
439411

440412
def mac_init(self):
441413
raise NotImplementedError("Mac Support not yet implemented")

Diff for: benchmarks/common/tensorflow/run_tf_benchmark.py

+21-26
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,30 @@
2727

2828

2929
class ModelBenchmarkUtil(BaseBenchmarkUtil):
30-
"""Benchmark util for int8 and fp32 models"""
30+
"""Benchmark util for int8 and fp32 models """
3131

3232
def main(self):
3333
# Additional args that are used internally for the start script to call the model_init.py
34-
arg_parser = ArgumentParser(
35-
parents=[self._common_arg_parser],
36-
description="Parse args for benchmark " "interface",
37-
)
38-
39-
arg_parser.add_argument(
40-
"--intelai-models",
41-
help="Local path to the intelai optimized " "model scripts",
42-
nargs="?",
43-
dest="intelai_models",
44-
)
45-
46-
arg_parser.add_argument(
47-
"--benchmark-dir",
48-
help="Local path intelai benchmark directory",
49-
nargs="?",
50-
dest="benchmark_dir",
51-
)
52-
53-
arg_parser.add_argument(
54-
"--use-case",
55-
help="The corresponding use case of the given " "model ",
56-
nargs="?",
57-
dest="use_case",
58-
)
34+
arg_parser = ArgumentParser(parents=[self._common_arg_parser],
35+
description='Parse args for benchmark '
36+
'interface')
37+
38+
arg_parser.add_argument("--intelai-models",
39+
help="Local path to the intelai optimized "
40+
"model scripts",
41+
nargs='?',
42+
dest="intelai_models")
43+
44+
arg_parser.add_argument("--benchmark-dir",
45+
help="Local path intelai benchmark directory",
46+
nargs='?',
47+
dest="benchmark_dir")
48+
49+
arg_parser.add_argument("--use-case",
50+
help="The corresponding use case of the given "
51+
"model ",
52+
nargs='?',
53+
dest="use_case")
5954

6055
args, unknown = arg_parser.parse_known_args()
6156
mi = self.initialize_model(args, unknown)

0 commit comments

Comments
 (0)