Skip to content

Im2col

Olivier BICHLER requested to merge im2col into dev
  • Add Unfold (Im2col) operator;
  • Add Fold (Col2im) operator;
  • Add recipe for converting Conv to Unfold + MatMul + Reshape (Fold not required).

Input graph:

%%{init: {'flowchart': { 'curve': 'monotoneY'}, 'fontFamily': 'Verdana' } }%%
flowchart TB

Producer_3("conv2_w\n<sub><em>(Producer#3)</em></sub>"):::producerCls
Conv_1("conv2\n<sub><em>(Conv#1)</em></sub>")
Conv_0("conv1\n<sub><em>(Conv#0)</em></sub>")
Producer_2("conv1_b\n<sub><em>(Producer#2)</em></sub>"):::producerCls
Producer_1("conv1_w\n<sub><em>(Producer#1)</em></sub>"):::producerCls
Producer_4("conv3_w\n<sub><em>(Producer#4)</em></sub>"):::producerCls
Conv_2("conv3\n<sub><em>(Conv#2)</em></sub>")
Producer_5("conv3_b\n<sub><em>(Producer#5)</em></sub>"):::producerCls
Producer_0("dataProvider\n<sub><em>(Producer#0)</em></sub>"):::producerCls_rootCls
Producer_3-->|"0 [7, 4, 3, 3]&rarr;1"|Conv_1
Conv_1-->|"0 [2, 7, 9, 20]&rarr;0"|Conv_2
Conv_0-->|"0 [2, 4, 11, 22]&rarr;0"|Conv_1
Producer_2-->|"0 [4]&rarr;2"|Conv_0
Producer_1-->|"0 [4, 3, 3, 3]&rarr;1"|Conv_0
Producer_4-->|"0 [10, 7, 1, 1]&rarr;1"|Conv_2
Producer_5-->|"0 [10]&rarr;2"|Conv_2
Producer_0-->|"0 [2, 3, 13, 24]&rarr;0"|Conv_0
input0((in#0)):::inputCls--->|"&rarr;2"|Conv_1
Conv_2--->|"0 [2, 10, 5, 10]&rarr;"|output0((out#0)):::outputCls
classDef inputCls fill:#afa
classDef outputCls fill:#ffa
classDef externalCls fill:#ccc
classDef producerCls fill:#ccf
classDef genericCls fill:#f9f9ff,stroke-width:1px,stroke-dasharray: 5 5
classDef metaCls stroke-width:5px
classDef rootCls stroke:#f00
classDef producerCls_rootCls stroke:#f00,fill:#ccf
classDef genericCls_rootCls stroke:#f00,fill:#f9f9ff,stroke-width:1px,stroke-dasharray: 5 5
classDef metaCls_rootCls stroke:#f00,stroke-width:5px

Output graph:

%%{init: {'flowchart': { 'curve': 'monotoneY'}, 'fontFamily': 'Verdana' } }%%
flowchart TB

Producer_0("dataProvider\n<sub><em>(Producer#0)</em></sub>"):::producerCls_rootCls
MatMul_2("conv3_matmul\n<sub><em>(MatMul#2)</em></sub>")
Producer_7("conv3_reshape_shape_prod\n<sub><em>(Producer#7)</em></sub>"):::producerCls
Reshape_2("conv3_reshape\n<sub><em>(Reshape#2)</em></sub>")
Add_1("conv3_add\n<sub><em>(Add#1)</em></sub>")
Producer_8("conv3_b_reshape_0\n<sub><em>(Producer#8)</em></sub>"):::producerCls
Producer_1("conv1_w_reshape_0\n<sub><em>(Producer#1)</em></sub>"):::producerCls
Unfold_2("conv3_unfold\n<sub><em>(Unfold#2)</em></sub>")
Producer_3("conv1_b_reshape_0\n<sub><em>(Producer#3)</em></sub>"):::producerCls
Unfold_0("conv1_unfold\n<sub><em>(Unfold#0)</em></sub>")
MatMul_0("conv1_matmul\n<sub><em>(MatMul#0)</em></sub>")
Producer_2("conv1_reshape_shape_prod\n<sub><em>(Producer#2)</em></sub>"):::producerCls
Reshape_0("conv1_reshape\n<sub><em>(Reshape#0)</em></sub>")
Add_0("conv1_add\n<sub><em>(Add#0)</em></sub>")
Unfold_1("conv2_unfold\n<sub><em>(Unfold#1)</em></sub>")
MatMul_1("conv2_matmul\n<sub><em>(MatMul#1)</em></sub>")
Producer_5("conv2_reshape_shape_prod\n<sub><em>(Producer#5)</em></sub>"):::producerCls
Reshape_1("conv2_reshape\n<sub><em>(Reshape#1)</em></sub>")
Producer_4("conv2_w_reshape_0\n<sub><em>(Producer#4)</em></sub>"):::producerCls
Producer_6("conv3_w_reshape_0\n<sub><em>(Producer#6)</em></sub>"):::producerCls
Producer_0-->|"0 [2, 3, 13, 24]&rarr;0"|Unfold_0
MatMul_2-->|"0 [2, 10, 50]&rarr;0"|Reshape_2
Producer_7-->|"0 [4]&rarr;1"|Reshape_2
Reshape_2-->|"0 [2, 10, 5, 10]&rarr;0"|Add_1
Producer_8-->|"0 [1, 10, 1, 1]&rarr;1"|Add_1
Producer_1-->|"0 [4, 27]&rarr;0"|MatMul_0
Unfold_2-->|"0 [2, 7, 50]&rarr;1"|MatMul_2
Producer_3-->|"0 [1, 4, 1, 1]&rarr;1"|Add_0
Unfold_0-->|"0 [2, 27, 242]&rarr;1"|MatMul_0
MatMul_0-->|"0 [2, 4, 242]&rarr;0"|Reshape_0
Producer_2-->|"0 [4]&rarr;1"|Reshape_0
Reshape_0-->|"0 [2, 4, 11, 22]&rarr;0"|Add_0
Add_0-->|"0 [2, 4, 11, 22]&rarr;0"|Unfold_1
Unfold_1-->|"0 [2, 36, 180]&rarr;1"|MatMul_1
MatMul_1-->|"0 [2, 7, 180]&rarr;0"|Reshape_1
Producer_5-->|"0 [4]&rarr;1"|Reshape_1
Reshape_1-->|"0 [2, 7, 9, 20]&rarr;0"|Unfold_2
Producer_4-->|"0 [7, 36]&rarr;0"|MatMul_1
Producer_6-->|"0 [10, 7]&rarr;0"|MatMul_2
Add_1--->|"0 [2, 10, 5, 10]&rarr;"|output0((out#0)):::outputCls
classDef inputCls fill:#afa
classDef outputCls fill:#ffa
classDef externalCls fill:#ccc
classDef producerCls fill:#ccf
classDef genericCls fill:#f9f9ff,stroke-width:1px,stroke-dasharray: 5 5
classDef metaCls stroke-width:5px
classDef rootCls stroke:#f00
classDef producerCls_rootCls stroke:#f00,fill:#ccf
classDef genericCls_rootCls stroke:#f00,fill:#f9f9ff,stroke-width:1px,stroke-dasharray: 5 5
classDef metaCls_rootCls stroke:#f00,stroke-width:5px
Edited by Olivier BICHLER

Merge request reports