Last active
August 6, 2019 05:47
-
-
Save cbalint13/3aada2285cad74dc78feeccbd5edd00b to your computer and use it in GitHub Desktop.
Upgrade TOPHUB winograd entries.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import sys | |
import json | |
old_file = 'arm_cpu_v0.04.log' | |
new_file = 'arm_cpu_v0.05.log' | |
fn = open(new_file, 'w') | |
with open(old_file) as fp: | |
for cnt, line in enumerate(fp): | |
if "winograd" in line: | |
# parse as json | |
d = json.loads(line) | |
# data info | |
_, _, H, W = d['i'][2][0][1] | |
# insert tile_size knob | |
d['i'][5]['e'].insert(0, ["tile_size", "ot", 4]) | |
print("Insert [arm_cpu] H:%i W:%i tile_size=%s" % (H, W, d['i'][5]['e'][0])) | |
new_line = json.dumps(d, separators=(', ', ': ')) | |
# output to file | |
fn.write(new_line + "\n") | |
else: | |
fn.write(str(line)) | |
fn.close() | |
old_file = 'mali_v0.05.log' | |
new_file = 'mali_v0.06.log' | |
fn = open(new_file, 'w') | |
with open(old_file) as fp: | |
for cnt, line in enumerate(fp): | |
if "winograd" in line: | |
# parse as json | |
d = json.loads(line) | |
# data info | |
_, _, H, W = d['i'][2][0][1] | |
# insert tile_size knob | |
if H % 4 == 0: | |
tile_size = 4 | |
else: | |
tile_size = 2 | |
if ": 15112" in line: | |
# EXCEPTION | |
# replace original (28GFLOPS?) with 22GFLOPS one. | |
d = json.loads('{"i": ["opencl -model=rk3399 -device=mali", "topi_nn_conv2d", [["TENSOR", [1, 512, 7, 7], "float32"], ["TENSOR", [512, 512, 3, 3], "float32"], [1, 1], [1, 1], [1, 1], "NCHW", "float32"], {}, ["conv2d", [1, 512, 7, 7, "float32"], [512, 512, 3, 3, "float32"], [1, 1], [1, 1], [1, 1], "NCHW", "float32"], {"i": 15112, "t": "winograd", "c": null, "e": [["tile_size", "ot", 2], ["tile_bna", "ot", 4], ["tile_bnb", "ot", 4], ["tile_t1", "sp", [64, 8]], ["tile_t2", "sp", [256, 2]], ["c_unroll", "sp", [256, 2]], ["yt", "ot", 32]]}], "r": [[0.0104451508], 0, 20.086809873580933, 1565054826.0923486], "v": 0.1}') | |
d['i'][5]['e'].insert(0, ["tile_size", "ot", tile_size]) | |
print("Insert [mali] H:%i W:%i tile_size=%s" % (H, W, d['i'][5]['e'][0])) | |
new_line = json.dumps(d, separators=(', ', ': ')) | |
# output to file | |
fn.write(new_line + "\n") | |
else: | |
fn.write(str(line)) | |
fn.close() | |
old_file = 'cuda_v0.04.log' | |
new_file = 'cuda_v0.05.log' | |
fn = open(new_file, 'w') | |
with open(old_file) as fp: | |
for cnt, line in enumerate(fp): | |
if "winograd" in line: | |
# parse as json | |
d = json.loads(line) | |
# data info | |
_, _, H, W = d['i'][2][0][1] | |
# insert tile_size knob | |
if H % 8 == 0: | |
d['i'][5]['e'].insert(0, ["tile_size", "ot", 4]) | |
else: | |
d['i'][5]['e'].insert(0, ["tile_size", "ot", 2]) | |
print("Insert [cuda] H:%i W:%i tile_size=%s" % (H, W, d['i'][5]['e'][0])) | |
new_line = json.dumps(d, separators=(', ', ': ')) | |
# output to file | |
fn.write(new_line + "\n") | |
else: | |
fn.write(str(line)) | |
fn.close() | |
old_file = 'opencl_v0.02.log' | |
new_file = 'opencl_v0.03.log' | |
fn = open(new_file, 'w') | |
with open(old_file) as fp: | |
for cnt, line in enumerate(fp): | |
if "winograd" in line: | |
# parse as json | |
d = json.loads(line) | |
# data info | |
_, _, H, W = d['i'][2][0][1] | |
# insert tile_size knob | |
if H % 8 == 0: | |
d['i'][5]['e'].insert(0, ["tile_size", "ot", 4]) | |
else: | |
d['i'][5]['e'].insert(0, ["tile_size", "ot", 2]) | |
print("Insert [cuda] H:%i W:%i tile_size=%s" % (H, W, d['i'][5]['e'][0])) | |
new_line = json.dumps(d, separators=(', ', ': ')) | |
# output to file | |
fn.write(new_line + "\n") | |
else: | |
fn.write(str(line)) | |
fn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment