pcnn: parallel convolutional neural network ...eigenman/ece563/projectpresentations... s2 feature...

13
PCNN: PARALLEL CONVOLUTIONAL NEURAL NETWORK IMPLEMENTATIONS FOR HANDWRITTEN DIGIT RECOGNITION Swagath Venkataramani Rangharajan Venkatesan Ashiwan Sivakumar 1

Upload: others

Post on 05-Oct-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: pCNN: Parallel Convolutional Neural Network ...eigenman/ECE563/ProjectPresentations... S2 feature map  1ax 2 25 W i W 15 5 6 10 21 W 0 1 W i (5X

PCNN: PARALLEL CONVOLUTIONAL

NEURAL NETWORK IMPLEMENTATIONS

FOR HANDWRITTEN DIGIT RECOGNITION

Swagath Venkataramani

Rangharajan Venkatesan

Ashiwan Sivakumar

1

Page 2: pCNN: Parallel Convolutional Neural Network ...eigenman/ECE563/ProjectPresentations... S2 feature map  1ax 2 25 W i W 15 5 6 10 21 W 0 1 W i (5X

OBJECTIVE

Implement parallel software versions of Convolutional Neural Networks (CNN)

OpenMP, pthreads, MPI

Lenet-5: Designed for handwritten digit recognition application.

• MNIST dataset

• Experiments run on

server with 48 AMD cores

W0

W1

W2

I0

I1

I2

𝑤𝑖 O

2

Page 3: pCNN: Parallel Convolutional Neural Network ...eigenman/ECE563/ProjectPresentations... S2 feature map  1ax 2 25 W i W 15 5 6 10 21 W 0 1 W i (5X

LENET 5: CNN

1 2

784

Wi (5X 5)

W0 (5X 5)

W5 (5X 5)

28

29 56

756

1 2 28

784 756

29 56 30

1 2

196

Wi

W5

14

15 28

182

W0

1 2

100

Wi (5X 5)

W0 (5X 5)

W59(5X 5)

10

11 20

90

Input: <32 X 32> C1 feature map

<6 X 28 X 28> S2 feature map

<6 X 14 X 14>

1 2

25

Wi

W15

5

6 10

21

W0

1 Wi (5X 5)

1 W0 (5X 5)

1 W1919(5X 5)

2

1

W0(120X1)

3

10

C3 feature map

<16 X 10 X 10>

S4 feature map

<16 X 5 X 5>

C5 feature map

<120 X 1>

Output

<10 X 1>

Fin

d M

ax

Output

label

Connection Table

<6 X 16>

3

Page 4: pCNN: Parallel Convolutional Neural Network ...eigenman/ECE563/ProjectPresentations... S2 feature map  1ax 2 25 W i W 15 5 6 10 21 W 0 1 W i (5X

LENET 5: PROFILING

1 2

784

Wi (5X 5)

W0 (5X 5)

W5 (5X 5)

28

29 56

756

1 2 28

784 756

29 56 30

1 2

196

Wi

W5

14

15 28

182

W0

1 2

100

Wi (5X 5)

W0 (5X 5)

W59(5X 5)

10

11 20

90

Input: <32 X 32> C1 feature map

<6 X 28 X 28> S2 feature map

<6 X 14 X 14>

1 2

25

Wi

W15

5

6 10

21

W0

1 Wi (5X 5)

1 W0 (5X 5)

1 W1919(5X 5)

2

1

W0(120X1)

3

10

Connection Table <16 X 120>

C3 feature map

<16 X 10 X 10>

S4 feature map

<16 X 5 X 5>

C5 feature map

<120 X 1>

Output

<10 X 1>

Fin

d M

ax

Output

label

Loop C1

4704 Iterations

25 ip. MAC

Time: ~38%

Loop S2

1176 Iterations

4 ip. Average

Time: ~3%

Loop C3

1600 Iterations

~90 ip. MAC

Time: ~43%

Loop S4

400 Iterations

4 ip. Average

Time: ~1%

Loop C5

120 Iterations

400 ip. MAC

Time: ~12%

Loop F6

10 Iterations

120 ip. MAC

Time: ~1%

4

Page 5: pCNN: Parallel Convolutional Neural Network ...eigenman/ECE563/ProjectPresentations... S2 feature map  1ax 2 25 W i W 15 5 6 10 21 W 0 1 W i (5X

TRANSFORMATION 1: NAÏVE PARALLEL

W0 (5X 5)

W5 (5X 5)

1 2 28

784 756

29 56 30

W5

W0 W0 (5X 5)

W59(5X 5)

W15

W0 1 W0 (5X 5)

1 W1919(5X 5)

1

W0(120X1)

10

Find

Max

Output

label

0

5

10

15

20

25

0 8 16 24 32 40 48

Spee

du

p -

->

No of Cores -->

Baseline

Naïve

BARRIER

5

Page 6: pCNN: Parallel Convolutional Neural Network ...eigenman/ECE563/ProjectPresentations... S2 feature map  1ax 2 25 W i W 15 5 6 10 21 W 0 1 W i (5X

TRANSFORMATION 2: REHASH & FUSE

6 X 8 Input Feature Map

2 X 4 Convolved Feature Map

1 2 3 5 6 7

4 8

1

2

3

4

5

6

7

8

1 2 3 5 6 7

4 8

2D Conv.

5X5 Window

1

8

4

Sub-sampling

2X2 Window

S1

S2

S1 S2

2 X 1 Subsampled Feature Map

6 X 8 Input Feature Map

1 X 2 Convolved & Subsampled Feature Map

1 2 5 3 4 7

6 8

1 2 5 3 4 7

6 8

2D Convolution & Sub-sampling

5X5 Conv. Window 2X2 Sub. Sampling

1

2

3

4

1

8

5

S1

5

6

7

8

S1

4

S1 S2

6

Page 7: pCNN: Parallel Convolutional Neural Network ...eigenman/ECE563/ProjectPresentations... S2 feature map  1ax 2 25 W i W 15 5 6 10 21 W 0 1 W i (5X

TRANSFORMATION 2: REHASH & FUSE

0

5

10

15

20

25

0 8 16 24 32 40 48

Spee

du

p -

->

No of Cores -->

BaselineNaïveFused

W0 (5X 5)

W5 (5X 5)

W0 (5X 5)

W59(5X 5) W5

W0 W0

W59

1 W0 (5X 5)

1 W1919(5X 5)

1

W0(120X1)

10

Fin

d M

ax

Output

label

7

Page 8: pCNN: Parallel Convolutional Neural Network ...eigenman/ECE563/ProjectPresentations... S2 feature map  1ax 2 25 W i W 15 5 6 10 21 W 0 1 W i (5X

TRANSFORMATION 3: PIPE-FUSED PARALLEL

Digit recognition typically

processes stream of i/ps1

1http://yann.lecun.com/exdb/lenet/index.html

Producer-Consumer relationship across

layers in Fused Parallel implementation

1176

iterations 400

iterations 120

iterations 10

iterations

i

i-1

i-2

i-3

(1176+400+120+10) iterations

C1-S2 C3-S4 C5 F6

C1-S2 C3-S4 C5 F6

C1-S2 C3-S4 C5 F6

C1-S2 C3-S4 C5 F6

Time Inp

ut

C1-S2 C3-S4 C5 F6

C1-S2 C3-S4 C5 F6

C1-S2 C3-S4 C5 F6

PIPE- FUSED: Enhanced parallelism through Pipelining

8

Page 9: pCNN: Parallel Convolutional Neural Network ...eigenman/ECE563/ProjectPresentations... S2 feature map  1ax 2 25 W i W 15 5 6 10 21 W 0 1 W i (5X

TRANSFORMATION 3: PIPEFUSED PARALLEL

Pseudo-code

#pragma omp for

for (i=1:N_Total)

if ( i < N1)

process C1-S2

else if ( i< N1+N2)

process C3-S4

else if ( i < N1+N2+N3)

process C5

else

process F6

N1

N_Total threads

N2 N3 N4

C1-S2 C3-S4 C5 F6

• N1,N2,N3,N4??

• Design-space exploration

Page 10: pCNN: Parallel Convolutional Neural Network ...eigenman/ECE563/ProjectPresentations... S2 feature map  1ax 2 25 W i W 15 5 6 10 21 W 0 1 W i (5X

TRANSFORMATION 3: PIPEFUSED PARALLEL

Pseudo-code

#pragma omp for

for (i=1:N_Total)

if ( i < N1)

process C1-S2

else if ( i< N1+N2)

process C3-S4

else if ( I < N1+N2+N3)

process C5

else

process F6

Page 11: pCNN: Parallel Convolutional Neural Network ...eigenman/ECE563/ProjectPresentations... S2 feature map  1ax 2 25 W i W 15 5 6 10 21 W 0 1 W i (5X

Naive implementation:

Broadcast output before running next layer

Transformation 2: “Selective Send” based on connection table

Transformation 1: Fuse layers

Eliminates C1-S2 and C3-S4 communication

Still broadcast between S2-C3 and S4-C5

DISTRIBUTED MEMORY MODEL - MPI

F6

11

Page 12: pCNN: Parallel Convolutional Neural Network ...eigenman/ECE563/ProjectPresentations... S2 feature map  1ax 2 25 W i W 15 5 6 10 21 W 0 1 W i (5X

RESULTS

MPI pthread

0

2

4

6

8

10

12

14

0 20 40 60Sp

eed

up

-->

No of Cores -->

ActualFusedPipeFused

12

0

2

4

6

8

10

12

14

16

0 20 40 60

Spee

du

p -

->

No of Processors -->

Sequential

Fused-Bcast

Fused

PipeFused

Page 13: pCNN: Parallel Convolutional Neural Network ...eigenman/ECE563/ProjectPresentations... S2 feature map  1ax 2 25 W i W 15 5 6 10 21 W 0 1 W i (5X

SUMMARY & FUTURE WORK

Intense Communication between Neurons – Distributed memory model suffers

Loop body of each neuron is small – Fork-Join overheads

Take advantage of “Convolution followed by Sub-sampling”

Pipe-fused expands the parallelism beyond each network layer

Parallelize training phase

OpenMP and MPI 13