Skip to content

Commit ac37c3f

Browse files
xiangzhou.yecharlesxzb
authored andcommitted
fix: restrict conv2d hw margin to dw, single core
- restrict non-dw conv2d hw margin to single-core and dilation=1 Change-Id: I832a09c79fcbacaf499a894b85cb5ccd4344c406
1 parent 25af55c commit ac37c3f

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

lib/Dialect/Tpu/Transforms/LayerGroup/LayerGroupUtil.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,8 +1707,10 @@ bool get_backward_slice_info(LgInfo &lg_info, slice_info_t &in_si,
17071707
bool support_hw_margin = module::isBM1684XFamily();
17081708
if (auto conv_op = dyn_cast<tpu::Conv2DOp>(op)) {
17091709
auto attr = getConv2DParam(conv_op);
1710-
bool support_dwconv2d_hw_margin = attr.is_dw;
1711-
support_hw_margin = support_hw_margin && support_dwconv2d_hw_margin;
1710+
if (!attr.is_dw &&
1711+
(module::getCoreNum() > 1 || attr.dh > 1 || attr.dw > 1)) {
1712+
support_hw_margin = false;
1713+
}
17121714
}
17131715
if (shape_secs.dsecs == 1) {
17141716
in_si.d.emplace_back(slice_pair_t(0, d));
@@ -2205,11 +2207,14 @@ static bool backward_update_slice(
22052207
// has no backend support.)
22062208
auto tpukernel_support_HWmargins = [&lg_info](Operation *op) -> bool {
22072209
if (auto conv_op = dyn_cast<tpu::Conv2DOp>(op)) {
2208-
auto attr = getConv2DParam(conv_op);
2209-
bool support_dwconv2d_hw_margin =
2210-
module::isBM1684XFamily() && attr.is_dw;
2211-
if (support_dwconv2d_hw_margin) {
2212-
return true;
2210+
if (module::isBM1684XFamily()) {
2211+
auto attr = getConv2DParam(conv_op);
2212+
if (attr.is_dw) {
2213+
return true;
2214+
}
2215+
if (module::getCoreNum() == 1 && attr.dh == 1 && attr.dw == 1) {
2216+
return true;
2217+
}
22132218
}
22142219
// Note: backend function is incomplete, feel free to complete it
22152220
// Realizing this functionality could lead to significant rewards.

0 commit comments

Comments
 (0)