Skip to content

Commit ed1ae9b

Browse files
author
Avik Pal
authored
Merge pull request #21 from nirmal-suthar/auto-juliaformatter-pr
Automatic JuliaFormatter.jl run
2 parents 6b39c12 + ce60a2f commit ed1ae9b

File tree

18 files changed

+206
-187
lines changed

18 files changed

+206
-187
lines changed

benchmarks/metrics.jl

Lines changed: 70 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,21 @@ function run_benchmarks!(benchmarks, x, benchmark_func, device)
2525
for (func, args, name) in x
2626
args = args .|> device
2727
trial_f = @benchmark $benchmark_func($func, $args)
28-
back_args = [x->func(x...), args]
28+
back_args = [x -> func(x...), args]
2929
trial_t = @benchmark $benchmark_func($gradient, $back_args)
3030
time_f = minimum(trial_f.times) * 1.0e-6
3131
time_t = minimum(trial_t.times) * 1.0e-6
3232
time_b = time_t - time_f
3333
println("$name (forward): $time_f ms")
3434
println("$name (back): $time_b ms")
3535
println("$name (total): $time_t ms")
36-
push!(benchmarks[name], [time_f,time_b,time_t])
36+
push!(benchmarks[name], [time_f, time_b, time_t])
3737
end
3838
end
3939

4040
npoint_arr = 2 .^ [6, 8, 10, 12, 14]
4141

42-
names = [
43-
"sample_points",
44-
"chamfer_distance",
45-
"edge_loss",
46-
"laplacian_loss"
47-
]
42+
names = ["sample_points", "chamfer_distance", "edge_loss", "laplacian_loss"]
4843

4944
cpu_bm = setup_benchmark_record(names)
5045
gpu_bm = setup_benchmark_record(names)
@@ -54,19 +49,16 @@ for _npoints in npoint_arr
5449
arr = [
5550
# (sample_points, [generate_trimesh(_npoints), _npoints],
5651
# "sample_points"),
57-
(chamfer_distance,
58-
[generate_pcloud(_npoints), generate_pcloud(_npoints)],
59-
"chamfer_distance"),
52+
(
53+
chamfer_distance,
54+
[generate_pcloud(_npoints), generate_pcloud(_npoints)],
55+
"chamfer_distance",
56+
),
6057
(edge_loss, [generate_trimesh(_npoints)], "edge_loss"),
61-
(laplacian_loss, [generate_trimesh(_npoints)], "laplacian_loss")
58+
(laplacian_loss, [generate_trimesh(_npoints)], "laplacian_loss"),
6259
]
6360
println("Running benchmarks for npoints = $_npoints")
64-
run_benchmarks!(
65-
cpu_bm,
66-
arr,
67-
(op, pc) -> op(pc...),
68-
cpu,
69-
)
61+
run_benchmarks!(cpu_bm, arr, (op, pc) -> op(pc...), cpu)
7062
println()
7163
end
7264

@@ -78,19 +70,16 @@ if has_cuda()
7870
arr = [
7971
# (sample_points, [generate_trimesh(_npoints), _npoints],
8072
# "sample_points"),
81-
(chamfer_distance,
82-
[generate_pcloud(_npoints), generate_pcloud(_npoints)],
83-
"chamfer_distance"),
73+
(
74+
chamfer_distance,
75+
[generate_pcloud(_npoints), generate_pcloud(_npoints)],
76+
"chamfer_distance",
77+
),
8478
(edge_loss, [generate_trimesh(_npoints)], "edge_loss"),
8579
(laplacian_loss, [generate_trimesh(_npoints)], "laplacian_loss"),
8680
]
8781
println("Running benchmarks for npoints = $_npoints")
88-
run_benchmarks!(
89-
gpu_bm,
90-
arr,
91-
(op, pc) -> (CUDA.@sync op(pc...)),
92-
gpu
93-
)
82+
run_benchmarks!(gpu_bm, arr, (op, pc) -> (CUDA.@sync op(pc...)), gpu)
9483
println()
9584
end
9685
end
@@ -100,24 +89,66 @@ function save_bm(fname, rep, cpu_benchmarks, gpu_benchmarks)
10089
device = "cpu"
10190
for (key, values) in cpu_benchmarks
10291
for (p, v) in zip(npoint_arr, values)
103-
Printf.@printf(io, "Flux3D(Forward) %s %s %s %d %f ms\n",
104-
rep, device, key, p, v[1])
105-
Printf.@printf(io, "Flux3D(Backward) %s %s %s %d %f ms\n",
106-
rep, device, key, p, v[2])
107-
Printf.@printf(io, "Flux3D(Total) %s %s %s %d %f ms\n",
108-
rep, device, key, p, v[3])
92+
Printf.@printf(
93+
io,
94+
"Flux3D(Forward) %s %s %s %d %f ms\n",
95+
rep,
96+
device,
97+
key,
98+
p,
99+
v[1]
100+
)
101+
Printf.@printf(
102+
io,
103+
"Flux3D(Backward) %s %s %s %d %f ms\n",
104+
rep,
105+
device,
106+
key,
107+
p,
108+
v[2]
109+
)
110+
Printf.@printf(
111+
io,
112+
"Flux3D(Total) %s %s %s %d %f ms\n",
113+
rep,
114+
device,
115+
key,
116+
p,
117+
v[3]
118+
)
109119
end
110120
end
111121

