Skip to content
Snippets Groups Projects
Commit 1848d531 authored by Russel Arbore's avatar Russel Arbore
Browse files

Chefs kiss

parent 5ba0636b
No related branches found
No related tags found
1 merge request!178Some Cava optimization
Pipeline #201633 passed
......@@ -35,20 +35,6 @@ fn scale<row : usize, col : usize>(input : u8[CHAN, row, col]) -> f32[CHAN, row,
return res;
}
fn descale<row : usize, col : usize>(input : f32[CHAN, row, col]) -> u8[CHAN, row, col] {
let res : u8[CHAN, row, col];
for chan = 0 to CHAN {
for r = 0 to row {
for c = 0 to col {
res[chan, r, c] = min!::<f32>(max!::<f32>(input[chan, r, c] * 255, 0), 255) as u8;
}
}
}
return res;
}
fn demosaic<row : usize, col : usize>(input : f32[CHAN, row, col]) -> f32[CHAN, row, col] {
@res2 let res : f32[CHAN, row, col];
......@@ -184,7 +170,7 @@ fn gamut<row : usize, col : usize, num_ctrl_pts : usize>(
fn tone_map<row : usize, col:usize>
(input : f32[CHAN, row, col], tone_map : f32[256, CHAN]) -> f32[CHAN, row, col] {
let result : f32[CHAN, row, col];
@res1 let result : f32[CHAN, row, col];
for chan = 0 to CHAN {
for r = 0 to row {
......@@ -198,6 +184,20 @@ fn tone_map<row : usize, col:usize>
return result;
}
fn descale<row : usize, col : usize>(input : f32[CHAN, row, col]) -> u8[CHAN, row, col] {
@res2 let res : u8[CHAN, row, col];
for chan = 0 to CHAN {
for r = 0 to row {
for c = 0 to col {
res[chan, r, c] = min!::<f32>(max!::<f32>(input[chan, r, c] * 255, 0), 255) as u8;
}
}
}
return res;
}
#[entry]
fn cava<r, c, num_ctrl_pts : usize>(
input : u8[CHAN, r, c],
......@@ -212,7 +212,7 @@ fn cava<r, c, num_ctrl_pts : usize>(
@fuse2 let denosd = denoise::<r, c>(demosc);
@fuse3 let transf = transform::<r, c>(denosd, TsTw);
@fuse4 let gamutd = gamut::<r, c, num_ctrl_pts>(transf, ctrl_pts, weights, coefs);
let tonemd = tone_map::<r, c>(gamutd, tonemap);
let dscald = descale::<r, c>(tonemd);
@fuse5 let tonemd = tone_map::<r, c>(gamutd, tonemap);
@fuse5 let dscald = descale::<r, c>(tonemd);
return dscald;
}
......@@ -22,6 +22,9 @@ inline(fuse3);
let fuse4 = outline(cava@fuse4);
inline(fuse4);
let fuse5 = outline(cava@fuse5);
inline(fuse5);
ip-sroa(*);
sroa(*);
simpl!(*);
......@@ -58,6 +61,7 @@ fixpoint {
fork-guard-elim(fuse3);
fork-coalesce(fuse3);
}
simpl!(fuse3);
fork-split(fuse3);
unforkify(fuse3);
......@@ -68,8 +72,23 @@ fixpoint {
fork-guard-elim(fuse4);
fork-coalesce(fuse4);
}
simpl!(fuse4);
fork-split(fuse4);
unforkify(fuse4);
no-memset(fuse5@res1);
no-memset(fuse5@res2);
fixpoint {
forkify(fuse5);
fork-guard-elim(fuse5);
fork-coalesce(fuse5);
}
simpl!(fuse5);
array-slf(fuse5);
simpl!(fuse5);
fork-split(fuse5);
unforkify(fuse5);
simpl!(*);
delete-uncalled(*);
gcm(*);
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment