Approximate Program Synthesis James Bornholt Emina Torlak Luis Ceze Dan Grossman University of Washington
Writing approximate programs is hard Precise Implementation
Writing approximate programs is hard Precise Implementation
Writing approximate programs is hard Precise Implementation Desired Quality
Writing approximate programs is hard Precise Implementation Approximate Compiler ACCEPT, Chisel, iACT, ExpAX, … Desired Quality
Writing approximate programs is hard Precise Implementation Approximate Approximate Compiler Program ACCEPT, Chisel, iACT, ExpAX, … Desired Quality
Writing approximate programs is hard s p e c i fj c m a p a p r g r o o x r i p m a t i o n s n o o i p t a p t o o r n t u n n a i t i e s Precise Implementation Approximate Approximate Compiler Program ACCEPT, Chisel, iACT, ExpAX, … target Desired Quality language q u global a l i t y m e t optimization r i c
Synthesis: write programs automatically Programs Semantics
Synthesis: write programs automatically Target Behavior f ( x ) = 4 x + 1 Programs Semantics
Synthesis: write programs automatically Target Behavior f ( x ) = 4 x + 1 Programs Semantics
Synthesis: write programs automatically 4*x + 1 Target Behavior f ( x ) = 4 x + 1 Programs Semantics
Synthesis: write programs automatically 4*x + 1 Target Behavior f ( x ) = 4 x + 1 Programs Semantics
Synthesis: write programs automatically 4*x + 1 (x<<2) + 1 Target Behavior f ( x ) = 4 x + 1 x + x + x + x + 1 Programs Semantics
Synthesizing approximate programs 4*x + 1 (x<<2) + 1 Target Behavior f ( x ) = 4 x + 1 x + x + x + x + 1 Programs Semantics
Synthesizing approximate programs 4*x + 1 Approximate (x<<2) + 1 Behavior Target Behavior f ( x ) = 4 x + 1 x + x + x + x + 1 Programs Semantics
Synthesizing approximate programs 4*x + 1 Approximate (x<<2) + 1 Behavior Target Behavior f ( x ) = 4 x + 1 x<<2 x + x + x + x + 1 Programs Semantics
Synthesizing approximate programs 4*x + 1 Approximate κ = 10 (x<<2) + 1 Behavior κ = 6 Target Behavior = κ 4 f ( x ) = 4 x + 1 x<<2 8 = κ x + x + x + x + 1 Programs Semantics
Synthesizing approximate programs 4*x + 1 Approximate κ = 10 (x<<2) + 1 Behavior κ = 6 Target Behavior κ = 4 f ( x ) = 4 x + 1 x<<2 8 = κ x + x + x + x + 1 Programs Semantics
Synthesis automates approximation s p e c i fj c m a p a p r g r o o x r i p m a t i o n s n o o i p t a p t o o r n t u n n a i t i e s Precise Implementation Approximate Approximate Compiler Program ACCEPT, Chisel, iACT, ExpAX, … target Desired Quality language q u global a l i t y m e t optimization r i c
Synthesis automates approximation s p e c i fj c m a p a p r g r o o x r i p m a t i o n s n o o i p t a p t o o r n t u n n a i t i e s Precise Implementation Approximate Approximate Program Program Synthesis target Desired Quality language q u global a l i t y m e t optimization r i c
Synthesis automates approximation speci fj c Precise approximation Implementation opportunities Approximate Approximate Program Program Synthesis target Desired Quality global program language annotations optimization q u a l i t y m e t r i c
Existing synthesizers don’t scale enough Approximate benchmarks • fft • kmeans • inversek2j • sobel ∀ p, c. | dist ( p, c ) − f ( p, c ) | < 50% † Alur et al. Syntax-Guided Synthesis . FMCAD 2013.
Existing synthesizers don’t scale enough Approximate benchmarks • fft • kmeans • inversek2j • sobel Off-the-shelf synthesizers † • Symbolic ∀ p, c. | dist ( p, c ) − f ( p, c ) | < 50% • Stochastic • Brute-force † Alur et al. Syntax-Guided Synthesis . FMCAD 2013.
Existing synthesizers don’t scale enough float dist(float p[3], float c[3]) { Approximate benchmarks float r = 0; • fft r += (p[0] - c[0])*(p[0] - c[0]); r += (p[1] - c[1])*(p[1] - c[1]); • kmeans r += (p[2] - c[2])*(p[2] - c[2]); • inversek2j float ret = sqrt(r); • sobel return ret; } float f(float p[3], float c[3]) { ?? } Off-the-shelf synthesizers † • Symbolic assert ∀ p, c. | dist ( p, c ) − f ( p, c ) | < 50% • Stochastic • Brute-force † Alur et al. Syntax-Guided Synthesis . FMCAD 2013.
Existing synthesizers don’t scale enough float dist(float p[3], float c[3]) { Approximate benchmarks float r = 0; • fft r += (p[0] - c[0])*(p[0] - c[0]); r += (p[1] - c[1])*(p[1] - c[1]); • kmeans r += (p[2] - c[2])*(p[2] - c[2]); • inversek2j float ret = sqrt(r); • sobel return ret; } float f(float p[3], float c[3]) { ?? + - * / & | ^ } << >> … Off-the-shelf synthesizers † • Symbolic assert ∀ p, c. | dist ( p, c ) − f ( p, c ) | < 50% • Stochastic • Brute-force † Alur et al. Syntax-Guided Synthesis . FMCAD 2013.
Existing synthesizers don’t scale enough float dist(float p[3], float c[3]) { Approximate benchmarks float r = 0; • fft r += (p[0] - c[0])*(p[0] - c[0]); r += (p[1] - c[1])*(p[1] - c[1]); • kmeans r += (p[2] - c[2])*(p[2] - c[2]); • inversek2j float ret = sqrt(r); • sobel return ret; } float f(float p[3], float c[3]) { ?? + - * / & | ^ } << >> … Off-the-shelf synthesizers † • Symbolic assert ∀ p, c. | dist ( p, c ) − f ( p, c ) | < 50% • Stochastic • Brute-force Reference Program being program synthesized † Alur et al. Syntax-Guided Synthesis . FMCAD 2013.
Existing synthesizers don’t scale enough float dist(float p[3], float c[3]) { Approximate benchmarks float r = 0; • fft r += (p[0] - c[0])*(p[0] - c[0]); r += (p[1] - c[1])*(p[1] - c[1]); • kmeans r += (p[2] - c[2])*(p[2] - c[2]); • inversek2j float ret = sqrt(r); • sobel return ret; } float f(float p[3], float c[3]) { ?? + - * / & | ^ } << >> … Off-the-shelf synthesizers † • Symbolic assert ∀ p, c. | dist ( p, c ) − f ( p, c ) | < 50% • Stochastic • Brute-force Reference Program being program synthesized † Alur et al. Syntax-Guided Synthesis . FMCAD 2013.
Existing synthesizers don’t scale enough float dist(float p[3], float c[3]) { float r = 0; r += (p[0] - c[0])*(p[0] - c[0]); r += (p[1] - c[1])*(p[1] - c[1]); r += (p[2] - c[2])*(p[2] - c[2]); float ret = sqrt(r); return ret; } float f(float p[3], float c[3]) { ?? + - * / & | ^ } << >> … assert ∀ p, c. | dist ( p, c ) − f ( p, c ) | < 50% Programs Reference Program being program synthesized
Existing synthesizers don’t scale enough float dist(float p[3], float c[3]) { float r = 0; r += (p[0] - c[0])*(p[0] - c[0]); r += (p[1] - c[1])*(p[1] - c[1]); r += (p[2] - c[2])*(p[2] - c[2]); float ret = sqrt(r); return ret; } float f(float p[3], float c[3]) { ?? + - * / & | ^ } << >> … assert ∀ p, c. | dist ( p, c ) − f ( p, c ) | < 50% Programs Reference Program being program synthesized
Existing synthesizers don’t scale enough float dist(float p[3], float c[3]) { float r = 0; r += (p[0] - c[0])*(p[0] - c[0]); r += (p[1] - c[1])*(p[1] - c[1]); r += (p[2] - c[2])*(p[2] - c[2]); float ret = sqrt(r); 7.1 × 10 43 return ret; } programs float f(float p[3], float c[3]) { ?? + - * / & | ^ } << >> … assert ∀ p, c. | dist ( p, c ) − f ( p, c ) | < 50% Programs Reference Program being program synthesized
Use reference programs to guide synthesis float dist(float p[3], float c[3]) { float r = 0; r += (p[0] - c[0])*(p[0] - c[0]); r += (p[1] - c[1])*(p[1] - c[1]); r += (p[2] - c[2])*(p[2] - c[2]); float ret = sqrt(r); 7.1 × 10 43 return ret; } programs float f(float p[3], float c[3]) { ?? + - * / & | ^ } << >> … assert ∀ p, c. | dist ( p, c ) − f ( p, c ) | < 50% Programs Reference Program being program synthesized
Use reference programs to guide synthesis float dist(float p[3], float c[3]) { float r = 0; r += (p[0] - c[0])*(p[0] - c[0]); r += (p[1] - c[1])*(p[1] - c[1]); r += (p[2] - c[2])*(p[2] - c[2]); float ret = sqrt(r); 7.1 × 10 43 return ret; } programs float f(float p[3], float c[3]) { ?? + - * / & | ^ } << >> … assert ∀ p, c. | dist ( p, c ) − f ( p, c ) | < 50% Programs Reference Program being program synthesized
Use reference programs to guide synthesis float dist(float p[3], float c[3]) { float r = 0; r += (p[0] - c[0])*(p[0] - c[0]); r += (p[1] - c[1])*(p[1] - c[1]); r += (p[2] - c[2])*(p[2] - c[2]); float ret = sqrt(r); 7.1 × 10 43 return ret; } programs float f(float p[3], float c[3]) { ?? + - * / & | ^ } << >> … assert ∀ p, c. | dist ( p, c ) − f ( p, c ) | < 50% Programs Reference Program being program synthesized
Recommend
More recommend