112122
device = "gpu"
113123
for (key, values) in gpu_benchmarks
114124
for (p, v) in zip(npoint_arr, values)
115-
Printf.@printf(io, "Flux3D(Forward) %s %s %s %d %f ms\n",
116-
rep, device, key, p, v[1])
117-
Printf.@printf(io, "Flux3D(Backward) %s %s %s %d %f ms\n",
118-
rep, device, key, p, v[2])
119-
Printf.@printf(io, "Flux3D(Total) %s %s %s %d %f ms\n",
120-
rep, device, key, p, v[3])
125+
Printf.@printf(
126+
io,
127+
"Flux3D(Forward) %s %s %s %d %f ms\n",
128+
rep,
129+
device,
130+
key,
131+
p,
132+
v[1]
133+
)
134+
Printf.@printf(
135+
io,
136+
"Flux3D(Backward) %s %s %s %d %f ms\n",
137+
rep,
138+
device,
139+
key,
140+
p,
141+
v[2]
142+
)
143+
Printf.@printf(
144+
io,
145+
"Flux3D(Total) %s %s %s %d %f ms\n",
146+
rep,
147+
device,
148+
key,
149+
p,
150+
v[3]
151+
)
121152
end
122153
end
123154
end

benchmarks/plot.jl

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,7 @@ function read_bm_transforms(fname, framework)
1111
)
1212
for line in eachline(fname)
1313
raw = split(line)
14-
push!(
15-
data,
16-
(
17-
raw[1],
18-
raw[2],
19-
raw[3],
20-
parse(Int, raw[4]),
21-
parse(Float64, raw[5]),
22-
),
23-
)
14+
push!(data, (raw[1], raw[2], raw[3], parse(Int, raw[4]), parse(Float64, raw[5])))
2415
end
2516
data[!, :framework] .= framework
2617
return data
@@ -40,14 +31,7 @@ function read_bm_metrics(fname)
4031
raw = split(line)
4132
push!(
4233
data,
43-
(
44-
raw[1],
45-
raw[2],
46-
raw[3],
47-
raw[4],
48-
parse(Int, raw[5]),
49-
parse(Float64, raw[6]),
50-
),
34+
(raw[1], raw[2], raw[3], raw[4], parse(Int, raw[5]), parse(Float64, raw[6])),
5135
)
5236
end
5337
return data

benchmarks/transforms.jl

Lines changed: 51 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,7 @@ names = [
6262
cpu_bm_pcloud = setup_benchmark_record(names)
6363
gpu_bm_pcloud = setup_benchmark_record(names)
6464

65-
names = [
66-
"ScaleTriMesh",
67-
"RotateTriMesh",
68-
"ReAlignTriMesh",
69-
"NormalizeTriMesh",
70-
"Chain",
71-
]
65+
names = ["ScaleTriMesh", "RotateTriMesh", "ReAlignTriMesh", "NormalizeTriMesh", "Chain"]
7266
cpu_bm_trimesh = setup_benchmark_record(names)
7367
gpu_bm_trimesh = setup_benchmark_record(names)
7468

@@ -78,25 +72,36 @@ for _npoints in npoint_arr
7872
pcloud_arr = [
7973
(ScalePointCloud(0.5; inplace = false), "ScalePointCloud"),
8074
(RotatePointCloud(ROT_MATRIX; inplace = false), "RotatePointCloud"),
81-
(ReAlignPointCloud(realign_point_cloud(_npoints); inplace = false),
82-
"ReAlignPointCloud"),
75+
(
76+
ReAlignPointCloud(realign_point_cloud(_npoints); inplace = false),
77+
"ReAlignPointCloud",
78+
),
8379
(NormalizePointCloud(inplace = false), "NormalizePointCloud"),
84-
(Chain(ScalePointCloud(0.5; inplace = false),
85-
RotatePointCloud(ROT_MATRIX; inplace = false),
86-
ReAlignPointCloud(realign_point_cloud(_npoints);inplace = false,),
87-
NormalizePointCloud()),"Chain",)
80+
(
81+
Chain(
82+
ScalePointCloud(0.5; inplace = false),
83+
RotatePointCloud(ROT_MATRIX; inplace = false),
84+
ReAlignPointCloud(realign_point_cloud(_npoints); inplace = false),
85+
NormalizePointCloud(),
86+
),
87+
"Chain",
88+
),
8889
]
8990

9091
trimesh_arr = [
9192
(ScaleTriMesh(0.5; inplace = true), "ScaleTriMesh"),
9293
(RotateTriMesh(ROT_MATRIX; inplace = true), "RotateTriMesh"),
93-
(ReAlignTriMesh(realign_trimesh(_npoints); inplace = true),
94-
"ReAlignTriMesh"),
94+
(ReAlignTriMesh(realign_trimesh(_npoints); inplace = true), "ReAlignTriMesh"),
9595
(NormalizeTriMesh(inplace = true), "NormalizeTriMesh"),
96-
(Chain(ScaleTriMesh(0.5; inplace = true),
97-
RotateTriMesh(ROT_MATRIX; inplace = true),
98-
ReAlignTriMesh(realign_trimesh(_npoints); inplace = true),
99-
NormalizeTriMesh(inplace = true)),"Chain"),
96+
(
97+
Chain(
98+
ScaleTriMesh(0.5; inplace = true),
99+
RotateTriMesh(ROT_MATRIX; inplace = true),
100+
ReAlignTriMesh(realign_trimesh(_npoints); inplace = true),
101+
NormalizeTriMesh(inplace = true),
102+
),
103+
"Chain",
104+
),
100105
]
101106
println("Running benchmarks for npoints = $_npoints")
102107
run_benchmarks!(
@@ -126,25 +131,36 @@ if has_cuda()
126131
pcloud_arr = [
127132
(ScalePointCloud(0.5; inplace = false), "ScalePointCloud"),
128133
(RotatePointCloud(ROT_MATRIX; inplace = false), "RotatePointCloud"),
129-
(ReAlignPointCloud(realign_point_cloud(_npoints); inplace = false),
130-
"ReAlignPointCloud"),
134+
(
135+
ReAlignPointCloud(realign_point_cloud(_npoints); inplace = false),
136+
"ReAlignPointCloud",
137+
),
131138
(NormalizePointCloud(inplace = false), "NormalizePointCloud"),
132-
(Chain(ScalePointCloud(0.5; inplace = false),
133-
RotatePointCloud(ROT_MATRIX; inplace = false),
134-
ReAlignPointCloud(realign_point_cloud(_npoints);inplace = false,),
135-
NormalizePointCloud()),"Chain",)
139+
(
140+
Chain(
141+
ScalePointCloud(0.5; inplace = false),
142+
RotatePointCloud(ROT_MATRIX; inplace = false),
143+
ReAlignPointCloud(realign_point_cloud(_npoints); inplace = false),
144+
NormalizePointCloud(),
145+
),
146+
"Chain",
147+
),
136148
]
137149

138150
trimesh_arr = [
139151
(ScaleTriMesh(0.5; inplace = true), "ScaleTriMesh"),
140152
(RotateTriMesh(ROT_MATRIX; inplace = true), "RotateTriMesh"),
141-
(ReAlignTriMesh(realign_trimesh(_npoints); inplace = true),
142-
"ReAlignTriMesh"),
153+
(ReAlignTriMesh(realign_trimesh(_npoints); inplace = true), "ReAlignTriMesh"),
143154
(NormalizeTriMesh(inplace = true), "NormalizeTriMesh"),
144-
(Chain(ScaleTriMesh(0.5; inplace = true),
145-
RotateTriMesh(ROT_MATRIX; inplace = true),
146-
ReAlignTriMesh(realign_trimesh(_npoints); inplace = true),
147-
NormalizeTriMesh(inplace = true)),"Chain"),
155+
(
156+
Chain(
157+
ScaleTriMesh(0.5; inplace = true),
158+
RotateTriMesh(ROT_MATRIX; inplace = true),
159+
ReAlignTriMesh(realign_trimesh(_npoints); inplace = true),
160+
NormalizeTriMesh(inplace = true),
161+
),
162+
"Chain",
163+
),
148164
]
149165
println("Running benchmarks for npoints = $_npoints")
150166
run_benchmarks!(
@@ -153,15 +169,15 @@ if has_cuda()
153169
_npoints,
154170
generate_point_cloud,
155171
(op, pc) -> (CUDA.@sync op(pc)),
156-
gpu
172+
gpu,
157173
)
158174
run_benchmarks!(
159175
gpu_bm_trimesh,
160176
trimesh_arr,
161177
_npoints,
162178
generate_trimesh,
163179
(op, pc) -> (CUDA.@sync op(pc)),
164-
gpu
180+
gpu,
165181
)
166182
println()
167183
end
@@ -172,16 +188,14 @@ function save_bm(fname, rep, cpu_benchmarks, gpu_benchmarks)
172188
device = "cpu"
173189
for (key, values) in cpu_benchmarks
174190
for (p, v) in zip(npoint_arr, values)
175-
Printf.@printf(io, "%s %s %s %d %f ms\n",
176-
rep, device, key, p, v)
191+
Printf.@printf(io, "%s %s %s %d %f ms\n", rep, device, key, p, v)
177192
end
178193
end
179194

180195
device = "gpu"
181196
for (key, values) in gpu_benchmarks
182197
for (p, v) in zip(npoint_arr, values)
183-
Printf.@printf(io, "%s %s %s %d %f ms\n",
184-
rep, device, key, p, v)
198+
Printf.@printf(io, "%s %s %s %d %f ms\n", rep, device, key, p, v)
185199
end
186200
end
187201
end

0 commit comments

Comments
 (0)