From d0e752003da3fc023fa85094d7f5b65b47dd5091 Mon Sep 17 00:00:00 2001 From: qazal <77887910+Qazalin@users.noreply.github.com> Date: Fri, 22 Sep 2023 02:20:27 +0300 Subject: [PATCH] fixes (#1893) --- extra/accel/ane/lib/ane.py | 2 +- extra/datasets/__init__.py | 4 ++-- extra/datasets/coco.py | 6 +++--- extra/gemm/amx.py | 2 +- extra/gemm/gemm.py | 2 +- sz.py | 2 +- test/external/external_test_image.py | 4 ++-- test/extra/test_utils.py | 10 +++++----- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/extra/accel/ane/lib/ane.py b/extra/accel/ane/lib/ane.py index 7b7710486d..2e430c0f54 100755 --- a/extra/accel/ane/lib/ane.py +++ b/extra/accel/ane/lib/ane.py @@ -214,7 +214,7 @@ if __name__ == "__main__": mdf = ane.pack(dd, md) assert(md == mdf) - comp = ane.compile(dat) + comp = ane.compile(dat) ret = ane.run(comp, tin, tout) print("** after **") print(tind) diff --git a/extra/datasets/__init__.py b/extra/datasets/__init__.py index 4d4a1a4f34..30aafe6c0d 100644 --- a/extra/datasets/__init__.py +++ b/extra/datasets/__init__.py @@ -32,7 +32,7 @@ def fetch_cifar(shuffle=False): X[idx:idx+bs].assign(x[order,:]) Y[idx:idx+bs].assign(y[order]) idx += bs - return X, Y + return X, Y fn = Path(__file__).parent.resolve() / "cifar-10-python.tar.gz" download_file('https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz', fn) tt = tarfile.open(fn, mode='r:gz') @@ -40,4 +40,4 @@ def fetch_cifar(shuffle=False): X_train, Y_train = _load_disk_tensor(50000, 10000, db, "cifar_train", shuffle=shuffle) db = [pickle.load(tt.extractfile('cifar-10-batches-py/test_batch'), encoding="bytes")] X_test, Y_test = _load_disk_tensor(10000, 10000, db, "cifar_test", shuffle=shuffle) - return X_train, Y_train, X_test, Y_test \ No newline at end of file + return X_train, Y_train, X_test, Y_test diff --git a/extra/datasets/coco.py b/extra/datasets/coco.py index 008efae4fa..5b35974587 100644 --- a/extra/datasets/coco.py +++ b/extra/datasets/coco.py @@ -24,7 +24,7 @@ if not pathlib.Path(BASEDIR/'val2017').is_dir(): with zipfile.ZipFile(fn, 'r') as zip_ref: zip_ref.extractall(BASEDIR) fn.unlink() - + if not pathlib.Path(BASEDIR/'annotations').is_dir(): fn = BASEDIR/'annotations_trainval2017.zip' @@ -178,7 +178,7 @@ def evaluate_predictions_on_coco(json_result_file, iou_type="bbox"): with open(json_result_file, "r") as f: for line in f: coco_results.append(json.loads(line)) - + coco_gt = COCO(str(BASEDIR/'annotations/instances_val2017.json')) set_of_json = remove_dup([json.dumps(d, cls=NpEncoder) for d in coco_results]) unique_list = [json.loads(s) for s in set_of_json] @@ -186,7 +186,7 @@ def evaluate_predictions_on_coco(json_result_file, iou_type="bbox"): with open(f'{json_result_file}.flattend', "w") as f: json.dump(unique_list, f) - coco_dt = coco_gt.loadRes(str(f'{json_result_file}.flattend')) + coco_dt = coco_gt.loadRes(str(f'{json_result_file}.flattend')) coco_eval = COCOeval(coco_gt, coco_dt, iou_type) coco_eval.evaluate() coco_eval.accumulate() diff --git a/extra/gemm/amx.py b/extra/gemm/amx.py index af0b3bd6c6..3058b66390 100755 --- a/extra/gemm/amx.py +++ b/extra/gemm/amx.py @@ -56,7 +56,7 @@ bufs = [c,a,b] module = ir.Module(name=__file__) func = ir.Function(module, ir.FunctionType(ir.IntType(64), [ir.FloatType().as_pointer()]*3), name='exec') -# load all +# load all entry = ir.IRBuilder(func.append_basic_block(name="entry")) zm, xm, ym = [entry.ptrtoint(func.args[i], ir.IntType(64)) for i in range(3)] diff --git a/extra/gemm/gemm.py b/extra/gemm/gemm.py index 5073cc05cb..f6f13d8f99 100755 --- a/extra/gemm/gemm.py +++ b/extra/gemm/gemm.py @@ -21,7 +21,7 @@ if __name__ == "__main__": et = time.monotonic() s = et-st print(f"{flop/s * 1e-9:.2f} GFLOP/S, {s*1e3:.2f} ms") - + with open("/tmp/matmul", "wb") as f: f.write(A.data) f.write(B.data) diff --git a/sz.py b/sz.py index c70280c806..b64de65647 100755 --- a/sz.py +++ b/sz.py @@ -37,7 +37,7 @@ def gen_diff(table_old, table_new): for file in unchanged: file_stat_old = [stats for stats in table_old if file in stats] file_stat_new = [stats for stats in table_new if file in stats] - if file_stat_new[0][1]-file_stat_old[0][1] != 0 or file_stat_new[0][2]-file_stat_old[0][2] != 0: + if file_stat_new[0][1]-file_stat_old[0][1] != 0 or file_stat_new[0][2]-file_stat_old[0][2] != 0: table.append([file_stat_new[0][0], file_stat_new[0][1], file_stat_new[0][1]-file_stat_old[0][1], file_stat_new[0][2], file_stat_new[0][2]-file_stat_old[0][2]]) return table diff --git a/test/external/external_test_image.py b/test/external/external_test_image.py index 68d0aec348..3e246eef70 100644 --- a/test/external/external_test_image.py +++ b/test/external/external_test_image.py @@ -23,7 +23,7 @@ class TestImage(unittest.TestCase): t1 = t1.sum() t1.realize() assert t1.numpy() == 16*4*4*4, f"got {t1.numpy()}" - + def test_add_image(self): t1 = Tensor.ones(16, 16, 1).reshape(16, 4, 4) + 3 t2 = Tensor.ones(16, 16, 1).reshape(16, 4, 4) + 4 @@ -38,7 +38,7 @@ class TestImage(unittest.TestCase): tiny_conv = Conv2d(in_chans, out_chans, 3, bias=None, padding=1) tiny_dat = Tensor.ones(bs, 12, 64, 128) tiny_conv(tiny_dat).realize() - + def test_op_conv(self): bs, in_chans, out_chans = 1,12,32 tiny_conv = Conv2d(in_chans, out_chans, 3, bias=None, padding=1) diff --git a/test/extra/test_utils.py b/test/extra/test_utils.py index b18aa0c814..b6a8149c9c 100644 --- a/test/extra/test_utils.py +++ b/test/extra/test_utils.py @@ -32,7 +32,7 @@ class TestFetchRelative(unittest.TestCase): self.tempdir = tempfile.TemporaryDirectory() os.chdir(self.tempdir.name) with open('test_file.txt', 'x') as f: - f.write("12345") + f.write("12345") def tearDown(self): os.chdir(self.working_dir) @@ -44,9 +44,9 @@ class TestFetchRelative(unittest.TestCase): #test ../ def test_fetch_relative_dotdotslash(self): - os.mkdir('test_file_path') - os.chdir('test_file_path') - self.assertEqual(b'12345', fetch("../test_file.txt")) + os.mkdir('test_file_path') + os.chdir('test_file_path') + self.assertEqual(b'12345', fetch("../test_file.txt")) class TestDownloadFile(unittest.TestCase): def setUp(self): @@ -103,4 +103,4 @@ class TestUtils(unittest.TestCase): assert a.dtype == b.dtype assert np.array_equal(a, b) if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main()