Skip to content

Commit 2709d18

Browse files
committed
Implement remaining changes
1 parent c0753ea commit 2709d18

File tree

7 files changed

+30
-13
lines changed

7 files changed

+30
-13
lines changed

Deeploy/Targets/Generic/Layers.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -652,15 +652,12 @@ def computeShapes(self, inputShapes: Shape, outputShapes: Shape, operatorReprese
652652
weight_shape = inputShapes[1]
653653

654654
if newOutputShapes and len(newOutputShapes[0]) >= 2:
655+
# For 1D: weight_shape = [C_in, C_out // group, kW]
656+
# For 2D: weight_shape = [C_in, C_out // group, kH, kW]
657+
ch_out = weight_shape[1] * group
655658
if channels_first:
656-
# For 1D: weight_shape = [C_in, C_out // group, kW]
657-
# For 2D: weight_shape = [C_in, C_out // group, kH, kW]
658-
ch_out = weight_shape[1] * group
659659
newOutputShapes[0][1] = ch_out
660660
else:
661-
# For 1D: weight_shape = [C_in, C_out // group, kW]
662-
# For 2D: weight_shape = [C_in, C_out // group, kH, kW]
663-
ch_out = weight_shape[-2] * group
664661
newOutputShapes[0][-1] = ch_out
665662

666663
return newInputShapes, newOutputShapes

Deeploy/Targets/Generic/Parsers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2765,7 +2765,7 @@ def parseNode(self, node: gs.Node) -> bool:
27652765
self.operatorRepresentation['padding_y'] = int(self.operatorRepresentation['pads'][0])
27662766
self.operatorRepresentation['stride_y'] = int(self.operatorRepresentation['strides'][0])
27672767

2768-
return wellFormed
2768+
return ret
27692769

27702770
def parseNodeCtxt(self,
27712771
ctxt: NetworkContext,
@@ -2787,4 +2787,5 @@ def parseNodeCtxt(self,
27872787
"batchOffsetIn"] = self.operatorRepresentation["ch_im_in"] * self.operatorRepresentation["dim_im_in_y"]
27882788
self.operatorRepresentation["batchOffsetOut"] = self.operatorRepresentation[
27892789
"ch_im_out"] * self.operatorRepresentation["dim_im_out_y"]
2790-
return ctxt, True
2790+
return newCtxt, True
2791+
return ctxt, False

Deeploy/Targets/Generic/Templates/ConvTransposeTemplate.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ def alignToContext(self, ctxt: NetworkContext,
7777
${bias}, ${has_bias},
7878
ref_${data_out}_${data_out}, ${dim_im_out_y}
7979
);
80-
80+
81+
ref_${data_out}_${data_in} += ${batchOffsetIn};
82+
ref_${data_out}_${data_out} += ${batchOffsetOut};
8183
}
8284
END_SINGLE_CORE
8385
""")

Deeploy/Targets/Generic/Templates/FloatConvTemplate.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
""")
3232

3333
reference1DTemplate = NodeTemplate("""
34+
<%
35+
batchOffsetIn = ch_im_in * dim_im_in_y
36+
batchOffsetOut = ch_im_out * dim_im_out_y
37+
%>
3438
// 1D FP Conv (Name: ${nodeName}, Op: ${nodeOp})
3539
BEGIN_SINGLE_CORE
3640
${data_in_type.typeName} ref_${data_out}_${data_in} = ${data_in};
@@ -45,6 +49,9 @@
4549
ref_${data_out}_${data_out},
4650
${dim_im_out_y}
4751
);
52+
53+
ref_${data_out}_${data_in} += ${batchOffsetIn};
54+
ref_${data_out}_${data_out} += ${batchOffsetOut};
4855
}
4956
END_SINGLE_CORE
5057
""")

Deeploy/Targets/Generic/Templates/FloatMaxPoolTemplate.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,22 @@
2222
""")
2323

2424
reference1DTemplate = NodeTemplate("""
25+
<%
26+
batchOffsetIn = ch_im_in * dim_im_in_y
27+
batchOffsetOut = ch_im_out * dim_im_out_y
28+
%>
2529
// 1D Float MaxPool (Name: ${nodeName}, Op: ${nodeOp})
2630
BEGIN_SINGLE_CORE
31+
${data_in_type.typeName} ref_${data_out}_${data_in} = ${data_in};
32+
${data_out_type.typeName} ref_${data_out}_${data_out} = ${data_out};
2733
for (uint32_t n=0; n<${batch}; ++n) {
2834
MaxPool1d_fp32_fp32(
29-
${data_in}, ${ch_im_in}, ${dim_im_in_y},
35+
ref_${data_out}_${data_in}, ${ch_im_in}, ${dim_im_in_y},
3036
${dim_kernel_y}, ${stride_y},
31-
${data_out}
37+
ref_${data_out}_${data_out}
3238
);
39+
ref_${data_out}_${data_in} += ${batchOffsetIn};
40+
ref_${data_out}_${data_out} += ${batchOffsetOut};
3341
}
3442
END_SINGLE_CORE
3543
""")

Deeploy/Targets/Generic/Templates/FloatPadTemplate.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@
6565
6666
// 1D Float Pad (Name: ${nodeName}, Op: ${nodeOp})
6767
BEGIN_SINGLE_CORE
68-
memset(${data_out}, 0, ${data_out_size}*sizeof(${data_out_type.referencedType.typeName}));
68+
for (uint32_t i = 0; i < ${data_out_size}; i++) {
69+
${data_out}[i] = ${value};
70+
}
6971
uint32_t xoffset_${data_out}_${data_in};
7072
uint32_t offset_in_${data_out}_${data_in} = 0;
7173

Deeploy/Targets/MemPool/Platform.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
# Fallback bindings from the generic platform
3939
# (they support a wider range of attribute values)
40-
GenericConv1D_Mapper = NodeMapper(GenericConv1DParser(), [BasicConv1DBindings])
40+
GenericConv1D_Mapper = NodeMapper(GenericConv1DParser(), BasicConv1DBindings)
4141
GenericDWConv1D_Mapper = NodeMapper(GenericDWConv1DParser(), [BasicDWConv1DBinding])
4242
GenericConv2D_Mapper = NodeMapper(GenericConv2DParser(), BasicConv2DBindings)
4343
GenericDWConv2D_Mapper = NodeMapper(GenericDWConv2DParser(), BasicDWConv2DBindings)

0 commit comments

Comments
 (0)