forked from ktrk115/const_layout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
69 lines (40 loc) · 1.24 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# import numpy as np
# from multiprocessing import Pool, cpu_count
# # 矩阵加法函数
# def matrix_add_subsection(a, b, start, end):
# return np.add(a[start:end], b[start:end])
# # 将矩阵划分为多个子部分并分配给不同的进程
# def parallel_matrix_add(a, b):
# num_processes = cpu_count() # 获取CPU核心数
# print(num_processes)
# # exit(0)
# rows = a.shape[0]
# step = rows // num_processes
# # 创建进程池
# pool = Pool(processes=num_processes)
# # 分配任务
# results = [pool.apply_async(matrix_add_subsection, args=(a, b, i, i + step)) for i in range(0, rows, step)]
# # 收集结果
# results = [p.get() for p in results]
# breakpoint()
# # 合并结果
# result_matrix = np.concatenate(results, axis=0)
# # 关闭进程池
# pool.close()
# pool.join()
# return result_matrix
# # 创建两个矩阵
# a = np.random.rand(1000, 1000)
# b = np.random.rand(1000, 1000)
# # 使用多进程进行矩阵加法
# result = parallel_matrix_add(a, b)
# # 输出结果的一部分以验证
# print(result[:5, :5])
import numpy as np
print(bbox)
print(label)
breakpoint()
print()
print(layout_np.shape)
breakpoint()
print()